import{a as E,b as I}from"./chunk-FQ4ILEWG.js";var R=r=>typeof r.id=="string"&&typeof r.from=="number"&&typeof r.to=="number"&&typeof r.text=="string",_=r=>!r||/^\s*$/.test(r),p={ID:"ID",TIME_LINE:"TIME_LINE",TEXT:"TEXT",MULTI_LINE_TEXT:"MULTI_LINE_TEXT",FIN_ENTRY:"FIN_ENTRY",FINISH:"FINISH"},N=r=>{let n=r.split(":"),e,t,o;return n.length===2?[t,o]=n:[e,t,o]=n,parseInt(o.replace(",",""),10)+parseInt(t,10)*60*1e3+(e?parseInt(e,10):0)*60*60*1e3},O=()=>({start(r){let n=p.ID,e={tokens:r.split(/\n/),pos:0,result:[],current:{}};for(;n!==p.FINISH;){let t=this[n](e);e=t.params,n=t.next}return e.result},[p.ID](r){let{tokens:n,pos:e,current:t}=r;if(n.length<=e)return{next:p.FINISH,params:r};if(_(n[e]))return{next:p.ID,params:I(E({},r),{pos:e+1})};let o=n[e].includes("-->");return t.id=o?"":n[e],{next:p.TIME_LINE,params:I(E({},r),{current:t,tokens:n,pos:o?e:e+1})}},[p.TIME_LINE](r){let{tokens:n,pos:e,current:t}=r,o=n[e],[a,T]=o.split("-->");return t.from=N(a),t.to=N(T),{next:p.TEXT,params:I(E({},r),{current:t,pos:e+1})}},[p.TEXT](r){let{tokens:n,pos:e,current:t}=r;return n.length<=e?{next:p.FINISH,params:r}:(t.text=n[e],{next:p.MULTI_LINE_TEXT,params:I(E({},r),{current:t,pos:e+1})})},[p.MULTI_LINE_TEXT](r){let{tokens:n,pos:e,current:t}=r;return n.length<=e||_(n[e])?{next:p.FIN_ENTRY,params:r}:(t.text=`${t.text}
${n[e]}`,{next:p.MULTI_LINE_TEXT,params:I(E({},r),{current:t,pos:e+1})})},[p.FIN_ENTRY](r){let{pos:n,current:e,result:t}=r;if(R(e))t.push(e);else throw new Error(`Parsing error current not complete ${JSON.stringify(e)}`);return{next:p.ID,params:I(E({},r),{current:{},pos:n+1})}},[p.FINISH](r){return{next:p.FINISH,params:r}}}),c=r=>({entries:O().start(r)}),s={HEADER:"HEADER",ID:"ID",TIME_LINE:"TIME_LINE",ID_OR_NOTE_OR_STYLE_OR_REGION:"ID_OR_NOTE_OR_STYLE_OR_REGION",STYLE:"STYLE",NOTE:"NOTE",REGION:"REGION",LEGACY_HEADER:"LEGACY_HEADER",TEXT:"TEXT",MULTI_LINE_TEXT:"MULTI_LINE_TEXT",FIN_ENTRY:"FIN_ENTRY",FINISH:"FINISH"},u=r=>{let n=r.split(":"),e,t,o;return n.length===2?[t,o]=n:[e,t,o]=n,parseInt(o.replace(".",""),10)+parseInt(t,10)*60*1e3+(e?parseInt(e,10):0)*60*60*1e3},L=()=>({start(r){let n=s.HEADER,e={tokens:r.split(/\n/),pos:0,result:[],current:{}};for(;n!==s.FINISH;){let t=this[n](e);e=t.params,n=t.next}return e.result},[s.HEADER](r){return{next:s.LEGACY_HEADER,params:I(E({},r),{pos:r.pos+1})}},[s.LEGACY_HEADER](r){let{tokens:n,pos:e}=r;return n.length<=e?{next:s.FINISH,params:r}:n[e].includes(":")&&!n[e].includes("-->")?{next:s.LEGACY_HEADER,params:I(E({},r),{pos:e+1})}:{next:s.ID_OR_NOTE_OR_STYLE_OR_REGION,params:r}},[s.ID_OR_NOTE_OR_STYLE_OR_REGION](r){let{tokens:n,pos:e}=r;return n.length<=e?{next:s.FINISH,params:r}:_(n[e])?{next:s.ID_OR_NOTE_OR_STYLE_OR_REGION,params:I(E({},r),{pos:e+1})}:n[e].toUpperCase().includes("NOTE")?{next:s.NOTE,params:r}:n[e].toUpperCase().includes("STYLE")?{next:s.STYLE,params:r}:n[e].toUpperCase().includes("REGION")?{next:s.REGION,params:r}:{next:s.ID,params:r}},[s.STYLE](r){let{tokens:n,pos:e}=r;return _(n[e])?{next:s.ID_OR_NOTE_OR_STYLE_OR_REGION,params:I(E({},r),{pos:e+1})}:{next:s.STYLE,params:I(E({},r),{pos:e+1})}},[s.NOTE](r){let{tokens:n,pos:e}=r;return _(n[e])?{next:s.ID_OR_NOTE_OR_STYLE_OR_REGION,params:I(E({},r),{pos:e+1})}:{next:s.STYLE,params:I(E({},r),{pos:e+1})}},[s.REGION](r){let{tokens:n,pos:e}=r;return _(n[e])?{next:s.ID_OR_NOTE_OR_STYLE_OR_REGION,params:I(E({},r),{pos:e+1})}:{next:s.REGION,params:I(E({},r),{pos:e+1})}},[s.ID](r){let{tokens:n,pos:e,current:t}=r;if(n.length<=e)return{next:s.FINISH,params:r};if(_(n[e]))return{next:s.ID,params:I(E({},r),{pos:e+1})};let o=n[e].includes("-->");return t.id=o?"":n[e],{next:s.TIME_LINE,params:I(E({},r),{current:t,tokens:n,pos:o?e:e+1})}},[s.TIME_LINE](r){let{tokens:n,pos:e,current:t}=r,o=n[e],[a,T]=o.split("-->");return t.from=u(a),t.to=u(T),{next:s.TEXT,params:I(E({},r),{current:t,pos:e+1})}},[s.TEXT](r){let{tokens:n,pos:e,current:t}=r;return n.length<=e?{next:s.FINISH,params:r}:(t.text=n[e],{next:s.MULTI_LINE_TEXT,params:I(E({},r),{current:t,pos:e+1})})},[s.MULTI_LINE_TEXT](r){let{tokens:n,pos:e,current:t}=r;return n.length<=e||_(n[e])?{next:s.FIN_ENTRY,params:r}:(t.text=`${t.text}
${n[e]}`,{next:s.MULTI_LINE_TEXT,params:I(E({},r),{current:t,pos:e+1})})},[s.FIN_ENTRY](r){let{pos:n,current:e,result:t}=r;if(R(e))t.push(e);else throw new Error(`Parsing error current not complete ${JSON.stringify(e)}`);return{next:s.ID_OR_NOTE_OR_STYLE_OR_REGION,params:I(E({},r),{current:{},pos:n+1})}},[s.FINISH](r){return{next:s.FINISH,params:r}}}),x=r=>({entries:L().start(r)}),m=r=>r.startsWith("WEBVTT")?x(r):c(r);export{m as a};
/**i18n:93ef1b86561141301263c1f349fa8abb749523958c3a6dfaf46ed36d22b0a506*/
//# sourceMappingURL=chunk-CS5MH4M6.js.map
