@kinxcdn/commerce-player 1.7.3-alpha.0 → 1.7.3-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commerce-player.min.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/index.d.ts +10 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -37,4 +37,4 @@ var Jr={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24
|
|
|
37
37
|
*
|
|
38
38
|
* This source code is licensed under the ISC license.
|
|
39
39
|
* See the LICENSE file in the root directory of this source tree.
|
|
40
|
-
*/function ki(t,r=[]){let i=[];const n=()=>{const r=i.map(t=>e.createContext(t));return function(i){const n=i?.[t]||r;return e.useMemo(()=>({[`__scope${t}`]:{...i,[t]:n}}),[i,n])}};return n.scopeName=t,[function(r,n){const s=e.createContext(n),a=i.length;i=[...i,n];const o=r=>{const{scope:i,children:n,...o}=r,l=i?.[t]?.[a]||s,c=e.useMemo(()=>o,Object.values(o));return b(l.Provider,{value:c,children:n})};return o.displayName=r+"Provider",[o,function(i,o){const l=o?.[t]?.[a]||s,c=e.useContext(l);if(c)return c;if(void 0!==n)return n;throw new Error(`\`${i}\` must be used within \`${r}\``)}]},Ii(n,...r)]}function Ii(...t){const r=t[0];if(1===t.length)return r;const i=()=>{const i=t.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(t){const n=i.reduce((e,{useScope:r,scopeName:i})=>({...e,...r(t)[`__scope${i}`]}),{});return e.useMemo(()=>({[`__scope${r.scopeName}`]:n}),[n])}};return i.scopeName=r.scopeName,i}function Li(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function Ri(...e){return t=>{let r=!1;const i=e.map(e=>{const i=Li(e,t);return r||"function"!=typeof i||(r=!0),i});if(r)return()=>{for(let t=0;t<i.length;t++){const r=i[t];"function"==typeof r?r():Li(e[t],null)}}}}function Pi(...t){return e.useCallback(Ri(...t),t)}var Ci=e.forwardRef((t,r)=>{const{children:i,...n}=t,s=e.Children.toArray(i),a=s.find(Oi);if(a){const t=a.props.children,i=s.map(r=>r===a?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:r);return b(Di,{...n,ref:r,children:e.isValidElement(t)?e.cloneElement(t,void 0,i):null})}return b(Di,{...n,ref:r,children:i})});Ci.displayName="Slot";var Di=e.forwardRef((t,r)=>{const{children:i,...n}=t;if(e.isValidElement(i)){const t=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;if(r)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r)return e.props.ref;return e.props.ref||e.ref}(i),s=function(e,t){const r={...t};for(const i in t){const n=e[i],s=t[i];/^on[A-Z]/.test(i)?n&&s?r[i]=(...e)=>{s(...e),n(...e)}:n&&(r[i]=n):"style"===i?r[i]={...n,...s}:"className"===i&&(r[i]=[n,s].filter(Boolean).join(" "))}return{...e,...r}}(n,i.props);return i.type!==e.Fragment&&(s.ref=r?Ri(r,t):t),e.cloneElement(i,s)}return e.Children.count(i)>1?e.Children.only(null):null});Di.displayName="SlotClone";var _i=({children:e})=>b(E,{children:e});function Oi(t){return e.isValidElement(t)&&t.type===_i}function Mi(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function Ni(...e){return t=>{let r=!1;const i=e.map(e=>{const i=Mi(e,t);return r||"function"!=typeof i||(r=!0),i});if(r)return()=>{for(let t=0;t<i.length;t++){const r=i[t];"function"==typeof r?r():Mi(e[t],null)}}}}function Fi(e,t,{checkForDefaultPrevented:r=!0}={}){return function(i){if(e?.(i),!1===r||!i.defaultPrevented)return t?.(i)}}function $i(t){const r=e.useRef(t);return e.useEffect(()=>{r.current=t}),e.useMemo(()=>(...e)=>r.current?.(...e),[])}function Bi({prop:t,defaultProp:r,onChange:i=()=>{}}){const[n,s]=function({defaultProp:t,onChange:r}){const i=e.useState(t),[n]=i,s=e.useRef(n),a=$i(r);return e.useEffect(()=>{s.current!==n&&(a(n),s.current=n)},[n,s,a]),i}({defaultProp:r,onChange:i}),a=void 0!==t,o=a?t:n,l=$i(i);return[o,e.useCallback(e=>{if(a){const r="function"==typeof e?e(t):e;r!==t&&l(r)}else s(e)},[a,t,s,l])]}var Ui=e.forwardRef((t,r)=>{const{children:i,...n}=t,s=e.Children.toArray(i),a=s.find(ji);if(a){const t=a.props.children,i=s.map(r=>r===a?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:r);return b(zi,{...n,ref:r,children:e.isValidElement(t)?e.cloneElement(t,void 0,i):null})}return b(zi,{...n,ref:r,children:i})});Ui.displayName="Slot";var zi=e.forwardRef((t,r)=>{const{children:i,...n}=t;if(e.isValidElement(i)){const t=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;if(r)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r)return e.props.ref;return e.props.ref||e.ref}(i),s=function(e,t){const r={...t};for(const i in t){const n=e[i],s=t[i];/^on[A-Z]/.test(i)?n&&s?r[i]=(...e)=>{s(...e),n(...e)}:n&&(r[i]=n):"style"===i?r[i]={...n,...s}:"className"===i&&(r[i]=[n,s].filter(Boolean).join(" "))}return{...e,...r}}(n,i.props);return i.type!==e.Fragment&&(s.ref=r?Ni(r,t):t),e.cloneElement(i,s)}return e.Children.count(i)>1?e.Children.only(null):null});zi.displayName="SlotClone";var Gi=({children:e})=>b(E,{children:e});function ji(t){return e.isValidElement(t)&&t.type===Gi}var Hi=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"].reduce((t,r)=>{const i=e.forwardRef((e,t)=>{const{asChild:i,...n}=e,s=i?Ui:r;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),b(s,{...n,ref:t})});return i.displayName=`Primitive.${r}`,{...t,[r]:i}},{}),Vi=Boolean(globalThis?.document)?e.useLayoutEffect:()=>{};function Wi(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function Yi(...e){return t=>{let r=!1;const i=e.map(e=>{const i=Wi(e,t);return r||"function"!=typeof i||(r=!0),i});if(r)return()=>{for(let t=0;t<i.length;t++){const r=i[t];"function"==typeof r?r():Wi(e[t],null)}}}}var Ki=e.forwardRef((t,r)=>{const{children:i,...n}=t,s=e.Children.toArray(i),a=s.find(Qi);if(a){const t=a.props.children,i=s.map(r=>r===a?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:r);return b(qi,{...n,ref:r,children:e.isValidElement(t)?e.cloneElement(t,void 0,i):null})}return b(qi,{...n,ref:r,children:i})});Ki.displayName="Slot";var qi=e.forwardRef((t,r)=>{const{children:i,...n}=t;if(e.isValidElement(i)){const t=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;if(r)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r)return e.props.ref;return e.props.ref||e.ref}(i),s=function(e,t){const r={...t};for(const i in t){const n=e[i],s=t[i];/^on[A-Z]/.test(i)?n&&s?r[i]=(...e)=>{s(...e),n(...e)}:n&&(r[i]=n):"style"===i?r[i]={...n,...s}:"className"===i&&(r[i]=[n,s].filter(Boolean).join(" "))}return{...e,...r}}(n,i.props);return i.type!==e.Fragment&&(s.ref=r?Yi(r,t):t),e.cloneElement(i,s)}return e.Children.count(i)>1?e.Children.only(null):null});qi.displayName="SlotClone";var Xi=({children:e})=>b(E,{children:e});function Qi(t){return e.isValidElement(t)&&t.type===Xi}var Zi=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"].reduce((t,r)=>{const i=e.forwardRef((e,t)=>{const{asChild:i,...n}=e,s=i?Ki:r;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),b(s,{...n,ref:t})});return i.displayName=`Primitive.${r}`,{...t,[r]:i}},{});function Ji(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function en(...t){return e.useCallback(function(...e){return t=>{let r=!1;const i=e.map(e=>{const i=Ji(e,t);return r||"function"!=typeof i||(r=!0),i});if(r)return()=>{for(let t=0;t<i.length;t++){const r=i[t];"function"==typeof r?r():Ji(e[t],null)}}}}(...t),t)}var tn=Boolean(globalThis?.document)?e.useLayoutEffect:()=>{};var rn=t=>{const{present:r,children:i}=t,n=function(t){const[r,i]=e.useState(),n=e.useRef({}),s=e.useRef(t),a=e.useRef("none"),o=t?"mounted":"unmounted",[l,c]=function(t,r){return e.useReducer((e,t)=>r[e][t]??e,t)}(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return e.useEffect(()=>{const e=nn(n.current);a.current="mounted"===l?e:"none"},[l]),tn(()=>{const e=n.current,r=s.current;if(r!==t){const i=a.current,n=nn(e);if(t)c("MOUNT");else if("none"===n||"none"===e?.display)c("UNMOUNT");else{c(r&&i!==n?"ANIMATION_OUT":"UNMOUNT")}s.current=t}},[t,c]),tn(()=>{if(r){let e;const t=r.ownerDocument.defaultView??window,i=i=>{const a=nn(n.current).includes(i.animationName);if(i.target===r&&a&&(c("ANIMATION_END"),!s.current)){const i=r.style.animationFillMode;r.style.animationFillMode="forwards",e=t.setTimeout(()=>{"forwards"===r.style.animationFillMode&&(r.style.animationFillMode=i)})}},o=e=>{e.target===r&&(a.current=nn(n.current))};return r.addEventListener("animationstart",o),r.addEventListener("animationcancel",i),r.addEventListener("animationend",i),()=>{t.clearTimeout(e),r.removeEventListener("animationstart",o),r.removeEventListener("animationcancel",i),r.removeEventListener("animationend",i)}}c("ANIMATION_END")},[r,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:e.useCallback(e=>{e&&(n.current=getComputedStyle(e)),i(e)},[])}}(r),s="function"==typeof i?i({present:n.isPresent}):e.Children.only(i),a=en(n.ref,function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;if(r)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r)return e.props.ref;return e.props.ref||e.ref}(s));return"function"==typeof i||n.isPresent?e.cloneElement(s,{ref:a}):null};function nn(e){return e?.animationName||"none"}rn.displayName="Presence";var sn=Boolean(globalThis?.document)?e.useLayoutEffect:()=>{},an=e["useId".toString()]||(()=>{}),on=0;function ln(t){const[r,i]=e.useState(an());return sn(()=>{i(e=>e??String(on++))},[t]),r?`radix-${r}`:""}var cn="Collapsible",[dn,un]=ki(cn),[hn,fn]=dn(cn),pn=e.forwardRef((t,r)=>{const{__scopeCollapsible:i,open:n,defaultOpen:s,disabled:a,onOpenChange:o,...l}=t,[c=!1,d]=Bi({prop:n,defaultProp:s,onChange:o});return b(hn,{scope:i,disabled:a,contentId:ln(),open:c,onOpenToggle:e.useCallback(()=>d(e=>!e),[d]),children:b(Zi.div,{"data-state":En(c),"data-disabled":a?"":void 0,...l,ref:r})})});pn.displayName=cn;var mn="CollapsibleTrigger",gn=e.forwardRef((e,t)=>{const{__scopeCollapsible:r,...i}=e,n=fn(mn,r);return b(Zi.button,{type:"button","aria-controls":n.contentId,"aria-expanded":n.open||!1,"data-state":En(n.open),"data-disabled":n.disabled?"":void 0,disabled:n.disabled,...i,ref:t,onClick:Fi(e.onClick,n.onOpenToggle)})});gn.displayName=mn;var vn="CollapsibleContent",yn=e.forwardRef((e,t)=>{const{forceMount:r,...i}=e,n=fn(vn,e.__scopeCollapsible);return b(rn,{present:r||n.open,children:({present:e})=>b(bn,{...i,ref:t,present:e})})});yn.displayName=vn;var bn=e.forwardRef((t,r)=>{const{__scopeCollapsible:i,present:n,children:s,...a}=t,o=fn(vn,i),[l,c]=e.useState(n),d=e.useRef(null),u=function(...t){return e.useCallback(Yi(...t),t)}(r,d),h=e.useRef(0),f=h.current,p=e.useRef(0),m=p.current,g=o.open||l,v=e.useRef(g),y=e.useRef(void 0);return e.useEffect(()=>{const e=requestAnimationFrame(()=>v.current=!1);return()=>cancelAnimationFrame(e)},[]),Vi(()=>{const e=d.current;if(e){y.current=y.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration="0s",e.style.animationName="none";const t=e.getBoundingClientRect();h.current=t.height,p.current=t.width,v.current||(e.style.transitionDuration=y.current.transitionDuration,e.style.animationName=y.current.animationName),c(n)}},[o.open,n]),b(Zi.div,{"data-state":En(o.open),"data-disabled":o.disabled?"":void 0,id:o.contentId,hidden:!g,...a,ref:u,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...t.style},children:g&&s})});function En(e){return e?"open":"closed"}var wn=pn,Sn=gn,Tn=yn,xn=e.createContext(void 0);var An="Accordion",kn=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[In,Ln,Rn]=function(e){const r=e+"CollectionProvider",[i,n]=ki(r),[s,a]=i(r,{collectionRef:{current:null},itemMap:new Map}),o=e=>{const{scope:r,children:i}=e,n=t.useRef(null),a=t.useRef(new Map).current;return b(s,{scope:r,itemMap:a,collectionRef:n,children:i})};o.displayName=r;const l=e+"CollectionSlot",c=t.forwardRef((e,t)=>{const{scope:r,children:i}=e,n=Pi(t,a(l,r).collectionRef);return b(Ci,{ref:n,children:i})});c.displayName=l;const d=e+"CollectionItemSlot",u="data-radix-collection-item",h=t.forwardRef((e,r)=>{const{scope:i,children:n,...s}=e,o=t.useRef(null),l=Pi(r,o),c=a(d,i);return t.useEffect(()=>(c.itemMap.set(o,{ref:o,...s}),()=>{c.itemMap.delete(o)})),b(Ci,{[u]:"",ref:l,children:n})});return h.displayName=d,[{Provider:o,Slot:c,ItemSlot:h},function(r){const i=a(e+"CollectionConsumer",r),n=t.useCallback(()=>{const e=i.collectionRef.current;if(!e)return[];const t=Array.from(e.querySelectorAll(`[${u}]`)),r=Array.from(i.itemMap.values()).sort((e,r)=>t.indexOf(e.ref.current)-t.indexOf(r.ref.current));return r},[i.collectionRef,i.itemMap]);return n},n]}(An),[Pn,Cn]=ki(An,[Rn,un]),Dn=un(),_n=t.forwardRef((e,t)=>{const{type:r,...i}=e,n=i,s=i;return b(In.Provider,{scope:e.__scopeAccordion,children:"multiple"===r?b(Bn,{...s,ref:t}):b($n,{...n,ref:t})})});_n.displayName=An;var[On,Mn]=Pn(An),[Nn,Fn]=Pn(An,{collapsible:!1}),$n=t.forwardRef((e,r)=>{const{value:i,defaultValue:n,onValueChange:s=()=>{},collapsible:a=!1,...o}=e,[l,c]=Bi({prop:i,defaultProp:n,onChange:s});return b(On,{scope:e.__scopeAccordion,value:l?[l]:[],onItemOpen:c,onItemClose:t.useCallback(()=>a&&c(""),[a,c]),children:b(Nn,{scope:e.__scopeAccordion,collapsible:a,children:b(Gn,{...o,ref:r})})})}),Bn=t.forwardRef((e,r)=>{const{value:i,defaultValue:n,onValueChange:s=()=>{},...a}=e,[o=[],l]=Bi({prop:i,defaultProp:n,onChange:s}),c=t.useCallback(e=>l((t=[])=>[...t,e]),[l]),d=t.useCallback(e=>l((t=[])=>t.filter(t=>t!==e)),[l]);return b(On,{scope:e.__scopeAccordion,value:o,onItemOpen:c,onItemClose:d,children:b(Nn,{scope:e.__scopeAccordion,collapsible:!0,children:b(Gn,{...a,ref:r})})})}),[Un,zn]=Pn(An),Gn=t.forwardRef((r,i)=>{const{__scopeAccordion:n,disabled:s,dir:a,orientation:o="vertical",...l}=r,c=function(...t){return e.useCallback(Ni(...t),t)}(t.useRef(null),i),d=Ln(n),u="ltr"===function(t){const r=e.useContext(xn);return t||r||"ltr"}(a),h=Fi(r.onKeyDown,e=>{if(!kn.includes(e.key))return;const t=e.target,r=d().filter(e=>!e.ref.current?.disabled),i=r.findIndex(e=>e.ref.current===t),n=r.length;if(-1===i)return;e.preventDefault();let s=i;const a=n-1,l=()=>{s=i+1,s>a&&(s=0)},c=()=>{s=i-1,s<0&&(s=a)};switch(e.key){case"Home":s=0;break;case"End":s=a;break;case"ArrowRight":"horizontal"===o&&(u?l():c());break;case"ArrowDown":"vertical"===o&&l();break;case"ArrowLeft":"horizontal"===o&&(u?c():l());break;case"ArrowUp":"vertical"===o&&c()}const h=s%n;r[h].ref.current?.focus()});return b(Un,{scope:n,disabled:s,direction:a,orientation:o,children:b(In.Slot,{scope:n,children:b(Hi.div,{...l,"data-orientation":o,ref:c,onKeyDown:s?void 0:h})})})}),jn="AccordionItem",[Hn,Vn]=Pn(jn),Wn=t.forwardRef((e,t)=>{const{__scopeAccordion:r,value:i,...n}=e,s=zn(jn,r),a=Mn(jn,r),o=Dn(r),l=ln(),c=i&&a.value.includes(i)||!1,d=s.disabled||e.disabled;return b(Hn,{scope:r,open:c,disabled:d,triggerId:l,children:b(wn,{"data-orientation":s.orientation,"data-state":Jn(c),...o,...n,ref:t,disabled:d,open:c,onOpenChange:e=>{e?a.onItemOpen(i):a.onItemClose(i)}})})});Wn.displayName=jn;var Yn="AccordionHeader",Kn=t.forwardRef((e,t)=>{const{__scopeAccordion:r,...i}=e,n=zn(An,r),s=Vn(Yn,r);return b(Hi.h3,{"data-orientation":n.orientation,"data-state":Jn(s.open),"data-disabled":s.disabled?"":void 0,...i,ref:t})});Kn.displayName=Yn;var qn="AccordionTrigger",Xn=t.forwardRef((e,t)=>{const{__scopeAccordion:r,...i}=e,n=zn(An,r),s=Vn(qn,r),a=Fn(qn,r),o=Dn(r);return b(In.ItemSlot,{scope:r,children:b(Sn,{"aria-disabled":s.open&&!a.collapsible||void 0,"data-orientation":n.orientation,id:s.triggerId,...o,...i,ref:t})})});Xn.displayName=qn;var Qn="AccordionContent",Zn=t.forwardRef((e,t)=>{const{__scopeAccordion:r,...i}=e,n=zn(An,r),s=Vn(Qn,r),a=Dn(r);return b(Tn,{role:"region","aria-labelledby":s.triggerId,"data-orientation":n.orientation,...a,...i,ref:t,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...e.style}})});function Jn(e){return e?"open":"closed"}Zn.displayName=Qn;var es=_n,ts=Wn,rs=Kn,is=Xn,ns=Zn;function ss(t){var r=T(t,[]);return e.createElement(es,Object.assign({"data-slot":"accordion"},r))}function as(t){var{className:r}=t,i=T(t,["className"]);return e.createElement(ts,Object.assign({"data-slot":"accordion-item",className:St("border-b last:border-b-0",r)},i))}function os(t){var{className:r,children:i}=t,n=T(t,["className","children"]);return e.createElement(rs,{className:"flex"},e.createElement(is,Object.assign({"data-slot":"accordion-trigger",className:St("focus-visible:border-ring focus-visible:ring-ring/50 flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180",r)},n),i,e.createElement(ri,{className:"text-muted-foreground pointer-events-none size-4 shrink-0 translate-y-0.5 transition-transform duration-200"})))}function ls(t){var{className:r,children:i}=t,n=T(t,["className","children"]);return e.createElement(ns,Object.assign({"data-slot":"accordion-content",className:"data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm"},n),e.createElement("div",{className:St("pt-0 pb-4",r)},i))}const cs=({title:e,content:r})=>t.createElement(ss,{style:{borderRadius:"0.625rem"},type:"single",collapsible:!0,className:"bg-white px-4",defaultValue:"item"},t.createElement(as,{value:"item"},t.createElement(os,{className:""},e),t.createElement(ls,{className:"text-gray-700"},r))),ds=({logo:e})=>t.createElement("div",{className:"w-full bg-zinc-700 h-[60px] flex"},t.createElement("div",{className:"my-0 mx-auto w-full px-[24px] flex items-center justify-between"},e?t.createElement("div",{className:"h-10 max-w-[160px]"},t.createElement("img",{src:e.thumbPath,alt:e.logoName,width:100,height:100,className:"object-contain w-full h-full"})):t.createElement("div",null),t.createElement("button",{className:"text-white cursor-pointer"},t.createElement(gi,null)))),us=e=>{const{isPreview:r,playerSettings:i,shortform:{description:n,productsInfo:s,logo:a,brand:o,title:l,shortsId:c},player:d}=e;return t.createElement("div",{className:"w-full h-full bg-[#f4f4f4] overflow-scroll"},t.createElement(ds,{logo:a}),t.createElement("div",{className:" w-full h-full flex justify-between p-10 gap-10"},t.createElement("div",{className:""},t.createElement("div",{className:"flex gap-4 w-full mb-2 h-[125px] flex-col"},o?t.createElement("div",{className:"items-center flex gap-3"},o.thumbPath&&t.createElement("div",{className:"w-16 h-16 bg-white rounded-full border "},t.createElement("img",{src:o.thumbPath,alt:o.brandName,width:100,height:100,className:"object-contain w-full h-full rounded-full"})),t.createElement("div",null,t.createElement("p",null,o.brandName),t.createElement("p",{className:"text-lg font-semibold"},l))):t.createElement("p",{className:"text-xl font-semibold"},l),t.createElement(vi,null)),t.createElement("div",{className:"w-full pb-10 flex gap-4 justify-center"},t.createElement("div",{className:"flex gap-3"},d),t.createElement("div",{className:"flex flex-col gap-4 justify-end"},t.createElement(Ti,{rounded:!0,shortsId:c,isPreview:r}),t.createElement(xi,{rounded:!0}),t.createElement(Ai,{rounded:!0})))),t.createElement("div",{className:"flex flex-col gap-4 max-w-[40%]"},n&&t.createElement(cs,{title:"숏클립 안내",content:t.createElement("p",{className:"font-medium"},n)}),t.createElement(cs,{title:"상품 목록",content:t.createElement(t.Fragment,null,t.createElement("div",{className:"max-h-[300px] overflow-y-auto font-medium"},s.map((e,i)=>t.createElement(t.Fragment,null,t.createElement(Ei,{product:e,contentId:c,isPreview:r}),i!==s.length-1&&t.createElement("div",{className:"h-1 w-full border-t my-2"})))),t.createElement("button",{className:"w-full mt-3 border rounded py-2 px-4 cursor-pointer",disabled:!(null==s?void 0:s.length)},"상품 전체 보기"))}),i.comment&&t.createElement(cs,{title:"댓글",content:t.createElement(wi,null)}))))};function hs(e){return null!==e&&"object"==typeof e&&"constructor"in e&&e.constructor===Object}function fs(e,t){void 0===e&&(e={}),void 0===t&&(t={}),Object.keys(t).forEach(r=>{void 0===e[r]?e[r]=t[r]:hs(t[r])&&hs(e[r])&&Object.keys(t[r]).length>0&&fs(e[r],t[r])})}const ps={body:{},addEventListener(){},removeEventListener(){},activeElement:{blur(){},nodeName:""},querySelector:()=>null,querySelectorAll:()=>[],getElementById:()=>null,createEvent:()=>({initEvent(){}}),createElement:()=>({children:[],childNodes:[],style:{},setAttribute(){},getElementsByTagName:()=>[]}),createElementNS:()=>({}),importNode:()=>null,location:{hash:"",host:"",hostname:"",href:"",origin:"",pathname:"",protocol:"",search:""}};function ms(){const e="undefined"!=typeof document?document:{};return fs(e,ps),e}const gs={document:ps,navigator:{userAgent:""},location:{hash:"",host:"",hostname:"",href:"",origin:"",pathname:"",protocol:"",search:""},history:{replaceState(){},pushState(){},go(){},back(){}},CustomEvent:function(){return this},addEventListener(){},removeEventListener(){},getComputedStyle:()=>({getPropertyValue:()=>""}),Image(){},Date(){},screen:{},setTimeout(){},clearTimeout(){},matchMedia:()=>({}),requestAnimationFrame:e=>"undefined"==typeof setTimeout?(e(),null):setTimeout(e,0),cancelAnimationFrame(e){"undefined"!=typeof setTimeout&&clearTimeout(e)}};function vs(){const e="undefined"!=typeof window?window:{};return fs(e,gs),e}function ys(e,t){return void 0===t&&(t=0),setTimeout(e,t)}function bs(){return Date.now()}function Es(e,t){void 0===t&&(t="x");const r=vs();let i,n,s;const a=function(e){const t=vs();let r;return t.getComputedStyle&&(r=t.getComputedStyle(e,null)),!r&&e.currentStyle&&(r=e.currentStyle),r||(r=e.style),r}(e);return r.WebKitCSSMatrix?(n=a.transform||a.webkitTransform,n.split(",").length>6&&(n=n.split(", ").map(e=>e.replace(",",".")).join(", ")),s=new r.WebKitCSSMatrix("none"===n?"":n)):(s=a.MozTransform||a.OTransform||a.MsTransform||a.msTransform||a.transform||a.getPropertyValue("transform").replace("translate(","matrix(1, 0, 0, 1,"),i=s.toString().split(",")),"x"===t&&(n=r.WebKitCSSMatrix?s.m41:16===i.length?parseFloat(i[12]):parseFloat(i[4])),"y"===t&&(n=r.WebKitCSSMatrix?s.m42:16===i.length?parseFloat(i[13]):parseFloat(i[5])),n||0}function ws(e){return"object"==typeof e&&null!==e&&e.constructor&&"Object"===Object.prototype.toString.call(e).slice(8,-1)}function Ss(e){return"undefined"!=typeof window&&void 0!==window.HTMLElement?e instanceof HTMLElement:e&&(1===e.nodeType||11===e.nodeType)}function Ts(){const e=Object(arguments.length<=0?void 0:arguments[0]),t=["__proto__","constructor","prototype"];for(let r=1;r<arguments.length;r+=1){const i=r<0||arguments.length<=r?void 0:arguments[r];if(null!=i&&!Ss(i)){const r=Object.keys(Object(i)).filter(e=>t.indexOf(e)<0);for(let t=0,n=r.length;t<n;t+=1){const n=r[t],s=Object.getOwnPropertyDescriptor(i,n);void 0!==s&&s.enumerable&&(ws(e[n])&&ws(i[n])?i[n].__swiper__?e[n]=i[n]:Ts(e[n],i[n]):!ws(e[n])&&ws(i[n])?(e[n]={},i[n].__swiper__?e[n]=i[n]:Ts(e[n],i[n])):e[n]=i[n])}}}return e}function xs(e,t,r){e.style.setProperty(t,r)}function As(e){let{swiper:t,targetPosition:r,side:i}=e;const n=vs(),s=-t.translate;let a,o=null;const l=t.params.speed;t.wrapperEl.style.scrollSnapType="none",n.cancelAnimationFrame(t.cssModeFrameID);const c=r>s?"next":"prev",d=(e,t)=>"next"===c&&e>=t||"prev"===c&&e<=t,u=()=>{a=(new Date).getTime(),null===o&&(o=a);const e=Math.max(Math.min((a-o)/l,1),0),c=.5-Math.cos(e*Math.PI)/2;let h=s+c*(r-s);if(d(h,r)&&(h=r),t.wrapperEl.scrollTo({[i]:h}),d(h,r))return t.wrapperEl.style.overflow="hidden",t.wrapperEl.style.scrollSnapType="",setTimeout(()=>{t.wrapperEl.style.overflow="",t.wrapperEl.scrollTo({[i]:h})}),void n.cancelAnimationFrame(t.cssModeFrameID);t.cssModeFrameID=n.requestAnimationFrame(u)};u()}function ks(e){return e.querySelector(".swiper-slide-transform")||e.shadowRoot&&e.shadowRoot.querySelector(".swiper-slide-transform")||e}function Is(e,t){void 0===t&&(t="");const r=[...e.children];return e instanceof HTMLSlotElement&&r.push(...e.assignedElements()),t?r.filter(e=>e.matches(t)):r}function Ls(e){try{return void console.warn(e)}catch(e){}}function Rs(e,t){void 0===t&&(t=[]);const r=document.createElement(e);return r.classList.add(...Array.isArray(t)?t:function(e){return void 0===e&&(e=""),e.trim().split(" ").filter(e=>!!e.trim())}(t)),r}function Ps(e,t){return vs().getComputedStyle(e,null).getPropertyValue(t)}function Cs(e){let t,r=e;if(r){for(t=0;null!==(r=r.previousSibling);)1===r.nodeType&&(t+=1);return t}}function Ds(e,t,r){const i=vs();return e["width"===t?"offsetWidth":"offsetHeight"]+parseFloat(i.getComputedStyle(e,null).getPropertyValue("width"===t?"margin-right":"margin-top"))+parseFloat(i.getComputedStyle(e,null).getPropertyValue("width"===t?"margin-left":"margin-bottom"))}function _s(e){return(Array.isArray(e)?e:[e]).filter(e=>!!e)}let Os,Ms,Ns;function Fs(){return Os||(Os=function(){const e=vs(),t=ms();return{smoothScroll:t.documentElement&&t.documentElement.style&&"scrollBehavior"in t.documentElement.style,touch:!!("ontouchstart"in e||e.DocumentTouch&&t instanceof e.DocumentTouch)}}()),Os}function $s(e){return void 0===e&&(e={}),Ms||(Ms=function(e){let{userAgent:t}=void 0===e?{}:e;const r=Fs(),i=vs(),n=i.navigator.platform,s=t||i.navigator.userAgent,a={ios:!1,android:!1},o=i.screen.width,l=i.screen.height,c=s.match(/(Android);?[\s\/]+([\d.]+)?/);let d=s.match(/(iPad).*OS\s([\d_]+)/);const u=s.match(/(iPod)(.*OS\s([\d_]+))?/),h=!d&&s.match(/(iPhone\sOS|iOS)\s([\d_]+)/),f="Win32"===n;let p="MacIntel"===n;return!d&&p&&r.touch&&["1024x1366","1366x1024","834x1194","1194x834","834x1112","1112x834","768x1024","1024x768","820x1180","1180x820","810x1080","1080x810"].indexOf(`${o}x${l}`)>=0&&(d=s.match(/(Version)\/([\d.]+)/),d||(d=[0,1,"13_0_0"]),p=!1),c&&!f&&(a.os="android",a.android=!0),(d||h||u)&&(a.os="ios",a.ios=!0),a}(e)),Ms}function Bs(){return Ns||(Ns=function(){const e=vs(),t=$s();let r=!1;function i(){const t=e.navigator.userAgent.toLowerCase();return t.indexOf("safari")>=0&&t.indexOf("chrome")<0&&t.indexOf("android")<0}if(i()){const t=String(e.navigator.userAgent);if(t.includes("Version/")){const[e,i]=t.split("Version/")[1].split(" ")[0].split(".").map(e=>Number(e));r=e<16||16===e&&i<2}}const n=/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(e.navigator.userAgent),s=i();return{isSafari:r||s,needPerspectiveFix:r,need3dFix:s||n&&t.ios,isWebView:n}}()),Ns}var Us={on(e,t,r){const i=this;if(!i.eventsListeners||i.destroyed)return i;if("function"!=typeof t)return i;const n=r?"unshift":"push";return e.split(" ").forEach(e=>{i.eventsListeners[e]||(i.eventsListeners[e]=[]),i.eventsListeners[e][n](t)}),i},once(e,t,r){const i=this;if(!i.eventsListeners||i.destroyed)return i;if("function"!=typeof t)return i;function n(){i.off(e,n),n.__emitterProxy&&delete n.__emitterProxy;for(var r=arguments.length,s=new Array(r),a=0;a<r;a++)s[a]=arguments[a];t.apply(i,s)}return n.__emitterProxy=t,i.on(e,n,r)},onAny(e,t){const r=this;if(!r.eventsListeners||r.destroyed)return r;if("function"!=typeof e)return r;const i=t?"unshift":"push";return r.eventsAnyListeners.indexOf(e)<0&&r.eventsAnyListeners[i](e),r},offAny(e){const t=this;if(!t.eventsListeners||t.destroyed)return t;if(!t.eventsAnyListeners)return t;const r=t.eventsAnyListeners.indexOf(e);return r>=0&&t.eventsAnyListeners.splice(r,1),t},off(e,t){const r=this;return!r.eventsListeners||r.destroyed?r:r.eventsListeners?(e.split(" ").forEach(e=>{void 0===t?r.eventsListeners[e]=[]:r.eventsListeners[e]&&r.eventsListeners[e].forEach((i,n)=>{(i===t||i.__emitterProxy&&i.__emitterProxy===t)&&r.eventsListeners[e].splice(n,1)})}),r):r},emit(){const e=this;if(!e.eventsListeners||e.destroyed)return e;if(!e.eventsListeners)return e;let t,r,i;for(var n=arguments.length,s=new Array(n),a=0;a<n;a++)s[a]=arguments[a];"string"==typeof s[0]||Array.isArray(s[0])?(t=s[0],r=s.slice(1,s.length),i=e):(t=s[0].events,r=s[0].data,i=s[0].context||e),r.unshift(i);return(Array.isArray(t)?t:t.split(" ")).forEach(t=>{e.eventsAnyListeners&&e.eventsAnyListeners.length&&e.eventsAnyListeners.forEach(e=>{e.apply(i,[t,...r])}),e.eventsListeners&&e.eventsListeners[t]&&e.eventsListeners[t].forEach(e=>{e.apply(i,r)})}),e}};const zs=(e,t,r)=>{t&&!e.classList.contains(r)?e.classList.add(r):!t&&e.classList.contains(r)&&e.classList.remove(r)};const Gs=(e,t,r)=>{t&&!e.classList.contains(r)?e.classList.add(r):!t&&e.classList.contains(r)&&e.classList.remove(r)};const js=(e,t)=>{if(!e||e.destroyed||!e.params)return;const r=t.closest(e.isElement?"swiper-slide":`.${e.params.slideClass}`);if(r){let t=r.querySelector(`.${e.params.lazyPreloaderClass}`);!t&&e.isElement&&(r.shadowRoot?t=r.shadowRoot.querySelector(`.${e.params.lazyPreloaderClass}`):requestAnimationFrame(()=>{r.shadowRoot&&(t=r.shadowRoot.querySelector(`.${e.params.lazyPreloaderClass}`),t&&t.remove())})),t&&t.remove()}},Hs=(e,t)=>{if(!e.slides[t])return;const r=e.slides[t].querySelector('[loading="lazy"]');r&&r.removeAttribute("loading")},Vs=e=>{if(!e||e.destroyed||!e.params)return;let t=e.params.lazyPreloadPrevNext;const r=e.slides.length;if(!r||!t||t<0)return;t=Math.min(t,r);const i="auto"===e.params.slidesPerView?e.slidesPerViewDynamic():Math.ceil(e.params.slidesPerView),n=e.activeIndex;if(e.params.grid&&e.params.grid.rows>1){const r=n,s=[r-t];return s.push(...Array.from({length:t}).map((e,t)=>r+i+t)),void e.slides.forEach((t,r)=>{s.includes(t.column)&&Hs(e,r)})}const s=n+i-1;if(e.params.rewind||e.params.loop)for(let i=n-t;i<=s+t;i+=1){const t=(i%r+r)%r;(t<n||t>s)&&Hs(e,t)}else for(let i=Math.max(n-t,0);i<=Math.min(s+t,r-1);i+=1)i!==n&&(i>s||i<n)&&Hs(e,i)};var Ws={updateSize:function(){const e=this;let t,r;const i=e.el;t=void 0!==e.params.width&&null!==e.params.width?e.params.width:i.clientWidth,r=void 0!==e.params.height&&null!==e.params.height?e.params.height:i.clientHeight,0===t&&e.isHorizontal()||0===r&&e.isVertical()||(t=t-parseInt(Ps(i,"padding-left")||0,10)-parseInt(Ps(i,"padding-right")||0,10),r=r-parseInt(Ps(i,"padding-top")||0,10)-parseInt(Ps(i,"padding-bottom")||0,10),Number.isNaN(t)&&(t=0),Number.isNaN(r)&&(r=0),Object.assign(e,{width:t,height:r,size:e.isHorizontal()?t:r}))},updateSlides:function(){const e=this;function t(t,r){return parseFloat(t.getPropertyValue(e.getDirectionLabel(r))||0)}const r=e.params,{wrapperEl:i,slidesEl:n,size:s,rtlTranslate:a,wrongRTL:o}=e,l=e.virtual&&r.virtual.enabled,c=l?e.virtual.slides.length:e.slides.length,d=Is(n,`.${e.params.slideClass}, swiper-slide`),u=l?e.virtual.slides.length:d.length;let h=[];const f=[],p=[];let m=r.slidesOffsetBefore;"function"==typeof m&&(m=r.slidesOffsetBefore.call(e));let g=r.slidesOffsetAfter;"function"==typeof g&&(g=r.slidesOffsetAfter.call(e));const v=e.snapGrid.length,y=e.slidesGrid.length;let b=r.spaceBetween,E=-m,w=0,S=0;if(void 0===s)return;"string"==typeof b&&b.indexOf("%")>=0?b=parseFloat(b.replace("%",""))/100*s:"string"==typeof b&&(b=parseFloat(b)),e.virtualSize=-b,d.forEach(e=>{a?e.style.marginLeft="":e.style.marginRight="",e.style.marginBottom="",e.style.marginTop=""}),r.centeredSlides&&r.cssMode&&(xs(i,"--swiper-centered-offset-before",""),xs(i,"--swiper-centered-offset-after",""));const T=r.grid&&r.grid.rows>1&&e.grid;let x;T?e.grid.initSlides(d):e.grid&&e.grid.unsetSlides();const A="auto"===r.slidesPerView&&r.breakpoints&&Object.keys(r.breakpoints).filter(e=>void 0!==r.breakpoints[e].slidesPerView).length>0;for(let i=0;i<u;i+=1){let n;if(x=0,d[i]&&(n=d[i]),T&&e.grid.updateSlide(i,n,d),!d[i]||"none"!==Ps(n,"display")){if("auto"===r.slidesPerView){A&&(d[i].style[e.getDirectionLabel("width")]="");const s=getComputedStyle(n),a=n.style.transform,o=n.style.webkitTransform;if(a&&(n.style.transform="none"),o&&(n.style.webkitTransform="none"),r.roundLengths)x=e.isHorizontal()?Ds(n,"width"):Ds(n,"height");else{const e=t(s,"width"),r=t(s,"padding-left"),i=t(s,"padding-right"),a=t(s,"margin-left"),o=t(s,"margin-right"),l=s.getPropertyValue("box-sizing");if(l&&"border-box"===l)x=e+a+o;else{const{clientWidth:t,offsetWidth:s}=n;x=e+r+i+a+o+(s-t)}}a&&(n.style.transform=a),o&&(n.style.webkitTransform=o),r.roundLengths&&(x=Math.floor(x))}else x=(s-(r.slidesPerView-1)*b)/r.slidesPerView,r.roundLengths&&(x=Math.floor(x)),d[i]&&(d[i].style[e.getDirectionLabel("width")]=`${x}px`);d[i]&&(d[i].swiperSlideSize=x),p.push(x),r.centeredSlides?(E=E+x/2+w/2+b,0===w&&0!==i&&(E=E-s/2-b),0===i&&(E=E-s/2-b),Math.abs(E)<.001&&(E=0),r.roundLengths&&(E=Math.floor(E)),S%r.slidesPerGroup===0&&h.push(E),f.push(E)):(r.roundLengths&&(E=Math.floor(E)),(S-Math.min(e.params.slidesPerGroupSkip,S))%e.params.slidesPerGroup===0&&h.push(E),f.push(E),E=E+x+b),e.virtualSize+=x+b,w=x,S+=1}}if(e.virtualSize=Math.max(e.virtualSize,s)+g,a&&o&&("slide"===r.effect||"coverflow"===r.effect)&&(i.style.width=`${e.virtualSize+b}px`),r.setWrapperSize&&(i.style[e.getDirectionLabel("width")]=`${e.virtualSize+b}px`),T&&e.grid.updateWrapperSize(x,h),!r.centeredSlides){const t=[];for(let i=0;i<h.length;i+=1){let n=h[i];r.roundLengths&&(n=Math.floor(n)),h[i]<=e.virtualSize-s&&t.push(n)}h=t,Math.floor(e.virtualSize-s)-Math.floor(h[h.length-1])>1&&h.push(e.virtualSize-s)}if(l&&r.loop){const t=p[0]+b;if(r.slidesPerGroup>1){const i=Math.ceil((e.virtual.slidesBefore+e.virtual.slidesAfter)/r.slidesPerGroup),n=t*r.slidesPerGroup;for(let e=0;e<i;e+=1)h.push(h[h.length-1]+n)}for(let i=0;i<e.virtual.slidesBefore+e.virtual.slidesAfter;i+=1)1===r.slidesPerGroup&&h.push(h[h.length-1]+t),f.push(f[f.length-1]+t),e.virtualSize+=t}if(0===h.length&&(h=[0]),0!==b){const t=e.isHorizontal()&&a?"marginLeft":e.getDirectionLabel("marginRight");d.filter((e,t)=>!(r.cssMode&&!r.loop)||t!==d.length-1).forEach(e=>{e.style[t]=`${b}px`})}if(r.centeredSlides&&r.centeredSlidesBounds){let e=0;p.forEach(t=>{e+=t+(b||0)}),e-=b;const t=e>s?e-s:0;h=h.map(e=>e<=0?-m:e>t?t+g:e)}if(r.centerInsufficientSlides){let e=0;p.forEach(t=>{e+=t+(b||0)}),e-=b;const t=(r.slidesOffsetBefore||0)+(r.slidesOffsetAfter||0);if(e+t<s){const r=(s-e-t)/2;h.forEach((e,t)=>{h[t]=e-r}),f.forEach((e,t)=>{f[t]=e+r})}}if(Object.assign(e,{slides:d,snapGrid:h,slidesGrid:f,slidesSizesGrid:p}),r.centeredSlides&&r.cssMode&&!r.centeredSlidesBounds){xs(i,"--swiper-centered-offset-before",-h[0]+"px"),xs(i,"--swiper-centered-offset-after",e.size/2-p[p.length-1]/2+"px");const t=-e.snapGrid[0],r=-e.slidesGrid[0];e.snapGrid=e.snapGrid.map(e=>e+t),e.slidesGrid=e.slidesGrid.map(e=>e+r)}if(u!==c&&e.emit("slidesLengthChange"),h.length!==v&&(e.params.watchOverflow&&e.checkOverflow(),e.emit("snapGridLengthChange")),f.length!==y&&e.emit("slidesGridLengthChange"),r.watchSlidesProgress&&e.updateSlidesOffset(),e.emit("slidesUpdated"),!(l||r.cssMode||"slide"!==r.effect&&"fade"!==r.effect)){const t=`${r.containerModifierClass}backface-hidden`,i=e.el.classList.contains(t);u<=r.maxBackfaceHiddenSlides?i||e.el.classList.add(t):i&&e.el.classList.remove(t)}},updateAutoHeight:function(e){const t=this,r=[],i=t.virtual&&t.params.virtual.enabled;let n,s=0;"number"==typeof e?t.setTransition(e):!0===e&&t.setTransition(t.params.speed);const a=e=>i?t.slides[t.getSlideIndexByData(e)]:t.slides[e];if("auto"!==t.params.slidesPerView&&t.params.slidesPerView>1)if(t.params.centeredSlides)(t.visibleSlides||[]).forEach(e=>{r.push(e)});else for(n=0;n<Math.ceil(t.params.slidesPerView);n+=1){const e=t.activeIndex+n;if(e>t.slides.length&&!i)break;r.push(a(e))}else r.push(a(t.activeIndex));for(n=0;n<r.length;n+=1)if(void 0!==r[n]){const e=r[n].offsetHeight;s=e>s?e:s}(s||0===s)&&(t.wrapperEl.style.height=`${s}px`)},updateSlidesOffset:function(){const e=this,t=e.slides,r=e.isElement?e.isHorizontal()?e.wrapperEl.offsetLeft:e.wrapperEl.offsetTop:0;for(let i=0;i<t.length;i+=1)t[i].swiperSlideOffset=(e.isHorizontal()?t[i].offsetLeft:t[i].offsetTop)-r-e.cssOverflowAdjustment()},updateSlidesProgress:function(e){void 0===e&&(e=this&&this.translate||0);const t=this,r=t.params,{slides:i,rtlTranslate:n,snapGrid:s}=t;if(0===i.length)return;void 0===i[0].swiperSlideOffset&&t.updateSlidesOffset();let a=-e;n&&(a=e),t.visibleSlidesIndexes=[],t.visibleSlides=[];let o=r.spaceBetween;"string"==typeof o&&o.indexOf("%")>=0?o=parseFloat(o.replace("%",""))/100*t.size:"string"==typeof o&&(o=parseFloat(o));for(let e=0;e<i.length;e+=1){const l=i[e];let c=l.swiperSlideOffset;r.cssMode&&r.centeredSlides&&(c-=i[0].swiperSlideOffset);const d=(a+(r.centeredSlides?t.minTranslate():0)-c)/(l.swiperSlideSize+o),u=(a-s[0]+(r.centeredSlides?t.minTranslate():0)-c)/(l.swiperSlideSize+o),h=-(a-c),f=h+t.slidesSizesGrid[e],p=h>=0&&h<=t.size-t.slidesSizesGrid[e],m=h>=0&&h<t.size-1||f>1&&f<=t.size||h<=0&&f>=t.size;m&&(t.visibleSlides.push(l),t.visibleSlidesIndexes.push(e)),zs(l,m,r.slideVisibleClass),zs(l,p,r.slideFullyVisibleClass),l.progress=n?-d:d,l.originalProgress=n?-u:u}},updateProgress:function(e){const t=this;if(void 0===e){const r=t.rtlTranslate?-1:1;e=t&&t.translate&&t.translate*r||0}const r=t.params,i=t.maxTranslate()-t.minTranslate();let{progress:n,isBeginning:s,isEnd:a,progressLoop:o}=t;const l=s,c=a;if(0===i)n=0,s=!0,a=!0;else{n=(e-t.minTranslate())/i;const r=Math.abs(e-t.minTranslate())<1,o=Math.abs(e-t.maxTranslate())<1;s=r||n<=0,a=o||n>=1,r&&(n=0),o&&(n=1)}if(r.loop){const r=t.getSlideIndexByData(0),i=t.getSlideIndexByData(t.slides.length-1),n=t.slidesGrid[r],s=t.slidesGrid[i],a=t.slidesGrid[t.slidesGrid.length-1],l=Math.abs(e);o=l>=n?(l-n)/a:(l+a-s)/a,o>1&&(o-=1)}Object.assign(t,{progress:n,progressLoop:o,isBeginning:s,isEnd:a}),(r.watchSlidesProgress||r.centeredSlides&&r.autoHeight)&&t.updateSlidesProgress(e),s&&!l&&t.emit("reachBeginning toEdge"),a&&!c&&t.emit("reachEnd toEdge"),(l&&!s||c&&!a)&&t.emit("fromEdge"),t.emit("progress",n)},updateSlidesClasses:function(){const e=this,{slides:t,params:r,slidesEl:i,activeIndex:n}=e,s=e.virtual&&r.virtual.enabled,a=e.grid&&r.grid&&r.grid.rows>1,o=e=>Is(i,`.${r.slideClass}${e}, swiper-slide${e}`)[0];let l,c,d;if(s)if(r.loop){let t=n-e.virtual.slidesBefore;t<0&&(t=e.virtual.slides.length+t),t>=e.virtual.slides.length&&(t-=e.virtual.slides.length),l=o(`[data-swiper-slide-index="${t}"]`)}else l=o(`[data-swiper-slide-index="${n}"]`);else a?(l=t.filter(e=>e.column===n)[0],d=t.filter(e=>e.column===n+1)[0],c=t.filter(e=>e.column===n-1)[0]):l=t[n];l&&(a||(d=function(e,t){const r=[];for(;e.nextElementSibling;){const i=e.nextElementSibling;t?i.matches(t)&&r.push(i):r.push(i),e=i}return r}(l,`.${r.slideClass}, swiper-slide`)[0],r.loop&&!d&&(d=t[0]),c=function(e,t){const r=[];for(;e.previousElementSibling;){const i=e.previousElementSibling;t?i.matches(t)&&r.push(i):r.push(i),e=i}return r}(l,`.${r.slideClass}, swiper-slide`)[0],r.loop&&0===!c&&(c=t[t.length-1]))),t.forEach(e=>{Gs(e,e===l,r.slideActiveClass),Gs(e,e===d,r.slideNextClass),Gs(e,e===c,r.slidePrevClass)}),e.emitSlidesClasses()},updateActiveIndex:function(e){const t=this,r=t.rtlTranslate?t.translate:-t.translate,{snapGrid:i,params:n,activeIndex:s,realIndex:a,snapIndex:o}=t;let l,c=e;const d=e=>{let r=e-t.virtual.slidesBefore;return r<0&&(r=t.virtual.slides.length+r),r>=t.virtual.slides.length&&(r-=t.virtual.slides.length),r};if(void 0===c&&(c=function(e){const{slidesGrid:t,params:r}=e,i=e.rtlTranslate?e.translate:-e.translate;let n;for(let e=0;e<t.length;e+=1)void 0!==t[e+1]?i>=t[e]&&i<t[e+1]-(t[e+1]-t[e])/2?n=e:i>=t[e]&&i<t[e+1]&&(n=e+1):i>=t[e]&&(n=e);return r.normalizeSlideIndex&&(n<0||void 0===n)&&(n=0),n}(t)),i.indexOf(r)>=0)l=i.indexOf(r);else{const e=Math.min(n.slidesPerGroupSkip,c);l=e+Math.floor((c-e)/n.slidesPerGroup)}if(l>=i.length&&(l=i.length-1),c===s&&!t.params.loop)return void(l!==o&&(t.snapIndex=l,t.emit("snapIndexChange")));if(c===s&&t.params.loop&&t.virtual&&t.params.virtual.enabled)return void(t.realIndex=d(c));const u=t.grid&&n.grid&&n.grid.rows>1;let h;if(t.virtual&&n.virtual.enabled&&n.loop)h=d(c);else if(u){const e=t.slides.filter(e=>e.column===c)[0];let r=parseInt(e.getAttribute("data-swiper-slide-index"),10);Number.isNaN(r)&&(r=Math.max(t.slides.indexOf(e),0)),h=Math.floor(r/n.grid.rows)}else if(t.slides[c]){const e=t.slides[c].getAttribute("data-swiper-slide-index");h=e?parseInt(e,10):c}else h=c;Object.assign(t,{previousSnapIndex:o,snapIndex:l,previousRealIndex:a,realIndex:h,previousIndex:s,activeIndex:c}),t.initialized&&Vs(t),t.emit("activeIndexChange"),t.emit("snapIndexChange"),(t.initialized||t.params.runCallbacksOnInit)&&(a!==h&&t.emit("realIndexChange"),t.emit("slideChange"))},updateClickedSlide:function(e,t){const r=this,i=r.params;let n=e.closest(`.${i.slideClass}, swiper-slide`);!n&&r.isElement&&t&&t.length>1&&t.includes(e)&&[...t.slice(t.indexOf(e)+1,t.length)].forEach(e=>{!n&&e.matches&&e.matches(`.${i.slideClass}, swiper-slide`)&&(n=e)});let s,a=!1;if(n)for(let e=0;e<r.slides.length;e+=1)if(r.slides[e]===n){a=!0,s=e;break}if(!n||!a)return r.clickedSlide=void 0,void(r.clickedIndex=void 0);r.clickedSlide=n,r.virtual&&r.params.virtual.enabled?r.clickedIndex=parseInt(n.getAttribute("data-swiper-slide-index"),10):r.clickedIndex=s,i.slideToClickedSlide&&void 0!==r.clickedIndex&&r.clickedIndex!==r.activeIndex&&r.slideToClickedSlide()}};var Ys={getTranslate:function(e){void 0===e&&(e=this.isHorizontal()?"x":"y");const{params:t,rtlTranslate:r,translate:i,wrapperEl:n}=this;if(t.virtualTranslate)return r?-i:i;if(t.cssMode)return i;let s=Es(n,e);return s+=this.cssOverflowAdjustment(),r&&(s=-s),s||0},setTranslate:function(e,t){const r=this,{rtlTranslate:i,params:n,wrapperEl:s,progress:a}=r;let o,l=0,c=0;r.isHorizontal()?l=i?-e:e:c=e,n.roundLengths&&(l=Math.floor(l),c=Math.floor(c)),r.previousTranslate=r.translate,r.translate=r.isHorizontal()?l:c,n.cssMode?s[r.isHorizontal()?"scrollLeft":"scrollTop"]=r.isHorizontal()?-l:-c:n.virtualTranslate||(r.isHorizontal()?l-=r.cssOverflowAdjustment():c-=r.cssOverflowAdjustment(),s.style.transform=`translate3d(${l}px, ${c}px, 0px)`);const d=r.maxTranslate()-r.minTranslate();o=0===d?0:(e-r.minTranslate())/d,o!==a&&r.updateProgress(e),r.emit("setTranslate",r.translate,t)},minTranslate:function(){return-this.snapGrid[0]},maxTranslate:function(){return-this.snapGrid[this.snapGrid.length-1]},translateTo:function(e,t,r,i,n){void 0===e&&(e=0),void 0===t&&(t=this.params.speed),void 0===r&&(r=!0),void 0===i&&(i=!0);const s=this,{params:a,wrapperEl:o}=s;if(s.animating&&a.preventInteractionOnTransition)return!1;const l=s.minTranslate(),c=s.maxTranslate();let d;if(d=i&&e>l?l:i&&e<c?c:e,s.updateProgress(d),a.cssMode){const e=s.isHorizontal();if(0===t)o[e?"scrollLeft":"scrollTop"]=-d;else{if(!s.support.smoothScroll)return As({swiper:s,targetPosition:-d,side:e?"left":"top"}),!0;o.scrollTo({[e?"left":"top"]:-d,behavior:"smooth"})}return!0}return 0===t?(s.setTransition(0),s.setTranslate(d),r&&(s.emit("beforeTransitionStart",t,n),s.emit("transitionEnd"))):(s.setTransition(t),s.setTranslate(d),r&&(s.emit("beforeTransitionStart",t,n),s.emit("transitionStart")),s.animating||(s.animating=!0,s.onTranslateToWrapperTransitionEnd||(s.onTranslateToWrapperTransitionEnd=function(e){s&&!s.destroyed&&e.target===this&&(s.wrapperEl.removeEventListener("transitionend",s.onTranslateToWrapperTransitionEnd),s.onTranslateToWrapperTransitionEnd=null,delete s.onTranslateToWrapperTransitionEnd,s.animating=!1,r&&s.emit("transitionEnd"))}),s.wrapperEl.addEventListener("transitionend",s.onTranslateToWrapperTransitionEnd))),!0}};function Ks(e){let{swiper:t,runCallbacks:r,direction:i,step:n}=e;const{activeIndex:s,previousIndex:a}=t;let o=i;if(o||(o=s>a?"next":s<a?"prev":"reset"),t.emit(`transition${n}`),r&&s!==a){if("reset"===o)return void t.emit(`slideResetTransition${n}`);t.emit(`slideChangeTransition${n}`),"next"===o?t.emit(`slideNextTransition${n}`):t.emit(`slidePrevTransition${n}`)}}var qs={setTransition:function(e,t){const r=this;r.params.cssMode||(r.wrapperEl.style.transitionDuration=`${e}ms`,r.wrapperEl.style.transitionDelay=0===e?"0ms":""),r.emit("setTransition",e,t)},transitionStart:function(e,t){void 0===e&&(e=!0);const r=this,{params:i}=r;i.cssMode||(i.autoHeight&&r.updateAutoHeight(),Ks({swiper:r,runCallbacks:e,direction:t,step:"Start"}))},transitionEnd:function(e,t){void 0===e&&(e=!0);const r=this,{params:i}=r;r.animating=!1,i.cssMode||(r.setTransition(0),Ks({swiper:r,runCallbacks:e,direction:t,step:"End"}))}};var Xs={slideTo:function(e,t,r,i,n){void 0===e&&(e=0),void 0===r&&(r=!0),"string"==typeof e&&(e=parseInt(e,10));const s=this;let a=e;a<0&&(a=0);const{params:o,snapGrid:l,slidesGrid:c,previousIndex:d,activeIndex:u,rtlTranslate:h,wrapperEl:f,enabled:p}=s;if(!p&&!i&&!n||s.destroyed||s.animating&&o.preventInteractionOnTransition)return!1;void 0===t&&(t=s.params.speed);const m=Math.min(s.params.slidesPerGroupSkip,a);let g=m+Math.floor((a-m)/s.params.slidesPerGroup);g>=l.length&&(g=l.length-1);const v=-l[g];if(o.normalizeSlideIndex)for(let e=0;e<c.length;e+=1){const t=-Math.floor(100*v),r=Math.floor(100*c[e]),i=Math.floor(100*c[e+1]);void 0!==c[e+1]?t>=r&&t<i-(i-r)/2?a=e:t>=r&&t<i&&(a=e+1):t>=r&&(a=e)}if(s.initialized&&a!==u){if(!s.allowSlideNext&&(h?v>s.translate&&v>s.minTranslate():v<s.translate&&v<s.minTranslate()))return!1;if(!s.allowSlidePrev&&v>s.translate&&v>s.maxTranslate()&&(u||0)!==a)return!1}let y;a!==(d||0)&&r&&s.emit("beforeSlideChangeStart"),s.updateProgress(v),y=a>u?"next":a<u?"prev":"reset";const b=s.virtual&&s.params.virtual.enabled;if(!(b&&n)&&(h&&-v===s.translate||!h&&v===s.translate))return s.updateActiveIndex(a),o.autoHeight&&s.updateAutoHeight(),s.updateSlidesClasses(),"slide"!==o.effect&&s.setTranslate(v),"reset"!==y&&(s.transitionStart(r,y),s.transitionEnd(r,y)),!1;if(o.cssMode){const e=s.isHorizontal(),r=h?v:-v;if(0===t)b&&(s.wrapperEl.style.scrollSnapType="none",s._immediateVirtual=!0),b&&!s._cssModeVirtualInitialSet&&s.params.initialSlide>0?(s._cssModeVirtualInitialSet=!0,requestAnimationFrame(()=>{f[e?"scrollLeft":"scrollTop"]=r})):f[e?"scrollLeft":"scrollTop"]=r,b&&requestAnimationFrame(()=>{s.wrapperEl.style.scrollSnapType="",s._immediateVirtual=!1});else{if(!s.support.smoothScroll)return As({swiper:s,targetPosition:r,side:e?"left":"top"}),!0;f.scrollTo({[e?"left":"top"]:r,behavior:"smooth"})}return!0}return s.setTransition(t),s.setTranslate(v),s.updateActiveIndex(a),s.updateSlidesClasses(),s.emit("beforeTransitionStart",t,i),s.transitionStart(r,y),0===t?s.transitionEnd(r,y):s.animating||(s.animating=!0,s.onSlideToWrapperTransitionEnd||(s.onSlideToWrapperTransitionEnd=function(e){s&&!s.destroyed&&e.target===this&&(s.wrapperEl.removeEventListener("transitionend",s.onSlideToWrapperTransitionEnd),s.onSlideToWrapperTransitionEnd=null,delete s.onSlideToWrapperTransitionEnd,s.transitionEnd(r,y))}),s.wrapperEl.addEventListener("transitionend",s.onSlideToWrapperTransitionEnd)),!0},slideToLoop:function(e,t,r,i){if(void 0===e&&(e=0),void 0===r&&(r=!0),"string"==typeof e){e=parseInt(e,10)}const n=this;if(n.destroyed)return;void 0===t&&(t=n.params.speed);const s=n.grid&&n.params.grid&&n.params.grid.rows>1;let a=e;if(n.params.loop)if(n.virtual&&n.params.virtual.enabled)a+=n.virtual.slidesBefore;else{let e;if(s){const t=a*n.params.grid.rows;e=n.slides.filter(e=>1*e.getAttribute("data-swiper-slide-index")===t)[0].column}else e=n.getSlideIndexByData(a);const t=s?Math.ceil(n.slides.length/n.params.grid.rows):n.slides.length,{centeredSlides:r}=n.params;let o=n.params.slidesPerView;"auto"===o?o=n.slidesPerViewDynamic():(o=Math.ceil(parseFloat(n.params.slidesPerView,10)),r&&o%2==0&&(o+=1));let l=t-e<o;if(r&&(l=l||e<Math.ceil(o/2)),i&&r&&"auto"!==n.params.slidesPerView&&!s&&(l=!1),l){const i=r?e<n.activeIndex?"prev":"next":e-n.activeIndex-1<n.params.slidesPerView?"next":"prev";n.loopFix({direction:i,slideTo:!0,activeSlideIndex:"next"===i?e+1:e-t+1,slideRealIndex:"next"===i?n.realIndex:void 0})}if(s){const e=a*n.params.grid.rows;a=n.slides.filter(t=>1*t.getAttribute("data-swiper-slide-index")===e)[0].column}else a=n.getSlideIndexByData(a)}return requestAnimationFrame(()=>{n.slideTo(a,t,r,i)}),n},slideNext:function(e,t,r){void 0===t&&(t=!0);const i=this,{enabled:n,params:s,animating:a}=i;if(!n||i.destroyed)return i;void 0===e&&(e=i.params.speed);let o=s.slidesPerGroup;"auto"===s.slidesPerView&&1===s.slidesPerGroup&&s.slidesPerGroupAuto&&(o=Math.max(i.slidesPerViewDynamic("current",!0),1));const l=i.activeIndex<s.slidesPerGroupSkip?1:o,c=i.virtual&&s.virtual.enabled;if(s.loop){if(a&&!c&&s.loopPreventsSliding)return!1;if(i.loopFix({direction:"next"}),i._clientLeft=i.wrapperEl.clientLeft,i.activeIndex===i.slides.length-1&&s.cssMode)return requestAnimationFrame(()=>{i.slideTo(i.activeIndex+l,e,t,r)}),!0}return s.rewind&&i.isEnd?i.slideTo(0,e,t,r):i.slideTo(i.activeIndex+l,e,t,r)},slidePrev:function(e,t,r){void 0===t&&(t=!0);const i=this,{params:n,snapGrid:s,slidesGrid:a,rtlTranslate:o,enabled:l,animating:c}=i;if(!l||i.destroyed)return i;void 0===e&&(e=i.params.speed);const d=i.virtual&&n.virtual.enabled;if(n.loop){if(c&&!d&&n.loopPreventsSliding)return!1;i.loopFix({direction:"prev"}),i._clientLeft=i.wrapperEl.clientLeft}function u(e){return e<0?-Math.floor(Math.abs(e)):Math.floor(e)}const h=u(o?i.translate:-i.translate),f=s.map(e=>u(e));let p=s[f.indexOf(h)-1];if(void 0===p&&n.cssMode){let e;s.forEach((t,r)=>{h>=t&&(e=r)}),void 0!==e&&(p=s[e>0?e-1:e])}let m=0;if(void 0!==p&&(m=a.indexOf(p),m<0&&(m=i.activeIndex-1),"auto"===n.slidesPerView&&1===n.slidesPerGroup&&n.slidesPerGroupAuto&&(m=m-i.slidesPerViewDynamic("previous",!0)+1,m=Math.max(m,0))),n.rewind&&i.isBeginning){const n=i.params.virtual&&i.params.virtual.enabled&&i.virtual?i.virtual.slides.length-1:i.slides.length-1;return i.slideTo(n,e,t,r)}return n.loop&&0===i.activeIndex&&n.cssMode?(requestAnimationFrame(()=>{i.slideTo(m,e,t,r)}),!0):i.slideTo(m,e,t,r)},slideReset:function(e,t,r){void 0===t&&(t=!0);const i=this;if(!i.destroyed)return void 0===e&&(e=i.params.speed),i.slideTo(i.activeIndex,e,t,r)},slideToClosest:function(e,t,r,i){void 0===t&&(t=!0),void 0===i&&(i=.5);const n=this;if(n.destroyed)return;void 0===e&&(e=n.params.speed);let s=n.activeIndex;const a=Math.min(n.params.slidesPerGroupSkip,s),o=a+Math.floor((s-a)/n.params.slidesPerGroup),l=n.rtlTranslate?n.translate:-n.translate;if(l>=n.snapGrid[o]){const e=n.snapGrid[o];l-e>(n.snapGrid[o+1]-e)*i&&(s+=n.params.slidesPerGroup)}else{const e=n.snapGrid[o-1];l-e<=(n.snapGrid[o]-e)*i&&(s-=n.params.slidesPerGroup)}return s=Math.max(s,0),s=Math.min(s,n.slidesGrid.length-1),n.slideTo(s,e,t,r)},slideToClickedSlide:function(){const e=this;if(e.destroyed)return;const{params:t,slidesEl:r}=e,i="auto"===t.slidesPerView?e.slidesPerViewDynamic():t.slidesPerView;let n,s=e.clickedIndex;const a=e.isElement?"swiper-slide":`.${t.slideClass}`;if(t.loop){if(e.animating)return;n=parseInt(e.clickedSlide.getAttribute("data-swiper-slide-index"),10),t.centeredSlides?s<e.loopedSlides-i/2||s>e.slides.length-e.loopedSlides+i/2?(e.loopFix(),s=e.getSlideIndex(Is(r,`${a}[data-swiper-slide-index="${n}"]`)[0]),ys(()=>{e.slideTo(s)})):e.slideTo(s):s>e.slides.length-i?(e.loopFix(),s=e.getSlideIndex(Is(r,`${a}[data-swiper-slide-index="${n}"]`)[0]),ys(()=>{e.slideTo(s)})):e.slideTo(s)}else e.slideTo(s)}};var Qs={loopCreate:function(e){const t=this,{params:r,slidesEl:i}=t;if(!r.loop||t.virtual&&t.params.virtual.enabled)return;const n=()=>{Is(i,`.${r.slideClass}, swiper-slide`).forEach((e,t)=>{e.setAttribute("data-swiper-slide-index",t)})},s=t.grid&&r.grid&&r.grid.rows>1,a=r.slidesPerGroup*(s?r.grid.rows:1),o=t.slides.length%a!==0,l=s&&t.slides.length%r.grid.rows!==0,c=e=>{for(let i=0;i<e;i+=1){const e=t.isElement?Rs("swiper-slide",[r.slideBlankClass]):Rs("div",[r.slideClass,r.slideBlankClass]);t.slidesEl.append(e)}};if(o){if(r.loopAddBlankSlides){c(a-t.slides.length%a),t.recalcSlides(),t.updateSlides()}else Ls("Swiper Loop Warning: The number of slides is not even to slidesPerGroup, loop mode may not function properly. You need to add more slides (or make duplicates, or empty slides)");n()}else if(l){if(r.loopAddBlankSlides){c(r.grid.rows-t.slides.length%r.grid.rows),t.recalcSlides(),t.updateSlides()}else Ls("Swiper Loop Warning: The number of slides is not even to grid.rows, loop mode may not function properly. You need to add more slides (or make duplicates, or empty slides)");n()}else n();t.loopFix({slideRealIndex:e,direction:r.centeredSlides?void 0:"next"})},loopFix:function(e){let{slideRealIndex:t,slideTo:r=!0,direction:i,setTranslate:n,activeSlideIndex:s,byController:a,byMousewheel:o}=void 0===e?{}:e;const l=this;if(!l.params.loop)return;l.emit("beforeLoopFix");const{slides:c,allowSlidePrev:d,allowSlideNext:u,slidesEl:h,params:f}=l,{centeredSlides:p}=f;if(l.allowSlidePrev=!0,l.allowSlideNext=!0,l.virtual&&f.virtual.enabled)return r&&(f.centeredSlides||0!==l.snapIndex?f.centeredSlides&&l.snapIndex<f.slidesPerView?l.slideTo(l.virtual.slides.length+l.snapIndex,0,!1,!0):l.snapIndex===l.snapGrid.length-1&&l.slideTo(l.virtual.slidesBefore,0,!1,!0):l.slideTo(l.virtual.slides.length,0,!1,!0)),l.allowSlidePrev=d,l.allowSlideNext=u,void l.emit("loopFix");let m=f.slidesPerView;"auto"===m?m=l.slidesPerViewDynamic():(m=Math.ceil(parseFloat(f.slidesPerView,10)),p&&m%2==0&&(m+=1));const g=f.slidesPerGroupAuto?m:f.slidesPerGroup;let v=g;v%g!==0&&(v+=g-v%g),v+=f.loopAdditionalSlides,l.loopedSlides=v;const y=l.grid&&f.grid&&f.grid.rows>1;c.length<m+v?Ls("Swiper Loop Warning: The number of slides is not enough for loop mode, it will be disabled and not function properly. You need to add more slides (or make duplicates) or lower the values of slidesPerView and slidesPerGroup parameters"):y&&"row"===f.grid.fill&&Ls("Swiper Loop Warning: Loop mode is not compatible with grid.fill = `row`");const b=[],E=[];let w=l.activeIndex;void 0===s?s=l.getSlideIndex(c.filter(e=>e.classList.contains(f.slideActiveClass))[0]):w=s;const S="next"===i||!i,T="prev"===i||!i;let x=0,A=0;const k=y?Math.ceil(c.length/f.grid.rows):c.length,I=(y?c[s].column:s)+(p&&void 0===n?-m/2+.5:0);if(I<v){x=Math.max(v-I,g);for(let e=0;e<v-I;e+=1){const t=e-Math.floor(e/k)*k;if(y){const e=k-t-1;for(let t=c.length-1;t>=0;t-=1)c[t].column===e&&b.push(t)}else b.push(k-t-1)}}else if(I+m>k-v){A=Math.max(I-(k-2*v),g);for(let e=0;e<A;e+=1){const t=e-Math.floor(e/k)*k;y?c.forEach((e,r)=>{e.column===t&&E.push(r)}):E.push(t)}}if(l.__preventObserver__=!0,requestAnimationFrame(()=>{l.__preventObserver__=!1}),T&&b.forEach(e=>{c[e].swiperLoopMoveDOM=!0,h.prepend(c[e]),c[e].swiperLoopMoveDOM=!1}),S&&E.forEach(e=>{c[e].swiperLoopMoveDOM=!0,h.append(c[e]),c[e].swiperLoopMoveDOM=!1}),l.recalcSlides(),"auto"===f.slidesPerView?l.updateSlides():y&&(b.length>0&&T||E.length>0&&S)&&l.slides.forEach((e,t)=>{l.grid.updateSlide(t,e,l.slides)}),f.watchSlidesProgress&&l.updateSlidesOffset(),r)if(b.length>0&&T){if(void 0===t){const e=l.slidesGrid[w],t=l.slidesGrid[w+x]-e;o?l.setTranslate(l.translate-t):(l.slideTo(w+Math.ceil(x),0,!1,!0),n&&(l.touchEventsData.startTranslate=l.touchEventsData.startTranslate-t,l.touchEventsData.currentTranslate=l.touchEventsData.currentTranslate-t))}else if(n){const e=y?b.length/f.grid.rows:b.length;l.slideTo(l.activeIndex+e,0,!1,!0),l.touchEventsData.currentTranslate=l.translate}}else if(E.length>0&&S)if(void 0===t){const e=l.slidesGrid[w],t=l.slidesGrid[w-A]-e;o?l.setTranslate(l.translate-t):(l.slideTo(w-A,0,!1,!0),n&&(l.touchEventsData.startTranslate=l.touchEventsData.startTranslate-t,l.touchEventsData.currentTranslate=l.touchEventsData.currentTranslate-t))}else{const e=y?E.length/f.grid.rows:E.length;l.slideTo(l.activeIndex-e,0,!1,!0)}if(l.allowSlidePrev=d,l.allowSlideNext=u,l.controller&&l.controller.control&&!a){const e={slideRealIndex:t,direction:i,setTranslate:n,activeSlideIndex:s,byController:!0};Array.isArray(l.controller.control)?l.controller.control.forEach(t=>{!t.destroyed&&t.params.loop&&t.loopFix({...e,slideTo:t.params.slidesPerView===f.slidesPerView&&r})}):l.controller.control instanceof l.constructor&&l.controller.control.params.loop&&l.controller.control.loopFix({...e,slideTo:l.controller.control.params.slidesPerView===f.slidesPerView&&r})}l.emit("loopFix")},loopDestroy:function(){const e=this,{params:t,slidesEl:r}=e;if(!t.loop||e.virtual&&e.params.virtual.enabled)return;e.recalcSlides();const i=[];e.slides.forEach(e=>{const t=void 0===e.swiperSlideIndex?1*e.getAttribute("data-swiper-slide-index"):e.swiperSlideIndex;i[t]=e}),e.slides.forEach(e=>{e.removeAttribute("data-swiper-slide-index")}),i.forEach(e=>{r.append(e)}),e.recalcSlides(),e.slideTo(e.realIndex,0)}};function Zs(e,t,r){const i=vs(),{params:n}=e,s=n.edgeSwipeDetection,a=n.edgeSwipeThreshold;return!s||!(r<=a||r>=i.innerWidth-a)||"prevent"===s&&(t.preventDefault(),!0)}function Js(e){const t=this,r=ms();let i=e;i.originalEvent&&(i=i.originalEvent);const n=t.touchEventsData;if("pointerdown"===i.type){if(null!==n.pointerId&&n.pointerId!==i.pointerId)return;n.pointerId=i.pointerId}else"touchstart"===i.type&&1===i.targetTouches.length&&(n.touchId=i.targetTouches[0].identifier);if("touchstart"===i.type)return void Zs(t,i,i.targetTouches[0].pageX);const{params:s,touches:a,enabled:o}=t;if(!o)return;if(!s.simulateTouch&&"mouse"===i.pointerType)return;if(t.animating&&s.preventInteractionOnTransition)return;!t.animating&&s.cssMode&&s.loop&&t.loopFix();let l=i.target;if("wrapper"===s.touchEventsTarget&&!function(e,t){const r=t.contains(e);if(!r&&t instanceof HTMLSlotElement)return[...t.assignedElements()].includes(e);return r}(l,t.wrapperEl))return;if("which"in i&&3===i.which)return;if("button"in i&&i.button>0)return;if(n.isTouched&&n.isMoved)return;const c=!!s.noSwipingClass&&""!==s.noSwipingClass,d=i.composedPath?i.composedPath():i.path;c&&i.target&&i.target.shadowRoot&&d&&(l=d[0]);const u=s.noSwipingSelector?s.noSwipingSelector:`.${s.noSwipingClass}`,h=!(!i.target||!i.target.shadowRoot);if(s.noSwiping&&(h?function(e,t){return void 0===t&&(t=this),function t(r){if(!r||r===ms()||r===vs())return null;r.assignedSlot&&(r=r.assignedSlot);const i=r.closest(e);return i||r.getRootNode?i||t(r.getRootNode().host):null}(t)}(u,l):l.closest(u)))return void(t.allowClick=!0);if(s.swipeHandler&&!l.closest(s.swipeHandler))return;a.currentX=i.pageX,a.currentY=i.pageY;const f=a.currentX,p=a.currentY;if(!Zs(t,i,f))return;Object.assign(n,{isTouched:!0,isMoved:!1,allowTouchCallbacks:!0,isScrolling:void 0,startMoving:void 0}),a.startX=f,a.startY=p,n.touchStartTime=bs(),t.allowClick=!0,t.updateSize(),t.swipeDirection=void 0,s.threshold>0&&(n.allowThresholdMove=!1);let m=!0;l.matches(n.focusableElements)&&(m=!1,"SELECT"===l.nodeName&&(n.isTouched=!1)),r.activeElement&&r.activeElement.matches(n.focusableElements)&&r.activeElement!==l&&("mouse"===i.pointerType||"mouse"!==i.pointerType&&!l.matches(n.focusableElements))&&r.activeElement.blur();const g=m&&t.allowTouchMove&&s.touchStartPreventDefault;!s.touchStartForcePreventDefault&&!g||l.isContentEditable||i.preventDefault(),s.freeMode&&s.freeMode.enabled&&t.freeMode&&t.animating&&!s.cssMode&&t.freeMode.onTouchStart(),t.emit("touchStart",i)}function ea(e){const t=ms(),r=this,i=r.touchEventsData,{params:n,touches:s,rtlTranslate:a,enabled:o}=r;if(!o)return;if(!n.simulateTouch&&"mouse"===e.pointerType)return;let l,c=e;if(c.originalEvent&&(c=c.originalEvent),"pointermove"===c.type){if(null!==i.touchId)return;if(c.pointerId!==i.pointerId)return}if("touchmove"===c.type){if(l=[...c.changedTouches].filter(e=>e.identifier===i.touchId)[0],!l||l.identifier!==i.touchId)return}else l=c;if(!i.isTouched)return void(i.startMoving&&i.isScrolling&&r.emit("touchMoveOpposite",c));const d=l.pageX,u=l.pageY;if(c.preventedByNestedSwiper)return s.startX=d,void(s.startY=u);if(!r.allowTouchMove)return c.target.matches(i.focusableElements)||(r.allowClick=!1),void(i.isTouched&&(Object.assign(s,{startX:d,startY:u,currentX:d,currentY:u}),i.touchStartTime=bs()));if(n.touchReleaseOnEdges&&!n.loop)if(r.isVertical()){if(u<s.startY&&r.translate<=r.maxTranslate()||u>s.startY&&r.translate>=r.minTranslate())return i.isTouched=!1,void(i.isMoved=!1)}else if(d<s.startX&&r.translate<=r.maxTranslate()||d>s.startX&&r.translate>=r.minTranslate())return;if(t.activeElement&&t.activeElement.matches(i.focusableElements)&&t.activeElement!==c.target&&"mouse"!==c.pointerType&&t.activeElement.blur(),t.activeElement&&c.target===t.activeElement&&c.target.matches(i.focusableElements))return i.isMoved=!0,void(r.allowClick=!1);i.allowTouchCallbacks&&r.emit("touchMove",c),s.previousX=s.currentX,s.previousY=s.currentY,s.currentX=d,s.currentY=u;const h=s.currentX-s.startX,f=s.currentY-s.startY;if(r.params.threshold&&Math.sqrt(h**2+f**2)<r.params.threshold)return;if(void 0===i.isScrolling){let e;r.isHorizontal()&&s.currentY===s.startY||r.isVertical()&&s.currentX===s.startX?i.isScrolling=!1:h*h+f*f>=25&&(e=180*Math.atan2(Math.abs(f),Math.abs(h))/Math.PI,i.isScrolling=r.isHorizontal()?e>n.touchAngle:90-e>n.touchAngle)}if(i.isScrolling&&r.emit("touchMoveOpposite",c),void 0===i.startMoving&&(s.currentX===s.startX&&s.currentY===s.startY||(i.startMoving=!0)),i.isScrolling||"touchmove"===c.type&&i.preventTouchMoveFromPointerMove)return void(i.isTouched=!1);if(!i.startMoving)return;r.allowClick=!1,!n.cssMode&&c.cancelable&&c.preventDefault(),n.touchMoveStopPropagation&&!n.nested&&c.stopPropagation();let p=r.isHorizontal()?h:f,m=r.isHorizontal()?s.currentX-s.previousX:s.currentY-s.previousY;n.oneWayMovement&&(p=Math.abs(p)*(a?1:-1),m=Math.abs(m)*(a?1:-1)),s.diff=p,p*=n.touchRatio,a&&(p=-p,m=-m);const g=r.touchesDirection;r.swipeDirection=p>0?"prev":"next",r.touchesDirection=m>0?"prev":"next";const v=r.params.loop&&!n.cssMode,y="next"===r.touchesDirection&&r.allowSlideNext||"prev"===r.touchesDirection&&r.allowSlidePrev;if(!i.isMoved){if(v&&y&&r.loopFix({direction:r.swipeDirection}),i.startTranslate=r.getTranslate(),r.setTransition(0),r.animating){const e=new window.CustomEvent("transitionend",{bubbles:!0,cancelable:!0,detail:{bySwiperTouchMove:!0}});r.wrapperEl.dispatchEvent(e)}i.allowMomentumBounce=!1,!n.grabCursor||!0!==r.allowSlideNext&&!0!==r.allowSlidePrev||r.setGrabCursor(!0),r.emit("sliderFirstMove",c)}if((new Date).getTime(),i.isMoved&&i.allowThresholdMove&&g!==r.touchesDirection&&v&&y&&Math.abs(p)>=1)return Object.assign(s,{startX:d,startY:u,currentX:d,currentY:u,startTranslate:i.currentTranslate}),i.loopSwapReset=!0,void(i.startTranslate=i.currentTranslate);r.emit("sliderMove",c),i.isMoved=!0,i.currentTranslate=p+i.startTranslate;let b=!0,E=n.resistanceRatio;if(n.touchReleaseOnEdges&&(E=0),p>0?(v&&y&&i.allowThresholdMove&&i.currentTranslate>(n.centeredSlides?r.minTranslate()-r.slidesSizesGrid[r.activeIndex+1]-("auto"!==n.slidesPerView&&r.slides.length-n.slidesPerView>=2?r.slidesSizesGrid[r.activeIndex+1]+r.params.spaceBetween:0)-r.params.spaceBetween:r.minTranslate())&&r.loopFix({direction:"prev",setTranslate:!0,activeSlideIndex:0}),i.currentTranslate>r.minTranslate()&&(b=!1,n.resistance&&(i.currentTranslate=r.minTranslate()-1+(-r.minTranslate()+i.startTranslate+p)**E))):p<0&&(v&&y&&i.allowThresholdMove&&i.currentTranslate<(n.centeredSlides?r.maxTranslate()+r.slidesSizesGrid[r.slidesSizesGrid.length-1]+r.params.spaceBetween+("auto"!==n.slidesPerView&&r.slides.length-n.slidesPerView>=2?r.slidesSizesGrid[r.slidesSizesGrid.length-1]+r.params.spaceBetween:0):r.maxTranslate())&&r.loopFix({direction:"next",setTranslate:!0,activeSlideIndex:r.slides.length-("auto"===n.slidesPerView?r.slidesPerViewDynamic():Math.ceil(parseFloat(n.slidesPerView,10)))}),i.currentTranslate<r.maxTranslate()&&(b=!1,n.resistance&&(i.currentTranslate=r.maxTranslate()+1-(r.maxTranslate()-i.startTranslate-p)**E))),b&&(c.preventedByNestedSwiper=!0),!r.allowSlideNext&&"next"===r.swipeDirection&&i.currentTranslate<i.startTranslate&&(i.currentTranslate=i.startTranslate),!r.allowSlidePrev&&"prev"===r.swipeDirection&&i.currentTranslate>i.startTranslate&&(i.currentTranslate=i.startTranslate),r.allowSlidePrev||r.allowSlideNext||(i.currentTranslate=i.startTranslate),n.threshold>0){if(!(Math.abs(p)>n.threshold||i.allowThresholdMove))return void(i.currentTranslate=i.startTranslate);if(!i.allowThresholdMove)return i.allowThresholdMove=!0,s.startX=s.currentX,s.startY=s.currentY,i.currentTranslate=i.startTranslate,void(s.diff=r.isHorizontal()?s.currentX-s.startX:s.currentY-s.startY)}n.followFinger&&!n.cssMode&&((n.freeMode&&n.freeMode.enabled&&r.freeMode||n.watchSlidesProgress)&&(r.updateActiveIndex(),r.updateSlidesClasses()),n.freeMode&&n.freeMode.enabled&&r.freeMode&&r.freeMode.onTouchMove(),r.updateProgress(i.currentTranslate),r.setTranslate(i.currentTranslate))}function ta(e){const t=this,r=t.touchEventsData;let i,n=e;n.originalEvent&&(n=n.originalEvent);if("touchend"===n.type||"touchcancel"===n.type){if(i=[...n.changedTouches].filter(e=>e.identifier===r.touchId)[0],!i||i.identifier!==r.touchId)return}else{if(null!==r.touchId)return;if(n.pointerId!==r.pointerId)return;i=n}if(["pointercancel","pointerout","pointerleave","contextmenu"].includes(n.type)){if(!(["pointercancel","contextmenu"].includes(n.type)&&(t.browser.isSafari||t.browser.isWebView)))return}r.pointerId=null,r.touchId=null;const{params:s,touches:a,rtlTranslate:o,slidesGrid:l,enabled:c}=t;if(!c)return;if(!s.simulateTouch&&"mouse"===n.pointerType)return;if(r.allowTouchCallbacks&&t.emit("touchEnd",n),r.allowTouchCallbacks=!1,!r.isTouched)return r.isMoved&&s.grabCursor&&t.setGrabCursor(!1),r.isMoved=!1,void(r.startMoving=!1);s.grabCursor&&r.isMoved&&r.isTouched&&(!0===t.allowSlideNext||!0===t.allowSlidePrev)&&t.setGrabCursor(!1);const d=bs(),u=d-r.touchStartTime;if(t.allowClick){const e=n.path||n.composedPath&&n.composedPath();t.updateClickedSlide(e&&e[0]||n.target,e),t.emit("tap click",n),u<300&&d-r.lastClickTime<300&&t.emit("doubleTap doubleClick",n)}if(r.lastClickTime=bs(),ys(()=>{t.destroyed||(t.allowClick=!0)}),!r.isTouched||!r.isMoved||!t.swipeDirection||0===a.diff&&!r.loopSwapReset||r.currentTranslate===r.startTranslate&&!r.loopSwapReset)return r.isTouched=!1,r.isMoved=!1,void(r.startMoving=!1);let h;if(r.isTouched=!1,r.isMoved=!1,r.startMoving=!1,h=s.followFinger?o?t.translate:-t.translate:-r.currentTranslate,s.cssMode)return;if(s.freeMode&&s.freeMode.enabled)return void t.freeMode.onTouchEnd({currentPos:h});const f=h>=-t.maxTranslate()&&!t.params.loop;let p=0,m=t.slidesSizesGrid[0];for(let e=0;e<l.length;e+=e<s.slidesPerGroupSkip?1:s.slidesPerGroup){const t=e<s.slidesPerGroupSkip-1?1:s.slidesPerGroup;void 0!==l[e+t]?(f||h>=l[e]&&h<l[e+t])&&(p=e,m=l[e+t]-l[e]):(f||h>=l[e])&&(p=e,m=l[l.length-1]-l[l.length-2])}let g=null,v=null;s.rewind&&(t.isBeginning?v=s.virtual&&s.virtual.enabled&&t.virtual?t.virtual.slides.length-1:t.slides.length-1:t.isEnd&&(g=0));const y=(h-l[p])/m,b=p<s.slidesPerGroupSkip-1?1:s.slidesPerGroup;if(u>s.longSwipesMs){if(!s.longSwipes)return void t.slideTo(t.activeIndex);"next"===t.swipeDirection&&(y>=s.longSwipesRatio?t.slideTo(s.rewind&&t.isEnd?g:p+b):t.slideTo(p)),"prev"===t.swipeDirection&&(y>1-s.longSwipesRatio?t.slideTo(p+b):null!==v&&y<0&&Math.abs(y)>s.longSwipesRatio?t.slideTo(v):t.slideTo(p))}else{if(!s.shortSwipes)return void t.slideTo(t.activeIndex);t.navigation&&(n.target===t.navigation.nextEl||n.target===t.navigation.prevEl)?n.target===t.navigation.nextEl?t.slideTo(p+b):t.slideTo(p):("next"===t.swipeDirection&&t.slideTo(null!==g?g:p+b),"prev"===t.swipeDirection&&t.slideTo(null!==v?v:p))}}function ra(){const e=this,{params:t,el:r}=e;if(r&&0===r.offsetWidth)return;t.breakpoints&&e.setBreakpoint();const{allowSlideNext:i,allowSlidePrev:n,snapGrid:s}=e,a=e.virtual&&e.params.virtual.enabled;e.allowSlideNext=!0,e.allowSlidePrev=!0,e.updateSize(),e.updateSlides(),e.updateSlidesClasses();const o=a&&t.loop;!("auto"===t.slidesPerView||t.slidesPerView>1)||!e.isEnd||e.isBeginning||e.params.centeredSlides||o?e.params.loop&&!a?e.slideToLoop(e.realIndex,0,!1,!0):e.slideTo(e.activeIndex,0,!1,!0):e.slideTo(e.slides.length-1,0,!1,!0),e.autoplay&&e.autoplay.running&&e.autoplay.paused&&(clearTimeout(e.autoplay.resizeTimeout),e.autoplay.resizeTimeout=setTimeout(()=>{e.autoplay&&e.autoplay.running&&e.autoplay.paused&&e.autoplay.resume()},500)),e.allowSlidePrev=n,e.allowSlideNext=i,e.params.watchOverflow&&s!==e.snapGrid&&e.checkOverflow()}function ia(e){const t=this;t.enabled&&(t.allowClick||(t.params.preventClicks&&e.preventDefault(),t.params.preventClicksPropagation&&t.animating&&(e.stopPropagation(),e.stopImmediatePropagation())))}function na(){const e=this,{wrapperEl:t,rtlTranslate:r,enabled:i}=e;if(!i)return;let n;e.previousTranslate=e.translate,e.isHorizontal()?e.translate=-t.scrollLeft:e.translate=-t.scrollTop,0===e.translate&&(e.translate=0),e.updateActiveIndex(),e.updateSlidesClasses();const s=e.maxTranslate()-e.minTranslate();n=0===s?0:(e.translate-e.minTranslate())/s,n!==e.progress&&e.updateProgress(r?-e.translate:e.translate),e.emit("setTranslate",e.translate,!1)}function sa(e){const t=this;js(t,e.target),t.params.cssMode||"auto"!==t.params.slidesPerView&&!t.params.autoHeight||t.update()}function aa(){const e=this;e.documentTouchHandlerProceeded||(e.documentTouchHandlerProceeded=!0,e.params.touchReleaseOnEdges&&(e.el.style.touchAction="auto"))}const oa=(e,t)=>{const r=ms(),{params:i,el:n,wrapperEl:s,device:a}=e,o=!!i.nested,l="on"===t?"addEventListener":"removeEventListener",c=t;n&&"string"!=typeof n&&(r[l]("touchstart",e.onDocumentTouchStart,{passive:!1,capture:o}),n[l]("touchstart",e.onTouchStart,{passive:!1}),n[l]("pointerdown",e.onTouchStart,{passive:!1}),r[l]("touchmove",e.onTouchMove,{passive:!1,capture:o}),r[l]("pointermove",e.onTouchMove,{passive:!1,capture:o}),r[l]("touchend",e.onTouchEnd,{passive:!0}),r[l]("pointerup",e.onTouchEnd,{passive:!0}),r[l]("pointercancel",e.onTouchEnd,{passive:!0}),r[l]("touchcancel",e.onTouchEnd,{passive:!0}),r[l]("pointerout",e.onTouchEnd,{passive:!0}),r[l]("pointerleave",e.onTouchEnd,{passive:!0}),r[l]("contextmenu",e.onTouchEnd,{passive:!0}),(i.preventClicks||i.preventClicksPropagation)&&n[l]("click",e.onClick,!0),i.cssMode&&s[l]("scroll",e.onScroll),i.updateOnWindowResize?e[c](a.ios||a.android?"resize orientationchange observerUpdate":"resize observerUpdate",ra,!0):e[c]("observerUpdate",ra,!0),n[l]("load",e.onLoad,{capture:!0}))};const la=(e,t)=>e.grid&&t.grid&&t.grid.rows>1;var ca={setBreakpoint:function(){const e=this,{realIndex:t,initialized:r,params:i,el:n}=e,s=i.breakpoints;if(!s||s&&0===Object.keys(s).length)return;const a=e.getBreakpoint(s,e.params.breakpointsBase,e.el);if(!a||e.currentBreakpoint===a)return;const o=(a in s?s[a]:void 0)||e.originalParams,l=la(e,i),c=la(e,o),d=e.params.grabCursor,u=o.grabCursor,h=i.enabled;l&&!c?(n.classList.remove(`${i.containerModifierClass}grid`,`${i.containerModifierClass}grid-column`),e.emitContainerClasses()):!l&&c&&(n.classList.add(`${i.containerModifierClass}grid`),(o.grid.fill&&"column"===o.grid.fill||!o.grid.fill&&"column"===i.grid.fill)&&n.classList.add(`${i.containerModifierClass}grid-column`),e.emitContainerClasses()),d&&!u?e.unsetGrabCursor():!d&&u&&e.setGrabCursor(),["navigation","pagination","scrollbar"].forEach(t=>{if(void 0===o[t])return;const r=i[t]&&i[t].enabled,n=o[t]&&o[t].enabled;r&&!n&&e[t].disable(),!r&&n&&e[t].enable()});const f=o.direction&&o.direction!==i.direction,p=i.loop&&(o.slidesPerView!==i.slidesPerView||f),m=i.loop;f&&r&&e.changeDirection(),Ts(e.params,o);const g=e.params.enabled,v=e.params.loop;Object.assign(e,{allowTouchMove:e.params.allowTouchMove,allowSlideNext:e.params.allowSlideNext,allowSlidePrev:e.params.allowSlidePrev}),h&&!g?e.disable():!h&&g&&e.enable(),e.currentBreakpoint=a,e.emit("_beforeBreakpoint",o),r&&(p?(e.loopDestroy(),e.loopCreate(t),e.updateSlides()):!m&&v?(e.loopCreate(t),e.updateSlides()):m&&!v&&e.loopDestroy()),e.emit("breakpoint",o)},getBreakpoint:function(e,t,r){if(void 0===t&&(t="window"),!e||"container"===t&&!r)return;let i=!1;const n=vs(),s="window"===t?n.innerHeight:r.clientHeight,a=Object.keys(e).map(e=>{if("string"==typeof e&&0===e.indexOf("@")){const t=parseFloat(e.substr(1));return{value:s*t,point:e}}return{value:e,point:e}});a.sort((e,t)=>parseInt(e.value,10)-parseInt(t.value,10));for(let e=0;e<a.length;e+=1){const{point:s,value:o}=a[e];"window"===t?n.matchMedia(`(min-width: ${o}px)`).matches&&(i=s):o<=r.clientWidth&&(i=s)}return i||"max"}};var da={init:!0,direction:"horizontal",oneWayMovement:!1,swiperElementNodeName:"SWIPER-CONTAINER",touchEventsTarget:"wrapper",initialSlide:0,speed:300,cssMode:!1,updateOnWindowResize:!0,resizeObserver:!0,nested:!1,createElements:!1,eventsPrefix:"swiper",enabled:!0,focusableElements:"input, select, option, textarea, button, video, label",width:null,height:null,preventInteractionOnTransition:!1,userAgent:null,url:null,edgeSwipeDetection:!1,edgeSwipeThreshold:20,autoHeight:!1,setWrapperSize:!1,virtualTranslate:!1,effect:"slide",breakpoints:void 0,breakpointsBase:"window",spaceBetween:0,slidesPerView:1,slidesPerGroup:1,slidesPerGroupSkip:0,slidesPerGroupAuto:!1,centeredSlides:!1,centeredSlidesBounds:!1,slidesOffsetBefore:0,slidesOffsetAfter:0,normalizeSlideIndex:!0,centerInsufficientSlides:!1,watchOverflow:!0,roundLengths:!1,touchRatio:1,touchAngle:45,simulateTouch:!0,shortSwipes:!0,longSwipes:!0,longSwipesRatio:.5,longSwipesMs:300,followFinger:!0,allowTouchMove:!0,threshold:5,touchMoveStopPropagation:!1,touchStartPreventDefault:!0,touchStartForcePreventDefault:!1,touchReleaseOnEdges:!1,uniqueNavElements:!0,resistance:!0,resistanceRatio:.85,watchSlidesProgress:!1,grabCursor:!1,preventClicks:!0,preventClicksPropagation:!0,slideToClickedSlide:!1,loop:!1,loopAddBlankSlides:!0,loopAdditionalSlides:0,loopPreventsSliding:!0,rewind:!1,allowSlidePrev:!0,allowSlideNext:!0,swipeHandler:null,noSwiping:!0,noSwipingClass:"swiper-no-swiping",noSwipingSelector:null,passiveListeners:!0,maxBackfaceHiddenSlides:10,containerModifierClass:"swiper-",slideClass:"swiper-slide",slideBlankClass:"swiper-slide-blank",slideActiveClass:"swiper-slide-active",slideVisibleClass:"swiper-slide-visible",slideFullyVisibleClass:"swiper-slide-fully-visible",slideNextClass:"swiper-slide-next",slidePrevClass:"swiper-slide-prev",wrapperClass:"swiper-wrapper",lazyPreloaderClass:"swiper-lazy-preloader",lazyPreloadPrevNext:0,runCallbacksOnInit:!0,_emitClasses:!1};function ua(e,t){return function(r){void 0===r&&(r={});const i=Object.keys(r)[0],n=r[i];"object"==typeof n&&null!==n?(!0===e[i]&&(e[i]={enabled:!0}),"navigation"===i&&e[i]&&e[i].enabled&&!e[i].prevEl&&!e[i].nextEl&&(e[i].auto=!0),["pagination","scrollbar"].indexOf(i)>=0&&e[i]&&e[i].enabled&&!e[i].el&&(e[i].auto=!0),i in e&&"enabled"in n?("object"!=typeof e[i]||"enabled"in e[i]||(e[i].enabled=!0),e[i]||(e[i]={enabled:!1}),Ts(t,r)):Ts(t,r)):Ts(t,r)}}const ha={eventsEmitter:Us,update:Ws,translate:Ys,transition:qs,slide:Xs,loop:Qs,grabCursor:{setGrabCursor:function(e){const t=this;if(!t.params.simulateTouch||t.params.watchOverflow&&t.isLocked||t.params.cssMode)return;const r="container"===t.params.touchEventsTarget?t.el:t.wrapperEl;t.isElement&&(t.__preventObserver__=!0),r.style.cursor="move",r.style.cursor=e?"grabbing":"grab",t.isElement&&requestAnimationFrame(()=>{t.__preventObserver__=!1})},unsetGrabCursor:function(){const e=this;e.params.watchOverflow&&e.isLocked||e.params.cssMode||(e.isElement&&(e.__preventObserver__=!0),e["container"===e.params.touchEventsTarget?"el":"wrapperEl"].style.cursor="",e.isElement&&requestAnimationFrame(()=>{e.__preventObserver__=!1}))}},events:{attachEvents:function(){const e=this,{params:t}=e;e.onTouchStart=Js.bind(e),e.onTouchMove=ea.bind(e),e.onTouchEnd=ta.bind(e),e.onDocumentTouchStart=aa.bind(e),t.cssMode&&(e.onScroll=na.bind(e)),e.onClick=ia.bind(e),e.onLoad=sa.bind(e),oa(e,"on")},detachEvents:function(){oa(this,"off")}},breakpoints:ca,checkOverflow:{checkOverflow:function(){const e=this,{isLocked:t,params:r}=e,{slidesOffsetBefore:i}=r;if(i){const t=e.slides.length-1,r=e.slidesGrid[t]+e.slidesSizesGrid[t]+2*i;e.isLocked=e.size>r}else e.isLocked=1===e.snapGrid.length;!0===r.allowSlideNext&&(e.allowSlideNext=!e.isLocked),!0===r.allowSlidePrev&&(e.allowSlidePrev=!e.isLocked),t&&t!==e.isLocked&&(e.isEnd=!1),t!==e.isLocked&&e.emit(e.isLocked?"lock":"unlock")}},classes:{addClasses:function(){const e=this,{classNames:t,params:r,rtl:i,el:n,device:s}=e,a=function(e,t){const r=[];return e.forEach(e=>{"object"==typeof e?Object.keys(e).forEach(i=>{e[i]&&r.push(t+i)}):"string"==typeof e&&r.push(t+e)}),r}(["initialized",r.direction,{"free-mode":e.params.freeMode&&r.freeMode.enabled},{autoheight:r.autoHeight},{rtl:i},{grid:r.grid&&r.grid.rows>1},{"grid-column":r.grid&&r.grid.rows>1&&"column"===r.grid.fill},{android:s.android},{ios:s.ios},{"css-mode":r.cssMode},{centered:r.cssMode&&r.centeredSlides},{"watch-progress":r.watchSlidesProgress}],r.containerModifierClass);t.push(...a),n.classList.add(...t),e.emitContainerClasses()},removeClasses:function(){const{el:e,classNames:t}=this;e&&"string"!=typeof e&&(e.classList.remove(...t),this.emitContainerClasses())}}},fa={};let pa=class e{constructor(){let t,r;for(var i=arguments.length,n=new Array(i),s=0;s<i;s++)n[s]=arguments[s];1===n.length&&n[0].constructor&&"Object"===Object.prototype.toString.call(n[0]).slice(8,-1)?r=n[0]:[t,r]=n,r||(r={}),r=Ts({},r),t&&!r.el&&(r.el=t);const a=ms();if(r.el&&"string"==typeof r.el&&a.querySelectorAll(r.el).length>1){const t=[];return a.querySelectorAll(r.el).forEach(i=>{const n=Ts({},r,{el:i});t.push(new e(n))}),t}const o=this;o.__swiper__=!0,o.support=Fs(),o.device=$s({userAgent:r.userAgent}),o.browser=Bs(),o.eventsListeners={},o.eventsAnyListeners=[],o.modules=[...o.__modules__],r.modules&&Array.isArray(r.modules)&&o.modules.push(...r.modules);const l={};o.modules.forEach(e=>{e({params:r,swiper:o,extendParams:ua(r,l),on:o.on.bind(o),once:o.once.bind(o),off:o.off.bind(o),emit:o.emit.bind(o)})});const c=Ts({},da,l);return o.params=Ts({},c,fa,r),o.originalParams=Ts({},o.params),o.passedParams=Ts({},r),o.params&&o.params.on&&Object.keys(o.params.on).forEach(e=>{o.on(e,o.params.on[e])}),o.params&&o.params.onAny&&o.onAny(o.params.onAny),Object.assign(o,{enabled:o.params.enabled,el:t,classNames:[],slides:[],slidesGrid:[],snapGrid:[],slidesSizesGrid:[],isHorizontal:()=>"horizontal"===o.params.direction,isVertical:()=>"vertical"===o.params.direction,activeIndex:0,realIndex:0,isBeginning:!0,isEnd:!1,translate:0,previousTranslate:0,progress:0,velocity:0,animating:!1,cssOverflowAdjustment(){return Math.trunc(this.translate/2**23)*2**23},allowSlideNext:o.params.allowSlideNext,allowSlidePrev:o.params.allowSlidePrev,touchEventsData:{isTouched:void 0,isMoved:void 0,allowTouchCallbacks:void 0,touchStartTime:void 0,isScrolling:void 0,currentTranslate:void 0,startTranslate:void 0,allowThresholdMove:void 0,focusableElements:o.params.focusableElements,lastClickTime:0,clickTimeout:void 0,velocities:[],allowMomentumBounce:void 0,startMoving:void 0,pointerId:null,touchId:null},allowClick:!0,allowTouchMove:o.params.allowTouchMove,touches:{startX:0,startY:0,currentX:0,currentY:0,diff:0},imagesToLoad:[],imagesLoaded:0}),o.emit("_swiper"),o.params.init&&o.init(),o}getDirectionLabel(e){return this.isHorizontal()?e:{width:"height","margin-top":"margin-left","margin-bottom ":"margin-right","margin-left":"margin-top","margin-right":"margin-bottom","padding-left":"padding-top","padding-right":"padding-bottom",marginRight:"marginBottom"}[e]}getSlideIndex(e){const{slidesEl:t,params:r}=this,i=Cs(Is(t,`.${r.slideClass}, swiper-slide`)[0]);return Cs(e)-i}getSlideIndexByData(e){return this.getSlideIndex(this.slides.filter(t=>1*t.getAttribute("data-swiper-slide-index")===e)[0])}recalcSlides(){const{slidesEl:e,params:t}=this;this.slides=Is(e,`.${t.slideClass}, swiper-slide`)}enable(){const e=this;e.enabled||(e.enabled=!0,e.params.grabCursor&&e.setGrabCursor(),e.emit("enable"))}disable(){const e=this;e.enabled&&(e.enabled=!1,e.params.grabCursor&&e.unsetGrabCursor(),e.emit("disable"))}setProgress(e,t){const r=this;e=Math.min(Math.max(e,0),1);const i=r.minTranslate(),n=(r.maxTranslate()-i)*e+i;r.translateTo(n,void 0===t?0:t),r.updateActiveIndex(),r.updateSlidesClasses()}emitContainerClasses(){const e=this;if(!e.params._emitClasses||!e.el)return;const t=e.el.className.split(" ").filter(t=>0===t.indexOf("swiper")||0===t.indexOf(e.params.containerModifierClass));e.emit("_containerClasses",t.join(" "))}getSlideClasses(e){const t=this;return t.destroyed?"":e.className.split(" ").filter(e=>0===e.indexOf("swiper-slide")||0===e.indexOf(t.params.slideClass)).join(" ")}emitSlidesClasses(){const e=this;if(!e.params._emitClasses||!e.el)return;const t=[];e.slides.forEach(r=>{const i=e.getSlideClasses(r);t.push({slideEl:r,classNames:i}),e.emit("_slideClass",r,i)}),e.emit("_slideClasses",t)}slidesPerViewDynamic(e,t){void 0===e&&(e="current"),void 0===t&&(t=!1);const{params:r,slides:i,slidesGrid:n,slidesSizesGrid:s,size:a,activeIndex:o}=this;let l=1;if("number"==typeof r.slidesPerView)return r.slidesPerView;if(r.centeredSlides){let e,t=i[o]?Math.ceil(i[o].swiperSlideSize):0;for(let r=o+1;r<i.length;r+=1)i[r]&&!e&&(t+=Math.ceil(i[r].swiperSlideSize),l+=1,t>a&&(e=!0));for(let r=o-1;r>=0;r-=1)i[r]&&!e&&(t+=i[r].swiperSlideSize,l+=1,t>a&&(e=!0))}else if("current"===e)for(let e=o+1;e<i.length;e+=1){(t?n[e]+s[e]-n[o]<a:n[e]-n[o]<a)&&(l+=1)}else for(let e=o-1;e>=0;e-=1){n[o]-n[e]<a&&(l+=1)}return l}update(){const e=this;if(!e||e.destroyed)return;const{snapGrid:t,params:r}=e;function i(){const t=e.rtlTranslate?-1*e.translate:e.translate,r=Math.min(Math.max(t,e.maxTranslate()),e.minTranslate());e.setTranslate(r),e.updateActiveIndex(),e.updateSlidesClasses()}let n;if(r.breakpoints&&e.setBreakpoint(),[...e.el.querySelectorAll('[loading="lazy"]')].forEach(t=>{t.complete&&js(e,t)}),e.updateSize(),e.updateSlides(),e.updateProgress(),e.updateSlidesClasses(),r.freeMode&&r.freeMode.enabled&&!r.cssMode)i(),r.autoHeight&&e.updateAutoHeight();else{if(("auto"===r.slidesPerView||r.slidesPerView>1)&&e.isEnd&&!r.centeredSlides){const t=e.virtual&&r.virtual.enabled?e.virtual.slides:e.slides;n=e.slideTo(t.length-1,0,!1,!0)}else n=e.slideTo(e.activeIndex,0,!1,!0);n||i()}r.watchOverflow&&t!==e.snapGrid&&e.checkOverflow(),e.emit("update")}changeDirection(e,t){void 0===t&&(t=!0);const r=this,i=r.params.direction;return e||(e="horizontal"===i?"vertical":"horizontal"),e===i||"horizontal"!==e&&"vertical"!==e||(r.el.classList.remove(`${r.params.containerModifierClass}${i}`),r.el.classList.add(`${r.params.containerModifierClass}${e}`),r.emitContainerClasses(),r.params.direction=e,r.slides.forEach(t=>{"vertical"===e?t.style.width="":t.style.height=""}),r.emit("changeDirection"),t&&r.update()),r}changeLanguageDirection(e){const t=this;t.rtl&&"rtl"===e||!t.rtl&&"ltr"===e||(t.rtl="rtl"===e,t.rtlTranslate="horizontal"===t.params.direction&&t.rtl,t.rtl?(t.el.classList.add(`${t.params.containerModifierClass}rtl`),t.el.dir="rtl"):(t.el.classList.remove(`${t.params.containerModifierClass}rtl`),t.el.dir="ltr"),t.update())}mount(e){const t=this;if(t.mounted)return!0;let r=e||t.params.el;if("string"==typeof r&&(r=document.querySelector(r)),!r)return!1;r.swiper=t,r.parentNode&&r.parentNode.host&&r.parentNode.host.nodeName===t.params.swiperElementNodeName.toUpperCase()&&(t.isElement=!0);const i=()=>`.${(t.params.wrapperClass||"").trim().split(" ").join(".")}`;let n=(()=>{if(r&&r.shadowRoot&&r.shadowRoot.querySelector){return r.shadowRoot.querySelector(i())}return Is(r,i())[0]})();return!n&&t.params.createElements&&(n=Rs("div",t.params.wrapperClass),r.append(n),Is(r,`.${t.params.slideClass}`).forEach(e=>{n.append(e)})),Object.assign(t,{el:r,wrapperEl:n,slidesEl:t.isElement&&!r.parentNode.host.slideSlots?r.parentNode.host:n,hostEl:t.isElement?r.parentNode.host:r,mounted:!0,rtl:"rtl"===r.dir.toLowerCase()||"rtl"===Ps(r,"direction"),rtlTranslate:"horizontal"===t.params.direction&&("rtl"===r.dir.toLowerCase()||"rtl"===Ps(r,"direction")),wrongRTL:"-webkit-box"===Ps(n,"display")}),!0}init(e){const t=this;if(t.initialized)return t;if(!1===t.mount(e))return t;t.emit("beforeInit"),t.params.breakpoints&&t.setBreakpoint(),t.addClasses(),t.updateSize(),t.updateSlides(),t.params.watchOverflow&&t.checkOverflow(),t.params.grabCursor&&t.enabled&&t.setGrabCursor(),t.params.loop&&t.virtual&&t.params.virtual.enabled?t.slideTo(t.params.initialSlide+t.virtual.slidesBefore,0,t.params.runCallbacksOnInit,!1,!0):t.slideTo(t.params.initialSlide,0,t.params.runCallbacksOnInit,!1,!0),t.params.loop&&t.loopCreate(),t.attachEvents();const r=[...t.el.querySelectorAll('[loading="lazy"]')];return t.isElement&&r.push(...t.hostEl.querySelectorAll('[loading="lazy"]')),r.forEach(e=>{e.complete?js(t,e):e.addEventListener("load",e=>{js(t,e.target)})}),Vs(t),t.initialized=!0,Vs(t),t.emit("init"),t.emit("afterInit"),t}destroy(e,t){void 0===e&&(e=!0),void 0===t&&(t=!0);const r=this,{params:i,el:n,wrapperEl:s,slides:a}=r;return void 0===r.params||r.destroyed||(r.emit("beforeDestroy"),r.initialized=!1,r.detachEvents(),i.loop&&r.loopDestroy(),t&&(r.removeClasses(),n&&"string"!=typeof n&&n.removeAttribute("style"),s&&s.removeAttribute("style"),a&&a.length&&a.forEach(e=>{e.classList.remove(i.slideVisibleClass,i.slideFullyVisibleClass,i.slideActiveClass,i.slideNextClass,i.slidePrevClass),e.removeAttribute("style"),e.removeAttribute("data-swiper-slide-index")})),r.emit("destroy"),Object.keys(r.eventsListeners).forEach(e=>{r.off(e)}),!1!==e&&(r.el&&"string"!=typeof r.el&&(r.el.swiper=null),function(e){const t=e;Object.keys(t).forEach(e=>{try{t[e]=null}catch(e){}try{delete t[e]}catch(e){}})}(r)),r.destroyed=!0),null}static extendDefaults(e){Ts(fa,e)}static get extendedDefaults(){return fa}static get defaults(){return da}static installModule(t){e.prototype.__modules__||(e.prototype.__modules__=[]);const r=e.prototype.__modules__;"function"==typeof t&&r.indexOf(t)<0&&r.push(t)}static use(t){return Array.isArray(t)?(t.forEach(t=>e.installModule(t)),e):(e.installModule(t),e)}};Object.keys(ha).forEach(e=>{Object.keys(ha[e]).forEach(t=>{pa.prototype[t]=ha[e][t]})}),pa.use([function(e){let{swiper:t,on:r,emit:i}=e;const n=vs();let s=null,a=null;const o=()=>{t&&!t.destroyed&&t.initialized&&(i("beforeResize"),i("resize"))},l=()=>{t&&!t.destroyed&&t.initialized&&i("orientationchange")};r("init",()=>{t.params.resizeObserver&&void 0!==n.ResizeObserver?t&&!t.destroyed&&t.initialized&&(s=new ResizeObserver(e=>{a=n.requestAnimationFrame(()=>{const{width:r,height:i}=t;let n=r,s=i;e.forEach(e=>{let{contentBoxSize:r,contentRect:i,target:a}=e;a&&a!==t.el||(n=i?i.width:(r[0]||r).inlineSize,s=i?i.height:(r[0]||r).blockSize)}),n===r&&s===i||o()})}),s.observe(t.el)):(n.addEventListener("resize",o),n.addEventListener("orientationchange",l))}),r("destroy",()=>{a&&n.cancelAnimationFrame(a),s&&s.unobserve&&t.el&&(s.unobserve(t.el),s=null),n.removeEventListener("resize",o),n.removeEventListener("orientationchange",l)})},function(e){let{swiper:t,extendParams:r,on:i,emit:n}=e;const s=[],a=vs(),o=function(e,r){void 0===r&&(r={});const i=new(a.MutationObserver||a.WebkitMutationObserver)(e=>{if(t.__preventObserver__)return;if(1===e.length)return void n("observerUpdate",e[0]);const r=function(){n("observerUpdate",e[0])};a.requestAnimationFrame?a.requestAnimationFrame(r):a.setTimeout(r,0)});i.observe(e,{attributes:void 0===r.attributes||r.attributes,childList:t.isElement||(void 0===r.childList||r).childList,characterData:void 0===r.characterData||r.characterData}),s.push(i)};r({observer:!1,observeParents:!1,observeSlideChildren:!1}),i("init",()=>{if(t.params.observer){if(t.params.observeParents){const e=function(e){const t=[];let r=e.parentElement;for(;r;)t.push(r),r=r.parentElement;return t}(t.hostEl);for(let t=0;t<e.length;t+=1)o(e[t])}o(t.hostEl,{childList:t.params.observeSlideChildren}),o(t.wrapperEl,{attributes:!1})}}),i("destroy",()=>{s.forEach(e=>{e.disconnect()}),s.splice(0,s.length)})}]);const ma=["eventsPrefix","injectStyles","injectStylesUrls","modules","init","_direction","oneWayMovement","swiperElementNodeName","touchEventsTarget","initialSlide","_speed","cssMode","updateOnWindowResize","resizeObserver","nested","focusableElements","_enabled","_width","_height","preventInteractionOnTransition","userAgent","url","_edgeSwipeDetection","_edgeSwipeThreshold","_freeMode","_autoHeight","setWrapperSize","virtualTranslate","_effect","breakpoints","breakpointsBase","_spaceBetween","_slidesPerView","maxBackfaceHiddenSlides","_grid","_slidesPerGroup","_slidesPerGroupSkip","_slidesPerGroupAuto","_centeredSlides","_centeredSlidesBounds","_slidesOffsetBefore","_slidesOffsetAfter","normalizeSlideIndex","_centerInsufficientSlides","_watchOverflow","roundLengths","touchRatio","touchAngle","simulateTouch","_shortSwipes","_longSwipes","longSwipesRatio","longSwipesMs","_followFinger","allowTouchMove","_threshold","touchMoveStopPropagation","touchStartPreventDefault","touchStartForcePreventDefault","touchReleaseOnEdges","uniqueNavElements","_resistance","_resistanceRatio","_watchSlidesProgress","_grabCursor","preventClicks","preventClicksPropagation","_slideToClickedSlide","_loop","loopAdditionalSlides","loopAddBlankSlides","loopPreventsSliding","_rewind","_allowSlidePrev","_allowSlideNext","_swipeHandler","_noSwiping","noSwipingClass","noSwipingSelector","passiveListeners","containerModifierClass","slideClass","slideActiveClass","slideVisibleClass","slideFullyVisibleClass","slideNextClass","slidePrevClass","slideBlankClass","wrapperClass","lazyPreloaderClass","lazyPreloadPrevNext","runCallbacksOnInit","observer","observeParents","observeSlideChildren","a11y","_autoplay","_controller","coverflowEffect","cubeEffect","fadeEffect","flipEffect","creativeEffect","cardsEffect","hashNavigation","history","keyboard","mousewheel","_navigation","_pagination","parallax","_scrollbar","_thumbs","virtual","zoom","control"];function ga(e){return"object"==typeof e&&null!==e&&e.constructor&&"Object"===Object.prototype.toString.call(e).slice(8,-1)&&!e.__swiper__}function va(e,t){const r=["__proto__","constructor","prototype"];Object.keys(t).filter(e=>r.indexOf(e)<0).forEach(r=>{void 0===e[r]?e[r]=t[r]:ga(t[r])&&ga(e[r])&&Object.keys(t[r]).length>0?t[r].__swiper__?e[r]=t[r]:va(e[r],t[r]):e[r]=t[r]})}function ya(e){return void 0===e&&(e={}),e.navigation&&void 0===e.navigation.nextEl&&void 0===e.navigation.prevEl}function ba(e){return void 0===e&&(e={}),e.pagination&&void 0===e.pagination.el}function Ea(e){return void 0===e&&(e={}),e.scrollbar&&void 0===e.scrollbar.el}function wa(e){void 0===e&&(e="");const t=e.split(" ").map(e=>e.trim()).filter(e=>!!e),r=[];return t.forEach(e=>{r.indexOf(e)<0&&r.push(e)}),r.join(" ")}function Sa(e){return void 0===e&&(e=""),e?e.includes("swiper-wrapper")?e:`swiper-wrapper ${e}`:"swiper-wrapper"}function Ta(){return Ta=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},Ta.apply(this,arguments)}function xa(e){return e.type&&e.type.displayName&&e.type.displayName.includes("SwiperSlide")}function Aa(e){const r=[];return t.Children.toArray(e).forEach(e=>{xa(e)?r.push(e):e.props&&e.props.children&&Aa(e.props.children).forEach(e=>r.push(e))}),r}function ka(e){const r=[],i={"container-start":[],"container-end":[],"wrapper-start":[],"wrapper-end":[]};return t.Children.toArray(e).forEach(e=>{if(xa(e))r.push(e);else if(e.props&&e.props.slot&&i[e.props.slot])i[e.props.slot].push(e);else if(e.props&&e.props.children){const t=Aa(e.props.children);t.length>0?t.forEach(e=>r.push(e)):i["container-end"].push(e)}else i["container-end"].push(e)}),{slides:r,slots:i}}function Ia(e,t){return"undefined"==typeof window?i(e,t):l(e,t)}const La=a(null),Ra=a(null),Pa=o(function(e,n){let{className:a,tag:o="div",wrapperTag:l="div",children:c,onSwiper:d,...u}=void 0===e?{}:e,h=!1;const[f,p]=s("swiper"),[m,g]=s(null),[v,y]=s(!1),b=r(!1),E=r(null),w=r(null),S=r(null),T=r(null),x=r(null),A=r(null),k=r(null),I=r(null),{params:L,passedParams:R,rest:P,events:C}=function(e,t){void 0===e&&(e={}),void 0===t&&(t=!0);const r={on:{}},i={},n={};va(r,da),r._emitClasses=!0,r.init=!1;const s={},a=ma.map(e=>e.replace(/_/,"")),o=Object.assign({},e);return Object.keys(o).forEach(o=>{void 0!==e[o]&&(a.indexOf(o)>=0?ga(e[o])?(r[o]={},n[o]={},va(r[o],e[o]),va(n[o],e[o])):(r[o]=e[o],n[o]=e[o]):0===o.search(/on[A-Z]/)&&"function"==typeof e[o]?t?i[`${o[2].toLowerCase()}${o.substr(3)}`]=e[o]:r.on[`${o[2].toLowerCase()}${o.substr(3)}`]=e[o]:s[o]=e[o])}),["navigation","pagination","scrollbar"].forEach(e=>{!0===r[e]&&(r[e]={}),!1===r[e]&&delete r[e]}),{params:r,passedParams:n,rest:s,events:i}}(u),{slides:D,slots:_}=ka(c),O=()=>{y(!v)};Object.assign(L.on,{_containerClasses(e,t){p(t)}});const M=()=>{Object.assign(L.on,C),h=!0;const e={...L};if(delete e.wrapperClass,w.current=new pa(e),w.current.virtual&&w.current.params.virtual.enabled){w.current.virtual.slides=D;const e={cache:!1,slides:D,renderExternal:g,renderExternalUpdate:!1};va(w.current.params.virtual,e),va(w.current.originalParams.virtual,e)}};E.current||M(),w.current&&w.current.on("_beforeBreakpoint",O);return i(()=>()=>{w.current&&w.current.off("_beforeBreakpoint",O)}),i(()=>{!b.current&&w.current&&(w.current.emitSlidesClasses(),b.current=!0)}),Ia(()=>{if(n&&(n.current=E.current),E.current)return w.current.destroyed&&M(),function(e,t){let{el:r,nextEl:i,prevEl:n,paginationEl:s,scrollbarEl:a,swiper:o}=e;ya(t)&&i&&n&&(o.params.navigation.nextEl=i,o.originalParams.navigation.nextEl=i,o.params.navigation.prevEl=n,o.originalParams.navigation.prevEl=n),ba(t)&&s&&(o.params.pagination.el=s,o.originalParams.pagination.el=s),Ea(t)&&a&&(o.params.scrollbar.el=a,o.originalParams.scrollbar.el=a),o.init(r)}({el:E.current,nextEl:x.current,prevEl:A.current,paginationEl:k.current,scrollbarEl:I.current,swiper:w.current},L),d&&!w.current.destroyed&&d(w.current),()=>{w.current&&!w.current.destroyed&&w.current.destroy(!0,!1)}},[]),Ia(()=>{!h&&C&&w.current&&Object.keys(C).forEach(e=>{w.current.on(e,C[e])});const e=function(e,t,r,i,n){const s=[];if(!t)return s;const a=e=>{s.indexOf(e)<0&&s.push(e)};if(r&&i){const e=i.map(n),t=r.map(n);e.join("")!==t.join("")&&a("children"),i.length!==r.length&&a("children")}return ma.filter(e=>"_"===e[0]).map(e=>e.replace(/_/,"")).forEach(r=>{if(r in e&&r in t)if(ga(e[r])&&ga(t[r])){const i=Object.keys(e[r]),n=Object.keys(t[r]);i.length!==n.length?a(r):(i.forEach(i=>{e[r][i]!==t[r][i]&&a(r)}),n.forEach(i=>{e[r][i]!==t[r][i]&&a(r)}))}else e[r]!==t[r]&&a(r)}),s}(R,S.current,D,T.current,e=>e.key);return S.current=R,T.current=D,e.length&&w.current&&!w.current.destroyed&&function(e){let{swiper:t,slides:r,passedParams:i,changedParams:n,nextEl:s,prevEl:a,scrollbarEl:o,paginationEl:l}=e;const c=n.filter(e=>"children"!==e&&"direction"!==e&&"wrapperClass"!==e),{params:d,pagination:u,navigation:h,scrollbar:f,virtual:p,thumbs:m}=t;let g,v,y,b,E,w,S,T;n.includes("thumbs")&&i.thumbs&&i.thumbs.swiper&&!i.thumbs.swiper.destroyed&&d.thumbs&&(!d.thumbs.swiper||d.thumbs.swiper.destroyed)&&(g=!0),n.includes("controller")&&i.controller&&i.controller.control&&d.controller&&!d.controller.control&&(v=!0),n.includes("pagination")&&i.pagination&&(i.pagination.el||l)&&(d.pagination||!1===d.pagination)&&u&&!u.el&&(y=!0),n.includes("scrollbar")&&i.scrollbar&&(i.scrollbar.el||o)&&(d.scrollbar||!1===d.scrollbar)&&f&&!f.el&&(b=!0),n.includes("navigation")&&i.navigation&&(i.navigation.prevEl||a)&&(i.navigation.nextEl||s)&&(d.navigation||!1===d.navigation)&&h&&!h.prevEl&&!h.nextEl&&(E=!0);const x=e=>{t[e]&&(t[e].destroy(),"navigation"===e?(t.isElement&&(t[e].prevEl.remove(),t[e].nextEl.remove()),d[e].prevEl=void 0,d[e].nextEl=void 0,t[e].prevEl=void 0,t[e].nextEl=void 0):(t.isElement&&t[e].el.remove(),d[e].el=void 0,t[e].el=void 0))};n.includes("loop")&&t.isElement&&(d.loop&&!i.loop?w=!0:!d.loop&&i.loop?S=!0:T=!0),c.forEach(e=>{if(ga(d[e])&&ga(i[e]))Object.assign(d[e],i[e]),"navigation"!==e&&"pagination"!==e&&"scrollbar"!==e||!("enabled"in i[e])||i[e].enabled||x(e);else{const t=i[e];!0!==t&&!1!==t||"navigation"!==e&&"pagination"!==e&&"scrollbar"!==e?d[e]=i[e]:!1===t&&x(e)}}),c.includes("controller")&&!v&&t.controller&&t.controller.control&&d.controller&&d.controller.control&&(t.controller.control=d.controller.control),n.includes("children")&&r&&p&&d.virtual.enabled?(p.slides=r,p.update(!0)):n.includes("virtual")&&p&&d.virtual.enabled&&(r&&(p.slides=r),p.update(!0)),n.includes("children")&&r&&d.loop&&(T=!0),g&&m.init()&&m.update(!0);v&&(t.controller.control=d.controller.control),y&&(!t.isElement||l&&"string"!=typeof l||(l=document.createElement("div"),l.classList.add("swiper-pagination"),l.part.add("pagination"),t.el.appendChild(l)),l&&(d.pagination.el=l),u.init(),u.render(),u.update()),b&&(!t.isElement||o&&"string"!=typeof o||(o=document.createElement("div"),o.classList.add("swiper-scrollbar"),o.part.add("scrollbar"),t.el.appendChild(o)),o&&(d.scrollbar.el=o),f.init(),f.updateSize(),f.setTranslate()),E&&(t.isElement&&(s&&"string"!=typeof s||(s=document.createElement("div"),s.classList.add("swiper-button-next"),s.innerHTML=t.hostEl.constructor.nextButtonSvg,s.part.add("button-next"),t.el.appendChild(s)),a&&"string"!=typeof a||(a=document.createElement("div"),a.classList.add("swiper-button-prev"),a.innerHTML=t.hostEl.constructor.prevButtonSvg,a.part.add("button-prev"),t.el.appendChild(a))),s&&(d.navigation.nextEl=s),a&&(d.navigation.prevEl=a),h.init(),h.update()),n.includes("allowSlideNext")&&(t.allowSlideNext=i.allowSlideNext),n.includes("allowSlidePrev")&&(t.allowSlidePrev=i.allowSlidePrev),n.includes("direction")&&t.changeDirection(i.direction,!1),(w||T)&&t.loopDestroy(),(S||T)&&t.loopCreate(),t.update()}({swiper:w.current,slides:D,passedParams:R,changedParams:e,nextEl:x.current,prevEl:A.current,scrollbarEl:I.current,paginationEl:k.current}),()=>{C&&w.current&&Object.keys(C).forEach(e=>{w.current.off(e,C[e])})}}),Ia(()=>{var e;!(e=w.current)||e.destroyed||!e.params.virtual||e.params.virtual&&!e.params.virtual.enabled||(e.updateSlides(),e.updateProgress(),e.updateSlidesClasses(),e.parallax&&e.params.parallax&&e.params.parallax.enabled&&e.parallax.setTranslate())},[m]),t.createElement(o,Ta({ref:E,className:wa(`${f}${a?` ${a}`:""}`)},P),t.createElement(Ra.Provider,{value:w.current},_["container-start"],t.createElement(l,{className:Sa(L.wrapperClass)},_["wrapper-start"],L.virtual?function(e,r,i){if(!i)return null;const n=e=>{let t=e;return e<0?t=r.length+e:t>=r.length&&(t-=r.length),t},s=e.isHorizontal()?{[e.rtlTranslate?"right":"left"]:`${i.offset}px`}:{top:`${i.offset}px`},{from:a,to:o}=i,l=e.params.loop?-r.length:0,c=e.params.loop?2*r.length:r.length,d=[];for(let e=l;e<c;e+=1)e>=a&&e<=o&&d.push(r[n(e)]);return d.map((r,i)=>t.cloneElement(r,{swiper:e,style:s,key:r.props.virtualIndex||r.key||`slide-${i}`}))}(w.current,D,m):D.map((e,r)=>t.cloneElement(e,{swiper:w.current,swiperSlideIndex:r})),_["wrapper-end"]),ya(L)&&t.createElement(t.Fragment,null,t.createElement("div",{ref:A,className:"swiper-button-prev"}),t.createElement("div",{ref:x,className:"swiper-button-next"})),Ea(L)&&t.createElement("div",{ref:I,className:"swiper-scrollbar"}),ba(L)&&t.createElement("div",{ref:k,className:"swiper-pagination"}),_["container-end"]))});Pa.displayName="Swiper";const Ca=o(function(e,i){let{tag:n="div",children:a,className:o="",swiper:l,zoom:c,lazy:d,virtualIndex:u,swiperSlideIndex:h,...f}=void 0===e?{}:e;const p=r(null),[m,g]=s("swiper-slide"),[v,y]=s(!1);function b(e,t,r){t===p.current&&g(r)}Ia(()=>{if(void 0!==h&&(p.current.swiperSlideIndex=h),i&&(i.current=p.current),p.current&&l){if(!l.destroyed)return l.on("_slideClass",b),()=>{l&&l.off("_slideClass",b)};"swiper-slide"!==m&&g("swiper-slide")}}),Ia(()=>{l&&p.current&&!l.destroyed&&g(l.getSlideClasses(p.current))},[l]);const E={isActive:m.indexOf("swiper-slide-active")>=0,isVisible:m.indexOf("swiper-slide-visible")>=0,isPrev:m.indexOf("swiper-slide-prev")>=0,isNext:m.indexOf("swiper-slide-next")>=0},w=()=>"function"==typeof a?a(E):a;return t.createElement(n,Ta({ref:p,className:wa(`${m}${o?` ${o}`:""}`),"data-swiper-slide-index":u,onLoad:()=>{y(!0)}},f),c&&t.createElement(La.Provider,{value:E},t.createElement("div",{className:"swiper-zoom-container","data-swiper-zoom":"number"==typeof c?c:void 0},w(),d&&!v&&t.createElement("div",{className:"swiper-lazy-preloader"}))),!c&&t.createElement(La.Provider,{value:E},w(),d&&!v&&t.createElement("div",{className:"swiper-lazy-preloader"})))});function Da(e){let{swiper:t,extendParams:r,on:i,emit:n}=e;const s=vs();let a;r({mousewheel:{enabled:!1,releaseOnEdges:!1,invert:!1,forceToAxis:!1,sensitivity:1,eventsTarget:"container",thresholdDelta:null,thresholdTime:null,noMousewheelClass:"swiper-no-mousewheel"}}),t.mousewheel={enabled:!1};let o,l=bs();const c=[];function d(){t.enabled&&(t.mouseEntered=!0)}function u(){t.enabled&&(t.mouseEntered=!1)}function h(e){return!(t.params.mousewheel.thresholdDelta&&e.delta<t.params.mousewheel.thresholdDelta)&&(!(t.params.mousewheel.thresholdTime&&bs()-l<t.params.mousewheel.thresholdTime)&&(e.delta>=6&&bs()-l<60||(e.direction<0?t.isEnd&&!t.params.loop||t.animating||(t.slideNext(),n("scroll",e.raw)):t.isBeginning&&!t.params.loop||t.animating||(t.slidePrev(),n("scroll",e.raw)),l=(new s.Date).getTime(),!1)))}function f(e){let r=e,i=!0;if(!t.enabled)return;if(e.target.closest(`.${t.params.mousewheel.noMousewheelClass}`))return;const s=t.params.mousewheel;t.params.cssMode&&r.preventDefault();let l=t.el;"container"!==t.params.mousewheel.eventsTarget&&(l=document.querySelector(t.params.mousewheel.eventsTarget));const d=l&&l.contains(r.target);if(!t.mouseEntered&&!d&&!s.releaseOnEdges)return!0;r.originalEvent&&(r=r.originalEvent);let u=0;const f=t.rtlTranslate?-1:1,p=function(e){let t=0,r=0,i=0,n=0;return"detail"in e&&(r=e.detail),"wheelDelta"in e&&(r=-e.wheelDelta/120),"wheelDeltaY"in e&&(r=-e.wheelDeltaY/120),"wheelDeltaX"in e&&(t=-e.wheelDeltaX/120),"axis"in e&&e.axis===e.HORIZONTAL_AXIS&&(t=r,r=0),i=10*t,n=10*r,"deltaY"in e&&(n=e.deltaY),"deltaX"in e&&(i=e.deltaX),e.shiftKey&&!i&&(i=n,n=0),(i||n)&&e.deltaMode&&(1===e.deltaMode?(i*=40,n*=40):(i*=800,n*=800)),i&&!t&&(t=i<1?-1:1),n&&!r&&(r=n<1?-1:1),{spinX:t,spinY:r,pixelX:i,pixelY:n}}(r);if(s.forceToAxis)if(t.isHorizontal()){if(!(Math.abs(p.pixelX)>Math.abs(p.pixelY)))return!0;u=-p.pixelX*f}else{if(!(Math.abs(p.pixelY)>Math.abs(p.pixelX)))return!0;u=-p.pixelY}else u=Math.abs(p.pixelX)>Math.abs(p.pixelY)?-p.pixelX*f:-p.pixelY;if(0===u)return!0;s.invert&&(u=-u);let m=t.getTranslate()+u*s.sensitivity;if(m>=t.minTranslate()&&(m=t.minTranslate()),m<=t.maxTranslate()&&(m=t.maxTranslate()),i=!!t.params.loop||!(m===t.minTranslate()||m===t.maxTranslate()),i&&t.params.nested&&r.stopPropagation(),t.params.freeMode&&t.params.freeMode.enabled){const e={time:bs(),delta:Math.abs(u),direction:Math.sign(u)},i=o&&e.time<o.time+500&&e.delta<=o.delta&&e.direction===o.direction;if(!i){o=void 0;let l=t.getTranslate()+u*s.sensitivity;const d=t.isBeginning,h=t.isEnd;if(l>=t.minTranslate()&&(l=t.minTranslate()),l<=t.maxTranslate()&&(l=t.maxTranslate()),t.setTransition(0),t.setTranslate(l),t.updateProgress(),t.updateActiveIndex(),t.updateSlidesClasses(),(!d&&t.isBeginning||!h&&t.isEnd)&&t.updateSlidesClasses(),t.params.loop&&t.loopFix({direction:e.direction<0?"next":"prev",byMousewheel:!0}),t.params.freeMode.sticky){clearTimeout(a),a=void 0,c.length>=15&&c.shift();const r=c.length?c[c.length-1]:void 0,i=c[0];if(c.push(e),r&&(e.delta>r.delta||e.direction!==r.direction))c.splice(0);else if(c.length>=15&&e.time-i.time<500&&i.delta-e.delta>=1&&e.delta<=6){const r=u>0?.8:.2;o=e,c.splice(0),a=ys(()=>{!t.destroyed&&t.params&&t.slideToClosest(t.params.speed,!0,void 0,r)},0)}a||(a=ys(()=>{if(t.destroyed||!t.params)return;o=e,c.splice(0),t.slideToClosest(t.params.speed,!0,void 0,.5)},500))}if(i||n("scroll",r),t.params.autoplay&&t.params.autoplayDisableOnInteraction&&t.autoplay.stop(),s.releaseOnEdges&&(l===t.minTranslate()||l===t.maxTranslate()))return!0}}else{const r={time:bs(),delta:Math.abs(u),direction:Math.sign(u),raw:e};c.length>=2&&c.shift();const i=c.length?c[c.length-1]:void 0;if(c.push(r),i?(r.direction!==i.direction||r.delta>i.delta||r.time>i.time+150)&&h(r):h(r),function(e){const r=t.params.mousewheel;if(e.direction<0){if(t.isEnd&&!t.params.loop&&r.releaseOnEdges)return!0}else if(t.isBeginning&&!t.params.loop&&r.releaseOnEdges)return!0;return!1}(r))return!0}return r.preventDefault?r.preventDefault():r.returnValue=!1,!1}function p(e){let r=t.el;"container"!==t.params.mousewheel.eventsTarget&&(r=document.querySelector(t.params.mousewheel.eventsTarget)),r[e]("mouseenter",d),r[e]("mouseleave",u),r[e]("wheel",f)}function m(){return t.params.cssMode?(t.wrapperEl.removeEventListener("wheel",f),!0):!t.mousewheel.enabled&&(p("addEventListener"),t.mousewheel.enabled=!0,!0)}function g(){return t.params.cssMode?(t.wrapperEl.addEventListener(event,f),!0):!!t.mousewheel.enabled&&(p("removeEventListener"),t.mousewheel.enabled=!1,!0)}i("init",()=>{!t.params.mousewheel.enabled&&t.params.cssMode&&g(),t.params.mousewheel.enabled&&m()}),i("destroy",()=>{t.params.cssMode&&m(),t.mousewheel.enabled&&g()}),Object.assign(t.mousewheel,{enable:m,disable:g})}function _a(e){let{swiper:t,extendParams:r,on:i,emit:n}=e;function s(e){let r;return e&&"string"==typeof e&&t.isElement&&(r=t.el.querySelector(e)||t.hostEl.querySelector(e),r)?r:(e&&("string"==typeof e&&(r=[...document.querySelectorAll(e)]),t.params.uniqueNavElements&&"string"==typeof e&&r&&r.length>1&&1===t.el.querySelectorAll(e).length?r=t.el.querySelector(e):r&&1===r.length&&(r=r[0])),e&&!r?e:r)}function a(e,r){const i=t.params.navigation;(e=_s(e)).forEach(e=>{e&&(e.classList[r?"add":"remove"](...i.disabledClass.split(" ")),"BUTTON"===e.tagName&&(e.disabled=r),t.params.watchOverflow&&t.enabled&&e.classList[t.isLocked?"add":"remove"](i.lockClass))})}function o(){const{nextEl:e,prevEl:r}=t.navigation;if(t.params.loop)return a(r,!1),void a(e,!1);a(r,t.isBeginning&&!t.params.rewind),a(e,t.isEnd&&!t.params.rewind)}function l(e){e.preventDefault(),(!t.isBeginning||t.params.loop||t.params.rewind)&&(t.slidePrev(),n("navigationPrev"))}function c(e){e.preventDefault(),(!t.isEnd||t.params.loop||t.params.rewind)&&(t.slideNext(),n("navigationNext"))}function d(){const e=t.params.navigation;if(t.params.navigation=function(e,t,r,i){return e.params.createElements&&Object.keys(i).forEach(n=>{if(!r[n]&&!0===r.auto){let s=Is(e.el,`.${i[n]}`)[0];s||(s=Rs("div",i[n]),s.className=i[n],e.el.append(s)),r[n]=s,t[n]=s}}),r}(t,t.originalParams.navigation,t.params.navigation,{nextEl:"swiper-button-next",prevEl:"swiper-button-prev"}),!e.nextEl&&!e.prevEl)return;let r=s(e.nextEl),i=s(e.prevEl);Object.assign(t.navigation,{nextEl:r,prevEl:i}),r=_s(r),i=_s(i);const n=(r,i)=>{r&&r.addEventListener("click","next"===i?c:l),!t.enabled&&r&&r.classList.add(...e.lockClass.split(" "))};r.forEach(e=>n(e,"next")),i.forEach(e=>n(e,"prev"))}function u(){let{nextEl:e,prevEl:r}=t.navigation;e=_s(e),r=_s(r);const i=(e,r)=>{e.removeEventListener("click","next"===r?c:l),e.classList.remove(...t.params.navigation.disabledClass.split(" "))};e.forEach(e=>i(e,"next")),r.forEach(e=>i(e,"prev"))}r({navigation:{nextEl:null,prevEl:null,hideOnClick:!1,disabledClass:"swiper-button-disabled",hiddenClass:"swiper-button-hidden",lockClass:"swiper-button-lock",navigationDisabledClass:"swiper-navigation-disabled"}}),t.navigation={nextEl:null,prevEl:null},i("init",()=>{!1===t.params.navigation.enabled?h():(d(),o())}),i("toEdge fromEdge lock unlock",()=>{o()}),i("destroy",()=>{u()}),i("enable disable",()=>{let{nextEl:e,prevEl:r}=t.navigation;e=_s(e),r=_s(r),t.enabled?o():[...e,...r].filter(e=>!!e).forEach(e=>e.classList.add(t.params.navigation.lockClass))}),i("click",(e,r)=>{let{nextEl:i,prevEl:s}=t.navigation;i=_s(i),s=_s(s);const a=r.target;let o=s.includes(a)||i.includes(a);if(t.isElement&&!o){const e=r.path||r.composedPath&&r.composedPath();e&&(o=e.find(e=>i.includes(e)||s.includes(e)))}if(t.params.navigation.hideOnClick&&!o){if(t.pagination&&t.params.pagination&&t.params.pagination.clickable&&(t.pagination.el===a||t.pagination.el.contains(a)))return;let e;i.length?e=i[0].classList.contains(t.params.navigation.hiddenClass):s.length&&(e=s[0].classList.contains(t.params.navigation.hiddenClass)),n(!0===e?"navigationShow":"navigationHide"),[...i,...s].filter(e=>!!e).forEach(e=>e.classList.toggle(t.params.navigation.hiddenClass))}});const h=()=>{t.el.classList.add(...t.params.navigation.navigationDisabledClass.split(" ")),u()};Object.assign(t.navigation,{enable:()=>{t.el.classList.remove(...t.params.navigation.navigationDisabledClass.split(" ")),d(),o()},disable:h,update:o,init:d,destroy:u})}function Oa(e){let t,r,{swiper:i,extendParams:n,on:s,emit:a,params:o}=e;i.autoplay={running:!1,paused:!1,timeLeft:0},n({autoplay:{enabled:!1,delay:3e3,waitForTransition:!0,disableOnInteraction:!1,stopOnLastSlide:!1,reverseDirection:!1,pauseOnMouseEnter:!1}});let l,c,d,u,h,f,p,m,g=o&&o.autoplay?o.autoplay.delay:3e3,v=o&&o.autoplay?o.autoplay.delay:3e3,y=(new Date).getTime();function b(e){i&&!i.destroyed&&i.wrapperEl&&e.target===i.wrapperEl&&(i.wrapperEl.removeEventListener("transitionend",b),m||e.detail&&e.detail.bySwiperTouchMove||A())}const E=()=>{if(i.destroyed||!i.autoplay.running)return;i.autoplay.paused?c=!0:c&&(v=l,c=!1);const e=i.autoplay.paused?l:y+v-(new Date).getTime();i.autoplay.timeLeft=e,a("autoplayTimeLeft",e,e/g),r=requestAnimationFrame(()=>{E()})},w=e=>{if(i.destroyed||!i.autoplay.running)return;cancelAnimationFrame(r),E();let n=void 0===e?i.params.autoplay.delay:e;g=i.params.autoplay.delay,v=i.params.autoplay.delay;const s=(()=>{let e;if(e=i.virtual&&i.params.virtual.enabled?i.slides.filter(e=>e.classList.contains("swiper-slide-active"))[0]:i.slides[i.activeIndex],!e)return;return parseInt(e.getAttribute("data-swiper-autoplay"),10)})();!Number.isNaN(s)&&s>0&&void 0===e&&(n=s,g=s,v=s),l=n;const o=i.params.speed,c=()=>{i&&!i.destroyed&&(i.params.autoplay.reverseDirection?!i.isBeginning||i.params.loop||i.params.rewind?(i.slidePrev(o,!0,!0),a("autoplay")):i.params.autoplay.stopOnLastSlide||(i.slideTo(i.slides.length-1,o,!0,!0),a("autoplay")):!i.isEnd||i.params.loop||i.params.rewind?(i.slideNext(o,!0,!0),a("autoplay")):i.params.autoplay.stopOnLastSlide||(i.slideTo(0,o,!0,!0),a("autoplay")),i.params.cssMode&&(y=(new Date).getTime(),requestAnimationFrame(()=>{w()})))};return n>0?(clearTimeout(t),t=setTimeout(()=>{c()},n)):requestAnimationFrame(()=>{c()}),n},S=()=>{y=(new Date).getTime(),i.autoplay.running=!0,w(),a("autoplayStart")},T=()=>{i.autoplay.running=!1,clearTimeout(t),cancelAnimationFrame(r),a("autoplayStop")},x=(e,r)=>{if(i.destroyed||!i.autoplay.running)return;clearTimeout(t),e||(p=!0);const n=()=>{a("autoplayPause"),i.params.autoplay.waitForTransition?i.wrapperEl.addEventListener("transitionend",b):A()};if(i.autoplay.paused=!0,r)return f&&(l=i.params.autoplay.delay),f=!1,void n();const s=l||i.params.autoplay.delay;l=s-((new Date).getTime()-y),i.isEnd&&l<0&&!i.params.loop||(l<0&&(l=0),n())},A=()=>{i.isEnd&&l<0&&!i.params.loop||i.destroyed||!i.autoplay.running||(y=(new Date).getTime(),p?(p=!1,w(l)):w(),i.autoplay.paused=!1,a("autoplayResume"))},k=()=>{if(i.destroyed||!i.autoplay.running)return;const e=ms();"hidden"===e.visibilityState&&(p=!0,x(!0)),"visible"===e.visibilityState&&A()},I=e=>{"mouse"===e.pointerType&&(p=!0,m=!0,i.animating||i.autoplay.paused||x(!0))},L=e=>{"mouse"===e.pointerType&&(m=!1,i.autoplay.paused&&A())};s("init",()=>{i.params.autoplay.enabled&&(i.params.autoplay.pauseOnMouseEnter&&(i.el.addEventListener("pointerenter",I),i.el.addEventListener("pointerleave",L)),ms().addEventListener("visibilitychange",k),S())}),s("destroy",()=>{i.el&&"string"!=typeof i.el&&(i.el.removeEventListener("pointerenter",I),i.el.removeEventListener("pointerleave",L)),ms().removeEventListener("visibilitychange",k),i.autoplay.running&&T()}),s("_freeModeStaticRelease",()=>{(u||p)&&A()}),s("_freeModeNoMomentumRelease",()=>{i.params.autoplay.disableOnInteraction?T():x(!0,!0)}),s("beforeTransitionStart",(e,t,r)=>{!i.destroyed&&i.autoplay.running&&(r||!i.params.autoplay.disableOnInteraction?x(!0,!0):T())}),s("sliderFirstMove",()=>{!i.destroyed&&i.autoplay.running&&(i.params.autoplay.disableOnInteraction?T():(d=!0,u=!1,p=!1,h=setTimeout(()=>{p=!0,u=!0,x(!0)},200)))}),s("touchEnd",()=>{if(!i.destroyed&&i.autoplay.running&&d){if(clearTimeout(h),clearTimeout(t),i.params.autoplay.disableOnInteraction)return u=!1,void(d=!1);u&&i.params.cssMode&&A(),u=!1,d=!1}}),s("slideChange",()=>{!i.destroyed&&i.autoplay.running&&(f=!0)}),Object.assign(i.autoplay,{start:S,stop:T,pause:x,resume:A})}function Ma(e){let t,r,i,n,{swiper:s,extendParams:a,on:o}=e;a({grid:{rows:1,fill:"column"}});const l=()=>{let e=s.params.spaceBetween;return"string"==typeof e&&e.indexOf("%")>=0?e=parseFloat(e.replace("%",""))/100*s.size:"string"==typeof e&&(e=parseFloat(e)),e};o("init",()=>{n=s.params.grid&&s.params.grid.rows>1}),o("update",()=>{const{params:e,el:t}=s,r=e.grid&&e.grid.rows>1;n&&!r?(t.classList.remove(`${e.containerModifierClass}grid`,`${e.containerModifierClass}grid-column`),i=1,s.emitContainerClasses()):!n&&r&&(t.classList.add(`${e.containerModifierClass}grid`),"column"===e.grid.fill&&t.classList.add(`${e.containerModifierClass}grid-column`),s.emitContainerClasses()),n=r}),s.grid={initSlides:e=>{const{slidesPerView:n}=s.params,{rows:a,fill:o}=s.params.grid,l=s.virtual&&s.params.virtual.enabled?s.virtual.slides.length:e.length;i=Math.floor(l/a),t=Math.floor(l/a)===l/a?l:Math.ceil(l/a)*a,"auto"!==n&&"row"===o&&(t=Math.max(t,n*a)),r=t/a},unsetSlides:()=>{s.slides&&s.slides.forEach(e=>{e.swiperSlideGridSet&&(e.style.height="",e.style[s.getDirectionLabel("margin-top")]="")})},updateSlide:(e,n,a)=>{const{slidesPerGroup:o}=s.params,c=l(),{rows:d,fill:u}=s.params.grid,h=s.virtual&&s.params.virtual.enabled?s.virtual.slides.length:a.length;let f,p,m;if("row"===u&&o>1){const r=Math.floor(e/(o*d)),i=e-d*o*r,s=0===r?o:Math.min(Math.ceil((h-r*d*o)/d),o);m=Math.floor(i/s),p=i-m*s+r*o,f=p+m*t/d,n.style.order=f}else"column"===u?(p=Math.floor(e/d),m=e-p*d,(p>i||p===i&&m===d-1)&&(m+=1,m>=d&&(m=0,p+=1))):(m=Math.floor(e/r),p=e-m*r);n.row=m,n.column=p,n.style.height=`calc((100% - ${(d-1)*c}px) / ${d})`,n.style[s.getDirectionLabel("margin-top")]=0!==m?c&&`${c}px`:"",n.swiperSlideGridSet=!0},updateWrapperSize:(e,r)=>{const{centeredSlides:i,roundLengths:n}=s.params,a=l(),{rows:o}=s.params.grid;if(s.virtualSize=(e+a)*t,s.virtualSize=Math.ceil(s.virtualSize/o)-a,s.params.cssMode||(s.wrapperEl.style[s.getDirectionLabel("width")]=`${s.virtualSize+a}px`),i){const e=[];for(let t=0;t<r.length;t+=1){let i=r[t];n&&(i=Math.floor(i)),r[t]<s.virtualSize+r[0]&&e.push(i)}r.splice(0,r.length),r.push(...e)}}}}function Na(e){const t=this,{params:r,slidesEl:i}=t;r.loop&&t.loopDestroy();const n=e=>{if("string"==typeof e){const t=document.createElement("div");t.innerHTML=e,i.append(t.children[0]),t.innerHTML=""}else i.append(e)};if("object"==typeof e&&"length"in e)for(let t=0;t<e.length;t+=1)e[t]&&n(e[t]);else n(e);t.recalcSlides(),r.loop&&t.loopCreate(),r.observer&&!t.isElement||t.update()}function Fa(e){const t=this,{params:r,activeIndex:i,slidesEl:n}=t;r.loop&&t.loopDestroy();let s=i+1;const a=e=>{if("string"==typeof e){const t=document.createElement("div");t.innerHTML=e,n.prepend(t.children[0]),t.innerHTML=""}else n.prepend(e)};if("object"==typeof e&&"length"in e){for(let t=0;t<e.length;t+=1)e[t]&&a(e[t]);s=i+e.length}else a(e);t.recalcSlides(),r.loop&&t.loopCreate(),r.observer&&!t.isElement||t.update(),t.slideTo(s,0,!1)}function $a(e,t){const r=this,{params:i,activeIndex:n,slidesEl:s}=r;let a=n;i.loop&&(a-=r.loopedSlides,r.loopDestroy(),r.recalcSlides());const o=r.slides.length;if(e<=0)return void r.prependSlide(t);if(e>=o)return void r.appendSlide(t);let l=a>e?a+1:a;const c=[];for(let t=o-1;t>=e;t-=1){const e=r.slides[t];e.remove(),c.unshift(e)}if("object"==typeof t&&"length"in t){for(let e=0;e<t.length;e+=1)t[e]&&s.append(t[e]);l=a>e?a+t.length:a}else s.append(t);for(let e=0;e<c.length;e+=1)s.append(c[e]);r.recalcSlides(),i.loop&&r.loopCreate(),i.observer&&!r.isElement||r.update(),i.loop?r.slideTo(l+r.loopedSlides,0,!1):r.slideTo(l,0,!1)}function Ba(e){const t=this,{params:r,activeIndex:i}=t;let n=i;r.loop&&(n-=t.loopedSlides,t.loopDestroy());let s,a=n;if("object"==typeof e&&"length"in e){for(let r=0;r<e.length;r+=1)s=e[r],t.slides[s]&&t.slides[s].remove(),s<a&&(a-=1);a=Math.max(a,0)}else s=e,t.slides[s]&&t.slides[s].remove(),s<a&&(a-=1),a=Math.max(a,0);t.recalcSlides(),r.loop&&t.loopCreate(),r.observer&&!t.isElement||t.update(),r.loop?t.slideTo(a+t.loopedSlides,0,!1):t.slideTo(a,0,!1)}function Ua(){const e=this,t=[];for(let r=0;r<e.slides.length;r+=1)t.push(r);e.removeSlide(t)}function za(e){let{swiper:t}=e;Object.assign(t,{appendSlide:Na.bind(t),prependSlide:Fa.bind(t),addSlide:$a.bind(t),removeSlide:Ba.bind(t),removeAllSlides:Ua.bind(t)})}function Ga(e,t){const r=ks(t);return r!==t&&(r.style.backfaceVisibility="hidden",r.style["-webkit-backface-visibility"]="hidden"),r}function ja(e){let{swiper:t,duration:r,transformElements:i,allSlides:n}=e;const{activeIndex:s}=t;if(t.params.virtualTranslate&&0!==r){let e,r=!1;e=n?i:i.filter(e=>{const r=e.classList.contains("swiper-slide-transform")?(e=>{if(!e.parentElement)return t.slides.filter(t=>t.shadowRoot&&t.shadowRoot===e.parentNode)[0];return e.parentElement})(e):e;return t.getSlideIndex(r)===s}),e.forEach(e=>{!function(e,t){t&&e.addEventListener("transitionend",function r(i){i.target===e&&(t.call(e,i),e.removeEventListener("transitionend",r))})}(e,()=>{if(r)return;if(!t||t.destroyed)return;r=!0,t.animating=!1;const e=new window.CustomEvent("transitionend",{bubbles:!0,cancelable:!0});t.wrapperEl.dispatchEvent(e)})})}}function Ha(e,t,r){const i=`swiper-slide-shadow swiper-slide-shadow-${e}`,n=ks(t);let s=n.querySelector(`.${i.split(" ").join(".")}`);return s||(s=Rs("div",i.split(" ")),n.append(s)),s}function Va(e){let{swiper:t,extendParams:r,on:i}=e;r({cardsEffect:{slideShadows:!0,rotate:!0,perSlideRotate:2,perSlideOffset:8}});!function(e){const{effect:t,swiper:r,on:i,setTranslate:n,setTransition:s,overwriteParams:a,perspective:o,recreateShadows:l,getEffectParams:c}=e;let d;i("beforeInit",()=>{if(r.params.effect!==t)return;r.classNames.push(`${r.params.containerModifierClass}${t}`),o&&o()&&r.classNames.push(`${r.params.containerModifierClass}3d`);const e=a?a():{};Object.assign(r.params,e),Object.assign(r.originalParams,e)}),i("setTranslate",()=>{r.params.effect===t&&n()}),i("setTransition",(e,i)=>{r.params.effect===t&&s(i)}),i("transitionEnd",()=>{if(r.params.effect===t&&l){if(!c||!c().slideShadows)return;r.slides.forEach(e=>{e.querySelectorAll(".swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left").forEach(e=>e.remove())}),l()}}),i("virtualUpdate",()=>{r.params.effect===t&&(r.slides.length||(d=!0),requestAnimationFrame(()=>{d&&r.slides&&r.slides.length&&(n(),d=!1)}))})}({effect:"cards",swiper:t,on:i,setTranslate:()=>{const{slides:e,activeIndex:r,rtlTranslate:i}=t,n=t.params.cardsEffect,{startTranslate:s,isTouched:a}=t.touchEventsData,o=i?-t.translate:t.translate;for(let l=0;l<e.length;l+=1){const c=e[l],d=c.progress,u=Math.min(Math.max(d,-4),4);let h=c.swiperSlideOffset;t.params.centeredSlides&&!t.params.cssMode&&(t.wrapperEl.style.transform=`translateX(${t.minTranslate()}px)`),t.params.centeredSlides&&t.params.cssMode&&(h-=e[0].swiperSlideOffset);let f=t.params.cssMode?-h-t.translate:-h,p=0;const m=-100*Math.abs(u);let g=1,v=-n.perSlideRotate*u,y=n.perSlideOffset-.75*Math.abs(u);const b=t.virtual&&t.params.virtual.enabled?t.virtual.from+l:l,E=(b===r||b===r-1)&&u>0&&u<1&&(a||t.params.cssMode)&&o<s,w=(b===r||b===r+1)&&u<0&&u>-1&&(a||t.params.cssMode)&&o>s;if(E||w){const e=(1-Math.abs((Math.abs(u)-.5)/.5))**.5;v+=-28*u*e,g+=-.5*e,y+=96*e,p=-25*e*Math.abs(u)+"%"}if(f=u<0?`calc(${f}px ${i?"-":"+"} (${y*Math.abs(u)}%))`:u>0?`calc(${f}px ${i?"-":"+"} (-${y*Math.abs(u)}%))`:`${f}px`,!t.isHorizontal()){const e=p;p=f,f=e}const S=u<0?""+(1+(1-g)*u):""+(1-(1-g)*u),T=`\n translate3d(${f}, ${p}, ${m}px)\n rotateZ(${n.rotate?i?-v:v:0}deg)\n scale(${S})\n `;if(n.slideShadows){let e=c.querySelector(".swiper-slide-shadow");e||(e=Ha("cards",c)),e&&(e.style.opacity=Math.min(Math.max((Math.abs(u)-.5)/.5,0),1))}c.style.zIndex=-Math.abs(Math.round(d))+e.length;Ga(0,c).style.transform=T}},setTransition:e=>{const r=t.slides.map(e=>ks(e));r.forEach(t=>{t.style.transitionDuration=`${e}ms`,t.querySelectorAll(".swiper-slide-shadow").forEach(t=>{t.style.transitionDuration=`${e}ms`})}),ja({swiper:t,duration:e,transformElements:r})},perspective:()=>!0,overwriteParams:()=>({watchSlidesProgress:!0,virtualTranslate:!t.params.cssMode})})}Ca.displayName="SwiperSlide";const Wa=({product:e,contentId:r,isPreview:i})=>{var n;const[a,o]=s(!1);return t.createElement("a",{href:null!==(n=e.linkPath)&&void 0!==n?n:void 0,"data-mgcode":e.mallProductCode,target:"_blank",rel:"noopener noreferrer",className:"apphref",onClick:t=>{r&&(i||Gt({contentProductId:e.eventProductId,contentId:r,productId:e.productId}),Mt(t.currentTarget)?t.preventDefault():e.linkPath&&(t.preventDefault(),window.open(e.linkPath,"_blank","noopener,noreferrer")))}},t.createElement("div",{className:"w-full h-full min-w-0 flex gap-2 flex-col"},t.createElement("div",{className:"mb-2 flex aspect-square w-full max-h-fit items-center justify-center overflow-hidden rounded border"},e.thumbPath&&!a?t.createElement(bi,{product:e,onError:()=>o(!0)}):t.createElement(yi,null)),t.createElement("div",{className:"justify-center flex flex-col min-w-0"},e.brand&&t.createElement("p",{className:"max-w-52 break-keep line-clamp-1 text-xs text-gray-500"},e.brand.brandName),t.createElement("p",{className:"break-keep line-clamp-2"},e.productName),t.createElement("div",{className:"break-keep"},t.createElement("span",{className:"font-semibold text-red-500"},e.discount,"%"," "),t.createElement("span",{className:"font-semibold"},Tt(e.sellingPrice,e.currency))))))},Ya=({products:e,contentId:i,isPreview:n})=>{const s=r(null);return e&&t.createElement("div",{className:"relative flex h-full w-full max-w-[830px] items-center"},e.length>3&&t.createElement("button",{"aria-label":"prev",onClick:()=>{var e;null===(e=s.current)||void 0===e||e.slidePrev()},className:"absolute left-0 top-1/2 z-10 -translate-y-1/2 cursor-pointer text-zinc-500"},t.createElement(ii,{size:32,strokeWidth:1})),t.createElement("div",{className:"w-full px-10"},t.createElement(Pa,{modules:[_a],onSwiper:e=>{s.current=e},slidesPerView:3,navigation:{prevEl:".slide__prev",nextEl:".slide__next"},spaceBetween:0},e.map(e=>t.createElement(Ca,{key:e.productId},t.createElement("div",{className:"h-full px-3 md:px-4 lg:px-5"},t.createElement(Wa,{product:e,contentId:i,isPreview:n})))))),e.length>3&&t.createElement("button",{"aria-label":"next",onClick:()=>{var e;null===(e=s.current)||void 0===e||e.slideNext()},className:"absolute right-0 top-1/2 z-10 -translate-y-1/2 cursor-pointer text-zinc-500"},t.createElement(ni,{size:32,strokeWidth:1})))},Ka=e=>{const{isPreview:r,player:i,shortform:n}=e;return t.createElement("div",{className:"flex h-full w-full gap-5 bg-white items-center"},t.createElement("div",{className:"h-full shrink-0"},i),t.createElement("div",{className:"flex h-full w-full min-w-44 max-w-[800px] items-center overflow-hidden text-sm"},t.createElement(Ya,{products:n.productsInfo,contentId:n.shortsId,isPreview:r})))},qa=({products:e,contentId:n,isPreview:a})=>{const o=r(null),l=r(null),[c,d]=s(4);return i(()=>{const e=l.current;if(!e)return;const t=()=>{const t=e.clientHeight;if(!t)return;const r=Math.max(1,Math.floor((t+12)/112));d(r)};t();const r=new ResizeObserver(()=>t());return r.observe(e),window.addEventListener("resize",t),()=>{r.disconnect(),window.removeEventListener("resize",t)}},[]),t.createElement("div",{className:"flex h-[80%] min-h-0 w-full flex-col items-center",style:{height:500}},e.length>c&&t.createElement(si,{size:50,strokeWidth:1,className:"slide__prev shrink-0 cursor-pointer text-zinc-500"}),t.createElement("div",{ref:l,className:"min-h-0 w-full max-w-full flex-1"},t.createElement(Pa,{modules:[Da,_a],mousewheel:!0,onSwiper:e=>{o.current=e},spaceBetween:12,className:"h-full min-h-0 w-full max-w-full",slidesPerView:c,direction:"vertical",navigation:{prevEl:".slide__prev",nextEl:".slide__next"}},e.map(e=>t.createElement(Ca,{key:e.productId},t.createElement("div",{className:"h-full items-center flex"},t.createElement(Ei,{product:e,contentId:n,isPreview:a})))))),e.length>c&&t.createElement(ri,{size:50,strokeWidth:1,className:"slide__next shrink-0 cursor-pointer text-zinc-500"}))},Xa=e=>{const{isPreview:r,playerSettings:i,shortform:{productsInfo:n,shortsId:s},player:a}=e;return t.createElement("div",{className:"flex h-full w-full gap-5"},t.createElement("div",{className:" h-full "},a),t.createElement("div",{className:"max-w-[800px] overflow-hidden"},t.createElement(qa,{products:n,contentId:s,isPreview:r})))},Qa=({products:e,contentId:i,isPreview:n})=>{const s=r(null),a=e.length>6;return t.createElement("div",{className:"relative flex h-full w-full max-w-[830px] items-center text-sm"},a&&t.createElement("button",{"aria-label":"prev",onClick:()=>{var e;null===(e=s.current)||void 0===e||e.slidePrev()},className:"absolute left-0 top-1/2 z-10 -translate-y-1/2 cursor-pointer text-zinc-500"},t.createElement(ii,{size:50,strokeWidth:1})),t.createElement("div",{className:"w-full px-14"},t.createElement(Pa,{onSwiper:e=>{s.current=e},slidesPerView:3,spaceBetween:20,modules:[Ma],grid:{rows:2,fill:"row"}},e.map(e=>t.createElement(Ca,{key:e.productId},t.createElement(Wa,{product:e,contentId:i,isPreview:n}))))),a&&t.createElement("button",{"aria-label":"next",onClick:()=>{var e;null===(e=s.current)||void 0===e||e.slideNext()},className:"absolute right-0 top-1/2 z-10 -translate-y-1/2 cursor-pointer text-zinc-500"},t.createElement(ni,{size:50,strokeWidth:1})))},Za=e=>{const{isPreview:r,player:i,shortform:{productsInfo:n,shortsId:s}}=e;return t.createElement("div",{className:"flex gap-4 w-full h-full min-w-[768px] items-center"},t.createElement("div",{className:"flex-1 w-full h-full flex justify-center"},i),t.createElement("div",{className:"flex-[2] w-full h-full overflow-hidden"},t.createElement(Qa,{products:n,contentId:s,isPreview:r})))},Ja="cursor-pointer text-zinc-500",eo=e=>{const{collection:i,shortform:n,setShortform:s}=e,a=r(null);return t.createElement(t.Fragment,null,i.contents.length>1&&t.createElement("div",{className:"self-center flex gap-4 flex-col"},t.createElement(si,{size:44,strokeWidth:1,className:Ja,onClick:()=>{var e;null===(e=a.current)||void 0===e||e.swiper.slidePrev()}}),t.createElement(ri,{size:44,strokeWidth:1,className:Ja,onClick:()=>{var e;null===(e=a.current)||void 0===e||e.swiper.slideNext()}})),t.createElement("div",{className:"h-full aspect-[9/16] relative"},t.createElement(Pa,{modules:[Da,za],mousewheel:!0,loop:i.contents.length>1,direction:"vertical",touchEventsTarget:"container",preventClicksPropagation:!1,preventClicks:!1,allowTouchMove:!1,slidesPerView:1.05,ref:a,className:"h-full z-10",onSlideChangeTransitionEnd:e=>{(e=>{const t=i.contents[e];t&&s(Object.assign({},t))})(e.realIndex)}},i.contents.map(e=>t.createElement(Ca,{key:e.shortsId,className:"rounded-xl overflow-hidden aspect-[9/16]"},t.createElement("div",{className:"h-[95%] mb-2"},n.shortsId===e.shortsId&&t.createElement("div",{className:"h-[95%] overflow-hidden rounded-xl absolute z-[999] w-full"},t.createElement(I,{file:xt(n.media.objectId)})),t.createElement("img",{src:Dt(e.thumbPath),alt:e.title,className:"rounded-xl w-full h-full bg-black "+(e.media.width>e.media.height?"object-contain":"object-cover")})))))))},to=()=>t.createElement("div",{className:"inline-block absolute pointer-events-none top-0 z-10 animate-float w-[24px] h-[24px]"},t.createElement(li,{className:"fill-red-500 text-transparent w-[24px] h-[24px]"})),ro=({shortsId:e,isPreview:r})=>{const n=ar(e=>e.isPreview),a=null!=r?r:n,[o,l]=s(a?123:0),[c,d]=s([]);i(()=>{a?l(123):x(void 0,void 0,void 0,function*(){try{const t=yield jt(e);l(t)}catch(e){return console.error(`Error in statistics getLikeInLive: ${e.toString()}`),0}})},[a,e]);return t.createElement("div",{className:"flex justify-center flex-col items-center relative"},t.createElement("button",{onClick:()=>x(void 0,void 0,void 0,function*(){(()=>{const e=Date.now();d(t=>[...t,e]),setTimeout(()=>{d(t=>t.filter(t=>t!==e))},2e3)})(),l(e=>e+1),a||(yield x(void 0,void 0,void 0,function*(){yield Ht(e)}))}),className:"z-[5] cursor-pointer","aria-label":"좋아요"},t.createElement("div",{className:"glass-panel flex h-10 w-10 items-center justify-center rounded-full"},t.createElement("img",{src:"https://mbus-asset.s3.ap-northeast-2.amazonaws.com/mcom-player/heart.png",width:24,height:24,className:"block h-6 w-6 object-contain",alt:"like"}))),c.map(e=>t.createElement(to,{key:e})),t.createElement("span",{className:"break-keep text-[10px]"},kt(o)))};var io,no,so={},ao={exports:{}},oo=ao.exports;function lo(){return io||(io=1,e=ao,t=ao.exports,function(r,i){var n="function",s="undefined",a="object",o="string",l="major",c="model",d="name",u="type",h="vendor",f="version",p="architecture",m="console",g="mobile",v="tablet",y="smarttv",b="wearable",E="embedded",w="Amazon",S="Apple",T="ASUS",x="BlackBerry",A="Browser",k="Chrome",I="Firefox",L="Google",R="Huawei",P="LG",C="Microsoft",D="Motorola",_="Opera",O="Samsung",M="Sharp",N="Sony",F="Xiaomi",$="Zebra",B="Facebook",U="Chromium OS",z="Mac OS",G=" Browser",j=function(e){for(var t={},r=0;r<e.length;r++)t[e[r].toUpperCase()]=e[r];return t},H=function(e,t){return typeof e===o&&-1!==V(t).indexOf(V(e))},V=function(e){return e.toLowerCase()},W=function(e,t){if(typeof e===o)return e=e.replace(/^\s\s*/,""),typeof t===s?e:e.substring(0,500)},Y=function(e,t){for(var r,s,o,l,c,d,u=0;u<t.length&&!c;){var h=t[u],f=t[u+1];for(r=s=0;r<h.length&&!c&&h[r];)if(c=h[r++].exec(e))for(o=0;o<f.length;o++)d=c[++s],typeof(l=f[o])===a&&l.length>0?2===l.length?typeof l[1]==n?this[l[0]]=l[1].call(this,d):this[l[0]]=l[1]:3===l.length?typeof l[1]!==n||l[1].exec&&l[1].test?this[l[0]]=d?d.replace(l[1],l[2]):i:this[l[0]]=d?l[1].call(this,d,l[2]):i:4===l.length&&(this[l[0]]=d?l[3].call(this,d.replace(l[1],l[2])):i):this[l]=d||i;u+=2}},K=function(e,t){for(var r in t)if(typeof t[r]===a&&t[r].length>0){for(var n=0;n<t[r].length;n++)if(H(t[r][n],e))return"?"===r?i:r}else if(H(t[r],e))return"?"===r?i:r;return t.hasOwnProperty("*")?t["*"]:e},q={ME:"4.90","NT 3.11":"NT3.51","NT 4.0":"NT4.0",2e3:"NT 5.0",XP:["NT 5.1","NT 5.2"],Vista:"NT 6.0",7:"NT 6.1",8:"NT 6.2",8.1:"NT 6.3",10:["NT 6.4","NT 10.0"],RT:"ARM"},X={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[f,[d,"Chrome"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[f,[d,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[d,f],[/opios[\/ ]+([\w\.]+)/i],[f,[d,_+" Mini"]],[/\bop(?:rg)?x\/([\w\.]+)/i],[f,[d,_+" GX"]],[/\bopr\/([\w\.]+)/i],[f,[d,_]],[/\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[\/ ]?([\w\.]+)/i],[f,[d,"Baidu"]],[/\b(?:mxbrowser|mxios|myie2)\/?([-\w\.]*)\b/i],[f,[d,"Maxthon"]],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer|sleipnir)[\/ ]?([\w\.]*)/i,/(avant|iemobile|slim(?:browser|boat|jet))[\/ ]?([\d\.]*)/i,/(?:ms|\()(ie) ([\w\.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|duckduckgo|klar|helio|(?=comodo_)?dragon)\/([-\w\.]+)/i,/(heytap|ovi|115)browser\/([\d\.]+)/i,/(weibo)__([\d\.]+)/i],[d,f],[/quark(?:pc)?\/([-\w\.]+)/i],[f,[d,"Quark"]],[/\bddg\/([\w\.]+)/i],[f,[d,"DuckDuckGo"]],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[f,[d,"UC"+A]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i,/micromessenger\/([\w\.]+)/i],[f,[d,"WeChat"]],[/konqueror\/([\w\.]+)/i],[f,[d,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[f,[d,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[f,[d,"Yandex"]],[/slbrowser\/([\w\.]+)/i],[f,[d,"Smart Lenovo "+A]],[/(avast|avg)\/([\w\.]+)/i],[[d,/(.+)/,"$1 Secure "+A],f],[/\bfocus\/([\w\.]+)/i],[f,[d,I+" Focus"]],[/\bopt\/([\w\.]+)/i],[f,[d,_+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[f,[d,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[f,[d,"Dolphin"]],[/coast\/([\w\.]+)/i],[f,[d,_+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[f,[d,"MIUI"+G]],[/fxios\/([\w\.-]+)/i],[f,[d,I]],[/\bqihoobrowser\/?([\w\.]*)/i],[f,[d,"360"]],[/\b(qq)\/([\w\.]+)/i],[[d,/(.+)/,"$1Browser"],f],[/(oculus|sailfish|huawei|vivo|pico)browser\/([\w\.]+)/i],[[d,/(.+)/,"$1"+G],f],[/samsungbrowser\/([\w\.]+)/i],[f,[d,O+" Internet"]],[/metasr[\/ ]?([\d\.]+)/i],[f,[d,"Sogou Explorer"]],[/(sogou)mo\w+\/([\d\.]+)/i],[[d,"Sogou Mobile"],f],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|2345(?=browser|chrome|explorer))\w*[\/ ]?v?([\w\.]+)/i],[d,f],[/(lbbrowser|rekonq)/i,/\[(linkedin)app\]/i],[d],[/ome\/([\w\.]+) \w* ?(iron) saf/i,/ome\/([\w\.]+).+qihu (360)[es]e/i],[f,d],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[d,B],f],[/(Klarna)\/([\w\.]+)/i,/(kakao(?:talk|story))[\/ ]([\w\.]+)/i,/(naver)\(.*?(\d+\.[\w\.]+).*\)/i,/safari (line)\/([\w\.]+)/i,/\b(line)\/([\w\.]+)\/iab/i,/(alipay)client\/([\w\.]+)/i,/(twitter)(?:and| f.+e\/([\w\.]+))/i,/(chromium|instagram|snapchat)[\/ ]([-\w\.]+)/i],[d,f],[/\bgsa\/([\w\.]+) .*safari\//i],[f,[d,"GSA"]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[f,[d,"TikTok"]],[/headlesschrome(?:\/([\w\.]+)| )/i],[f,[d,k+" Headless"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[d,k+" WebView"],f],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[f,[d,"Android "+A]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[d,f],[/version\/([\w\.\,]+) .*mobile\/\w+ (safari)/i],[f,[d,"Mobile Safari"]],[/version\/([\w(\.|\,)]+) .*(mobile ?safari|safari)/i],[f,d],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[d,[f,K,{"1.0":"/8",1.2:"/1",1.3:"/3","2.0":"/412","2.0.2":"/416","2.0.3":"/417","2.0.4":"/419","?":"/"}]],[/(webkit|khtml)\/([\w\.]+)/i],[d,f],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[d,"Netscape"],f],[/(wolvic|librewolf)\/([\w\.]+)/i],[d,f],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[f,[d,I+" Reality"]],[/ekiohf.+(flow)\/([\w\.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror)[\/ ]?([\w\.\+]+)/i,/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,/(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i,/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|obigo|mosaic|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/(links) \(([\w\.]+)/i],[d,[f,/_/g,"."]],[/(cobalt)\/([\w\.]+)/i],[d,[f,/master.|lts./,""]]],cpu:[[/(?:(amd|x(?:(?:86|64)[-_])?|wow|win)64)[;\)]/i],[[p,"amd64"]],[/(ia32(?=;))/i],[[p,V]],[/((?:i[346]|x)86)[;\)]/i],[[p,"ia32"]],[/\b(aarch64|arm(v?8e?l?|_?64))\b/i],[[p,"arm64"]],[/\b(arm(?:v[67])?ht?n?[fl]p?)\b/i],[[p,"armhf"]],[/windows (ce|mobile); ppc;/i],[[p,"arm"]],[/((?:ppc|powerpc)(?:64)?)(?: mac|;|\))/i],[[p,/ower/,"",V]],[/(sun4\w)[;\)]/i],[[p,"sparc"]],[/((?:avr32|ia64(?=;))|68k(?=\))|\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\b|pa-risc)/i],[[p,V]]],device:[[/\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i],[c,[h,O],[u,v]],[/\b((?:s[cgp]h|gt|sm)-(?![lr])\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,/samsung[- ]((?!sm-[lr])[-\w]+)/i,/sec-(sgh\w+)/i],[c,[h,O],[u,g]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i],[c,[h,S],[u,g]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[c,[h,S],[u,v]],[/(macintosh);/i],[c,[h,S]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[c,[h,M],[u,g]],[/(?:honor)([-\w ]+)[;\)]/i],[c,[h,"Honor"],[u,g]],[/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i],[c,[h,R],[u,v]],[/(?:huawei)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[c,[h,R],[u,g]],[/\b(poco[\w ]+|m2\d{3}j\d\d[a-z]{2})(?: bui|\))/i,/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,/oid[^\)]+; (m?[12][0-389][01]\w{3,6}[c-y])( bui|; wv|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite|pro)?)(?: bui|\))/i],[[c,/_/g," "],[h,F],[u,g]],[/oid[^\)]+; (2\d{4}(283|rpbf)[cgl])( bui|\))/i,/\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i],[[c,/_/g," "],[h,F],[u,v]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[c,[h,"OPPO"],[u,g]],[/\b(opd2\d{3}a?) bui/i],[c,[h,"OPPO"],[u,v]],[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[c,[h,"Vivo"],[u,g]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i],[c,[h,"Realme"],[u,g]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,/\bmot(?:orola)?[- ](\w*)/i,/((?:moto[\w\(\) ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i],[c,[h,D],[u,g]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[c,[h,D],[u,v]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[c,[h,P],[u,v]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+((?!browser|netcast|android tv)\w+)/i,/\blg-?([\d\w]+) bui/i],[c,[h,P],[u,g]],[/(ideatab[-\w ]+)/i,/lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i],[c,[h,"Lenovo"],[u,v]],[/(?:maemo|nokia).*(n900|lumia \d+)/i,/nokia[-_ ]?([-\w\.]*)/i],[[c,/_/g," "],[h,"Nokia"],[u,g]],[/(pixel c)\b/i],[c,[h,L],[u,v]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[c,[h,L],[u,g]],[/droid.+; (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i],[c,[h,N],[u,g]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[c,"Xperia Tablet"],[h,N],[u,v]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[c,[h,"OnePlus"],[u,g]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo(?!bc)\w\w)( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[c,[h,w],[u,v]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[c,/(.+)/g,"Fire Phone $1"],[h,w],[u,g]],[/(playbook);[-\w\),; ]+(rim)/i],[c,h,[u,v]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[c,[h,x],[u,g]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[c,[h,T],[u,v]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[c,[h,T],[u,g]],[/(nexus 9)/i],[c,[h,"HTC"],[u,v]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[h,[c,/_/g," "],[u,g]],[/droid [\w\.]+; ((?:8[14]9[16]|9(?:0(?:48|60|8[01])|1(?:3[27]|66)|2(?:6[69]|9[56])|466))[gqswx])\w*(\)| bui)/i],[c,[h,"TCL"],[u,v]],[/(itel) ((\w+))/i],[[h,V],c,[u,K,{tablet:["p10001l","w7001"],"*":"mobile"}]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[c,[h,"Acer"],[u,v]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[c,[h,"Meizu"],[u,g]],[/; ((?:power )?armor(?:[\w ]{0,8}))(?: bui|\))/i],[c,[h,"Ulefone"],[u,g]],[/; (energy ?\w+)(?: bui|\))/i,/; energizer ([\w ]+)(?: bui|\))/i],[c,[h,"Energizer"],[u,g]],[/; cat (b35);/i,/; (b15q?|s22 flip|s48c|s62 pro)(?: bui|\))/i],[c,[h,"Cat"],[u,g]],[/((?:new )?andromax[\w- ]+)(?: bui|\))/i],[c,[h,"Smartfren"],[u,g]],[/droid.+; (a(?:015|06[35]|142p?))/i],[c,[h,"Nothing"],[u,g]],[/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron|infinix|tecno|micromax|advan)[-_ ]?([-\w]*)/i,/; (imo) ((?!tab)[\w ]+?)(?: bui|\))/i,/(hp) ([\w ]+\w)/i,/(asus)-?(\w+)/i,/(microsoft); (lumia[\w ]+)/i,/(lenovo)[-_ ]?([-\w]+)/i,/(jolla)/i,/(oppo) ?([\w ]+) bui/i],[h,c,[u,g]],[/(imo) (tab \w+)/i,/(kobo)\s(ereader|touch)/i,/(archos) (gamepad2?)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i,/(nook)[\w ]+build\/(\w+)/i,/(dell) (strea[kpr\d ]*[\dko])/i,/(le[- ]+pan)[- ]+(\w{1,9}) bui/i,/(trinity)[- ]*(t\d{3}) bui/i,/(gigaset)[- ]+(q\w{1,9}) bui/i,/(vodafone) ([\w ]+)(?:\)| bui)/i],[h,c,[u,v]],[/(surface duo)/i],[c,[h,C],[u,v]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[c,[h,"Fairphone"],[u,g]],[/(u304aa)/i],[c,[h,"AT&T"],[u,g]],[/\bsie-(\w*)/i],[c,[h,"Siemens"],[u,g]],[/\b(rct\w+) b/i],[c,[h,"RCA"],[u,v]],[/\b(venue[\d ]{2,7}) b/i],[c,[h,"Dell"],[u,v]],[/\b(q(?:mv|ta)\w+) b/i],[c,[h,"Verizon"],[u,v]],[/\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i],[c,[h,"Barnes & Noble"],[u,v]],[/\b(tm\d{3}\w+) b/i],[c,[h,"NuVision"],[u,v]],[/\b(k88) b/i],[c,[h,"ZTE"],[u,v]],[/\b(nx\d{3}j) b/i],[c,[h,"ZTE"],[u,g]],[/\b(gen\d{3}) b.+49h/i],[c,[h,"Swiss"],[u,g]],[/\b(zur\d{3}) b/i],[c,[h,"Swiss"],[u,v]],[/\b((zeki)?tb.*\b) b/i],[c,[h,"Zeki"],[u,v]],[/\b([yr]\d{2}) b/i,/\b(dragon[- ]+touch |dt)(\w{5}) b/i],[[h,"Dragon Touch"],c,[u,v]],[/\b(ns-?\w{0,9}) b/i],[c,[h,"Insignia"],[u,v]],[/\b((nxa|next)-?\w{0,9}) b/i],[c,[h,"NextBook"],[u,v]],[/\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i],[[h,"Voice"],c,[u,g]],[/\b(lvtel\-)?(v1[12]) b/i],[[h,"LvTel"],c,[u,g]],[/\b(ph-1) /i],[c,[h,"Essential"],[u,g]],[/\b(v(100md|700na|7011|917g).*\b) b/i],[c,[h,"Envizen"],[u,v]],[/\b(trio[-\w\. ]+) b/i],[c,[h,"MachSpeed"],[u,v]],[/\btu_(1491) b/i],[c,[h,"Rotor"],[u,v]],[/(shield[\w ]+) b/i],[c,[h,"Nvidia"],[u,v]],[/(sprint) (\w+)/i],[h,c,[u,g]],[/(kin\.[onetw]{3})/i],[[c,/\./g," "],[h,C],[u,g]],[/droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[c,[h,$],[u,v]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[c,[h,$],[u,g]],[/smart-tv.+(samsung)/i],[h,[u,y]],[/hbbtv.+maple;(\d+)/i],[[c,/^/,"SmartTV"],[h,O],[u,y]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[h,P],[u,y]],[/(apple) ?tv/i],[h,[c,S+" TV"],[u,y]],[/crkey/i],[[c,k+"cast"],[h,L],[u,y]],[/droid.+aft(\w+)( bui|\))/i],[c,[h,w],[u,y]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[c,[h,M],[u,y]],[/(bravia[\w ]+)( bui|\))/i],[c,[h,N],[u,y]],[/(mitv-\w{5}) bui/i],[c,[h,F],[u,y]],[/Hbbtv.*(technisat) (.*);/i],[h,c,[u,y]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[h,W],[c,W],[u,y]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[u,y]],[/(ouya)/i,/(nintendo) ([wids3utch]+)/i],[h,c,[u,m]],[/droid.+; (shield) bui/i],[c,[h,"Nvidia"],[u,m]],[/(playstation [345portablevi]+)/i],[c,[h,N],[u,m]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[c,[h,C],[u,m]],[/\b(sm-[lr]\d\d[05][fnuw]?s?)\b/i],[c,[h,O],[u,b]],[/((pebble))app/i],[h,c,[u,b]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[c,[h,S],[u,b]],[/droid.+; (glass) \d/i],[c,[h,L],[u,b]],[/droid.+; (wt63?0{2,3})\)/i],[c,[h,$],[u,b]],[/droid.+; (glass) \d/i],[c,[h,L],[u,b]],[/(pico) (4|neo3(?: link|pro)?)/i],[h,c,[u,b]],[/; (quest( \d| pro)?)/i],[c,[h,B],[u,b]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[h,[u,E]],[/(aeobc)\b/i],[c,[h,w],[u,E]],[/droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew).+? mobile safari/i],[c,[u,g]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i],[c,[u,v]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[u,v]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[u,g]],[/(android[-\w\. ]{0,9});.+buil/i],[c,[h,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[f,[d,"EdgeHTML"]],[/(arkweb)\/([\w\.]+)/i],[d,f],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[f,[d,"Blink"]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna|servo)\/([\w\.]+)/i,/ekioh(flow)\/([\w\.]+)/i,/(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i,/(icab)[\/ ]([23]\.[\d\.]+)/i,/\b(libweb)/i],[d,f],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[f,d]],os:[[/microsoft (windows) (vista|xp)/i],[d,f],[/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i],[d,[f,K,q]],[/windows nt 6\.2; (arm)/i,/windows[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i,/(?:win(?=3|9|n)|win 9x )([nt\d\.]+)/i],[[f,K,q],[d,"Windows"]],[/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i,/(?:ios;fbsv\/|iphone.+ios[\/ ])([\d\.]+)/i,/cfnetwork\/.+darwin/i],[[f,/_/g,"."],[d,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[d,z],[f,/_/g,"."]],[/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i],[f,d],[/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish|openharmony)[-\/ ]?([\w\.]*)/i,/(blackberry)\w*\/([\w\.]*)/i,/(tizen|kaios)[\/ ]([\w\.]+)/i,/\((series40);/i],[d,f],[/\(bb(10);/i],[f,[d,x]],[/(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i],[f,[d,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[f,[d,I+" OS"]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[f,[d,"webOS"]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[f,[d,"watchOS"]],[/crkey\/([\d\.]+)/i],[f,[d,k+"cast"]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[d,U],f],[/panasonic;(viera)/i,/(netrange)mmh/i,/(nettv)\/(\d+\.[\w\.]+)/i,/(nintendo|playstation) ([wids345portablevuch]+)/i,/(xbox); +xbox ([^\);]+)/i,/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i,/(mint)[\/\(\) ]?(\w*)/i,/(mageia|vectorlinux)[; ]/i,/([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,/(hurd|linux) ?([\w\.]*)/i,/(gnu) ?([\w\.]*)/i,/\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i,/(haiku) (\w+)/i],[d,f],[/(sunos) ?([\w\.\d]*)/i],[[d,"Solaris"],f],[/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,/(aix) ((\d)(?=\.|\)| )[\w\.])*/i,/\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux|serenityos)/i,/(unix) ?([\w\.]*)/i],[d,f]]},Q=function(e,t){if(typeof e===a&&(t=e,e=i),!(this instanceof Q))return new Q(e,t).getResult();var m=typeof r!==s&&r.navigator?r.navigator:i,y=e||(m&&m.userAgent?m.userAgent:""),b=m&&m.userAgentData?m.userAgentData:i,E=t?function(e,t){var r={};for(var i in e)t[i]&&t[i].length%2==0?r[i]=t[i].concat(e[i]):r[i]=e[i];return r}(X,t):X,w=m&&m.userAgent==y;return this.getBrowser=function(){var e={};return e[d]=i,e[f]=i,Y.call(e,y,E.browser),e[l]=function(e){return typeof e===o?e.replace(/[^\d\.]/g,"").split(".")[0]:i}(e[f]),w&&m&&m.brave&&typeof m.brave.isBrave==n&&(e[d]="Brave"),e},this.getCPU=function(){var e={};return e[p]=i,Y.call(e,y,E.cpu),e},this.getDevice=function(){var e={};return e[h]=i,e[c]=i,e[u]=i,Y.call(e,y,E.device),w&&!e[u]&&b&&b.mobile&&(e[u]=g),w&&"Macintosh"==e[c]&&m&&typeof m.standalone!==s&&m.maxTouchPoints&&m.maxTouchPoints>2&&(e[c]="iPad",e[u]=v),e},this.getEngine=function(){var e={};return e[d]=i,e[f]=i,Y.call(e,y,E.engine),e},this.getOS=function(){var e={};return e[d]=i,e[f]=i,Y.call(e,y,E.os),w&&!e[d]&&b&&b.platform&&"Unknown"!=b.platform&&(e[d]=b.platform.replace(/chrome os/i,U).replace(/macos/i,z)),e},this.getResult=function(){return{ua:this.getUA(),browser:this.getBrowser(),engine:this.getEngine(),os:this.getOS(),device:this.getDevice(),cpu:this.getCPU()}},this.getUA=function(){return y},this.setUA=function(e){return y=typeof e===o&&e.length>500?W(e,500):e,this},this.setUA(y),this};Q.VERSION="1.0.40",Q.BROWSER=j([d,f,l]),Q.CPU=j([p]),Q.DEVICE=j([c,h,u,m,g,y,v,b,E]),Q.ENGINE=Q.OS=j([d,f]),e.exports&&(t=e.exports=Q),t.UAParser=Q;var Z=typeof r!==s&&(r.jQuery||r.Zepto);if(Z&&!Z.ua){var J=new Q;Z.ua=J.getResult(),Z.ua.get=function(){return J.getUA()},Z.ua.set=function(e){J.setUA(e);var t=J.getResult();for(var r in t)Z.ua[r]=t[r]}}}("object"==typeof window?window:oo)),ao.exports;var e,t}var co=function(){if(no)return so;no=1,Object.defineProperty(so,"__esModule",{value:!0});var e,r=t,i=(e=r)&&"object"==typeof e&&"default"in e?e.default:e,n=lo(),s=new n,a=s.getBrowser(),o=s.getCPU(),l=s.getDevice(),c=s.getEngine(),d=s.getOS(),u=s.getUA(),h=function(e){return s.setUA(e)},f=function(e){if(e){var t=new n(e);return{UA:t,browser:t.getBrowser(),cpu:t.getCPU(),device:t.getDevice(),engine:t.getEngine(),os:t.getOS(),ua:t.getUA(),setUserAgent:function(e){return t.setUA(e)}}}console.error("No userAgent string was provided")},p=Object.freeze({ClientUAInstance:s,browser:a,cpu:o,device:l,engine:c,os:d,ua:u,setUa:h,parseUserAgent:f});function m(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,i)}return r}function g(e){return g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},g(e)}function v(e,t,r){return t&&function(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}(e.prototype,t),e}function y(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function b(){return b=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},b.apply(this,arguments)}function E(e){return E=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},E(e)}function w(e,t){return w=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},w(e,t)}function S(e,t){if(null==e)return{};var r,i,n=function(e,t){if(null==e)return{};var r,i,n={},s=Object.keys(e);for(i=0;i<s.length;i++)r=s[i],t.indexOf(r)>=0||(n[r]=e[r]);return n}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(i=0;i<s.length;i++)r=s[i],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function T(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function x(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==r)return;var i,n,s=[],a=!0,o=!1;try{for(r=r.call(e);!(a=(i=r.next()).done)&&(s.push(i.value),!t||s.length!==t);a=!0);}catch(e){o=!0,n=e}finally{try{a||null==r.return||r.return()}finally{if(o)throw n}}return s}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return A(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return A(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function A(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}var k="mobile",I="tablet",L="smarttv",R="console",P="wearable",C="embedded",D=void 0,_={Chrome:"Chrome",Firefox:"Firefox",Opera:"Opera",Yandex:"Yandex",Safari:"Safari",InternetExplorer:"Internet Explorer",Edge:"Edge",Chromium:"Chromium",Ie:"IE",MobileSafari:"Mobile Safari",EdgeChromium:"Edge Chromium",MIUI:"MIUI Browser",SamsungBrowser:"Samsung Browser"},O={IOS:"iOS",Android:"Android",WindowsPhone:"Windows Phone",Windows:"Windows",MAC_OS:"Mac OS"},M={isMobile:!1,isTablet:!1,isBrowser:!1,isSmartTV:!1,isConsole:!1,isWearable:!1},N=function(e){return e||(arguments.length>1&&void 0!==arguments[1]?arguments[1]:"none")},F=function(){return!("undefined"==typeof window||!window.navigator&&!navigator)&&(window.navigator||navigator)},$=function(e){var t=F();return t&&t.platform&&(-1!==t.platform.indexOf(e)||"MacIntel"===t.platform&&t.maxTouchPoints>1&&!window.MSStream)},B=function(e,t,r,i){return function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?m(Object(r),!0).forEach(function(t){y(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):m(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}({},e,{vendor:N(t.vendor),model:N(t.model),os:N(r.name),osVersion:N(r.version),ua:N(i)})},U=function(e){return e.type===k},z=function(e){return e.type===I},G=function(e){var t=e.type;return t===k||t===I},j=function(e){return e.type===L},H=function(e){return e.type===D},V=function(e){return e.type===P},W=function(e){return e.type===R},Y=function(e){return e.type===C},K=function(e){var t=e.vendor;return N(t)},q=function(e){var t=e.model;return N(t)},X=function(e){var t=e.type;return N(t,"browser")},Q=function(e){return e.name===O.Android},Z=function(e){return e.name===O.Windows},J=function(e){return e.name===O.MAC_OS},ee=function(e){return e.name===O.WindowsPhone},te=function(e){return e.name===O.IOS},re=function(e){var t=e.version;return N(t)},ie=function(e){var t=e.name;return N(t)},ne=function(e){return e.name===_.Chrome},se=function(e){return e.name===_.Firefox},ae=function(e){return e.name===_.Chromium},oe=function(e){return e.name===_.Edge},le=function(e){return e.name===_.Yandex},ce=function(e){var t=e.name;return t===_.Safari||t===_.MobileSafari},de=function(e){return e.name===_.MobileSafari},ue=function(e){return e.name===_.Opera},he=function(e){var t=e.name;return t===_.InternetExplorer||t===_.Ie},fe=function(e){return e.name===_.MIUI},pe=function(e){return e.name===_.SamsungBrowser},me=function(e){var t=e.version;return N(t)},ge=function(e){var t=e.major;return N(t)},ve=function(e){var t=e.name;return N(t)},ye=function(e){var t=e.name;return N(t)},be=function(e){var t=e.version;return N(t)},Ee=function(){var e=F(),t=e&&e.userAgent&&e.userAgent.toLowerCase();return"string"==typeof t&&/electron/.test(t)},we=function(e){return"string"==typeof e&&-1!==e.indexOf("Edg/")},Se=function(){var e=F();return e&&(/iPad|iPhone|iPod/.test(e.platform)||"MacIntel"===e.platform&&e.maxTouchPoints>1)&&!window.MSStream},Te=function(){return $("iPad")},xe=function(){return $("iPhone")},Ae=function(){return $("iPod")},ke=function(e){return N(e)};function Ie(e){var t=e||p,r=t.device,i=t.browser,n=t.os,s=t.engine,a=t.ua;return{isSmartTV:j(r),isConsole:W(r),isWearable:V(r),isEmbedded:Y(r),isMobileSafari:de(i)||Te(),isChromium:ae(i),isMobile:G(r)||Te(),isMobileOnly:U(r),isTablet:z(r)||Te(),isBrowser:H(r),isDesktop:H(r),isAndroid:Q(n),isWinPhone:ee(n),isIOS:te(n)||Te(),isChrome:ne(i),isFirefox:se(i),isSafari:ce(i),isOpera:ue(i),isIE:he(i),osVersion:re(n),osName:ie(n),fullBrowserVersion:me(i),browserVersion:ge(i),browserName:ve(i),mobileVendor:K(r),mobileModel:q(r),engineName:ye(s),engineVersion:be(s),getUA:ke(a),isEdge:oe(i)||we(a),isYandex:le(i),deviceType:X(r),isIOS13:Se(),isIPad13:Te(),isIPhone13:xe(),isIPod13:Ae(),isElectron:Ee(),isEdgeChromium:we(a),isLegacyEdge:oe(i)&&!we(a),isWindows:Z(n),isMacOs:J(n),isMIUI:fe(i),isSamsungBrowser:pe(i)}}var Le=j(l),Re=W(l),Pe=V(l),Ce=Y(l),De=de(a)||Te(),_e=ae(a),Oe=G(l)||Te(),Me=U(l),Ne=z(l)||Te(),Fe=H(l),$e=H(l),Be=Q(d),Ue=ee(d),ze=te(d)||Te(),Ge=ne(a),je=se(a),He=ce(a),Ve=ue(a),We=he(a),Ye=re(d),Ke=ie(d),qe=me(a),Xe=ge(a),Qe=ve(a),Ze=K(l),Je=q(l),et=ye(c),tt=be(c),rt=ke(u),it=oe(a)||we(u),nt=le(a),st=X(l),at=Se(),ot=Te(),lt=xe(),ct=Ae(),dt=Ee(),ut=we(u),ht=oe(a)&&!we(u),ft=Z(d),pt=J(d),mt=fe(a),gt=pe(a);function vt(e){var t=e||window.navigator.userAgent;return f(t)}return so.AndroidView=function(e){var t=e.renderWithFragment,n=e.children,s=S(e,["renderWithFragment","children"]);return Be?t?i.createElement(r.Fragment,null,n):i.createElement("div",s,n):null},so.BrowserTypes=_,so.BrowserView=function(e){var t=e.renderWithFragment,n=e.children,s=S(e,["renderWithFragment","children"]);return Fe?t?i.createElement(r.Fragment,null,n):i.createElement("div",s,n):null},so.ConsoleView=function(e){var t=e.renderWithFragment,n=e.children,s=S(e,["renderWithFragment","children"]);return Re?t?i.createElement(r.Fragment,null,n):i.createElement("div",s,n):null},so.CustomView=function(e){var t=e.renderWithFragment,n=e.children;e.viewClassName,e.style;var s=e.condition,a=S(e,["renderWithFragment","children","viewClassName","style","condition"]);return s?t?i.createElement(r.Fragment,null,n):i.createElement("div",a,n):null},so.IEView=function(e){var t=e.renderWithFragment,n=e.children,s=S(e,["renderWithFragment","children"]);return We?t?i.createElement(r.Fragment,null,n):i.createElement("div",s,n):null},so.IOSView=function(e){var t=e.renderWithFragment,n=e.children,s=S(e,["renderWithFragment","children"]);return ze?t?i.createElement(r.Fragment,null,n):i.createElement("div",s,n):null},so.MobileOnlyView=function(e){var t=e.renderWithFragment,n=e.children;e.viewClassName,e.style;var s=S(e,["renderWithFragment","children","viewClassName","style"]);return Me?t?i.createElement(r.Fragment,null,n):i.createElement("div",s,n):null},so.MobileView=function(e){var t=e.renderWithFragment,n=e.children,s=S(e,["renderWithFragment","children"]);return Oe?t?i.createElement(r.Fragment,null,n):i.createElement("div",s,n):null},so.OsTypes=O,so.SmartTVView=function(e){var t=e.renderWithFragment,n=e.children,s=S(e,["renderWithFragment","children"]);return Le?t?i.createElement(r.Fragment,null,n):i.createElement("div",s,n):null},so.TabletView=function(e){var t=e.renderWithFragment,n=e.children,s=S(e,["renderWithFragment","children"]);return Ne?t?i.createElement(r.Fragment,null,n):i.createElement("div",s,n):null},so.WearableView=function(e){var t=e.renderWithFragment,n=e.children,s=S(e,["renderWithFragment","children"]);return Pe?t?i.createElement(r.Fragment,null,n):i.createElement("div",s,n):null},so.WinPhoneView=function(e){var t=e.renderWithFragment,n=e.children,s=S(e,["renderWithFragment","children"]);return Ue?t?i.createElement(r.Fragment,null,n):i.createElement("div",s,n):null},so.browserName=Qe,so.browserVersion=Xe,so.deviceDetect=function(e){var t=e?f(e):p,r=t.device,i=t.browser,n=t.engine,s=t.os,a=t.ua,o=function(e){switch(e){case k:return{isMobile:!0};case I:return{isTablet:!0};case L:return{isSmartTV:!0};case R:return{isConsole:!0};case P:return{isWearable:!0};case D:return{isBrowser:!0};case C:return{isEmbedded:!0};default:return M}}(r.type),l=o.isBrowser,c=o.isMobile,d=o.isTablet,u=o.isSmartTV,h=o.isConsole,m=o.isWearable,g=o.isEmbedded;return l?function(e,t,r,i,n){return{isBrowser:e,browserMajorVersion:N(t.major),browserFullVersion:N(t.version),browserName:N(t.name),engineName:N(r.name),engineVersion:N(r.version),osName:N(i.name),osVersion:N(i.version),userAgent:N(n)}}(l,i,n,s,a):u?function(e,t,r,i){return{isSmartTV:e,engineName:N(t.name),engineVersion:N(t.version),osName:N(r.name),osVersion:N(r.version),userAgent:N(i)}}(u,n,s,a):h?function(e,t,r,i){return{isConsole:e,engineName:N(t.name),engineVersion:N(t.version),osName:N(r.name),osVersion:N(r.version),userAgent:N(i)}}(h,n,s,a):c||d?B(o,r,s,a):m?function(e,t,r,i){return{isWearable:e,engineName:N(t.name),engineVersion:N(t.version),osName:N(r.name),osVersion:N(r.version),userAgent:N(i)}}(m,n,s,a):g?function(e,t,r,i,n){return{isEmbedded:e,vendor:N(t.vendor),model:N(t.model),engineName:N(r.name),engineVersion:N(r.version),osName:N(i.name),osVersion:N(i.version),userAgent:N(n)}}(g,r,n,s,a):void 0},so.deviceType=st,so.engineName=et,so.engineVersion=tt,so.fullBrowserVersion=qe,so.getSelectorsByUserAgent=function(e){if(e&&"string"==typeof e){var t=f(e);return Ie({device:t.device,browser:t.browser,os:t.os,engine:t.engine,ua:t.ua})}console.error("No valid user agent string was provided")},so.getUA=rt,so.isAndroid=Be,so.isBrowser=Fe,so.isChrome=Ge,so.isChromium=_e,so.isConsole=Re,so.isDesktop=$e,so.isEdge=it,so.isEdgeChromium=ut,so.isElectron=dt,so.isEmbedded=Ce,so.isFirefox=je,so.isIE=We,so.isIOS=ze,so.isIOS13=at,so.isIPad13=ot,so.isIPhone13=lt,so.isIPod13=ct,so.isLegacyEdge=ht,so.isMIUI=mt,so.isMacOs=pt,so.isMobile=Oe,so.isMobileOnly=Me,so.isMobileSafari=De,so.isOpera=Ve,so.isSafari=He,so.isSamsungBrowser=gt,so.isSmartTV=Le,so.isTablet=Ne,so.isWearable=Pe,so.isWinPhone=Ue,so.isWindows=ft,so.isYandex=nt,so.mobileModel=Je,so.mobileVendor=Ze,so.osName=Ke,so.osVersion=Ye,so.parseUserAgent=f,so.setUserAgent=function(e){return h(e)},so.useDeviceData=vt,so.useDeviceSelectors=function(e){var t=vt(e||window.navigator.userAgent);return[Ie(t),t]},so.useMobileOrientation=function(){var e=x(r.useState(function(){var e=window.innerWidth>window.innerHeight?90:0;return{isPortrait:0===e,isLandscape:90===e,orientation:0===e?"portrait":"landscape"}}),2),t=e[0],i=e[1],n=r.useCallback(function(){var e=window.innerWidth>window.innerHeight?90:0,r={isPortrait:0===e,isLandscape:90===e,orientation:0===e?"portrait":"landscape"};t.orientation!==r.orientation&&i(r)},[t.orientation]);return r.useEffect(function(){return void 0!==("undefined"==typeof window?"undefined":g(window))&&Oe&&(n(),window.addEventListener("load",n,!1),window.addEventListener("resize",n,!1)),function(){window.removeEventListener("resize",n,!1),window.removeEventListener("load",n,!1)}},[n]),t},so.withOrientationChange=function(e){return function(t){function r(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,r),(t=function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return T(e)}(this,E(r).call(this,e))).isEventListenerAdded=!1,t.handleOrientationChange=t.handleOrientationChange.bind(T(t)),t.onOrientationChange=t.onOrientationChange.bind(T(t)),t.onPageLoad=t.onPageLoad.bind(T(t)),t.state={isLandscape:!1,isPortrait:!1},t}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&w(e,t)}(r,t),v(r,[{key:"handleOrientationChange",value:function(){this.isEventListenerAdded||(this.isEventListenerAdded=!0);var e=window.innerWidth>window.innerHeight?90:0;this.setState({isPortrait:0===e,isLandscape:90===e})}},{key:"onOrientationChange",value:function(){this.handleOrientationChange()}},{key:"onPageLoad",value:function(){this.handleOrientationChange()}},{key:"componentDidMount",value:function(){void 0!==("undefined"==typeof window?"undefined":g(window))&&Oe&&(this.isEventListenerAdded?window.removeEventListener("load",this.onPageLoad,!1):(this.handleOrientationChange(),window.addEventListener("load",this.onPageLoad,!1)),window.addEventListener("resize",this.onOrientationChange,!1))}},{key:"componentWillUnmount",value:function(){window.removeEventListener("resize",this.onOrientationChange,!1)}},{key:"render",value:function(){return i.createElement(e,b({},this.props,{isLandscape:this.state.isLandscape,isPortrait:this.state.isPortrait}))}}]),r}(i.Component)},so}();function uo({message:e,duration:r=3e3,visible:n,setVisible:s}){return i(()=>{const e=setTimeout(()=>s(!1),r);return()=>clearTimeout(e)},[n]),n?t.createElement("div",{style:{position:"fixed",top:"1rem",left:"50%",transform:"translateX(-50%)",background:"rgba(0,0,0,0.8)",color:"#fff",padding:"0.75rem 1.25rem",borderRadius:"0.375rem",fontSize:"14px",zIndex:9999,boxShadow:"0 2px 10px rgba(0,0,0,0.2)"}},e):null}const ho=({shortForm:e,shareUrl:r})=>{const i=null!=r?r:window.location.href,[n,a]=s(!1);return t.createElement(t.Fragment,null,t.createElement("button",{onClick:()=>x(void 0,void 0,void 0,function*(){try{a(!0),co.isMobile&&navigator.share&&e?yield navigator.share({title:e.title,url:i}):(e=>{if(void 0!==navigator.clipboard)navigator.clipboard.writeText(e).then(()=>{});else{const t=document.createElement("textarea");t.value=e,document.body.appendChild(t),t.select(),t.setSelectionRange(0,99999);try{document.execCommand("copy")}catch(e){console.error("복사 실패",e)}t.setSelectionRange(0,0),document.body.removeChild(t)}})(i)}catch(e){console.error("Fail to copy on clipboard")}}),className:"cursor-pointer","aria-label":"공유"},t.createElement("div",{className:"glass-panel flex h-10 w-10 items-center justify-center rounded-full"},t.createElement("img",{src:"https://mbus-asset.s3.ap-northeast-2.amazonaws.com/mcom-player/share.png",alt:"share",width:24,height:24,className:"block h-6 w-6 object-contain"})),t.createElement(uo,{message:"공유 링크 복사 완료",setVisible:a,visible:n})))},fo=({product:e,contentId:r,height:i=80,onOpenProductList:n,additionalProductCount:a,isPreview:o,showPrice:l=!0})=>{var c;const{isPreview:d,priceText:u,memberOnly:h,isMemberLoggedIn:f}=ar(),p=null!=o?o:d,m=h&&!f,[g,v]=s(!1),y=t=>{if(t.stopPropagation(),n)return t.preventDefault(),void n();p||Gt({contentProductId:e.eventProductId,contentId:r,productId:e.productId});Mt(t.currentTarget)&&t.preventDefault()},b=t.createElement(t.Fragment,null,t.createElement("div",{className:"w-1/3 h-full shrink-0"},e.thumbPath&&!g?t.createElement(bi,{product:e,onError:()=>v(!0)}):t.createElement(yi,null)),t.createElement("div",{className:"flex flex-col text-left p-2 w-full justify-center"},e.brand&&t.createElement("span",{className:"break-keep line-clamp-1 text-gray-500",style:{fontSize:"10px"}},e.brand.brandName),t.createElement("div",{className:"mobile-product-name text-gray-800 text-ellipsis line-clamp-1 ",style:{fontSize:"12px"}},e.productName),l&&t.createElement("div",{className:"text-red-500 break-keep",style:{fontSize:"12px"}},m?t.createElement("span",{className:"font-semibold break-keep"},"판매가 회원 공개"):t.createElement(t.Fragment,null,u?u+" ":"할인가 ",t.createElement("span",{className:"font-semibold break-keep"},Tt(e.sellingPrice,e.currency)))))),E=Boolean(a)&&t.createElement("span",{className:"absolute -right-[5px] -top-[5px] rounded-full bg-black/65 px-1 py-0.5 text-[9px] font-semibold leading-none text-white","aria-label":`추가 상품 ${a}개`},"+",a);return n?t.createElement("button",{type:"button",style:{height:i},className:"relative flex w-full cursor-pointer items-center gap-2 border-0 bg-transparent p-0",onClickCapture:y,"aria-haspopup":"dialog"},b,E):t.createElement("a",{href:null!==(c=e.linkPath)&&void 0!==c?c:void 0,"data-mgcode":e.mallProductCode,target:"_blank",draggable:!1,rel:"noopener noreferrer",style:{height:i,textDecoration:"none",color:"inherit"},className:"apphref relative flex gap-2 items-center w-full",onClickCapture:y},b,E)},po=({products:e,contentId:n,height:s=80,onOpenSheet:a,isPreview:o,productBannerType:l="list",showPrice:c=!0})=>{const d=r(null),h=r(!1),f=r(null),p=r(null);i(()=>()=>{f.current&&clearTimeout(f.current)},[]);const m=u(()=>(e=>{if(!e.length)return[];if(e.length>=3)return e;const t=[...e];for(;t.length<3;)t.push(...e);return t})(e),[e]),g=1===(null==e?void 0:e.length);return(null==e?void 0:e.length)?"list"===l?t.createElement("div",{className:"mobile-product-carousel mobile-product-list w-full overflow-visible rounded-xl bg-white",style:{borderRadius:"10px",height:s}},t.createElement(fo,{product:e[0],contentId:n,height:s,isPreview:o,showPrice:c,additionalProductCount:e.length>1?e.length-1:void 0,onOpenProductList:a?()=>a(e):void 0})):t.createElement("div",{ref:p,className:"mobile-product-carousel w-full",onPointerDownCapture:e=>{if(!d.current&&(f.current&&(clearTimeout(f.current),f.current=null),h.current=!1,d.current={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,maxDistance:0},"function"==typeof e.currentTarget.setPointerCapture))try{e.currentTarget.setPointerCapture(e.pointerId)}catch(e){}},onPointerMoveCapture:e=>{const t=d.current;t&&t.pointerId===e.pointerId&&(t.maxDistance=Math.max(t.maxDistance,Math.hypot(e.clientX-t.startX,e.clientY-t.startY)))},onPointerUpCapture:e=>{var t,r,i;const n=d.current;if(!n||n.pointerId!==e.pointerId)return;const s=Math.max(n.maxDistance,Math.hypot(e.clientX-n.startX,e.clientY-n.startY));if(d.current=null,"function"==typeof e.currentTarget.hasPointerCapture&&e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),s>10)return h.current=!0,void(f.current=setTimeout(()=>{h.current=!1,f.current=null},0));if(e.target.closest("a[href]"))return;const a=null!==(r=null===(t=p.current)||void 0===t?void 0:t.querySelector(".swiper-slide-active a[href]"))&&void 0!==r?r:null===(i=p.current)||void 0===i?void 0:i.querySelector("a[href]");null==a||a.click()},onPointerCancelCapture:e=>{const t=d.current;t&&t.pointerId===e.pointerId&&(d.current=null,"function"==typeof e.currentTarget.hasPointerCapture&&e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),h.current=!1,f.current&&(clearTimeout(f.current),f.current=null))},onLostPointerCapture:e=>{const t=d.current;(null==t?void 0:t.pointerId)===e.pointerId&&(d.current=null)},onClickCapture:e=>{h.current&&(e.preventDefault(),e.stopPropagation(),h.current=!1,f.current&&(clearTimeout(f.current),f.current=null))},style:{height:s}},g?t.createElement("div",{className:"mobile-single-product bg-white overflow-hidden rounded-xl w-full",style:{borderRadius:"10px",height:s}},t.createElement(fo,{product:e[0],contentId:n,height:s,isPreview:o,showPrice:c})):t.createElement(Pa,{nested:!0,modules:[Va,Oa],slidesPerView:1.1,effect:"cards",autoplay:!0,loop:!0,grabCursor:!0,preventClicks:!1,preventClicksPropagation:!1,threshold:10,cardsEffect:{rotate:!1},className:"w-full",style:{height:s}},m.map((e,r)=>t.createElement(Ca,{key:r+e.productId,className:"bg-white overflow-hidden rounded-xl",style:{borderRadius:"10px",height:s}},t.createElement(fo,{product:e,contentId:n,height:s,isPreview:o,showPrice:c}))))):null},mo=({product:e,productLength:r,hideMoreBadge:i=!1,contentId:n,lineClamp:s,showMoreBtn:a=!1,showPrice:o=!1,sheet:l=!1,imageSize:c,openProductPopup:d,isPreview:u})=>{var h;const f=ar(e=>e.isPreview),p=null!=u?u:f,m=t.createElement(t.Fragment,null,t.createElement("span",{className:"product-banner__clip","aria-hidden":!0},t.createElement("span",{className:"product-banner__sheen"})),t.createElement("div",{className:"relative",style:{width:l?60:null!=c?c:o?64:"40%",minWidth:l?60:null!=c?c:o?64:"40%",height:l?60:null!=c?c:o?64:void 0}},t.createElement("img",{style:{borderRadius:o||c?"7px":"8px"},className:"aspect-square object-cover w-full",src:Dt(e.thumbPath),alt:e.productName})),t.createElement("div",{style:{position:"relative",zIndex:2,minWidth:0,flex:1,paddingRight:24,display:l?"flex":void 0,flexDirection:l?"column":void 0,justifyContent:l?"center":void 0,alignSelf:l?"stretch":void 0}},t.createElement("p",{className:"product-banner__name",style:{display:"-webkit-box",WebkitLineClamp:s||2,WebkitBoxOrient:"vertical",overflow:"hidden",wordBreak:"break-word",fontWeight:400,color:"#494949"}},e.productName),o&&(l?t.createElement("p",{className:"product-banner__price"},e.discount>0&&t.createElement("span",{className:"product-banner__pct"},e.discount,"%"),t.createElement("span",{className:"product-banner__amt"},Tt(e.sellingPrice,e.currency)),e.discount>0&&e.price>e.sellingPrice&&t.createElement("span",{className:"product-banner__was"},Tt(e.price,e.currency))):t.createElement("p",{className:"product-banner__price",style:{marginTop:4,fontSize:"12px",lineHeight:1.2}},e.discount>0&&t.createElement("span",{style:{marginRight:4,color:"#ef4444",fontWeight:700}},e.discount,"%"),t.createElement("span",{style:{color:"#494949",fontWeight:700}},Tt(e.sellingPrice,e.currency))))),t.createElement("span",{className:"product-banner__arrow","aria-hidden":!0},"›"),!i&&t.createElement("span",{className:"absolute text-white",style:{top:-8,right:-8,zIndex:3,backgroundColor:"#797979",padding:"2px 6px",fontSize:"10px",lineHeight:1.3,borderRadius:"0.625rem"}},"+",r-1));return t.createElement(t.Fragment,null,i?t.createElement("a",{href:null!==(h=e.linkPath)&&void 0!==h?h:void 0,"data-mgcode":e.mallProductCode,target:"_blank",rel:"noopener noreferrer",className:`apphref product-banner ${o?"product-banner--priced ":""}${l?"product-banner--sheet":"border mbus-border"}`,style:{textDecoration:"none",color:"inherit"},onClickCapture:t=>{t.stopPropagation(),p||Gt({contentProductId:e.eventProductId,contentId:n,productId:e.productId});Mt(t.currentTarget)&&t.preventDefault()}},m):t.createElement("div",{className:`product-banner ${o?"product-banner--priced ":""}${l?"product-banner--sheet":"border mbus-border"}`},m),a&&r>1&&t.createElement("div",{onClick:d,className:" flex items-center justify-center border mbus-border cursor-pointer",style:{borderRadius:"0.625rem",padding:"10px",backgroundColor:"#f5f5f5",fontWeight:600}},"+ 더보기 (",r,")"))};function go(){const[e,t]=s({width:window.innerWidth,height:window.innerHeight});return i(()=>{const e=()=>t({width:window.innerWidth,height:window.innerHeight});return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e}const vo=({products:e,contentId:r,singleColumn:i=!1,showPrice:n=!1,sheet:s=!1,isPreview:a})=>{const o=go().width<430||co.isMobile;return t.createElement("div",{onWheel:e=>e.stopPropagation(),className:`grid ${s?"gap-0":"gap-2"} ${i||o?"grid-cols-1":"grid-cols-2"}`,style:{fontSize:13}},e.map(i=>t.createElement(mo,{key:i.productId,product:i,hideMoreBadge:!0,productLength:e.length,contentId:r,showPrice:n,sheet:s,isPreview:a})))},yo=({products:e,contentId:n,showPrice:s,isPreview:a,onClose:o})=>{const l=r(null);return i(()=>{const e=l.current;if(!e)return;const t=e=>e.stopPropagation();return e.addEventListener("wheel",t,{passive:!0}),()=>e.removeEventListener("wheel",t)},[]),t.createElement(t.Fragment,null,t.createElement("div",{className:"product-sheet-backdrop","aria-hidden":!0,onClick:e=>{e.stopPropagation(),o()}}),t.createElement("section",{className:"product-sheet swiper-no-swiping","data-swiper-no-swiping":!0,onClick:e=>e.stopPropagation(),"aria-label":"상품목록"},t.createElement("div",{className:"product-sheet__handle","aria-hidden":!0}),t.createElement("header",{className:"product-sheet__header"},t.createElement("h2",null,"상품목록"),t.createElement("button",{type:"button",className:"cursor-pointer",onClick:e=>{e.stopPropagation(),o()},"aria-label":"상품목록 닫기"},t.createElement(gi,{size:20,color:"#374151"}))),t.createElement("div",{className:"product-sheet__list",ref:l},t.createElement(vo,{products:e,contentId:n,singleColumn:!0,showPrice:s,sheet:!0,isPreview:a}))))},bo="https://mbus-asset.s3.ap-northeast-2.amazonaws.com/mcom-player",Eo=({shortForm:e,isPopup:n,hideProductCarousel:a,hideOverlay:o,shareUrl:l,handleClose:c,productBannerHeight:d,productBannerType:u="list",like:h=!0,share:f=!0,onProductSheetOpenChange:p,trackStatistics:m=!0,isPreview:g})=>{var v,y;const[b,E]=s(!Boolean(n)),[w,S]=s(!0),[T,x]=s(null),A=r(!1),k=r(p);A.current=Boolean(T),k.current=p;const L=ar(e=>e.isPreview),R=null!=g?g:L,P=r();(null===(v=P.current)||void 0===v?void 0:v.shortsId)!==e.shortsId&&(P.current={shortsId:e.shortsId,uuid:null!==(y=e.uuid)&&void 0!==y?y:Lt()});const C=Object.assign(Object.assign({},e),{uuid:P.current.uuid}),{playtime:D}=Ft(m&&!R&&w);Jt({shortform:C,playtime:D,enabled:m&&!R}),i(()=>{(R||"slide"===u)&&x(null)},[u,R]),i(()=>{x(null)},[e.shortsId]),i(()=>{null==p||p(!!T)},[T,p]),i(()=>()=>{var e;A.current&&(null===(e=k.current)||void 0===e||e.call(k,!1))},[]);const _=()=>{E(e=>!e)},O=()=>{S(e=>!e)},{logo:M,productsInfo:N,thumbPath:F,title:$,media:B,brand:U,shortsId:z}=e,G=n?"mb-1 max-h-10 max-w-20 object-contain object-left":"mb-1 max-h-10 max-w-28 object-contain object-left",j=e=>{e.stopPropagation()},H=n?t.createElement("div",{className:"justify-self-end flex gap-2"},t.createElement("button",{className:"cursor-pointer text-white",onClick:O},t.createElement("div",{className:"glass-panel flex h-10 w-10 items-center justify-center rounded-full"},w?t.createElement(ui,{size:24}):t.createElement(hi,{size:24}))),t.createElement("button",{className:"cursor-pointer text-white",onClick:_},t.createElement("div",{className:"glass-panel flex h-10 w-10 items-center justify-center rounded-full"},t.createElement("img",{src:`${bo}/${b?"sound_off":"sound"}.png`,alt:b?"muted":"volume",width:24,height:24,className:"block h-6 w-6 object-contain"}))),c?t.createElement("button",{className:"cursor-pointer text-white",onClick:c},t.createElement("div",{className:"glass-panel flex h-10 w-10 items-center justify-center rounded-full"},t.createElement(gi,{size:24}))):null):t.createElement("div",{className:"mobile-top-controls flex flex-col gap-3 items-end"},t.createElement("button",{type:"button",className:"cursor-pointer text-white",onClick:e=>{j(e),_()},"aria-label":b?"음소거 해제":"음소거"},t.createElement("div",{className:"glass-panel flex h-10 w-10 items-center justify-center rounded-full"},t.createElement("img",{src:`${bo}/${b?"sound_off":"sound"}.png`,alt:b?"muted":"volume",width:24,height:24,className:"block h-6 w-6 object-contain"}))),c?t.createElement("button",{type:"button",className:"cursor-pointer text-white",onClick:e=>{j(e),c()},"aria-label":"닫기"},t.createElement("div",{className:"glass-panel flex h-10 w-10 items-center justify-center rounded-full"},t.createElement(gi,{size:24}))):null);return t.createElement("div",{className:"h-full w-full text-sm overflow-hidden text-white relative",onClick:n?void 0:O},t.createElement("div",{className:"mobile-player-overlay pointer-events-none absolute inset-0 z-[1] flex h-full w-full flex-col justify-between p-4 "+(o?"":"bg-gradient-to-b from-black/40 via-transparent to-black/40")},t.createElement("div",{className:"flex gap-2 justify-between pointer-events-auto",onClick:j},t.createElement("div",{className:"mobile-top-logo"},!o&&(null==M?void 0:M.thumbPath)?t.createElement("img",{className:G,src:M.thumbPath,alt:M.logoName,width:100,height:100}):null),!o&&H),t.createElement("div",{className:"h-full w-full"}),t.createElement("div",{className:"mobile-bottom-content mb-6 pointer-events-auto",onClick:j},!o&&t.createElement("div",{className:"mobile-content-summary flex justify-between items-end mb-3 gap-3"},t.createElement("div",{className:"w-full"},U&&t.createElement("div",{className:"items-center flex gap-3 mb-2"},t.createElement("div",{className:"mobile-brand-logo w-14 h-14 bg-white rounded-full border overflow-hidden shrink-0"},t.createElement("img",{src:U.thumbPath,alt:U.brandName,width:100,height:100,className:"object-contain w-full h-full"})),t.createElement("p",{className:"mb-2 text-start text-sm line-clamp-1"},null==U?void 0:U.brandName)),t.createElement("p",{className:"mobile-shortform-title text-start text-base line-clamp-2"},$)),t.createElement("div",{className:"flex flex-col gap-4 items-center"},h&&t.createElement(ro,{shortsId:z,isPreview:R}),f&&t.createElement("div",{className:"flex items-center justify-center"},t.createElement(ho,{shortForm:e,shareUrl:l})))),!a&&(null==N?void 0:N.length)>0&&t.createElement(po,{products:N,contentId:e.shortsId,height:d,productBannerType:u,isPreview:R,onOpenSheet:x}))),t.createElement(I,{file:xt(null==B?void 0:B.objectId),thumbnail:`${Dt(F)}`,mute:b,isVertical:(null==B?void 0:B.height)>(null==B?void 0:B.width),play:w}),T&&t.createElement(yo,{products:T,contentId:z,showPrice:!0,isPreview:R,onClose:()=>x(null)}))},wo="cursor-pointer text-zinc-500",So=e=>{const{collection:i,shortform:n,setShortform:s,isPreview:a}=e,o=r(null);return t.createElement("div",{className:"flex h-full gap-2 items-center justify-center mx-auto"},t.createElement("div",{className:"flex flex-col gap-4"},t.createElement(si,{size:44,strokeWidth:1,className:wo,onClick:()=>{var e;null===(e=o.current)||void 0===e||e.swiper.slidePrev()}}),t.createElement(ri,{size:44,strokeWidth:1,className:wo,onClick:()=>{var e;null===(e=o.current)||void 0===e||e.swiper.slideNext()}})),t.createElement("div",{className:"h-full aspect-[9/16] max-w-fit relative"},t.createElement(Pa,{modules:[Da,za],mousewheel:!0,direction:"vertical",slidesPerView:1,ref:o,onSlideChangeTransitionEnd:e=>{(e=>{const t=i.contents[e];t&&s(Object.assign({},t))})(e.realIndex)},className:"h-full",preventClicksPropagation:!1,preventClicks:!1,noSwiping:!0,allowTouchMove:!1,loop:!0},i.contents.map(e=>t.createElement(Ca,{key:e.shortsId},t.createElement("div",{className:"flex justify-center gap-3 h-full"},n.shortsId===e.shortsId&&t.createElement("div",{className:"h-full absolute z-[999] w-full bg-white"},t.createElement(Eo,{shortForm:n,hideProductCarousel:!0,trackStatistics:!1,isPreview:a})),t.createElement("img",{src:Dt(e.thumbPath),alt:e.title,className:"w-full h-full bg-black "+(e.media.width>e.media.height?"object-contain":"object-cover")})))))))},To=()=>t.createElement("div",{className:"w-full h-full bg-black/50 absolute top-0 left-0 z-[999] flex items-center justify-center pointer-events-none"},t.createElement("div",{className:"flex flex-col gap-5 items-center justify-center"},t.createElement(ai,{size:80,strokeWidth:1.2,className:"text-white"}),t.createElement("p",{className:"text-white"},"위아래로 스와이프 해보세요"))),xo=e=>Math.max(0,Math.floor((Date.now()-e)/1e3)),Ao=({collection:e,shortform:t,isPreview:n})=>{const s=r(null),a=r(null),o=r(0),l=e=>{e&&zt({contentId:e.contentId,uuid:e.uuid,type:wt.COLLECTION,userId:e.userId,playtime:xo(e.startedAt)})},c=e=>{if(!e)return;const t=xo(e.startedAt);zt({contentId:e.contentId,uuid:e.uuid,type:wt.SHORTS,userId:e.userId,playtime:t,isFinished:Boolean(e.duration&&t>=e.duration)})};i(()=>{const t=n||null==e?void 0:e.colId,r=s.current;if((null==r?void 0:r.contentId)===t)return;if(l(r),s.current=null,!e||!t)return;const i={contentId:t,uuid:Lt(),userId:e.userId,startedAt:Date.now()};s.current=i,Ut({contentId:i.contentId,uuid:i.uuid,type:wt.COLLECTION,userId:i.userId,isFirstPlay:!Pt(i.contentId)})},[null==e?void 0:e.colId,null==e?void 0:e.userId,n]),i(()=>{const e=n||null==t?void 0:t.shortsId,r=a.current;if((null==r?void 0:r.contentId)===e)return;if(c(r),a.current=null,!t||!e)return;const i={contentId:e,uuid:Lt(),userId:t.userId,startedAt:Date.now(),duration:At(t.media.duration)};a.current=i,Ut({contentId:i.contentId,uuid:i.uuid,type:wt.SHORTS,userId:i.userId,isFirstPlay:!Pt(i.contentId)})},[n,null==t?void 0:t.media.duration,null==t?void 0:t.shortsId,null==t?void 0:t.userId]),i(()=>{o.current+=1;const e=o.current;return()=>{Promise.resolve().then(()=>{o.current===e&&(l(s.current),c(a.current),s.current=null,a.current=null)})}},[])},ko=({collection:e,playerSettings:r,isPreview:i=!1})=>{const[a,o]=s(e.contents[0]),[l,c]=s(!0);Ao({collection:e,shortform:a,isPreview:i});const d=n(()=>{l&&c(!1)},[l]);return t.createElement("div",{className:"flex-1 md:flex md:justify-center w-full h-full bg-black relative",onClick:d},l&&t.createElement(To,null),t.createElement("div",{className:"h-full w-full"},t.createElement(Pa,{modules:[Da,za],loop:!0,mousewheel:!0,direction:"vertical",touchEventsTarget:"container",slidesPerView:1,onSlideChangeTransitionEnd:t=>{const r=e.contents[t.realIndex];o(Object.assign({},r))},className:"h-full md:aspect-[9/16] md:mx-auto"},e.contents.map(e=>t.createElement(Ca,{key:e.shortsId,className:"rounded-xl overflow-hidden"},a.shortsId===e.shortsId&&t.createElement("div",{className:"w-full h-full md:flex md:justify-center absolute z-[999]"},t.createElement(Eo,{shortForm:a,trackStatistics:!1,isPreview:i})),t.createElement("img",{src:Dt(e.thumbPath),alt:e.title,className:"rounded-xl w-full h-full bg-black "+(e.media.width>e.media.height?"object-contain":"object-cover")}))))))};const Io='/*! tailwindcss v4.0.12 | MIT License | https://tailwindcss.com */@layer theme, base, components, utilities;@layer theme{:host,:root{--font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--color-red-500:oklch(0.637 0.237 25.331);--color-blue-200:oklch(0.882 0.059 254.128);--color-blue-300:oklch(0.809 0.105 251.813);--color-gray-200:oklch(0.928 0.006 264.531);--color-gray-400:oklch(0.707 0.022 261.325);--color-gray-500:oklch(0.551 0.027 264.364);--color-gray-700:oklch(0.373 0.034 259.733);--color-gray-800:oklch(0.278 0.033 256.848);--color-gray-900:oklch(0.21 0.034 264.665);--color-zinc-500:oklch(0.552 0.016 285.938);--color-zinc-700:oklch(0.37 0.013 285.805);--color-black:#000;--color-white:#fff;--spacing:0.25rem;--container-lg:32rem;--text-xs:0.75rem;--text-xs--line-height:1.33333;--text-sm:0.875rem;--text-sm--line-height:1.42857;--text-base:1rem;--text-base--line-height:1.5;--text-lg:1.125rem;--text-lg--line-height:1.55556;--text-xl:1.25rem;--text-xl--line-height:1.4;--font-weight-medium:500;--font-weight-semibold:600;--leading-tight:1.25;--ease-in:cubic-bezier(0.4,0,1,1);--ease-in-out:cubic-bezier(0.4,0,0.2,1);--animate-pulse:pulse 2s cubic-bezier(0.4,0,0.6,1) infinite;--aspect-video:16/9;--default-transition-duration:150ms;--default-transition-timing-function:cubic-bezier(0.4,0,0.2,1);--default-font-family:var(--font-sans);--default-font-feature-settings:var(--font-sans--font-feature-settings);--default-font-variation-settings:var(\n --font-sans--font-variation-settings\n );--default-mono-font-family:var(--font-mono);--default-mono-font-feature-settings:var(\n --font-mono--font-feature-settings\n );--default-mono-font-variation-settings:var(\n --font-mono--font-variation-settings\n );--animate-float:float 2s ease}}@layer base{*,::backdrop,::file-selector-button,:after,:before{border:0 solid;box-sizing:border-box;margin:0;padding:0}:host,html{-webkit-text-size-adjust:100%;font-feature-settings:var(--default-font-feature-settings,normal);-webkit-tap-highlight-color:transparent;font-family:var( --default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji" );font-variation-settings:var( --default-font-variation-settings,normal );line-height:1.5;tab-size:4}body{line-height:inherit}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-feature-settings:var( --default-mono-font-feature-settings,normal );font-family:var( --default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace );font-size:1em;font-variation-settings:var( --default-mono-font-variation-settings,normal )}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}menu,ol,ul{list-style:none}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}::file-selector-button,button,input,optgroup,select,textarea{font-feature-settings:inherit;background-color:transparent;border-radius:0;color:inherit;font:inherit;font-variation-settings:inherit;letter-spacing:inherit;opacity:1}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{color:color-mix(in oklab,currentColor 50%,transparent);opacity:1}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit,::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-hour-field,::-webkit-datetime-edit-meridiem-field,::-webkit-datetime-edit-millisecond-field,::-webkit-datetime-edit-minute-field,::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-second-field,::-webkit-datetime-edit-year-field{padding-block:0}:-moz-ui-invalid{box-shadow:none}::file-selector-button,button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer utilities{.pointer-events-auto{pointer-events:auto}.pointer-events-none{pointer-events:none}.visible{visibility:visible}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.inset-0{inset:calc(var(--spacing)*0)}.inset-x-0{inset-inline:calc(var(--spacing)*0)}.-top-\\[5px\\]{top:-5px}.top-0{top:calc(var(--spacing)*0)}.top-1\\/2{top:50%}.top-3{top:calc(var(--spacing)*3)}.top-4{top:calc(var(--spacing)*4)}.-right-\\[5px\\]{right:-5px}.right-0{right:calc(var(--spacing)*0)}.right-4{right:calc(var(--spacing)*4)}.bottom-0{bottom:calc(var(--spacing)*0)}.left-0{left:calc(var(--spacing)*0)}.left-3{left:calc(var(--spacing)*3)}.left-4{left:calc(var(--spacing)*4)}.z-10{z-index:10}.z-20{z-index:20}.z-50{z-index:50}.z-\\[1\\]{z-index:1}.z-\\[5\\]{z-index:5}.z-\\[10\\]{z-index:10}.z-\\[20\\]{z-index:20}.z-\\[999\\]{z-index:999}.container{width:100%;@media (width >= 40rem){max-width:40rem}@media (width >= 48rem){max-width:48rem}@media (width >= 64rem){max-width:64rem}@media (width >= 80rem){max-width:80rem}@media (width >= 96rem){max-width:96rem}}.mx-0{margin-inline:calc(var(--spacing)*0)}.mx-auto{margin-inline:auto}.my-0{margin-block:calc(var(--spacing)*0)}.my-2{margin-block:calc(var(--spacing)*2)}.mt-2{margin-top:calc(var(--spacing)*2)}.mt-3{margin-top:calc(var(--spacing)*3)}.mt-4{margin-top:calc(var(--spacing)*4)}.mb-1{margin-bottom:calc(var(--spacing)*1)}.mb-2{margin-bottom:calc(var(--spacing)*2)}.mb-3{margin-bottom:calc(var(--spacing)*3)}.mb-6{margin-bottom:calc(var(--spacing)*6)}.line-clamp-1{-webkit-line-clamp:1}.line-clamp-1,.line-clamp-2{-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.line-clamp-2{-webkit-line-clamp:2}.block{display:block}.contents{display:contents}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-block{display:inline-block}.table{display:table}.aspect-\\[9\\/16\\]{aspect-ratio:9/16}.aspect-square{aspect-ratio:1/1}.aspect-video{aspect-ratio:var(--aspect-video)}.size-3{height:calc(var(--spacing)*3);width:calc(var(--spacing)*3)}.size-4{height:calc(var(--spacing)*4);width:calc(var(--spacing)*4)}.h-1{height:calc(var(--spacing)*1)}.h-3\\.5{height:calc(var(--spacing)*3.5)}.h-4{height:calc(var(--spacing)*4)}.h-5{height:calc(var(--spacing)*5)}.h-6{height:calc(var(--spacing)*6)}.h-9{height:calc(var(--spacing)*9)}.h-10{height:calc(var(--spacing)*10)}.h-12{height:calc(var(--spacing)*12)}.h-14{height:calc(var(--spacing)*14)}.h-16{height:calc(var(--spacing)*16)}.h-\\[24px\\]{height:24px}.h-\\[60px\\]{height:60px}.h-\\[80\\%\\]{height:80%}.h-\\[95\\%\\]{height:95%}.h-\\[100px\\]{height:100px}.h-\\[125px\\]{height:125px}.h-\\[500px\\]{height:500px}.h-\\[600px\\]{height:600px}.h-full{height:100%}.max-h-10{max-height:calc(var(--spacing)*10)}.max-h-\\[150px\\]{max-height:150px}.max-h-\\[300px\\]{max-height:300px}.max-h-fit{max-height:fit-content}.max-h-full{max-height:100%}.min-h-0{min-height:calc(var(--spacing)*0)}.\\!w-auto{width:auto!important}.w-1\\/3{width:33.33333%}.w-4{width:calc(var(--spacing)*4)}.w-4\\/5{width:80%}.w-6{width:calc(var(--spacing)*6)}.w-9{width:calc(var(--spacing)*9)}.w-10{width:calc(var(--spacing)*10)}.w-12{width:calc(var(--spacing)*12)}.w-14{width:calc(var(--spacing)*14)}.w-16{width:calc(var(--spacing)*16)}.w-36{width:calc(var(--spacing)*36)}.w-\\[24px\\]{width:24px}.w-\\[400px\\]{width:400px}.w-\\[500px\\]{width:500px}.w-\\[1024px\\]{width:1024px}.w-full{width:100%}.max-w-20{max-width:calc(var(--spacing)*20)}.max-w-28{max-width:calc(var(--spacing)*28)}.max-w-52{max-width:calc(var(--spacing)*52)}.max-w-\\[40\\%\\]{max-width:40%}.max-w-\\[160px\\]{max-width:160px}.max-w-\\[800px\\]{max-width:800px}.max-w-\\[830px\\]{max-width:830px}.max-w-fit{max-width:fit-content}.max-w-full{max-width:100%}.max-w-lg{max-width:var(--container-lg)}.max-w-none{max-width:none}.min-w-0{min-width:calc(var(--spacing)*0)}.min-w-44{min-width:calc(var(--spacing)*44)}.min-w-\\[768px\\]{min-width:768px}.flex-1{flex:1}.flex-\\[2\\]{flex:2}.flex-shrink-0,.shrink-0{flex-shrink:0}.grow{flex-grow:1}.border-collapse{border-collapse:collapse}.-translate-y-1\\/2{--tw-translate-y:-50%}.-translate-y-1\\/2,.translate-y-0\\.5{translate:var(--tw-translate-x) var(--tw-translate-y)}.translate-y-0\\.5{--tw-translate-y:calc(var(--spacing)*0.5)}.transform{transform:var(--tw-rotate-x) var(--tw-rotate-y) var(--tw-rotate-z) var(--tw-skew-x) var(--tw-skew-y)}.animate-float{animation:var(--animate-float)}.animate-pulse{animation:var(--animate-pulse)}.cursor-default{cursor:default}.cursor-pointer{cursor:pointer}.touch-none{touch-action:none}.resize{resize:both}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-col-reverse{flex-direction:column-reverse}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-0{gap:calc(var(--spacing)*0)}.gap-1{gap:calc(var(--spacing)*1)}.gap-2{gap:calc(var(--spacing)*2)}.gap-3{gap:calc(var(--spacing)*3)}.gap-4{gap:calc(var(--spacing)*4)}.gap-5{gap:calc(var(--spacing)*5)}.gap-8{gap:calc(var(--spacing)*8)}.gap-10{gap:calc(var(--spacing)*10)}.self-center{align-self:center}.justify-self-end{justify-self:flex-end}.truncate{text-overflow:ellipsis;white-space:nowrap}.overflow-hidden,.truncate{overflow:hidden}.overflow-scroll{overflow:scroll}.overflow-visible{overflow:visible}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-\\[15px\\]{border-radius:15px}.rounded-full{border-radius:calc(infinity * 1px)}.rounded-lg{border-radius:var(--radius)}.rounded-md{border-radius:calc(var(--radius) - 2px)}.rounded-xl{border-radius:calc(var(--radius) + 4px)}.border{border-style:var(--tw-border-style);border-width:1px}.border-0{border-style:var(--tw-border-style);border-width:0}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-none{--tw-border-style:none;border-style:none}.bg-\\[\\#0ab060\\]{background-color:#0ab060}.bg-\\[\\#eeeeee\\]{background-color:#eee}.bg-\\[\\#f4f4f4\\]{background-color:#f4f4f4}.bg-\\[rgba\\(0\\,0\\,0\\,\\.3\\)\\]{background-color:rgba(0,0,0,.3)}.bg-black{background-color:var(--color-black)}.bg-black\\/40{background-color:color-mix(in oklab,var(--color-black) 40%,transparent)}.bg-black\\/50{background-color:color-mix(in oklab,var(--color-black) 50%,transparent)}.bg-black\\/65{background-color:color-mix(in oklab,var(--color-black) 65%,transparent)}.bg-blue-200{background-color:var(--color-blue-200)}.bg-blue-300{background-color:var(--color-blue-300)}.bg-gray-200{background-color:var(--color-gray-200)}.bg-transparent{background-color:transparent}.bg-white{background-color:var(--color-white)}.bg-zinc-700{background-color:var(--color-zinc-700)}.bg-gradient-to-b{--tw-gradient-position:to bottom in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.from-black\\/40{--tw-gradient-from:color-mix(in oklab,var(--color-black) 40%,transparent);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from) var(--tw-gradient-from-position),var(--tw-gradient-to) var(--tw-gradient-to-position))}.via-transparent{--tw-gradient-via:transparent;--tw-gradient-via-stops:var(--tw-gradient-position),var(--tw-gradient-from) var(--tw-gradient-from-position),var(--tw-gradient-via) var(--tw-gradient-via-position),var(--tw-gradient-to) var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-via-stops)}.to-black\\/40{--tw-gradient-to:color-mix(in oklab,var(--color-black) 40%,transparent);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from) var(--tw-gradient-from-position),var(--tw-gradient-to) var(--tw-gradient-to-position))}.fill-black{fill:var(--color-black)}.fill-red-500{fill:var(--color-red-500)}.fill-white{fill:var(--color-white)}.object-contain{object-fit:contain}.object-cover{object-fit:cover}.object-center{object-position:center}.object-left{object-position:left}.p-0{padding:calc(var(--spacing)*0)}.p-1{padding:calc(var(--spacing)*1)}.p-2{padding:calc(var(--spacing)*2)}.p-3{padding:calc(var(--spacing)*3)}.p-4{padding:calc(var(--spacing)*4)}.p-6{padding:calc(var(--spacing)*6)}.p-10{padding:calc(var(--spacing)*10)}.p-\\[3px\\]{padding:3px}.px-1{padding-inline:calc(var(--spacing)*1)}.px-2{padding-inline:calc(var(--spacing)*2)}.px-3{padding-inline:calc(var(--spacing)*3)}.px-4{padding-inline:calc(var(--spacing)*4)}.px-10{padding-inline:calc(var(--spacing)*10)}.px-14{padding-inline:calc(var(--spacing)*14)}.px-\\[24px\\]{padding-inline:24px}.py-0\\.5{padding-block:calc(var(--spacing)*.5)}.py-2{padding-block:calc(var(--spacing)*2)}.py-4{padding-block:calc(var(--spacing)*4)}.pt-0{padding-top:calc(var(--spacing)*0)}.pr-1{padding-right:calc(var(--spacing)*1)}.pb-4{padding-bottom:calc(var(--spacing)*4)}.pb-10{padding-bottom:calc(var(--spacing)*10)}.text-center{text-align:center}.text-left{text-align:left}.text-start{text-align:start}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xl{font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\\[9px\\]{font-size:9px}.text-\\[10px\\]{font-size:10px}.text-\\[12px\\]{font-size:12px}.leading-none{--tw-leading:1;line-height:1}.leading-tight{--tw-leading:var(--leading-tight);line-height:var(--leading-tight)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.break-keep{word-break:keep-all}.text-clip{text-overflow:clip}.text-ellipsis{text-overflow:ellipsis}.whitespace-nowrap{white-space:nowrap}.text-black{color:var(--color-black)}.text-gray-400{color:var(--color-gray-400)}.text-gray-500{color:var(--color-gray-500)}.text-gray-700{color:var(--color-gray-700)}.text-gray-800{color:var(--color-gray-800)}.text-gray-900{color:var(--color-gray-900)}.text-muted-foreground{color:var(--muted-foreground)}.text-red-500{color:var(--color-red-500)}.text-transparent{color:transparent}.text-white{color:var(--color-white)}.text-zinc-500{color:var(--color-zinc-500)}.line-through{text-decoration-line:line-through}.opacity-50{opacity:50%}.opacity-70{opacity:70%}.shadow,.shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,rgba(0,0,0,.1)),0 1px 2px -1px var(--tw-shadow-color,rgba(0,0,0,.1));box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-ring\\/30{--tw-ring-color:color-mix(in oklab,var(--ring) 30%,transparent)}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.filter{filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.transition{transition-duration:var(--tw-duration,var(--default-transition-duration));transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function))}.transition-\\[color\\,box-shadow\\]{transition-duration:var(--tw-duration,var(--default-transition-duration));transition-property:color,box-shadow;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function))}.transition-all{transition-duration:var(--tw-duration,var(--default-transition-duration));transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function))}.transition-opacity{transition-duration:var(--tw-duration,var(--default-transition-duration));transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function))}.transition-transform{transition-duration:var(--tw-duration,var(--default-transition-duration));transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function))}.duration-200{--tw-duration:200ms;transition-duration:.2s}.ease-in{--tw-ease:var(--ease-in);transition-timing-function:var(--ease-in)}.ease-in-out{--tw-ease:var(--ease-in-out);transition-timing-function:var(--ease-in-out)}.outline-none{--tw-outline-style:none;outline-style:none}.select-none{-webkit-user-select:none;user-select:none}.duration-200{animation-duration:.2s}.ease-in{animation-timing-function:cubic-bezier(.4,0,1,1)}.ease-in-out{animation-timing-function:cubic-bezier(.4,0,.2,1)}.fade-in{--tw-enter-opacity:0}.last\\:border-b-0{&:last-child{border-bottom-style:var(--tw-border-style);border-bottom-width:0}}.hover\\:underline{&:hover{@media (hover:hover){text-decoration-line:underline}}}.hover\\:opacity-100{&:hover{@media (hover:hover){opacity:100%}}}.hover\\:ring-4{&:hover{@media (hover:hover){--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(4px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentColor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}}}.focus\\:ring-2{&:focus{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentColor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}}.focus\\:ring-ring{&:focus{--tw-ring-color:var(--ring)}}.focus\\:ring-offset-2{&:focus{--tw-ring-offset-width:2px;--tw-ring-offset-shadow:var(--tw-ring-inset,) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color)}}.focus\\:ring-offset-background{&:focus{--tw-ring-offset-color:var(--background)}}.focus\\:outline-none{&:focus{--tw-outline-style:none;outline-style:none}}.focus-visible\\:border-ring{&:focus-visible{border-color:var(--ring)}}.focus-visible\\:ring-4{&:focus-visible{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(4px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentColor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}}.focus-visible\\:ring-\\[3px\\]{&:focus-visible{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(3px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentColor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}}.focus-visible\\:ring-ring\\/50{&:focus-visible{--tw-ring-color:color-mix(in oklab,var(--ring) 50%,transparent)}}.focus-visible\\:outline-hidden{&:focus-visible{--tw-outline-style:none;outline-style:none;@media (forced-colors:active){outline:2px solid transparent;outline-offset:2px}}}.disabled\\:pointer-events-none{&:disabled{pointer-events:none}}.disabled\\:opacity-50{&:disabled{opacity:50%}}.data-\\[disabled\\]\\:opacity-50{&[data-disabled]{opacity:50%}}.data-\\[orientation\\=horizontal\\]\\:h-1\\.5{&[data-orientation=horizontal]{height:calc(var(--spacing)*1.5)}}.data-\\[orientation\\=horizontal\\]\\:h-full{&[data-orientation=horizontal]{height:100%}}.data-\\[orientation\\=horizontal\\]\\:w-full{&[data-orientation=horizontal]{width:100%}}.data-\\[orientation\\=vertical\\]\\:h-full{&[data-orientation=vertical]{height:100%}}.data-\\[orientation\\=vertical\\]\\:min-h-44{&[data-orientation=vertical]{min-height:calc(var(--spacing)*44)}}.data-\\[orientation\\=vertical\\]\\:w-1\\.5{&[data-orientation=vertical]{width:calc(var(--spacing)*1.5)}}.data-\\[orientation\\=vertical\\]\\:w-auto{&[data-orientation=vertical]{width:auto}}.data-\\[orientation\\=vertical\\]\\:w-full{&[data-orientation=vertical]{width:100%}}.data-\\[orientation\\=vertical\\]\\:flex-col{&[data-orientation=vertical]{flex-direction:column}}.\\[\\&\\[data-state\\=open\\]\\>svg\\]\\:rotate-180,.lg\\:px-5,.md\\:aspect-\\[9\\/16\\],.md\\:flex,.md\\:justify-center,.md\\:mx-auto,.md\\:px-4,.sm\\:flex-row,.sm\\:justify-end,.sm\\:mx-0{&[data-state=open]>svg{rotate:180deg}}}body{--background:oklch(1 0 0);--foreground:oklch(0.145 0 0);--card:oklch(1 0 0);--card-foreground:oklch(0.145 0 0);--popover:oklch(1 0 0);--popover-foreground:oklch(0.145 0 0);--primary:oklch(0.205 0 0);--primary-foreground:oklch(0.985 0 0);--secondary:oklch(0.97 0 0);--secondary-foreground:oklch(0.205 0 0);--muted:oklch(0.97 0 0);--muted-foreground:oklch(0.556 0 0);--accent:oklch(0.97 0 0);--accent-foreground:oklch(0.205 0 0);--destructive:oklch(0.577 0.245 27.325);--destructive-foreground:oklch(0.577 0.245 27.325);--border:oklch(0.922 0 0);--input:oklch(0.922 0 0);--ring:oklch(0.708 0 0);--chart-1:oklch(0.646 0.222 41.116);--chart-2:oklch(0.6 0.118 184.704);--chart-3:oklch(0.398 0.07 227.392);--chart-4:oklch(0.828 0.189 84.429);--chart-5:oklch(0.769 0.188 70.08);--radius:0.625rem;--sidebar:oklch(0.985 0 0);--sidebar-foreground:oklch(0.145 0 0);--sidebar-primary:oklch(0.205 0 0);--sidebar-primary-foreground:oklch(0.985 0 0);--sidebar-accent:oklch(0.97 0 0);--sidebar-accent-foreground:oklch(0.205 0 0);--sidebar-border:oklch(0.922 0 0);--sidebar-ring:oklch(0.708 0 0);--mp-surface:#fff;--mp-surface-2:#f7f8fa;--mp-ink:#16181d;--mp-ink-2:#3d4657;--mp-muted:#8a90a0;--mp-line:#ebedf1;--mp-line-strong:#c4cad4;--mp-price:#d93025;outline:none}.dark{--background:oklch(0.145 0 0);--foreground:oklch(0.985 0 0);--card:oklch(0.145 0 0);--card-foreground:oklch(0.985 0 0);--popover:oklch(0.145 0 0);--popover-foreground:oklch(0.985 0 0);--primary:oklch(0.985 0 0);--primary-foreground:oklch(0.205 0 0);--secondary:oklch(0.269 0 0);--secondary-foreground:oklch(0.985 0 0);--muted:oklch(0.269 0 0);--muted-foreground:oklch(0.708 0 0);--accent:oklch(0.269 0 0);--accent-foreground:oklch(0.985 0 0);--destructive:oklch(0.396 0.141 25.723);--destructive-foreground:oklch(0.637 0.237 25.331);--border:oklch(0.269 0 0);--input:oklch(0.269 0 0);--ring:oklch(0.439 0 0);--chart-1:oklch(0.488 0.243 264.376);--chart-2:oklch(0.696 0.17 162.48);--chart-3:oklch(0.769 0.188 70.08);--chart-4:oklch(0.627 0.265 303.9);--chart-5:oklch(0.645 0.246 16.439);--sidebar:oklch(0.205 0 0);--sidebar-foreground:oklch(0.985 0 0);--sidebar-primary:oklch(0.488 0.243 264.376);--sidebar-primary-foreground:oklch(0.985 0 0);--sidebar-accent:oklch(0.269 0 0);--sidebar-accent-foreground:oklch(0.985 0 0);--sidebar-border:oklch(0.269 0 0);--sidebar-ring:oklch(0.439 0 0)}@layer base{*{border-color:var(--border);outline-color:color-mix(in oklab,var(--ring) 50%,transparent)}body{background-color:var(--background);color:var(--foreground)}}html.overflow-hidden{overflow:hidden}.scrollbar-hide::-webkit-scrollbar{display:none}.scrollbar-hide{-ms-overflow-style:none;scrollbar-width:none}.bg-insta{background-image:linear-gradient(to top right,#facc15,#ec4899,#9333ea)}.glass-panel{backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);background:hsla(0,0%,100%,.1);border:1px solid hsla(0,0%,100%,.1)}.floating-player--expanded-shopping .mobile-player-overlay{padding:12px}.floating-player--expanded-shopping .mobile-top-controls{gap:8px}.floating-collection-player .glass-panel,.floating-player .glass-panel{height:34px;width:34px}.floating-collection-player .glass-panel img,.floating-collection-player .glass-panel svg,.floating-player .glass-panel img,.floating-player .glass-panel svg{height:18px;width:18px}.floating-player--expanded-shopping .mobile-bottom-content{margin-bottom:0}.floating-player--expanded-shopping .mobile-content-summary{gap:8px;margin-bottom:8px}.floating-player--expanded-shopping .mobile-shortform-title{font-size:13px;line-height:1.4}.floating-collection-player .mobile-bottom-content{margin-bottom:8px}.floating-collection-player .mobile-brand-logo{height:40px;width:40px}.floating-collection-player .mobile-top-logo{margin-left:0}.floating-collection-player .mobile-shortform-title{font-size:13px;line-height:1.4}.floating-collection-player .mobile-content-summary{margin-bottom:8px}.floating-collection-player .mobile-product-name,.floating-collection-player .product-banner__name{font-size:11px!important}.product-banner{align-items:center;background:#fff;border-radius:8px;cursor:pointer;display:flex;gap:8px;position:relative}.product-banner__clip{border-radius:inherit;overflow:hidden}.product-banner__clip,.product-banner__sheen{inset:0;pointer-events:none;position:absolute;z-index:1}.product-banner__sheen{background:linear-gradient(270deg,rgba(0,0,0,.1),transparent);transform:translateX(100%);transition:transform .3s ease}.product-banner:hover .product-banner__sheen{transform:translateX(0)}.product-banner__arrow{opacity:0;pointer-events:none;position:absolute;right:8px;top:50%;transform:translate(4px,-50%);transition:transform .3s ease,opacity .3s ease;z-index:2}.product-banner:hover .product-banner__arrow{opacity:1;transform:translateY(-50%)}.product-banner--sheet{align-items:center;background:transparent;border-radius:0;gap:12px;padding:11px 4px}.product-banner--sheet+.product-banner--sheet{border-top:1px solid var(--mp-line)}.product-banner--sheet .product-banner__clip{display:none}.product-banner--sheet .product-banner__arrow{color:var(--mp-line-strong);display:block;font-size:20px;opacity:.55;transform:translateY(-50%)}.product-banner--sheet .product-banner__name{color:var(--mp-ink-2);font-size:13.5px;font-weight:450;line-height:1.42}.product-banner--sheet .product-banner__price{align-items:baseline;display:flex;flex-wrap:wrap;font-variant-numeric:tabular-nums;gap:6px;margin-top:5px}.product-banner--sheet .product-banner__pct{color:var(--mp-price);font-size:13px;font-weight:700}.product-banner--sheet .product-banner__amt{color:var(--mp-ink);font-size:15px;font-weight:700;letter-spacing:-.01em}.product-banner--sheet .product-banner__was{color:var(--mp-muted);font-size:11.5px;text-decoration:line-through}.product-sheet-backdrop{background:transparent;inset:0;position:absolute;z-index:49}.product-sheet{animation:product-sheet-in .25s ease-out;background:#fff;border-radius:18px 18px 0 0;box-shadow:0 -4px 20px rgba(0,0,0,.12);display:flex;flex-direction:column;height:330px;inset:auto 0 0;max-height:82%;overflow:hidden;padding:8px 12px 16px;position:absolute;touch-action:pan-y;z-index:50}.product-sheet__handle{background:#e5e7eb;border-radius:999px;height:5px;margin:0 auto 14px;width:36px}.product-sheet__header{align-items:center;display:flex;justify-content:space-between}.product-sheet__header h2{color:#374151;font-size:14px;font-weight:700}.product-sheet__list{-webkit-overflow-scrolling:touch;flex:1 1 auto;margin-top:10px;min-height:0;overflow-y:auto;overscroll-behavior:contain;scrollbar-width:none;touch-action:pan-y}.product-sheet__list::-webkit-scrollbar{display:none}@keyframes product-sheet-in{0%{transform:translateY(100%)}to{transform:translateY(0)}}.collection-slider--carousel .collection-slider__slide{width:clamp(220px,28vw,320px)}.collection-slider__nav{align-items:center;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);background:rgba(0,0,0,.48);border:1px solid hsla(0,0%,100%,.24);border-radius:999px;color:#fff;cursor:pointer;display:flex;height:36px;justify-content:center;padding:0;position:absolute;top:50%;touch-action:manipulation;transform:translateY(-50%);transition:background-color .16s ease,transform .16s ease;width:36px;z-index:20}.collection-slider__nav--prev{left:8px}.collection-slider__nav--next{right:8px}.collection-slider__nav:hover{background:rgba(0,0,0,.66)}.collection-slider__nav:active{transform:translateY(-50%) scale(.94)}.collection-slider__nav:focus-visible{outline:2px solid #fff;outline-offset:2px}@media (max-width:480px){.collection-slider--carousel .collection-slider__slide{width:min(78vw,280px)}.collection-slider__nav{height:34px;width:34px}}.product-dialog-container{max-height:70vh;max-width:min(82vw,500px);overflow-y:auto;width:100%}.product-dialog--list{background:var(--mp-surface);border-radius:18px;box-shadow:0 18px 48px -14px rgba(22,26,34,.28),0 2px 6px -2px rgba(22,26,34,.1)}.product-dialog--list [data-slot=dialog-title]{font-size:16px;font-weight:640;letter-spacing:-.01em}.product-dialog--list [data-slot=dialog-close]{align-items:center;background:var(--mp-surface-2);border-radius:8px;color:var(--mp-ink-2);display:flex;height:28px;justify-content:center;opacity:1;width:28px}.product-dialog-container.product-dialog--list{display:flex;flex-direction:column;overflow:hidden}.product-dialog--list .product-dialog__scroll{-webkit-overflow-scrolling:touch;-ms-overflow-style:none;flex:1 1 auto;min-height:0;overflow-y:auto;overscroll-behavior:contain;scrollbar-width:none}.product-dialog--list .product-dialog__scroll::-webkit-scrollbar{display:none}.border{border:1px solid oklch(.922 0 0)}.sc-info{align-items:center;color:inherit;cursor:pointer;display:flex;gap:11px;text-decoration:none}.sc-info--clean{margin-top:12px;min-height:56px}.sc-thumb{background:#f0f0ed;border-radius:10px;flex:none;height:54px;object-fit:cover;width:54px}.sc-stack{flex:none;height:54px;position:relative;width:58px}.sc-stack img{background:#f0f0ed;border:2px solid #fff;border-radius:9px;box-shadow:0 2px 7px rgba(0,0,0,.2);height:46px;object-fit:cover;position:absolute;width:46px}.sc-stack img:first-child{left:0;top:6px;transform:rotate(-7deg);transition:transform .3s ease}.sc-stack img:nth-child(2){left:6px;top:3px}.sc-stack img:nth-child(3){left:12px;top:0;transform:rotate(6deg);transition:transform .3s ease}.sc-glass-card:hover .sc-stack img:first-child,.sc-info:hover .sc-stack img:first-child{transform:translate(-3px,-1px) rotate(-11deg)}.sc-glass-card:hover .sc-stack img:nth-child(3),.sc-info:hover .sc-stack img:nth-child(3){transform:translate(3px,-1px) rotate(10deg)}.sc-body{flex:1;min-width:0}.sc-name{-webkit-line-clamp:2;-webkit-box-orient:vertical;color:#3f4046;display:-webkit-box;font-size:13px;font-weight:550;line-height:1.32;overflow:hidden;overflow-wrap:anywhere}.sc-price{align-items:baseline;display:flex;flex-wrap:wrap;font-size:13px;font-variant-numeric:tabular-nums;gap:6px;margin-top:3px}.sc-price .off{color:#f5391f;font-weight:700}.sc-price .amt{color:#222;font-weight:700}.sc-price .was{color:#9a9ca4;font-size:11.5px;font-weight:400;text-decoration:line-through}.sc-count{color:#8a8c92;font-size:11px}.sc-media-title-overlay{background:linear-gradient(0deg,rgba(0,0,0,.58),transparent);inset:auto 0 0;padding:28px 12px 12px;pointer-events:none;position:absolute;z-index:2}.sc-media-title{-webkit-line-clamp:2;-webkit-box-orient:vertical;color:#fff;display:-webkit-box;font-size:13px;font-weight:600;line-height:1.4;margin:0;overflow:hidden;text-shadow:0 1px 3px rgba(0,0,0,.55)}.sc-overlay{background:linear-gradient(0deg,rgba(0,0,0,.6),transparent);inset:auto 0 0 0;padding:12px;position:absolute;z-index:3}.sc-title{-webkit-line-clamp:1;-webkit-box-orient:vertical;color:#fff;display:-webkit-box;font-size:13px;font-weight:600;line-height:1.35;margin:0 0 8px;overflow:hidden;text-shadow:0 1px 3px rgba(0,0,0,.55)}.sc-glass-card{align-items:center;-webkit-backdrop-filter:blur(14px) saturate(1.2);backdrop-filter:blur(14px) saturate(1.2);background:hsla(0,0%,100%,.16);border:1px solid hsla(0,0%,100%,.28);border-radius:12px;box-shadow:0 8px 22px rgba(0,0,0,.26);cursor:pointer;display:flex;gap:10px;padding:9px;text-decoration:none}.sc-glass-card .sc-thumb{border-radius:8px;height:42px;width:42px}.sc-glass-card .sc-stack{height:44px;width:50px}.sc-glass-card .sc-stack img{border-color:hsla(0,0%,100%,.65);height:38px;width:38px}.sc-glass-card .sc-name{-webkit-line-clamp:2;color:#fff;font-size:12px;font-weight:600;text-shadow:0 1px 2px rgba(0,0,0,.4)}.sc-glass-card .sc-count{color:hsla(0,0%,100%,.75);margin-left:2px;white-space:nowrap}.sc-glass-card .sc-name--measure{-webkit-line-clamp:unset;display:block;left:-10000px;overflow:visible;pointer-events:none;position:fixed;top:0;visibility:hidden}.sc-glass-card .sc-price .amt{color:#fff}.sc-glass-card .sc-price .off{color:#ffd7cf}.sc-glass-card .sc-price .was{color:hsla(0,0%,100%,.7)}@media (max-width:480px){.sc-overlay{padding:8px}.sc-glass-card{-webkit-backdrop-filter:blur(10px) saturate(1.2);backdrop-filter:blur(10px) saturate(1.2);border:0;box-shadow:none;gap:8px;padding:7px}.sc-glass-card .sc-thumb{height:36px;width:36px}.sc-glass-card .sc-name{font-size:11px}}@media (prefers-reduced-motion:reduce){.collection-slider__nav,.sc-stack img{transition:none}}@font-face{font-family:swiper-icons;font-style:normal;font-weight:400;src:url("data:application/font-woff;charset=utf-8;base64, d09GRgABAAAAAAZgABAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABGRlRNAAAGRAAAABoAAAAci6qHkUdERUYAAAWgAAAAIwAAACQAYABXR1BPUwAABhQAAAAuAAAANuAY7+xHU1VCAAAFxAAAAFAAAABm2fPczU9TLzIAAAHcAAAASgAAAGBP9V5RY21hcAAAAkQAAACIAAABYt6F0cBjdnQgAAACzAAAAAQAAAAEABEBRGdhc3AAAAWYAAAACAAAAAj//wADZ2x5ZgAAAywAAADMAAAD2MHtryVoZWFkAAABbAAAADAAAAA2E2+eoWhoZWEAAAGcAAAAHwAAACQC9gDzaG10eAAAAigAAAAZAAAArgJkABFsb2NhAAAC0AAAAFoAAABaFQAUGG1heHAAAAG8AAAAHwAAACAAcABAbmFtZQAAA/gAAAE5AAACXvFdBwlwb3N0AAAFNAAAAGIAAACE5s74hXjaY2BkYGAAYpf5Hu/j+W2+MnAzMYDAzaX6QjD6/4//Bxj5GA8AuRwMYGkAPywL13jaY2BkYGA88P8Agx4j+/8fQDYfA1AEBWgDAIB2BOoAeNpjYGRgYNBh4GdgYgABEMnIABJzYNADCQAACWgAsQB42mNgYfzCOIGBlYGB0YcxjYGBwR1Kf2WQZGhhYGBiYGVmgAFGBiQQkOaawtDAoMBQxXjg/wEGPcYDDA4wNUA2CCgwsAAAO4EL6gAAeNpj2M0gyAACqxgGNWBkZ2D4/wMA+xkDdgAAAHjaY2BgYGaAYBkGRgYQiAHyGMF8FgYHIM3DwMHABGQrMOgyWDLEM1T9/w8UBfEMgLzE////P/5//f/V/xv+r4eaAAeMbAxwIUYmIMHEgKYAYjUcsDAwsLKxc3BycfPw8jEQA/gZBASFhEVExcQlJKWkZWTl5BUUlZRVVNXUNTQZBgMAAMR+E+gAEQFEAAAAKgAqACoANAA+AEgAUgBcAGYAcAB6AIQAjgCYAKIArAC2AMAAygDUAN4A6ADyAPwBBgEQARoBJAEuATgBQgFMAVYBYAFqAXQBfgGIAZIBnAGmAbIBzgHsAAB42u2NMQ6CUAyGW568x9AneYYgm4MJbhKFaExIOAVX8ApewSt4Bic4AfeAid3VOBixDxfPYEza5O+Xfi04YADggiUIULCuEJK8VhO4bSvpdnktHI5QCYtdi2sl8ZnXaHlqUrNKzdKcT8cjlq+rwZSvIVczNiezsfnP/uznmfPFBNODM2K7MTQ45YEAZqGP81AmGGcF3iPqOop0r1SPTaTbVkfUe4HXj97wYE+yNwWYxwWu4v1ugWHgo3S1XdZEVqWM7ET0cfnLGxWfkgR42o2PvWrDMBSFj/IHLaF0zKjRgdiVMwScNRAoWUoH78Y2icB/yIY09An6AH2Bdu/UB+yxopYshQiEvnvu0dURgDt8QeC8PDw7Fpji3fEA4z/PEJ6YOB5hKh4dj3EvXhxPqH/SKUY3rJ7srZ4FZnh1PMAtPhwP6fl2PMJMPDgeQ4rY8YT6Gzao0eAEA409DuggmTnFnOcSCiEiLMgxCiTI6Cq5DZUd3Qmp10vO0LaLTd2cjN4fOumlc7lUYbSQcZFkutRG7g6JKZKy0RmdLY680CDnEJ+UMkpFFe1RN7nxdVpXrC4aTtnaurOnYercZg2YVmLN/d/gczfEimrE/fs/bOuq29Zmn8tloORaXgZgGa78yO9/cnXm2BpaGvq25Dv9S4E9+5SIc9PqupJKhYFSSl47+Qcr1mYNAAAAeNptw0cKwkAAAMDZJA8Q7OUJvkLsPfZ6zFVERPy8qHh2YER+3i/BP83vIBLLySsoKimrqKqpa2hp6+jq6RsYGhmbmJqZSy0sraxtbO3sHRydnEMU4uR6yx7JJXveP7WrDycAAAAAAAH//wACeNpjYGRgYOABYhkgZgJCZgZNBkYGLQZtIJsFLMYAAAw3ALgAeNolizEKgDAQBCchRbC2sFER0YD6qVQiBCv/H9ezGI6Z5XBAw8CBK/m5iQQVauVbXLnOrMZv2oLdKFa8Pjuru2hJzGabmOSLzNMzvutpB3N42mNgZGBg4GKQYzBhYMxJLMlj4GBgAYow/P/PAJJhLM6sSoWKfWCAAwDAjgbRAAB42mNgYGBkAIIbCZo5IPrmUn0hGA0AO8EFTQAA")}:root{--swiper-theme-color:#007aff}:host{display:block;margin-left:auto;margin-right:auto;position:relative;z-index:1}.swiper{display:block;list-style:none;margin-left:auto;margin-right:auto;overflow:hidden;padding:0;position:relative;z-index:1}.swiper-vertical>.swiper-wrapper{flex-direction:column}.swiper-wrapper{box-sizing:content-box;display:flex;height:100%;position:relative;transition-property:transform;transition-timing-function:var(--swiper-wrapper-transition-timing-function,initial);width:100%;z-index:1}.swiper-android .swiper-slide,.swiper-ios .swiper-slide,.swiper-wrapper{transform:translateZ(0)}.swiper-horizontal{touch-action:pan-y}.swiper-vertical{touch-action:pan-x}.swiper-slide{display:block;flex-shrink:0;height:100%;position:relative;transition-property:transform;width:100%}.swiper-slide-invisible-blank{visibility:hidden}.swiper-autoheight,.swiper-autoheight .swiper-slide{height:auto}.swiper-autoheight .swiper-wrapper{align-items:flex-start;transition-property:transform,height}.swiper-backface-hidden .swiper-slide{-webkit-backface-visibility:hidden;backface-visibility:hidden;transform:translateZ(0)}.swiper-3d.swiper-css-mode .swiper-wrapper{perspective:1200px}.swiper-3d .swiper-wrapper{transform-style:preserve-3d}.swiper-3d{perspective:1200px}.swiper-3d .swiper-cube-shadow,.swiper-3d .swiper-slide{transform-style:preserve-3d}.swiper-css-mode>.swiper-wrapper{-ms-overflow-style:none;overflow:auto;scrollbar-width:none}.swiper-css-mode>.swiper-wrapper::-webkit-scrollbar{display:none}.swiper-css-mode>.swiper-wrapper>.swiper-slide{scroll-snap-align:start start}.swiper-css-mode.swiper-horizontal>.swiper-wrapper{scroll-snap-type:x mandatory}.swiper-css-mode.swiper-vertical>.swiper-wrapper{scroll-snap-type:y mandatory}.swiper-css-mode.swiper-free-mode>.swiper-wrapper{scroll-snap-type:none}.swiper-css-mode.swiper-free-mode>.swiper-wrapper>.swiper-slide{scroll-snap-align:none}.swiper-css-mode.swiper-centered>.swiper-wrapper:before{content:"";flex-shrink:0;order:9999}.swiper-css-mode.swiper-centered>.swiper-wrapper>.swiper-slide{scroll-snap-align:center center;scroll-snap-stop:always}.swiper-css-mode.swiper-centered.swiper-horizontal>.swiper-wrapper>.swiper-slide:first-child{margin-inline-start:var(--swiper-centered-offset-before)}.swiper-css-mode.swiper-centered.swiper-horizontal>.swiper-wrapper:before{height:100%;min-height:1px;width:var(--swiper-centered-offset-after)}.swiper-css-mode.swiper-centered.swiper-vertical>.swiper-wrapper>.swiper-slide:first-child{margin-block-start:var(--swiper-centered-offset-before)}.swiper-css-mode.swiper-centered.swiper-vertical>.swiper-wrapper:before{height:var(--swiper-centered-offset-after);min-width:1px;width:100%}.swiper-3d .swiper-slide-shadow,.swiper-3d .swiper-slide-shadow-bottom,.swiper-3d .swiper-slide-shadow-left,.swiper-3d .swiper-slide-shadow-right,.swiper-3d .swiper-slide-shadow-top{height:100%;left:0;pointer-events:none;position:absolute;top:0;width:100%;z-index:10}.swiper-3d .swiper-slide-shadow{background:rgba(0,0,0,.15)}.swiper-3d .swiper-slide-shadow-left{background-image:linear-gradient(270deg,rgba(0,0,0,.5),transparent)}.swiper-3d .swiper-slide-shadow-right{background-image:linear-gradient(90deg,rgba(0,0,0,.5),transparent)}.swiper-3d .swiper-slide-shadow-top{background-image:linear-gradient(0deg,rgba(0,0,0,.5),transparent)}.swiper-3d .swiper-slide-shadow-bottom{background-image:linear-gradient(180deg,rgba(0,0,0,.5),transparent)}.swiper-lazy-preloader{border:4px solid var(--swiper-preloader-color,var(--swiper-theme-color));border-radius:50%;border-top:4px solid transparent;box-sizing:border-box;height:42px;left:50%;margin-left:-21px;margin-top:-21px;position:absolute;top:50%;transform-origin:50%;width:42px;z-index:10}.swiper-watch-progress .swiper-slide-visible .swiper-lazy-preloader,.swiper:not(.swiper-watch-progress) .swiper-lazy-preloader{animation:swiper-preloader-spin 1s linear infinite}.swiper-lazy-preloader-white{--swiper-preloader-color:#fff}.swiper-lazy-preloader-black{--swiper-preloader-color:#000}@keyframes swiper-preloader-spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}.swiper.swiper-cards{overflow:visible}.swiper-cards .swiper-slide{-webkit-backface-visibility:hidden;backface-visibility:hidden;overflow:hidden;transform-origin:center bottom}.swiper-grid>.swiper-wrapper{flex-wrap:wrap}.swiper-grid-column>.swiper-wrapper{flex-direction:column;flex-wrap:wrap}@keyframes enter{0%{opacity:var(--tw-enter-opacity,1);transform:translate3d(var(--tw-enter-translate-x,0),var(--tw-enter-translate-y,0),0) scale3d(var(--tw-enter-scale,1),var(--tw-enter-scale,1),var(--tw-enter-scale,1)) rotate(var(--tw-enter-rotate,0))}}@keyframes exit{to{opacity:var(--tw-exit-opacity,1);transform:translate3d(var(--tw-exit-translate-x,0),var(--tw-exit-translate-y,0),0) scale3d(var(--tw-exit-scale,1),var(--tw-exit-scale,1),var(--tw-exit-scale,1)) rotate(var(--tw-exit-rotate,0))}}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-rotate-x{syntax:"*";inherits:false;initial-value:rotateX(0)}@property --tw-rotate-y{syntax:"*";inherits:false;initial-value:rotateY(0)}@property --tw-rotate-z{syntax:"*";inherits:false;initial-value:rotateZ(0)}@property --tw-skew-x{syntax:"*";inherits:false;initial-value:skewX(0)}@property --tw-skew-y{syntax:"*";inherits:false;initial-value:skewY(0)}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-gradient-position{syntax:"*";inherits:false}@property --tw-gradient-from{syntax:"<color>";inherits:false;initial-value:#0000}@property --tw-gradient-via{syntax:"<color>";inherits:false;initial-value:#0000}@property --tw-gradient-to{syntax:"<color>";inherits:false;initial-value:#0000}@property --tw-gradient-stops{syntax:"*";inherits:false}@property --tw-gradient-via-stops{syntax:"*";inherits:false}@property --tw-gradient-from-position{syntax:"<length-percentage>";inherits:false;initial-value:0}@property --tw-gradient-via-position{syntax:"<length-percentage>";inherits:false;initial-value:50%}@property --tw-gradient-to-position{syntax:"<length-percentage>";inherits:false;initial-value:100%}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@property --tw-ease{syntax:"*";inherits:false}@keyframes pulse{50%{opacity:.5}}@keyframes float{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(-200px)}}',Lo=Io.trim().length>0,Ro="undefined"!=typeof window&&"adoptedStyleSheets"in Document.prototype&&"undefined"!=typeof CSSStyleSheet&&"replaceSync"in CSSStyleSheet.prototype;let Po=null;function Co(e){return Po||(Po=new CSSStyleSheet,Po.replaceSync(e)),Po}function Do(){return Lo?Io:function(){const e=[];for(const t of Array.from(document.styleSheets))try{e.push(Array.from(t.cssRules).map(e=>e.cssText).join("\n"))}catch(e){}return e.join("\n")}()}const _o=({extra:e})=>{const r=Do()+(e?"\n"+e:"");return t.createElement("style",null,r)};const Oo=sr(e=>({open:!1,setOpen:t=>e({open:t})}));function Mo(){const[e,n]=t.useState(null),s=r(null),{open:a,setOpen:o}=Oo();return i(()=>{s.current&&(s.current.style.display=a?"block":"none")},[a]),t.useLayoutEffect(()=>{const e=document.createElement("div");e.style.position="fixed",e.style.inset="0",e.style.zIndex="214748348",e.style.display="none",document.body.appendChild(e),s.current=e;const t=e.attachShadow({mode:"open"});!function(e){const t=Do();if(Ro)e.adoptedStyleSheets=[Co(t)];else{const r=document.createElement("style");r.textContent=t,e.appendChild(r)}}(t);const r=document.createElement("style");r.innerHTML="\n .product-dialog-container{\n max-height: 70vh;\n overflow-y: auto;\n width: 100%;\n max-width: min(82vw, 500px) !important;\n }\n ",t.appendChild(r);const i=document.createElement("div");return t.appendChild(i),n(i),()=>e.remove()},[]),{container:e,setOpen:o}}const No=t.createContext(null),Fo=e=>{var r;const{isMobile:n}=e,a=ar(e=>e.setIsPreview),[o,l]=s("collection"in e?e.collection.contents[0]:null),c=null!==(r=e.isPreview)&&void 0!==r&&r;if(Ao({collection:"collection"in e&&!n?e.collection:void 0,shortform:"shortform"in e?e.shortform:n?null:o,isPreview:c}),i(()=>{var t;const r=ar.getState().isPreview;return a(null!==(t=e.isPreview)&&void 0!==t&&t),()=>{a(r)}},[e.isPreview,a]),n){if("shortform"in e)return t.createElement(Eo,{shortForm:e.shortform,trackStatistics:!1,isPreview:c});if(e.collection)return t.createElement(ko,{collection:e.collection,playerSettings:e.collection.player.shoppingPlayer,isPreview:c})}if("shortform"in e){const{layout:r}=e.shortform.player,i=e.shortform.player.shoppingPlayer;switch(r){case Kr.PLATFORM:return t.createElement(us,{shortform:e.shortform,playerSettings:i,isPreview:c,player:t.createElement("div",{className:"aspect-[9/16] h-full rounded-xl border overflow-hidden"},t.createElement(Eo,{shortForm:e.shortform,hideProductCarousel:!0,hideOverlay:!0,trackStatistics:!1,isPreview:c}))});case Kr.HORIZONTAL:return t.createElement(Ka,{shortform:e.shortform,playerSettings:i,isPreview:c,player:t.createElement("div",{className:"h-full aspect-[9/16]"},t.createElement(Eo,{shortForm:e.shortform,hideProductCarousel:!0,trackStatistics:!1,isPreview:c}))});case Kr.VERTICAL:return t.createElement(Xa,{shortform:e.shortform,playerSettings:i,isPreview:c,player:t.createElement("div",{className:"aspect-[9/16] h-full"},t.createElement(Eo,{shortForm:e.shortform,hideProductCarousel:!0,trackStatistics:!1,isPreview:c}))});case Kr.GRID:return t.createElement(Za,{shortform:e.shortform,playerSettings:i,isPreview:c,player:t.createElement("div",{className:"h-full aspect-[9/16]"},t.createElement(Eo,{shortForm:e.shortform,hideProductCarousel:!0,trackStatistics:!1,isPreview:c}))})}}else{if(!e.collection||!o)return null;{const{layout:r}=e.collection.player,i=e.collection.player.shoppingPlayer;switch(r){case Kr.PLATFORM:return t.createElement(us,{shortform:o,playerSettings:i,isPreview:c,player:t.createElement("div",{className:"w-full flex items-center justify-center gap-4",style:{height:"calc(-220px + 100vh)"}},t.createElement(eo,{collection:e.collection,playerSettings:i,shortform:o,setShortform:l}))});case Kr.HORIZONTAL:return t.createElement(Ka,{shortform:o,isPreview:c,playerSettings:Object.assign({},i),player:t.createElement(So,{collection:e.collection,playerSettings:i,shortform:o,setShortform:l,isPreview:c})});case Kr.VERTICAL:return t.createElement(Xa,{isPreview:c,playerSettings:Object.assign({},i),shortform:o,player:t.createElement(So,{collection:e.collection,playerSettings:i,shortform:o,setShortform:l,isPreview:c})});case Kr.GRID:return t.createElement(Za,{shortform:o,isPreview:c,playerSettings:Object.assign({},i),player:t.createElement(So,{collection:e.collection,playerSettings:i,shortform:o,setShortform:l,isPreview:c})})}}}},$o=e=>{const{container:r}=Mo();return r?t.createElement(qr.div,{style:{display:"block",width:"100%",height:"100%"}},t.createElement(_o,null),t.createElement(No.Provider,{value:r},t.createElement(Fo,Object.assign({},e)))):null},Bo=e=>{const{container:r}=Mo();return r?t.createElement(qr.div,{style:{display:"block",width:"100%",height:"100%"}},t.createElement(_o,null),t.createElement(No.Provider,{value:r},t.createElement(Eo,Object.assign({},e,{isPreview:!0,trackStatistics:!1})))):null},Uo=t.createContext(null),zo=({children:e})=>{const r=t.useRef(null);return r.current||(r.current=tr(e=>({collection:null,setCollection:t=>e({collection:t}),nextKey:"",setNextKey:t=>e({nextKey:t}),isFetching:!1,setIsFetching:t=>e({isFetching:t})}))),t.createElement(Uo.Provider,{value:r.current},e)},Go=()=>(e=>{const r=t.useContext(Uo);if(!r)throw new Error("Missing CollectionProvider");return ir(r,e)})(e=>e),jo=(e,t,n)=>{const{collection:s,setCollection:a,isFetching:o,setIsFetching:l,nextKey:c,setNextKey:d}=Go(),u=ar(e=>e.isPreview),h=null!=n?n:u,f=(null==e?void 0:e.media)?At(e.media.duration):0,{resetPlaytime:p,playtime:m}=Ft(),{playtime:g,resetPlaytime:v}=Ft(),y=Qt(),b=r(new Set),E=r(new Set),w=()=>{if(!s)return;const{colId:t,uuid:r,userId:i}=s;if(h)return;const n=Ge,a=Math.floor((new Date).getTime()/1e3);localStorage.setItem(n,a.toString()),r&&!b.current.has(r)&&(b.current.add(r),zt({contentId:t,uuid:r,type:wt.COLLECTION,userId:i,playtime:g})),(null==e?void 0:e.uuid)&&!E.current.has(e.uuid)&&(E.current.add(e.uuid),zt({contentId:e.shortsId,uuid:e.uuid,type:wt.SHORTS,userId:e.userId,playtime:m,isFinished:m>=f})),v(),p()},S=r(w);S.current=w;const T=r(0);i(()=>{T.current+=1;const e=T.current;return()=>{Promise.resolve().then(()=>{T.current===e&&S.current()})}},[]),i(()=>{y||w()},[y]);return{onSlideChange:r=>x(void 0,void 0,void 0,function*(){if(e&&s&&(yield(e=>x(void 0,void 0,void 0,function*(){var t,r;if(!s)return;const{contents:i,count:n}=s;if((null!=n?n:Number.MAX_SAFE_INTEGER)>i.length&&e>=i.length-5&&!o){l(!0);try{const e=yield Vt({collectionId:s.colId,nextKey:c});if(!e||!(null===(t=e.contents)||void 0===t?void 0:t.length))return;d((null===(r=e.contents.at(-1))||void 0===r?void 0:r.shortsId)||"");const i=new Set(s.contents.map(e=>e.shortsId)),n=e.contents.filter(e=>!i.has(e.shortsId));if(!n.length)return;const o=s.contents.concat(n);a(Object.assign(Object.assign({},s),{contents:o}))}catch(e){console.error(e)}finally{l(!1)}}}))(r),!h)){const{shortsId:i,uuid:n,userId:a}=e;n&&!E.current.has(n)&&(E.current.add(n),zt({contentId:i,uuid:n,type:wt.SHORTS,playtime:m,isFinished:m>=f,userId:a})),p();const o=Lt(),l=s.contents[r];t(Object.assign(Object.assign({},l),{uuid:o})),yield Ut({contentId:l.shortsId,uuid:o,type:wt.SHORTS,userId:l.userId,isFirstPlay:!Pt(l.shortsId)})}}),onCollectionClose:w}},Ho=t.memo(({shortform:e,shareUrl:r,handleClose:i})=>t.createElement(t.Fragment,null,t.createElement("div",{onClick:e=>e.stopPropagation(),className:"overflow-hidden",style:{borderRadius:"10px",overflow:"hidden",width:"100%",height:"100%",backgroundRepeat:"no-repeat",backgroundPosition:"center",backgroundSize:"cover",backgroundImage:`url(${Dt(e.thumbPath)})`}},t.createElement(Eo,{handleClose:i,shortForm:e,isPopup:!0,trackStatistics:!1,shareUrl:r})))),Vo=t.memo(({shortform:e})=>t.createElement("div",{onClick:e=>{e.stopPropagation()},style:{width:"100%",height:"100%",borderRadius:"10px",backgroundRepeat:"no-repeat",backgroundPosition:"center",backgroundSize:"cover",backgroundImage:`url(${e.thumbPath.includes("https")?e.thumbPath:`https://${e.thumbPath}`})`}})),Wo=({shortform:e,shareUrl:r,handleClose:i})=>{const{isActive:n}=d(La),s=d(Ra),a=go().width<430||co.isMobile;return t.createElement("div",{className:"flex items-center justify-center w-full h-full select-none",onClick:e=>{i()}},t.createElement("div",{className:"max-h-full flex items-center justify-center",style:{width:"100%",aspectRatio:a?"auto":"9 / 16",height:a?"100dvh":"auto",maxHeight:a?void 0:"90vh",transform:a?void 0:`scale(${n?1:.8})`,transition:"transform 180ms ease"}},n?t.createElement("div",{className:"flex items-center justify-between w-full h-full text-white relative"},t.createElement("div",{className:"cursor-pointer absolute",onClick:e=>{e.stopPropagation(),s.slidePrev()},style:{zIndex:1e5,left:a?"0":"-30px",top:"50%",transform:"translateY(-50%)",width:30,height:30,display:"grid",placeItems:"center",pointerEvents:"auto"}},t.createElement(ii,{size:28})),t.createElement(Ho,{shortform:e,shareUrl:r,handleClose:i}),t.createElement("div",{className:"cursor-pointer absolute",style:{zIndex:1e5,right:a?"0":"-30px",top:"50%",transform:"translateY(-50%)",width:30,height:30,display:"grid",placeItems:"center",pointerEvents:"auto"},onClick:e=>{e.stopPropagation(),s.slideNext()}},t.createElement(ni,{size:28}))):t.createElement(Vo,{shortform:e})))},Yo=({collection:e,initialShortsId:i,onSlideChange:n,onClosePlayer:s})=>{var a;const{PLAYER_BASE_URL:o}=gt(),l=u(()=>Math.max(e.contents.findIndex(e=>e.shortsId===i),0),[e.contents,i]),c=null!==(a=go().width)&&void 0!==a?a:0,d=c<430||co.isMobile,h=d?1:c>=1200?4:c>=900?3:2,f=e.contents.length>=3,p=f?Math.min(h,e.contents.length-1):Math.min(h,e.contents.length),m=r(null);return t.createElement("div",{style:{minHeight:100,minWidth:300},className:"w-full"},t.createElement(Pa,{style:{minHeight:100,overflow:"visible"},initialSlide:l,ref:m,lazyPreloadPrevNext:2,className:"w-full",spaceBetween:d?8:c>=1200?24:c>=900?25:16,slidesPerView:p,grabCursor:!0,centeredSlides:1!==p,onSlideChangeTransitionEnd:t=>{const r=t.realIndex;null==n||n(r);const i=e.contents[f?(r+1)%e.contents.length:r+1];var s;i&&(s=xt(i.media.objectId),A||(A=document.createElement("video"),A.muted=!0,A.playsInline=!0,A.preload="metadata",A.loop=!0,A.style.cssText="position:fixed;left:-9999px;top:-9999px;width:1px;height:1px;opacity:0",document.body.appendChild(A)),k!==s&&(A.src=s,A.load(),k=s))},loop:f,onClick:e=>{const t=e.clickedIndex;if("number"!=typeof t||Number.isNaN(t))return;if(!f)return void e.slideTo(t);const r=t-e.activeIndex,i=Math.min(Math.abs(r),p);for(let t=0;t<i;t+=1)r>0?e.slideNext():e.slidePrev()}},e.contents.map(r=>t.createElement(Ca,{key:r.shortsId},t.createElement(Wo,{handleClose:s,shortform:r,shareUrl:`${o}/collection/${e.colId}?start=${r.shortsId}&layout=5`})))))},Ko=({shortform:e,onThumbnailClick:r,iconSize:i,exposeTitle:n,borderLine:s})=>{const a=u(()=>Ct(s),[s])?{background:"linear-gradient(#fff,#fff) padding-box, conic-gradient(#f58529,#f77737,#fd1d1d,#833ab4,#c13584,#f58529) border-box",border:"3px solid transparent"}:{background:"#fff",border:"3px solid #fff"};return t.createElement("div",{className:"flex flex-col w-full gap-2",onClick:()=>r(e.shortsId)},t.createElement("div",{className:"rounded-full overflow-hidden cursor-pointer",style:Object.assign({width:i,height:i,padding:4},a)},t.createElement("img",{src:Dt(e.thumbPath),alt:"thumbnail",className:"w-full h-full object-cover block rounded-full"})),n&&t.createElement("span",{style:{width:i},className:"text-black overflow-hidden text-[12px] whitespace-nowrap text-center text-clip cursor-default"},e.title))},qo=({products:e,iconSize:r,contentId:i,setSelectedProducts:n,showMoreBtn:s,hideMoreBadge:a,showPrice:o,openInPortal:l=!0,imageSize:c})=>{const{setOpen:d}=Oo(),u=()=>{n({productsInfo:e,shortsId:i}),l&&d(!0)};return t.createElement(t.Fragment,null,t.createElement("div",{onClick:()=>x(void 0,void 0,void 0,function*(){1===e.length||s||u()}),className:"flex flex-col gap-2 mt-4 text-gray-800",style:{maxWidth:r||"100%",fontSize:13}},t.createElement(mo,{showMoreBtn:s,lineClamp:2,product:e[0],contentId:i,productLength:e.length,hideMoreBadge:null!=a?a:1===e.length,showPrice:o,imageSize:c,openProductPopup:u})))},Xo=({product:e,maxWidth:r="100%",height:i,cardWidth:n})=>{const s=ar(e=>e.memberOnly&&!e.isMemberLoggedIn);return t.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,borderRadius:8,backgroundColor:"#ffffff",color:"#111827",maxWidth:r,height:i,width:"100%",paddingRight:8}},t.createElement("img",{src:Dt(e.thumbPath),alt:e.productName,style:{height:"100%",aspectRatio:"1 / 1",borderRadius:6,objectFit:"cover",flexShrink:0}}),t.createElement("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",justifyContent:"center"}},t.createElement("span",{style:{lineHeight:1.25,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",fontSize:12}},e.productName),t.createElement("span",{style:{lineHeight:1.25,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",fontSize:11}},(()=>{if(s)return t.createElement("span",{style:{color:"#dc2626",fontWeight:600}},"판매가 회원 공개");return"number"==typeof e.sellingPrice&&e.sellingPrice<e.price?"number"==typeof n&&n>=190?t.createElement(t.Fragment,null,t.createElement("span",{style:{color:"#dc2626",fontWeight:600,marginRight:4}},Tt(e.sellingPrice,e.currency)),t.createElement("span",{style:{color:"#9ca3af",textDecoration:"line-through"}},Tt(e.price,e.currency))):t.createElement("span",{style:{color:"#dc2626",fontWeight:600}},Tt(e.sellingPrice,e.currency)):t.createElement("span",{style:{color:"#dc2626",fontWeight:600}},Tt(e.price,e.currency))})())))},Qo=({playUrl:e,poster:r})=>t.createElement("div",{className:"w-full h-full absolute top-0 left-0 z-10 pointer-events-none",style:{backgroundImage:`url(${r})`,backgroundSize:"cover",backgroundPosition:"center",backgroundRepeat:"no-repeat"}},t.createElement("video",{src:e,autoPlay:!0,muted:!0,preload:"auto",playsInline:!0,loop:!0,className:"w-full h-full object-cover"})),Zo=({shortform:e,onThumbnailClick:r,onPreviewPlay:i,iconSize:n,exposeTitle:a,rounded:o,borderLine:l,titlePosition:c,exposeProductBanner:d,setSelectedProducts:h,iconRatio:f,hoverPlay:p,exposeProductBadge:m})=>{var g;const v=u(()=>Ct(l),[l]),[y,b]=s(!1),{API_BASE_URL:E}=gt();return t.createElement("div",{className:"relative"},t.createElement("div",{onMouseEnter:()=>{b(!0),p&&i(e.shortsId)},onMouseLeave:()=>b(!1),onClick:()=>r(e.shortsId),style:Object.assign({width:n,aspectRatio:f},o&&{borderRadius:"15px"}),className:`cursor-pointer p-[3px] ${o&&"rounded-[15px]"} ${v&&"bg-insta"} relative overflow-hidden`},y&&p&&t.createElement(Qo,{playUrl:`${E}/direct/${e.media.objectId}`,poster:Dt(e.thumbPath)}),t.createElement("img",{style:Object.assign({},o&&{borderRadius:"15px"}),src:Dt(e.thumbPath),alt:"thumbnail",className:`w-full h-full object-cover ${o&&"rounded-[15px]"}`}),m&&(null===(g=e.productsInfo)||void 0===g?void 0:g.length)>0&&!(p&&y)&&t.createElement("div",{className:"absolute pointer-events-none flex items-center justify-center z-20",style:{left:2,right:2,bottom:10,height:"20%"}},t.createElement("div",{className:"h-full inline-block",style:{width:"95%"}},t.createElement(Xo,{product:e.productsInfo[0],maxWidth:"100%",height:"100%",cardWidth:n}))),a&&c===Be.INNER&&!(p&&y)&&t.createElement("p",{style:Object.assign({overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},m?{bottom:"22%"}:{}),className:"absolute bottom-0 left-0 w-full my-2 text-white px-2 z-10 text-[12px] cursor-default truncate"},e.title)),a&&c!==Be.INNER&&t.createElement("p",{style:{width:n,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},className:"my-2 text-[12px] cursor-default truncate"},e.title),d&&t.createElement(qo,{setSelectedProducts:h,products:e.productsInfo,iconSize:n,contentId:e.shortsId}))},Jo=e=>{const{iconShape:r,collection:i}=e;return r===Ne.MANY?t.createElement(el,Object.assign({},e)):t.createElement(tl,Object.assign({},e,{shortform:i.contents[0]}))},el=e=>{const{collection:r}=e,{thumbnailAutoPlay:i}=e,{setCollection:n,nextKey:s,setNextKey:a,isFetching:o,setIsFetching:l}=Go();return t.createElement(Pa,{freeMode:!0,slidesPerView:"auto",spaceBetween:12,onReachEnd:()=>x(void 0,void 0,void 0,function*(){var e,t,i;if(r&&!(o||(null!==(e=r.count)&&void 0!==e?e:Number.MAX_SAFE_INTEGER)<=r.contents.length)){l(!0);try{const e=yield Vt({collectionId:r.colId,nextKey:s});if(!e||!(null===(t=e.contents)||void 0===t?void 0:t.length))return;a((null===(i=e.contents.at(-1))||void 0===i?void 0:i.shortsId)||"");const o=new Set(r.contents.map(e=>e.shortsId)),l=e.contents.filter(e=>!o.has(e.shortsId));if(!l.length)return;n(Object.assign(Object.assign({},r),{contents:[...r.contents,...l]}))}catch(e){console.error(e)}finally{l(!1)}}}),modules:i?[Oa]:[],autoplay:!!i&&{delay:3e3,disableOnInteraction:!1,pauseOnMouseEnter:!0},loop:i||void 0},null==r?void 0:r.contents.map(r=>t.createElement(Ca,{key:r.shortsId,className:"!w-auto"},t.createElement(tl,Object.assign({},e,{shortform:r})))))},tl=e=>{const{iconForm:r}=e;return r===Me.INSTA?t.createElement(Ko,Object.assign({},e)):t.createElement(Zo,Object.assign({},e))};function rl(e,t,{checkForDefaultPrevented:r=!0}={}){return function(i){if(e?.(i),!1===r||!i.defaultPrevented)return t?.(i)}}function il(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function nl(...e){return t=>{let r=!1;const i=e.map(e=>{const i=il(e,t);return r||"function"!=typeof i||(r=!0),i});if(r)return()=>{for(let t=0;t<i.length;t++){const r=i[t];"function"==typeof r?r():il(e[t],null)}}}}function sl(...t){return e.useCallback(nl(...t),t)}function al(...t){const r=t[0];if(1===t.length)return r;const i=()=>{const i=t.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(t){const n=i.reduce((e,{useScope:r,scopeName:i})=>({...e,...r(t)[`__scope${i}`]}),{});return e.useMemo(()=>({[`__scope${r.scopeName}`]:n}),[n])}};return i.scopeName=r.scopeName,i}var ol=globalThis?.document?e.useLayoutEffect:()=>{},ll=e[" useId ".trim().toString()]||(()=>{}),cl=0;function dl(t){const[r,i]=e.useState(ll());return ol(()=>{t||i(e=>e??String(cl++))},[t]),t||(r?`radix-${r}`:"")}var ul=e[" useInsertionEffect ".trim().toString()]||ol;function hl({prop:t,defaultProp:r,onChange:i=()=>{},caller:n}){const[s,a,o]=function({defaultProp:t,onChange:r}){const[i,n]=e.useState(t),s=e.useRef(i),a=e.useRef(r);return ul(()=>{a.current=r},[r]),e.useEffect(()=>{s.current!==i&&(a.current?.(i),s.current=i)},[i,s]),[i,n,a]}({defaultProp:r,onChange:i}),l=void 0!==t,c=l?t:s;{const r=e.useRef(void 0!==t);e.useEffect(()=>{const e=r.current;if(e!==l){const t=e?"controlled":"uncontrolled",r=l?"controlled":"uncontrolled";console.warn(`${n} is changing from ${t} to ${r}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`)}r.current=l},[l,n])}const d=e.useCallback(e=>{if(l){const r=function(e){return"function"==typeof e}(e)?e(t):e;r!==t&&o.current?.(r)}else a(e)},[l,t,a,o]);return[c,d]}function fl(e,t,{checkForDefaultPrevented:r=!0}={}){return function(i){if(e?.(i),!1===r||!i.defaultPrevented)return t?.(i)}}function pl(t){const r=ml(t),i=e.forwardRef((t,i)=>{const{children:n,...s}=t,a=e.Children.toArray(n),o=a.find(vl);if(o){const t=o.props.children,n=a.map(r=>r===o?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:r);return b(r,{...s,ref:i,children:e.isValidElement(t)?e.cloneElement(t,void 0,n):null})}return b(r,{...s,ref:i,children:n})});return i.displayName=`${t}.Slot`,i}function ml(t){const r=e.forwardRef((t,r)=>{const{children:i,...n}=t;if(e.isValidElement(i)){const t=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;if(r)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r)return e.props.ref;return e.props.ref||e.ref}(i),s=function(e,t){const r={...t};for(const i in t){const n=e[i],s=t[i];/^on[A-Z]/.test(i)?n&&s?r[i]=(...e)=>{const t=s(...e);return n(...e),t}:n&&(r[i]=n):"style"===i?r[i]={...n,...s}:"className"===i&&(r[i]=[n,s].filter(Boolean).join(" "))}return{...e,...r}}(n,i.props);return i.type!==e.Fragment&&(s.ref=r?nl(r,t):t),e.cloneElement(i,s)}return e.Children.count(i)>1?e.Children.only(null):null});return r.displayName=`${t}.SlotClone`,r}var gl=Symbol("radix.slottable");function vl(t){return e.isValidElement(t)&&"function"==typeof t.type&&"__radixId"in t.type&&t.type.__radixId===gl}var yl=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((t,r)=>{const i=pl(`Primitive.${r}`),n=e.forwardRef((e,t)=>{const{asChild:n,...s}=e,a=n?i:r;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),b(a,{...s,ref:t})});return n.displayName=`Primitive.${r}`,{...t,[r]:n}},{});function bl(t){const r=e.useRef(t);return e.useEffect(()=>{r.current=t}),e.useMemo(()=>(...e)=>r.current?.(...e),[])}var El,wl="dismissableLayer.update",Sl="dismissableLayer.pointerDownOutside",Tl="dismissableLayer.focusOutside",xl=e.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Al=e.forwardRef((t,r)=>{const{disableOutsidePointerEvents:i=!1,onEscapeKeyDown:n,onPointerDownOutside:s,onFocusOutside:a,onInteractOutside:o,onDismiss:l,...c}=t,d=e.useContext(xl),[u,h]=e.useState(null),f=u?.ownerDocument??globalThis?.document,[,p]=e.useState({}),m=sl(r,e=>h(e)),g=Array.from(d.layers),[v]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),y=g.indexOf(v),E=u?g.indexOf(u):-1,w=d.layersWithOutsidePointerEventsDisabled.size>0,S=E>=y,T=function(t,r=globalThis?.document){const i=bl(t),n=e.useRef(!1),s=e.useRef(()=>{});return e.useEffect(()=>{const e=e=>{if(e.target&&!n.current){let t=function(){Il(Sl,i,n,{discrete:!0})};const n={originalEvent:e};"touch"===e.pointerType?(r.removeEventListener("click",s.current),s.current=t,r.addEventListener("click",s.current,{once:!0})):t()}else r.removeEventListener("click",s.current);n.current=!1},t=window.setTimeout(()=>{r.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(t),r.removeEventListener("pointerdown",e),r.removeEventListener("click",s.current)}},[r,i]),{onPointerDownCapture:()=>n.current=!0}}(e=>{const t=e.target,r=[...d.branches].some(e=>e.contains(t));S&&!r&&(s?.(e),o?.(e),e.defaultPrevented||l?.())},f),x=function(t,r=globalThis?.document){const i=bl(t),n=e.useRef(!1);return e.useEffect(()=>{const e=e=>{if(e.target&&!n.current){Il(Tl,i,{originalEvent:e},{discrete:!1})}};return r.addEventListener("focusin",e),()=>r.removeEventListener("focusin",e)},[r,i]),{onFocusCapture:()=>n.current=!0,onBlurCapture:()=>n.current=!1}}(e=>{const t=e.target;[...d.branches].some(e=>e.contains(t))||(a?.(e),o?.(e),e.defaultPrevented||l?.())},f);return function(t,r=globalThis?.document){const i=bl(t);e.useEffect(()=>{const e=e=>{"Escape"===e.key&&i(e)};return r.addEventListener("keydown",e,{capture:!0}),()=>r.removeEventListener("keydown",e,{capture:!0})},[i,r])}(e=>{E===d.layers.size-1&&(n?.(e),!e.defaultPrevented&&l&&(e.preventDefault(),l()))},f),e.useEffect(()=>{if(u)return i&&(0===d.layersWithOutsidePointerEventsDisabled.size&&(El=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(u)),d.layers.add(u),kl(),()=>{i&&1===d.layersWithOutsidePointerEventsDisabled.size&&(f.body.style.pointerEvents=El)}},[u,f,i,d]),e.useEffect(()=>()=>{u&&(d.layers.delete(u),d.layersWithOutsidePointerEventsDisabled.delete(u),kl())},[u,d]),e.useEffect(()=>{const e=()=>p({});return document.addEventListener(wl,e),()=>document.removeEventListener(wl,e)},[]),b(yl.div,{...c,ref:m,style:{pointerEvents:w?S?"auto":"none":void 0,...t.style},onFocusCapture:fl(t.onFocusCapture,x.onFocusCapture),onBlurCapture:fl(t.onBlurCapture,x.onBlurCapture),onPointerDownCapture:fl(t.onPointerDownCapture,T.onPointerDownCapture)})});Al.displayName="DismissableLayer";function kl(){const e=new CustomEvent(wl);document.dispatchEvent(e)}function Il(e,t,r,{discrete:i}){const n=r.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});t&&n.addEventListener(e,t,{once:!0}),i?function(e,t){e&&p.flushSync(()=>e.dispatchEvent(t))}(n,s):n.dispatchEvent(s)}e.forwardRef((t,r)=>{const i=e.useContext(xl),n=e.useRef(null),s=sl(r,n);return e.useEffect(()=>{const e=n.current;if(e)return i.branches.add(e),()=>{i.branches.delete(e)}},[i.branches]),b(yl.div,{...t,ref:s})}).displayName="DismissableLayerBranch";var Ll="focusScope.autoFocusOnMount",Rl="focusScope.autoFocusOnUnmount",Pl={bubbles:!1,cancelable:!0},Cl=e.forwardRef((t,r)=>{const{loop:i=!1,trapped:n=!1,onMountAutoFocus:s,onUnmountAutoFocus:a,...o}=t,[l,c]=e.useState(null),d=bl(s),u=bl(a),h=e.useRef(null),f=sl(r,e=>c(e)),p=e.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;e.useEffect(()=>{if(n){let e=function(e){if(p.paused||!l)return;const t=e.target;l.contains(t)?h.current=t:Ml(h.current,{select:!0})},t=function(e){if(p.paused||!l)return;const t=e.relatedTarget;null!==t&&(l.contains(t)||Ml(h.current,{select:!0}))},r=function(e){if(document.activeElement===document.body)for(const t of e)t.removedNodes.length>0&&Ml(l)};document.addEventListener("focusin",e),document.addEventListener("focusout",t);const i=new MutationObserver(r);return l&&i.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",t),i.disconnect()}}},[n,l,p.paused]),e.useEffect(()=>{if(l){Nl.add(p);const t=document.activeElement;if(!l.contains(t)){const r=new CustomEvent(Ll,Pl);l.addEventListener(Ll,d),l.dispatchEvent(r),r.defaultPrevented||(!function(e,{select:t=!1}={}){const r=document.activeElement;for(const i of e)if(Ml(i,{select:t}),document.activeElement!==r)return}((e=Dl(l),e.filter(e=>"A"!==e.tagName)),{select:!0}),document.activeElement===t&&Ml(l))}return()=>{l.removeEventListener(Ll,d),setTimeout(()=>{const e=new CustomEvent(Rl,Pl);l.addEventListener(Rl,u),l.dispatchEvent(e),e.defaultPrevented||Ml(t??document.body,{select:!0}),l.removeEventListener(Rl,u),Nl.remove(p)},0)}}var e},[l,d,u,p]);const m=e.useCallback(e=>{if(!i&&!n)return;if(p.paused)return;const t="Tab"===e.key&&!e.altKey&&!e.ctrlKey&&!e.metaKey,r=document.activeElement;if(t&&r){const t=e.currentTarget,[n,s]=function(e){const t=Dl(e),r=_l(t,e),i=_l(t.reverse(),e);return[r,i]}(t);n&&s?e.shiftKey||r!==s?e.shiftKey&&r===n&&(e.preventDefault(),i&&Ml(s,{select:!0})):(e.preventDefault(),i&&Ml(n,{select:!0})):r===t&&e.preventDefault()}},[i,n,p.paused]);return b(yl.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});function Dl(e){const t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{const t="INPUT"===e.tagName&&"hidden"===e.type;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)t.push(r.currentNode);return t}function _l(e,t){for(const r of e)if(!Ol(r,{upTo:t}))return r}function Ol(e,{upTo:t}){if("hidden"===getComputedStyle(e).visibility)return!0;for(;e;){if(void 0!==t&&e===t)return!1;if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}function Ml(e,{select:t=!1}={}){if(e&&e.focus){const r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&function(e){return e instanceof HTMLInputElement&&"select"in e}(e)&&t&&e.select()}}Cl.displayName="FocusScope";var Nl=function(){let e=[];return{add(t){const r=e[0];t!==r&&r?.pause(),e=Fl(e,t),e.unshift(t)},remove(t){e=Fl(e,t),e[0]?.resume()}}}();function Fl(e,t){const r=[...e],i=r.indexOf(t);return-1!==i&&r.splice(i,1),r}var $l=e.forwardRef((t,r)=>{const{container:i,...n}=t,[s,a]=e.useState(!1);ol(()=>a(!0),[]);const o=i||s&&globalThis?.document?.body;return o?m.createPortal(b(yl.div,{...n,ref:r}),o):null});$l.displayName="Portal";var Bl=t=>{const{present:r,children:i}=t,n=function(t){const[r,i]=e.useState(),n=e.useRef(null),s=e.useRef(t),a=e.useRef("none"),o=t?"mounted":"unmounted",[l,c]=function(t,r){return e.useReducer((e,t)=>r[e][t]??e,t)}(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return e.useEffect(()=>{const e=Ul(n.current);a.current="mounted"===l?e:"none"},[l]),ol(()=>{const e=n.current,r=s.current;if(r!==t){const i=a.current,n=Ul(e);if(t)c("MOUNT");else if("none"===n||"none"===e?.display)c("UNMOUNT");else{c(r&&i!==n?"ANIMATION_OUT":"UNMOUNT")}s.current=t}},[t,c]),ol(()=>{if(r){let e;const t=r.ownerDocument.defaultView??window,i=i=>{const a=Ul(n.current).includes(CSS.escape(i.animationName));if(i.target===r&&a&&(c("ANIMATION_END"),!s.current)){const i=r.style.animationFillMode;r.style.animationFillMode="forwards",e=t.setTimeout(()=>{"forwards"===r.style.animationFillMode&&(r.style.animationFillMode=i)})}},o=e=>{e.target===r&&(a.current=Ul(n.current))};return r.addEventListener("animationstart",o),r.addEventListener("animationcancel",i),r.addEventListener("animationend",i),()=>{t.clearTimeout(e),r.removeEventListener("animationstart",o),r.removeEventListener("animationcancel",i),r.removeEventListener("animationend",i)}}c("ANIMATION_END")},[r,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:e.useCallback(e=>{n.current=e?getComputedStyle(e):null,i(e)},[])}}(r),s="function"==typeof i?i({present:n.isPresent}):e.Children.only(i),a=sl(n.ref,function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;if(r)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r)return e.props.ref;return e.props.ref||e.ref}(s));return"function"==typeof i||n.isPresent?e.cloneElement(s,{ref:a}):null};function Ul(e){return e?.animationName||"none"}Bl.displayName="Presence";var zl=0;function Gl(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var jl="right-scroll-bar-position",Hl="width-before-scroll-bar";function Vl(e,t){return"function"==typeof e?e(t):e&&(e.current=t),e}var Wl="undefined"!=typeof window?e.useLayoutEffect:e.useEffect,Yl=new WeakMap;function Kl(e,t){var r,i,n,a=(r=null,i=function(t){return e.forEach(function(e){return Vl(e,t)})},(n=s(function(){return{value:r,callback:i,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0]).callback=i,n.facade);return Wl(function(){var t=Yl.get(a);if(t){var r=new Set(t),i=new Set(e),n=a.current;r.forEach(function(e){i.has(e)||Vl(e,null)}),i.forEach(function(e){r.has(e)||Vl(e,n)})}Yl.set(a,e)},[e]),a}function ql(e){return e}var Xl=function(t){var r=t.sideCar,i=T(t,["sideCar"]);if(!r)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var n=r.read();if(!n)throw new Error("Sidecar medium not found");return e.createElement(n,S({},i))};Xl.isSideCarExport=!0;var Ql=function(e){void 0===e&&(e={});var t=function(e,t){void 0===t&&(t=ql);var r=[],i=!1,n={read:function(){if(i)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return r.length?r[r.length-1]:e},useMedium:function(e){var n=t(e,i);return r.push(n),function(){r=r.filter(function(e){return e!==n})}},assignSyncMedium:function(e){for(i=!0;r.length;){var t=r;r=[],t.forEach(e)}r={push:function(t){return e(t)},filter:function(){return r}}},assignMedium:function(e){i=!0;var t=[];if(r.length){var n=r;r=[],n.forEach(e),t=r}var s=function(){var r=t;t=[],r.forEach(e)},a=function(){return Promise.resolve().then(s)};a(),r={push:function(e){t.push(e),a()},filter:function(e){return t=t.filter(e),r}}}};return n}(null);return t.options=S({async:!0,ssr:!1},e),t}(),Zl=function(){},Jl=e.forwardRef(function(t,r){var i=e.useRef(null),n=e.useState({onScrollCapture:Zl,onWheelCapture:Zl,onTouchMoveCapture:Zl}),s=n[0],a=n[1],o=t.forwardProps,l=t.children,c=t.className,d=t.removeScrollBar,u=t.enabled,h=t.shards,f=t.sideCar,p=t.noRelative,m=t.noIsolation,g=t.inert,v=t.allowPinchZoom,y=t.as,b=void 0===y?"div":y,E=t.gapMode,w=T(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),x=f,A=Kl([i,r]),k=S(S({},w),s);return e.createElement(e.Fragment,null,u&&e.createElement(x,{sideCar:Ql,removeScrollBar:d,shards:h,noRelative:p,noIsolation:m,inert:g,setCallbacks:a,allowPinchZoom:!!v,lockRef:i,gapMode:E}),o?e.cloneElement(e.Children.only(l),S(S({},k),{ref:A})):e.createElement(b,S({},k,{className:c,ref:A}),l))});Jl.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Jl.classNames={fullWidth:Hl,zeroRight:jl};function ec(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=function(){if("undefined"!=typeof __webpack_nonce__)return __webpack_nonce__}();return t&&e.setAttribute("nonce",t),e}var tc=function(){var e=0,t=null;return{add:function(r){var i,n;0==e&&(t=ec())&&(n=r,(i=t).styleSheet?i.styleSheet.cssText=n:i.appendChild(document.createTextNode(n)),function(e){(document.head||document.getElementsByTagName("head")[0]).appendChild(e)}(t)),e++},remove:function(){! --e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},rc=function(){var t,r=(t=tc(),function(r,i){e.useEffect(function(){return t.add(r),function(){t.remove()}},[r&&i])});return function(e){var t=e.styles,i=e.dynamic;return r(t,i),null}},ic={left:0,top:0,right:0,gap:0},nc=function(e){return parseInt(e||"",10)||0},sc=function(e){if(void 0===e&&(e="margin"),"undefined"==typeof window)return ic;var t=function(e){var t=window.getComputedStyle(document.body),r=t["padding"===e?"paddingLeft":"marginLeft"],i=t["padding"===e?"paddingTop":"marginTop"],n=t["padding"===e?"paddingRight":"marginRight"];return[nc(r),nc(i),nc(n)]}(e),r=document.documentElement.clientWidth,i=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,i-r+t[2]-t[0])}},ac=rc(),oc="data-scroll-locked",lc=function(e,t,r,i){var n=e.left,s=e.top,a=e.right,o=e.gap;return void 0===r&&(r="margin"),"\n .".concat("with-scroll-bars-hidden"," {\n overflow: hidden ").concat(i,";\n padding-right: ").concat(o,"px ").concat(i,";\n }\n body[").concat(oc,"] {\n overflow: hidden ").concat(i,";\n overscroll-behavior: contain;\n ").concat([t&&"position: relative ".concat(i,";"),"margin"===r&&"\n padding-left: ".concat(n,"px;\n padding-top: ").concat(s,"px;\n padding-right: ").concat(a,"px;\n margin-left:0;\n margin-top:0;\n margin-right: ").concat(o,"px ").concat(i,";\n "),"padding"===r&&"padding-right: ".concat(o,"px ").concat(i,";")].filter(Boolean).join(""),"\n }\n \n .").concat(jl," {\n right: ").concat(o,"px ").concat(i,";\n }\n \n .").concat(Hl," {\n margin-right: ").concat(o,"px ").concat(i,";\n }\n \n .").concat(jl," .").concat(jl," {\n right: 0 ").concat(i,";\n }\n \n .").concat(Hl," .").concat(Hl," {\n margin-right: 0 ").concat(i,";\n }\n \n body[").concat(oc,"] {\n ").concat("--removed-body-scroll-bar-size",": ").concat(o,"px;\n }\n")},cc=function(){var e=parseInt(document.body.getAttribute(oc)||"0",10);return isFinite(e)?e:0},dc=function(t){var r=t.noRelative,i=t.noImportant,n=t.gapMode,s=void 0===n?"margin":n;e.useEffect(function(){return document.body.setAttribute(oc,(cc()+1).toString()),function(){var e=cc()-1;e<=0?document.body.removeAttribute(oc):document.body.setAttribute(oc,e.toString())}},[]);var a=e.useMemo(function(){return sc(s)},[s]);return e.createElement(ac,{styles:lc(a,!r,s,i?"":"!important")})},uc=!1;if("undefined"!=typeof window)try{var hc=Object.defineProperty({},"passive",{get:function(){return uc=!0,!0}});window.addEventListener("test",hc,hc),window.removeEventListener("test",hc,hc)}catch(e){uc=!1}var fc=!!uc&&{passive:!1},pc=function(e,t){if(!(e instanceof Element))return!1;var r=window.getComputedStyle(e);return"hidden"!==r[t]&&!(r.overflowY===r.overflowX&&!function(e){return"TEXTAREA"===e.tagName}(e)&&"visible"===r[t])},mc=function(e,t){var r=t.ownerDocument,i=t;do{if("undefined"!=typeof ShadowRoot&&i instanceof ShadowRoot&&(i=i.host),gc(e,i)){var n=vc(e,i);if(n[1]>n[2])return!0}i=i.parentNode}while(i&&i!==r.body);return!1},gc=function(e,t){return"v"===e?function(e){return pc(e,"overflowY")}(t):function(e){return pc(e,"overflowX")}(t)},vc=function(e,t){return"v"===e?[(r=t).scrollTop,r.scrollHeight,r.clientHeight]:function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]}(t);var r},yc=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},bc=function(e){return[e.deltaX,e.deltaY]},Ec=function(e){return e&&"current"in e?e.current:e},wc=function(e){return"\n .block-interactivity-".concat(e," {pointer-events: none;}\n .allow-interactivity-").concat(e," {pointer-events: all;}\n")},Sc=0,Tc=[];function xc(e){for(var t=null;null!==e;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var Ac,kc=(Ac=function(t){var r=e.useRef([]),i=e.useRef([0,0]),n=e.useRef(),s=e.useState(Sc++)[0],a=e.useState(rc)[0],o=e.useRef(t);e.useEffect(function(){o.current=t},[t]),e.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(s));var e=function(e,t,r){if(r||2===arguments.length)for(var i,n=0,s=t.length;n<s;n++)!i&&n in t||(i||(i=Array.prototype.slice.call(t,0,n)),i[n]=t[n]);return e.concat(i||Array.prototype.slice.call(t))}([t.lockRef.current],(t.shards||[]).map(Ec),!0).filter(Boolean);return e.forEach(function(e){return e.classList.add("allow-interactivity-".concat(s))}),function(){document.body.classList.remove("block-interactivity-".concat(s)),e.forEach(function(e){return e.classList.remove("allow-interactivity-".concat(s))})}}},[t.inert,t.lockRef.current,t.shards]);var l=e.useCallback(function(e,t){if("touches"in e&&2===e.touches.length||"wheel"===e.type&&e.ctrlKey)return!o.current.allowPinchZoom;var r,s=yc(e),a=i.current,l="deltaX"in e?e.deltaX:a[0]-s[0],c="deltaY"in e?e.deltaY:a[1]-s[1],d=e.target,u=Math.abs(l)>Math.abs(c)?"h":"v";if("touches"in e&&"h"===u&&"range"===d.type)return!1;var h=mc(u,d);if(!h)return!0;if(h?r=u:(r="v"===u?"h":"v",h=mc(u,d)),!h)return!1;if(!n.current&&"changedTouches"in e&&(l||c)&&(n.current=r),!r)return!0;var f=n.current||r;return function(e,t,r,i,n){var s=function(e,t){return"h"===e&&"rtl"===t?-1:1}(e,window.getComputedStyle(t).direction),a=s*i,o=r.target,l=t.contains(o),c=!1,d=a>0,u=0,h=0;do{if(!o)break;var f=vc(e,o),p=f[0],m=f[1]-f[2]-s*p;(p||m)&&gc(e,o)&&(u+=m,h+=p);var g=o.parentNode;o=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!l&&o!==document.body||l&&(t.contains(o)||t===o));return d&&(Math.abs(u)<1||!n)?c=!0:d||!(Math.abs(h)<1)&&n||(c=!0),c}(f,t,e,"h"===f?l:c,!0)},[]),c=e.useCallback(function(e){var t=e;if(Tc.length&&Tc[Tc.length-1]===a){var i="deltaY"in t?bc(t):yc(t),n=r.current.filter(function(e){return e.name===t.type&&(e.target===t.target||t.target===e.shadowParent)&&function(e,t){return e[0]===t[0]&&e[1]===t[1]}(e.delta,i)})[0];if(n&&n.should)t.cancelable&&t.preventDefault();else if(!n){var s=(o.current.shards||[]).map(Ec).filter(Boolean).filter(function(e){return e.contains(t.target)});(s.length>0?l(t,s[0]):!o.current.noIsolation)&&t.cancelable&&t.preventDefault()}}},[]),d=e.useCallback(function(e,t,i,n){var s={name:e,delta:t,target:i,should:n,shadowParent:xc(i)};r.current.push(s),setTimeout(function(){r.current=r.current.filter(function(e){return e!==s})},1)},[]),u=e.useCallback(function(e){i.current=yc(e),n.current=void 0},[]),h=e.useCallback(function(e){d(e.type,bc(e),e.target,l(e,t.lockRef.current))},[]),f=e.useCallback(function(e){d(e.type,yc(e),e.target,l(e,t.lockRef.current))},[]);e.useEffect(function(){return Tc.push(a),t.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:f}),document.addEventListener("wheel",c,fc),document.addEventListener("touchmove",c,fc),document.addEventListener("touchstart",u,fc),function(){Tc=Tc.filter(function(e){return e!==a}),document.removeEventListener("wheel",c,fc),document.removeEventListener("touchmove",c,fc),document.removeEventListener("touchstart",u,fc)}},[]);var p=t.removeScrollBar,m=t.inert;return e.createElement(e.Fragment,null,m?e.createElement(a,{styles:wc(s)}):null,p?e.createElement(dc,{noRelative:t.noRelative,gapMode:t.gapMode}):null)},Ql.useMedium(Ac),Xl),Ic=e.forwardRef(function(t,r){return e.createElement(Jl,S({},t,{ref:r,sideCar:kc}))});Ic.classNames=Jl.classNames;var Lc=new WeakMap,Rc=new WeakMap,Pc={},Cc=0,Dc=function(e){return e&&(e.host||Dc(e.parentNode))},_c=function(e,t,r,i){var n=function(e,t){return t.map(function(t){if(e.contains(t))return t;var r=Dc(t);return r&&e.contains(r)?r:(console.error("aria-hidden",t,"in not contained inside",e,". Doing nothing"),null)}).filter(function(e){return Boolean(e)})}(t,Array.isArray(e)?e:[e]);Pc[r]||(Pc[r]=new WeakMap);var s=Pc[r],a=[],o=new Set,l=new Set(n),c=function(e){e&&!o.has(e)&&(o.add(e),c(e.parentNode))};n.forEach(c);var d=function(e){e&&!l.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(o.has(e))d(e);else try{var t=e.getAttribute(i),n=null!==t&&"false"!==t,l=(Lc.get(e)||0)+1,c=(s.get(e)||0)+1;Lc.set(e,l),s.set(e,c),a.push(e),1===l&&n&&Rc.set(e,!0),1===c&&e.setAttribute(r,"true"),n||e.setAttribute(i,"true")}catch(t){console.error("aria-hidden: cannot operate on ",e,t)}})};return d(t),o.clear(),Cc++,function(){a.forEach(function(e){var t=Lc.get(e)-1,n=s.get(e)-1;Lc.set(e,t),s.set(e,n),t||(Rc.has(e)||e.removeAttribute(i),Rc.delete(e)),n||e.removeAttribute(r)}),--Cc||(Lc=new WeakMap,Lc=new WeakMap,Rc=new WeakMap,Pc={})}},Oc=function(e,t,r){void 0===r&&(r="data-aria-hidden");var i=Array.from(Array.isArray(e)?e:[e]),n=function(e){return"undefined"==typeof document?null:(Array.isArray(e)?e[0]:e).ownerDocument.body}(e);return n?(i.push.apply(i,Array.from(n.querySelectorAll("[aria-live], script"))),_c(i,n,r,"aria-hidden")):function(){return null}},Mc="Dialog",[Nc,Fc]=function(t,r=[]){let i=[];const n=()=>{const r=i.map(t=>e.createContext(t));return function(i){const n=i?.[t]||r;return e.useMemo(()=>({[`__scope${t}`]:{...i,[t]:n}}),[i,n])}};return n.scopeName=t,[function(r,n){const s=e.createContext(n),a=i.length;i=[...i,n];const o=r=>{const{scope:i,children:n,...o}=r,l=i?.[t]?.[a]||s,c=e.useMemo(()=>o,Object.values(o));return b(l.Provider,{value:c,children:n})};return o.displayName=r+"Provider",[o,function(i,o){const l=o?.[t]?.[a]||s,c=e.useContext(l);if(c)return c;if(void 0!==n)return n;throw new Error(`\`${i}\` must be used within \`${r}\``)}]},al(n,...r)]}(Mc),[$c,Bc]=Nc(Mc),Uc=t=>{const{__scopeDialog:r,children:i,open:n,defaultOpen:s,onOpenChange:a,modal:o=!0}=t,l=e.useRef(null),c=e.useRef(null),[d,u]=hl({prop:n,defaultProp:s??!1,onChange:a,caller:Mc});return b($c,{scope:r,triggerRef:l,contentRef:c,contentId:dl(),titleId:dl(),descriptionId:dl(),open:d,onOpenChange:u,onOpenToggle:e.useCallback(()=>u(e=>!e),[u]),modal:o,children:i})};Uc.displayName=Mc;var zc="DialogTrigger";e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=Bc(zc,r),s=sl(t,n.triggerRef);return b(yl.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":od(n.open),...i,ref:s,onClick:rl(e.onClick,n.onOpenToggle)})}).displayName=zc;var Gc="DialogPortal",[jc,Hc]=Nc(Gc,{forceMount:void 0}),Vc=t=>{const{__scopeDialog:r,forceMount:i,children:n,container:s}=t,a=Bc(Gc,r);return b(jc,{scope:r,forceMount:i,children:e.Children.map(n,e=>b(Bl,{present:i||a.open,children:b($l,{asChild:!0,container:s,children:e})}))})};Vc.displayName=Gc;var Wc="DialogOverlay",Yc=e.forwardRef((e,t)=>{const r=Hc(Wc,e.__scopeDialog),{forceMount:i=r.forceMount,...n}=e,s=Bc(Wc,e.__scopeDialog);return s.modal?b(Bl,{present:i||s.open,children:b(qc,{...n,ref:t})}):null});Yc.displayName=Wc;var Kc=pl("DialogOverlay.RemoveScroll"),qc=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=Bc(Wc,r);return b(Ic,{as:Kc,allowPinchZoom:!0,shards:[n.contentRef],children:b(yl.div,{"data-state":od(n.open),...i,ref:t,style:{pointerEvents:"auto",...i.style}})})}),Xc="DialogContent",Qc=e.forwardRef((e,t)=>{const r=Hc(Xc,e.__scopeDialog),{forceMount:i=r.forceMount,...n}=e,s=Bc(Xc,e.__scopeDialog);return b(Bl,{present:i||s.open,children:s.modal?b(Zc,{...n,ref:t}):b(Jc,{...n,ref:t})})});Qc.displayName=Xc;var Zc=e.forwardRef((t,r)=>{const i=Bc(Xc,t.__scopeDialog),n=e.useRef(null),s=sl(r,i.contentRef,n);return e.useEffect(()=>{const e=n.current;if(e)return Oc(e)},[]),b(ed,{...t,ref:s,trapFocus:i.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:rl(t.onCloseAutoFocus,e=>{e.preventDefault(),i.triggerRef.current?.focus()}),onPointerDownOutside:rl(t.onPointerDownOutside,e=>{const t=e.detail.originalEvent,r=0===t.button&&!0===t.ctrlKey;(2===t.button||r)&&e.preventDefault()}),onFocusOutside:rl(t.onFocusOutside,e=>e.preventDefault())})}),Jc=e.forwardRef((t,r)=>{const i=Bc(Xc,t.__scopeDialog),n=e.useRef(!1),s=e.useRef(!1);return b(ed,{...t,ref:r,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:e=>{t.onCloseAutoFocus?.(e),e.defaultPrevented||(n.current||i.triggerRef.current?.focus(),e.preventDefault()),n.current=!1,s.current=!1},onInteractOutside:e=>{t.onInteractOutside?.(e),e.defaultPrevented||(n.current=!0,"pointerdown"===e.detail.originalEvent.type&&(s.current=!0));const r=e.target,a=i.triggerRef.current?.contains(r);a&&e.preventDefault(),"focusin"===e.detail.originalEvent.type&&s.current&&e.preventDefault()}})}),ed=e.forwardRef((t,r)=>{const{__scopeDialog:i,trapFocus:n,onOpenAutoFocus:s,onCloseAutoFocus:a,...o}=t,l=Bc(Xc,i),c=e.useRef(null),d=sl(r,c);return e.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Gl()),document.body.insertAdjacentElement("beforeend",e[1]??Gl()),zl++,()=>{1===zl&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),zl--}},[]),w(E,{children:[b(Cl,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:s,onUnmountAutoFocus:a,children:b(Al,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":od(l.open),...o,ref:d,onDismiss:()=>l.onOpenChange(!1)})}),w(E,{children:[b(ud,{titleId:l.titleId}),b(hd,{contentRef:c,descriptionId:l.descriptionId})]})]})}),td="DialogTitle",rd=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=Bc(td,r);return b(yl.h2,{id:n.titleId,...i,ref:t})});rd.displayName=td;var id="DialogDescription",nd=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=Bc(id,r);return b(yl.p,{id:n.descriptionId,...i,ref:t})});nd.displayName=id;var sd="DialogClose",ad=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=Bc(sd,r);return b(yl.button,{type:"button",...i,ref:t,onClick:rl(e.onClick,()=>n.onOpenChange(!1))})});function od(e){return e?"open":"closed"}ad.displayName=sd;var ld="DialogTitleWarning",[cd,dd]=function(t,r){const i=e.createContext(r),n=t=>{const{children:r,...n}=t,s=e.useMemo(()=>n,Object.values(n));return b(i.Provider,{value:s,children:r})};return n.displayName=t+"Provider",[n,function(n){const s=e.useContext(i);if(s)return s;if(void 0!==r)return r;throw new Error(`\`${n}\` must be used within \`${t}\``)}]}(ld,{contentName:Xc,titleName:td,docsSlug:"dialog"}),ud=({titleId:t})=>{const r=dd(ld),i=`\`${r.contentName}\` requires a \`${r.titleName}\` for the component to be accessible for screen reader users.\n\nIf you want to hide the \`${r.titleName}\`, you can wrap it with our VisuallyHidden component.\n\nFor more information, see https://radix-ui.com/primitives/docs/components/${r.docsSlug}`;return e.useEffect(()=>{if(t){document.getElementById(t)||console.error(i)}},[i,t]),null},hd=({contentRef:t,descriptionId:r})=>{const i=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${dd("DialogDescriptionWarning").contentName}}.`;return e.useEffect(()=>{const e=t.current?.getAttribute("aria-describedby");if(r&&e){document.getElementById(r)||console.warn(i)}},[i,t,r]),null},fd=Uc,pd=Vc,md=Yc,gd=Qc,vd=rd,yd=ad;function bd(t){return e.createElement(fd,Object.assign({"data-slot":"dialog"},t))}function Ed(t){var r=T(t,[]);return e.createElement(pd,Object.assign({"data-slot":"dialog-portal"},r))}function wd(t){var{className:r}=t,i=T(t,["className"]);return e.createElement(md,Object.assign({"data-slot":"dialog-overlay",className:St("fixed inset-0 z-50 bg-black/50",r)},i))}function Sd(t){var{className:r,children:i,showCloseButton:n=!0,container:s}=t,a=T(t,["className","children","showCloseButton","container"]);return e.createElement(Ed,{"data-slot":"dialog-portal",container:s},e.createElement(wd,null),e.createElement(gd,Object.assign({"data-slot":"dialog-content",style:{left:"50%",top:"50%",transform:"translate(-50%, -50%)",outline:"none"},className:St("fixed","z-50 grid w-full max-w-lg sm:mx-0 gap-4 p-6",r)},a),i,n&&e.createElement(yd,{"data-slot":"dialog-close",style:{right:"calc(var(--spacing) * 4)",top:"calc(var(--spacing) * 4)",outline:"none"},className:St("absolute right-4 top-4 rounded opacity-70 transition-opacity","hover:opacity-100 focus:outline-none","focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:ring-offset-background","disabled:pointer-events-none"),"aria-label":"Close"},e.createElement(gi,{className:"h-4 w-4 pointer-events-none shrink-0",style:{height:"calc(var(--spacing) * 4)",width:"calc(var(--spacing) * 4)"}}))))}function Td(t){var{className:r}=t,i=T(t,["className"]);return e.createElement("div",Object.assign({"data-slot":"dialog-header",className:St("flex flex-col gap-2 text-left",r)},i))}function xd(t){var{className:r}=t,i=T(t,["className"]);return e.createElement(vd,Object.assign({"data-slot":"dialog-title",className:St("text-lg leading-none font-semibold",r)},i))}function Ad({title:e,children:r,contentClassName:i,hideCloseButton:n=!1,portalContainer:s,description:a,autoFocusOnOpen:o=!0}){const{open:l,setOpen:c}=Oo();return t.createElement(bd,{open:l,onOpenChange:c},t.createElement(Sd,{container:s,className:i,showCloseButton:!n,onOpenAutoFocus:o?void 0:e=>{var t;e.preventDefault(),null===(t=e.currentTarget)||void 0===t||t.focus()}},e&&t.createElement(Td,null,t.createElement(xd,{style:{color:"#494949"}},e||""),t.createElement(nd,{style:{color:"#5e5e5e",fontSize:"12.5px"}},a||"")),r))}const kd=({widgetPlayerOption:e,setCollectionUuid:a,portalContainer:o})=>{const{PLAYER_BASE_URL:l}=gt(),{player:c}=e,[d,u]=s(null),{collection:h}=Go(),{isPreview:f}=ar(),{onSlideChange:p,onCollectionClose:m}=jo(d,u),g=r(null),v=r(new Set),y=n(e=>{f||h&&(v.current.has(e)||(v.current.add(e),Ut({contentId:e,uuid:Lt(),type:wt.SHORTS,userId:h.userId,isFirstPlay:!Rt(e)}).catch(e=>console.error("Error joining shorts PV:",e))))},[f,h]);i(()=>{if(f)return;if(!h)return;if(g.current===h.colId)return;g.current=h.colId;const e=Lt();a(e),Ut({contentId:h.colId,uuid:e,type:wt.COLLECTION,userId:h.userId,isFirstPlay:!Pt(h.colId)}).catch(e=>console.error("Error joining collection PV:",e))},[f,null==h?void 0:h.colId]);const{setOpen:b,open:E}=Oo();i(()=>{E||(d&&(m(),u(null)),w&&S(null))},[E]);const[w,S]=s();return t.createElement(t.Fragment,null,h&&t.createElement(Jo,Object.assign({collection:h},e,{onThumbnailClick:e=>x(void 0,void 0,void 0,function*(){if(c===$e.POPUP){const t=Lt();if(u(Object.assign(Object.assign({},h.contents.find(t=>t.shortsId===e)),{uuid:t})),b(!0),f)return;try{yield Ut({contentId:e,uuid:t,type:wt.SHORTS,userId:h.userId,isFirstPlay:!Pt(e)})}catch(e){console.error("Error joining shorts PV:",e)}}else{const t=(e=>{switch(e){case $e.HORIZONTAL:return Ue.HORIZONTAL;case $e.VERTICAL:return Ue.VERTICAL;case $e.GRID:return Ue.PRODUCTS;case $e.TABLET:return Ue.TABLET;default:return Ue.PLATFORM}})(c),r=null==h?void 0:h.contents.findIndex(t=>t.shortsId===e);let i="";r&&(i=(null==h?void 0:h.contents[r-1].shortsId)||"");const n=new URLSearchParams(Object.assign(Object.assign({},i&&{nextKey:i}),{layout:String(t)}));open(`${l}/collection/${h.colId}?${n.toString()}`)}}),onPreviewPlay:y,setSelectedProducts:S})),w&&t.createElement(Ad,{portalContainer:o,title:"상품 목록",contentClassName:"bg-white rounded p-4 product-dialog-container",description:"상품 정보를 확인해 보세요"},t.createElement(vo,{products:w.productsInfo,contentId:w.shortsId})),h&&d&&t.createElement(Ad,{portalContainer:o,hideCloseButton:!0,contentClassName:"w-full max-w-none p-0 mx-0"},t.createElement(Yo,{collection:h,initialShortsId:d.shortsId,onClosePlayer:()=>{b(!1)},onSlideChange:p})))};const Id=e=>{const{collectionId:r,isPreview:n,priceText:s,memberOnly:a,container:o}=e,{setIsPreview:l,setPriceText:c,setMemberOnly:d,setIsMemberLoggedIn:u}=ar(),{setCollection:h,setNextKey:f,collection:p}=Go();i(()=>{s&&c(s);const e=Boolean(n);e&&l(e),a&&(d(!0),u(Boolean(window.MEMBER_UID)))},[]),i(()=>{x(void 0,void 0,void 0,function*(){var e;const t=yield Vt({collectionId:r,size:10});if(!t)return;const{contents:i,count:n}=t;(null==i?void 0:i.length)&&f(null===(e=i.at(-1))||void 0===e?void 0:e.shortsId),h(Object.assign(Object.assign({},t),{count:n}))})},[r]);const m=function(e){var t,r,i,n,s,a,o,l,c,d,u,h;const f=null!==(t=e.iconForm)&&void 0!==t?t:Me.INSTA,p={collectionId:e.collectionId,iconForm:f,iconShape:null!==(r=e.iconShape)&&void 0!==r?r:Ne.MANY,iconSize:null!==(i=e.iconSize)&&void 0!==i?i:120,borderLine:null!==(n=e.borderLine)&&void 0!==n?n:Fe.DAY,exposeTitle:null===(s=e.exposeTitle)||void 0===s||s,player:null!==(a=e.player)&&void 0!==a?a:$e.POPUP,rounded:null===(o=e.rounded)||void 0===o||o,titlePosition:null!==(l=e.titlePosition)&&void 0!==l?l:Be.BOTTOM,exposeProductBanner:null!==(c=e.exposeProductBanner)&&void 0!==c&&c,exposeProductBadge:null!==(d=e.exposeProductBadge)&&void 0!==d&&d,priceText:e.priceText||"할인가",hoverPlay:null!==(u=e.hoverPlay)&&void 0!==u&&u,thumbnailAutoPlay:null!==(h=e.thumbnailAutoPlay)&&void 0!==h&&h};return f===Me.YOUTUBE?Object.assign(Object.assign({},p),{iconForm:Me.YOUTUBE,iconRatio:e.iconRatio||"9/16"}):Object.assign(Object.assign({},p),{iconForm:Me.INSTA})}(e),{containerRef:g}=function({collectionId:e,iconSize:r}){const{collection:i,setCollection:n,nextKey:s,setNextKey:a,isFetching:o,setIsFetching:l}=Go(),c=t.useRef(null),[d,u]=t.useState(0);return t.useEffect(()=>{if(!c.current)return;const e=new ResizeObserver(e=>{var t,r,i;const n=null!==(i=null===(r=null===(t=e[0])||void 0===t?void 0:t.contentRect)||void 0===r?void 0:r.width)&&void 0!==i?i:0;u(n)});return e.observe(c.current),()=>e.disconnect()},[]),t.useEffect(()=>{var e;if(!i||!i.contents)return;const t=Math.max(1,r+12),c=Math.ceil((d||0)/t)+4,u=null!==(e=i.count)&&void 0!==e?e:Number.MAX_SAFE_INTEGER,h=Math.min(u,c);if(i.contents.length>=h||o)return;let f=!1;return(()=>{x(this,void 0,void 0,function*(){var e,t,r,o,c;try{l(!0);let d=i,u=s||(null===(e=d.contents.at(-1))||void 0===e?void 0:e.shortsId)||void 0;const p=new Set(d.contents.map(e=>e.shortsId));for(;!f&&d.contents.length<h;){const e=Math.max(6,h-d.contents.length),i=yield Vt({collectionId:d.colId,nextKey:u,size:e});if(!i||!(null===(t=i.contents)||void 0===t?void 0:t.length))break;u=null!==(o=null===(r=i.contents.at(-1))||void 0===r?void 0:r.shortsId)&&void 0!==o?o:u;const s=i.contents.filter(e=>!p.has(e.shortsId));if(!s.length)break;if(s.forEach(e=>p.add(e.shortsId)),d=Object.assign(Object.assign({},d),{contents:[...d.contents,...s]}),n(d),a(u||""),d.contents.length>=(null!==(c=d.count)&&void 0!==c?c:Number.MAX_SAFE_INTEGER))break}}finally{l(!1)}})})(),()=>{f=!0}},[null==i?void 0:i.colId,null==i?void 0:i.count,null==i?void 0:i.contents.length,d,r,o,s,n,l,a]),{containerRef:c}}({collectionId:r,iconSize:m.iconSize});return t.createElement(qr.div,null,t.createElement(_o,null),t.createElement("div",{ref:g},t.createElement(kd,{widgetPlayerOption:m,setCollectionUuid:e=>{h(Object.assign(Object.assign({},p),{uuid:e}))},portalContainer:o})))},Ld=e=>{const{container:r}=Mo();return r?t.createElement(zo,null,t.createElement(Id,Object.assign({},e,{container:r}))):null},Rd=({products:e,stack:r})=>r&&e.length>1?t.createElement("span",{className:"sc-stack","aria-hidden":!0},e.slice(0,3).map(e=>t.createElement("img",{key:e.productId,src:Dt(e.thumbPath),alt:""}))):t.createElement("img",{className:"sc-thumb",src:Dt(e[0].thumbPath),alt:e[0].productName}),Pd=({name:e,count:r})=>{const i=t.useRef(null),[n,s]=t.useState(e);return t.useLayoutEffect(()=>{const t=i.current,n=null==t?void 0:t.parentElement;if(!t||!n)return;const a=()=>{const i=t.clientWidth;if(i<=0)return;const a=document.createElement("span");a.className="sc-name sc-name--measure",a.style.width=`${i}px`;const o=document.createElement("span");o.className="sc-product-name";const l=document.createElement("span");l.className="sc-count",l.textContent=`외 ${r-1}개`,a.append(o,l),n.appendChild(a);const c=Number.parseFloat(getComputedStyle(a).lineHeight),d=e=>(o.textContent=e,a.scrollHeight<=2*c+.5);let u=e;if(!d(e)){const t=Array.from(e);let r=0,i=t.length;for(;r<i;){const e=Math.ceil((r+i)/2);d(`${t.slice(0,e).join("")}…`)?r=e:i=e-1}u=`${t.slice(0,r).join("")}…`}a.remove(),s(e=>e===u?e:u)};if(a(),"undefined"==typeof ResizeObserver)return;const o=new ResizeObserver(a);return o.observe(t),()=>o.disconnect()},[r,e]),t.createElement("span",{ref:i,className:"sc-name",title:e,"aria-label":`${e} 외 ${r-1}개`},t.createElement("span",{className:"sc-product-name"},n),t.createElement("span",{className:"sc-count"},"외 ",r-1,"개"))},Cd=({rep:e,count:r,showPrice:i,isGlass:n})=>t.createElement("span",{className:"sc-body"},n&&r>1?t.createElement(Pd,{name:e.productName,count:r}):t.createElement("span",{className:"sc-name"},e.productName,r>1&&t.createElement("span",{className:"sc-count"}," 외 ",r-1,"개")),i?t.createElement("span",{className:"sc-price"},e.discount>0&&t.createElement("span",{className:"off"},e.discount,"%"),t.createElement("span",{className:"amt"},Tt(e.sellingPrice,e.currency))):t.createElement(t.Fragment,null)),Dd=({products:e,contentId:r,variant:i,showPrice:n,isPreview:s=!1,onOpenList:a})=>{var o;const l=e[0],c=e.length>1,d=t.createElement(t.Fragment,null,t.createElement(Rd,{products:e,stack:"clean"===i}),t.createElement(Cd,{rep:l,count:e.length,showPrice:n,isGlass:"glass"===i})),u="glass"===i?"sc-glass-card":"sc-info sc-info--clean",h=c?t.createElement("div",{className:u,role:"button",tabIndex:0,onClick:a,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),a())}},d):t.createElement("a",{className:`${u} apphref`,href:null!==(o=l.linkPath)&&void 0!==o?o:void 0,target:"_blank",rel:"noopener noreferrer",onClick:()=>{s||Gt({contentProductId:l.eventProductId,contentId:r,productId:l.productId})}},d);return h},_d=e=>{e.forEach(e=>{const t=Math.max(0,Math.floor((Date.now()-e.startedAt)/1e3));zt({contentId:e.contentId,uuid:e.uuid,type:wt.SHORTS,userId:e.userId,playtime:t,isFinished:e.duration>0&&t>=e.duration})}),e.clear()},Od=({portalContainer:e,aspectRatio:n,productPosition:a="below",showPrice:o=!1,showTitle:l,rounded:c=!0,isPreview:d=!1})=>{var u;const{collection:h}=Go(),[f,p]=s(),{open:m,setOpen:g}=Oo(),v=r(new Map);i(()=>{_d(v.current)},[null==h?void 0:h.colId]),i(()=>{d&&_d(v.current)},[d]),i(()=>()=>_d(v.current),[]),i(()=>{!m&&f&&p(null)},[m,f]);const y=(e,t)=>{p({productsInfo:e,shortsId:t}),g(!0)},b=null!==(u=go().width)&&void 0!==u?u:0,E=r(null),[w,S]=s(0),T=b<480?2:b<768?3:b<1024?4:5,x="overlay"===a,A=null!=l?l:x,k=Math.max(1,Math.floor((w+16)/236)),I=x?Math.min(T,k):T;return i(()=>{const e=E.current;if(!e)return;const t=()=>S(e.clientWidth);t();const r=new ResizeObserver(t);return r.observe(e),()=>r.disconnect()},[]),t.createElement(t.Fragment,null,t.createElement("div",{ref:E,className:"grid gap-4",style:{gridTemplateColumns:`repeat(${I}, minmax(0, 1fr))`}},null==h?void 0:h.contents.map(e=>{var r;const i=(null===(r=e.productsInfo)||void 0===r?void 0:r.length)>0;return t.createElement("div",{key:e.shortsId},t.createElement("div",{className:"overflow-hidden relative bg-black",style:{borderRadius:c?"15px":0,aspectRatio:null!=n?n:"9/16",boxShadow:"0 1px 2px rgba(0,0,0,0.06), 0 8px 22px rgba(0,0,0,0.08)"}},t.createElement("video",{loop:!0,className:"w-full h-full object-cover",muted:!0,autoPlay:!0,playsInline:!0,src:xt(e.media.objectId),poster:Dt(e.thumbPath),onPlay:()=>{var t;return((e,t,r)=>{if(d||v.current.has(e))return;const i={contentId:e,uuid:Lt(),userId:t,startedAt:Date.now(),duration:At(r)};v.current.set(e,i),Ut({contentId:e,uuid:i.uuid,type:wt.SHORTS,userId:t,isFirstPlay:!Pt(e)})})(e.shortsId,null!==(t=e.userId)&&void 0!==t?t:h.userId,e.media.duration)}}),!x&&A&&e.title&&t.createElement("div",{className:"sc-media-title-overlay"},t.createElement("p",{className:"sc-media-title"},e.title)),x&&(A||i)&&t.createElement("div",{className:"sc-overlay"},A&&e.title&&t.createElement("p",{className:"sc-title"},e.title),i&&t.createElement(Dd,{variant:"glass",products:e.productsInfo,contentId:e.shortsId,showPrice:o,isPreview:d,onOpenList:()=>y(e.productsInfo,e.shortsId)}))),!x&&i&&t.createElement(Dd,{variant:"clean",products:e.productsInfo,contentId:e.shortsId,showPrice:o,isPreview:d,onOpenList:()=>y(e.productsInfo,e.shortsId)}))})),f&&t.createElement(Ad,{portalContainer:e,title:"상품 목록",contentClassName:"p-4 product-dialog-container product-dialog--list",description:"연결된 전체 상품 정보를 확인해 보세요",autoFocusOnOpen:!1},t.createElement("div",{className:"product-dialog__scroll"},t.createElement(vo,{products:f.productsInfo,contentId:f.shortsId,showPrice:o,singleColumn:!0,sheet:!0,isPreview:d}))))},Md=e=>{e.forEach(e=>{const t=Math.max(0,Math.floor((Date.now()-e.startedAt)/1e3));zt({contentId:e.contentId,uuid:e.uuid,type:wt.SHORTS,userId:e.userId,playtime:t,isFinished:e.duration>0&&t>=e.duration})}),e.clear()},Nd=({muted:e,src:n,poster:s,onPlay:a})=>{const o=r(null);return i(()=>{const e=o.current;e&&(e.load(),e.play().catch(()=>{}))},[n]),t.createElement("video",{ref:o,loop:!0,className:"w-full h-full object-cover",muted:e,autoPlay:!0,playsInline:!0,preload:"auto",src:n,poster:s,onPlay:a})},Fd=({aspectRatio:e,rounded:a=!0,variant:o="spotlight",productBannerType:l="list",showTitle:c=!0,showPrice:d=!0,isPreview:u=!1})=>{const{collection:h}=Go(),[f,p]=s(),[m,g]=s(0),[v,y]=s(!0),[b,E]=s(!1),[w,S]=s(!1),[T,x]=s(()=>new Set),[A,k]=s(()=>"undefined"==typeof IntersectionObserver),I=r(null),L=r(null),R=r(new Map),P=r(new Set);i(()=>{Md(R.current),P.current.clear()},[null==h?void 0:h.colId]),i(()=>{u&&Md(R.current)},[u]),i(()=>()=>Md(R.current),[]),i(()=>{R.current.forEach(e=>{const t=null==h?void 0:h.contents.findIndex(t=>t.shortsId===e.contentId);(!A||void 0===t||t<0||!T.has(t))&&((e,t)=>{const r=e.get(t);if(!r)return;const i=Math.max(0,Math.floor((Date.now()-r.startedAt)/1e3));zt({contentId:r.contentId,uuid:r.uuid,type:wt.SHORTS,userId:r.userId,playtime:i,isFinished:r.duration>0&&i>=r.duration}),e.delete(t)})(R.current,e.contentId)})},[null==h?void 0:h.contents,A,T]);const C=n(e=>{var t;const r=new Set,i=null!==(t=e.params.slideVisibleClass)&&void 0!==t?t:"swiper-slide-visible";e.slides.forEach(e=>{if(!e.classList.contains(i))return;const t=e.getAttribute("data-swiper-slide-index");if(null===t)return;const n=Number(t);Number.isInteger(n)&&n>=0&&r.add(n)}),x(e=>{return i=r,(t=e).size===i.size&&[...t].every(e=>i.has(e))?e:r;var t,i})},[]),D=n(e=>{const t="carousel"===o&&!e.isLocked,r=t&&!e.isBeginning,i=t&&!e.isEnd;E(e=>e===r?e:r),S(e=>e===i?e:i)},[o]),_=n(e=>{C(e),D(e)},[D,C]);i(()=>{const e=I.current;if(!e)return;if("undefined"==typeof IntersectionObserver)return void k(!0);const t=new IntersectionObserver(([e])=>k(e.isIntersecting),{root:null,threshold:[0]});return t.observe(e),()=>t.disconnect()},[null==h?void 0:h.colId]),i(()=>{const e=L.current;(null==e?void 0:e.mousewheel)&&(f?e.mousewheel.disable():e.mousewheel.enable())},[f]),i(()=>{p(null)},[l,o]);const O=n((e,t)=>{p({productsInfo:e,shortsId:t})},[]),M=n((e,t,r)=>{if(u||P.current.has(e))return;const i={contentId:e,uuid:Lt(),userId:t,startedAt:Date.now(),duration:At(r)};P.current.add(e),R.current.set(e,i),Ut({contentId:e,uuid:i.uuid,type:wt.SHORTS,userId:t,isFirstPlay:!Pt(e)})},[u]),N=e=>{e.stopPropagation(),y(e=>!e)};if(!h)return null;const[F,$]=(null!=e?e:"9/16").split("/").map(Number),B=`max(320px, min(82vw, calc(80vh * ${F&&$?F/$:9/16})))`,U="spotlight"===o;return t.createElement(t.Fragment,null,t.createElement("div",{ref:I,className:"relative flex items-center w-full"},t.createElement(Pa,{modules:[za,Da],centeredSlides:U,loop:U&&h.contents.length>1,spaceBetween:16,slidesPerView:"auto",watchSlidesProgress:!0,mousewheel:!0,allowTouchMove:!f,className:`collection-slider collection-slider--${o} w-full`,onSwiper:e=>{L.current=e,g(e.realIndex),_(e)},onResize:_,onSlidesUpdated:_,onTransitionEnd:e=>{var t;if(g(e.realIndex),_(e),"spotlight"!==o)return;const r=null===(t=h.contents[e.realIndex])||void 0===t?void 0:t.shortsId;p(e=>e&&e.shortsId!==r?null:e)}},h.contents.map((e,r)=>{var i;const n=r===m,s=A&&T.has(r),g=(null===(i=e.productsInfo)||void 0===i?void 0:i.length)>0,y=c&&Boolean(e.title),b=(null==f?void 0:f.shortsId)===e.shortsId&&(!U||n);return t.createElement(Ca,{key:e.shortsId,virtualIndex:r,className:"collection-slider__slide",style:{width:U?B:void 0}},t.createElement("div",{className:"relative overflow-hidden bg-black",onClick:()=>(e=>{var t,r;e!==m&&"spotlight"===o&&(h&&h.contents.length>1?null===(t=L.current)||void 0===t||t.slideToLoop(e):null===(r=L.current)||void 0===r||r.slideTo(e))})(r),style:{width:"100%",aspectRatio:`${F||9} / ${$||16}`,borderRadius:a?"15px":0,transform:!U||n?"scale(1)":"scale(0.78)",transition:"transform 300ms ease",cursor:n?"default":"pointer"}},s?t.createElement(Nd,{muted:!n||v,src:xt(e.media.objectId),poster:Dt(e.thumbPath),onPlay:()=>{var t;return M(e.shortsId,null!==(t=e.userId)&&void 0!==t?t:h.userId,e.media.duration)}}):t.createElement("img",{className:"w-full h-full object-cover",src:Dt(e.thumbPath),alt:"",loading:"lazy",draggable:!1}),n&&t.createElement("button",{className:"absolute cursor-pointer text-white",style:{top:10,right:10,zIndex:3},onClick:N,"aria-label":v?"음소거 해제":"음소거"},t.createElement("span",{className:"flex h-9 w-9 items-center justify-center rounded-full bg-black/40"},v?t.createElement(mi,{size:18}):t.createElement(pi,{size:18}))),(y||g)&&t.createElement("div",{className:"absolute inset-x-0 bottom-0",style:{zIndex:2,padding:"12px",background:"linear-gradient(to top, rgba(0,0,0,0.65), rgba(0,0,0,0))"}},y&&t.createElement("p",{className:"line-clamp-2 text-white",style:{marginBottom:"12px",fontSize:"14px",fontWeight:600,lineHeight:1.4,textShadow:"0 1px 3px rgba(0,0,0,0.65)"}},e.title),g&&t.createElement("div",null,t.createElement(po,{products:e.productsInfo,contentId:e.shortsId,productBannerType:l,showPrice:d,isPreview:u,onOpenSheet:t=>O(t,e.shortsId)}))),b&&t.createElement(yo,{products:f.productsInfo,contentId:f.shortsId,showPrice:d,isPreview:u,onClose:()=>p(null)})))})),!f&&b&&t.createElement("button",{type:"button",className:"collection-slider__nav collection-slider__nav--prev","aria-label":"이전 슬라이드",onClick:e=>{var t;e.stopPropagation(),null===(t=L.current)||void 0===t||t.slidePrev()}},t.createElement(ii,{size:20,"aria-hidden":!0})),!f&&w&&t.createElement("button",{type:"button",className:"collection-slider__nav collection-slider__nav--next","aria-label":"다음 슬라이드",onClick:e=>{var t;e.stopPropagation(),null===(t=L.current)||void 0===t||t.slideNext()}},t.createElement(ni,{size:20,"aria-hidden":!0}))))},$d=({collectionId:e,aspectRatio:r,container:n,isPreview:s,layout:a,productBannerType:o,rounded:l,productPosition:c,showPrice:d,showTitle:u})=>{const{setCollection:h,setNextKey:f}=Go();return i(()=>{let t,r=!1;return x(void 0,void 0,void 0,function*(){var i,n;const a=yield Vt({collectionId:e,size:-1});if(!a||r)return;const{contents:o,count:l}=a;(null==o?void 0:o.length)&&f(null===(i=o.at(-1))||void 0===i?void 0:i.shortsId),h(Object.assign(Object.assign({},a),{count:l}));const c=null!==(n=a.colId)&&void 0!==n?n:e;s||(t={contentId:c,uuid:Lt(),userId:a.userId,startedAt:Date.now()},Ut({contentId:t.contentId,uuid:t.uuid,type:wt.COLLECTION,userId:t.userId,isFirstPlay:!Pt(t.contentId)}))}),()=>{r=!0,t&&zt({contentId:t.contentId,uuid:t.uuid,type:wt.COLLECTION,userId:t.userId,playtime:Math.max(0,Math.floor((Date.now()-t.startedAt)/1e3))})}},[e,s,h,f]),t.createElement(qr.div,null,t.createElement(_o,null),"spotlight"===a||"carousel"===a?t.createElement(Fd,{portalContainer:n,aspectRatio:r,rounded:l,variant:a,productBannerType:o,showPrice:d,showTitle:u,isPreview:s}):t.createElement(Od,{portalContainer:n,aspectRatio:r,productPosition:c,showPrice:d,showTitle:u,rounded:l,isPreview:s}))},Bd=e=>{const{container:r}=Mo();return r?t.createElement(zo,null,t.createElement($d,Object.assign({},e,{container:r}))):null},Ud=sr(e=>({shortform:null,setShortform:t=>e({shortform:t})})),zd=({shortform:e,setClose:r,compact:n=!1})=>{const[a,o]=t.useState(!0),[l,c]=s(!0),[d,u]=s(!1),h=t.useRef(null),f=()=>{h.current&&(window.clearTimeout(h.current),h.current=null)},p=(e=1500)=>{f(),h.current=window.setTimeout(()=>u(!1),e)};return i(()=>()=>f(),[]),t.createElement("div",{className:"relative w-full h-full",onClick:()=>{u(!0),p(2e3)},onMouseLeave:()=>p(800),onMouseEnter:()=>d&&p(1500)},t.createElement("div",{className:"absolute inset-0 bg-black",style:{zIndex:1,opacity:!n&&d?.4:0,transition:"opacity 300ms ease",pointerEvents:!n&&d?"auto":"none"}}),t.createElement("div",{className:"absolute inset-0",style:{zIndex:2,opacity:!n&&d?1:0,transition:"opacity 300ms ease",pointerEvents:!n&&d?"auto":"none"}},t.createElement("div",{className:"absolute text-white flex gap-2",style:{zIndex:3,top:8,right:8}},t.createElement("button",{type:"button",className:"cursor-pointer",onClick:e=>{e.stopPropagation(),o(e=>!e)},"aria-label":a?"음소거 해제":"음소거"},t.createElement("span",{className:"glass-panel flex items-center justify-center rounded-full"},a?t.createElement(mi,null):t.createElement(pi,null))),t.createElement("button",{type:"button",className:"cursor-pointer",onClick:e=>{null==e||e.stopPropagation(),r()},"aria-label":"닫기"},t.createElement("span",{className:"glass-panel flex items-center justify-center rounded-full"},t.createElement(gi,null)))),t.createElement("div",{className:"absolute inset-0 flex items-center justify-center",style:{pointerEvents:"none"}},t.createElement("button",{type:"button",onClick:e=>{null==e||e.stopPropagation(),c(e=>!e)},"aria-label":l?"일시정지":"재생",className:"cursor-pointer text-white",style:{pointerEvents:!n&&d?"auto":"none"}},t.createElement("span",{className:"glass-panel flex items-center justify-center rounded-full"},l?t.createElement(ui,null):t.createElement(hi,null))))),t.createElement(or,{shortform:e,mute:a,play:l,trackStatistics:!1}))},Gd={small:{width:160,height:284},large:{width:240,height:427}},jd=2147483647,Hd=({size:e,pcInitialWidth:t,mobileInitialWidth:r})=>{const i="small"===e?r:t;return"number"==typeof i&&Number.isFinite(i)&&i>0?{width:i,height:Math.round(16*i/9)}:Gd[e]},Vd=({shortsId:e,type:r,isPreview:i,productBannerType:n="list",like:a=!0,share:o=!0,horizontalPosition:l="right",verticalPosition:c="bottom",horizontalOffset:d=50,verticalOffset:u=50,initialSize:h,pcInitialWidth:f,mobileInitialWidth:p,cornerStyle:m="square"})=>{const{shortform:g}=Ud(),[v,y]=s(!1),[b,E]=s(()=>window.innerWidth<=430?"small":null!=h?h:"large"),{playtime:w}=Ft(!v),{leave:S}=Jt({shortform:g,playtime:w,enabled:!v&&!i}),T=()=>{g&&(y(!0),S())},x=Hd({size:b,pcInitialWidth:f,mobileInitialWidth:p}),A="large"===b&&"shopping"===r&&Boolean(null==g?void 0:g.productsInfo.length);return g&&!v&&t.createElement("div",{className:"floating-player "+(A?"floating-player--expanded-shopping":""),style:{position:"fixed",width:x.width,height:x.height,left:"left"===l?d:void 0,right:"right"===l?d:void 0,top:"top"===c?u:void 0,bottom:"bottom"===c?u:void 0,zIndex:jd,borderRadius:"rounded"===m?16:0,overflow:"hidden"}},t.createElement("div",{className:"relative h-full w-full overflow-hidden bg-black"},"shopping"===r&&g.productsInfo.length>0?t.createElement(Eo,{shortForm:g,handleClose:T,trackStatistics:!1,isPreview:i,hideOverlay:"small"===b,hideProductCarousel:"small"===b,productBannerHeight:60,productBannerType:n,like:a,share:o}):t.createElement(zd,{shortform:g,setClose:T,compact:"small"===b}),t.createElement("button",{type:"button",onClick:e=>{e.stopPropagation(),E(e=>"small"===e?"large":"small")},className:"small"===b?"absolute inset-0 flex cursor-pointer items-start justify-end p-3 text-white":"absolute left-3 top-3 cursor-pointer text-white",style:{zIndex:10},"aria-label":"small"===b?"플레이어 펼치기":"플레이어 접기"},t.createElement("span",{className:"glass-panel flex items-center justify-center rounded-full"},"small"===b?t.createElement(ci,null):t.createElement(di,null)))))},Wd=({shortsId:e,type:r,isPreview:n,productBannerType:s="list",like:a=!0,share:o=!0,horizontalPosition:l,verticalPosition:c,horizontalOffset:d,verticalOffset:u,initialSize:h,pcInitialWidth:f,mobileInitialWidth:p,cornerStyle:m})=>{const{setShortform:g,shortform:v}=Ud();return i(()=>{if(!e)return;let t=!1;return e&&x(void 0,void 0,void 0,function*(){const r=yield Wt(e,n);r&&!t&&g(Object.assign(Object.assign({},r),{uuid:Lt()}))}),()=>{t=!0}},[e,n,g]),v?t.createElement(qr.div,{style:{position:"fixed",inset:0,pointerEvents:"none",zIndex:jd}},t.createElement(_o,null),t.createElement("div",{style:{pointerEvents:"auto"}},t.createElement(Vd,{shortsId:e,type:r,isPreview:n,productBannerType:s,like:a,share:o,horizontalPosition:l,verticalPosition:c,horizontalOffset:d,verticalOffset:u,initialSize:h,pcInitialWidth:f,mobileInitialWidth:p,cornerStyle:m}))):null},Yd=({navigation:e,like:i,share:n,isPreview:a,productBannerType:o="list",horizontalPosition:l="right",verticalPosition:c="bottom",horizontalOffset:d=50,verticalOffset:u=50,initialSize:h,pcInitialWidth:f,mobileInitialWidth:p,cornerStyle:m="square"})=>{var g,v;const{collection:y}=Go(),[b,E]=s(!1),[w,S]=s(!1),[T,x]=s(null!==(v=null===(g=null==y?void 0:y.contents)||void 0===g?void 0:g[0])&&void 0!==v?v:null),[A,k]=s(()=>window.innerWidth<=430?"small":null!=h?h:"large"),I=r(null),{onSlideChange:L,onCollectionClose:R}=jo(T,x,a);if(!y||b)return null;const P=()=>{R(),E(!0)},C=Hd({size:A,pcInitialWidth:f,mobileInitialWidth:p}),D="small"===A;return t.createElement("div",{className:"floating-collection-player",style:{position:"fixed",width:C.width,height:C.height,left:"left"===l?d:void 0,right:"right"===l?d:void 0,top:"top"===c?u:void 0,bottom:"bottom"===c?u:void 0,zIndex:jd,borderRadius:"rounded"===m?16:0,overflow:"hidden"}},t.createElement("div",{className:"relative h-full w-full overflow-hidden bg-black"},t.createElement(Pa,{direction:"vertical",slidesPerView:1,loop:y.contents.length>1,mousewheel:!0,modules:[Da,za],ref:I,allowTouchMove:!D,className:"h-full w-full",onSlideChange:e=>{const t=y.contents[e.realIndex];t&&(x(t),L(e.realIndex))}},y.contents.map(e=>t.createElement(Ca,{key:e.shortsId},t.createElement("div",{className:"relative w-full h-full"},(null==T?void 0:T.shortsId)===e.shortsId&&t.createElement("div",{className:"absolute inset-0 z-[10]"},t.createElement(Eo,{shortForm:T,trackStatistics:!1,isPreview:a,productBannerHeight:64,productBannerType:o,handleClose:P,like:i,share:n,hideOverlay:D,hideProductCarousel:D,onProductSheetOpenChange:S})),t.createElement("img",{src:Dt(e.thumbPath),alt:e.title,className:"w-full h-full object-cover"}))))),e&&!D&&!w&&y.contents.length>1&&t.createElement("div",{className:"absolute left-4 top-1/2 -translate-y-1/2 z-[20] flex flex-col gap-2"},t.createElement("button",{type:"button",className:"cursor-pointer text-white",onClick:e=>{var t;e.stopPropagation(),null===(t=I.current)||void 0===t||t.swiper.slidePrev()},"aria-label":"이전 영상"},t.createElement("div",{className:"glass-panel flex h-9 w-9 items-center justify-center rounded-full bg-black/40"},t.createElement(si,{size:20}))),t.createElement("button",{type:"button",className:"cursor-pointer text-white",onClick:e=>{var t;e.stopPropagation(),null===(t=I.current)||void 0===t||t.swiper.slideNext()},"aria-label":"다음 영상"},t.createElement("div",{className:"glass-panel flex h-9 w-9 items-center justify-center rounded-full bg-black/40"},t.createElement(ri,{size:20})))),t.createElement("button",{type:"button",onClick:e=>{e.stopPropagation(),k(e=>"small"===e?"large":"small")},className:D?"absolute inset-0 flex cursor-pointer items-start justify-end p-3 text-white":"absolute left-3 top-3 cursor-pointer text-white",style:{zIndex:30},"aria-label":D?"플레이어 펼치기":"플레이어 접기"},t.createElement("span",{className:"glass-panel flex items-center justify-center rounded-full"},D?t.createElement(ci,null):t.createElement(di,null)))))},Kd=({collectionId:e,isPreview:n,navigation:s=!0,like:a=!0,share:o=!0,productBannerType:l="list",horizontalPosition:c,verticalPosition:d,horizontalOffset:u,verticalOffset:h,initialSize:f,pcInitialWidth:p,mobileInitialWidth:m,cornerStyle:g})=>{var v;const{collection:y,setCollection:b,setNextKey:E}=Go(),{setIsPreview:w}=ar(),S=r(new Set),T=r(new Set);return i(()=>{const e=ar.getState().isPreview;return w(Boolean(n)),()=>{w(e)}},[n,w]),i(()=>{if(!e)return;let t=!1;return x(void 0,void 0,void 0,function*(){var r;const i=yield Vt({collectionId:e,size:10});if(!i||t)return;const{contents:n,count:s}=i;(null==n?void 0:n.length)&&E(null===(r=n.at(-1))||void 0===r?void 0:r.shortsId);const a=null==n?void 0:n[0],o=Lt(),l=a?Lt():void 0;b(Object.assign(Object.assign({},i),{count:s,uuid:o,contents:a?[Object.assign(Object.assign({},a),{uuid:l}),...n.slice(1)]:n}))}),()=>{t=!0}},[e,n,b,E]),i(()=>{if(n||!(null==y?void 0:y.uuid))return;S.current.has(y.uuid)||(S.current.add(y.uuid),Ut({contentId:y.colId,uuid:y.uuid,type:wt.COLLECTION,userId:y.userId,isFirstPlay:!Pt(y.colId)}));const e=y.contents[0];(null==e?void 0:e.uuid)&&!T.current.has(e.uuid)&&(T.current.add(e.uuid),Ut({contentId:e.shortsId,uuid:e.uuid,type:wt.SHORTS,userId:e.userId,isFirstPlay:!Pt(e.shortsId)}))},[y,n]),y&&(null===(v=y.contents)||void 0===v?void 0:v.length)?t.createElement(qr.div,{style:{position:"fixed",inset:0,pointerEvents:"none",zIndex:jd}},t.createElement(_o,null),t.createElement("div",{style:{pointerEvents:"auto"}},t.createElement(Yd,{key:`${y.uuid}:${Boolean(n)}`,navigation:s,like:a,share:o,productBannerType:l,isPreview:Boolean(n),horizontalPosition:c,verticalPosition:d,horizontalOffset:u,verticalOffset:h,initialSize:f,pcInitialWidth:p,mobileInitialWidth:m,cornerStyle:g}))):null},qd=e=>t.createElement(zo,null,t.createElement(Kd,Object.assign({},e))),Xd=t.createContext(null),Qd=({children:e})=>{const r=t.useRef(null);return r.current||(r.current=tr(e=>({liveWidget:null,setLiveWidget:t=>e({liveWidget:t}),nextKey:"",setNextKey:t=>e({nextKey:t}),isFetching:!1,setIsFetching:t=>e({isFetching:t})}))),t.createElement(Xd.Provider,{value:r.current},e)};function Zd(e){const r=t.useContext(Xd);if(!r)throw new Error("Missing LiveWidgetProvider");return ir(r,e)}var Jd;!function(e){e[e.READY=1]="READY",e[e.STREAMING=2]="STREAMING",e[e.PAUSED=3]="PAUSED"}(Jd||(Jd={}));const eu=({opacity:e=.4,className:r})=>{const i=Math.max(0,Math.min(1,e));return t.createElement("div",{"aria-hidden":!0,role:"presentation",className:`absolute inset-0 pointer-events-none ${null!=r?r:""}`,style:{backgroundColor:`rgba(0,0,0,${i})`,borderRadius:"inherit"}})},tu=({content:e})=>{const{PLAYER_BASE_URL:r}=gt();return t.createElement("iframe",{src:`${r}/live/${e.eventId}`,className:"w-full h-full block",style:{border:0,display:"block"},allow:"autoplay; fullscreen; picture-in-picture",allowFullScreen:!0,scrolling:"no",referrerPolicy:"no-referrer-when-downgrade"})},ru=(e,r)=>{const[i,n]=t.useState({}),[s,a]=t.useState({primary:20,secondary:12});return t.useLayoutEffect(()=>{n({})},[e]),t.useEffect(()=>{const t=r.current;if(!t)return;const i=()=>{const r=t.getBoundingClientRect(),i=Math.max(0,Math.floor(r.width)),s=Math.max(0,Math.floor(r.height)),[o,l]=e.includes("/")?e.split("/").map(e=>parseFloat(e)):[1,1],c=l/o;let d,u;i>0&&s>0?(d=i,u=Math.round(d*c),u>s&&(u=s,d=Math.round(u/c)),n({width:d,height:u})):n({});const h="number"==typeof d?d:i,f=Math.max(16,Math.round(.075*h)),p=Math.max(11,Math.round(.042*h));a({primary:f,secondary:p})};if("undefined"!=typeof ResizeObserver){const e=new ResizeObserver(()=>i());return e.observe(t),()=>e.disconnect()}{const e=()=>i();return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)}},[e]),{fontSize:s,boxSize:i}},iu=({content:e,aspectRatio:r="9/16",cursor:i="default",borderRadius:n})=>{var a,o;const{leftTime:l}=(e=>{const{start:t}=e,r=qe().tz("Asia/Seoul").unix(),[i,n]=s(t-r>0?t-r:0);return Nt(()=>{n(i<=0?0:e=>e-1)},1e3),{leftTime:i}})(e),c=null===(o=null===(a=null==e?void 0:e.designInfo)||void 0===a?void 0:a.thumbPath)||void 0===o?void 0:o.preview,d=t.useRef(null),{boxSize:u,fontSize:h}=ru(r,d),{PLAYER_BASE_URL:f}=gt(),p=Math.floor(Date.now()/1e3),m="number"==typeof e.end&&e.end>0&&e.end<p;return t.createElement("div",{className:"w-full h-full flex items-center justify-center",ref:d},t.createElement("div",{className:"relative rounded overflow-hidden",style:{width:u.width?`${u.width}px`:"100%",height:u.height?`${u.height}px`:"100%",borderRadius:`${null!=n?n:10}px`,backgroundRepeat:"no-repeat",backgroundPosition:"center",backgroundSize:"cover",aspectRatio:u.height?void 0:r,backgroundImage:c?`url(${Dt(c)})`:void 0,backgroundColor:c?void 0:"black"}},1===e.openStatus?t.createElement(t.Fragment,null,t.createElement(tu,{content:e}),t.createElement("a",{href:`${f}/live/${e.eventId}`,target:"_blank",rel:"noopener noreferrer","aria-label":`${e.eventName} 바로가기`,style:{position:"absolute",inset:0,zIndex:30,display:"block",textDecoration:"none",cursor:"pointer",background:"transparent"}})):m?t.createElement(t.Fragment,null,t.createElement(eu,null),t.createElement("div",{className:"text-white flex flex-col items-center justify-center absolute inset-0",style:{zIndex:10,gap:"12px",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none",cursor:i,pointerEvents:"none"}},t.createElement("p",{style:{fontSize:`${h.primary}px`,fontWeight:700}},"다시보기"),t.createElement("p",{style:{fontSize:`${h.secondary}px`}},"라이브가 종료되었습니다"))):t.createElement(t.Fragment,null,t.createElement(eu,null),t.createElement("div",{className:"text-white flex flex-col items-center justify-center absolute inset-0",style:{zIndex:10,gap:"20px",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none",cursor:i,pointerEvents:"none"}},t.createElement("p",{style:{fontSize:`${h.primary}px`}},((e,t)=>{if(e>86400)return qe.unix(t).tz("Asia/Seoul").format("M월 D일 A h시 mm분");const r=qe.duration(e,"seconds");return`${r.hours().toString().padStart(2,"0")}:${r.minutes().toString().padStart(2,"0")}:${r.seconds().toString().padStart(2,"0")}`})(l,e.start)),t.createElement("p",{style:{fontSize:`${h.secondary}px`}},"곧 라이브가 시작됩니다!")))))},nu=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},su=Number.isSafeInteger||function(e){return"number"==typeof e&&Math.abs(e)<=au},au=Number.MAX_SAFE_INTEGER||9007199254740991;let ou=function(e){return e.NETWORK_ERROR="networkError",e.MEDIA_ERROR="mediaError",e.KEY_SYSTEM_ERROR="keySystemError",e.MUX_ERROR="muxError",e.OTHER_ERROR="otherError",e}({}),lu=function(e){return e.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",e.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",e.KEY_SYSTEM_NO_SESSION="keySystemNoSession",e.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",e.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",e.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",e.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",e.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",e.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR="keySystemDestroyMediaKeysError",e.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR="keySystemDestroyCloseSessionError",e.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR="keySystemDestroyRemoveSessionError",e.MANIFEST_LOAD_ERROR="manifestLoadError",e.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",e.MANIFEST_PARSING_ERROR="manifestParsingError",e.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",e.LEVEL_EMPTY_ERROR="levelEmptyError",e.LEVEL_LOAD_ERROR="levelLoadError",e.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",e.LEVEL_PARSING_ERROR="levelParsingError",e.LEVEL_SWITCH_ERROR="levelSwitchError",e.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",e.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",e.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",e.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",e.FRAG_LOAD_ERROR="fragLoadError",e.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",e.FRAG_DECRYPT_ERROR="fragDecryptError",e.FRAG_PARSING_ERROR="fragParsingError",e.FRAG_GAP="fragGap",e.REMUX_ALLOC_ERROR="remuxAllocError",e.KEY_LOAD_ERROR="keyLoadError",e.KEY_LOAD_TIMEOUT="keyLoadTimeOut",e.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",e.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",e.BUFFER_APPEND_ERROR="bufferAppendError",e.BUFFER_APPENDING_ERROR="bufferAppendingError",e.BUFFER_STALLED_ERROR="bufferStalledError",e.BUFFER_FULL_ERROR="bufferFullError",e.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",e.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",e.ASSET_LIST_LOAD_ERROR="assetListLoadError",e.ASSET_LIST_LOAD_TIMEOUT="assetListLoadTimeout",e.ASSET_LIST_PARSING_ERROR="assetListParsingError",e.INTERSTITIAL_ASSET_ITEM_ERROR="interstitialAssetItemError",e.INTERNAL_EXCEPTION="internalException",e.INTERNAL_ABORTED="aborted",e.ATTACH_MEDIA_ERROR="attachMediaError",e.UNKNOWN="unknown",e}({}),cu=function(e){return e.MEDIA_ATTACHING="hlsMediaAttaching",e.MEDIA_ATTACHED="hlsMediaAttached",e.MEDIA_DETACHING="hlsMediaDetaching",e.MEDIA_DETACHED="hlsMediaDetached",e.MEDIA_ENDED="hlsMediaEnded",e.STALL_RESOLVED="hlsStallResolved",e.BUFFER_RESET="hlsBufferReset",e.BUFFER_CODECS="hlsBufferCodecs",e.BUFFER_CREATED="hlsBufferCreated",e.BUFFER_APPENDING="hlsBufferAppending",e.BUFFER_APPENDED="hlsBufferAppended",e.BUFFER_EOS="hlsBufferEos",e.BUFFERED_TO_END="hlsBufferedToEnd",e.BUFFER_FLUSHING="hlsBufferFlushing",e.BUFFER_FLUSHED="hlsBufferFlushed",e.MANIFEST_LOADING="hlsManifestLoading",e.MANIFEST_LOADED="hlsManifestLoaded",e.MANIFEST_PARSED="hlsManifestParsed",e.LEVEL_SWITCHING="hlsLevelSwitching",e.LEVEL_SWITCHED="hlsLevelSwitched",e.LEVEL_LOADING="hlsLevelLoading",e.LEVEL_LOADED="hlsLevelLoaded",e.LEVEL_UPDATED="hlsLevelUpdated",e.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",e.LEVELS_UPDATED="hlsLevelsUpdated",e.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",e.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",e.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",e.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",e.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",e.AUDIO_TRACK_UPDATED="hlsAudioTrackUpdated",e.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",e.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",e.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",e.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",e.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",e.SUBTITLE_TRACK_UPDATED="hlsSubtitleTrackUpdated",e.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",e.CUES_PARSED="hlsCuesParsed",e.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",e.INIT_PTS_FOUND="hlsInitPtsFound",e.FRAG_LOADING="hlsFragLoading",e.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",e.FRAG_LOADED="hlsFragLoaded",e.FRAG_DECRYPTED="hlsFragDecrypted",e.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",e.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",e.FRAG_PARSING_METADATA="hlsFragParsingMetadata",e.FRAG_PARSED="hlsFragParsed",e.FRAG_BUFFERED="hlsFragBuffered",e.FRAG_CHANGED="hlsFragChanged",e.FPS_DROP="hlsFpsDrop",e.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",e.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",e.ERROR="hlsError",e.DESTROYING="hlsDestroying",e.KEY_LOADING="hlsKeyLoading",e.KEY_LOADED="hlsKeyLoaded",e.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",e.BACK_BUFFER_REACHED="hlsBackBufferReached",e.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",e.ASSET_LIST_LOADING="hlsAssetListLoading",e.ASSET_LIST_LOADED="hlsAssetListLoaded",e.INTERSTITIALS_UPDATED="hlsInterstitialsUpdated",e.INTERSTITIALS_BUFFERED_TO_BOUNDARY="hlsInterstitialsBufferedToBoundary",e.INTERSTITIAL_ASSET_PLAYER_CREATED="hlsInterstitialAssetPlayerCreated",e.INTERSTITIAL_STARTED="hlsInterstitialStarted",e.INTERSTITIAL_ASSET_STARTED="hlsInterstitialAssetStarted",e.INTERSTITIAL_ASSET_ENDED="hlsInterstitialAssetEnded",e.INTERSTITIAL_ASSET_ERROR="hlsInterstitialAssetError",e.INTERSTITIAL_ENDED="hlsInterstitialEnded",e.INTERSTITIALS_PRIMARY_RESUMED="hlsInterstitialsPrimaryResumed",e.PLAYOUT_LIMIT_REACHED="hlsPlayoutLimitReached",e.EVENT_CUE_ENTER="hlsEventCueEnter",e}({});var du="manifest",uu="level",hu="audioTrack",fu="subtitleTrack",pu="main",mu="audio",gu="subtitle";class vu{constructor(e,t=0,r=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=r}sample(e,t){const r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){const e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}}class yu{constructor(e,t,r,i=100){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=r,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new vu(e),this.fast_=new vu(t),this.defaultTTFB_=i,this.ttfb_=new vu(e)}update(e,t){const{slow_:r,fast_:i,ttfb_:n}=this;r.halfLife!==e&&(this.slow_=new vu(e,r.getEstimate(),r.getTotalWeight())),i.halfLife!==t&&(this.fast_=new vu(t,i.getEstimate(),i.getTotalWeight())),n.halfLife!==e&&(this.ttfb_=new vu(e,n.getEstimate(),n.getTotalWeight()))}sample(e,t){const r=(e=Math.max(e,this.minDelayMs_))/1e3,i=8*t/r;this.fast_.sample(r,i),this.slow_.sample(r,i)}sampleTTFB(e){const t=e/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(r,Math.max(e,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}get defaultEstimate(){return this.defaultEstimate_}destroy(){}}function bu(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Eu(){return Eu=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)({}).hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},Eu.apply(null,arguments)}function wu(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,i)}return r}function Su(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?wu(Object(r),!0).forEach(function(t){bu(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):wu(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}class Tu{constructor(e,t){this.trace=void 0,this.debug=void 0,this.log=void 0,this.warn=void 0,this.info=void 0,this.error=void 0;const r=`[${e}]:`;this.trace=xu,this.debug=t.debug.bind(null,r),this.log=t.log.bind(null,r),this.warn=t.warn.bind(null,r),this.info=t.info.bind(null,r),this.error=t.error.bind(null,r)}}const xu=function(){},Au={trace:xu,debug:xu,log:xu,warn:xu,info:xu,error:xu};function ku(){return Eu({},Au)}function Iu(e,t,r){return t[e]?t[e].bind(t):function(e,t){const r=self.console[e];return r?r.bind(self.console,`${t?"["+t+"] ":""}[${e}] >`):xu}(e,r)}const Lu=ku();const Ru=Lu;function Pu(e=!0){if("undefined"==typeof self)return;return(e||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function Cu(e,t){const r=Object.keys(e),i=Object.keys(t),n=r.length,s=i.length;return!n||!s||n===s&&!r.some(e=>-1===i.indexOf(e))}function Du(e,t=!1){if("undefined"!=typeof TextDecoder){const r=new TextDecoder("utf-8").decode(e);if(t){const e=r.indexOf("\0");return-1!==e?r.substring(0,e):r}return r.replace(/\0/g,"")}const r=e.length;let i,n,s,a="",o=0;for(;o<r;){if(i=e[o++],0===i&&t)return a;if(0!==i&&3!==i)switch(i>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:a+=String.fromCharCode(i);break;case 12:case 13:n=e[o++],a+=String.fromCharCode((31&i)<<6|63&n);break;case 14:n=e[o++],s=e[o++],a+=String.fromCharCode((15&i)<<12|(63&n)<<6|63&s)}}return a}function _u(e){let t="";for(let r=0;r<e.length;r++){let i=e[r].toString(16);i.length<2&&(i="0"+i),t+=i}return t}function Ou(e){return Uint8Array.from(e.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}function Mu(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Nu,Fu={exports:{}};var $u,Bu,Uu,zu,Gu,ju=Nu?Fu.exports:(Nu=1,$u=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,Bu=/^(?=([^\/?#]*))\1([^]*)$/,Uu=/(?:\/|^)\.(?=\/)/g,zu=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,Fu.exports=Gu={buildAbsoluteURL:function(e,t,r){if(r=r||{},e=e.trim(),!(t=t.trim())){if(!r.alwaysNormalize)return e;var i=Gu.parseURL(e);if(!i)throw new Error("Error trying to parse base URL.");return i.path=Gu.normalizePath(i.path),Gu.buildURLFromParts(i)}var n=Gu.parseURL(t);if(!n)throw new Error("Error trying to parse relative URL.");if(n.scheme)return r.alwaysNormalize?(n.path=Gu.normalizePath(n.path),Gu.buildURLFromParts(n)):t;var s=Gu.parseURL(e);if(!s)throw new Error("Error trying to parse base URL.");if(!s.netLoc&&s.path&&"/"!==s.path[0]){var a=Bu.exec(s.path);s.netLoc=a[1],s.path=a[2]}s.netLoc&&!s.path&&(s.path="/");var o={scheme:s.scheme,netLoc:n.netLoc,path:null,params:n.params,query:n.query,fragment:n.fragment};if(!n.netLoc&&(o.netLoc=s.netLoc,"/"!==n.path[0]))if(n.path){var l=s.path,c=l.substring(0,l.lastIndexOf("/")+1)+n.path;o.path=Gu.normalizePath(c)}else o.path=s.path,n.params||(o.params=s.params,n.query||(o.query=s.query));return null===o.path&&(o.path=r.alwaysNormalize?Gu.normalizePath(n.path):n.path),Gu.buildURLFromParts(o)},parseURL:function(e){var t=$u.exec(e);return t?{scheme:t[1]||"",netLoc:t[2]||"",path:t[3]||"",params:t[4]||"",query:t[5]||"",fragment:t[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(Uu,"");e.length!==(e=e.replace(zu,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}});class Hu{constructor(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}}var Vu="audio",Wu="video",Yu="audiovideo";class Ku{constructor(e){this._byteRange=null,this._url=null,this._stats=null,this._streams=null,this.base=void 0,this.relurl=void 0,"string"==typeof e&&(e={url:e}),this.base=e,function(e,t){const r=Zu(e,t);r&&(r.enumerable=!0,Object.defineProperty(e,t,r))}(this,"stats")}setByteRange(e,t){const r=e.split("@",2);let i;i=1===r.length?(null==t?void 0:t.byteRangeEndOffset)||0:parseInt(r[1]),this._byteRange=[i,parseInt(r[0])+i]}get baseurl(){return this.base.url}get byteRange(){return null===this._byteRange?[]:this._byteRange}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get elementaryStreams(){return null===this._streams&&(this._streams={[Vu]:null,[Wu]:null,[Yu]:null}),this._streams}set elementaryStreams(e){this._streams=e}get hasStats(){return null!==this._stats}get hasStreams(){return null!==this._streams}get stats(){return null===this._stats&&(this._stats=new Hu),this._stats}set stats(e){this._stats=e}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=ju.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}clearElementaryStreamInfo(){const{elementaryStreams:e}=this;e[Vu]=null,e[Wu]=null,e[Yu]=null}}function qu(e){return"initSegment"!==e.sn}class Xu extends Ku{constructor(e,t){super(t),this._decryptdata=null,this._programDateTime=null,this._ref=null,this._bitrate=void 0,this.rawProgramDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.playlistOffset=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.urlId=0,this.type=e}get byteLength(){if(this.hasStats){const e=this.stats.total;if(e)return e}if(this.byteRange.length){const e=this.byteRange[0],t=this.byteRange[1];if(nu(e)&&nu(t))return t-e}return null}get bitrate(){return this.byteLength?8*this.byteLength/this.duration:this._bitrate?this._bitrate:null}set bitrate(e){this._bitrate=e}get decryptdata(){var e;const{levelkeys:t}=this;if(!t||t.NONE)return null;if(t.identity)this._decryptdata||(this._decryptdata=t.identity.getDecryptData(this.sn));else if(null==(e=this._decryptdata)||!e.keyId){const e=Object.keys(t);if(1===e.length){const r=this._decryptdata=t[e[0]]||null;r&&(this._decryptdata=r.getDecryptData(this.sn,t))}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(null===this.programDateTime)return null;const e=nu(this.duration)?this.duration:0;return this.programDateTime+1e3*e}get encrypted(){var e;if(null!=(e=this._decryptdata)&&e.encrypted)return!0;if(this.levelkeys){var t;const e=Object.keys(this.levelkeys),r=e.length;if(r>1||1===r&&null!=(t=this.levelkeys[e[0]])&&t.encrypted)return!0}return!1}get programDateTime(){return null===this._programDateTime&&this.rawProgramDateTime&&(this.programDateTime=Date.parse(this.rawProgramDateTime)),this._programDateTime}set programDateTime(e){nu(e)?this._programDateTime=e:this._programDateTime=this.rawProgramDateTime=null}get ref(){return qu(this)?(this._ref||(this._ref={base:this.base,start:this.start,duration:this.duration,sn:this.sn,programDateTime:this.programDateTime}),this._ref):null}addStart(e){this.setStart(this.start+e)}setStart(e){this.start=e,this._ref&&(this._ref.start=e)}setDuration(e){this.duration=e,this._ref&&(this._ref.duration=e)}setKeyFormat(e){const t=this.levelkeys;if(t){var r;const i=t[e];!i||null!=(r=this._decryptdata)&&r.keyId||(this._decryptdata=i.getDecryptData(this.sn,t))}}abortRequests(){var e,t;null==(e=this.loader)||e.abort(),null==(t=this.keyLoader)||t.abort()}setElementaryStreamInfo(e,t,r,i,n,s=!1){const{elementaryStreams:a}=this,o=a[e];o?(o.startPTS=Math.min(o.startPTS,t),o.endPTS=Math.max(o.endPTS,r),o.startDTS=Math.min(o.startDTS,i),o.endDTS=Math.max(o.endDTS,n)):a[e]={startPTS:t,endPTS:r,startDTS:i,endDTS:n,partial:s}}}class Qu extends Ku{constructor(e,t,r,i,n){super(r),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=t,this.index=i;const s=e.enumeratedString("BYTERANGE");s&&this.setByteRange(s,n),n&&(this.fragOffset=n.fragOffset+n.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){const{elementaryStreams:e}=this;return!!(e.audio||e.video||e.audiovideo)}}function Zu(e,t){const r=Object.getPrototypeOf(e);if(r){const e=Object.getOwnPropertyDescriptor(r,t);return e||Zu(r,t)}}const Ju=Math.pow(2,32)-1,eh=[].push,th={video:1,audio:2,id3:3,text:4};function rh(e){return String.fromCharCode.apply(null,e)}function ih(e,t){const r=e[t]<<8|e[t+1];return r<0?65536+r:r}function nh(e,t){const r=ah(e,t);return r<0?4294967296+r:r}function sh(e,t){let r=nh(e,t);return r*=Math.pow(2,32),r+=nh(e,t+4),r}function ah(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function oh(e,t){const r=[];if(!t.length)return r;const i=e.byteLength;for(let n=0;n<i;){const s=nh(e,n),a=s>1?n+s:i;if(rh(e.subarray(n+4,n+8))===t[0])if(1===t.length)r.push(e.subarray(n+8,a));else{const i=oh(e.subarray(n+8,a),t.slice(1));i.length&&eh.apply(r,i)}n=a}return r}function lh(e){const t=[],r=e[0];let i=8;const n=nh(e,i);i+=4;let s=0,a=0;0===r?(s=nh(e,i),a=nh(e,i+4),i+=8):(s=sh(e,i),a=sh(e,i+8),i+=16),i+=2;let o=e.length+a;const l=ih(e,i);i+=2;for(let r=0;r<l;r++){let r=i;const s=nh(e,r);r+=4;const a=2147483647&s;if(1===(2147483648&s)>>>31)return Ru.warn("SIDX has hierarchical references (not supported)"),null;const l=nh(e,r);r+=4,t.push({referenceSize:a,subsegmentDuration:l,info:{duration:l/n,start:o,end:o+a-1}}),o+=a,r+=4,i=r}return{earliestPresentationTime:s,timescale:n,version:r,referencesCount:l,references:t}}function ch(e){const t=[],r=oh(e,["moov","trak"]);for(let e=0;e<r.length;e++){const i=r[e],n=oh(i,["tkhd"])[0];if(n){let e=n[0];const r=nh(n,0===e?12:20),s=oh(i,["mdia","mdhd"])[0];if(s){e=s[0];const n=nh(s,0===e?12:20),a=oh(i,["mdia","hdlr"])[0];if(a){const e=rh(a.subarray(8,12)),s={soun:Vu,vide:Wu}[e],o=dh(oh(i,["mdia","minf","stbl","stsd"])[0]);s?(t[r]={timescale:n,type:s,stsd:o},t[s]=Su({timescale:n,id:r},o)):t[r]={timescale:n,type:e,stsd:o}}}}}return oh(e,["moov","mvex","trex"]).forEach(e=>{const r=nh(e,4),i=t[r];i&&(i.default={duration:nh(e,12),flags:nh(e,20)})}),t}function dh(e){const t=e.subarray(8),r=t.subarray(86),i=rh(t.subarray(4,8));let n,s=i;const a="enca"===i||"encv"===i;if(a){const e=oh(t,[i])[0];oh(e.subarray("enca"===i?28:78),["sinf"]).forEach(e=>{const t=oh(e,["schm"])[0];if(t){const r=rh(t.subarray(4,8));if("cbcs"===r||"cenc"===r){const t=oh(e,["frma"])[0];t&&(s=rh(t))}}})}const o=s;switch(s){case"avc1":case"avc2":case"avc3":case"avc4":{const e=oh(r,["avcC"])[0];e&&e.length>3&&(s+="."+fh(e[1])+fh(e[2])+fh(e[3]),n=uh("avc1"===o?"dva1":"dvav",r));break}case"mp4a":{const e=oh(t,[i])[0],r=oh(e.subarray(28),["esds"])[0];if(r&&r.length>7){let e=4;if(3!==r[e++])break;e=hh(r,e),e+=2;const t=r[e++];if(128&t&&(e+=2),64&t&&(e+=r[e++]),4!==r[e++])break;e=hh(r,e);const i=r[e++];if(64!==i)break;if(s+="."+fh(i),e+=12,5!==r[e++])break;e=hh(r,e);const n=r[e++];let a=(248&n)>>3;31===a&&(a+=1+((7&n)<<3)+((224&r[e])>>5)),s+="."+a}break}case"hvc1":case"hev1":{const e=oh(r,["hvcC"])[0];if(e&&e.length>12){const t=e[1],r=["","A","B","C"][t>>6],i=31&t,n=nh(e,2),a=(32&t)>>5?"H":"L",o=e[12],l=e.subarray(6,12);s+="."+r+i,s+="."+function(e){let t=0;for(let r=0;r<32;r++)t|=(e>>r&1)<<31-r;return t>>>0}(n).toString(16).toUpperCase(),s+="."+a+o;let c="";for(let e=l.length;e--;){const t=l[e];if(t||c){c="."+t.toString(16).toUpperCase()+c}}s+=c}n=uh("hev1"==o?"dvhe":"dvh1",r);break}case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":s=uh(s,r)||s;break;case"vp09":{const e=oh(r,["vpcC"])[0];if(e&&e.length>6){const t=e[4],r=e[5],i=e[6]>>4&15;s+="."+ph(t)+"."+ph(r)+"."+ph(i)}break}case"av01":{const e=oh(r,["av1C"])[0];if(e&&e.length>2){const t=e[1]>>>5,i=31&e[1],a=e[2]>>>7?"H":"M",o=(64&e[2])>>6,l=(32&e[2])>>5,c=2===t&&o?l?12:10:o?10:8,d=(16&e[2])>>4,u=(8&e[2])>>3,h=(4&e[2])>>2,f=3&e[2],p=1,m=1,g=1,v=0;s+="."+t+"."+ph(i)+a+"."+ph(c)+"."+d+"."+u+h+f+"."+ph(p)+"."+ph(m)+"."+ph(g)+"."+v,n=uh("dav1",r)}break}}return{codec:s,encrypted:a,supplemental:n}}function uh(e,t){const r=oh(t,["dvvC"]),i=r.length?r[0]:oh(t,["dvcC"])[0];if(i){const t=i[2]>>1&127,r=i[2]<<5&32|i[3]>>3&31;return e+"."+ph(t)+"."+ph(r)}}function hh(e,t){const r=t+5;for(;128&e[t++]&&t<r;);return t}function fh(e){return("0"+e.toString(16).toUpperCase()).slice(-2)}function ph(e){return(e<10?"0":"")+e}function mh(e,t){oh(e,["moov","trak"]).forEach(e=>{const r=oh(e,["mdia","minf","stbl","stsd"])[0];if(!r)return;const i=r.subarray(8);let n=oh(i,["enca"]);const s=n.length>0;s||(n=oh(i,["encv"])),n.forEach(e=>{oh(s?e.subarray(28):e.subarray(78),["sinf"]).forEach(e=>{const r=gh(e);r&&t(r,s)})})})}function gh(e){const t=oh(e,["schm"])[0];if(t){const r=rh(t.subarray(4,8));if("cbcs"===r||"cenc"===r){const t=oh(e,["schi","tenc"])[0];if(t)return t}}}function vh(e,t){const r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}function yh(e,t){const r=[],i=t.samples,n=t.timescale,s=t.id;let a=!1;return oh(i,["moof"]).map(o=>{const l=o.byteOffset-8;oh(o,["traf"]).map(o=>{const c=oh(o,["tfdt"]).map(e=>{const t=e[0];let r=nh(e,4);return 1===t&&(r*=Math.pow(2,32),r+=nh(e,8)),r/n})[0];return void 0!==c&&(e=c),oh(o,["tfhd"]).map(c=>{const d=nh(c,4),u=16777215&nh(c,0);let h=0;const f=!!(16&u);let p=0;const m=!!(32&u);let g=8;d===s&&(!!(1&u)&&(g+=8),!!(2&u)&&(g+=4),!!(8&u)&&(h=nh(c,g),g+=4),f&&(p=nh(c,g),g+=4),m&&(g+=4),"video"===t.type&&(a=bh(t.codec)),oh(o,["trun"]).map(s=>{const o=s[0],c=16777215&nh(s,0),d=!!(1&c);let u=0;const f=!!(4&c),m=!!(256&c);let g=0;const v=!!(512&c);let y=0;const b=!!(1024&c),E=!!(2048&c);let w=0;const S=nh(s,4);let T=8;d&&(u=nh(s,T),T+=4),f&&(T+=4);let x=u+l;for(let l=0;l<S;l++){if(m?(g=nh(s,T),T+=4):g=h,v?(y=nh(s,T),T+=4):y=p,b&&(T+=4),E&&(w=0===o?nh(s,T):ah(s,T),T+=4),t.type===Wu){let t=0;for(;t<y;){const s=nh(i,x);if(x+=4,Eh(a,i[x])){wh(i.subarray(x,x+s),a?2:1,e+w/n,r)}x+=s,t+=s+4}}e+=g/n}}))})})}),r}function bh(e){if(!e)return!1;const t=e.substring(0,4);return"hvc1"===t||"hev1"===t||"dvh1"===t||"dvhe"===t}function Eh(e,t){if(e){const e=t>>1&63;return 39===e||40===e}return 6===(31&t)}function wh(e,t,r,i){const n=Sh(e);let s=0;s+=t;let a=0,o=0,l=0;for(;s<n.length;){a=0;do{if(s>=n.length)break;l=n[s++],a+=l}while(255===l);o=0;do{if(s>=n.length)break;l=n[s++],o+=l}while(255===l);const e=n.length-s;let t=s;if(o<e)s+=o;else if(o>e){Ru.error(`Malformed SEI payload. ${o} is too small, only ${e} bytes left to parse.`);break}if(4===a){if(181===n[t++]){const e=ih(n,t);if(t+=2,49===e){const e=nh(n,t);if(t+=4,1195456820===e){const e=n[t++];if(3===e){const s=n[t++],o=64&s,l=o?2+3*(31&s):0,c=new Uint8Array(l);if(o){c[0]=s;for(let e=1;e<l;e++)c[e]=n[t++]}i.push({type:e,payloadType:a,pts:r,bytes:c})}}}}}else if(5===a&&o>16){const e=[];for(let r=0;r<16;r++){const i=n[t++].toString(16);e.push(1==i.length?"0"+i:i),3!==r&&5!==r&&7!==r&&9!==r||e.push("-")}const s=o-16,l=new Uint8Array(s);for(let e=0;e<s;e++)l[e]=n[t++];i.push({payloadType:a,pts:r,uuid:e.join(""),userData:Du(l),userDataBytes:l})}}}function Sh(e){const t=e.byteLength,r=[];let i=1;for(;i<t-2;)0===e[i]&&0===e[i+1]&&3===e[i+2]?(r.push(i+2),i+=2):i++;if(0===r.length)return e;const n=t-r.length,s=new Uint8Array(n);let a=0;for(i=0;i<n;a++,i++)a===r[0]&&(a++,r.shift()),s[i]=e[a];return s}function Th(e,t,r){if(16!==e.byteLength)throw new RangeError("Invalid system id");let i,n,s;i=0,n=new Uint8Array,s=new Uint8Array;const a=new Uint8Array(4);return r.byteLength>0&&new DataView(a.buffer).setUint32(0,r.byteLength,!1),function(e,...t){const r=t.length;let i=8,n=r;for(;n--;)i+=t[n].byteLength;const s=new Uint8Array(i);for(s[0]=i>>24&255,s[1]=i>>16&255,s[2]=i>>8&255,s[3]=255&i,s.set(e,4),n=0,i=8;n<r;n++)s.set(t[n],i),i+=t[n].byteLength;return s}([112,115,115,104],new Uint8Array([0,0,0,0]),e,s,n,a,r)}function xh(e){const t=e.getUint32(0),r=e.byteOffset,i=e.byteLength;if(i<t)return{offset:r,size:i};if(1886614376!==e.getUint32(4))return{offset:r,size:t};const n=e.getUint32(8)>>>24;if(0!==n&&1!==n)return{offset:r,size:t};const s=e.buffer,a=_u(new Uint8Array(s,r+12,16));let o=null,l=null,c=0;if(0===n)c=28;else{const n=e.getUint32(28);if(!n||i<32+16*n)return{offset:r,size:t};o=[];for(let e=0;e<n;e++)o.push(new Uint8Array(s,r+32+16*e,16));c=32+16*n}if(!c)return{offset:r,size:t};const d=e.getUint32(c);return t-32<d?{offset:r,size:t}:(l=new Uint8Array(s,r+c+4,d),{version:n,systemId:a,kids:o,data:l,offset:r,size:t})}const Ah=()=>/\(Windows.+Firefox\//i.test(navigator.userAgent),kh={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,dav1:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function Ih(e,t){const r=kh[t];return!!r&&!!r[e.slice(0,4)]}function Lh(e,t,r=!0){return!e.split(",").some(e=>!Rh(e,t,r))}function Rh(e,t,r=!0){var i;const n=Pu(r);return null!=(i=null==n?void 0:n.isTypeSupported(Ph(e,t)))&&i}function Ph(e,t){return`${t}/mp4;codecs=${e}`}function Ch(e){if(e){const t=e.substring(0,4);return kh.video[t]}return 2}function Dh(e){const t=Ah();return e.split(",").reduce((e,r)=>{const i=t&&bh(r)?9:kh.video[r];return i?(2*i+e)/(e?3:2):(kh.audio[r]+e)/(e?2:1)},0)}const _h={};const Oh=/flac|opus|mp4a\.40\.34/i;function Mh(e,t=!0){return e.replace(Oh,e=>function(e,t=!0){if(_h[e])return _h[e];const r={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[e];for(let n=0;n<r.length;n++){var i;if(Rh(r[n],"audio",t))return _h[e]=r[n],r[n];if("mp3"===r[n]&&null!=(i=Pu(t))&&i.isTypeSupported("audio/mpeg"))return""}return e}(e.toLowerCase(),t))}function Nh(e,t){if(e&&(e.length>4||-1!==["ac-3","ec-3","alac","fLaC","Opus"].indexOf(e))&&(Fh(e,"audio")||Fh(e,"video")))return e;if(t){const r=t.split(",");if(r.length>1){if(e)for(let t=r.length;t--;)if(r[t].substring(0,4)===e.substring(0,4))return r[t];return r[0]}}return t||e}function Fh(e,t){return Ih(e,t)&&Rh(e,t)}function $h(e){if(e.startsWith("av01.")){const t=e.split("."),r=["0","111","01","01","01","0"];for(let e=t.length;e>4&&e<10;e++)t[e]=r[e-4];return t.join(".")}return e}function Bh(e){const t=Pu(e)||{isTypeSupported:()=>!1};return{mpeg:t.isTypeSupported("audio/mpeg"),mp3:t.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:t.isTypeSupported('audio/mp4; codecs="ac-3"')}}function Uh(e){return e.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}const zh={supported:!1,smooth:!1,powerEfficient:!1},Gh={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]};function jh(e,t){return{supported:!1,configurations:t,decodingInfoResults:[zh],error:e}}function Hh(e,t,r,i,n,s){const a=e.videoCodec,o=e.audioCodec?e.audioGroups:null,l=null==s?void 0:s.audioCodec,c=null==s?void 0:s.channels,d=c?parseInt(c):l?1/0:2;let u=null;if(null!=o&&o.length)try{u=1===o.length&&o[0]?t.groups[o[0]].channels:o.reduce((e,r)=>{if(r){const i=t.groups[r];if(!i)throw new Error(`Audio track group ${r} not found`);Object.keys(i.channels).forEach(t=>{e[t]=(e[t]||0)+i.channels[t]})}return e},{2:0})}catch(e){return!0}return void 0!==a&&(a.split(",").some(e=>bh(e))||e.width>1920&&e.height>1088||e.height>1920&&e.width>1088||e.frameRate>Math.max(i,30)||"SDR"!==e.videoRange&&e.videoRange!==r||e.bitrate>Math.max(n,8e6))||!!u&&nu(d)&&Object.keys(u).some(e=>parseInt(e)>d)}function Vh(e,t,r,i={}){const n=e.videoCodec;if(!n&&!e.audioCodec||!r)return Promise.resolve(Gh);const s=[],a=function(e){var t;const r=null==(t=e.videoCodec)?void 0:t.split(","),i=Yh(e),n=e.width||640,s=e.height||480,a=e.frameRate||30,o=e.videoRange.toLowerCase();return r?r.map(e=>{const t={contentType:Ph($h(e),"video"),width:n,height:s,bitrate:i,framerate:a};return"sdr"!==o&&(t.transferFunction=o),t}):[]}(e),o=a.length,l=function(e,t,r){var i;const n=null==(i=e.audioCodec)?void 0:i.split(","),s=Yh(e);if(n&&e.audioGroups)return e.audioGroups.reduce((e,i)=>{var a;const o=i?null==(a=t.groups[i])?void 0:a.tracks:null;return o?o.reduce((e,t)=>{if(t.groupId===i){const i=parseFloat(t.channels||"");n.forEach(t=>{const n={contentType:Ph(t,"audio"),bitrate:r?Wh(t,s):s};i&&(n.channels=""+i),e.push(n)})}return e},e):e},[]);return[]}(e,t,o>0),c=l.length;for(let e=o||1*c||1;e--;){const t={type:"media-source"};if(o&&(t.video=a[e%o]),c){t.audio=l[e%c];const r=t.audio.bitrate;t.video&&r&&(t.video.bitrate-=r)}s.push(t)}if(n){const e=navigator.userAgent;if(n.split(",").some(e=>bh(e))&&Ah())return Promise.resolve(jh(new Error(`Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent string: (${e})`),s))}return Promise.all(s.map(e=>{const t=function(e){let t="";const{audio:r,video:i}=e;if(i){t+=`${Uh(i.contentType)}_r${i.height}x${i.width}f${Math.ceil(i.framerate)}${i.transferFunction||"sd"}_${Math.ceil(i.bitrate/1e5)}`}if(r){t+=`${i?"_":""}${Uh(r.contentType)}_c${r.channels}`}return t}(e);return i[t]||(i[t]=r.decodingInfo(e))})).then(e=>({supported:!e.some(e=>!e.supported),configurations:s,decodingInfoResults:e})).catch(e=>({supported:!1,configurations:s,decodingInfoResults:[],error:e}))}function Wh(e,t){if(t<=1)return 1;let r=128e3;return"ec-3"===e?r=768e3:"ac-3"===e&&(r=64e4),Math.min(t/2,r)}function Yh(e){return 1e3*Math.ceil(Math.max(.9*e.bitrate,e.averageBitrate)/1e3)||1}const Kh=["NONE","TYPE-0","TYPE-1",null];const qh=["SDR","PQ","HLG"];var Xh="",Qh="YES",Zh="v2";function Jh(e){const{canSkipUntil:t,canSkipDateRanges:r,age:i}=e;return t&&i<t/2?r?Zh:Qh:Xh}class ef{constructor(e,t,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=r}addDirectives(e){const t=new self.URL(e);return void 0!==this.msn&&t.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}}class tf{constructor(e){if(this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.supplemental=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.frameRate=e.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=e.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.codecSet=[e.videoCodec,e.audioCodec].filter(e=>!!e).map(e=>e.substring(0,4)).join(","),"supplemental"in e){var t;this.supplemental=e.supplemental;const r=null==(t=e.supplemental)?void 0:t.videoCodec;r&&r!==e.videoCodec&&(this.codecSet+=`,${r.substring(0,4)}`)}this.addGroupId("audio",e.attrs.AUDIO),this.addGroupId("text",e.attrs.SUBTITLES)}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get averageBitrate(){return this._avgBitrate||this.realBitrate||this.bitrate}get attrs(){return this._attrs[0]}get codecs(){return this.attrs.CODECS||""}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get videoRange(){return this.attrs["VIDEO-RANGE"]||"SDR"}get score(){return this.attrs.optionalFloat("SCORE",0)}get uri(){return this.url[0]||""}hasAudioGroup(e){return rf(this._audioGroups,e)}hasSubtitleGroup(e){return rf(this._subtitleGroups,e)}get audioGroups(){return this._audioGroups}get subtitleGroups(){return this._subtitleGroups}addGroupId(e,t){if(t)if("audio"===e){let e=this._audioGroups;e||(e=this._audioGroups=[]),-1===e.indexOf(t)&&e.push(t)}else if("text"===e){let e=this._subtitleGroups;e||(e=this._subtitleGroups=[]),-1===e.indexOf(t)&&e.push(t)}}get urlId(){return 0}set urlId(e){}get audioGroupIds(){return this.audioGroups?[this.audioGroupId]:void 0}get textGroupIds(){return this.subtitleGroups?[this.textGroupId]:void 0}get audioGroupId(){var e;return null==(e=this.audioGroups)?void 0:e[0]}get textGroupId(){var e;return null==(e=this.subtitleGroups)?void 0:e[0]}addFallback(){}}function rf(e,t){return!(!t||!e)&&-1!==e.indexOf(t)}function nf(e,t){let r=!1,i=[];if(e&&(r="SDR"!==e,i=[e]),t){i=t.allowedVideoRanges||qh.slice(0);const e="SDR"!==i.join("")&&!t.videoCodec;r=void 0!==t.preferHDR?t.preferHDR:e&&function(){if("function"==typeof matchMedia){const e=matchMedia("(dynamic-range: high)"),t=matchMedia("bad query");if(e.media!==t.media)return!0===e.matches}return!1}(),r||(i=["SDR"])}return{preferHDR:r,allowedVideoRanges:i}}const sf=(e,t)=>JSON.stringify(e,(e=>{const t=new WeakSet;return(r,i)=>{if(e&&(i=e(r,i)),"object"==typeof i&&null!==i){if(t.has(i))return;t.add(i)}return i}})(t));function af(e,t){Ru.log(`[abr] start candidates with "${e}" ignored because ${t}`)}function of(e){return e.reduce((e,t)=>{let r=e.groups[t.groupId];r||(r=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),r.tracks.push(t);const i=t.channels||"2";return r.channels[i]=(r.channels[i]||0)+1,r.hasDefault=r.hasDefault||t.default,r.hasAutoSelect=r.hasAutoSelect||t.autoselect,r.hasDefault&&(e.hasDefaultAudio=!0),r.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function lf(e){if(!e)return e;const{lang:t,assocLang:r,characteristics:i,channels:n,audioCodec:s}=e;return{lang:t,assocLang:r,characteristics:i,channels:n,audioCodec:s}}function cf(e,t,r){if("attrs"in e){const r=t.indexOf(e);if(-1!==r)return r}for(let i=0;i<t.length;i++){if(df(e,t[i],r))return i}return-1}function df(e,t,r){const{groupId:i,name:n,lang:s,assocLang:a,default:o}=e,l=e.forced;return(void 0===i||t.groupId===i)&&(void 0===n||t.name===n)&&(void 0===s||function(e,t="--"){if(e.length===t.length)return e===t;return e.startsWith(t)||t.startsWith(e)}(s,t.lang))&&(void 0===s||t.assocLang===a)&&(void 0===o||t.default===o)&&(void 0===l||t.forced===l)&&(!("characteristics"in e)||function(e,t=""){const r=e.split(","),i=t.split(",");return r.length===i.length&&!r.some(e=>-1===i.indexOf(e))}(e.characteristics||"",t.characteristics))&&(void 0===r||r(e,t))}function uf(e,t){const{audioCodec:r,channels:i}=e;return!(void 0!==r&&(t.audioCodec||"").substring(0,4)!==r.substring(0,4)||void 0!==i&&i!==(t.channels||"2"))}function hf(e,t,r){for(let i=t;i>-1;i--)if(r(e[i]))return i;for(let i=t+1;i<e.length;i++)if(r(e[i]))return i;return-1}function ff(e,t){var r;return!!e&&e!==(null==(r=t.loadLevelObj)?void 0:r.uri)}const pf=function(e,t){let r=0,i=e.length-1,n=null,s=null;for(;r<=i;){n=(r+i)/2|0,s=e[n];const a=t(s);if(a>0)r=n+1;else{if(!(a<0))return s;i=n-1}}return null};function mf(e,t,r=0,i=0,n=.005){let s=null;if(e){s=t[1+e.sn-t[0].sn]||null;const i=e.endDTS-r;i>0&&i<15e-7&&(r+=15e-7),s&&e.level!==s.level&&s.end<=e.end&&(s=t[2+e.sn-t[0].sn]||null)}else 0===r&&0===t[0].start&&(s=t[0]);if(s&&((!e||e.level===s.level)&&0===gf(r,i,s)||function(e,t,r){if(t&&0===t.start&&t.level<e.level&&(t.endPTS||0)>0){const i=t.tagList.reduce((e,t)=>("INF"===t[0]&&(e+=parseFloat(t[1])),e),r);return e.start<=i}return!1}(s,e,Math.min(n,i))))return s;const a=pf(t,gf.bind(null,r,i));return!a||a===e&&s?s:a}function gf(e=0,t=0,r){if(r.start<=e&&r.start+r.duration>e)return 0;const i=Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return r.start+r.duration-i<=e?1:r.start-i>e&&r.start?-1:0}function vf(e,t,r){const i=1e3*Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return(r.endProgramDateTime||0)-i>e}function yf(e,t,r){if(e&&e.startCC<=t&&e.endCC>=t){let i=e.fragments;const{fragmentHint:n}=e;let s;return n&&(i=i.concat(n)),pf(i,e=>e.cc<t?1:e.cc>t?-1:(s=e,e.end<=r?1:e.start>r?-1:0)),s||null}return null}function bf(e){switch(e.details){case lu.FRAG_LOAD_TIMEOUT:case lu.KEY_LOAD_TIMEOUT:case lu.LEVEL_LOAD_TIMEOUT:case lu.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function Ef(e){return e.details.startsWith("key")}function wf(e){return Ef(e)&&!!e.frag&&!e.frag.decryptdata}function Sf(e,t){const r=bf(t);return e.default[(r?"timeout":"error")+"Retry"]}function Tf(e,t){const r="linear"===e.backoff?1:Math.pow(2,t);return Math.min(r*e.retryDelayMs,e.maxRetryDelayMs)}function xf(e){return Su(Su({},e),{errorRetry:null,timeoutRetry:null})}function Af(e,t,r,i){if(!e)return!1;const n=null==i?void 0:i.code,s=t<e.maxNumRetry&&(function(e){return kf(e)||!!e&&(e<400||e>499)}(n)||!!r);return e.shouldRetry?e.shouldRetry(e,t,r,i,s):s}function kf(e){return 0===e&&!1===navigator.onLine}var If=0,Lf=2,Rf=3,Pf=5,Cf=0,Df=1,_f=2,Of=4;function Mf(e){const t={action:If,flags:Cf};return e&&(t.resolved=!0),t}var Nf="NOT_LOADED",Ff="APPENDING",$f="PARTIAL",Bf="OK";class Uf{constructor(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}_registerListeners(){const{hls:e}=this;e&&(e.on(cu.MANIFEST_LOADING,this.onManifestLoading,this),e.on(cu.BUFFER_APPENDED,this.onBufferAppended,this),e.on(cu.FRAG_BUFFERED,this.onFragBuffered,this),e.on(cu.FRAG_LOADED,this.onFragLoaded,this))}_unregisterListeners(){const{hls:e}=this;e&&(e.off(cu.MANIFEST_LOADING,this.onManifestLoading,this),e.off(cu.BUFFER_APPENDED,this.onBufferAppended,this),e.off(cu.FRAG_BUFFERED,this.onFragBuffered,this),e.off(cu.FRAG_LOADED,this.onFragLoaded,this))}destroy(){this._unregisterListeners(),this.hls=this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){const r=this.activePartLists[t];if(r)for(let t=r.length;t--;){const i=r[t];if(!i)break;if(i.start<=e&&e<=i.end&&i.loaded)return i}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){return this.getFragAtPos(e,t,!0)}getFragAtPos(e,t,r){const{fragments:i}=this,n=Object.keys(i);for(let s=n.length;s--;){const a=i[n[s]];if((null==a?void 0:a.body.type)===t&&(!r||a.buffered)){const t=a.body;if(t.start<=e&&e<=t.end)return t}}return null}detectEvictedFragments(e,t,r,i,n){this.timeRanges&&(this.timeRanges[e]=t);const s=(null==i?void 0:i.fragment.sn)||-1;Object.keys(this.fragments).forEach(i=>{const a=this.fragments[i];if(!a)return;if(s>=a.body.sn)return;if(!a.buffered&&(!a.loaded||n))return void(a.body.type===r&&this.removeFragment(a.body));const o=a.range[e];o&&(0!==o.time.length?o.time.some(e=>{const r=!this.isTimeBuffered(e.startPTS,e.endPTS,t);return r&&this.removeFragment(a.body),r}):this.removeFragment(a.body))})}detectPartialFragments(e){const t=this.timeRanges;if(!t||"initSegment"===e.frag.sn)return;const r=e.frag,i=Gf(r),n=this.fragments[i];if(!n||n.buffered&&r.gap)return;const s=!r.relurl;Object.keys(t).forEach(i=>{const a=r.elementaryStreams[i];if(!a)return;const o=t[i],l=s||!0===a.partial;n.range[i]=this.getBufferedTimes(r,e.part,l,o)}),n.loaded=null,Object.keys(n.range).length?(this.bufferedEnd(n,r),zf(n)||this.removeParts(r.sn-1,r.type)):this.removeFragment(n.body)}bufferedEnd(e,t){e.buffered=!0;(e.body.endList=t.endList||e.body.endList)&&(this.endListFragments[e.body.type]=e)}removeParts(e,t){const r=this.activePartLists[t];r&&(this.activePartLists[t]=jf(r,t=>t.fragment.sn>=e))}fragBuffered(e,t){const r=Gf(e);let i=this.fragments[r];!i&&t&&(i=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),i&&(i.loaded=null,this.bufferedEnd(i,e))}getBufferedTimes(e,t,r,i){const n={time:[],partial:r},s=e.start,a=e.end,o=e.minEndPTS||a,l=e.maxStartPTS||s;for(let e=0;e<i.length;e++){const t=i.start(e)-this.bufferPadding,r=i.end(e)+this.bufferPadding;if(l>=t&&o<=r){n.time.push({startPTS:Math.max(s,i.start(e)),endPTS:Math.min(a,i.end(e))});break}if(s<r&&a>t){const t=Math.max(s,i.start(e)),r=Math.min(a,i.end(e));r>t&&(n.partial=!0,n.time.push({startPTS:t,endPTS:r}))}else if(a<=t)break}return n}getPartialFragment(e){let t,r,i,n=null,s=0;const{bufferPadding:a,fragments:o}=this;return Object.keys(o).forEach(l=>{const c=o[l];c&&zf(c)&&(r=c.body.start-a,i=c.body.end+a,e>=r&&e<=i&&(t=Math.min(e-r,i-e),s<=t&&(n=c.body,s=t)))}),n}isEndListAppended(e){const t=this.endListFragments[e];return void 0!==t&&(t.buffered||zf(t))}getState(e){const t=Gf(e),r=this.fragments[t];return r?r.buffered?zf(r)?$f:Bf:Ff:Nf}isTimeBuffered(e,t,r){let i,n;for(let s=0;s<r.length;s++){if(i=r.start(s)-this.bufferPadding,n=r.end(s)+this.bufferPadding,e>=i&&t<=n)return!0;if(t<=i)return!1}return!1}onManifestLoading(){this.removeAllFragments()}onFragLoaded(e,t){if("initSegment"===t.frag.sn||t.frag.bitrateTest)return;const r=t.frag,i=t.part?null:t,n=Gf(r);this.fragments[n]={body:r,appendedPTS:null,loaded:i,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){const{frag:r,part:i,timeRanges:n,type:s}=t;if("initSegment"===r.sn)return;const a=r.type;if(i){let e=this.activePartLists[a];e||(this.activePartLists[a]=e=[]),e.push(i)}this.timeRanges=n;const o=n[s];this.detectEvictedFragments(s,o,a,i)}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){const t=Gf(e);return!!this.fragments[t]}hasFragments(e){const{fragments:t}=this,r=Object.keys(t);if(!e)return r.length>0;for(let i=r.length;i--;){const n=t[r[i]];if((null==n?void 0:n.body.type)===e)return!0}return!1}hasParts(e){var t;return!(null==(t=this.activePartLists[e])||!t.length)}removeFragmentsInRange(e,t,r,i,n){i&&!this.hasGaps||Object.keys(this.fragments).forEach(s=>{const a=this.fragments[s];if(!a)return;const o=a.body;o.type!==r||i&&!o.gap||o.start<t&&o.end>e&&(a.buffered||n)&&this.removeFragment(o)})}removeFragment(e){const t=Gf(e);e.clearElementaryStreamInfo();const r=this.activePartLists[e.type];if(r){const t=e.sn;this.activePartLists[e.type]=jf(r,e=>e.fragment.sn!==t)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){var e;this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1;const t=null==(e=this.hls)||null==(e=e.latestLevelDetails)?void 0:e.partList;t&&t.forEach(e=>e.clearElementaryStreamInfo())}}function zf(e){var t,r,i;return e.buffered&&!!(e.body.gap||null!=(t=e.range.video)&&t.partial||null!=(r=e.range.audio)&&r.partial||null!=(i=e.range.audiovideo)&&i.partial)}function Gf(e){return`${e.type}_${e.level}_${e.sn}`}function jf(e,t){return e.filter(e=>{const r=t(e);return r||e.clearElementaryStreamInfo(),r})}var Hf=0,Vf=1;class Wf{constructor(e,t,r){this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=e,this.aesIV=t,this.aesMode=r}decrypt(e,t){switch(this.aesMode){case Hf:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e);case Vf:return this.subtle.decrypt({name:"AES-CTR",counter:this.aesIV,length:64},t,e);default:throw new Error(`[AESCrypto] invalid aes mode ${this.aesMode}`)}}}class Yf{constructor(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}uint8ArrayToUint32Array_(e){const t=new DataView(e),r=new Uint32Array(4);for(let e=0;e<4;e++)r[e]=t.getUint32(4*e);return r}initTable(){const e=this.sBox,t=this.invSBox,r=this.subMix,i=r[0],n=r[1],s=r[2],a=r[3],o=this.invSubMix,l=o[0],c=o[1],d=o[2],u=o[3],h=new Uint32Array(256);let f=0,p=0,m=0;for(m=0;m<256;m++)h[m]=m<128?m<<1:m<<1^283;for(m=0;m<256;m++){let r=p^p<<1^p<<2^p<<3^p<<4;r=r>>>8^255&r^99,e[f]=r,t[r]=f;const o=h[f],m=h[o],g=h[m];let v=257*h[r]^16843008*r;i[f]=v<<24|v>>>8,n[f]=v<<16|v>>>16,s[f]=v<<8|v>>>24,a[f]=v,v=16843009*g^65537*m^257*o^16843008*f,l[r]=v<<24|v>>>8,c[r]=v<<16|v>>>16,d[r]=v<<8|v>>>24,u[r]=v,f?(f=o^h[h[h[g^o]]],p^=h[h[p]]):f=p=1}}expandKey(e){const t=this.uint8ArrayToUint32Array_(e);let r=!0,i=0;for(;i<t.length&&r;)r=t[i]===this.key[i],i++;if(r)return;this.key=t;const n=this.keySize=t.length;if(4!==n&&6!==n&&8!==n)throw new Error("Invalid aes key size="+n);const s=this.ksRows=4*(n+6+1);let a,o;const l=this.keySchedule=new Uint32Array(s),c=this.invKeySchedule=new Uint32Array(s),d=this.sBox,u=this.rcon,h=this.invSubMix,f=h[0],p=h[1],m=h[2],g=h[3];let v,y;for(a=0;a<s;a++)a<n?v=l[a]=t[a]:(y=v,a%n===0?(y=y<<8|y>>>24,y=d[y>>>24]<<24|d[y>>>16&255]<<16|d[y>>>8&255]<<8|d[255&y],y^=u[a/n|0]<<24):n>6&&a%n===4&&(y=d[y>>>24]<<24|d[y>>>16&255]<<16|d[y>>>8&255]<<8|d[255&y]),l[a]=v=(l[a-n]^y)>>>0);for(o=0;o<s;o++)a=s-o,y=3&o?l[a]:l[a-4],c[o]=o<4||a<=4?y:f[d[y>>>24]]^p[d[y>>>16&255]]^m[d[y>>>8&255]]^g[d[255&y]],c[o]=c[o]>>>0}networkToHostOrderSwap(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24}decrypt(e,t,r){const i=this.keySize+6,n=this.invKeySchedule,s=this.invSBox,a=this.invSubMix,o=a[0],l=a[1],c=a[2],d=a[3],u=this.uint8ArrayToUint32Array_(r);let h=u[0],f=u[1],p=u[2],m=u[3];const g=new Int32Array(e),v=new Int32Array(g.length);let y,b,E,w,S,T,x,A,k,I,L,R,P,C;const D=this.networkToHostOrderSwap;for(;t<g.length;){for(k=D(g[t]),I=D(g[t+1]),L=D(g[t+2]),R=D(g[t+3]),S=k^n[0],T=R^n[1],x=L^n[2],A=I^n[3],P=4,C=1;C<i;C++)y=o[S>>>24]^l[T>>16&255]^c[x>>8&255]^d[255&A]^n[P],b=o[T>>>24]^l[x>>16&255]^c[A>>8&255]^d[255&S]^n[P+1],E=o[x>>>24]^l[A>>16&255]^c[S>>8&255]^d[255&T]^n[P+2],w=o[A>>>24]^l[S>>16&255]^c[T>>8&255]^d[255&x]^n[P+3],S=y,T=b,x=E,A=w,P+=4;y=s[S>>>24]<<24^s[T>>16&255]<<16^s[x>>8&255]<<8^s[255&A]^n[P],b=s[T>>>24]<<24^s[x>>16&255]<<16^s[A>>8&255]<<8^s[255&S]^n[P+1],E=s[x>>>24]<<24^s[A>>16&255]<<16^s[S>>8&255]<<8^s[255&T]^n[P+2],w=s[A>>>24]<<24^s[S>>16&255]<<16^s[T>>8&255]<<8^s[255&x]^n[P+3],v[t]=D(y^h),v[t+1]=D(w^f),v[t+2]=D(E^p),v[t+3]=D(b^m),h=k,f=I,p=L,m=R,t+=4}return v.buffer}}class Kf{constructor(e,t,r){this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=e,this.key=t,this.aesMode=r}expandKey(){const e=function(e){switch(e){case Hf:return"AES-CBC";case Vf:return"AES-CTR";default:throw new Error(`[FastAESKey] invalid aes mode ${e}`)}}(this.aesMode);return this.subtle.importKey("raw",this.key,{name:e},!1,["encrypt","decrypt"])}}class qf{constructor(e,{removePKCS7Padding:t=!0}={}){if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.enableSoftwareAES=void 0,this.enableSoftwareAES=e.enableSoftwareAES,this.removePKCS7Padding=t,t)try{const e=self.crypto;e&&(this.subtle=e.subtle||e.webkitSubtle)}catch(e){}this.useSoftware=!this.subtle}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}isSync(){return this.useSoftware}flush(){const{currentResult:e,remainderData:t}=this;if(!e||t)return this.reset(),null;const r=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?function(e){const t=e.byteLength,r=t&&new DataView(e.buffer).getUint8(t-1);return r?e.slice(0,t-r):e}(r):r}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,r,i){return this.useSoftware?new Promise((n,s)=>{const a=ArrayBuffer.isView(e)?e:new Uint8Array(e);this.softwareDecrypt(a,t,r,i);const o=this.flush();o?n(o.buffer):s(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,r,i)}softwareDecrypt(e,t,r,i){const{currentIV:n,currentResult:s,remainderData:a}=this;if(i!==Hf||16!==t.byteLength)return Ru.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),a&&(e=vh(a,e),this.remainderData=null);const o=this.getValidChunk(e);if(!o.length)return null;n&&(r=n);let l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new Yf),l.expandKey(t);const c=s;return this.currentResult=l.decrypt(o.buffer,0,r),this.currentIV=o.slice(-16).buffer,c||null}webCryptoDecrypt(e,t,r,i){if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,r,i));this.key=t,this.fastAesKey=new Kf(this.subtle,t,i)}return this.fastAesKey.expandKey().then(t=>{if(!this.subtle)return Promise.reject(new Error("web crypto not initialized"));this.logOnce("WebCrypto AES decrypt");return new Wf(this.subtle,new Uint8Array(r),i).decrypt(e.buffer,t)}).catch(n=>(Ru.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${n.name}: ${n.message}`),this.onWebCryptoError(e,t,r,i)))}onWebCryptoError(e,t,r,i){const n=this.enableSoftwareAES;if(n){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r,i);const n=this.flush();if(n)return n.buffer}throw new Error("WebCrypto"+(n?" and softwareDecrypt":"")+": failed to decrypt data")}getValidChunk(e){let t=e;const r=e.length-e.length%16;return r!==e.length&&(t=e.slice(0,r),this.remainderData=e.slice(r)),t}logOnce(e){this.logEnabled&&(Ru.log(`[decrypter]: ${e}`),this.logEnabled=!1)}}const Xf=Math.pow(2,17);class Qf{constructor(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(e,t){const r=e.url;if(!r)return Promise.reject(new ep({type:ou.NETWORK_ERROR,details:lu.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error("Fragment does not have a "+(r?"part list":"url")),networkDetails:null}));this.abort();const i=this.config,n=i.fLoader,s=i.loader;return new Promise((a,o)=>{if(this.loader&&this.loader.destroy(),e.gap){if(e.tagList.some(e=>"GAP"===e[0]))return void o(Jf(e));e.gap=!1}const l=this.loader=n?new n(i):new s(i),c=Zf(e);e.loader=l;const d=xf(i.fragLoadPolicy.default),u={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===e.sn?1/0:Xf};e.stats=l.stats;const h={onSuccess:(t,r,i,n)=>{this.resetLoader(e,l);let s=t.data;i.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(s.slice(0,16)),s=s.slice(16)),a({frag:e,part:null,payload:s,networkDetails:n})},onError:(t,i,n,s)=>{this.resetLoader(e,l),o(new ep({type:ou.NETWORK_ERROR,details:lu.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:Su({url:r,data:void 0},t),error:new Error(`HTTP Error ${t.code} ${t.text}`),networkDetails:n,stats:s}))},onAbort:(t,r,i)=>{this.resetLoader(e,l),o(new ep({type:ou.NETWORK_ERROR,details:lu.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:i,stats:t}))},onTimeout:(t,r,i)=>{this.resetLoader(e,l),o(new ep({type:ou.NETWORK_ERROR,details:lu.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${u.timeout}ms`),networkDetails:i,stats:t}))}};t&&(h.onProgress=(r,i,n,s)=>t({frag:e,part:null,payload:n,networkDetails:s})),l.load(c,u,h)})}loadPart(e,t,r){this.abort();const i=this.config,n=i.fLoader,s=i.loader;return new Promise((a,o)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap)return void o(Jf(e,t));const l=this.loader=n?new n(i):new s(i),c=Zf(e,t);e.loader=l;const d=xf(i.fragLoadPolicy.default),u={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:Xf};t.stats=l.stats,l.load(c,u,{onSuccess:(i,n,s,o)=>{this.resetLoader(e,l),this.updateStatsFromPart(e,t);const c={frag:e,part:t,payload:i.data,networkDetails:o};r(c),a(c)},onError:(r,i,n,s)=>{this.resetLoader(e,l),o(new ep({type:ou.NETWORK_ERROR,details:lu.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:Su({url:c.url,data:void 0},r),error:new Error(`HTTP Error ${r.code} ${r.text}`),networkDetails:n,stats:s}))},onAbort:(r,i,n)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,l),o(new ep({type:ou.NETWORK_ERROR,details:lu.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:n,stats:r}))},onTimeout:(r,i,n)=>{this.resetLoader(e,l),o(new ep({type:ou.NETWORK_ERROR,details:lu.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${u.timeout}ms`),networkDetails:n,stats:r}))}})})}updateStatsFromPart(e,t){const r=e.stats,i=t.stats,n=i.total;if(r.loaded+=i.loaded,n){const i=Math.round(e.duration/t.duration),s=Math.min(Math.round(r.loaded/n),i),a=(i-s)*Math.round(r.loaded/s);r.total=r.loaded+a}else r.total=Math.max(r.loaded,r.total);const s=r.loading,a=i.loading;s.start?s.first+=a.first-a.start:(s.start=a.start,s.first=a.first),s.end=a.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}function Zf(e,t=null){const r=t||e,i={frag:e,part:t,responseType:"arraybuffer",url:r.url,headers:{},rangeStart:0,rangeEnd:0},n=r.byteRangeStartOffset,s=r.byteRangeEndOffset;if(nu(n)&&nu(s)){var a;let t=n,r=s;if("initSegment"===e.sn&&("AES-128"===(o=null==(a=e.decryptdata)?void 0:a.method)||"AES-256"===o)){const e=s-n;e%16&&(r=s+(16-e%16)),0!==n&&(i.resetIV=!0,t=n-16)}i.rangeStart=t,i.rangeEnd=r}var o;return i}function Jf(e,t){const r=new Error(`GAP ${e.gap?"tag":"attribute"} found`),i={type:ou.MEDIA_ERROR,details:lu.FRAG_GAP,fatal:!1,frag:e,error:r,networkDetails:null};return t&&(i.part=t),(t||e).stats.aborted=!0,new ep(i)}class ep extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class tp extends Tu{constructor(e,t){super(e,t),this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(e){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)}clearInterval(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)}clearNextTick(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)}tick(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}class rp{constructor(e,t,r,i=0,n=-1,s=!1){this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=e,this.sn=t,this.id=r,this.size=i,this.part=n,this.partial=s}}const ip={length:0,start:()=>0,end:()=>0};class np{static isBuffered(e,t){if(e){const r=np.getBuffered(e);for(let e=r.length;e--;)if(t>=r.start(e)&&t<=r.end(e))return!0}return!1}static bufferedRanges(e){if(e){const t=np.getBuffered(e);return np.timeRangesToArray(t)}return[]}static timeRangesToArray(e){const t=[];for(let r=0;r<e.length;r++)t.push({start:e.start(r),end:e.end(r)});return t}static bufferInfo(e,t,r){if(e){const i=np.bufferedRanges(e);if(i.length)return np.bufferedInfo(i,t,r)}return{len:0,start:t,end:t,bufferedIndex:-1}}static bufferedInfo(e,t,r){t=Math.max(0,t),e.length>1&&e.sort((e,t)=>e.start-t.start||t.end-e.end);let i=-1,n=[];if(r)for(let s=0;s<e.length;s++){t>=e[s].start&&t<=e[s].end&&(i=s);const a=n.length;if(a){const t=n[a-1].end;e[s].start-t<r?e[s].end>t&&(n[a-1].end=e[s].end):n.push(e[s])}else n.push(e[s])}else n=e;let s,a=0,o=t,l=t;for(let e=0;e<n.length;e++){const c=n[e].start,d=n[e].end;if(-1===i&&t>=c&&t<=d&&(i=e),t+r>=c&&t<d)o=c,l=d,a=l-t;else if(t+r<c){s=c;break}}return{len:a,start:o||0,end:l||0,nextStart:s,buffered:e,bufferedIndex:i}}static getBuffered(e){try{return e.buffered||ip}catch(e){return Ru.log("failed to get media.buffered",e),ip}}}const sp=/\{\$([a-zA-Z0-9-_]+)\}/g;function ap(e){return sp.test(e)}function op(e,t){if(null!==e.variableList||e.hasVariableRefs){const r=e.variableList;return t.replace(sp,t=>{const i=t.substring(2,t.length-1),n=null==r?void 0:r[i];return void 0===n?(e.playlistParsingError||(e.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${i}"`)),t):n})}return t}function lp(e,t,r){let i,n,s=e.variableList;if(s||(e.variableList=s={}),"QUERYPARAM"in t){i=t.QUERYPARAM;try{const e=new self.URL(r).searchParams;if(!e.has(i))throw new Error(`"${i}" does not match any query parameter in URI: "${r}"`);n=e.get(i)}catch(t){e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${t.message}`))}}else i=t.NAME,n=t.VALUE;i in s?e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${i}"`)):s[i]=n||""}function cp(e,t,r){const i=t.IMPORT;if(r&&i in r){let t=e.variableList;t||(e.variableList=t={}),t[i]=r[i]}else e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${i}"`))}const dp=/^(\d+)x(\d+)$/,up=/(.+?)=(".*?"|.*?)(?:,|$)/g;class hp{constructor(e,t){"string"==typeof e&&(e=hp.parseAttrList(e,t)),Eu(this,e)}get clientAttrs(){return Object.keys(this).filter(e=>"X-"===e.substring(0,2))}decimalInteger(e){const t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}hexadecimalInteger(e){if(this[e]){let t=(this[e]||"0x").slice(2);t=(1&t.length?"0":"")+t;const r=new Uint8Array(t.length/2);for(let e=0;e<t.length/2;e++)r[e]=parseInt(t.slice(2*e,2*e+2),16);return r}return null}hexadecimalIntegerAsNumber(e){const t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,t){const r=this[e];return r?parseFloat(r):t}enumeratedString(e){return this[e]}enumeratedStringList(e,t){const r=this[e];return(r?r.split(/[ ,]+/):[]).reduce((e,t)=>(e[t.toLowerCase()]=!0,e),t)}bool(e){return"YES"===this[e]}decimalResolution(e){const t=dp.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e,t){let r;const i={};for(up.lastIndex=0;null!==(r=up.exec(e));){const n=r[1].trim();let s=r[2];const a=0===s.indexOf('"')&&s.lastIndexOf('"')===s.length-1;let o=!1;if(a)s=s.slice(1,-1);else switch(n){case"IV":case"SCTE35-CMD":case"SCTE35-IN":case"SCTE35-OUT":o=!0}if(t&&(a||o))s=op(t,s);else if(!o&&!a)switch(n){case"CLOSED-CAPTIONS":if("NONE"===s)break;case"ALLOWED-CPC":case"CLASS":case"ASSOC-LANGUAGE":case"AUDIO":case"BYTERANGE":case"CHANNELS":case"CHARACTERISTICS":case"CODECS":case"DATA-ID":case"END-DATE":case"GROUP-ID":case"ID":case"IMPORT":case"INSTREAM-ID":case"KEYFORMAT":case"KEYFORMATVERSIONS":case"LANGUAGE":case"NAME":case"PATHWAY-ID":case"QUERYPARAM":case"RECENTLY-REMOVED-DATERANGES":case"SERVER-URI":case"STABLE-RENDITION-ID":case"STABLE-VARIANT-ID":case"START-DATE":case"SUBTITLES":case"SUPPLEMENTAL-CODECS":case"URI":case"VALUE":case"VIDEO":case"X-ASSET-LIST":case"X-ASSET-URI":Ru.warn(`${e}: attribute ${n} is missing quotes`)}i[n]=s}return i}}function fp(e){return"ID"!==e&&"CLASS"!==e&&"CUE"!==e&&"START-DATE"!==e&&"DURATION"!==e&&"END-DATE"!==e&&"END-ON-NEXT"!==e}function pp(e){return"SCTE35-OUT"===e||"SCTE35-IN"===e||"SCTE35-CMD"===e}class mp{constructor(e,t,r=0){var i;if(this.attr=void 0,this.tagAnchor=void 0,this.tagOrder=void 0,this._startDate=void 0,this._endDate=void 0,this._dateAtEnd=void 0,this._cue=void 0,this._badValueForSameId=void 0,this.tagAnchor=(null==t?void 0:t.tagAnchor)||null,this.tagOrder=null!=(i=null==t?void 0:t.tagOrder)?i:r,t){const r=t.attr;for(const t in r)if(Object.prototype.hasOwnProperty.call(e,t)&&e[t]!==r[t]){Ru.warn(`DATERANGE tag attribute: "${t}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=t;break}e=Eu(new hp({}),r,e)}if(this.attr=e,t?(this._startDate=t._startDate,this._cue=t._cue,this._endDate=t._endDate,this._dateAtEnd=t._dateAtEnd):this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){const e=(null==t?void 0:t.endDate)||new Date(this.attr["END-DATE"]);nu(e.getTime())&&(this._endDate=e)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get cue(){const e=this._cue;return void 0===e?this._cue=this.attr.enumeratedStringList(this.attr.CUE?"CUE":"X-CUE",{pre:!1,post:!1,once:!1}):e}get startTime(){const{tagAnchor:e}=this;return null===e||null===e.programDateTime?(Ru.warn(`Expected tagAnchor Fragment with PDT set for DateRange "${this.id}": ${e}`),NaN):e.start+(this.startDate.getTime()-e.programDateTime)/1e3}get startDate(){return this._startDate}get endDate(){const e=this._endDate||this._dateAtEnd;if(e)return e;const t=this.duration;return null!==t?this._dateAtEnd=new Date(this._startDate.getTime()+1e3*t):null}get duration(){if("DURATION"in this.attr){const e=this.attr.decimalFloatingPoint("DURATION");if(nu(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isInterstitial(){return"com.apple.hls.interstitial"===this.class}get isValid(){return!!this.id&&!this._badValueForSameId&&nu(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)&&(!this.attr.CUE||!this.cue.pre&&!this.cue.post||this.cue.pre!==this.cue.post)&&(!this.isInterstitial||"X-ASSET-URI"in this.attr||"X-ASSET-LIST"in this.attr)}}class gp{constructor(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.dateRangeTagCount=0,this.live=!0,this.requestScheduled=-1,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.appliedTimelineOffset=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}reloaded(e){if(!e)return this.advanced=!0,void(this.updated=!0);const t=this.lastPartSn-e.lastPartSn,r=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!r||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||0===t&&r>0,this.updated||this.advanced?this.misses=Math.floor(.6*e.misses):this.misses=e.misses+1}hasKey(e){return this.encryptedFragments.some(t=>{let r=t.decryptdata;return r||(t.setKeyFormat(e.keyFormat),r=t.decryptdata),!!r&&e.matches(r)})}get hasProgramDateTime(){return!!this.fragments.length&&nu(this.fragments[this.fragments.length-1].programDateTime)}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||10}get drift(){const e=this.driftEndTime-this.driftStartTime;if(e>0){return 1e3*(this.driftEnd-this.driftStart)/e}return 1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){return this.fragments.length?this.fragments[this.fragments.length-1].end:0}get fragmentStart(){return this.fragments.length?this.fragments[0].start:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].index:-1}get maxPartIndex(){const e=this.partList;if(e){const t=this.lastPartIndex;if(-1!==t){for(let r=e.length;r--;)if(e[r].index>t)return e[r].index;return t}}return 0}get lastPartSn(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}get expired(){if(this.live&&this.age&&this.misses<3){const e=this.partEnd-this.fragmentStart;return this.age>Math.max(e,this.totalduration)+this.levelTargetDuration}return!1}}function vp(e,t){return e.length===t.length&&!e.some((e,r)=>e!==t[r])}function yp(e,t){return!e&&!t||!(!e||!t)&&vp(e,t)}function bp(e){return"AES-128"===e||"AES-256"===e||"AES-256-CTR"===e}function Ep(e){switch(e){case"AES-128":case"AES-256":return Hf;case"AES-256-CTR":return Vf;default:throw new Error(`invalid full segment method ${e}`)}}function wp(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0))}function Sp(e){return Uint8Array.from(unescape(encodeURIComponent(e)),e=>e.charCodeAt(0))}function Tp(e){const t=function(e,t,r){const i=e[t];e[t]=e[r],e[r]=i};t(e,0,3),t(e,1,2),t(e,4,5),t(e,6,7)}function xp(e){const t=e.split(":");let r=null;if("data"===t[0]&&2===t.length){const e=t[1].split(";"),i=e[e.length-1].split(",");if(2===i.length){const t="base64"===i[0],n=i[1];t?(e.splice(-1,1),r=wp(n)):r=function(e){const t=Sp(e).subarray(0,16),r=new Uint8Array(16);return r.set(t,16-t.length),r}(n)}}return r}const Ap="undefined"!=typeof self?self:void 0;var kp={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Ip="org.w3.clearkey",Lp="com.apple.streamingkeydelivery",Rp="com.microsoft.playready",Pp="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function Cp(e){switch(e){case Lp:return kp.FAIRPLAY;case Rp:return kp.PLAYREADY;case Pp:return kp.WIDEVINE;case Ip:return kp.CLEARKEY}}function Dp(e){switch(e){case kp.FAIRPLAY:return Lp;case kp.PLAYREADY:return Rp;case kp.WIDEVINE:return Pp;case kp.CLEARKEY:return Ip}}function _p(e){const{drmSystems:t,widevineLicenseUrl:r}=e,i=t?[kp.FAIRPLAY,kp.WIDEVINE,kp.PLAYREADY,kp.CLEARKEY].filter(e=>!!t[e]):[];return!i[kp.WIDEVINE]&&r&&i.push(kp.WIDEVINE),i}const Op=null!=Ap&&null!=(Mp=Ap.navigator)&&Mp.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;var Mp;function Np(e){const t=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),r=String.fromCharCode.apply(null,Array.from(t)),i=r.substring(r.indexOf("<"),r.length),n=(new DOMParser).parseFromString(i,"text/xml").getElementsByTagName("KID")[0];if(n){const e=n.childNodes[0]?n.childNodes[0].nodeValue:n.getAttribute("VALUE");if(e){const t=wp(e).subarray(0,16);return Tp(t),t}}return null}let Fp={};class $p{static clearKeyUriToKeyIdMap(){Fp={}}static setKeyIdForUri(e,t){Fp[e]=t}static addKeyIdForUri(e){const t=Object.keys(Fp).length%Number.MAX_SAFE_INTEGER,r=new Uint8Array(16);return new DataView(r.buffer,12,4).setUint32(0,t),Fp[e]=r,r}constructor(e,t,r,i=[1],n=null,s){this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=e,this.uri=t,this.keyFormat=r,this.keyFormatVersions=i,this.iv=n,this.encrypted=!!e&&"NONE"!==e,this.isCommonEncryption=this.encrypted&&!bp(e),null!=s&&s.startsWith("0x")&&(this.keyId=new Uint8Array(Ou(s)))}matches(e){return e.uri===this.uri&&e.method===this.method&&e.encrypted===this.encrypted&&e.keyFormat===this.keyFormat&&vp(e.keyFormatVersions,this.keyFormatVersions)&&yp(e.iv,this.iv)&&yp(e.keyId,this.keyId)}isSupported(){if(this.method){if(bp(this.method)||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method;switch(this.keyFormat){case Lp:case Pp:case Rp:case Ip:return-1!==["SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)}}return!1}getDecryptData(e,t){if(!this.encrypted||!this.uri)return null;if(bp(this.method)){let t=this.iv;t||("number"!=typeof e&&(Ru.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0),t=function(e){const t=new Uint8Array(16);for(let r=12;r<16;r++)t[r]=e>>8*(15-r)&255;return t}(e));return new $p(this.method,this.uri,"identity",this.keyFormatVersions,t)}if(this.keyId){const e=Fp[this.uri];if(e&&!vp(this.keyId,e)&&$p.setKeyIdForUri(this.uri,this.keyId),this.pssh)return this}const r=xp(this.uri);if(r)switch(this.keyFormat){case Pp:if(this.pssh=r,!this.keyId){const e=function(e){const t=[];if(e instanceof ArrayBuffer){const r=e.byteLength;let i=0;for(;i+32<r;){const r=xh(new DataView(e,i));t.push(r),i+=r.size}}return t}(r.buffer);if(e.length){var i;const t=e[0];this.keyId=null!=(i=t.kids)&&i.length?t.kids[0]:null}}this.keyId||(this.keyId=Bp(t));break;case Rp:{const e=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=Th(e,0,r),this.keyId=Np(r);break}default:{let e=r.subarray(0,16);if(16!==e.length){const t=new Uint8Array(16);t.set(e,16-e.length),e=t}this.keyId=e;break}}if(!this.keyId||16!==this.keyId.byteLength){let e;e=function(e){const t=null==e?void 0:e[Pp];if(t)return t.keyId;return null}(t),e||(e=Bp(t),e||(e=Fp[this.uri])),e&&(this.keyId=e,$p.setKeyIdForUri(this.uri,e))}return this}}function Bp(e){const t=null==e?void 0:e[Rp];if(t){const e=xp(t.uri);if(e)return Np(e)}return null}const Up=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,zp=/#EXT-X-MEDIA:(.*)/g,Gp=/^#EXT(?:INF|-X-TARGETDURATION):/m,jp=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),Hp=new RegExp([/#EXT-X-(PROGRAM-DATE-TIME|BYTERANGE|DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|"));class Vp{static findGroup(e,t){for(let r=0;r<e.length;r++){const i=e[r];if(i.id===t)return i}}static resolve(e,t){return ju.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return Gp.test(e)}static parseMasterPlaylist(e,t){const r={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:ap(e)},i=[];if(Up.lastIndex=0,!e.startsWith("#EXTM3U"))return r.playlistParsingError=new Error("no EXTM3U delimiter"),r;let n;for(;null!=(n=Up.exec(e));)if(n[1]){var s;const e=new hp(n[1],r),a=op(r,n[2]),o={attrs:e,bitrate:e.decimalInteger("BANDWIDTH")||e.decimalInteger("AVERAGE-BANDWIDTH"),name:e.NAME,url:Vp.resolve(a,t)},l=e.decimalResolution("RESOLUTION");l&&(o.width=l.width,o.height=l.height),Xp(e.CODECS,o);const c=e["SUPPLEMENTAL-CODECS"];c&&(o.supplemental={},Xp(c,o.supplemental)),null!=(s=o.unknownCodecs)&&s.length||i.push(o),r.levels.push(o)}else if(n[3]){const e=n[3],i=n[4];switch(e){case"SESSION-DATA":{const e=new hp(i,r),t=e["DATA-ID"];t&&(null===r.sessionData&&(r.sessionData={}),r.sessionData[t]=e);break}case"SESSION-KEY":{const e=Kp(i,t,r);e.encrypted&&e.isSupported()?(null===r.sessionKeys&&(r.sessionKeys=[]),r.sessionKeys.push(e)):Ru.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${i}"`);break}case"DEFINE":lp(r,new hp(i,r),t);break;case"CONTENT-STEERING":{const e=new hp(i,r);r.contentSteering={uri:Vp.resolve(e["SERVER-URI"],t),pathwayId:e["PATHWAY-ID"]||"."};break}case"START":r.startTimeOffset=qp(i)}}const a=i.length>0&&i.length<r.levels.length;return r.levels=a?i:r.levels,0===r.levels.length&&(r.playlistParsingError=new Error("no levels found in manifest")),r}static parseMasterPlaylistMedia(e,t,r){let i;const n={},s=r.levels,a={AUDIO:s.map(e=>({id:e.attrs.AUDIO,audioCodec:e.audioCodec})),SUBTITLES:s.map(e=>({id:e.attrs.SUBTITLES,textCodec:e.textCodec})),"CLOSED-CAPTIONS":[]};let o=0;for(zp.lastIndex=0;null!==(i=zp.exec(e));){const e=new hp(i[1],r),s=e.TYPE;if(s){const r=a[s],i=n[s]||[];n[s]=i;const l=e.LANGUAGE,c=e["ASSOC-LANGUAGE"],d=e.CHANNELS,u=e.CHARACTERISTICS,h=e["INSTREAM-ID"],f={attrs:e,bitrate:0,id:o++,groupId:e["GROUP-ID"]||"",name:e.NAME||l||"",type:s,default:e.bool("DEFAULT"),autoselect:e.bool("AUTOSELECT"),forced:e.bool("FORCED"),lang:l,url:e.URI?Vp.resolve(e.URI,t):""};if(c&&(f.assocLang=c),d&&(f.channels=d),u&&(f.characteristics=u),h&&(f.instreamId=h),null!=r&&r.length){const e=Vp.findGroup(r,f.groupId)||r[0];Qp(f,e,"audioCodec"),Qp(f,e,"textCodec")}i.push(f)}}return n}static parseLevelPlaylist(e,t,r,i,n,s){var a;const o={url:t},l=new gp(t),c=l.fragments,d=[];let u,h,f,p,m=null,g=0,v=0,y=0,b=0,E=0,w=null,S=new Xu(i,o),T=-1,x=!1,A=null;if(jp.lastIndex=0,l.m3u8=e,l.hasVariableRefs=ap(e),"#EXTM3U"!==(null==(a=jp.exec(e))?void 0:a[0]))return l.playlistParsingError=new Error("Missing format identifier #EXTM3U"),l;for(;null!==(u=jp.exec(e));){x&&(x=!1,S=new Xu(i,o),S.playlistOffset=y,S.setStart(y),S.sn=g,S.cc=b,E&&(S.bitrate=E),S.level=r,m&&(S.initSegment=m,m.rawProgramDateTime&&(S.rawProgramDateTime=m.rawProgramDateTime,m.rawProgramDateTime=null),A&&(S.setByteRange(A),A=null)));const e=u[1];if(e){S.duration=parseFloat(e);const t=(" "+u[2]).slice(1);S.title=t||null,S.tagList.push(t?["INF",e,t]:["INF",e])}else if(u[3]){if(nu(S.duration)){S.playlistOffset=y,S.setStart(y),f&&em(S,f,l),S.sn=g,S.level=r,S.cc=b,c.push(S);const e=(" "+u[3]).slice(1);S.relurl=op(l,e),Zp(S,w,d),w=S,y+=S.duration,g++,v=0,x=!0}}else{if(u=u[0].match(Hp),!u){Ru.warn("No matches on slow regex match for level playlist!");continue}for(h=1;h<u.length&&void 0===u[h];h++);const e=(" "+u[h]).slice(1),n=(" "+u[h+1]).slice(1),a=u[h+2]?(" "+u[h+2]).slice(1):null;switch(e){case"BYTERANGE":w?S.setByteRange(n,w):S.setByteRange(n);break;case"PROGRAM-DATE-TIME":S.rawProgramDateTime=n,S.tagList.push(["PROGRAM-DATE-TIME",n]),-1===T&&(T=c.length);break;case"PLAYLIST-TYPE":l.type&&tm(l,e,u),l.type=n.toUpperCase();break;case"MEDIA-SEQUENCE":0!==l.startSN?tm(l,e,u):c.length>0&&rm(l,e,u),g=l.startSN=parseInt(n);break;case"SKIP":{l.skippedSegments&&tm(l,e,u);const t=new hp(n,l),r=t.decimalInteger("SKIPPED-SEGMENTS");if(nu(r)){l.skippedSegments+=r;for(let e=r;e--;)c.push(null);g+=r}const i=t.enumeratedString("RECENTLY-REMOVED-DATERANGES");i&&(l.recentlyRemovedDateranges=(l.recentlyRemovedDateranges||[]).concat(i.split("\t")));break}case"TARGETDURATION":0!==l.targetduration&&tm(l,e,u),l.targetduration=Math.max(parseInt(n),1);break;case"VERSION":null!==l.version&&tm(l,e,u),l.version=parseInt(n);break;case"INDEPENDENT-SEGMENTS":break;case"ENDLIST":l.live||tm(l,e,u),l.live=!1;break;case"#":(n||a)&&S.tagList.push(a?[n,a]:[n]);break;case"DISCONTINUITY":b++,S.tagList.push(["DIS"]);break;case"GAP":S.gap=!0,S.tagList.push([e]);break;case"BITRATE":S.tagList.push([e,n]),E=1e3*parseInt(n),nu(E)?S.bitrate=E:E=0;break;case"DATERANGE":{const e=new hp(n,l),t=new mp(e,l.dateRanges[e.ID],l.dateRangeTagCount);l.dateRangeTagCount++,t.isValid||l.skippedSegments?l.dateRanges[t.id]=t:Ru.warn(`Ignoring invalid DATERANGE tag: "${n}"`),S.tagList.push(["EXT-X-DATERANGE",n]);break}case"DEFINE":{const e=new hp(n,l);"IMPORT"in e?cp(l,e,s):lp(l,e,t)}break;case"DISCONTINUITY-SEQUENCE":0!==l.startCC?tm(l,e,u):c.length>0&&rm(l,e,u),l.startCC=b=parseInt(n);break;case"KEY":{const e=Kp(n,t,l);if(e.isSupported()){if("NONE"===e.method){f=void 0;break}f||(f={});const t=f[e.keyFormat];null!=t&&t.matches(e)||(t&&(f=Eu({},f)),f[e.keyFormat]=e)}else Ru.warn(`[Keys] Ignoring unsupported EXT-X-KEY tag: "${n}"`);break}case"START":l.startTimeOffset=qp(n);break;case"MAP":{const e=new hp(n,l);if(S.duration){const t=new Xu(i,o);Jp(t,e,r,f),m=t,S.initSegment=m,m.rawProgramDateTime&&!S.rawProgramDateTime&&(S.rawProgramDateTime=m.rawProgramDateTime)}else{const t=S.byteRangeEndOffset;if(t){const e=S.byteRangeStartOffset;A=`${t-e}@${e}`}else A=null;Jp(S,e,r,f),m=S,x=!0}m.cc=b;break}case"SERVER-CONTROL":p&&tm(l,e,u),p=new hp(n),l.canBlockReload=p.bool("CAN-BLOCK-RELOAD"),l.canSkipUntil=p.optionalFloat("CAN-SKIP-UNTIL",0),l.canSkipDateRanges=l.canSkipUntil>0&&p.bool("CAN-SKIP-DATERANGES"),l.partHoldBack=p.optionalFloat("PART-HOLD-BACK",0),l.holdBack=p.optionalFloat("HOLD-BACK",0);break;case"PART-INF":{l.partTarget&&tm(l,e,u);const t=new hp(n);l.partTarget=t.decimalFloatingPoint("PART-TARGET");break}case"PART":{let e=l.partList;e||(e=l.partList=[]);const t=v>0?e[e.length-1]:void 0,r=v++,i=new hp(n,l),s=new Qu(i,S,o,r,t);e.push(s),S.duration+=s.duration;break}case"PRELOAD-HINT":{const e=new hp(n,l);l.preloadHint=e;break}case"RENDITION-REPORT":{const e=new hp(n,l);l.renditionReports=l.renditionReports||[],l.renditionReports.push(e);break}default:Ru.warn(`line parsed but not handled: ${u}`)}}}w&&!w.relurl?(c.pop(),y-=w.duration,l.partList&&(l.fragmentHint=w)):l.partList&&(Zp(S,w,d),S.cc=b,l.fragmentHint=S,f&&em(S,f,l)),l.targetduration||(l.playlistParsingError=new Error("Missing Target Duration"));const k=c.length,I=c[0],L=c[k-1];if(y+=l.skippedSegments*l.targetduration,y>0&&k&&L){l.averagetargetduration=y/k;const e=L.sn;l.endSN="initSegment"!==e?e:0,l.live||(L.endList=!0),T>0&&(!function(e,t){let r=e[t];for(let i=t;i--;){const t=e[i];if(!t)return;t.programDateTime=r.programDateTime-1e3*t.duration,r=t}}(c,T),I&&d.unshift(I))}return l.fragmentHint&&(y+=l.fragmentHint.duration),l.totalduration=y,d.length&&l.dateRangeTagCount&&I&&Wp(d,l),l.endCC=b,l}}function Wp(e,t){let r=e.length;if(!r){if(!t.hasProgramDateTime)return;{const i=t.fragments[t.fragments.length-1];e.push(i),r++}}const i=e[r-1],n=t.live?1/0:t.totalduration,s=Object.keys(t.dateRanges);for(let o=s.length;o--;){const l=t.dateRanges[s[o]],c=l.startDate.getTime();l.tagAnchor=i.ref;for(let i=r;i--;){var a;if((null==(a=e[i])?void 0:a.sn)<t.startSN)break;const r=Yp(t,c,e,i,n);if(-1!==r){l.tagAnchor=t.fragments[r].ref;break}}}}function Yp(e,t,r,i,n){const s=r[i];if(s){const o=s.programDateTime;if(t>=o||0===i){var a;if(t<=o+1e3*(((null==(a=r[i+1])?void 0:a.start)||n)-s.start)){const n=r[i].sn-e.startSN;if(n<0)return-1;const s=e.fragments;if(s.length>r.length){for(let a=(r[i+1]||s[s.length-1]).sn-e.startSN;a>n;a--){const e=s[a].programDateTime;if(t>=e&&t<e+1e3*s[a].duration)return a}}return n}}}return-1}function Kp(e,t,r){var i,n;const s=new hp(e,r),a=null!=(i=s.METHOD)?i:"",o=s.URI,l=s.hexadecimalInteger("IV"),c=s.KEYFORMATVERSIONS,d=null!=(n=s.KEYFORMAT)?n:"identity";o&&s.IV&&!l&&Ru.error(`Invalid IV: ${s.IV}`);const u=o?Vp.resolve(o,t):"",h=(c||"1").split("/").map(Number).filter(Number.isFinite);return new $p(a,u,d,h,l,s.KEYID)}function qp(e){const t=new hp(e).decimalFloatingPoint("TIME-OFFSET");return nu(t)?t:null}function Xp(e,t){let r=(e||"").split(/[ ,]+/).filter(e=>e);["video","audio","text"].forEach(e=>{const i=r.filter(t=>Ih(t,e));i.length&&(t[`${e}Codec`]=i.map(e=>e.split("/")[0]).join(","),r=r.filter(e=>-1===i.indexOf(e)))}),t.unknownCodecs=r}function Qp(e,t,r){const i=t[r];i&&(e[r]=i)}function Zp(e,t,r){e.rawProgramDateTime?r.push(e):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime)}function Jp(e,t,r,i){e.relurl=t.URI,t.BYTERANGE&&e.setByteRange(t.BYTERANGE),e.level=r,e.sn="initSegment",i&&(e.levelkeys=i),e.initSegment=null}function em(e,t,r){e.levelkeys=t;const{encryptedFragments:i}=r;i.length&&i[i.length-1].levelkeys===t||!Object.keys(t).some(e=>t[e].isCommonEncryption)||i.push(e)}function tm(e,t,r){e.playlistParsingError=new Error(`#EXT-X-${t} must not appear more than once (${r[0]})`)}function rm(e,t,r){e.playlistParsingError=new Error(`#EXT-X-${t} must appear before the first Media Segment (${r[0]})`)}function im(e,t){const r=t.startPTS;if(nu(r)){let i,n=0;t.sn>e.sn?(n=r-e.start,i=e):(n=e.start-r,i=t),i.duration!==n&&i.setDuration(n)}else if(t.sn>e.sn){e.cc===t.cc&&e.minEndPTS?t.setStart(e.start+(e.minEndPTS-e.start)):t.setStart(e.start+e.duration)}else t.setStart(Math.max(e.start-t.duration,0))}function nm(e,t,r,i,n,s,a){i-r<=0&&(a.warn("Fragment should have a positive duration",t),i=r+t.duration,s=n+t.duration);let o=r,l=i;const c=t.startPTS,d=t.endPTS;if(nu(c)){const u=Math.abs(c-r);e&&u>e.totalduration?a.warn(`media timestamps and playlist times differ by ${u}s for level ${t.level} ${e.url}`):nu(t.deltaPTS)?t.deltaPTS=Math.max(u,t.deltaPTS):t.deltaPTS=u,o=Math.max(r,c),r=Math.min(r,c),n=void 0!==t.startDTS?Math.min(n,t.startDTS):n,l=Math.min(i,d),i=Math.max(i,d),s=void 0!==t.endDTS?Math.max(s,t.endDTS):s}const u=r-t.start;0!==t.start&&t.setStart(r),t.setDuration(i-t.start),t.startPTS=r,t.maxStartPTS=o,t.startDTS=n,t.endPTS=i,t.minEndPTS=l,t.endDTS=s;const h=t.sn;if(!e||h<e.startSN||h>e.endSN)return 0;let f;const p=h-e.startSN,m=e.fragments;for(m[p]=t,f=p;f>0;f--)im(m[f],m[f-1]);for(f=p;f<m.length-1;f++)im(m[f],m[f+1]);return e.fragmentHint&&im(m[m.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,u}function sm(e,t,r){if(e===t)return;let i=null;const n=e.fragments;for(let e=n.length-1;e>=0;e--){const t=n[e].initSegment;if(t){i=t;break}}let s;e.fragmentHint&&delete e.fragmentHint.endPTS,function(e,t,r){const i=t.skippedSegments,n=Math.max(e.startSN,t.startSN)-t.startSN,s=(e.fragmentHint?1:0)+(i?t.endSN:Math.min(e.endSN,t.endSN))-t.startSN,a=t.startSN-e.startSN,o=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,l=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments;for(let c=n;c<=s;c++){const n=l[a+c];let s=o[c];if(i&&!s&&n&&(s=t.fragments[c]=n),n&&s){r(n,s,c,o);const i=n.relurl,a=s.relurl;if(i&&pm(i,a))return void(t.playlistParsingError=am(`media sequence mismatch ${s.sn}:`,e,t,n,s));if(n.cc!==s.cc)return void(t.playlistParsingError=am(`discontinuity sequence mismatch (${n.cc}!=${s.cc})`,e,t,n,s))}}}(e,t,(e,r,n,a)=>{if((!t.startCC||t.skippedSegments)&&r.cc!==e.cc){const i=e.cc-r.cc;for(let e=n;e<a.length;e++)a[e].cc+=i;t.endCC=a[a.length-1].cc}nu(e.startPTS)&&nu(e.endPTS)&&(r.setStart(r.startPTS=e.startPTS),r.startDTS=e.startDTS,r.maxStartPTS=e.maxStartPTS,r.endPTS=e.endPTS,r.endDTS=e.endDTS,r.minEndPTS=e.minEndPTS,r.setDuration(e.endPTS-e.startPTS),r.duration&&(s=r),t.PTSKnown=t.alignedSliding=!0),e.hasStreams&&(r.elementaryStreams=e.elementaryStreams),r.loader=e.loader,e.hasStats&&(r.stats=e.stats),e.initSegment&&(r.initSegment=e.initSegment,i=e.initSegment)});const a=t.fragments,o=t.fragmentHint?a.concat(t.fragmentHint):a;if(i&&o.forEach(e=>{var t;!e||e.initSegment&&e.initSegment.relurl!==(null==(t=i)?void 0:t.relurl)||(e.initSegment=i)}),t.skippedSegments){if(t.deltaUpdateFailed=a.some(e=>!e),t.deltaUpdateFailed){r.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let e=t.skippedSegments;e--;)a.shift();t.startSN=a[0].sn}else{t.canSkipDateRanges&&(t.dateRanges=function(e,t,r){const{dateRanges:i,recentlyRemovedDateranges:n}=t,s=Eu({},e);n&&n.forEach(e=>{delete s[e]});const a=Object.keys(s).length;if(!a)return i;return Object.keys(i).forEach(e=>{const t=s[e],n=new mp(i[e].attr,t);n.isValid?(s[e]=n,t||(n.tagOrder+=a)):r.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${sf(i[e].attr)}"`)}),s}(e.dateRanges,t,r));const i=e.fragments.filter(e=>e.rawProgramDateTime);if(e.hasProgramDateTime&&!t.hasProgramDateTime)for(let e=1;e<o.length;e++)null===o[e].programDateTime&&Zp(o[e],o[e-1],i);Wp(i,t)}t.endCC=a[a.length-1].cc}if(!t.startCC){var l;const r=dm(e,t.startSN-1);t.startCC=null!=(l=null==r?void 0:r.cc)?l:a[0].cc}!function(e,t,r){if(e&&t){let i=0;for(let n=0,s=e.length;n<=s;n++){const s=e[n],a=t[n+i];s&&a&&s.index===a.index&&s.fragment.sn===a.fragment.sn?r(s,a):i--}}}(e.partList,t.partList,(e,t)=>{t.elementaryStreams=e.elementaryStreams,t.stats=e.stats}),s?nm(t,s,s.startPTS,s.endPTS,s.startDTS,s.endDTS,r):om(e,t),a.length&&(t.totalduration=t.edge-a[0].start),t.driftStartTime=e.driftStartTime,t.driftStart=e.driftStart;const c=t.advancedDateTime;if(t.advanced&&c){const e=t.edge;t.driftStart||(t.driftStartTime=c,t.driftStart=e),t.driftEndTime=c,t.driftEnd=e}else t.driftEndTime=e.driftEndTime,t.driftEnd=e.driftEnd,t.advancedDateTime=e.advancedDateTime;-1===t.requestScheduled&&(t.requestScheduled=e.requestScheduled)}function am(e,t,r,i,n){return new Error(`${e} ${n.url}\nPlaylist starting @${t.startSN}\n${t.m3u8}\n\nPlaylist starting @${r.startSN}\n${r.m3u8}`)}function om(e,t,r=!0){const i=t.startSN+t.skippedSegments-e.startSN,n=e.fragments,s=i>=0;let a=0;if(s&&i<n.length)a=n[i].start;else if(s&&t.startSN===e.endSN+1)a=e.fragmentEnd;else if(s&&r)a=e.fragmentStart+i*t.levelTargetDuration;else{if(t.skippedSegments||0!==t.fragmentStart)return;a=e.fragmentStart}lm(t,a)}function lm(e,t){if(t){const r=e.fragments;for(let i=e.skippedSegments;i<r.length;i++)r[i].addStart(t);e.fragmentHint&&e.fragmentHint.addStart(t)}}function cm(e,t=1/0){let r=1e3*e.targetduration;if(e.updated){const i=e.fragments,n=4;if(i.length&&r*n>t){const e=1e3*i[i.length-1].duration;e<r&&(r=e)}}else r/=2;return Math.round(r)}function dm(e,t,r){if(!e)return null;let i=e.fragments[t-e.startSN];return i||(i=e.fragmentHint,i&&i.sn===t?i:t<e.startSN&&r&&r.sn===t?r:null)}function um(e,t,r){return e?hm(e.partList,t,r):null}function hm(e,t,r){if(e)for(let i=e.length;i--;){const n=e[i];if(n.index===r&&n.fragment.sn===t)return n}return null}function fm(e){e.forEach((e,t)=>{var r;null==(r=e.details)||r.fragments.forEach(e=>{e.level=t,e.initSegment&&(e.initSegment.level=t)})})}function pm(e,t){return!(e===t||!t)&&mm(e)!==mm(t)}function mm(e){return e.replace(/\?[^?]*$/,"")}function gm(e,t){for(let i=0,n=e.length;i<n;i++){var r;if((null==(r=e[i])?void 0:r.cc)===t)return e[i]}return null}function vm(e,t){const r=e.start+t;e.startPTS=r,e.setStart(r),e.endPTS=r+e.duration}function ym(e,t){const r=t.fragments;for(let t=0,i=r.length;t<i;t++)vm(r[t],e);t.fragmentHint&&vm(t.fragmentHint,e),t.alignedSliding=!0}function bm(e,t){if(!function(e,t){return!!(e&&t.startCC<e.endCC&&t.endCC>e.startCC)}(t,e))return;const r=Math.min(t.endCC,e.endCC),i=gm(t.fragments,r),n=gm(e.fragments,r);if(!i||!n)return;Ru.log(`Aligning playlist at start of dicontinuity sequence ${r}`);ym(i.start-n.start,e)}function Em(e,t){if(!e.hasProgramDateTime||!t.hasProgramDateTime)return;const r=e.fragments,i=t.fragments;if(!r.length||!i.length)return;let n,s;const a=Math.min(t.endCC,e.endCC);t.startCC<a&&e.startCC<a&&(n=gm(i,a),s=gm(r,a)),n&&s||(n=i[Math.floor(i.length/2)],s=gm(r,n.cc)||r[Math.floor(r.length/2)]);const o=n.programDateTime,l=s.programDateTime;if(!o||!l)return;ym((l-o)/1e3-(s.start-n.start),e)}function wm(e,t,r){Sm(e,t,r),e.addEventListener(t,r)}function Sm(e,t,r){e.removeEventListener(t,r)}const Tm=function(e){let t="";const r=e.length;for(let i=0;i<r;i++)t+=`[${e.start(i).toFixed(3)}-${e.end(i).toFixed(3)}]`;return t},xm="STOPPED",Am="IDLE",km="KEY_LOADING",Im="FRAG_LOADING",Lm="FRAG_LOADING_WAITING_RETRY",Rm="WAITING_TRACK",Pm="PARSING",Cm="PARSED",Dm="ENDED",_m="ERROR",Om="WAITING_INIT_PTS",Mm="WAITING_LEVEL";class Nm extends tp{constructor(e,t,r,i,n){super(i,e.logger),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=xm,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.buffering=!0,this.loadingParts=!1,this.loopSn=void 0,this.onMediaSeeking=()=>{const{config:e,fragCurrent:t,media:r,mediaBuffer:i,state:n}=this,s=r?r.currentTime:0,a=np.bufferInfo(i||r,s,e.maxBufferHole),o=!a.len;if(this.log(`Media seeking to ${nu(s)?s.toFixed(3):s}, state: ${n}, ${o?"out of":"in"} buffer`),this.state===Dm)this.resetLoadingState();else if(t){const r=e.maxFragLookUpTolerance,i=t.start-r,n=t.start+t.duration+r;if(o||n<a.start||i>a.end){const e=s>n;(s<i||e)&&(e&&t.loader&&(this.log(`Cancelling fragment load for seek (sn: ${t.sn})`),t.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}if(r){this.fragmentTracker.removeFragmentsInRange(s,1/0,this.playlistType,!0);if(s>this.lastCurrentTime&&(this.lastCurrentTime=s),!this.loadingParts){const e=Math.max(a.end,s),t=this.shouldLoadParts(this.getLevelDetails(),e);t&&(this.log(`LL-Part loading ON after seeking to ${s.toFixed(2)} with buffer @${e.toFixed(2)}`),this.loadingParts=t)}}this.hls.hasEnoughToStart||(this.log(`Setting ${o?"startPosition":"nextLoadPosition"} to ${s} for seek without enough to start`),this.nextLoadPosition=s,o&&(this.startPosition=s)),o&&this.state===Am&&this.tickImmediate()},this.onMediaEnded=()=>{this.log("setting startPosition to 0 because media ended"),this.startPosition=this.lastCurrentTime=0},this.playlistType=n,this.hls=e,this.fragmentLoader=new Qf(e.config),this.keyLoader=r,this.fragmentTracker=t,this.config=e.config,this.decrypter=new qf(e.config)}registerListeners(){const{hls:e}=this;e.on(cu.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(cu.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(cu.MANIFEST_LOADING,this.onManifestLoading,this),e.on(cu.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(cu.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(cu.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(cu.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(cu.MANIFEST_LOADING,this.onManifestLoading,this),e.off(cu.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(cu.ERROR,this.onError,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){if(this.state===xm)return;this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);const e=this.fragCurrent;null!=e&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=xm}get startPositionValue(){const{nextLoadPosition:e,startPosition:t}=this;return-1===t&&e?e:t}get bufferingEnabled(){return this.buffering}pauseBuffering(){this.buffering=!1}resumeBuffering(){this.buffering=!0}get inFlightFrag(){return{frag:this.fragCurrent,state:this.state}}_streamEnded(e,t){if(t.live||!this.media)return!1;const r=e.end||0,i=this.config.timelineOffset||0;if(r<=i)return!1;const n=e.buffered;this.config.maxBufferHole&&n&&n.length>1&&(e=np.bufferedInfo(n,e.start,0));const s=e.nextStart;if(s&&s>i&&s<t.edge)return!1;if(this.media.currentTime<e.start)return!1;const a=t.partList;if(null!=a&&a.length){const e=a[a.length-1];return np.isBuffered(this.media,e.start+e.duration/2)}const o=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(o)}getLevelDetails(){if(this.levels&&null!==this.levelLastLoaded)return this.levelLastLoaded.details}get timelineOffset(){const e=this.config.timelineOffset;var t;return e?(null==(t=this.getLevelDetails())?void 0:t.appliedTimelineOffset)||e:0}onMediaAttached(e,t){const r=this.media=this.mediaBuffer=t.media;wm(r,"seeking",this.onMediaSeeking),wm(r,"ended",this.onMediaEnded);const i=this.config;this.levels&&i.autoStartLoad&&this.state===xm&&this.startLoad(i.startPosition)}onMediaDetaching(e,t){const r=!!t.transferMedia,i=this.media;if(null!==i){if(i.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),Sm(i,"seeking",this.onMediaSeeking),Sm(i,"ended",this.onMediaEnded),this.keyLoader&&!r&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loopSn=void 0,r)return this.resetLoadingState(),void this.resetTransmuxer();this.loadingParts=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}}onManifestLoading(){this.initPTS=[],this.levels=this.levelLastLoaded=this.fragCurrent=null,this.lastCurrentTime=this.startPosition=0,this.startFragRequested=!1}onError(e,t){}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset}onHandlerDestroying(){this.stopLoad(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),super.onHandlerDestroying(),this.hls=this.onMediaSeeking=this.onMediaEnded=null}onHandlerDestroyed(){this.state=xm,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed()}loadFragment(e,t,r){this.startFragRequested=!0,this._loadFragForPlayback(e,t,r)}_loadFragForPlayback(e,t,r){this._doFragLoad(e,t,r,e=>{const t=e.frag;if(this.fragContextChanged(t))return this.warn(`${t.type} sn: ${t.sn}${e.part?" part: "+e.part.index:""} of ${this.fragInfo(t,!1,e.part)}) was dropped during download.`),void this.fragmentTracker.removeFragment(t);t.stats.chunkCount++,this._handleFragmentLoadProgress(e)}).then(e=>{if(!e)return;const t=this.state,r=e.frag;this.fragContextChanged(r)?(t===Im||!this.fragCurrent&&t===Pm)&&(this.fragmentTracker.removeFragment(r),this.state=Am):("payload"in e&&(this.log(`Loaded ${r.type} sn: ${r.sn} of ${this.playlistLabel()} ${r.level}`),this.hls.trigger(cu.FRAG_LOADED,e)),this._handleFragmentLoadComplete(e))}).catch(t=>{this.state!==xm&&this.state!==_m&&(this.warn(`Frag error: ${(null==t?void 0:t.message)||t}`),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var t;const{fragmentTracker:r}=this;if(r.getState(e)===Ff){const t=e.type,i=this.getFwdBufferInfo(this.mediaBuffer,t),n=Math.max(e.duration,i?i.len:this.config.maxBufferLength),s=this.backtrackFragment;(1===(s?e.sn-s.sn:0)||this.reduceMaxBufferLength(n,e.duration))&&r.removeFragment(e)}else 0===(null==(t=this.mediaBuffer)?void 0:t.buffered.length)?r.removeAllFragments():r.hasParts(e.type)&&(r.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),r.getState(e)===$f&&r.removeFragment(e))}checkLiveUpdate(e){if(e.updated&&!e.live){const t=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)}waitForLive(e){const t=e.details;return(null==t?void 0:t.live)&&"EVENT"!==t.type&&(this.levelLastLoaded!==e||t.expired)}flushMainBuffer(e,t,r=null){if(!(e-t))return;const i={startOffset:e,endOffset:t,type:r};this.hls.trigger(cu.BUFFER_FLUSHING,i)}_loadInitSegment(e,t){this._doFragLoad(e,t).then(e=>{const t=null==e?void 0:e.frag;if(!t||this.fragContextChanged(t)||!this.levels)throw new Error("init load aborted");return e}).then(e=>{const{hls:t}=this,{frag:r,payload:i}=e,n=r.decryptdata;if(i&&i.byteLength>0&&null!=n&&n.key&&n.iv&&bp(n.method)){const s=self.performance.now();return this.decrypter.decrypt(new Uint8Array(i),n.key.buffer,n.iv.buffer,Ep(n.method)).catch(e=>{throw t.trigger(cu.ERROR,{type:ou.MEDIA_ERROR,details:lu.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:r}),e}).then(i=>{const n=self.performance.now();return t.trigger(cu.FRAG_DECRYPTED,{frag:r,payload:i,stats:{tstart:s,tdecrypt:n}}),e.payload=i,this.completeInitSegmentLoad(e)})}return this.completeInitSegmentLoad(e)}).catch(t=>{this.state!==xm&&this.state!==_m&&(this.warn(t),this.resetFragmentLoading(e))})}completeInitSegmentLoad(e){const{levels:t}=this;if(!t)throw new Error("init load aborted, missing levels");const r=e.frag.stats;this.state!==xm&&(this.state=Am),e.frag.data=new Uint8Array(e.payload),r.parsing.start=r.buffering.start=self.performance.now(),r.parsing.end=r.buffering.end=self.performance.now(),this.tick()}unhandledEncryptionError(e,t){var r,i;const n=e.tracks;if(n&&!t.encrypted&&(null!=(r=n.audio)&&r.encrypted||null!=(i=n.video)&&i.encrypted)&&(!this.config.emeEnabled||!this.keyLoader.emeController)){const e=this.media,r=new Error(`Encrypted track with no key in ${this.fragInfo(t)} (media ${e?"attached mediaKeys: "+e.mediaKeys:"detached"})`);return this.warn(r.message),!e||e.mediaKeys?!1:(this.hls.trigger(cu.ERROR,{type:ou.KEY_SYSTEM_ERROR,details:lu.KEY_SYSTEM_NO_KEYS,fatal:!1,error:r,frag:t}),this.resetTransmuxer(),!0)}return!1}fragContextChanged(e){const{fragCurrent:t}=this;return!e||!t||e.sn!==t.sn||e.level!==t.level}fragBufferedComplete(e,t){const r=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)} > buffer:${r?Tm(np.getBuffered(r)):"(detached)"})`),qu(e)){var i;if(e.type!==gu){const t=e.elementaryStreams;if(!Object.keys(t).some(e=>!!t[e]))return void(this.state=Am)}const t=null==(i=this.levels)?void 0:i[e.level];null!=t&&t.fragmentError&&(this.log(`Resetting level fragment error count of ${t.fragmentError} on frag buffered`),t.fragmentError=0)}this.state=Am}_handleFragmentLoadComplete(e){const{transmuxer:t}=this;if(!t)return;const{frag:r,part:i,partsLoaded:n}=e,s=!n||0===n.length||n.some(e=>!e),a=new rp(r.level,r.sn,r.stats.chunkCount+1,0,i?i.index:-1,!s);t.flush(a)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,r=null,i){var n;this.fragCurrent=e;const s=t.details;if(!this.levels||!s)throw new Error(`frag load aborted, missing level${s?"":" detail"}s`);let a=null;if(!e.encrypted||null!=(n=e.decryptdata)&&n.key)e.encrypted||(a=this.keyLoader.loadClear(e,s.encryptedFragments,this.startFragRequested),a&&this.log("[eme] blocking frag load until media-keys acquired"));else if(this.log(`Loading key for ${e.sn} of [${s.startSN}-${s.endSN}], ${this.playlistLabel()} ${e.level}`),this.state=km,this.fragCurrent=e,a=this.keyLoader.load(e).then(e=>{if(!this.fragContextChanged(e.frag))return this.hls.trigger(cu.KEY_LOADED,e),this.state===km&&(this.state=Am),e}),this.hls.trigger(cu.KEY_LOADING,{frag:e}),null===this.fragCurrent)return this.log("context changed in KEY_LOADING"),Promise.resolve(null);const o=this.fragPrevious;if(qu(e)&&(!o||e.sn!==o.sn)){const r=this.shouldLoadParts(t.details,e.end);r!==this.loadingParts&&(this.log(`LL-Part loading ${r?"ON":"OFF"} loading sn ${null==o?void 0:o.sn}->${e.sn}`),this.loadingParts=r)}if(r=Math.max(e.start,r||0),this.loadingParts&&qu(e)){const n=s.partList;if(n&&i){r>s.fragmentEnd&&s.fragmentHint&&(e=s.fragmentHint);const o=this.getNextPart(n,e,r);if(o>-1){const l=n[o];let c;return e=this.fragCurrent=l.fragment,this.log(`Loading ${e.type} sn: ${e.sn} part: ${l.index} (${o}/${n.length-1}) of ${this.fragInfo(e,!1,l)}) cc: ${e.cc} [${s.startSN}-${s.endSN}], target: ${parseFloat(r.toFixed(3))}`),this.nextLoadPosition=l.start+l.duration,this.state=Im,c=a?a.then(r=>!r||this.fragContextChanged(r.frag)?null:this.doFragPartsLoad(e,l,t,i)).catch(e=>this.handleFragLoadError(e)):this.doFragPartsLoad(e,l,t,i).catch(e=>this.handleFragLoadError(e)),this.hls.trigger(cu.FRAG_LOADING,{frag:e,part:l,targetBufferTime:r}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):c}if(!e.url||this.loadedEndOfParts(n,r))return Promise.resolve(null)}}var l;if(qu(e)&&this.loadingParts)this.log(`LL-Part loading OFF after next part miss @${r.toFixed(2)} Check buffer at sn: ${e.sn} loaded parts: ${null==(l=s.partList)?void 0:l.filter(e=>e.loaded).map(e=>`[${e.start}-${e.end}]`)}`),this.loadingParts=!1;else if(!e.url)return Promise.resolve(null);this.log(`Loading ${e.type} sn: ${e.sn} of ${this.fragInfo(e,!1)}) cc: ${e.cc} ${"["+s.startSN+"-"+s.endSN+"]"}, target: ${parseFloat(r.toFixed(3))}`),nu(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=Im;const c=this.config.progressive&&e.type!==gu;let d;return d=c&&a?a.then(t=>!t||this.fragContextChanged(t.frag)?null:this.fragmentLoader.load(e,i)).catch(e=>this.handleFragLoadError(e)):Promise.all([this.fragmentLoader.load(e,c?i:void 0),a]).then(([e])=>(!c&&i&&i(e),e)).catch(e=>this.handleFragLoadError(e)),this.hls.trigger(cu.FRAG_LOADING,{frag:e,targetBufferTime:r}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):d}doFragPartsLoad(e,t,r,i){return new Promise((n,s)=>{var a;const o=[],l=null==(a=r.details)?void 0:a.partList,c=t=>{this.fragmentLoader.loadPart(e,t,i).then(i=>{o[t.index]=i;const s=i.part;this.hls.trigger(cu.FRAG_LOADED,i);const a=um(r.details,e.sn,t.index+1)||hm(l,e.sn,t.index+1);if(!a)return n({frag:e,part:s,partsLoaded:o});c(a)}).catch(s)};c(t)})}handleFragLoadError(e){if("data"in e){const t=e.data;t.frag&&t.details===lu.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):t.frag&&t.type===ou.KEY_SYSTEM_ERROR?(t.frag.abortRequests(),this.resetStartWhenNotLoaded(),this.resetFragmentLoading(t.frag)):this.hls.trigger(cu.ERROR,t)}else this.hls.trigger(cu.ERROR,{type:ou.OTHER_ERROR,details:lu.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){const t=this.getCurrentContext(e);if(!t||this.state!==Pm)return void(this.fragCurrent||this.state===xm||this.state===_m||(this.state=Am));const{frag:r,part:i,level:n}=t,s=self.performance.now();r.stats.parsing.end=s,i&&(i.stats.parsing.end=s);const a=this.getLevelDetails(),o=a&&r.sn>a.endSN||this.shouldLoadParts(a,r.end);o!==this.loadingParts&&(this.log(`LL-Part loading ${o?"ON":"OFF"} after parsing segment ending @${r.end.toFixed(2)}`),this.loadingParts=o),this.updateLevelTiming(r,i,n,e.partial)}shouldLoadParts(e,t){if(this.config.lowLatencyMode){if(!e)return this.loadingParts;if(e.partList){var r;const n=e.partList[0];if(n.fragment.type===gu)return!1;if(t>=n.end+((null==(r=e.fragmentHint)?void 0:r.duration)||0)){var i;if((this.hls.hasEnoughToStart?(null==(i=this.media)?void 0:i.currentTime)||this.lastCurrentTime:this.getLoadPosition())>n.start-n.fragment.duration)return!0}}}return!1}getCurrentContext(e){const{levels:t,fragCurrent:r}=this,{level:i,sn:n,part:s}=e;if(null==t||!t[i])return this.warn(`Levels object was unset while buffering fragment ${n} of ${this.playlistLabel()} ${i}. The current chunk will not be buffered.`),null;const a=t[i],o=a.details,l=s>-1?um(o,n,s):null,c=l?l.fragment:dm(o,n,r);return c?(r&&r!==c&&(c.stats=r.stats),{frag:c,part:l,level:a}):null}bufferFragmentData(e,t,r,i,n){if(this.state!==Pm)return;const{data1:s,data2:a}=e;let o=s;if(a&&(o=vh(s,a)),!o.length)return;const l=this.initPTS[t.cc],c=l?-l.baseTime/l.timescale:void 0,d={type:e.type,frag:t,part:r,chunkMeta:i,offset:c,parent:t.type,data:o};if(this.hls.trigger(cu.BUFFER_APPENDING,d),e.dropped&&e.independent&&!r){if(n)return;this.flushBufferGap(t)}}flushBufferGap(e){const t=this.media;if(!t)return;if(!np.isBuffered(t,t.currentTime))return void this.flushMainBuffer(0,e.start);const r=t.currentTime,i=np.bufferInfo(t,r,0),n=e.duration,s=Math.min(2*this.config.maxFragLookUpTolerance,.25*n),a=Math.max(Math.min(e.start-s,i.end-s),r+s);e.start-a>s&&this.flushMainBuffer(a,e.start)}getFwdBufferInfo(e,t){var r;const i=this.getLoadPosition();if(!nu(i))return null;const n=this.lastCurrentTime>i||null!=(r=this.media)&&r.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(e,i,t,n)}getFwdBufferInfoAtPos(e,t,r,i){const n=np.bufferInfo(e,t,i);if(0===n.len&&void 0!==n.nextStart){const s=this.fragmentTracker.getBufferedFrag(t,r);if(s&&(n.nextStart<=s.end||s.gap)){const r=Math.max(Math.min(n.nextStart,s.end)-t,i);return np.bufferInfo(e,t,r)}}return n}getMaxBufferLength(e){const{config:t}=this;let r;return r=e?Math.max(8*t.maxBufferSize/e,t.maxBufferLength):t.maxBufferLength,Math.min(r,t.maxMaxBufferLength)}reduceMaxBufferLength(e,t){const r=this.config,i=Math.max(Math.min(e-t,r.maxBufferLength),t),n=Math.max(e-3*t,r.maxMaxBufferLength/2,i);return n>=i&&(r.maxMaxBufferLength=n,this.warn(`Reduce max buffer length to ${n}s`),!0)}getAppendedFrag(e,t=pu){const r=this.fragmentTracker?this.fragmentTracker.getAppendedFrag(e,t):null;return r&&"fragment"in r?r.fragment:r}getNextFragment(e,t){const r=t.fragments,i=r.length;if(!i)return null;const{config:n}=this,s=r[0].start,a=n.lowLatencyMode&&!!t.partList;let o=null;if(t.live){const r=n.initialLiveManifestSize;if(i<r)return this.warn(`Not enough fragments to start playback (have: ${i}, need: ${r})`),null;if(!t.PTSKnown&&!this.startFragRequested&&-1===this.startPosition||e<s){var l;a&&!this.loadingParts&&(this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=!0),o=this.getInitialLiveFragment(t);const r=this.hls.startPosition,i=this.hls.liveSyncPosition,n=o?(-1!==r&&r>=s?r:i)||o.start:e;this.log(`Setting startPosition to ${n} to match start frag at live edge. mainStart: ${r} liveSyncPosition: ${i} frag.start: ${null==(l=o)?void 0:l.start}`),this.startPosition=this.nextLoadPosition=n}}else e<=s&&(o=r[0]);if(!o){const r=this.loadingParts?t.partEnd:t.fragmentEnd;o=this.getFragmentAtPosition(e,r,t)}let c=this.filterReplacedPrimary(o,t);if(!c&&o){const e=o.sn-t.startSN;c=this.filterReplacedPrimary(r[e+1]||null,t)}return this.mapToInitFragWhenRequired(c)}isLoopLoading(e,t){const r=this.fragmentTracker.getState(e);return(r===Bf||r===$f&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,r,i,n){let s=null;if(e.gap&&(s=this.getNextFragment(this.nextLoadPosition,t),s&&!s.gap&&r.nextStart)){const e=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,r.nextStart,i,0);if(null!==e&&r.len+e.len>=n){const e=s.sn;return this.loopSn!==e&&(this.log(`buffer full after gaps in "${i}" playlist starting at sn: ${e}`),this.loopSn=e),null}}return this.loopSn=void 0,s}get primaryPrefetch(){if(Fm(this.config)){var e;if(null==(e=this.hls.interstitialsManager)||null==(e=e.playingItem)?void 0:e.event)return!0}return!1}filterReplacedPrimary(e,t){if(!e)return e;if(Fm(this.config)&&e.type!==gu){const r=this.hls.interstitialsManager,i=null==r?void 0:r.bufferingItem;if(i){const r=i.event;if(r){if(r.appendInPlace||Math.abs(e.start-i.start)>1||0===i.start)return null}else{if(e.end<=i.start&&!1===(null==t?void 0:t.live))return null;if(e.start>i.end&&i.nextEvent&&(i.nextEvent.appendInPlace||e.start-i.end>1))return null}}const n=null==r?void 0:r.playerQueue;if(n)for(let t=n.length;t--;){const r=n[t].interstitial;if(r.appendInPlace&&e.start>=r.startTime&&e.end<=r.resumeTime)return null}}return e}mapToInitFragWhenRequired(e){return null==e||!e.initSegment||e.initSegment.data||this.bitrateTest?e:e.initSegment}getNextPart(e,t,r){let i=-1,n=!1,s=!0;for(let a=0,o=e.length;a<o;a++){const o=e[a];if(s=s&&!o.independent,i>-1&&r<o.start)break;const l=o.loaded;l?i=-1:(n||(o.independent||s)&&o.fragment===t)&&(o.fragment!==t&&this.warn(`Need buffer at ${r} but next unloaded part starts at ${o.start}`),i=a),n=l}return i}loadedEndOfParts(e,t){let r;for(let i=e.length;i--;){if(r=e[i],!r.loaded)return!1;if(t>r.start)return!0}return!1}getInitialLiveFragment(e){const t=e.fragments,r=this.fragPrevious;let i=null;if(r){if(e.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${r.programDateTime}`),i=function(e,t,r){if(null===t||!Array.isArray(e)||!e.length||!nu(t))return null;if(t<(e[0].programDateTime||0))return null;if(t>=(e[e.length-1].endProgramDateTime||0))return null;for(let i=0;i<e.length;++i){const n=e[i];if(vf(t,r,n))return n}return null}(t,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),!i){const n=r.sn+1;if(n>=e.startSN&&n<=e.endSN){const s=t[n-e.startSN];r.cc===s.cc&&(i=s,this.log(`Live playlist, switching playlist, load frag with next SN: ${i.sn}`))}i||(i=yf(e,r.cc,r.end),i&&this.log(`Live playlist, switching playlist, load frag with same CC: ${i.sn}`))}}else{const t=this.hls.liveSyncPosition;null!==t&&(i=this.getFragmentAtPosition(t,this.bitrateTest?e.fragmentEnd:e.edge,e))}return i}getFragmentAtPosition(e,t,r){const{config:i}=this;let{fragPrevious:n}=this,{fragments:s,endSN:a}=r;const{fragmentHint:o}=r,{maxFragLookUpTolerance:l}=i,c=r.partList,d=!!(this.loadingParts&&null!=c&&c.length&&o);let u;if(d&&!this.bitrateTest&&c[c.length-1].fragment.sn===o.sn&&(s=s.concat(o),a=o.sn),e<t){var h;u=mf(n,s,e,e<this.lastCurrentTime||e>t-l||null!=(h=this.media)&&h.paused||!this.startFragRequested?0:l)}else u=s[s.length-1];if(u){const e=u.sn-r.startSN,t=this.fragmentTracker.getState(u);if((t===Bf||t===$f&&u.gap)&&(n=u),n&&u.sn===n.sn&&(!d||c[0].fragment.sn>u.sn||!r.live)){if(u.level===n.level){const t=s[e+1];u=u.sn<a&&this.fragmentTracker.getState(t)!==Bf?t:null}}}return u}alignPlaylists(e,t,r){const i=e.fragments.length;if(!i)return this.warn("No fragments in live playlist"),0;const n=e.fragmentStart,s=!t,a=e.alignedSliding&&nu(n);if(s||!a&&!n){!function(e,t){e&&(bm(t,e),t.alignedSliding||Em(t,e),t.alignedSliding||t.skippedSegments||om(e,t,!1))}(r,e);const n=e.fragmentStart;return this.log(`Live playlist sliding: ${n.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} fragments: ${i}`),n}return n}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,3*e.partTarget)}setStartPosition(e,t){let r=this.startPosition;r<t&&(r=-1);const i=this.timelineOffset;if(-1===r){const n=null!==this.startTimeOffset,s=n?this.startTimeOffset:e.startTimeOffset;null!==s&&nu(s)?(r=t+s,s<0&&(r+=e.edge),r=Math.min(Math.max(t,r),t+e.totalduration),this.log(`Setting startPosition to ${r} for start time offset ${s} found in ${n?"multivariant":"media"} playlist`),this.startPosition=r):e.live?(r=this.hls.liveSyncPosition||t,this.log(`Setting startPosition to -1 to start at live edge ${r}`),this.startPosition=-1):(this.log("setting startPosition to 0 by default"),this.startPosition=r=0),this.lastCurrentTime=r+i}this.nextLoadPosition=r+i}getLoadPosition(){var e;const{media:t}=this;let r=0;return null!=(e=this.hls)&&e.hasEnoughToStart&&t?r=t.currentTime:this.nextLoadPosition>=0&&(r=this.nextLoadPosition),r}handleFragLoadAborted(e,t){this.transmuxer&&e.type===this.playlistType&&qu(e)&&e.stats.aborted&&(this.log(`Fragment ${e.sn}${t?" part "+t.index:""} of ${this.playlistLabel()} ${e.level} was aborted`),this.resetFragmentLoading(e))}resetFragmentLoading(e){this.fragCurrent&&(this.fragContextChanged(e)||this.state===Lm)||(this.state=Am)}onFragmentOrKeyLoadError(e,t){var r;if(t.chunkMeta&&!t.frag){const e=this.getCurrentContext(t.chunkMeta);e&&(t.frag=e.frag)}const i=t.frag;if(!i||i.type!==e||!this.levels)return;var n;if(this.fragContextChanged(i))return void this.warn(`Frag load error must match current frag to retry ${i.url} > ${null==(n=this.fragCurrent)?void 0:n.url}`);const s=t.details===lu.FRAG_GAP;s&&this.fragmentTracker.fragBuffered(i,!0);const a=t.errorAction;if(!a)return void(this.state=_m);const{action:o,flags:l,retryCount:c=0,retryConfig:d}=a,u=!!d,h=u&&o===Pf,f=u&&!a.resolved&&l===Df,p=null==(r=this.hls.latestLevelDetails)?void 0:r.live;if(!h&&f&&qu(i)&&!i.endList&&p&&!wf(t))this.resetFragmentErrors(e),this.treatAsGap(i),a.resolved=!0;else if((h||f)&&c<d.maxNumRetry){var m;const r=kf(null==(m=t.response)?void 0:m.code),n=Tf(d,c);if(this.resetStartWhenNotLoaded(),this.retryDate=self.performance.now()+n,this.state=Lm,a.resolved=!0,r)return this.log("Waiting for connection (offline)"),this.retryDate=1/0,void(t.reason="offline");this.warn(`Fragment ${i.sn} of ${e} ${i.level} errored with ${t.details}, retrying loading ${c+1}/${d.maxNumRetry} in ${n}ms`)}else if(d){if(this.resetFragmentErrors(e),!(c<d.maxNumRetry))return void this.warn(`${t.details} reached or exceeded max retry (${c})`);s||o===Rf||(a.resolved=!0)}else this.state=o===Lf?Mm:_m;this.tickImmediate()}checkRetryDate(){const e=self.performance.now(),t=this.retryDate,r=t===1/0;(!t||e>=t||r&&!kf(0))&&(r&&this.log("Connection restored (online)"),this.resetStartWhenNotLoaded(),this.state=Am)}reduceLengthAndFlushBuffer(e){if(this.state===Pm||this.state===Cm){const t=e.frag,r=e.parent,i=this.getFwdBufferInfo(this.mediaBuffer,r),n=i&&i.len>.5;n&&this.reduceMaxBufferLength(i.len,(null==t?void 0:t.duration)||10);const s=!n;return s&&this.warn(`Buffer full error while media.currentTime (${this.getLoadPosition()}) is not buffered, flush ${r} buffer`),t&&(this.fragmentTracker.removeFragment(t),this.nextLoadPosition=t.start),this.resetLoadingState(),s}return!1}resetFragmentErrors(e){e===mu&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==xm&&(this.state=Am)}afterBufferFlushed(e,t,r){if(!e)return;const i=np.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,i,r),this.state===Dm&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==xm&&(this.state=Am)}resetStartWhenNotLoaded(){if(!this.hls.hasEnoughToStart){this.startFragRequested=!1;const e=this.levelLastLoaded,t=e?e.details:null;null!=t&&t.live?(this.log("resetting startPosition for live start"),this.startPosition=-1,this.setStartPosition(t,t.fragmentStart),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(e){this.log(`Loading context changed while buffering sn ${e.sn} of ${this.playlistLabel()} ${-1===e.level?"<removed>":e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(),this.resetLoadingState()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(e,t,r,i){const n=r.details;if(!n)return void this.warn("level.details undefined");if(!Object.keys(e.elementaryStreams).reduce((t,s)=>{const a=e.elementaryStreams[s];if(a){const o=a.endPTS-a.startPTS;if(o<=0)return this.warn(`Could not parse fragment ${e.sn} ${s} duration reliably (${o})`),t||!1;const l=i?0:nm(n,e,a.startPTS,a.endPTS,a.startDTS,a.endDTS,this);return this.hls.trigger(cu.LEVEL_PTS_UPDATED,{details:n,level:r,drift:l,type:s,frag:e,start:a.startPTS,end:a.endPTS}),!0}return t},!1)){var s;const t=null===(null==(s=this.transmuxer)?void 0:s.error);if((0===r.fragmentError||t&&(r.fragmentError<2||e.endList))&&this.treatAsGap(e,r),t){const t=new Error(`Found no media in fragment ${e.sn} of ${this.playlistLabel()} ${e.level} resetting transmuxer to fallback to playlist timing`);if(this.warn(t.message),this.hls.trigger(cu.ERROR,{type:ou.MEDIA_ERROR,details:lu.FRAG_PARSING_ERROR,fatal:!1,error:t,frag:e,reason:`Found no media in msn ${e.sn} of ${this.playlistLabel()} "${r.url}"`}),!this.hls)return;this.resetTransmuxer()}}this.state=Cm,this.log(`Parsed ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)})`),this.hls.trigger(cu.FRAG_PARSED,{frag:e,part:t})}playlistLabel(){return this.playlistType===pu?"level":"track"}fragInfo(e,t=!0,r){var i,n;return`${this.playlistLabel()} ${e.level} (${r?"part":"frag"}:[${(null!=(i=t&&!r?e.startPTS:(r||e).start)?i:NaN).toFixed(3)}-${(null!=(n=t&&!r?e.endPTS:(r||e).end)?n:NaN).toFixed(3)}]${r&&"main"===e.type?"INDEPENDENT="+(r.independent?"YES":"NO"):""}`}treatAsGap(e,t){t&&t.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)}resetTransmuxer(){var e;null==(e=this.transmuxer)||e.reset()}recoverWorkerError(e){"demuxerWorker"===e.event&&(this.fragmentTracker.removeAllFragments(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),this.resetStartWhenNotLoaded(),this.resetLoadingState())}set state(e){const t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}get state(){return this._state}}function Fm(e){return!!e.interstitialsController&&!1!==e.enableInterstitialPlayback}class $m{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){const{chunks:e,dataLength:t}=this;let r;return e.length?(r=1===e.length?e[0]:function(e,t){const r=new Uint8Array(t);let i=0;for(let t=0;t<e.length;t++){const n=e[t];r.set(n,i),i+=n.length}return r}(e,t),this.reset(),r):new Uint8Array(0)}reset(){this.chunks.length=0,this.dataLength=0}}var Bm,Um={exports:{}};var zm=(Bm||(Bm=1,function(e){var t=Object.prototype.hasOwnProperty,r="~";function i(){}function n(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function s(e,t,i,s,a){if("function"!=typeof i)throw new TypeError("The listener must be a function");var o=new n(i,s||e,a),l=r?r+t:t;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],o]:e._events[l].push(o):(e._events[l]=o,e._eventsCount++),e}function a(e,t){0===--e._eventsCount?e._events=new i:delete e._events[t]}function o(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(r=!1)),o.prototype.eventNames=function(){var e,i,n=[];if(0===this._eventsCount)return n;for(i in e=this._events)t.call(e,i)&&n.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},o.prototype.listeners=function(e){var t=r?r+e:e,i=this._events[t];if(!i)return[];if(i.fn)return[i.fn];for(var n=0,s=i.length,a=new Array(s);n<s;n++)a[n]=i[n].fn;return a},o.prototype.listenerCount=function(e){var t=r?r+e:e,i=this._events[t];return i?i.fn?1:i.length:0},o.prototype.emit=function(e,t,i,n,s,a){var o=r?r+e:e;if(!this._events[o])return!1;var l,c,d=this._events[o],u=arguments.length;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),u){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,t),!0;case 3:return d.fn.call(d.context,t,i),!0;case 4:return d.fn.call(d.context,t,i,n),!0;case 5:return d.fn.call(d.context,t,i,n,s),!0;case 6:return d.fn.call(d.context,t,i,n,s,a),!0}for(c=1,l=new Array(u-1);c<u;c++)l[c-1]=arguments[c];d.fn.apply(d.context,l)}else{var h,f=d.length;for(c=0;c<f;c++)switch(d[c].once&&this.removeListener(e,d[c].fn,void 0,!0),u){case 1:d[c].fn.call(d[c].context);break;case 2:d[c].fn.call(d[c].context,t);break;case 3:d[c].fn.call(d[c].context,t,i);break;case 4:d[c].fn.call(d[c].context,t,i,n);break;default:if(!l)for(h=1,l=new Array(u-1);h<u;h++)l[h-1]=arguments[h];d[c].fn.apply(d[c].context,l)}}return!0},o.prototype.on=function(e,t,r){return s(this,e,t,r,!1)},o.prototype.once=function(e,t,r){return s(this,e,t,r,!0)},o.prototype.removeListener=function(e,t,i,n){var s=r?r+e:e;if(!this._events[s])return this;if(!t)return a(this,s),this;var o=this._events[s];if(o.fn)o.fn!==t||n&&!o.once||i&&o.context!==i||a(this,s);else{for(var l=0,c=[],d=o.length;l<d;l++)(o[l].fn!==t||n&&!o[l].once||i&&o[l].context!==i)&&c.push(o[l]);c.length?this._events[s]=1===c.length?c[0]:c:a(this,s)}return this},o.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&a(this,t)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=r,o.EventEmitter=o,e.exports=o}(Um)),Um.exports),Gm=Mu(zm);const jm="1.6.15",Hm={};function Vm(e,t){return t+10<=e.length&&51===e[t]&&68===e[t+1]&&73===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128}function Wm(e,t){return t+10<=e.length&&73===e[t]&&68===e[t+1]&&51===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128}function Ym(e,t){let r=0;return r=(127&e[t])<<21,r|=(127&e[t+1])<<14,r|=(127&e[t+2])<<7,r|=127&e[t+3],r}function Km(e,t){const r=t;let i=0;for(;Wm(e,t);){i+=10;i+=Ym(e,t+6),Vm(e,t+10)&&(i+=10),t+=i}if(i>0)return e.subarray(r,r+i)}function qm(e,t){return 255===e[t]&&240==(246&e[t+1])}function Xm(e,t){return 1&e[t+1]?7:9}function Qm(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function Zm(e,t){return t+1<e.length&&qm(e,t)}function Jm(e,t){if(Zm(e,t)){const r=Xm(e,t);if(t+r>=e.length)return!1;const i=Qm(e,t);if(i<=r)return!1;const n=t+i;return n===e.length||Zm(e,n)}return!1}function eg(e,t,r,i,n){if(!e.samplerate){const s=function(e,t,r,i){const n=t[r+2],s=n>>2&15;if(s>12){const t=new Error(`invalid ADTS sampling index:${s}`);return void e.emit(cu.ERROR,cu.ERROR,{type:ou.MEDIA_ERROR,details:lu.FRAG_PARSING_ERROR,fatal:!0,error:t,reason:t.message})}const a=1+(n>>6&3),o=t[r+3]>>6&3|(1&n)<<2,l="mp4a.40."+a,c=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][s];let d=s;5!==a&&29!==a||(d-=3);const u=[a<<3|(14&d)>>1,(1&d)<<7|o<<3];return Ru.log(`manifest codec:${i}, parsed codec:${l}, channels:${o}, rate:${c} (ADTS object type:${a} sampling index:${s})`),{config:u,samplerate:c,channelCount:o,codec:l,parsedCodec:l,manifestCodec:i}}(t,r,i,n);if(!s)return;Eu(e,s)}}function tg(e){return 9216e4/e}function rg(e,t,r,i,n){const s=i+n*tg(e.samplerate),a=function(e,t){const r=Xm(e,t);if(t+r<=e.length){const i=Qm(e,t)-r;if(i>0)return{headerLength:r,frameLength:i}}}(t,r);let o;if(a){const{frameLength:i,headerLength:n}=a,l=n+i,c=Math.max(0,r+l-t.length);c?(o=new Uint8Array(l-n),o.set(t.subarray(r+n,t.length),0)):o=t.subarray(r+n,r+l);const d={unit:o,pts:s};return c||e.samples.push(d),{sample:d,length:l,missing:c}}const l=t.length-r;o=new Uint8Array(l),o.set(t.subarray(r,t.length),0);return{sample:{unit:o,pts:s},length:l,missing:-1}}function ig(e,t){return Wm(e,t)&&Ym(e,t+6)+10<=e.length-t}function ng(e,t=0,r=1/0){return function(e,t,r,i){const n=function(e){return e instanceof ArrayBuffer?e:e.buffer}(e);let s=1;"BYTES_PER_ELEMENT"in i&&(s=i.BYTES_PER_ELEMENT);const a=(u=e,u&&u.buffer instanceof ArrayBuffer&&void 0!==u.byteLength&&void 0!==u.byteOffset?e.byteOffset:0),o=(a+e.byteLength)/s,l=(a+t)/s,c=Math.floor(Math.max(0,Math.min(l,o))),d=Math.floor(Math.min(c+Math.max(r,0),o));var u;return new i(n,c,d-c)}(e,t,r,Uint8Array)}function sg(e){const t={key:e.type,description:"",data:"",mimeType:null,pictureType:null};if(e.size<2)return;if(3!==e.data[0])return void console.log("Ignore frame with unrecognized character encoding");const r=e.data.subarray(1).indexOf(0);if(-1===r)return;const i=Du(ng(e.data,1,r)),n=e.data[2+r],s=e.data.subarray(3+r).indexOf(0);if(-1===s)return;const a=Du(ng(e.data,3+r,s));let o;return o="--\x3e"===i?Du(ng(e.data,4+r+s)):function(e){return e instanceof ArrayBuffer?e:0==e.byteOffset&&e.byteLength==e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer}(e.data.subarray(4+r+s)),t.mimeType=i,t.pictureType=n,t.description=a,t.data=o,t}function ag(e){return"PRIV"===e.type?function(e){if(e.size<2)return;const t=Du(e.data,!0),r=new Uint8Array(e.data.subarray(t.length+1));return{key:e.type,info:t,data:r.buffer}}(e):"W"===e.type[0]?function(e){if("WXXX"===e.type){if(e.size<2)return;let t=1;const r=Du(e.data.subarray(t),!0);t+=r.length+1;const i=Du(e.data.subarray(t));return{key:e.type,info:r,data:i}}const t=Du(e.data);return{key:e.type,info:"",data:t}}(e):"APIC"===e.type?sg(e):function(e){if(e.size<2)return;if("TXXX"===e.type){let t=1;const r=Du(e.data.subarray(t),!0);t+=r.length+1;const i=Du(e.data.subarray(t));return{key:e.type,info:r,data:i}}const t=Du(e.data.subarray(1));return{key:e.type,info:"",data:t}}(e)}function og(e){const t=String.fromCharCode(e[0],e[1],e[2],e[3]),r=Ym(e,4);return{type:t,size:r,data:e.subarray(10,10+r)}}function lg(e){let t=0;const r=[];for(;Wm(e,t);){const i=Ym(e,t+6);e[t+5]>>6&1&&(t+=10),t+=10;const n=t+i;for(;t+10<n;){const i=og(e.subarray(t)),n=ag(i);n&&r.push(n),t+=i.size+10}Vm(e,t)&&(t+=10)}return r}function cg(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info}function dg(e){if(8===e.data.byteLength){const t=new Uint8Array(e.data),r=1&t[3];let i=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return i/=45,r&&(i+=47721858.84),Math.round(i)}}function ug(e){const t=lg(e);for(let e=0;e<t.length;e++){const r=t[e];if(cg(r))return dg(r)}}let hg=function(e){return e.audioId3="org.id3",e.dateRange="com.apple.quicktime.HLS",e.emsg="https://aomedia.org/emsg/ID3",e.misbklv="urn:misb:KLV:bin:1910.1",e}({});function fg(e="",t=9e4){return{type:e,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}class pg{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(e,t,r,i){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(e){this.initPTS=e,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(e,t){return!1}appendFrame(e,t,r){}demux(e,t){this.cachedData&&(e=vh(this.cachedData,e),this.cachedData=null);let r,i=Km(e,0),n=i?i.length:0;const s=this._audioTrack,a=this._id3Track,o=i?ug(i):void 0,l=e.length;for((null===this.basePTS||0===this.frameIndex&&nu(o))&&(this.basePTS=mg(o,t,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),i&&i.length>0&&a.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:hg.audioId3,duration:Number.POSITIVE_INFINITY});n<l;){if(this.canParse(e,n)){const t=this.appendFrame(s,e,n);t?(this.frameIndex++,this.lastPTS=t.sample.pts,n+=t.length,r=n):n=l}else ig(e,n)?(i=Km(e,n),a.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:hg.audioId3,duration:Number.POSITIVE_INFINITY}),n+=i.length,r=n):n++;if(n===l&&r!==l){const t=e.slice(r);this.cachedData?this.cachedData=vh(this.cachedData,t):this.cachedData=t}}return{audioTrack:s,videoTrack:fg(),id3Track:a,textTrack:fg()}}demuxSampleAes(e,t,r){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(e){const t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:fg(),id3Track:this._id3Track,textTrack:fg()}}destroy(){this.cachedData=null,this._audioTrack=this._id3Track=void 0}}const mg=(e,t,r)=>{if(nu(e))return 90*e;return 9e4*t+(r?9e4*r.baseTime/r.timescale:0)};let gg=null;const vg=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],yg=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],bg=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],Eg=[0,1,1,4];function wg(e,t,r,i,n){if(r+24>t.length)return;const s=Sg(t,r);if(s&&r+s.frameLength<=t.length){const a=i+n*(9e4*s.samplesPerFrame/s.sampleRate),o={unit:t.subarray(r,r+s.frameLength),pts:a,dts:a};return e.config=[],e.channelCount=s.channelCount,e.samplerate=s.sampleRate,e.samples.push(o),{sample:o,length:s.frameLength,missing:0}}}function Sg(e,t){const r=e[t+1]>>3&3,i=e[t+1]>>1&3,n=e[t+2]>>4&15,s=e[t+2]>>2&3;if(1!==r&&0!==n&&15!==n&&3!==s){const a=e[t+2]>>1&1,o=e[t+3]>>6,l=1e3*vg[14*(3===r?3-i:3===i?3:4)+n-1],c=yg[3*(3===r?0:2===r?1:2)+s],d=3===o?1:2,u=bg[r][i],h=Eg[i],f=8*u*h,p=Math.floor(u*l/c+a)*h;if(null===gg){const e=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);gg=e?parseInt(e[1]):0}return!!gg&&gg<=87&&2===i&&l>=224e3&&0===o&&(e[t+3]=128|e[t+3]),{sampleRate:c,channelCount:d,frameLength:p,samplesPerFrame:f}}}function Tg(e,t){return!(255!==e[t]||224&~e[t+1]||!(6&e[t+1]))}function xg(e,t){return t+1<e.length&&Tg(e,t)}function Ag(e,t){if(t+1<e.length&&Tg(e,t)){const r=4,i=Sg(e,t);let n=r;null!=i&&i.frameLength&&(n=i.frameLength);const s=t+n;return s===e.length||xg(e,s)}return!1}const kg=(e,t)=>{let r=0,i=5;t+=i;const n=new Uint32Array(1),s=new Uint32Array(1),a=new Uint8Array(1);for(;i>0;){a[0]=e[t];const o=Math.min(i,8),l=8-o;s[0]=4278190080>>>24+l<<l,n[0]=(a[0]&s[0])>>l,r=r?r<<o|n[0]:n[0],t+=1,i-=o}return r};class Ig extends pg{constructor(e){super(),this.observer=void 0,this.observer=e}resetInitSegment(e,t,r,i){super.resetInitSegment(e,t,r,i),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:t,duration:i,inputTimeScale:9e4,dropped:0}}canParse(e,t){return t+64<e.length}appendFrame(e,t,r){const i=Lg(e,t,r,this.basePTS,this.frameIndex);if(-1!==i){return{sample:e.samples[e.samples.length-1],length:i,missing:0}}}static probe(e){if(!e)return!1;const t=Km(e,0);if(!t)return!1;const r=t.length;return 11===e[r]&&119===e[r+1]&&void 0!==ug(t)&&kg(e,r)<16}}function Lg(e,t,r,i,n){if(r+8>t.length)return-1;if(11!==t[r]||119!==t[r+1])return-1;const s=t[r+4]>>6;if(s>=3)return-1;const a=[48e3,44100,32e3][s],o=63&t[r+4],l=2*[64,69,96,64,70,96,80,87,120,80,88,120,96,104,144,96,105,144,112,121,168,112,122,168,128,139,192,128,140,192,160,174,240,160,175,240,192,208,288,192,209,288,224,243,336,224,244,336,256,278,384,256,279,384,320,348,480,320,349,480,384,417,576,384,418,576,448,487,672,448,488,672,512,557,768,512,558,768,640,696,960,640,697,960,768,835,1152,768,836,1152,896,975,1344,896,976,1344,1024,1114,1536,1024,1115,1536,1152,1253,1728,1152,1254,1728,1280,1393,1920,1280,1394,1920][3*o+s];if(r+l>t.length)return-1;const c=t[r+6]>>5;let d=0;2===c?d+=2:(1&c&&1!==c&&(d+=2),4&c&&(d+=2));const u=(t[r+6]<<8|t[r+7])>>12-d&1,h=[2,1,2,3,3,4,4,5][c]+u,f=t[r+5]>>3,p=7&t[r+5],m=new Uint8Array([s<<6|f<<1|p>>2,(3&p)<<6|c<<3|u<<2|o>>4,o<<4&224]),g=i+n*(1536/a*9e4),v=t.subarray(r,r+l);return e.config=m,e.channelCount=h,e.samplerate=a,e.samples.push({unit:v,pts:g}),l}const Rg=/\/emsg[-/]ID3/i;function Pg(e,t){return nu(e.presentationTime)?e.presentationTime/e.timeScale:t+e.presentationTimeDelta/e.timeScale}class Cg{constructor(e,t,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new qf(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,Hf)}decryptAacSample(e,t,r){const i=e[t].unit;if(i.length<=16)return;const n=i.subarray(16,i.length-i.length%16),s=n.buffer.slice(n.byteOffset,n.byteOffset+n.length);this.decryptBuffer(s).then(n=>{const s=new Uint8Array(n);i.set(s,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,r)}).catch(r)}decryptAacSamples(e,t,r){for(;;t++){if(t>=e.length)return void r();if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,r),!this.decrypter.isSync()))return}}getAvcEncryptedData(e){const t=16*Math.floor((e.length-48)/160)+16,r=new Int8Array(t);let i=0;for(let t=32;t<e.length-16;t+=160,i+=16)r.set(e.subarray(t,t+16),i);return r}getAvcDecryptedUnit(e,t){const r=new Uint8Array(t);let i=0;for(let t=32;t<e.length-16;t+=160,i+=16)e.set(r.subarray(i,i+16),t);return e}decryptAvcSample(e,t,r,i,n){const s=Sh(n.data),a=this.getAvcEncryptedData(s);this.decryptBuffer(a.buffer).then(a=>{n.data=this.getAvcDecryptedUnit(s,a),this.decrypter.isSync()||this.decryptAvcSamples(e,t,r+1,i)}).catch(i)}decryptAvcSamples(e,t,r,i){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length)return void i();const n=e[t].units;for(;!(r>=n.length);r++){const s=n[r];if(!(s.data.length<=48||1!==s.type&&5!==s.type||(this.decryptAvcSample(e,t,r,i,s),this.decrypter.isSync())))return}}}}class Dg{constructor(){this.VideoSample=null}createVideoSample(e,t,r){return{key:e,frame:!1,pts:t,dts:r,units:[],length:0}}getLastNalUnit(e){var t;let r,i=this.VideoSample;if(i&&0!==i.units.length||(i=e[e.length-1]),null!=(t=i)&&t.units){const e=i.units;r=e[e.length-1]}return r}pushAccessUnit(e,t){if(e.units.length&&e.frame){if(void 0===e.pts){const r=t.samples,i=r.length;if(!i)return void t.dropped++;{const t=r[i-1];e.pts=t.pts,e.dts=t.dts}}t.samples.push(e)}}parseNALu(e,t,r){const i=t.byteLength;let n=e.naluState||0;const s=n,a=[];let o,l,c,d=0,u=-1,h=0;for(-1===n&&(u=0,h=this.getNALuType(t,0),n=0,d=1);d<i;)if(o=t[d++],n)if(1!==n)if(o)if(1===o){if(l=d-n-1,u>=0){const e={data:t.subarray(u,l),type:h};a.push(e)}else{const r=this.getLastNalUnit(e.samples);r&&(s&&d<=4-s&&r.state&&(r.data=r.data.subarray(0,r.data.byteLength-s)),l>0&&(r.data=vh(r.data,t.subarray(0,l)),r.state=0))}d<i?(c=this.getNALuType(t,d),u=d,h=c,n=0):n=-1}else n=0;else n=3;else n=o?0:2;else n=o?0:1;if(u>=0&&n>=0){const e={data:t.subarray(u,i),type:h,state:n};a.push(e)}if(0===a.length){const r=this.getLastNalUnit(e.samples);r&&(r.data=vh(r.data,t))}return e.naluState=n,a}}class _g{constructor(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){const e=this.data,t=this.bytesAvailable,r=e.byteLength-t,i=new Uint8Array(4),n=Math.min(4,t);if(0===n)throw new Error("no bytes available");i.set(e.subarray(r,r+n)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*n,this.bytesAvailable-=n}skipBits(e){let t;e=Math.min(e,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(t=(e-=this.bitsAvailable)>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}readBits(e){let t=Math.min(this.bitsAvailable,e);const r=this.word>>>32-t;if(e>32&&Ru.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return t=e-t,t>0&&this.bitsAvailable?r<<t|this.readBits(t):r}skipLZ(){let e;for(e=0;e<this.bitsAvailable;++e)if(this.word&2147483648>>>e)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){const e=this.skipLZ();return this.readBits(e+1)-1}readEG(){const e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}readBoolean(){return 1===this.readBits(1)}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}}class Og extends Dg{parsePES(e,t,r,i){const n=this.parseNALu(e,r.data,i);let s,a=this.VideoSample,o=!1;r.data=null,a&&n.length&&!e.audFound&&(this.pushAccessUnit(a,e),a=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts)),n.forEach(i=>{var n,l;switch(i.type){case 1:{let t=!1;s=!0;const n=i.data;if(o&&n.length>4){const e=this.readSliceType(n);2!==e&&4!==e&&7!==e&&9!==e||(t=!0)}var c;if(t)null!=(c=a)&&c.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null);a||(a=this.VideoSample=this.createVideoSample(!0,r.pts,r.dts)),a.frame=!0,a.key=t;break}case 5:s=!0,null!=(n=a)&&n.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null),a||(a=this.VideoSample=this.createVideoSample(!0,r.pts,r.dts)),a.key=!0,a.frame=!0;break;case 6:s=!0,wh(i.data,1,r.pts,t.samples);break;case 7:{var d,u;s=!0,o=!0;const t=i.data,r=this.readSPS(t);if(!e.sps||e.width!==r.width||e.height!==r.height||(null==(d=e.pixelRatio)?void 0:d[0])!==r.pixelRatio[0]||(null==(u=e.pixelRatio)?void 0:u[1])!==r.pixelRatio[1]){e.width=r.width,e.height=r.height,e.pixelRatio=r.pixelRatio,e.sps=[t];const i=t.subarray(1,4);let n="avc1.";for(let e=0;e<3;e++){let t=i[e].toString(16);t.length<2&&(t="0"+t),n+=t}e.codec=n}break}case 8:s=!0,e.pps=[i.data];break;case 9:s=!0,e.audFound=!0,null!=(l=a)&&l.frame&&(this.pushAccessUnit(a,e),a=null),a||(a=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts));break;case 12:s=!0;break;default:s=!1}if(a&&s){a.units.push(i)}}),i&&a&&(this.pushAccessUnit(a,e),this.VideoSample=null)}getNALuType(e,t){return 31&e[t]}readSliceType(e){const t=new _g(e);return t.readUByte(),t.readUEG(),t.readUEG()}skipScalingList(e,t){let r,i=8,n=8;for(let s=0;s<e;s++)0!==n&&(r=t.readEG(),n=(i+r+256)%256),i=0===n?i:n}readSPS(e){const t=new _g(e);let r,i,n,s=0,a=0,o=0,l=0;const c=t.readUByte.bind(t),d=t.readBits.bind(t),u=t.readUEG.bind(t),h=t.readBoolean.bind(t),f=t.skipBits.bind(t),p=t.skipEG.bind(t),m=t.skipUEG.bind(t),g=this.skipScalingList.bind(this);c();const v=c();if(d(5),f(3),c(),m(),100===v||110===v||122===v||244===v||44===v||83===v||86===v||118===v||128===v){const e=u();if(3===e&&f(1),m(),m(),f(1),h())for(i=3!==e?8:12,n=0;n<i;n++)h()&&g(n<6?16:64,t)}m();const y=u();if(0===y)u();else if(1===y)for(f(1),p(),p(),r=u(),n=0;n<r;n++)p();m(),f(1);const b=u(),E=u(),w=d(1);0===w&&f(1),f(1),h()&&(s=u(),a=u(),o=u(),l=u());let S=[1,1];if(h()&&h()){switch(c()){case 1:S=[1,1];break;case 2:S=[12,11];break;case 3:S=[10,11];break;case 4:S=[16,11];break;case 5:S=[40,33];break;case 6:S=[24,11];break;case 7:S=[20,11];break;case 8:S=[32,11];break;case 9:S=[80,33];break;case 10:S=[18,11];break;case 11:S=[15,11];break;case 12:S=[64,33];break;case 13:S=[160,99];break;case 14:S=[4,3];break;case 15:S=[3,2];break;case 16:S=[2,1];break;case 255:S=[c()<<8|c(),c()<<8|c()]}}return{width:Math.ceil(16*(b+1)-2*s-2*a),height:(2-w)*(E+1)*16-(w?2:4)*(o+l),pixelRatio:S}}}class Mg extends Dg{constructor(...e){super(...e),this.initVPS=null}parsePES(e,t,r,i){const n=this.parseNALu(e,r.data,i);let s,a=this.VideoSample,o=!1;r.data=null,a&&n.length&&!e.audFound&&(this.pushAccessUnit(a,e),a=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts)),n.forEach(i=>{var n,l;switch(i.type){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:a||(a=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts)),a.frame=!0,s=!0;break;case 16:case 17:case 18:case 21:var c;if(s=!0,o)null!=(c=a)&&c.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null);a||(a=this.VideoSample=this.createVideoSample(!0,r.pts,r.dts)),a.key=!0,a.frame=!0;break;case 19:case 20:s=!0,null!=(n=a)&&n.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null),a||(a=this.VideoSample=this.createVideoSample(!0,r.pts,r.dts)),a.key=!0,a.frame=!0;break;case 39:s=!0,wh(i.data,2,r.pts,t.samples);break;case 32:s=!0,e.vps||("object"!=typeof e.params&&(e.params={}),e.params=Eu(e.params,this.readVPS(i.data)),this.initVPS=i.data),e.vps=[i.data];break;case 33:if(s=!0,o=!0,void 0===e.vps||e.vps[0]===this.initVPS||void 0===e.sps||this.matchSPS(e.sps[0],i.data)||(this.initVPS=e.vps[0],e.sps=e.pps=void 0),!e.sps){const t=this.readSPS(i.data);e.width=t.width,e.height=t.height,e.pixelRatio=t.pixelRatio,e.codec=t.codecString,e.sps=[],"object"!=typeof e.params&&(e.params={});for(const r in t.params)e.params[r]=t.params[r]}this.pushParameterSet(e.sps,i.data,e.vps),a||(a=this.VideoSample=this.createVideoSample(!0,r.pts,r.dts)),a.key=!0;break;case 34:if(s=!0,"object"==typeof e.params){if(!e.pps){e.pps=[];const t=this.readPPS(i.data);for(const r in t)e.params[r]=t[r]}this.pushParameterSet(e.pps,i.data,e.vps)}break;case 35:s=!0,e.audFound=!0,null!=(l=a)&&l.frame&&(this.pushAccessUnit(a,e),a=null),a||(a=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts));break;default:s=!1}if(a&&s){a.units.push(i)}}),i&&a&&(this.pushAccessUnit(a,e),this.VideoSample=null)}pushParameterSet(e,t,r){(r&&r[0]===this.initVPS||!r&&!e.length)&&e.push(t)}getNALuType(e,t){return(126&e[t])>>>1}ebsp2rbsp(e){const t=new Uint8Array(e.byteLength);let r=0;for(let i=0;i<e.byteLength;i++)i>=2&&3===e[i]&&0===e[i-1]&&0===e[i-2]||(t[r]=e[i],r++);return new Uint8Array(t.buffer,0,r)}pushAccessUnit(e,t){super.pushAccessUnit(e,t),this.initVPS&&(this.initVPS=null)}readVPS(e){const t=new _g(e);t.readUByte(),t.readUByte(),t.readBits(4),t.skipBits(2),t.readBits(6);return{numTemporalLayers:t.readBits(3)+1,temporalIdNested:t.readBoolean()}}readSPS(e){const t=new _g(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.readBits(4);const r=t.readBits(3);t.readBoolean();const i=t.readBits(2),n=t.readBoolean(),s=t.readBits(5),a=t.readUByte(),o=t.readUByte(),l=t.readUByte(),c=t.readUByte(),d=t.readUByte(),u=t.readUByte(),h=t.readUByte(),f=t.readUByte(),p=t.readUByte(),m=t.readUByte(),g=t.readUByte(),v=[],y=[];for(let e=0;e<r;e++)v.push(t.readBoolean()),y.push(t.readBoolean());if(r>0)for(let e=r;e<8;e++)t.readBits(2);for(let e=0;e<r;e++)v[e]&&(t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte()),y[e]&&t.readUByte();t.readUEG();const b=t.readUEG();3==b&&t.skipBits(1);const E=t.readUEG(),w=t.readUEG(),S=t.readBoolean();let T=0,x=0,A=0,k=0;S&&(T+=t.readUEG(),x+=t.readUEG(),A+=t.readUEG(),k+=t.readUEG());const I=t.readUEG(),L=t.readUEG(),R=t.readUEG();for(let e=t.readBoolean()?0:r;e<=r;e++)t.skipUEG(),t.skipUEG(),t.skipUEG();t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG();if(t.readBoolean()){if(t.readBoolean())for(let e=0;e<4;e++)for(let r=0;r<(3===e?2:6);r++){if(t.readBoolean()){const r=Math.min(64,1<<4+(e<<1));e>1&&t.readEG();for(let e=0;e<r;e++)t.readEG()}else t.readUEG()}}t.readBoolean(),t.readBoolean();t.readBoolean()&&(t.readUByte(),t.skipUEG(),t.skipUEG(),t.readBoolean());const P=t.readUEG();let C=0;for(let e=0;e<P;e++){let r=!1;if(0!==e&&(r=t.readBoolean()),r){e===P&&t.readUEG(),t.readBoolean(),t.readUEG();let r=0;for(let e=0;e<=C;e++){const e=t.readBoolean();let i=!1;e||(i=t.readBoolean()),(e||i)&&r++}C=r}else{const e=t.readUEG(),r=t.readUEG();C=e+r;for(let r=0;r<e;r++)t.readUEG(),t.readBoolean();for(let e=0;e<r;e++)t.readUEG(),t.readBoolean()}}if(t.readBoolean()){const e=t.readUEG();for(let r=0;r<e;r++){for(let e=0;e<R+4;e++)t.readBits(1);t.readBits(1)}}let D=0,_=1,O=1,M=!0,N=1,F=0;t.readBoolean(),t.readBoolean();let $=!1;if(t.readBoolean()){if(t.readBoolean()){const e=t.readUByte();e>0&&e<16?(_=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][e-1],O=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][e-1]):255===e&&(_=t.readBits(16),O=t.readBits(16))}t.readBoolean()&&t.readBoolean();if(t.readBoolean()){t.readBits(3),t.readBoolean();t.readBoolean()&&(t.readUByte(),t.readUByte(),t.readUByte())}t.readBoolean()&&(t.readUEG(),t.readUEG()),t.readBoolean(),t.readBoolean(),t.readBoolean(),$=t.readBoolean(),$&&(t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG());if(t.readBoolean()){N=t.readBits(32),F=t.readBits(32);t.readBoolean()&&t.readUEG();if(t.readBoolean()){const e=t.readBoolean(),i=t.readBoolean();let n=!1;(e||i)&&(n=t.readBoolean(),n&&(t.readUByte(),t.readBits(5),t.readBoolean(),t.readBits(5)),t.readBits(4),t.readBits(4),n&&t.readBits(4),t.readBits(5),t.readBits(5),t.readBits(5));for(let s=0;s<=r;s++){M=t.readBoolean();let r=!1;M||t.readBoolean()?t.readEG():r=t.readBoolean();const s=r?1:t.readUEG()+1;if(e)for(let e=0;e<s;e++)t.readUEG(),t.readUEG(),n&&(t.readUEG(),t.readUEG()),t.skipBits(1);if(i)for(let e=0;e<s;e++)t.readUEG(),t.readUEG(),n&&(t.readUEG(),t.readUEG()),t.skipBits(1)}}}t.readBoolean()&&(t.readBoolean(),t.readBoolean(),t.readBoolean(),D=t.readUEG())}let B=E,U=w;if(S){let e=1,t=1;1===b?e=t=2:2==b&&(e=2),B=E-e*x-e*T,U=w-t*k-t*A}const z=i?["A","B","C"][i]:"",G=a<<24|o<<16|l<<8|c;let j=0;for(let e=0;e<32;e++)j=(j|(G>>e&1)<<31-e)>>>0;let H=j.toString(16);1===s&&"2"===H&&(H="6");return{codecString:`hvc1.${z}${s}.${H}.${n?"H":"L"}${g}.B0`,params:{general_tier_flag:n,general_profile_idc:s,general_profile_space:i,general_profile_compatibility_flags:[a,o,l,c],general_constraint_indicator_flags:[d,u,h,f,p,m],general_level_idc:g,bit_depth:I+8,bit_depth_luma_minus8:I,bit_depth_chroma_minus8:L,min_spatial_segmentation_idc:D,chroma_format_idc:b,frame_rate:{fixed:M,fps:F/N}},width:B,height:U,pixelRatio:[_,O]}}readPPS(e){const t=new _g(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.skipUEG(),t.skipUEG(),t.skipBits(2),t.skipBits(3),t.skipBits(2),t.skipUEG(),t.skipUEG(),t.skipEG(),t.skipBits(2);t.readBoolean()&&t.skipUEG(),t.skipEG(),t.skipEG(),t.skipBits(4);const r=t.readBoolean(),i=t.readBoolean();let n=1;return i&&r?n=0:i?n=3:r&&(n=2),{parallelismType:n}}matchSPS(e,t){return String.fromCharCode.apply(null,e).substr(3)===String.fromCharCode.apply(null,t).substr(3)}}const Ng=188;class Fg{constructor(e,t,r,i){this.logger=void 0,this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=e,this.config=t,this.typeSupported=r,this.logger=i,this.videoParser=null}static probe(e,t){const r=Fg.syncOffset(e);return r>0&&t.warn(`MPEG2-TS detected but first sync word found @ offset ${r}`),-1!==r}static syncOffset(e){const t=e.length;let r=Math.min(940,t-Ng)+1,i=0;for(;i<r;){let n=!1,s=-1,a=0;for(let o=i;o<t;o+=Ng){if(71!==e[o]||t-o!==Ng&&71!==e[o+Ng]){if(a)return-1;break}if(a++,-1===s&&(s=o,0!==s&&(r=Math.min(s+18612,e.length-Ng)+1)),n||(n=0===$g(e,o)),n&&a>1&&(0===s&&a>2||o+Ng>r))return s}i++}return-1}static createTrack(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:th[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?t:void 0}}resetInitSegment(e,t,r,i){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=Fg.createTrack("video"),this._videoTrack.duration=i,this._audioTrack=Fg.createTrack("audio",i),this._id3Track=Fg.createTrack("id3"),this._txtTrack=Fg.createTrack("text"),this._audioTrack.segmentCodec="aac",this.videoParser=null,this.aacOverFlow=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=r}resetTimeStamp(){}resetContiguity(){const{_audioTrack:e,_videoTrack:t,_id3Track:r}=this;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.remainderData=null}demux(e,t,r=!1,i=!1){let n;r||(this.sampleAes=null);const s=this._videoTrack,a=this._audioTrack,o=this._id3Track,l=this._txtTrack;let c=s.pid,d=s.pesData,u=a.pid,h=o.pid,f=a.pesData,p=o.pesData,m=null,g=this.pmtParsed,v=this._pmtId,y=e.length;if(this.remainderData&&(y=(e=vh(this.remainderData,e)).length,this.remainderData=null),y<Ng&&!i)return this.remainderData=e,{audioTrack:a,videoTrack:s,id3Track:o,textTrack:l};const b=Math.max(0,Fg.syncOffset(e));y-=(y-b)%Ng,y<e.byteLength&&!i&&(this.remainderData=new Uint8Array(e.buffer,y,e.buffer.byteLength-y));let E=0;for(let t=b;t<y;t+=Ng)if(71===e[t]){const i=!!(64&e[t+1]),y=$g(e,t);let E;if((48&e[t+3])>>4>1){if(E=t+5+e[t+4],E===t+Ng)continue}else E=t+4;switch(y){case c:i&&(d&&(n=jg(d,this.logger))&&(this.readyVideoParser(s.segmentCodec),null!==this.videoParser&&this.videoParser.parsePES(s,l,n,!1)),d={data:[],size:0}),d&&(d.data.push(e.subarray(E,t+Ng)),d.size+=t+Ng-E);break;case u:if(i){if(f&&(n=jg(f,this.logger)))switch(a.segmentCodec){case"aac":this.parseAACPES(a,n);break;case"mp3":this.parseMPEGPES(a,n);break;case"ac3":this.parseAC3PES(a,n)}f={data:[],size:0}}f&&(f.data.push(e.subarray(E,t+Ng)),f.size+=t+Ng-E);break;case h:i&&(p&&(n=jg(p,this.logger))&&this.parseID3PES(o,n),p={data:[],size:0}),p&&(p.data.push(e.subarray(E,t+Ng)),p.size+=t+Ng-E);break;case 0:i&&(E+=e[E]+1),v=this._pmtId=Bg(e,E);break;case v:{i&&(E+=e[E]+1);const n=Ug(e,E,this.typeSupported,r,this.observer,this.logger);c=n.videoPid,c>0&&(s.pid=c,s.segmentCodec=n.segmentVideoCodec),u=n.audioPid,u>0&&(a.pid=u,a.segmentCodec=n.segmentAudioCodec),h=n.id3Pid,h>0&&(o.pid=h),null===m||g||(this.logger.warn(`MPEG-TS PMT found at ${t} after unknown PID '${m}'. Backtracking to sync byte @${b} to parse all TS packets.`),m=null,t=b-188),g=this.pmtParsed=!0;break}case 17:case 8191:break;default:m=y}}else E++;E>0&&zg(this.observer,new Error(`Found ${E} TS packet/s that do not start with 0x47`),void 0,this.logger),s.pesData=d,a.pesData=f,o.pesData=p;const w={audioTrack:a,videoTrack:s,id3Track:o,textTrack:l};return i&&this.extractRemainingSamples(w),w}flush(){const{remainderData:e}=this;let t;return this.remainderData=null,t=e?this.demux(e,-1,!1,!0):{videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t}extractRemainingSamples(e){const{audioTrack:t,videoTrack:r,id3Track:i,textTrack:n}=e,s=r.pesData,a=t.pesData,o=i.pesData;let l;if(s&&(l=jg(s,this.logger))?(this.readyVideoParser(r.segmentCodec),null!==this.videoParser&&(this.videoParser.parsePES(r,n,l,!0),r.pesData=null)):r.pesData=s,a&&(l=jg(a,this.logger))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,l);break;case"mp3":this.parseMPEGPES(t,l);break;case"ac3":this.parseAC3PES(t,l)}t.pesData=null}else null!=a&&a.size&&this.logger.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=a;o&&(l=jg(o,this.logger))?(this.parseID3PES(i,l),i.pesData=null):i.pesData=o}demuxSampleAes(e,t,r){const i=this.demux(e,r,!0,!this.config.progressive),n=this.sampleAes=new Cg(this.observer,this.config,t);return this.decrypt(i,n)}readyVideoParser(e){null===this.videoParser&&("avc"===e?this.videoParser=new Og:"hevc"===e&&(this.videoParser=new Mg))}decrypt(e,t){return new Promise(r=>{const{audioTrack:i,videoTrack:n}=e;i.samples&&"aac"===i.segmentCodec?t.decryptAacSamples(i.samples,0,()=>{n.samples?t.decryptAvcSamples(n.samples,0,0,()=>{r(e)}):r(e)}):n.samples&&t.decryptAvcSamples(n.samples,0,0,()=>{r(e)})})}destroy(){this.observer&&this.observer.removeAllListeners(),this.config=this.logger=this.observer=null,this.aacOverFlow=this.videoParser=this.remainderData=this.sampleAes=null,this._videoTrack=this._audioTrack=this._id3Track=this._txtTrack=void 0}parseAACPES(e,t){let r=0;const i=this.aacOverFlow;let n,s,a,o=t.data;if(i){this.aacOverFlow=null;const t=i.missing,n=i.sample.unit.byteLength;if(-1===t)o=vh(i.sample.unit,o);else{const s=n-t;i.sample.unit.set(o.subarray(0,t),s),e.samples.push(i.sample),r=i.missing}}for(n=r,s=o.length;n<s-1&&!Zm(o,n);n++);if(n!==r){let e;const t=n<s-1;if(e=t?`AAC PES did not start with ADTS header,offset:${n}`:"No ADTS header found in AAC PES",zg(this.observer,new Error(e),t,this.logger),!t)return}if(eg(e,this.observer,o,n,this.audioCodec),void 0!==t.pts)a=t.pts;else{if(!i)return void this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");{const t=tg(e.samplerate);a=i.sample.pts+t}}let l,c=0;for(;n<s;){if(l=rg(e,o,n,a,c),n+=l.length,l.missing){this.aacOverFlow=l;break}for(c++;n<s-1&&!Zm(o,n);n++);}}parseMPEGPES(e,t){const r=t.data,i=r.length;let n=0,s=0;const a=t.pts;if(void 0!==a)for(;s<i;)if(xg(r,s)){const t=wg(e,r,s,a,n);if(!t)break;s+=t.length,n++}else s++;else this.logger.warn("[tsdemuxer]: MPEG PES unknown PTS")}parseAC3PES(e,t){{const r=t.data,i=t.pts;if(void 0===i)return void this.logger.warn("[tsdemuxer]: AC3 PES unknown PTS");const n=r.length;let s,a=0,o=0;for(;o<n&&(s=Lg(e,r,o,i,a++))>0;)o+=s}}parseID3PES(e,t){if(void 0===t.pts)return void this.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");const r=Eu({},t,{type:this._videoTrack?hg.emsg:hg.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(r)}}function $g(e,t){return((31&e[t+1])<<8)+e[t+2]}function Bg(e,t){return(31&e[t+10])<<8|e[t+11]}function Ug(e,t,r,i,n,s){const a={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},o=t+3+((15&e[t+1])<<8|e[t+2])-4;for(t+=12+((15&e[t+10])<<8|e[t+11]);t<o;){const o=$g(e,t),l=(15&e[t+3])<<8|e[t+4];switch(e[t]){case 207:if(!i){Gg("ADTS AAC",s);break}case 15:-1===a.audioPid&&(a.audioPid=o);break;case 21:-1===a.id3Pid&&(a.id3Pid=o);break;case 219:if(!i){Gg("H.264",s);break}case 27:-1===a.videoPid&&(a.videoPid=o);break;case 3:case 4:r.mpeg||r.mp3?-1===a.audioPid&&(a.audioPid=o,a.segmentAudioCodec="mp3"):s.log("MPEG audio found, not supported in this browser");break;case 193:if(!i){Gg("AC-3",s);break}case 129:r.ac3?-1===a.audioPid&&(a.audioPid=o,a.segmentAudioCodec="ac3"):s.log("AC-3 audio found, not supported in this browser");break;case 6:if(-1===a.audioPid&&l>0){let i=t+5,n=l;for(;n>2;){if(106===e[i])!0!==r.ac3?s.log("AC-3 audio found, not supported in this browser for now"):(a.audioPid=o,a.segmentAudioCodec="ac3");const t=e[i+1]+2;i+=t,n-=t}}break;case 194:case 135:return zg(n,new Error("Unsupported EC-3 in M2TS found"),void 0,s),a;case 36:-1===a.videoPid&&(a.videoPid=o,a.segmentVideoCodec="hevc",s.log("HEVC in M2TS found"))}t+=l+5}return a}function zg(e,t,r,i){i.warn(`parsing error: ${t.message}`),e.emit(cu.ERROR,cu.ERROR,{type:ou.MEDIA_ERROR,details:lu.FRAG_PARSING_ERROR,fatal:!1,levelRetry:r,error:t,reason:t.message})}function Gg(e,t){t.log(`${e} with AES-128-CBC encryption found in unencrypted stream`)}function jg(e,t){let r,i,n,s,a,o=0;const l=e.data;if(!e||0===e.size)return null;for(;l[0].length<19&&l.length>1;)l[0]=vh(l[0],l[1]),l.splice(1,1);r=l[0];if(1===(r[0]<<16)+(r[1]<<8)+r[2]){if(i=(r[4]<<8)+r[5],i&&i>e.size-6)return null;const c=r[7];192&c&&(s=536870912*(14&r[9])+4194304*(255&r[10])+16384*(254&r[11])+128*(255&r[12])+(254&r[13])/2,64&c?(a=536870912*(14&r[14])+4194304*(255&r[15])+16384*(254&r[16])+128*(255&r[17])+(254&r[18])/2,s-a>54e5&&(t.warn(`${Math.round((s-a)/9e4)}s delta between PTS and DTS, align them`),s=a)):a=s),n=r[8];let d=n+9;if(e.size<=d)return null;e.size-=d;const u=new Uint8Array(e.size);for(let e=0,t=l.length;e<t;e++){r=l[e];let t=r.byteLength;if(d){if(d>t){d-=t;continue}r=r.subarray(d),t-=d,d=0}u.set(r,o),o+=t}return i&&(i-=n+3),{data:u,pts:s,dts:a,len:i}}return null}class Hg{static getSilentFrame(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===t)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}}}const Vg=Math.pow(2,32)-1;class Wg{static init(){let e;for(e in Wg.types={avc1:[],avcC:[],hvc1:[],hvcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},Wg.types)Wg.types.hasOwnProperty(e)&&(Wg.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);const t=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),r=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);Wg.HDLR_TYPES={video:t,audio:r};const i=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),n=new Uint8Array([0,0,0,0,0,0,0,0]);Wg.STTS=Wg.STSC=Wg.STCO=n,Wg.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),Wg.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),Wg.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),Wg.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const s=new Uint8Array([105,115,111,109]),a=new Uint8Array([97,118,99,49]),o=new Uint8Array([0,0,0,1]);Wg.FTYP=Wg.box(Wg.types.ftyp,s,o,s,a),Wg.DINF=Wg.box(Wg.types.dinf,Wg.box(Wg.types.dref,i))}static box(e,...t){let r=8,i=t.length;const n=i;for(;i--;)r+=t[i].byteLength;const s=new Uint8Array(r);for(s[0]=r>>24&255,s[1]=r>>16&255,s[2]=r>>8&255,s[3]=255&r,s.set(e,4),i=0,r=8;i<n;i++)s.set(t[i],r),r+=t[i].byteLength;return s}static hdlr(e){return Wg.box(Wg.types.hdlr,Wg.HDLR_TYPES[e])}static mdat(e){return Wg.box(Wg.types.mdat,e)}static mdhd(e,t){t*=e;const r=Math.floor(t/(Vg+1)),i=Math.floor(t%(Vg+1));return Wg.box(Wg.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,r>>24,r>>16&255,r>>8&255,255&r,i>>24,i>>16&255,i>>8&255,255&i,85,196,0,0]))}static mdia(e){return Wg.box(Wg.types.mdia,Wg.mdhd(e.timescale||0,e.duration||0),Wg.hdlr(e.type),Wg.minf(e))}static mfhd(e){return Wg.box(Wg.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e]))}static minf(e){return"audio"===e.type?Wg.box(Wg.types.minf,Wg.box(Wg.types.smhd,Wg.SMHD),Wg.DINF,Wg.stbl(e)):Wg.box(Wg.types.minf,Wg.box(Wg.types.vmhd,Wg.VMHD),Wg.DINF,Wg.stbl(e))}static moof(e,t,r){return Wg.box(Wg.types.moof,Wg.mfhd(e),Wg.traf(r,t))}static moov(e){let t=e.length;const r=[];for(;t--;)r[t]=Wg.trak(e[t]);return Wg.box.apply(null,[Wg.types.moov,Wg.mvhd(e[0].timescale||0,e[0].duration||0)].concat(r).concat(Wg.mvex(e)))}static mvex(e){let t=e.length;const r=[];for(;t--;)r[t]=Wg.trex(e[t]);return Wg.box.apply(null,[Wg.types.mvex,...r])}static mvhd(e,t){t*=e;const r=Math.floor(t/(Vg+1)),i=Math.floor(t%(Vg+1)),n=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,r>>24,r>>16&255,r>>8&255,255&r,i>>24,i>>16&255,i>>8&255,255&i,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return Wg.box(Wg.types.mvhd,n)}static sdtp(e){const t=e.samples||[],r=new Uint8Array(4+t.length);let i,n;for(i=0;i<t.length;i++)n=t[i].flags,r[i+4]=n.dependsOn<<4|n.isDependedOn<<2|n.hasRedundancy;return Wg.box(Wg.types.sdtp,r)}static stbl(e){return Wg.box(Wg.types.stbl,Wg.stsd(e),Wg.box(Wg.types.stts,Wg.STTS),Wg.box(Wg.types.stsc,Wg.STSC),Wg.box(Wg.types.stsz,Wg.STSZ),Wg.box(Wg.types.stco,Wg.STCO))}static avc1(e){let t,r,i,n=[],s=[];for(t=0;t<e.sps.length;t++)r=e.sps[t],i=r.byteLength,n.push(i>>>8&255),n.push(255&i),n=n.concat(Array.prototype.slice.call(r));for(t=0;t<e.pps.length;t++)r=e.pps[t],i=r.byteLength,s.push(i>>>8&255),s.push(255&i),s=s.concat(Array.prototype.slice.call(r));const a=Wg.box(Wg.types.avcC,new Uint8Array([1,n[3],n[4],n[5],255,224|e.sps.length].concat(n).concat([e.pps.length]).concat(s))),o=e.width,l=e.height,c=e.pixelRatio[0],d=e.pixelRatio[1];return Wg.box(Wg.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,o>>8&255,255&o,l>>8&255,255&l,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),a,Wg.box(Wg.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),Wg.box(Wg.types.pasp,new Uint8Array([c>>24,c>>16&255,c>>8&255,255&c,d>>24,d>>16&255,d>>8&255,255&d])))}static esds(e){const t=e.config;return new Uint8Array([0,0,0,0,3,25,0,1,0,4,17,64,21,0,0,0,0,0,0,0,0,0,0,0,5,2,...t,6,1,2])}static audioStsd(e){const t=e.samplerate||0;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount||0,0,16,0,0,0,0,t>>8&255,255&t,0,0])}static mp4a(e){return Wg.box(Wg.types.mp4a,Wg.audioStsd(e),Wg.box(Wg.types.esds,Wg.esds(e)))}static mp3(e){return Wg.box(Wg.types[".mp3"],Wg.audioStsd(e))}static ac3(e){return Wg.box(Wg.types["ac-3"],Wg.audioStsd(e),Wg.box(Wg.types.dac3,e.config))}static stsd(e){const{segmentCodec:t}=e;if("audio"===e.type){if("aac"===t)return Wg.box(Wg.types.stsd,Wg.STSD,Wg.mp4a(e));if("ac3"===t&&e.config)return Wg.box(Wg.types.stsd,Wg.STSD,Wg.ac3(e));if("mp3"===t&&"mp3"===e.codec)return Wg.box(Wg.types.stsd,Wg.STSD,Wg.mp3(e))}else{if(!e.pps||!e.sps)throw new Error("video track missing pps or sps");if("avc"===t)return Wg.box(Wg.types.stsd,Wg.STSD,Wg.avc1(e));if("hevc"===t&&e.vps)return Wg.box(Wg.types.stsd,Wg.STSD,Wg.hvc1(e))}throw new Error(`unsupported ${e.type} segment codec (${t}/${e.codec})`)}static tkhd(e){const t=e.id,r=(e.duration||0)*(e.timescale||0),i=e.width||0,n=e.height||0,s=Math.floor(r/(Vg+1)),a=Math.floor(r%(Vg+1));return Wg.box(Wg.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,0,0,0,0,s>>24,s>>16&255,s>>8&255,255&s,a>>24,a>>16&255,a>>8&255,255&a,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,i>>8&255,255&i,0,0,n>>8&255,255&n,0,0]))}static traf(e,t){const r=Wg.sdtp(e),i=e.id,n=Math.floor(t/(Vg+1)),s=Math.floor(t%(Vg+1));return Wg.box(Wg.types.traf,Wg.box(Wg.types.tfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i])),Wg.box(Wg.types.tfdt,new Uint8Array([1,0,0,0,n>>24,n>>16&255,n>>8&255,255&n,s>>24,s>>16&255,s>>8&255,255&s])),Wg.trun(e,r.length+16+20+8+16+8+8),r)}static trak(e){return e.duration=e.duration||4294967295,Wg.box(Wg.types.trak,Wg.tkhd(e),Wg.mdia(e))}static trex(e){const t=e.id;return Wg.box(Wg.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,t){const r=e.samples||[],i=r.length,n=12+16*i,s=new Uint8Array(n);let a,o,l,c,d,u;for(t+=8+n,s.set(["video"===e.type?1:0,0,15,1,i>>>24&255,i>>>16&255,i>>>8&255,255&i,t>>>24&255,t>>>16&255,t>>>8&255,255&t],0),a=0;a<i;a++)o=r[a],l=o.duration,c=o.size,d=o.flags,u=o.cts,s.set([l>>>24&255,l>>>16&255,l>>>8&255,255&l,c>>>24&255,c>>>16&255,c>>>8&255,255&c,d.isLeading<<2|d.dependsOn,d.isDependedOn<<6|d.hasRedundancy<<4|d.paddingValue<<1|d.isNonSync,61440&d.degradPrio,15&d.degradPrio,u>>>24&255,u>>>16&255,u>>>8&255,255&u],12+16*a);return Wg.box(Wg.types.trun,s)}static initSegment(e){Wg.types||Wg.init();const t=Wg.moov(e);return vh(Wg.FTYP,t)}static hvc1(e){const t=e.params,r=[e.vps,e.sps,e.pps],i=new Uint8Array([1,t.general_profile_space<<6|(t.general_tier_flag?32:0)|t.general_profile_idc,t.general_profile_compatibility_flags[0],t.general_profile_compatibility_flags[1],t.general_profile_compatibility_flags[2],t.general_profile_compatibility_flags[3],t.general_constraint_indicator_flags[0],t.general_constraint_indicator_flags[1],t.general_constraint_indicator_flags[2],t.general_constraint_indicator_flags[3],t.general_constraint_indicator_flags[4],t.general_constraint_indicator_flags[5],t.general_level_idc,240|t.min_spatial_segmentation_idc>>8,255&t.min_spatial_segmentation_idc,252|t.parallelismType,252|t.chroma_format_idc,248|t.bit_depth_luma_minus8,248|t.bit_depth_chroma_minus8,0,parseInt(t.frame_rate.fps),3|t.temporal_id_nested<<2|t.num_temporal_layers<<3|(t.frame_rate.fixed?64:0),r.length]);let n=i.length;for(let e=0;e<r.length;e+=1){n+=3;for(let t=0;t<r[e].length;t+=1)n+=2+r[e][t].length}const s=new Uint8Array(n);s.set(i,0),n=i.length;const a=r.length-1;for(let e=0;e<r.length;e+=1){s.set(new Uint8Array([32+e|(e===a?128:0),0,r[e].length]),n),n+=3;for(let t=0;t<r[e].length;t+=1)s.set(new Uint8Array([r[e][t].length>>8,255&r[e][t].length]),n),n+=2,s.set(r[e][t],n),n+=r[e][t].length}const o=Wg.box(Wg.types.hvcC,s),l=e.width,c=e.height,d=e.pixelRatio[0],u=e.pixelRatio[1];return Wg.box(Wg.types.hvc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,l>>8&255,255&l,c>>8&255,255&c,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,Wg.box(Wg.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),Wg.box(Wg.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,255&d,u>>24,u>>16&255,u>>8&255,255&u])))}}Wg.types=void 0,Wg.HDLR_TYPES=void 0,Wg.STTS=void 0,Wg.STSC=void 0,Wg.STCO=void 0,Wg.STSZ=void 0,Wg.VMHD=void 0,Wg.SMHD=void 0,Wg.STSD=void 0,Wg.FTYP=void 0,Wg.DINF=void 0;function Yg(e,t,r=1,i=!1){const n=e*t*r;return i?Math.round(n):n}function Kg(e,t=!1){return Yg(e,1e3,1/9e4,t)}function qg(e){const{baseTime:t,timescale:r,trackId:i}=e;return`${t/r} (${t}/${r}) trackId: ${i}`}let Xg,Qg=null,Zg=null;function Jg(e,t,r,i){return{duration:t,size:r,cts:i,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:e?2:1,isNonSync:e?0:1}}}class ev extends Tu{constructor(e,t,r,i){if(super("mp4-remuxer",i),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextVideoTs=null,this.nextAudioTs=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=e,this.config=t,this.typeSupported=r,this.ISGenerated=!1,null===Qg){const e=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Qg=e?parseInt(e[1]):0}if(null===Zg){const e=navigator.userAgent.match(/Safari\/(\d+)/i);Zg=e?parseInt(e[1]):0}}destroy(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}resetTimeStamp(e){const t=this._initPTS;t&&e&&e.trackId===t.trackId&&e.baseTime===t.baseTime&&e.timescale===t.timescale||this.log(`Reset initPTS: ${t?qg(t):t} > ${e?qg(e):e}`),this._initPTS=this._initDTS=e}resetNextTimestamp(){this.log("reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){this.log("ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}getVideoStartPts(e){let t=!1;const r=e[0].pts,i=e.reduce((e,i)=>{let n=i.pts,s=n-e;return s<-4294967296&&(t=!0,n=tv(n,r),s=n-e),s>0?e:n},r);return t&&this.debug("PTS rollover detected"),i}remux(e,t,r,i,n,s,a,o){let l,c,d,u,h,f,p=n,m=n;const g=e.pid>-1,v=t.pid>-1,y=t.samples.length,b=e.samples.length>0,E=a&&y>0||y>1;if((!g||b)&&(!v||E)||this.ISGenerated||a){if(this.ISGenerated){var w,S,T,x;const e=this.videoTrackConfig;(e&&(t.width!==e.width||t.height!==e.height||(null==(w=t.pixelRatio)?void 0:w[0])!==(null==(S=e.pixelRatio)?void 0:S[0])||(null==(T=t.pixelRatio)?void 0:T[1])!==(null==(x=e.pixelRatio)?void 0:x[1]))||!e&&E||null===this.nextAudioTs&&b)&&this.resetInitSegment()}this.ISGenerated||(d=this.generateIS(e,t,n,s));const r=this.isVideoContiguous;let i,a=-1;if(E&&(a=function(e){for(let t=0;t<e.length;t++)if(e[t].key)return t;return-1}(t.samples),!r&&this.config.forceKeyFrameOnDiscontinuity))if(f=!0,a>0){this.warn(`Dropped ${a} out of ${y} video samples due to a missing keyframe`);const e=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(a),t.dropped+=a,m+=(t.samples[0].pts-e)/t.inputTimeScale,i=m}else-1===a&&(this.warn(`No keyframe found out of ${y} video samples`),f=!1);if(this.ISGenerated){if(b&&E){const r=this.getVideoStartPts(t.samples),i=(tv(e.samples[0].pts,r)-r)/t.inputTimeScale;p+=Math.max(0,i),m+=Math.max(0,-i)}if(b){if(e.samplerate||(this.warn("regenerate InitSegment as audio detected"),d=this.generateIS(e,t,n,s)),c=this.remuxAudio(e,p,this.isAudioContiguous,s,v||E||o===mu?m:void 0),E){const i=c?c.endPTS-c.startPTS:0;t.inputTimeScale||(this.warn("regenerate InitSegment as video detected"),d=this.generateIS(e,t,n,s)),l=this.remuxVideo(t,m,r,i)}}else E&&(l=this.remuxVideo(t,m,r,0));l&&(l.firstKeyFrame=a,l.independent=-1!==a,l.firstKeyFramePTS=i)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(h=rv(r,n,this._initPTS,this._initDTS)),i.samples.length&&(u=iv(i,n,this._initPTS))),{audio:c,video:l,initSegment:d,independent:f,text:u,id3:h}}computeInitPts(e,t,r,i){const n=Math.round(r*t);let s=tv(e,n);if(s<n+t)for(this.log(`Adjusting PTS for rollover in timeline near ${(n-s)/t} ${i}`);s<n+t;)s+=8589934592;return s-n}generateIS(e,t,r,i){const n=e.samples,s=t.samples,a=this.typeSupported,o={},l=this._initPTS;let c,d,u,h=!l||i,f="audio/mp4",p=-1;if(h&&(c=d=1/0),e.config&&n.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":a.mpeg?(f="audio/mpeg",e.codec=""):a.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3"}o.audio={id:"audio",container:f,codec:e.codec,initSegment:"mp3"===e.segmentCodec&&a.mpeg?new Uint8Array(0):Wg.initSegment([e]),metadata:{channelCount:e.channelCount}},h&&(p=e.id,u=e.inputTimeScale,l&&u===l.timescale?h=!1:c=d=this.computeInitPts(n[0].pts,u,r,"audio"))}if(t.sps&&t.pps&&s.length){if(t.timescale=t.inputTimeScale,o.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:Wg.initSegment([t]),metadata:{width:t.width,height:t.height}},h)if(p=t.id,u=t.inputTimeScale,l&&u===l.timescale)h=!1;else{const e=this.getVideoStartPts(s),t=tv(s[0].dts,e),i=this.computeInitPts(t,u,r,"video"),n=this.computeInitPts(e,u,r,"video");d=Math.min(d,i),c=Math.min(c,n)}this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(o).length)return this.ISGenerated=!0,h?(l&&this.warn(`Timestamps at playlist time: ${i?"":"~"}${r} ${c/u} != initPTS: ${l.baseTime/l.timescale} (${l.baseTime}/${l.timescale}) trackId: ${l.trackId}`),this.log(`Found initPTS at playlist time: ${r} offset: ${c/u} (${c}/${u}) trackId: ${p}`),this._initPTS={baseTime:c,timescale:u,trackId:p},this._initDTS={baseTime:d,timescale:u,trackId:p}):c=u=void 0,{tracks:o,initPTS:c,timescale:u,trackId:p}}remuxVideo(e,t,r,i){const n=e.inputTimeScale,s=e.samples,a=[],o=s.length,l=this._initPTS,c=l.baseTime*n/l.timescale;let d,u,h=this.nextVideoTs,f=8,p=this.videoSampleDuration,m=Number.POSITIVE_INFINITY,g=Number.NEGATIVE_INFINITY,v=!1;if(!r||null===h){const e=c+t*n,i=s[0].pts-tv(s[0].dts,s[0].pts);Qg&&null!==h&&Math.abs(e-i-(h+c))<15e3?r=!0:h=e-i-c}const y=h+c;for(let e=0;e<o;e++){const t=s[e];t.pts=tv(t.pts,y),t.dts=tv(t.dts,y),t.dts<s[e>0?e-1:e].dts&&(v=!0)}v&&s.sort(function(e,t){const r=e.dts-t.dts,i=e.pts-t.pts;return r||i}),d=s[0].dts,u=s[s.length-1].dts;const b=u-d,E=b?Math.round(b/(o-1)):p||e.inputTimeScale/30;if(r){const r=d-y,i=r>E,n=r<-1;if((i||n)&&(i?this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${Kg(r,!0)} ms (${r}dts) hole between fragments detected at ${t.toFixed(3)}`):this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${Kg(-r,!0)} ms (${r}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!n||y>=s[0].pts||Qg)){d=y;const e=s[0].pts-r;if(i)s[0].dts=d,s[0].pts=e;else{let t=!0;for(let i=0;i<s.length&&!(s[i].dts>e&&t);i++){const e=s[i].pts;if(s[i].dts-=r,s[i].pts-=r,i<s.length-1){const r=s[i+1].pts;t=r<=s[i].pts==r<=e}}}this.log(`Video: Initial PTS/DTS adjusted: ${Kg(e,!0)}/${Kg(d,!0)}, delta: ${Kg(r,!0)} ms`)}}d=Math.max(0,d);let w=0,S=0,T=d;for(let e=0;e<o;e++){const t=s[e],r=t.units,i=r.length;let n=0;for(let e=0;e<i;e++)n+=r[e].data.length;S+=n,w+=i,t.length=n,t.dts<T?(t.dts=T,T+=E/4|0||1):T=t.dts,m=Math.min(t.pts,m),g=Math.max(t.pts,g)}u=s[o-1].dts;const x=S+4*w+8;let A;try{A=new Uint8Array(x)}catch(e){return void this.observer.emit(cu.ERROR,cu.ERROR,{type:ou.MUX_ERROR,details:lu.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:x,reason:`fail allocating video mdat ${x}`})}const k=new DataView(A.buffer);k.setUint32(0,x),A.set(Wg.types.mdat,4);let I=!1,L=Number.POSITIVE_INFINITY,R=Number.POSITIVE_INFINITY,P=Number.NEGATIVE_INFINITY,C=Number.NEGATIVE_INFINITY;for(let e=0;e<o;e++){const t=s[e],r=t.units;let l,d=0;for(let e=0,t=r.length;e<t;e++){const t=r[e],i=t.data,n=t.data.byteLength;k.setUint32(f,n),f+=4,A.set(i,f),f+=n,d+=4+n}if(e<o-1)p=s[e+1].dts-t.dts,l=s[e+1].pts-t.pts;else{const r=this.config,a=e>0?t.dts-s[e-1].dts:E;if(l=e>0?t.pts-s[e-1].pts:E,r.stretchShortVideoTrack&&null!==this.nextAudioTs){const e=Math.floor(r.maxBufferHole*n),s=(i?m+i*n:this.nextAudioTs+c)-t.pts;s>e?(p=s-a,p<0?p=a:I=!0,this.log(`It is approximately ${s/90} ms to the next segment; using duration ${p/90} ms for the last video frame.`)):p=a}else p=a}const u=Math.round(t.pts-t.dts);L=Math.min(L,p),P=Math.max(P,p),R=Math.min(R,l),C=Math.max(C,l),a.push(Jg(t.key,p,d,u))}if(a.length)if(Qg){if(Qg<70){const e=a[0].flags;e.dependsOn=2,e.isNonSync=0}}else if(Zg&&C-R<P-L&&E/P<.025&&0===a[0].cts){this.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let e=d;for(let t=0,r=a.length;t<r;t++){const i=e+a[t].duration,n=e+a[t].cts;if(t<r-1){const e=i+a[t+1].cts;a[t].duration=e-n}else a[t].duration=t?a[t-1].duration:E;a[t].cts=0,e=i}}p=I||!p?E:p;const D=u+p;this.nextVideoTs=h=D-c,this.videoSampleDuration=p,this.isVideoContiguous=!0;const _={data1:Wg.moof(e.sequenceNumber++,d,Eu(e,{samples:a})),data2:A,startPTS:(m-c)/n,endPTS:(g+p-c)/n,startDTS:(d-c)/n,endDTS:h/n,type:"video",hasAudio:!1,hasVideo:!0,nb:a.length,dropped:e.dropped};return e.samples=[],e.dropped=0,_}getSamplesPerFrame(e){switch(e.segmentCodec){case"mp3":return 1152;case"ac3":return 1536;default:return 1024}}remuxAudio(e,t,r,i,n){const s=e.inputTimeScale,a=s/(e.samplerate?e.samplerate:s),o=this.getSamplesPerFrame(e),l=o*a,c=this._initPTS,d="mp3"===e.segmentCodec&&this.typeSupported.mpeg,u=[],h=void 0!==n;let f=e.samples,p=d?0:8,m=this.nextAudioTs||-1;const g=c.baseTime*s/c.timescale,v=g+t*s;if(this.isAudioContiguous=r=r||f.length&&m>0&&(i&&Math.abs(v-(m+g))<9e3||Math.abs(tv(f[0].pts,v)-(m+g))<20*l),f.forEach(function(e){e.pts=tv(e.pts,v)}),!r||m<0){const e=f.length;if(f=f.filter(e=>e.pts>=0),e!==f.length&&this.warn(`Removed ${f.length-e} of ${e} samples (initPTS ${g} / ${s})`),!f.length)return;m=0===n?0:i&&!h?Math.max(0,v-g):f[0].pts-g}if("aac"===e.segmentCodec){const t=this.config.maxAudioFramesDrift;for(let r=0,i=m+g;r<f.length;r++){const n=f[r],a=n.pts,o=a-i,c=Math.abs(1e3*o/s);if(o<=-t*l&&h)0===r&&(this.warn(`Audio frame @ ${(a/s).toFixed(3)}s overlaps marker by ${Math.round(1e3*o/s)} ms.`),this.nextAudioTs=m=a-g,i=a);else if(o>=t*l&&c<1e4&&h){let t=Math.round(o/l);for(i=a-t*l;i<0&&t&&l;)t--,i+=l;0===r&&(this.nextAudioTs=m=i-g),this.warn(`Injecting ${t} audio frames @ ${((i-g)/s).toFixed(3)}s due to ${Math.round(1e3*o/s)} ms gap.`);for(let s=0;s<t;s++){let t=Hg.getSilentFrame(e.parsedCodec||e.manifestCodec||e.codec,e.channelCount);t||(this.log("Unable to get silent frame for given audio codec; duplicating last frame instead."),t=n.unit.subarray()),f.splice(r,0,{unit:t,pts:i}),i+=l,r++}}n.pts=i,i+=l}}let y,b=null,E=null,w=0,S=f.length;for(;S--;)w+=f[S].unit.byteLength;for(let t=0,i=f.length;t<i;t++){const i=f[t],n=i.unit;let s=i.pts;if(null!==E){u[t-1].duration=Math.round((s-E)/a)}else{if(r&&"aac"===e.segmentCodec&&(s=m+g),b=s,!(w>0))return;w+=p;try{y=new Uint8Array(w)}catch(e){return void this.observer.emit(cu.ERROR,cu.ERROR,{type:ou.MUX_ERROR,details:lu.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:w,reason:`fail allocating audio mdat ${w}`})}if(!d){new DataView(y.buffer).setUint32(0,w),y.set(Wg.types.mdat,4)}}y.set(n,p);const l=n.byteLength;p+=l,u.push(Jg(!0,o,l,0)),E=s}const T=u.length;if(!T)return;const x=u[u.length-1];m=E-g,this.nextAudioTs=m+a*x.duration;const A=d?new Uint8Array(0):Wg.moof(e.sequenceNumber++,b/a,Eu({},e,{samples:u}));e.samples=[];const k=(b-g)/s,I=this.nextAudioTs/s,L={data1:A,data2:y,startPTS:k,endPTS:I,startDTS:k,endDTS:I,type:"audio",hasAudio:!0,hasVideo:!1,nb:T};return this.isAudioContiguous=!0,L}}function tv(e,t){let r;if(null===t)return e;for(r=t<e?-8589934592:8589934592;Math.abs(e-t)>4294967296;)e+=r;return e}function rv(e,t,r,i){const n=e.samples.length;if(!n)return;const s=e.inputTimeScale;for(let a=0;a<n;a++){const n=e.samples[a];n.pts=tv(n.pts-r.baseTime*s/r.timescale,t*s)/s,n.dts=tv(n.dts-i.baseTime*s/i.timescale,t*s)/s}const a=e.samples;return e.samples=[],{samples:a}}function iv(e,t,r){const i=e.samples.length;if(!i)return;const n=e.inputTimeScale;for(let s=0;s<i;s++){const i=e.samples[s];i.pts=tv(i.pts-r.baseTime*n/r.timescale,t*n)/n}e.samples.sort((e,t)=>e.pts-t.pts);const s=e.samples;return e.samples=[],{samples:s}}function nv(e,t,r=!1){return void 0!==(null==e?void 0:e.start)?(e.start+(r?e.duration:0))/e.timescale:t}function sv(e,t,r){const i=e.codec;if(i&&i.length>4)return i;if(t===Vu){if("ec-3"===i||"ac-3"===i||"alac"===i)return i;if("fLaC"===i||"Opus"===i){return Mh(i,!1)}return r.warn(`Unhandled audio codec "${i}" in mp4 MAP`),i||"mp4a"}return r.warn(`Unhandled video codec "${i}" in mp4 MAP`),i||"avc1"}try{Xg=self.performance.now.bind(self.performance)}catch(e){Xg=Date.now}const av=[{demux:class{constructor(e,t){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=t}resetTimeStamp(){}resetInitSegment(e,t,r,i){const n=this.videoTrack=fg("video",1),s=this.audioTrack=fg("audio",1),a=this.txtTrack=fg("text",1);if(this.id3Track=fg("id3",1),this.timeOffset=0,null==e||!e.byteLength)return;const o=ch(e);if(o.video){const{id:e,timescale:t,codec:r,supplemental:i}=o.video;n.id=e,n.timescale=a.timescale=t,n.codec=r,n.supplemental=i}if(o.audio){const{id:e,timescale:t,codec:r}=o.audio;s.id=e,s.timescale=t,s.codec=r}a.id=th.text,n.sampleDuration=0,n.duration=s.duration=i}resetContiguity(){this.remainderData=null}static probe(e){return function(e){const t=e.byteLength;for(let r=0;r<t;){const i=nh(e,r);if(i>8&&109===e[r+4]&&111===e[r+5]&&111===e[r+6]&&102===e[r+7])return!0;r=i>1?r+i:t}return!1}(e)}demux(e,t){this.timeOffset=t;let r=e;const i=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=vh(this.remainderData,e));const t=function(e){const t={valid:null,remainder:null},r=oh(e,["moof"]);if(r.length<2)return t.remainder=e,t;const i=r[r.length-1];return t.valid=e.slice(0,i.byteOffset-8),t.remainder=e.slice(i.byteOffset-8),t}(r);this.remainderData=t.remainder,i.samples=t.valid||new Uint8Array}else i.samples=r;const s=this.extractID3Track(i,t);return n.samples=yh(t,i),{videoTrack:i,audioTrack:this.audioTrack,id3Track:s,textTrack:this.txtTrack}}flush(){const e=this.timeOffset,t=this.videoTrack,r=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;const i=this.extractID3Track(t,this.timeOffset);return r.samples=yh(e,t),{videoTrack:t,audioTrack:fg(),id3Track:i,textTrack:fg()}}extractID3Track(e,t){const r=this.id3Track;if(e.samples.length){const i=oh(e.samples,["emsg"]);i&&i.forEach(e=>{const i=function(e){const t=e[0];let r="",i="",n=0,s=0,a=0,o=0,l=0,c=0;if(0===t){for(;"\0"!==rh(e.subarray(c,c+1));)r+=rh(e.subarray(c,c+1)),c+=1;for(r+=rh(e.subarray(c,c+1)),c+=1;"\0"!==rh(e.subarray(c,c+1));)i+=rh(e.subarray(c,c+1)),c+=1;i+=rh(e.subarray(c,c+1)),c+=1,n=nh(e,12),s=nh(e,16),o=nh(e,20),l=nh(e,24),c=28}else if(1===t){c+=4,n=nh(e,c),c+=4;const t=nh(e,c);c+=4;const s=nh(e,c);for(c+=4,a=2**32*t+s,su(a)||(a=Number.MAX_SAFE_INTEGER,Ru.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=nh(e,c),c+=4,l=nh(e,c),c+=4;"\0"!==rh(e.subarray(c,c+1));)r+=rh(e.subarray(c,c+1)),c+=1;for(r+=rh(e.subarray(c,c+1)),c+=1;"\0"!==rh(e.subarray(c,c+1));)i+=rh(e.subarray(c,c+1)),c+=1;i+=rh(e.subarray(c,c+1)),c+=1}return{schemeIdUri:r,value:i,timeScale:n,presentationTime:a,presentationTimeDelta:s,eventDuration:o,id:l,payload:e.subarray(c,e.byteLength)}}(e);if(Rg.test(i.schemeIdUri)){const e=Pg(i,t);let n=4294967295===i.eventDuration?Number.POSITIVE_INFINITY:i.eventDuration/i.timeScale;n<=.001&&(n=Number.POSITIVE_INFINITY);const s=i.payload;r.samples.push({data:s,len:s.byteLength,dts:e,pts:e,type:hg.emsg,duration:n})}else if(this.config.enableEmsgKLVMetadata&&i.schemeIdUri.startsWith("urn:misb:KLV:bin:1910.1")){const e=Pg(i,t);r.samples.push({data:i.payload,len:i.payload.byteLength,dts:e,pts:e,type:hg.misbklv,duration:Number.POSITIVE_INFINITY})}})}return r}demuxSampleAes(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){this.config=null,this.remainderData=null,this.videoTrack=this.audioTrack=this.id3Track=this.txtTrack=void 0}},remux:class extends Tu{constructor(e,t,r,i){super("passthrough-remuxer",i),this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null,this.isVideoContiguous=!1}destroy(){}resetTimeStamp(e){this.lastEndTime=null;const t=this.initPTS;t&&e&&t.baseTime===e.baseTime&&t.timescale===e.timescale||(this.initPTS=e)}resetNextTimestamp(){this.isVideoContiguous=!1,this.lastEndTime=null}resetInitSegment(e,t,r,i){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(e,i),this.emitInitSegment=!0}generateInitSegment(e,t){let{audioCodec:r,videoCodec:i}=this;if(null==e||!e.byteLength)return this.initTracks=void 0,void(this.initData=void 0);const{audio:n,video:s}=this.initData=ch(e);if(t)!function(e,t){if(!e||!t)return;const r=t.keyId;r&&t.isCommonEncryption&&mh(e,(e,t)=>{const i=e.subarray(8,24);i.some(e=>0!==e)||(Ru.log(`[eme] Patching keyId in 'enc${t?"a":"v"}>sinf>>tenc' box: ${_u(i)} -> ${_u(r)}`),e.set(r,8))})}(e,t);else{const e=n||s;null!=e&&e.encrypted&&this.warn(`Init segment with encrypted track with has no key ("${e.codec}")!`)}n&&(r=sv(n,Vu,this)),s&&(i=sv(s,Wu,this));const a={};n&&s?a.audiovideo={container:"video/mp4",codec:r+","+i,supplemental:s.supplemental,encrypted:s.encrypted,initSegment:e,id:"main"}:n?a.audio={container:"audio/mp4",codec:r,encrypted:n.encrypted,initSegment:e,id:"audio"}:s?a.video={container:"video/mp4",codec:i,supplemental:s.supplemental,encrypted:s.encrypted,initSegment:e,id:"main"}:this.warn("initSegment does not contain moov or trak boxes."),this.initTracks=a}remux(e,t,r,i,n,s){var a,o;let{initPTS:l,lastEndTime:c}=this;const d={audio:void 0,video:void 0,text:i,id3:r,initSegment:void 0};nu(c)||(c=this.lastEndTime=n||0);const u=t.samples;if(!u.length)return d;const h={initPTS:void 0,timescale:void 0,trackId:void 0};let f=this.initData;if(null!=(a=f)&&a.length||(this.generateInitSegment(u),f=this.initData),null==(o=f)||!o.length)return this.warn("Failed to generate initSegment."),d;this.emitInitSegment&&(h.tracks=this.initTracks,this.emitInitSegment=!1);const p=function(e,t,r){const i={},n=oh(e,["moof","traf"]);for(let e=0;e<n.length;e++){const s=n[e],a=oh(s,["tfhd"])[0],o=nh(a,4),l=t[o];if(!l)continue;i[o]||(i[o]={start:NaN,duration:0,sampleCount:0,timescale:l.timescale,type:l.type});const c=i[o],d=oh(s,["tfdt"])[0];if(d){const e=d[0];let t=nh(d,4);1===e&&(t===Ju?r.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"):(t*=Ju+1,t+=nh(d,8))),nu(t)&&(!nu(c.start)||t<c.start)&&(c.start=t)}const u=l.default,h=nh(a,0)|(null==u?void 0:u.flags);let f=(null==u?void 0:u.duration)||0;8&h&&(f=nh(a,2&h?12:8));const p=oh(s,["trun"]);let m=c.start||0,g=0,v=f;for(let e=0;e<p.length;e++){const t=p[e],r=nh(t,4),i=c.sampleCount;c.sampleCount+=r;const n=1&t[3],s=4&t[3],a=1&t[2],o=2&t[2],l=4&t[2],d=8&t[2];let u=8,h=r;for(n&&(u+=4),s&&r&&(1&t[u+1]||void 0!==c.keyFrameIndex||(c.keyFrameIndex=i),u+=4,a?(v=nh(t,u),u+=4):v=f,o&&(u+=4),d&&(u+=4),m+=v,g+=v,h--);h--;)a?(v=nh(t,u),u+=4):v=f,o&&(u+=4),l&&(1&t[u+1]||void 0===c.keyFrameIndex&&(c.keyFrameIndex=c.sampleCount-(h+1),c.keyFrameStart=m),u+=4),d&&(u+=4),m+=v,g+=v;!g&&f&&(g+=f*r)}c.duration+=g}if(!Object.keys(i).some(e=>i[e].duration)){let t=1/0,r=0;const n=oh(e,["sidx"]);for(let e=0;e<n.length;e++){const i=lh(n[e]);if(null!=i&&i.references){t=Math.min(t,i.earliestPresentationTime/i.timescale);const e=i.references.reduce((e,t)=>e+t.info.duration||0,0);r=Math.max(r,e+i.earliestPresentationTime/i.timescale)}}r&&nu(r)&&Object.keys(i).forEach(e=>{i[e].duration||(i[e].duration=r*i[e].timescale-i[e].start)})}return i}(u,f,this),m=f.audio?p[f.audio.id]:null,g=f.video?p[f.video.id]:null,v=nv(g,1/0),y=nv(m,1/0),b=nv(g,0,!0),E=nv(m,0,!0);let w=n,S=0;const T=m&&(!g||!l&&y<v||l&&l.trackId===f.audio.id),x=T?m:g;if(x){const e=x.timescale,t=x.start-n*e,r=T?f.audio.id:f.video.id;w=x.start/e,S=T?E-y:b-v,!s&&l||!function(e,t,r,i){if(null===e)return!0;const n=Math.max(i,1),s=t-e.baseTime/e.timescale;return Math.abs(s-r)>n}(l,w,n,S)&&e===l.timescale||(l&&this.warn(`Timestamps at playlist time: ${s?"":"~"}${n} ${t/e} != initPTS: ${l.baseTime/l.timescale} (${l.baseTime}/${l.timescale}) trackId: ${l.trackId}`),this.log(`Found initPTS at playlist time: ${n} offset: ${w-n} (${t}/${e}) trackId: ${r}`),l=null,h.initPTS=t,h.timescale=e,h.trackId=r)}else this.warn(`No audio or video samples found for initPTS at playlist time: ${n}`);l?(h.initPTS=l.baseTime,h.timescale=l.timescale,h.trackId=l.trackId):(h.timescale&&void 0!==h.trackId&&void 0!==h.initPTS||(this.warn("Could not set initPTS"),h.initPTS=w,h.timescale=1,h.trackId=-1),this.initPTS=l={baseTime:h.initPTS,timescale:h.timescale,trackId:h.trackId});const A=w-l.baseTime/l.timescale,k=A+S;S>0?this.lastEndTime=k:(this.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const I=!!f.audio,L=!!f.video;let R="";I&&(R+="audio"),L&&(R+="video");const P={data1:u,startPTS:A,startDTS:A,endPTS:k,endDTS:k,type:R,hasAudio:I,hasVideo:L,nb:1,dropped:0,encrypted:!!f.audio&&f.audio.encrypted||!!f.video&&f.video.encrypted};d.audio=I&&!L?P:void 0,d.video=L?P:void 0;const C=null==g?void 0:g.sampleCount;if(C){const e=g.keyFrameIndex,t=-1!==e;P.nb=C,P.dropped=0===e||this.isVideoContiguous?0:t?e:C,P.independent=t,P.firstKeyFrame=e,t&&g.keyFrameStart&&(P.firstKeyFramePTS=(g.keyFrameStart-l.baseTime)/l.timescale),this.isVideoContiguous||(d.independent=t),this.isVideoContiguous||(this.isVideoContiguous=t),P.dropped&&this.warn(`fmp4 does not start with IDR: firstIDR ${e}/${C} dropped: ${P.dropped} start: ${P.firstKeyFramePTS||"NA"}`)}return d.initSegment=h,d.id3=rv(r,n,l,l),i.samples.length&&(d.text=iv(i,n,l)),d}}},{demux:Fg,remux:ev},{demux:class extends pg{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t}resetInitSegment(e,t,r,i){super.resetInitSegment(e,t,r,i),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:i,inputTimeScale:9e4,dropped:0}}static probe(e,t){if(!e)return!1;const r=Km(e,0);let i=(null==r?void 0:r.length)||0;if(Ag(e,i))return!1;for(let r=e.length;i<r;i++)if(Jm(e,i))return t.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return function(e,t){return function(e,t){return t+5<e.length}(e,t)&&qm(e,t)&&Qm(e,t)<=e.length-t}(e,t)}appendFrame(e,t,r){eg(e,this.observer,t,r,e.manifestCodec);const i=rg(e,t,r,this.basePTS,this.frameIndex);if(i&&0===i.missing)return i}},remux:ev},{demux:class extends pg{resetInitSegment(e,t,r,i){super.resetInitSegment(e,t,r,i),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:i,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;const t=Km(e,0);let r=(null==t?void 0:t.length)||0;if(t&&11===e[r]&&119===e[r+1]&&void 0!==ug(t)&&kg(e,r)<=16)return!1;for(let t=e.length;r<t;r++)if(Ag(e,r))return Ru.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return function(e,t){return Tg(e,t)&&4<=e.length-t}(e,t)}appendFrame(e,t,r){if(null!==this.basePTS)return wg(e,t,r,this.basePTS,this.frameIndex)}},remux:ev}];av.splice(2,0,{demux:Ig,remux:ev});class ov{constructor(e,t,r,i,n,s){this.asyncResult=!1,this.logger=void 0,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=t,this.config=r,this.id=n,this.logger=s}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,r,i){const n=r.transmuxing;n.executeStart=Xg();let s=new Uint8Array(e);const{currentTransmuxState:a,transmuxConfig:o}=this;i&&(this.currentTransmuxState=i);const{contiguous:l,discontinuity:c,trackSwitch:d,accurateTimeOffset:u,timeOffset:h,initSegmentChange:f}=i||a,{audioCodec:p,videoCodec:m,defaultInitPts:g,duration:v,initSegmentData:y}=o,b=function(e,t){let r=null;e.byteLength>0&&null!=(null==t?void 0:t.key)&&null!==t.iv&&null!=t.method&&(r=t);return r}(s,t);if(b&&bp(b.method)){const e=this.getDecrypter(),t=Ep(b.method);if(!e.isSync())return this.asyncResult=!0,this.decryptionPromise=e.webCryptoDecrypt(s,b.key.buffer,b.iv.buffer,t).then(e=>{const t=this.push(e,null,r);return this.decryptionPromise=null,t}),this.decryptionPromise;{let i=e.softwareDecrypt(s,b.key.buffer,b.iv.buffer,t);if(r.part>-1){const t=e.flush();i=t?t.buffer:t}if(!i)return n.executeEnd=Xg(),lv(r);s=new Uint8Array(i)}}const E=this.needsProbing(c,d);if(E){const e=this.configureTransmuxer(s);if(e)return this.logger.warn(`[transmuxer] ${e.message}`),this.observer.emit(cu.ERROR,cu.ERROR,{type:ou.MEDIA_ERROR,details:lu.FRAG_PARSING_ERROR,fatal:!1,error:e,reason:e.message}),n.executeEnd=Xg(),lv(r)}(c||d||f||E)&&this.resetInitSegment(y,p,m,v,t),(c||f||E)&&this.resetInitialTimestamp(g),l||this.resetContiguity();const w=this.transmux(s,b,h,u,r);this.asyncResult=cv(w);const S=this.currentTransmuxState;return S.contiguous=!0,S.discontinuity=!1,S.trackSwitch=!1,n.executeEnd=Xg(),w}flush(e){const t=e.transmuxing;t.executeStart=Xg();const{decrypter:r,currentTransmuxState:i,decryptionPromise:n}=this;if(n)return this.asyncResult=!0,n.then(()=>this.flush(e));const s=[],{timeOffset:a}=i;if(r){const t=r.flush();t&&s.push(this.push(t.buffer,null,e))}const{demuxer:o,remuxer:l}=this;if(!o||!l){t.executeEnd=Xg();const r=[lv(e)];return this.asyncResult?Promise.resolve(r):r}const c=o.flush(a);return cv(c)?(this.asyncResult=!0,c.then(t=>(this.flushRemux(s,t,e),s))):(this.flushRemux(s,c,e),this.asyncResult?Promise.resolve(s):s)}flushRemux(e,t,r){const{audioTrack:i,videoTrack:n,id3Track:s,textTrack:a}=t,{accurateTimeOffset:o,timeOffset:l}=this.currentTransmuxState;this.logger.log(`[transmuxer.ts]: Flushed ${this.id} sn: ${r.sn}${r.part>-1?" part: "+r.part:""} of ${this.id===pu?"level":"track"} ${r.level}`);const c=this.remuxer.remux(i,n,s,a,l,o,!0,this.id);e.push({remuxResult:c,chunkMeta:r}),r.transmuxing.executeEnd=Xg()}resetInitialTimestamp(e){const{demuxer:t,remuxer:r}=this;t&&r&&(t.resetTimeStamp(e),r.resetTimeStamp(e))}resetContiguity(){const{demuxer:e,remuxer:t}=this;e&&t&&(e.resetContiguity(),t.resetNextTimestamp())}resetInitSegment(e,t,r,i,n){const{demuxer:s,remuxer:a}=this;s&&a&&(s.resetInitSegment(e,t,r,i),a.resetInitSegment(e,t,r,n))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,r,i,n){let s;return s=t&&"SAMPLE-AES"===t.method?this.transmuxSampleAes(e,t,r,i,n):this.transmuxUnencrypted(e,r,i,n),s}transmuxUnencrypted(e,t,r,i){const{audioTrack:n,videoTrack:s,id3Track:a,textTrack:o}=this.demuxer.demux(e,t,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(n,s,a,o,t,r,!1,this.id),chunkMeta:i}}transmuxSampleAes(e,t,r,i,n){return this.demuxer.demuxSampleAes(e,t,r).then(e=>({remuxResult:this.remuxer.remux(e.audioTrack,e.videoTrack,e.id3Track,e.textTrack,r,i,!1,this.id),chunkMeta:n}))}configureTransmuxer(e){const{config:t,observer:r,typeSupported:i}=this;let n;for(let t=0,r=av.length;t<r;t++){var s;if(null!=(s=av[t].demux)&&s.probe(e,this.logger)){n=av[t];break}}if(!n)return new Error("Failed to find demuxer by probing fragment data");const a=this.demuxer,o=this.remuxer,l=n.remux,c=n.demux;o&&o instanceof l||(this.remuxer=new l(r,t,i,this.logger)),a&&a instanceof c||(this.demuxer=new c(r,t,i,this.logger),this.probe=c.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new qf(this.config)),e}}const lv=e=>({remuxResult:{},chunkMeta:e});function cv(e){return"then"in e&&e.then instanceof Function}class dv{constructor(e,t,r,i,n){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=r,this.duration=i,this.defaultInitPts=n||null}}class uv{constructor(e,t,r,i,n,s){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=e,this.contiguous=t,this.accurateTimeOffset=r,this.trackSwitch=i,this.timeOffset=n,this.initSegmentChange=s}}let hv=0;class fv{constructor(e,t,r,i){this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=hv++,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.onWorkerMessage=e=>{const t=e.data,r=this.hls;if(r&&null!=t&&t.event&&t.instanceNo===this.instanceNo)switch(t.event){case"init":{var i;const e=null==(i=this.workerContext)?void 0:i.objectURL;e&&self.URL.revokeObjectURL(e);break}case"transmuxComplete":this.handleTransmuxComplete(t.data);break;case"flush":this.onFlush(t.data);break;case"workerLog":r.logger[t.data.logType]&&r.logger[t.data.logType](t.data.message);break;default:t.data=t.data||{},t.data.frag=this.frag,t.data.part=this.part,t.data.id=this.id,r.trigger(t.event,t.data)}},this.onWorkerError=e=>{if(!this.hls)return;const t=new Error(`${e.message} (${e.filename}:${e.lineno})`);this.hls.config.enableWorker=!1,this.hls.logger.warn(`Error in "${this.id}" Web Worker, fallback to inline`),this.hls.trigger(cu.ERROR,{type:ou.OTHER_ERROR,details:lu.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:t})};const n=e.config;this.hls=e,this.id=t,this.useWorker=!!n.enableWorker,this.onTransmuxComplete=r,this.onFlush=i;const s=(e,t)=>{(t=t||{}).frag=this.frag||void 0,e===cu.ERROR&&(t.parent=this.id,t.part=this.part,this.error=t.error),this.hls.trigger(e,t)};this.observer=new Gm,this.observer.on(cu.FRAG_DECRYPTED,s),this.observer.on(cu.ERROR,s);const a=Bh(n.preferManagedMediaSource);if(this.useWorker&&"undefined"!=typeof Worker){const r=this.hls.logger;if(n.workerPath||"function"==typeof __HLS_WORKER_BUNDLE__){try{n.workerPath?(r.log(`loading Web Worker ${n.workerPath} for "${t}"`),this.workerContext=function(e){const t=Hm[e];if(t)return t.clientCount++,t;const r=new self.URL(e,self.location.href).href,i={worker:new self.Worker(r),scriptURL:r,clientCount:1};return Hm[e]=i,i}(n.workerPath)):(r.log(`injecting Web Worker for "${t}"`),this.workerContext=function(){const e=Hm[jm];if(e)return e.clientCount++,e;const t=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),r=self.URL.createObjectURL(t),i={worker:new self.Worker(r),objectURL:r,clientCount:1};return Hm[jm]=i,i}());const{worker:e}=this.workerContext;e.addEventListener("message",this.onWorkerMessage),e.addEventListener("error",this.onWorkerError),e.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:a,id:t,config:sf(n)})}catch(i){r.warn(`Error setting up "${t}" Web Worker, fallback to inline`,i),this.terminateWorker(),this.error=null,this.transmuxer=new ov(this.observer,a,n,"",t,e.logger)}return}}this.transmuxer=new ov(this.observer,a,n,"",t,e.logger)}reset(){if(this.frag=null,this.part=null,this.workerContext){const e=this.instanceNo;this.instanceNo=hv++;const t=this.hls.config,r=Bh(t.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:e,typeSupported:r,id:this.id,config:sf(t)})}}terminateWorker(){if(this.workerContext){const{worker:e}=this.workerContext;this.workerContext=null,e.removeEventListener("message",this.onWorkerMessage),e.removeEventListener("error",this.onWorkerError),function(e){const t=Hm[e||jm];if(t&&1===t.clientCount--){const{worker:r,objectURL:i}=t;delete Hm[e||jm],i&&self.URL.revokeObjectURL(i),r.terminate()}}(this.hls.config.workerPath)}}destroy(){if(this.workerContext)this.terminateWorker(),this.onWorkerMessage=this.onWorkerError=null;else{const e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}const e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.part=null,this.observer=null,this.hls=null}push(e,t,r,i,n,s,a,o,l,c){var d,u;l.transmuxing.start=self.performance.now();const{instanceNo:h,transmuxer:f}=this,p=s?s.start:n.start,m=n.decryptdata,g=this.frag,v=!(g&&n.cc===g.cc),y=!(g&&l.level===g.level),b=g?l.sn-g.sn:-1,E=this.part?l.part-this.part.index:-1,w=0===b&&l.id>1&&l.id===(null==g?void 0:g.stats.chunkCount),S=!y&&(1===b||0===b&&(1===E||w&&E<=0)),T=self.performance.now();(y||b||0===n.stats.parsing.start)&&(n.stats.parsing.start=T),!s||!E&&S||(s.stats.parsing.start=T);const x=!(g&&(null==(d=n.initSegment)?void 0:d.url)===(null==(u=g.initSegment)?void 0:u.url)),A=new uv(v,S,o,y,p,x);if(!S||v||x){this.hls.logger.log(`[transmuxer-interface]: Starting new transmux session for ${n.type} sn: ${l.sn}${l.part>-1?" part: "+l.part:""} ${this.id===pu?"level":"track"}: ${l.level} id: ${l.id}\n discontinuity: ${v}\n trackSwitch: ${y}\n contiguous: ${S}\n accurateTimeOffset: ${o}\n timeOffset: ${p}\n initSegmentChange: ${x}`);const e=new dv(r,i,t,a,c);this.configureTransmuxer(e)}if(this.frag=n,this.part=s,this.workerContext)this.workerContext.worker.postMessage({instanceNo:h,cmd:"demux",data:e,decryptdata:m,chunkMeta:l,state:A},e instanceof ArrayBuffer?[e]:[]);else if(f){const t=f.push(e,m,l,A);cv(t)?t.then(e=>{this.handleTransmuxComplete(e)}).catch(e=>{this.transmuxerError(e,l,"transmuxer-interface push error")}):this.handleTransmuxComplete(t)}}flush(e){e.transmuxing.start=self.performance.now();const{instanceNo:t,transmuxer:r}=this;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:t,cmd:"flush",chunkMeta:e});else if(r){const t=r.flush(e);cv(t)?t.then(t=>{this.handleFlushResult(t,e)}).catch(t=>{this.transmuxerError(t,e,"transmuxer-interface flush error")}):this.handleFlushResult(t,e)}}transmuxerError(e,t,r){this.hls&&(this.error=e,this.hls.trigger(cu.ERROR,{type:ou.MEDIA_ERROR,details:lu.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,part:this.part||void 0,fatal:!1,error:e,err:e,reason:r}))}handleFlushResult(e,t){e.forEach(e=>{this.handleTransmuxComplete(e)}),this.onFlush(t)}configureTransmuxer(e){const{instanceNo:t,transmuxer:r}=this;this.workerContext?this.workerContext.worker.postMessage({instanceNo:t,cmd:"configure",config:e}):r&&r.configure(e)}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}}class pv extends Tu{constructor(e,t){super(t,e.logger),this.hls=void 0,this.canLoad=!1,this.timer=-1,this.hls=e}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){-1!==this.timer&&(self.clearTimeout(this.timer),this.timer=-1)}startLoad(){this.canLoad=!0,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(e,t,r){const i=null==t?void 0:t.renditionReports;if(i){let n=-1;for(let r=0;r<i.length;r++){const s=i[r];let a;try{a=new self.URL(s.URI,t.url).href}catch(e){this.warn(`Could not construct new URL for Rendition Report: ${e}`),a=s.URI||""}if(a===e){n=r;break}a===e.substring(0,a.length)&&(n=r)}if(-1!==n){const e=i[n],s=parseInt(e["LAST-MSN"])||t.lastPartSn;let a=parseInt(e["LAST-PART"])||t.lastPartIndex;if(this.hls.config.lowLatencyMode){const e=Math.min(t.age-t.partTarget,t.targetduration);a>=0&&e>t.partTarget&&(a+=1)}const o=r&&Jh(r);return new ef(s,a>=0?a:void 0,o)}}}loadPlaylist(e){this.clearTimer()}loadingPlaylist(e,t){this.clearTimer()}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}getUrlWithDirectives(e,t){if(t)try{return t.addDirectives(e)}catch(e){this.warn(`Could not construct new URL with HLS Delivery Directives: ${e}`)}return e}playlistLoaded(e,t,r){const{details:i,stats:n}=t,s=self.performance.now(),a=n.loading.first?Math.max(0,s-n.loading.first):0;i.advancedDateTime=Date.now()-a;const o=this.hls.config.timelineOffset;if(o!==i.appliedTimelineOffset){const e=Math.max(o||0,0);i.appliedTimelineOffset=e,i.fragments.forEach(t=>{t.setStart(t.playlistOffset+e)})}if(i.live||null!=r&&r.live){const o="levelInfo"in t?t.levelInfo:t.track;if(i.reloaded(r),r&&i.fragments.length>0){sm(r,i,this);const e=i.playlistParsingError;if(e){this.warn(e);const r=this.hls;if(!r.config.ignorePlaylistParsingErrors){var l;const{networkDetails:s}=t;return void r.trigger(cu.ERROR,{type:ou.NETWORK_ERROR,details:lu.LEVEL_PARSING_ERROR,fatal:!1,url:i.url,error:e,reason:e.message,level:t.level||void 0,parent:null==(l=i.fragments[0])?void 0:l.type,networkDetails:s,stats:n})}i.playlistParsingError=null}}-1===i.requestScheduled&&(i.requestScheduled=n.loading.start);const c=this.hls.mainForwardBufferInfo,d=c?c.end-c.len:0,u=cm(i,1e3*(i.edge-d));if(i.requestScheduled+u<s?i.requestScheduled=s:i.requestScheduled+=u,this.log(`live playlist ${e} ${i.advanced?"REFRESHED "+i.lastPartSn+"-"+i.lastPartIndex:i.updated?"UPDATED":"MISSED"}`),!this.canLoad||!i.live)return;let h,f,p;if(i.canBlockReload&&i.endSN&&i.advanced){const e=this.hls.config.lowLatencyMode,n=i.lastPartSn,a=i.endSN,l=i.lastPartIndex,c=n===a;-1!==l?c?(f=a+1,p=e?0:l):(f=n,p=e?l+1:i.maxPartIndex):f=a+1;const d=i.age,u=d+i.ageHeader;let m=Math.min(u-i.partTarget,1.5*i.targetduration);if(m>0){if(u>3*i.targetduration)this.log(`Playlist last advanced ${d.toFixed(2)}s ago. Omitting segment and part directives.`),f=void 0,p=void 0;else if(null!=r&&r.tuneInGoal&&u-i.partTarget>r.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${r.tuneInGoal} to: ${m} with playlist age: ${i.age}`),m=0;else{const e=Math.floor(m/i.targetduration);if(f+=e,void 0!==p){p+=Math.round(m%i.targetduration/i.partTarget)}this.log(`CDN Tune-in age: ${i.ageHeader}s last advanced ${d.toFixed(2)}s goal: ${m} skip sn ${e} to part ${p}`)}i.tuneInGoal=m}if(h=this.getDeliveryDirectives(i,t.deliveryDirectives,f,p),e||!c)return i.requestScheduled=s,void this.loadingPlaylist(o,h)}else(i.canBlockReload||i.canSkipUntil)&&(h=this.getDeliveryDirectives(i,t.deliveryDirectives,f,p));h&&void 0!==f&&i.canBlockReload&&(i.requestScheduled=n.loading.first+Math.max(u-2*a,u/2)),this.scheduleLoading(o,h,i)}else this.clearTimer()}scheduleLoading(e,t,r){const i=r||e.details;if(!i)return void this.loadingPlaylist(e,t);const n=self.performance.now(),s=i.requestScheduled;if(n>=s)return void this.loadingPlaylist(e,t);const a=s-n;this.log(`reload live playlist ${e.name||e.bitrate+"bps"} in ${Math.round(a)} ms`),this.clearTimer(),this.timer=self.setTimeout(()=>this.loadingPlaylist(e,t),a)}getDeliveryDirectives(e,t,r,i){let n=Jh(e);return null!=t&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,i=t.part,n=Xh),new ef(r,i,n)}checkRetry(e){const t=e.details,r=bf(e),i=e.errorAction,{action:n,retryCount:s=0,retryConfig:a}=i||{},o=!!i&&!!a&&(n===Pf||!i.resolved&&n===Lf);if(o){var l;if(s>=a.maxNumRetry)return!1;if(r&&null!=(l=e.context)&&l.deliveryDirectives)this.warn(`Retrying playlist loading ${s+1}/${a.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{const e=Tf(a,s);this.clearTimer(),this.timer=self.setTimeout(()=>this.loadPlaylist(),e),this.warn(`Retrying playlist loading ${s+1}/${a.maxNumRetry} after "${t}" in ${e}ms`)}e.levelRetry=!0,i.resolved=!0}return o}}function mv(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!gv(e[r].attrs,t[r].attrs))return!1;return!0}function gv(e,t,r){const i=e["STABLE-RENDITION-ID"];return i&&!r?i===t["STABLE-RENDITION-ID"]:!(r||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some(r=>e[r]!==t[r])}function vv(e,t){return t.label.toLowerCase()===e.name.toLowerCase()&&(!t.language||t.language.toLowerCase()===(e.lang||"").toLowerCase())}class yv{constructor(e){this.tracks=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.tracks=e}destroy(){this.tracks=this.queues=null}append(e,t,r){if(null===this.queues||null===this.tracks)return;const i=this.queues[t];i.push(e),1!==i.length||r||this.executeNext(t)}appendBlocker(e){return new Promise(t=>{const r={label:"async-blocker",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.append(r,e)})}prependBlocker(e){return new Promise(t=>{if(this.queues){const r={label:"async-blocker-prepend",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.queues[e].unshift(r)}})}removeBlockers(){null!==this.queues&&[this.queues.video,this.queues.audio,this.queues.audiovideo].forEach(e=>{var t;const r=null==(t=e[0])?void 0:t.label;"async-blocker"!==r&&"async-blocker-prepend"!==r||(e[0].execute(),e.splice(0,1))})}unblockAudio(e){if(null===this.queues)return;this.queues.audio[0]===e&&this.shiftAndExecuteNext("audio")}executeNext(e){if(null===this.queues||null===this.tracks)return;const t=this.queues[e];if(t.length){const i=t[0];try{i.execute()}catch(t){var r;if(i.onError(t),null===this.queues||null===this.tracks)return;const n=null==(r=this.tracks[e])?void 0:r.buffer;null!=n&&n.updating||this.shiftAndExecuteNext(e)}}}shiftAndExecuteNext(e){null!==this.queues&&(this.queues[e].shift(),this.executeNext(e))}current(e){var t;return(null==(t=this.queues)?void 0:t[e][0])||null}toString(){const{queues:e,tracks:t}=this;return null===e||null===t?"<destroyed>":`\n${this.list("video")}\n${this.list("audio")}\n${this.list("audiovideo")}}`}list(e){var t,r;return null!=(t=this.queues)&&t[e]||null!=(r=this.tracks)&&r[e]?`${e}: (${this.listSbInfo(e)}) ${this.listOps(e)}`:""}listSbInfo(e){var t;const r=null==(t=this.tracks)?void 0:t[e],i=null==r?void 0:r.buffer;return i?`SourceBuffer${i.updating?" updating":""}${r.ended?" ended":""}${r.ending?" ending":""}`:"none"}listOps(e){var t;return(null==(t=this.queues)?void 0:t[e].map(e=>e.label).join(", "))||""}}const bv=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,Ev="HlsJsTrackRemovedError";class wv extends Error{constructor(e){super(e),this.name=Ev}}function Sv(e){const t=e.querySelectorAll("source");[].slice.call(t).forEach(t=>{e.removeChild(t)})}function Tv(e){return"audio"===e?1:0}class xv{constructor(e){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(e){this.streamController=e}destroy(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){const{hls:e}=this;e.on(cu.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(cu.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(cu.MANIFEST_PARSED,this.onManifestParsed,this),e.on(cu.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(cu.BUFFER_CODECS,this.onBufferCodecs,this),e.on(cu.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:e}=this;e.off(cu.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(cu.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(cu.MANIFEST_PARSED,this.onManifestParsed,this),e.off(cu.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(cu.BUFFER_CODECS,this.onBufferCodecs,this),e.off(cu.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(e,t){const r=this.hls.levels[t.droppedLevel];this.isLevelAllowed(r)&&this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})}onMediaAttaching(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()}onManifestParsed(e,t){const r=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,r.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onLevelsUpdated(e,t){this.timer&&nu(this.autoLevelCapping)&&this.detectPlayerSize()}onBufferCodecs(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping(),this.media=null}detectPlayerSize(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0)return void(this.clientRect=null);const e=this.hls.levels;if(e.length){const t=this.hls,r=this.getMaxLevel(e.length-1);r!==this.autoLevelCapping&&t.logger.log(`Setting autoLevelCapping to ${r}: ${e[r].height}p@${e[r].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),t.autoLevelCapping=r,t.autoLevelEnabled&&t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}}getMaxLevel(e){const t=this.hls.levels;if(!t.length)return-1;const r=t.filter((t,r)=>this.isLevelAllowed(t)&&r<=e);return this.clientRect=null,xv.getMaxLevelByMediaSize(r,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}stopCapping(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}getDimensions(){if(this.clientRect)return this.clientRect;const e=this.media,t={width:0,height:0};if(e){const r=e.getBoundingClientRect();t.width=r.width,t.height=r.height,t.width||t.height||(t.width=r.right-r.left||e.width||0,t.height=r.bottom-r.top||e.height||0)}return this.clientRect=t,t}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch(e){}return Math.min(e,this.hls.config.maxDevicePixelRatio)}isLevelAllowed(e){return!this.restrictedLevels.some(t=>e.bitrate===t.bitrate&&e.width===t.width&&e.height===t.height)}static getMaxLevelByMediaSize(e,t,r){if(null==e||!e.length)return-1;const i=(e,t)=>!t||(e.width!==t.width||e.height!==t.height);let n=e.length-1;const s=Math.max(t,r);for(let t=0;t<e.length;t+=1){const r=e[t];if((r.width>=s||r.height>=s)&&i(r,e[t+1])){n=t;break}}return n}}const Av={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"},kv={HLS:"h"};class Iv{constructor(e,t){Array.isArray(e)&&(e=e.map(e=>e instanceof Iv?e:new Iv(e))),this.value=e,this.params=t}}function Lv(e,t,r,i){return new Error(`failed to ${e} "${n=t,Array.isArray(n)?JSON.stringify(n):n instanceof Map?"Map{}":n instanceof Set?"Set{}":"object"==typeof n?JSON.stringify(n):String(n)}" as ${r}`,{cause:i});var n}function Rv(e,t,r){return Lv("serialize",e,t,r)}class Pv{constructor(e){this.description=e}}const Cv="Bare Item";function Dv(e){if(!1===ArrayBuffer.isView(e))throw Rv(e,"Byte Sequence");return`:${t=e,btoa(String.fromCharCode(...t))}:`;var t}function _v(e){if(function(e){return e<-999999999999999||999999999999999<e}(e))throw Rv(e,"Integer");return e.toString()}function Ov(e,t){if(e<0)return-Ov(-e,t);const r=Math.pow(10,t);if(Math.abs(e*r%1-.5)<Number.EPSILON){const t=Math.floor(e*r);return(t%2==0?t:t+1)/r}return Math.round(e*r)/r}function Mv(e){const t=Ov(e,3);if(Math.floor(Math.abs(t)).toString().length>12)throw Rv(e,"Decimal");const r=t.toString();return r.includes(".")?r:`${r}.0`}const Nv=/[\x00-\x1f\x7f]+/;function Fv(e){const t=(r=e).description||r.toString().slice(7,-1);var r;if(!1===/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(t))throw Rv(t,"Token");return t}function $v(e){switch(typeof e){case"number":if(!nu(e))throw Rv(e,Cv);return Number.isInteger(e)?_v(e):Mv(e);case"string":return function(e){if(Nv.test(e))throw Rv(e,"String");return`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}(e);case"symbol":return Fv(e);case"boolean":return function(e){if("boolean"!=typeof e)throw Rv(e,"Boolean");return e?"?1":"?0"}(e);case"object":if(e instanceof Date)return function(e){return`@${_v(e.getTime()/1e3)}`}(e);if(e instanceof Uint8Array)return Dv(e);if(e instanceof Pv)return Fv(e);default:throw Rv(e,Cv)}}function Bv(e){if(!1===/^[a-z*][a-z0-9\-_.*]*$/.test(e))throw Rv(e,"Key");return e}function Uv(e){return null==e?"":Object.entries(e).map(([e,t])=>!0===t?`;${Bv(e)}`:`;${Bv(e)}=${$v(t)}`).join("")}function zv(e){return e instanceof Iv?`${$v(e.value)}${Uv(e.params)}`:$v(e)}function Gv(e,t={whitespace:!0}){if("object"!=typeof e||null==e)throw Rv(e,"Dict");const r=e instanceof Map?e.entries():Object.entries(e),i=(null==t?void 0:t.whitespace)?" ":"";return Array.from(r).map(([e,t])=>{t instanceof Iv==!1&&(t=new Iv(t));let r=Bv(e);var i;return!0===t.value?r+=Uv(t.params):(r+="=",Array.isArray(t.value)?r+=`(${(i=t).value.map(zv).join(" ")})${Uv(i.params)}`:r+=zv(t)),r}).join(`,${i}`)}function jv(e,t){return Gv(e,t)}const Hv="CMCD-Object",Vv="CMCD-Request",Wv="CMCD-Session",Yv="CMCD-Status",Kv={br:Hv,ab:Hv,d:Hv,ot:Hv,tb:Hv,tpb:Hv,lb:Hv,tab:Hv,lab:Hv,url:Hv,pb:Vv,bl:Vv,tbl:Vv,dl:Vv,ltc:Vv,mtp:Vv,nor:Vv,nrr:Vv,rc:Vv,sn:Vv,sta:Vv,su:Vv,ttfb:Vv,ttfbb:Vv,ttlb:Vv,cmsdd:Vv,cmsds:Vv,smrt:Vv,df:Vv,cs:Vv,ts:Vv,cid:Wv,pr:Wv,sf:Wv,sid:Wv,st:Wv,v:Wv,msd:Wv,bs:Yv,bsd:Yv,cdn:Yv,rtp:Yv,bg:Yv,pt:Yv,ec:Yv,e:Yv},qv=Vv;function Xv(e,t){const r={};if(!e)return r;const i=Object.keys(e),n=t?(s=t,Object.keys(s).reduce((e,t)=>{var r;return null===(r=s[t])||void 0===r||r.forEach(r=>e[r]=t),e},{})):{};var s;return i.reduce((t,r)=>{var i;const s=Kv[r]||n[r]||qv;return(null!==(i=t[s])&&void 0!==i?i:t[s]={})[r]=e[r],t},r)}const Qv="event";const Zv=e=>Math.round(e),Jv=(e,t)=>Array.isArray(e)?e.map(e=>Jv(e,t)):e instanceof Iv&&"string"==typeof e.value?new Iv(Jv(e.value,t),e.params):(t.baseUrl&&(e=function(e,t){const r=new URL(e),i=new URL(t);if(r.origin!==i.origin)return e;const n=r.pathname.split("/").slice(1),s=i.pathname.split("/").slice(1,-1);for(;n[0]===s[0];)n.shift(),s.shift();for(;s.length;)s.shift(),n.unshift("..");return n.join("/")+r.search+r.hash}(e,t.baseUrl)),1===t.version?encodeURIComponent(e):e),ey=e=>100*Zv(e/100),ty={br:Zv,d:Zv,bl:ey,dl:ey,mtp:ey,nor:(e,t)=>{let r=e;return t.version>=2&&(e instanceof Iv&&"string"==typeof e.value?r=new Iv([e]):"string"==typeof e&&(r=[e])),Jv(r,t)},rtp:ey,tb:Zv},ry="request",iy="response",ny=["ab","bg","bl","br","bs","bsd","cdn","cid","cs","df","ec","lab","lb","ltc","msd","mtp","pb","pr","pt","sf","sid","sn","st","sta","tab","tb","tbl","tpb","ts","v"],sy=["e"],ay=/^[a-zA-Z0-9-.]+-[a-zA-Z0-9-.]+$/;function oy(e){return ay.test(e)}const ly=["d","dl","nor","ot","rtp","su"];const cy=["cmsdd","cmsds","rc","smrt","ttfb","ttfbb","ttlb","url"];const dy=["bl","br","bs","cid","d","dl","mtp","nor","nrr","ot","pr","rtp","sf","sid","st","su","tb","v"];function uy(e){return dy.includes(e)||oy(e)}const hy={[iy]:function(e){return ny.includes(e)||ly.includes(e)||cy.includes(e)||oy(e)},[Qv]:function(e){return ny.includes(e)||sy.includes(e)||oy(e)},[ry]:function(e){return ny.includes(e)||ly.includes(e)||oy(e)}};function fy(e,t={}){const r={};if(null==e||"object"!=typeof e)return r;const i=t.version||e.v||1,n=t.reportingMode||ry,s=1===i?uy:hy[n];let a=Object.keys(e).filter(s);const o=t.filter;"function"==typeof o&&(a=a.filter(o));const l=n===iy||n===Qv;l&&!a.includes("ts")&&a.push("ts"),i>1&&!a.includes("v")&&a.push("v");const c=Eu({},ty,t.formatters),d={version:i,reportingMode:n,baseUrl:t.baseUrl};return a.sort().forEach(t=>{let n=e[t];const s=c[t];if("function"==typeof s&&(n=s(n,d)),"v"===t){if(1===i)return;n=i}"pr"==t&&1===n||(l&&"ts"===t&&!nu(n)&&(n=Date.now()),function(e){return"number"==typeof e?nu(e):null!=e&&""!==e&&!1!==e}(n)&&(function(e){return["ot","sf","st","e","sta"].includes(e)}(t)&&"string"==typeof n&&(n=new Pv(n)),r[t]=n))}),r}function py(e,t,r){return Eu(e,function(e,t={}){const r={};if(!e)return r;const i=Xv(fy(e,t),null==t?void 0:t.customHeaderMap);return Object.entries(i).reduce((e,[t,r])=>{const i=jv(r,{whitespace:!1});return i&&(e[t]=i),e},r)}(t,r))}function my(e,t={}){if(!e)return"";const r=function(e,t={}){return e?jv(fy(e,t),{whitespace:!1}):""}(e,t);return encodeURIComponent(r)}const gy=/CMCD=[^&#]+/;function vy(e,t,r){const i=function(e,t={}){return e?`CMCD=${my(e,t)}`:""}(t,r);if(!i)return e;if(gy.test(e))return e.replace(gy,i);const n=e.includes("?")?"&":"?";return`${e}${n}${i}`}function yy(e,t,r,i){e&&Object.keys(t).forEach(n=>{const s=e.filter(e=>e.groupId===n).map(e=>{const s=Eu({},e);return s.details=void 0,s.attrs=new hp(s.attrs),s.url=s.attrs.URI=by(e.url,e.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",r),s.groupId=s.attrs["GROUP-ID"]=t[n],s.attrs["PATHWAY-ID"]=i,s});e.push(...s)})}function by(e,t,r,i){const{HOST:n,PARAMS:s,[r]:a}=i;let o;t&&(o=null==a?void 0:a[t],o&&(e=o));const l=new self.URL(e);return n&&!o&&(l.host=n),s&&Object.keys(s).sort().forEach(e=>{e&&l.searchParams.set(e,s[e])}),l.href}class Ey extends Tu{constructor(e){super("eme",e.logger),this.hls=void 0,this.config=void 0,this.media=null,this.mediaResolved=void 0,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.mediaKeys=null,this.setMediaKeysQueue=Ey.CDMCleanupPromise?[Ey.CDMCleanupPromise]:[],this.bannedKeyIds={},this.onMediaEncrypted=e=>{const{initDataType:t,initData:r}=e,i=`"${e.type}" event: init data type: "${t}"`;if(this.debug(i),null!==r){if(!this.keyFormatPromise){let e=Object.keys(this.keySystemAccessPromises);e.length||(e=_p(this.config));const t=e.map(Dp).filter(e=>!!e);this.keyFormatPromise=this.getKeyFormatPromise(t)}this.keyFormatPromise.then(n=>{const s=Cp(n);if("sinf"!==t||s!==kp.FAIRPLAY)return void this.log(`Ignoring "${e.type}" event with init data type: "${t}" for selected key-system ${s}`);let a;try{const e=rh(new Uint8Array(r)),t=gh(wp(JSON.parse(e).sinf));if(!t)throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");a=new Uint8Array(t.subarray(8,24))}catch(e){return void this.warn(`${i} Failed to parse sinf: ${e}`)}const o=_u(a),{keyIdToKeySessionPromise:l,mediaKeySessions:c}=this;let d=l[o];for(let e=0;e<c.length;e++){const i=c[e],n=i.decryptdata;if(!n.keyId)continue;const s=_u(n.keyId);if(vp(a,n.keyId)||-1!==n.uri.replace(/-/g,"").indexOf(o)){if(d=l[s],!d)continue;if(n.pssh)break;delete l[s],n.pssh=new Uint8Array(r),n.keyId=a,d=l[o]=d.then(()=>this.generateRequestWithPreferredKeySession(i,t,r,"encrypted-event-key-match")),d.catch(e=>this.handleError(e));break}}d||this.handleError(new Error(`Key ID ${o} not encountered in playlist. Key-system sessions ${c.length}.`))}).catch(e=>this.handleError(e))}},this.onWaitingForKey=e=>{this.log(`"${e.type}" event`)},this.hls=e,this.config=e.config,this.registerListeners()}destroy(){this.onDestroying(),this.onMediaDetached();const e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.config=this.keyIdToKeySessionPromise=null,this.onMediaEncrypted=this.onWaitingForKey=null}registerListeners(){this.hls.on(cu.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(cu.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(cu.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(cu.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.on(cu.DESTROYING,this.onDestroying,this)}unregisterListeners(){this.hls.off(cu.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(cu.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(cu.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(cu.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.off(cu.DESTROYING,this.onDestroying,this)}getLicenseServerUrl(e){const{drmSystems:t,widevineLicenseUrl:r}=this.config,i=null==t?void 0:t[e];return i?i.licenseUrl:e===kp.WIDEVINE&&r?r:void 0}getLicenseServerUrlOrThrow(e){const t=this.getLicenseServerUrl(e);if(void 0===t)throw new Error(`no license server URL configured for key-system "${e}"`);return t}getServerCertificateUrl(e){const{drmSystems:t}=this.config,r=null==t?void 0:t[e];if(r)return r.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}attemptKeySystemAccess(e){const t=this.hls.levels,r=(e,t,r)=>!!e&&r.indexOf(e)===t,i=t.map(e=>e.audioCodec).filter(r),n=t.map(e=>e.videoCodec).filter(r);return i.length+n.length===0&&n.push("avc1.42e01e"),new Promise((t,r)=>{const s=e=>{const a=e.shift();this.getMediaKeysPromise(a,i,n).then(e=>t({keySystem:a,mediaKeys:e})).catch(t=>{e.length?s(e):r(t instanceof Ty?t:new Ty({type:ou.KEY_SYSTEM_ERROR,details:lu.KEY_SYSTEM_NO_ACCESS,error:t,fatal:!0},t.message))})};s(e)})}requestMediaKeySystemAccess(e,t){const{requestMediaKeySystemAccessFunc:r}=this.config;if("function"!=typeof r){let e=`Configured requestMediaKeySystemAccess is not a function ${r}`;return null===Op&&"http:"===self.location.protocol&&(e=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(e))}return r(e,t)}getMediaKeysPromise(e,t,r){var i;const n=function(e,t,r,i){let n;switch(e){case kp.FAIRPLAY:n=["cenc","sinf"];break;case kp.WIDEVINE:case kp.PLAYREADY:n=["cenc"];break;case kp.CLEARKEY:n=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${e}`)}return function(e,t,r,i){return[{initDataTypes:e,persistentState:i.persistentState||"optional",distinctiveIdentifier:i.distinctiveIdentifier||"optional",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:t.map(e=>({contentType:`audio/mp4; codecs=${e}`,robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null})),videoCapabilities:r.map(e=>({contentType:`video/mp4; codecs=${e}`,robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}))}]}(n,t,r,i)}(e,t,r,this.config.drmSystemOptions||{});let s=this.keySystemAccessPromises[e],a=null==(i=s)?void 0:i.keySystemAccess;if(!a){this.log(`Requesting encrypted media "${e}" key-system access with config: ${sf(n)}`),a=this.requestMediaKeySystemAccess(e,n);const t=s=this.keySystemAccessPromises[e]={keySystemAccess:a};return a.catch(t=>{this.log(`Failed to obtain access to key-system "${e}": ${t}`)}),a.then(r=>{this.log(`Access for key-system "${r.keySystem}" obtained`);const i=this.fetchServerCertificate(e);this.log(`Create media-keys for "${e}"`);const n=t.mediaKeys=r.createMediaKeys().then(r=>(this.log(`Media-keys created for "${e}"`),t.hasMediaKeys=!0,i.then(t=>t?this.setMediaKeysServerCertificate(r,e,t):r)));return n.catch(t=>{this.error(`Failed to create media-keys for "${e}"}: ${t}`)}),n})}return a.then(()=>s.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:r}){this.log(`Creating key-system session "${t}" keyId: ${_u(e.keyId||[])} keyUri: ${e.uri}`);const i=r.createSession(),n={decryptdata:e,keySystem:t,mediaKeys:r,mediaKeysSession:i,keyStatus:"status-pending"};return this.mediaKeySessions.push(n),n}renewKeySession(e){const t=e.decryptdata;if(t.pssh){const r=this.createMediaKeySessionContext(e),i=wy(t),n="cenc";this.keyIdToKeySessionPromise[i]=this.generateRequestWithPreferredKeySession(r,n,t.pssh.buffer,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}updateKeySession(e,t){const r=e.mediaKeysSession;return this.log(`Updating key-session "${r.sessionId}" for keyId ${_u(e.decryptdata.keyId||[])}\n } (data length: ${t.byteLength})`),r.update(t)}getSelectedKeySystemFormats(){return Object.keys(this.keySystemAccessPromises).map(e=>({keySystem:e,hasMediaKeys:this.keySystemAccessPromises[e].hasMediaKeys})).filter(({hasMediaKeys:e})=>!!e).map(({keySystem:e})=>Dp(e)).filter(e=>!!e)}getKeySystemAccess(e){return this.getKeySystemSelectionPromise(e).then(({keySystem:e,mediaKeys:t})=>this.attemptSetMediaKeys(e,t))}selectKeySystem(e){return new Promise((t,r)=>{this.getKeySystemSelectionPromise(e).then(({keySystem:e})=>{const i=Dp(e);i?t(i):r(new Error(`Unable to find format for key-system "${e}"`))}).catch(r)})}selectKeySystemFormat(e){const t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}getKeyFormatPromise(e){const t=_p(this.config),r=e.map(Cp).filter(e=>!!e&&-1!==t.indexOf(e));return this.selectKeySystem(r)}getKeyStatus(e){const{mediaKeySessions:t}=this;for(let r=0;r<t.length;r++){const i=Sy(e,t[r]);if(i)return i}}loadKey(e){const t=e.keyInfo.decryptdata,r=wy(t),i=this.bannedKeyIds[r];if(i||"internal-error"===this.getKeyStatus(t)){const r=xy(i||"internal-error",t);return this.handleError(r,e.frag),Promise.reject(r)}const n=`(keyId: ${r} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${n}`);const s=this.keyIdToKeySessionPromise[r];if(!s){const i=this.getKeySystemForKeyPromise(t).then(({keySystem:r,mediaKeys:i})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${n}`),this.attemptSetMediaKeys(r,i).then(()=>(this.throwIfDestroyed(),this.createMediaKeySessionContext({keySystem:r,mediaKeys:i,decryptdata:t}))))).then(e=>{const r=t.pssh?t.pssh.buffer:null;return this.generateRequestWithPreferredKeySession(e,"cenc",r,"playlist-key")});return i.catch(t=>this.handleError(t,e.frag)),this.keyIdToKeySessionPromise[r]=i,i}return s.catch(r=>{if(r instanceof Ty){const i=Su({},r.data);"internal-error"===this.getKeyStatus(t)&&(i.decryptdata=t);const n=new Ty(i,r.message);this.handleError(n,e.frag)}}),s}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e,t){if(this.hls)if(e instanceof Ty){t&&(e.data.frag=t);const r=e.data.decryptdata;this.error(`${e.message}${r?` (${_u(r.keyId||[])})`:""}`),this.hls.trigger(cu.ERROR,e.data)}else this.error(e.message),this.hls.trigger(cu.ERROR,{type:ou.KEY_SYSTEM_ERROR,details:lu.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0})}getKeySystemForKeyPromise(e){const t=wy(e),r=this.keyIdToKeySessionPromise[t];if(!r){const t=Cp(e.keyFormat),r=t?[t]:_p(this.config);return this.attemptKeySystemAccess(r)}return r}getKeySystemSelectionPromise(e){if(e.length||(e=_p(this.config)),0===e.length)throw new Ty({type:ou.KEY_SYSTEM_ERROR,details:lu.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${sf({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}attemptSetMediaKeys(e,t){if(this.mediaResolved=void 0,this.mediaKeys===t)return Promise.resolve();const r=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);const i=Promise.all(r).then(()=>this.media?this.media.setMediaKeys(t):new Promise((e,r)=>{this.mediaResolved=()=>{if(this.mediaResolved=void 0,!this.media)return r(new Error("Attempted to set mediaKeys without media element attached"));this.mediaKeys=t,this.media.setMediaKeys(t).then(e).catch(r)}}));return this.mediaKeys=t,this.setMediaKeysQueue.push(i),i.then(()=>{this.log(`Media-keys set for "${e}"`),r.push(i),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(e=>-1===r.indexOf(e))})}generateRequestWithPreferredKeySession(e,t,r,i){var n;const s=null==(n=this.config.drmSystems)||null==(n=n[e.keySystem])?void 0:n.generateRequest;if(s)try{const i=s.call(this.hls,t,r,e);if(!i)throw new Error("Invalid response from configured generateRequest filter");t=i.initDataType,r=i.initData?i.initData:null,e.decryptdata.pssh=r?new Uint8Array(r):null}catch(e){if(this.warn(e.message),this.hls&&this.hls.config.debug)throw e}if(null===r)return this.log(`Skipping key-session request for "${i}" (no initData)`),Promise.resolve(e);const a=wy(e.decryptdata),o=e.decryptdata.uri;this.log(`Generating key-session request for "${i}" keyId: ${a} URI: ${o} (init data type: ${t} length: ${r.byteLength})`);const l=new Gm,c=e._onmessage=t=>{const r=e.mediaKeysSession;if(!r)return void l.emit("error",new Error("invalid state"));const{messageType:i,message:n}=t;this.log(`"${i}" message event for session "${r.sessionId}" message size: ${n.byteLength}`),"license-request"===i||"license-renewal"===i?this.renewLicense(e,n).catch(e=>{l.eventNames().length?l.emit("error",e):this.handleError(e)}):"license-release"===i?e.keySystem===kp.FAIRPLAY&&this.updateKeySession(e,Sp("acknowledged")).then(()=>this.removeSession(e)).catch(e=>this.handleError(e)):this.warn(`unhandled media key message type "${i}"`)},d=(e,t)=>{let r;t.keyStatus=e,e.startsWith("usable")?l.emit("resolved"):"internal-error"===e||"output-restricted"===e||"output-downscaled"===e?r=xy(e,t.decryptdata):"expired"===e?r=new Error(`key expired (keyId: ${a})`):"released"===e?r=new Error("key released"):"status-pending"===e||this.warn(`unhandled key status change "${e}" (keyId: ${a})`),r&&(l.eventNames().length?l.emit("error",r):this.handleError(r))},u=e._onkeystatuseschange=t=>{if(!e.mediaKeysSession)return void l.emit("error",new Error("invalid state"));const r=this.getKeyStatuses(e);if(!Object.keys(r).some(e=>"status-pending"!==r[e]))return;if("expired"===r[a])return this.log(`Expired key ${sf(r)} in key-session "${e.mediaKeysSession.sessionId}"`),void this.renewKeySession(e);let i=r[a];if(i)d(i,e);else{var n;const t=1e3;e.keyStatusTimeouts||(e.keyStatusTimeouts={}),(n=e.keyStatusTimeouts)[a]||(n[a]=self.setTimeout(()=>{if(!e.mediaKeysSession||!this.mediaKeys)return;const r=this.getKeyStatus(e.decryptdata);if(r&&"status-pending"!==r)return this.log(`No status for keyId ${a} in key-session "${e.mediaKeysSession.sessionId}". Using session key-status ${r} from other session.`),d(r,e);this.log(`key status for ${a} in key-session "${e.mediaKeysSession.sessionId}" timed out after ${t}ms`),i="internal-error",d(i,e)},t)),this.log(`No status for keyId ${a} (${sf(r)}).`)}};wm(e.mediaKeysSession,"message",c),wm(e.mediaKeysSession,"keystatuseschange",u);const h=new Promise((e,t)=>{l.on("error",t),l.on("resolved",e)});return e.mediaKeysSession.generateRequest(t,r).then(()=>{this.log(`Request generated for key-session "${e.mediaKeysSession.sessionId}" keyId: ${a} URI: ${o}`)}).catch(t=>{throw new Ty({type:ou.KEY_SYSTEM_ERROR,details:lu.KEY_SYSTEM_NO_SESSION,error:t,decryptdata:e.decryptdata,fatal:!1},`Error generating key-session request: ${t}`)}).then(()=>h).catch(t=>(l.removeAllListeners(),this.removeSession(e).then(()=>{throw t}))).then(()=>(l.removeAllListeners(),e))}getKeyStatuses(e){const t={};return e.mediaKeysSession.keyStatuses.forEach((r,i)=>{if("string"==typeof i&&"object"==typeof r){const e=i;i=r,r=e}const n="buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i);if(e.keySystem===kp.PLAYREADY&&16===n.length){const e=_u(n);t[e]=r,Tp(n)}const s=_u(n);"internal-error"===r&&(this.bannedKeyIds[s]=r),this.log(`key status change "${r}" for keyStatuses keyId: ${s} key-session "${e.mediaKeysSession.sessionId}"`),t[s]=r}),t}fetchServerCertificate(e){const t=this.config,r=new(0,t.loader)(t),i=this.getServerCertificateUrl(e);return i?(this.log(`Fetching server certificate for "${e}"`),new Promise((n,s)=>{const a={responseType:"arraybuffer",url:i},o=t.certLoadPolicy.default,l={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(e,t,r,i)=>{n(e.data)},onError:(t,r,n,o)=>{s(new Ty({type:ou.KEY_SYSTEM_ERROR,details:lu.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:n,response:Su({url:a.url,data:void 0},t)},`"${e}" certificate request failed (${i}). Status: ${t.code} (${t.text})`))},onTimeout:(t,r,n)=>{s(new Ty({type:ou.KEY_SYSTEM_ERROR,details:lu.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:n,response:{url:a.url,data:void 0}},`"${e}" certificate request timed out (${i})`))},onAbort:(e,t,r)=>{s(new Error("aborted"))}};r.load(a,l,c)})):Promise.resolve()}setMediaKeysServerCertificate(e,t,r){return new Promise((i,n)=>{e.setServerCertificate(r).then(n=>{this.log(`setServerCertificate ${n?"success":"not supported by CDM"} (${r.byteLength}) on "${t}"`),i(e)}).catch(e=>{n(new Ty({type:ou.KEY_SYSTEM_ERROR,details:lu.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:e,fatal:!0},e.message))})})}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then(t=>this.updateKeySession(e,new Uint8Array(t)).catch(t=>{throw new Ty({type:ou.KEY_SYSTEM_ERROR,details:lu.KEY_SYSTEM_SESSION_UPDATE_FAILED,decryptdata:e.decryptdata,error:t,fatal:!1},t.message)}))}unpackPlayReadyKeyMessage(e,t){const r=String.fromCharCode.apply(null,new Uint16Array(t.buffer));if(!r.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;const i=(new DOMParser).parseFromString(r,"application/xml"),n=i.querySelectorAll("HttpHeader");if(n.length>0){let t;for(let r=0,i=n.length;r<i;r++){var s,a;t=n[r];const i=null==(s=t.querySelector("name"))?void 0:s.textContent,o=null==(a=t.querySelector("value"))?void 0:a.textContent;i&&o&&e.setRequestHeader(i,o)}}const o=i.querySelector("Challenge"),l=null==o?void 0:o.textContent;if(!l)throw new Error("Cannot find <Challenge> in key message");return Sp(atob(l))}setupLicenseXHR(e,t,r,i){const n=this.config.licenseXhrSetup;return n?Promise.resolve().then(()=>{if(!r.decryptdata)throw new Error("Key removed");return n.call(this.hls,e,t,r,i)}).catch(s=>{if(!r.decryptdata)throw s;return e.open("POST",t,!0),n.call(this.hls,e,t,r,i)}).then(r=>{e.readyState||e.open("POST",t,!0);return{xhr:e,licenseChallenge:r||i}}):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:i}))}requestLicense(e,t){const r=this.config.keyLoadPolicy.default;return new Promise((i,n)=>{const s=this.getLicenseServerUrlOrThrow(e.keySystem);this.log(`Sending license request to URL: ${s}`);const a=new XMLHttpRequest;a.responseType="arraybuffer",a.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return n(new Error("invalid state"));if(4===a.readyState)if(200===a.status){this._requestLicenseFailureCount=0;let t=a.response;this.log(`License received ${t instanceof ArrayBuffer?t.byteLength:t}`);const r=this.config.licenseResponseCallback;if(r)try{t=r.call(this.hls,a,s,e)}catch(e){this.error(e)}i(t)}else{const o=r.errorRetry,l=o?o.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>l||a.status>=400&&a.status<500)n(new Ty({type:ou.KEY_SYSTEM_ERROR,details:lu.KEY_SYSTEM_LICENSE_REQUEST_FAILED,decryptdata:e.decryptdata,fatal:!0,networkDetails:a,response:{url:s,data:void 0,code:a.status,text:a.statusText}},`License Request XHR failed (${s}). Status: ${a.status} (${a.statusText})`));else{const r=l-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${r} attempts left`),this.requestLicense(e,t).then(i,n)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=a,this.setupLicenseXHR(a,s,e,t).then(({xhr:t,licenseChallenge:r})=>{e.keySystem==kp.PLAYREADY&&(r=this.unpackPlayReadyKeyMessage(t,r)),t.send(r)}).catch(n)})}onDestroying(){this.unregisterListeners(),this._clear()}onMediaAttached(e,t){if(!this.config.emeEnabled)return;const r=t.media;this.media=r,wm(r,"encrypted",this.onMediaEncrypted),wm(r,"waitingforkey",this.onWaitingForKey);const i=this.mediaResolved;i?i():this.mediaKeys=r.mediaKeys}onMediaDetached(){const e=this.media;e&&(Sm(e,"encrypted",this.onMediaEncrypted),Sm(e,"waitingforkey",this.onWaitingForKey),this.media=null,this.mediaKeys=null)}_clear(){var e;this._requestLicenseFailureCount=0,this.keyIdToKeySessionPromise={},this.bannedKeyIds={};const t=this.mediaResolved;if(t&&t(),!this.mediaKeys&&!this.mediaKeySessions.length)return;const r=this.media,i=this.mediaKeySessions.slice();this.mediaKeySessions=[],this.mediaKeys=null,$p.clearKeyUriToKeyIdMap();const n=i.length;Ey.CDMCleanupPromise=Promise.all(i.map(e=>this.removeSession(e)).concat((null==r||null==(e=r.setMediaKeys(null))?void 0:e.catch(e=>{this.log(`Could not clear media keys: ${e}`),this.hls&&this.hls.trigger(cu.ERROR,{type:ou.OTHER_ERROR,details:lu.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR,fatal:!1,error:new Error(`Could not clear media keys: ${e}`)})}))||Promise.resolve())).catch(e=>{this.log(`Could not close sessions and clear media keys: ${e}`),this.hls&&this.hls.trigger(cu.ERROR,{type:ou.OTHER_ERROR,details:lu.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close sessions and clear media keys: ${e}`)})}).then(()=>{n&&this.log("finished closing key sessions and clearing media keys")})}onManifestLoading(){this._clear()}onManifestLoaded(e,{sessionKeys:t}){if(t&&this.config.emeEnabled&&!this.keyFormatPromise){const e=t.reduce((e,t)=>(-1===e.indexOf(t.keyFormat)&&e.push(t.keyFormat),e),[]);this.log(`Selecting key-system from session-keys ${e.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(e)}}removeSession(e){const{mediaKeysSession:t,licenseXhr:r,decryptdata:i}=e;if(t){this.log(`Remove licenses and keys and close session "${t.sessionId}" keyId: ${_u((null==i?void 0:i.keyId)||[])}`),e._onmessage&&(t.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(t.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),r&&r.readyState!==XMLHttpRequest.DONE&&r.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;const n=this.mediaKeySessions.indexOf(e);n>-1&&this.mediaKeySessions.splice(n,1);const{keyStatusTimeouts:s}=e;s&&Object.keys(s).forEach(e=>self.clearTimeout(s[e]));const{drmSystemOptions:a}=this.config,o=function(e){var t;return!(!e||"persistent-license"!==e.sessionType&&(null==(t=e.sessionTypes)||!t.some(e=>"persistent-license"===e)))}(a)?new Promise((e,r)=>{self.setTimeout(()=>r(new Error("MediaKeySession.remove() timeout")),8e3),t.remove().then(e).catch(r)}):Promise.resolve();return o.catch(e=>{this.log(`Could not remove session: ${e}`),this.hls&&this.hls.trigger(cu.ERROR,{type:ou.OTHER_ERROR,details:lu.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR,fatal:!1,error:new Error(`Could not remove session: ${e}`)})}).then(()=>t.close()).catch(e=>{this.log(`Could not close session: ${e}`),this.hls&&this.hls.trigger(cu.ERROR,{type:ou.OTHER_ERROR,details:lu.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close session: ${e}`)})})}return Promise.resolve()}}function wy(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(null===e.keyId)throw new Error("keyId is null");return _u(e.keyId)}function Sy(e,t){return e.keyId&&t.mediaKeysSession.keyStatuses.has(e.keyId)?t.mediaKeysSession.keyStatuses.get(e.keyId):e.matches(t.decryptdata)?t.keyStatus:void 0}Ey.CDMCleanupPromise=void 0;class Ty extends Error{constructor(e,t){super(t),this.data=void 0,e.error||(e.error=new Error(t)),this.data=e,e.err=e.error}}function xy(e,t){const r="output-restricted"===e,i=r?lu.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:lu.KEY_SYSTEM_STATUS_INTERNAL_ERROR;return new Ty({type:ou.KEY_SYSTEM_ERROR,details:i,fatal:!1,decryptdata:t},r?"HDCP level output restricted":`key status changed to "${e}"`)}function Ay(e,t){let r;try{r=new Event("addtrack")}catch(e){r=document.createEvent("Event"),r.initEvent("addtrack",!1,!1)}r.track=e,t.dispatchEvent(r)}function ky(e,t){const r=e.mode;if("disabled"===r&&(e.mode="hidden"),e.cues&&!e.cues.getCueById(t.id))try{if(e.addCue(t),!e.cues.getCueById(t.id))throw new Error(`addCue is failed for: ${t}`)}catch(r){Ru.debug(`[texttrack-utils]: ${r}`);try{const r=new self.TextTrackCue(t.startTime,t.endTime,t.text);r.id=t.id,e.addCue(r)}catch(e){Ru.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${e}`)}}"disabled"===r&&(e.mode=r)}function Iy(e,t){const r=e.mode;if("disabled"===r&&(e.mode="hidden"),e.cues)for(let r=e.cues.length;r--;)t&&e.cues[r].removeEventListener("enter",t),e.removeCue(e.cues[r]);"disabled"===r&&(e.mode=r)}function Ly(e,t,r,i){const n=e.mode;if("disabled"===n&&(e.mode="hidden"),e.cues&&e.cues.length>0){const n=function(e,t,r){const i=[],n=function(e,t){if(t<=e[0].startTime)return 0;const r=e.length-1;if(t>e[r].endTime)return-1;let i,n=0,s=r;for(;n<=s;)if(i=Math.floor((s+n)/2),t<e[i].startTime)s=i-1;else{if(!(t>e[i].startTime&&n<r))return i;n=i+1}return e[n].startTime-t<t-e[s].startTime?n:s}(e,t);if(n>-1)for(let s=n,a=e.length;s<a;s++){const n=e[s];if(n.startTime>=t&&n.endTime<=r)i.push(n);else if(n.startTime>r)return i}return i}(e.cues,t,r);for(let t=0;t<n.length;t++)i&&!i(n[t])||e.removeCue(n[t])}"disabled"===n&&(e.mode=n)}function Ry(e){const t=[];for(let r=0;r<e.length;r++){const i=e[r];"subtitles"!==i.kind&&"captions"!==i.kind||!i.label||t.push(e[r])}return t}function Py(e){let t=5381,r=e.length;for(;r;)t=33*t^e.charCodeAt(--r);return(t>>>0).toString()}const Cy=.025;let Dy=function(e){return e[e.Point=0]="Point",e[e.Range=1]="Range",e}({});function _y(e,t,r){return`${e.identifier}-${r+1}-${Py(t)}`}class Oy{constructor(e,t){this.base=void 0,this._duration=null,this._timelineStart=null,this.appendInPlaceDisabled=void 0,this.appendInPlaceStarted=void 0,this.dateRange=void 0,this.hasPlayed=!1,this.cumulativeDuration=0,this.resumeOffset=NaN,this.playoutLimit=NaN,this.restrictions={skip:!1,jump:!1},this.snapOptions={out:!1,in:!1},this.assetList=[],this.assetListLoader=void 0,this.assetListResponse=null,this.resumeAnchor=void 0,this.error=void 0,this.resetOnResume=void 0,this.base=t,this.dateRange=e,this.setDateRange(e)}setDateRange(e){this.dateRange=e,this.resumeOffset=e.attr.optionalFloat("X-RESUME-OFFSET",this.resumeOffset),this.playoutLimit=e.attr.optionalFloat("X-PLAYOUT-LIMIT",this.playoutLimit),this.restrictions=e.attr.enumeratedStringList("X-RESTRICT",this.restrictions),this.snapOptions=e.attr.enumeratedStringList("X-SNAP",this.snapOptions)}reset(){var e;this.appendInPlaceStarted=!1,null==(e=this.assetListLoader)||e.destroy(),this.assetListLoader=void 0,this.supplementsPrimary||(this.assetListResponse=null,this.assetList=[],this._duration=null)}isAssetPastPlayoutLimit(e){var t;if(e>0&&e>=this.assetList.length)return!0;const r=this.playoutLimit;if(e<=0||isNaN(r))return!1;if(0===r)return!0;return((null==(t=this.assetList[e])?void 0:t.startOffset)||0)>r}findAssetIndex(e){return this.assetList.indexOf(e)}get identifier(){return this.dateRange.id}get startDate(){return this.dateRange.startDate}get startTime(){const e=this.dateRange.startTime;if(this.snapOptions.out){const t=this.dateRange.tagAnchor;if(t)return My(e,t)}return e}get startOffset(){return this.cue.pre?0:this.startTime}get startIsAligned(){if(0===this.startTime||this.snapOptions.out)return!0;const e=this.dateRange.tagAnchor;if(e){const t=this.dateRange.startTime;return t-My(t,e)<.1}return!1}get resumptionOffset(){const e=this.resumeOffset,t=nu(e)?e:this.duration;return this.cumulativeDuration+t}get resumeTime(){const e=this.startOffset+this.resumptionOffset;if(this.snapOptions.in){const t=this.resumeAnchor;if(t)return My(e,t)}return e}get appendInPlace(){return!!this.appendInPlaceStarted||!this.appendInPlaceDisabled&&!(this.cue.once||this.cue.pre||!this.startIsAligned||!(isNaN(this.playoutLimit)&&isNaN(this.resumeOffset)||this.resumeOffset&&this.duration&&Math.abs(this.resumeOffset-this.duration)<Cy))}set appendInPlace(e){this.appendInPlaceStarted?this.resetOnResume=!e:this.appendInPlaceDisabled=!e}get timelineStart(){return null!==this._timelineStart?this._timelineStart:this.startTime}set timelineStart(e){this._timelineStart=e}get duration(){const e=this.playoutLimit;let t;return t=null!==this._duration?this._duration:this.dateRange.duration?this.dateRange.duration:this.dateRange.plannedDuration||0,!isNaN(e)&&e<t&&(t=e),t}set duration(e){this._duration=e}get cue(){return this.dateRange.cue}get timelineOccupancy(){return"RANGE"===this.dateRange.attr["X-TIMELINE-OCCUPIES"]?Dy.Range:Dy.Point}get supplementsPrimary(){return"PRIMARY"===this.dateRange.attr["X-TIMELINE-STYLE"]}get contentMayVary(){return"NO"!==this.dateRange.attr["X-CONTENT-MAY-VARY"]}get assetUrl(){return this.dateRange.attr["X-ASSET-URI"]}get assetListUrl(){return this.dateRange.attr["X-ASSET-LIST"]}get baseUrl(){return this.base.url}get assetListLoaded(){return this.assetList.length>0||null!==this.assetListResponse}toString(){return`["${(e=this).identifier}" ${e.cue.pre?"<pre>":e.cue.post?"<post>":""}${e.timelineStart.toFixed(2)}-${e.resumeTime.toFixed(2)}]`;var e}}function My(e,t){return e-t.start<t.duration/2&&!(Math.abs(e-(t.start+t.duration))<Cy)?t.start:t.start+t.duration}function Ny(e,t,r){const i=new self.URL(e,r);return"data:"!==i.protocol&&i.searchParams.set("_HLS_primary_id",t),i}function Fy(e,t){for(;null!=(r=e.assetList[++t])&&r.error;)var r;return t}function $y(e){const t=e.timelineStart,r=e.duration||0;return`["${e.identifier}" ${t.toFixed(2)}-${(t+r).toFixed(2)}]`}class By{constructor(e,t,r,i){this.hls=void 0,this.interstitial=void 0,this.assetItem=void 0,this.tracks=null,this.hasDetails=!1,this.mediaAttached=null,this._currentTime=void 0,this._bufferedEosTime=void 0,this.checkPlayout=()=>{this.reachedPlayout(this.currentTime)&&this.hls&&this.hls.trigger(cu.PLAYOUT_LIMIT_REACHED,{})};const n=this.hls=new e(t);this.interstitial=r,this.assetItem=i;const s=()=>{this.hasDetails=!0};n.once(cu.LEVEL_LOADED,s),n.once(cu.AUDIO_TRACK_LOADED,s),n.once(cu.SUBTITLE_TRACK_LOADED,s),n.on(cu.MEDIA_ATTACHING,(e,{media:t})=>{this.removeMediaListeners(),this.mediaAttached=t;this.interstitial.playoutLimit&&(t.addEventListener("timeupdate",this.checkPlayout),this.appendInPlace&&n.on(cu.BUFFER_APPENDED,()=>{const e=this.bufferedEnd;this.reachedPlayout(e)&&(this._bufferedEosTime=e,n.trigger(cu.BUFFERED_TO_END,void 0))}))})}get appendInPlace(){return this.interstitial.appendInPlace}loadSource(){const e=this.hls;if(e)if(e.url)e.levels.length&&!e.started&&e.startLoad(-1,!0);else{let t=this.assetItem.uri;try{t=Ny(t,e.config.primarySessionId||"").href}catch(e){}e.loadSource(t)}}bufferedInPlaceToEnd(e){var t;if(!this.appendInPlace)return!1;if(null!=(t=this.hls)&&t.bufferedToEnd)return!0;if(!e)return!1;const r=Math.min(this._bufferedEosTime||1/0,this.duration),i=this.timelineOffset,n=np.bufferInfo(e,i,0);return this.getAssetTime(n.end)>=r-.02}reachedPlayout(e){const t=this.interstitial.playoutLimit;return this.startOffset+e>=t}get destroyed(){var e;return!(null!=(e=this.hls)&&e.userConfig)}get assetId(){return this.assetItem.identifier}get interstitialId(){return this.assetItem.parentIdentifier}get media(){var e;return(null==(e=this.hls)?void 0:e.media)||null}get bufferedEnd(){const e=this.media||this.mediaAttached;if(!e)return this._bufferedEosTime?this._bufferedEosTime:this.currentTime;const t=np.bufferInfo(e,e.currentTime,.001);return this.getAssetTime(t.end)}get currentTime(){const e=this.media||this.mediaAttached;return e?this.getAssetTime(e.currentTime):this._currentTime||0}get duration(){const e=this.assetItem.duration;if(!e)return 0;const t=this.interstitial.playoutLimit;if(t){const r=t-this.startOffset;if(r>0&&r<e)return r}return e}get remaining(){const e=this.duration;return e?Math.max(0,e-this.currentTime):0}get startOffset(){return this.assetItem.startOffset}get timelineOffset(){var e;return(null==(e=this.hls)?void 0:e.config.timelineOffset)||0}set timelineOffset(e){const t=this.timelineOffset;if(e!==t){const r=e-t;if(Math.abs(r)>1/9e4&&this.hls){if(this.hasDetails)throw new Error("Cannot set timelineOffset after playlists are loaded");this.hls.config.timelineOffset=e}}}getAssetTime(e){const t=this.timelineOffset,r=this.duration;return Math.min(Math.max(0,e-t),r)}removeMediaListeners(){const e=this.mediaAttached;e&&(this._currentTime=e.currentTime,this.bufferSnapShot(),e.removeEventListener("timeupdate",this.checkPlayout))}bufferSnapShot(){var e;this.mediaAttached&&(null!=(e=this.hls)&&e.bufferedToEnd&&(this._bufferedEosTime=this.bufferedEnd))}destroy(){this.removeMediaListeners(),this.hls&&this.hls.destroy(),this.hls=null,this.tracks=this.mediaAttached=this.checkPlayout=null}attachMedia(e){var t;this.loadSource(),null==(t=this.hls)||t.attachMedia(e)}detachMedia(){var e;this.removeMediaListeners(),this.mediaAttached=null,null==(e=this.hls)||e.detachMedia()}resumeBuffering(){var e;null==(e=this.hls)||e.resumeBuffering()}pauseBuffering(){var e;null==(e=this.hls)||e.pauseBuffering()}transferMedia(){var e;return this.bufferSnapShot(),(null==(e=this.hls)?void 0:e.transferMedia())||null}resetDetails(){const e=this.hls;if(e&&this.hasDetails){e.stopLoad();const t=e=>delete e.details;e.levels.forEach(t),e.allAudioTracks.forEach(t),e.allSubtitleTracks.forEach(t),this.hasDetails=!1}}on(e,t,r){var i;null==(i=this.hls)||i.on(e,t)}once(e,t,r){var i;null==(i=this.hls)||i.once(e,t)}off(e,t,r){var i;null==(i=this.hls)||i.off(e,t)}toString(){var e;return`HlsAssetPlayer: ${$y(this.assetItem)} ${null==(e=this.hls)?void 0:e.sessionId} ${this.appendInPlace?"append-in-place":""}`}}class Uy extends Tu{constructor(e,t){super("interstitials-sched",t),this.onScheduleUpdate=void 0,this.eventMap={},this.events=null,this.items=null,this.durations={primary:0,playout:0,integrated:0},this.onScheduleUpdate=e}destroy(){this.reset(),this.onScheduleUpdate=null}reset(){this.eventMap={},this.setDurations(0,0,0),this.events&&this.events.forEach(e=>e.reset()),this.events=this.items=null}resetErrorsInRange(e,t){return this.events?this.events.reduce((r,i)=>e<=i.startOffset&&t>i.startOffset?(delete i.error,r+1):r,0):0}get duration(){const e=this.items;return e?e[e.length-1].end:0}get length(){return this.items?this.items.length:0}getEvent(e){return e&&this.eventMap[e]||null}hasEvent(e){return e in this.eventMap}findItemIndex(e,t){if(e.event)return this.findEventIndex(e.event.identifier);let r=-1;e.nextEvent?r=this.findEventIndex(e.nextEvent.identifier)-1:e.previousEvent&&(r=this.findEventIndex(e.previousEvent.identifier)+1);const i=this.items;if(i)for(i[r]||(void 0===t&&(t=e.start),r=this.findItemIndexAtTime(t));r>=0&&null!=(n=i[r])&&n.event;){var n;r--}return r}findItemIndexAtTime(e,t){const r=this.items;if(r)for(let i=0;i<r.length;i++){let n=r[i];if(t&&"primary"!==t&&(n=n[t]),e===n.start||e>n.start&&e<n.end)return i}return-1}findJumpRestrictedIndex(e,t){const r=this.items;if(r)for(let i=e;i<=t&&r[i];i++){const e=r[i].event;if(null!=e&&e.restrictions.jump&&!e.appendInPlace)return i}return-1}findEventIndex(e){const t=this.items;if(t)for(let i=t.length;i--;){var r;if((null==(r=t[i].event)?void 0:r.identifier)===e)return i}return-1}findAssetIndex(e,t){const r=e.assetList,i=r.length;if(i>1)for(let e=0;e<i;e++){const n=r[e];if(!n.error){const r=n.timelineStart;if(t===r||t>r&&(t<r+(n.duration||0)||e===i-1))return e}}return 0}get assetIdAtEnd(){var e;const t=null==(e=this.items)||null==(e=e[this.length-1])?void 0:e.event;if(t){const e=t.assetList,r=e[e.length-1];if(r)return r.identifier}return null}parseInterstitialDateRanges(e,t){const r=e.main.details,{dateRanges:i}=r,n=this.events,s=this.parseDateRanges(i,{url:r.url},t),a=Object.keys(i),o=n?n.filter(e=>!a.includes(e.identifier)):[];s.length&&s.sort((e,t)=>{const r=e.cue.pre,i=e.cue.post,n=t.cue.pre,s=t.cue.post;if(r&&!n)return-1;if(n&&!r)return 1;if(i&&!s)return 1;if(s&&!i)return-1;if(!(r||n||i||s)){const r=e.startTime,i=t.startTime;if(r!==i)return r-i}return e.dateRange.tagOrder-t.dateRange.tagOrder}),this.events=s,o.forEach(e=>{this.removeEvent(e)}),this.updateSchedule(e,o)}updateSchedule(e,t=[],r=!1){const i=this.events||[];if(i.length||t.length||this.length<2){const n=this.items,s=this.parseSchedule(i,e),a=r||t.length||(null==n?void 0:n.length)!==s.length||s.some((e,t)=>Math.abs(e.playout.start-n[t].playout.start)>.005||Math.abs(e.playout.end-n[t].playout.end)>.005);a&&(this.items=s,this.onScheduleUpdate(t,n))}}parseDateRanges(e,t,r){const i=[],n=Object.keys(e);for(let s=0;s<n.length;s++){const a=n[s],o=e[a];if(o.isInterstitial){let e=this.eventMap[a];e?e.setDateRange(o):(e=new Oy(o,t),this.eventMap[a]=e,!1===r&&(e.appendInPlace=r)),i.push(e)}}return i}parseSchedule(e,t){const r=[],i=t.main.details,n=i.live?1/0:i.edge;let s=0;if((e=e.filter(e=>!(e.error||e.cue.once&&e.hasPlayed))).length){this.resolveOffsets(e,t);let i=0,o=0;if(e.forEach((t,a)=>{const l=t.cue.pre,c=t.cue.post,d=e[a-1]||null,u=t.appendInPlace,h=c?n:t.startOffset,f=t.duration,p=t.timelineOccupancy===Dy.Range?f:0,m=t.resumptionOffset,g=(null==d?void 0:d.startTime)===h,v=h+t.cumulativeDuration;let y=u?v+f:h+m;if(l||!c&&h<=0){const e=o;o+=p,t.timelineStart=v;const i=s;s+=f,r.push({event:t,start:v,end:y,playout:{start:i,end:s},integrated:{start:e,end:o}})}else{if(!(h<=n))return;{if(!g){const n=h-i;if(n>.033){const l=i,c=o;o+=n;const d=s;s+=n;const u={previousEvent:e[a-1]||null,nextEvent:t,start:l,end:l+n,playout:{start:d,end:s},integrated:{start:c,end:o}};r.push(u)}else n>0&&d&&(d.cumulativeDuration+=n,r[r.length-1].end=h)}c&&(y=v),t.timelineStart=v;const n=o;o+=p;const l=s;s+=f,r.push({event:t,start:v,end:y,playout:{start:l,end:s},integrated:{start:n,end:o}})}}const b=t.resumeTime;i=c||b>n?n:b}),i<n){var a;const e=i,t=o,l=n-i;o+=l;const c=s;s+=l,r.push({previousEvent:(null==(a=r[r.length-1])?void 0:a.event)||null,nextEvent:null,start:i,end:e+l,playout:{start:c,end:s},integrated:{start:t,end:o}})}this.setDurations(n,s,o)}else{const e=0;r.push({previousEvent:null,nextEvent:null,start:e,end:n,playout:{start:e,end:n},integrated:{start:e,end:n}}),this.setDurations(n,n,n)}return r}setDurations(e,t,r){this.durations={primary:e,playout:t,integrated:r}}resolveOffsets(e,t){const r=t.main.details,i=r.live?1/0:r.edge;let n=0,s=-1;e.forEach((a,o)=>{const l=a.cue.pre,c=a.cue.post,d=l?0:c?i:a.startTime;this.updateAssetDurations(a);if(s===d?a.cumulativeDuration=n:(n=0,s=d),!c&&a.snapOptions.in&&(a.resumeAnchor=mf(null,r.fragments,a.startOffset+a.resumptionOffset,0,0)||void 0),a.appendInPlace&&!a.appendInPlaceStarted){this.primaryCanResumeInPlaceAt(a,t)||(a.appendInPlace=!1)}if(!a.appendInPlace&&o+1<e.length){e[o+1].startTime-e[o].resumeTime<.033&&(e[o+1].appendInPlace=!1,e[o+1].appendInPlace&&this.warn(`Could not change append strategy for abutting event ${a}`))}const u=nu(a.resumeOffset)?a.resumeOffset:a.duration;n+=u})}primaryCanResumeInPlaceAt(e,t){const r=e.resumeTime,i=e.startTime+e.resumptionOffset;if(Math.abs(r-i)>Cy)return this.log(`"${e.identifier}" resumption ${r} not aligned with estimated timeline end ${i}`),!1;return!Object.keys(t).some(i=>{const n=t[i].details,s=n.edge;if(r>=s)return this.log(`"${e.identifier}" resumption ${r} past ${i} playlist end ${s}`),!1;const a=mf(null,n.fragments,r);if(!a)return this.log(`"${e.identifier}" resumption ${r} does not align with any fragments in ${i} playlist (${n.fragStart}-${n.fragmentEnd})`),!0;const o="audio"===i?.175:0;return!(Math.abs(a.start-r)<Cy+o||Math.abs(a.end-r)<Cy+o)&&(this.log(`"${e.identifier}" resumption ${r} not aligned with ${i} fragment bounds (${a.start}-${a.end} sn: ${a.sn} cc: ${a.cc})`),!0)})}updateAssetDurations(e){if(!e.assetListLoaded)return;const t=e.timelineStart;let r=0,i=!1,n=!1;for(let s=0;s<e.assetList.length;s++){const a=e.assetList[s],o=t+r;a.startOffset=r,a.timelineStart=o,i||(i=null===a.duration),n||(n=!!a.error);r+=a.error?0:a.duration||0}e.duration=i&&!n?Math.max(r,e.duration):r}removeEvent(e){e.reset(),delete this.eventMap[e.identifier]}}function zy(e){return`[${e.event?'"'+e.event.identifier+'"':"primary"}: ${e.start.toFixed(2)}-${e.end.toFixed(2)}]`}class Gy{constructor(e){this.hls=void 0,this.hls=e}destroy(){this.hls=null}loadAssetList(e,t){const r=e.assetListUrl;let i;try{i=Ny(r,this.hls.sessionId,e.baseUrl)}catch(t){const i=this.assignAssetListError(e,lu.ASSET_LIST_LOAD_ERROR,t,r);return void this.hls.trigger(cu.ERROR,i)}t&&"data:"!==i.protocol&&i.searchParams.set("_HLS_start_offset",""+t);const n=this.hls.config,s=new(0,n.loader)(n),a={responseType:"json",url:i.href},o=n.interstitialAssetListLoadPolicy.default,l={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(t,r,i,n)=>{const s=t.data,a=null==s?void 0:s.ASSETS;if(!Array.isArray(a)){const t=this.assignAssetListError(e,lu.ASSET_LIST_PARSING_ERROR,new Error("Invalid interstitial asset list"),i.url,r,n);return void this.hls.trigger(cu.ERROR,t)}e.assetListResponse=s,this.hls.trigger(cu.ASSET_LIST_LOADED,{event:e,assetListResponse:s,networkDetails:n})},onError:(t,r,i,n)=>{const s=this.assignAssetListError(e,lu.ASSET_LIST_LOAD_ERROR,new Error(`Error loading X-ASSET-LIST: HTTP status ${t.code} ${t.text} (${r.url})`),r.url,n,i);this.hls.trigger(cu.ERROR,s)},onTimeout:(t,r,i)=>{const n=this.assignAssetListError(e,lu.ASSET_LIST_LOAD_TIMEOUT,new Error(`Timeout loading X-ASSET-LIST (${r.url})`),r.url,t,i);this.hls.trigger(cu.ERROR,n)}};return s.load(a,l,c),this.hls.trigger(cu.ASSET_LIST_LOADING,{event:e}),s}assignAssetListError(e,t,r,i,n,s){return e.error=r,{type:ou.NETWORK_ERROR,details:t,fatal:!1,interstitial:e,url:i,error:r,networkDetails:s,stats:n}}}function jy(e){var t;null==e||null==(t=e.play())||t.catch(()=>{})}function Hy(e,t){return`[${e}] Advancing timeline position to ${t}`}class Vy{constructor(e){this.buffered=void 0;const t=(t,r,i)=>{if((r>>>=0)>i-1)throw new DOMException(`Failed to execute '${t}' on 'TimeRanges': The index provided (${r}) is greater than the maximum bound (${i})`);return e[r][t]};this.buffered={get length(){return e.length},end:r=>t("end",r,e.length),start:r=>t("start",r,e.length)}}}const Wy={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},Yy=e=>String.fromCharCode(Wy[e]||e),Ky=15,qy=100,Xy={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},Qy={17:2,18:4,21:6,22:8,23:10,19:13,20:15},Zy={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},Jy={25:2,26:4,29:6,30:8,31:10,27:13,28:15},eb=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class tb{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){const r="function"==typeof t?t():t;Ru.log(`${this.time} [${e}] ${r}`)}}}const rb=function(e){const t=[];for(let r=0;r<e.length;r++)t.push(e[r].toString(16));return t};class ib{constructor(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}reset(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}setStyles(e){const t=["foreground","underline","italics","background","flash"];for(let r=0;r<t.length;r++){const i=t[r];e.hasOwnProperty(i)&&(this[i]=e[i])}}isDefault(){return"white"===this.foreground&&!this.underline&&!this.italics&&"black"===this.background&&!this.flash}equals(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash}copy(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}class nb{constructor(){this.uchar=" ",this.penState=new ib}reset(){this.uchar=" ",this.penState.reset()}setChar(e,t){this.uchar=e,this.penState.copy(t)}setPenState(e){this.penState.copy(e)}equals(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)}copy(e){this.uchar=e.uchar,this.penState.copy(e.penState)}isEmpty(){return" "===this.uchar&&this.penState.isDefault()}}class sb{constructor(e){this.chars=[],this.pos=0,this.currPenState=new ib,this.cueStartTime=null,this.logger=void 0;for(let e=0;e<qy;e++)this.chars.push(new nb);this.logger=e}equals(e){for(let t=0;t<qy;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}copy(e){for(let t=0;t<qy;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<qy;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e}setCursor(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>qy&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=qy)}moveCursor(e){const t=this.pos+e;if(e>1)for(let e=this.pos+1;e<t+1;e++)this.chars[e].setPenState(this.currPenState);this.setCursor(t)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(e){e>=144&&this.backSpace();const t=Yy(e);this.pos>=qy?this.logger.log(0,()=>"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!"):(this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1))}clearFromPos(e){let t;for(t=e;t<qy;t++)this.chars[t].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){const e=[];let t=!0;for(let r=0;r<qy;r++){const i=this.chars[r].uchar;" "!==i&&(t=!1),e.push(i)}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e);this.chars[this.pos].setPenState(this.currPenState)}}class ab{constructor(e){this.rows=[],this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let t=0;t<Ky;t++)this.rows.push(new sb(e));this.logger=e}reset(){for(let e=0;e<Ky;e++)this.rows[e].clear();this.currRow=14}equals(e){let t=!0;for(let r=0;r<Ky;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t}copy(e){for(let t=0;t<Ky;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<Ky;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e}backSpace(){this.rows[this.currRow].backSpace()}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow()}insertChar(e){this.rows[this.currRow].insertChar(e)}setPen(e){this.rows[this.currRow].setPenStyles(e)}moveCursor(e){this.rows[this.currRow].moveCursor(e)}setCursor(e){this.logger.log(2,"setCursor: "+e);this.rows[this.currRow].setCursor(e)}setPAC(e){this.logger.log(2,()=>"pacData = "+sf(e));let t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(let e=0;e<Ky;e++)this.rows[e].clear();const e=this.currRow+1-this.nrRollUpRows,r=this.lastOutputScreen;if(r){const i=r.rows[e].cueStartTime,n=this.logger.time;if(null!==i&&null!==n&&i<n)for(let i=0;i<this.nrRollUpRows;i++)this.rows[t-this.nrRollUpRows+i+1].copy(r.rows[e+i])}}this.currRow=t;const r=this.rows[this.currRow];if(null!==e.indent){const t=e.indent,i=Math.max(t-1,0);r.setCursor(e.indent),e.color=r.chars[i].penState.foreground}const i={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(i)}setBkgData(e){this.logger.log(2,()=>"bkgData = "+sf(e)),this.backSpace(),this.setPen(e),this.insertChar(32)}setRollUpRows(e){this.nrRollUpRows=e}rollUp(){if(null===this.nrRollUpRows)return void this.logger.log(3,"roll_up but nrRollUpRows not set yet");this.logger.log(1,()=>this.getDisplayText());const e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(2,"Rolling up")}getDisplayText(e){e=e||!1;const t=[];let r="",i=-1;for(let r=0;r<Ky;r++){const n=this.rows[r].getTextString();n&&(i=r+1,e?t.push("Row "+i+": '"+n+"'"):t.push(n.trim()))}return t.length>0&&(r=e?"["+t.join(" | ")+"]":t.join("\n")),r}getTextAndFormat(){return this.rows}}class ob{constructor(e,t,r){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new ab(r),this.nonDisplayedMemory=new ab(r),this.lastOutputScreen=new ab(r),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=r}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(e){this.outputFilter=e}setPAC(e){this.writeScreen.setPAC(e)}setBkgData(e){this.writeScreen.setBkgData(e)}setMode(e){e!==this.mode&&(this.mode=e,this.logger.log(2,()=>"MODE="+e),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}insertChars(e){for(let t=0;t<e.length;t++)this.writeScreen.insertChar(e[t]);const t=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>t+": "+this.writeScreen.getDisplayText(!0)),"MODE_PAINT-ON"!==this.mode&&"MODE_ROLL-UP"!==this.mode||(this.logger.log(1,()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())}ccRCL(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}ccBS(){this.logger.log(2,"BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}ccAOF(){}ccAON(){}ccDER(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}ccRU(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){if(this.logger.log(2,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode){const e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}ccTO(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}ccMIDROW(e){const t={flash:!1};if(t.underline=e%2==1,t.italics=e>=46,t.italics)t.foreground="white";else{const r=Math.floor(e/2)-16,i=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=i[r]}this.logger.log(2,"MIDROW: "+sf(t)),this.writeScreen.setPen(t)}outputDataUpdate(e=!1){const t=this.logger.time;null!==t&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t):this.cueStartTime=t,this.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))}}class lb{constructor(e,t,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory={a:null,b:null},this.logger=void 0;const i=this.logger=new tb;this.channels=[null,new ob(e,t,i),new ob(e+1,r,i)]}getHandler(e){return this.channels[e].getHandler()}setHandler(e,t){this.channels[e].setHandler(t)}addData(e,t){this.logger.time=e;for(let e=0;e<t.length;e+=2){const r=127&t[e],i=127&t[e+1];let n=!1,s=null;if(0===r&&0===i)continue;this.logger.log(3,()=>"["+rb([t[e],t[e+1]])+"] -> ("+rb([r,i])+")");const a=this.cmdHistory;if(r>=16&&r<=31){if(db(r,i,a)){cb(null,null,a),this.logger.log(3,()=>"Repeated command ("+rb([r,i])+") is dropped");continue}cb(r,i,this.cmdHistory),n=this.parseCmd(r,i),n||(n=this.parseMidrow(r,i)),n||(n=this.parsePAC(r,i)),n||(n=this.parseBackgroundAttributes(r,i))}else cb(null,null,a);if(!n&&(s=this.parseChars(r,i),s)){const e=this.currentChannel;if(e&&e>0){this.channels[e].insertChars(s)}else this.logger.log(2,"No channel found yet. TEXT-MODE?")}n||s||this.logger.log(2,()=>"Couldn't parse cleaned data "+rb([r,i])+" orig: "+rb([t[e],t[e+1]]))}}parseCmd(e,t){if(!((20===e||28===e||21===e||29===e)&&t>=32&&t<=47)&&!((23===e||31===e)&&t>=33&&t<=35))return!1;const r=20===e||21===e||23===e?1:2,i=this.channels[r];return 20===e||21===e||28===e||29===e?32===t?i.ccRCL():33===t?i.ccBS():34===t?i.ccAOF():35===t?i.ccAON():36===t?i.ccDER():37===t?i.ccRU(2):38===t?i.ccRU(3):39===t?i.ccRU(4):40===t?i.ccFON():41===t?i.ccRDC():42===t?i.ccTR():43===t?i.ccRTD():44===t?i.ccEDM():45===t?i.ccCR():46===t?i.ccENM():47===t&&i.ccEOC():i.ccTO(t-32),this.currentChannel=r,!0}parseMidrow(e,t){let r=0;if((17===e||25===e)&&t>=32&&t<=47){if(r=17===e?1:2,r!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;const i=this.channels[r];return!!i&&(i.ccMIDROW(t),this.logger.log(3,()=>"MIDROW ("+rb([e,t])+")"),!0)}return!1}parsePAC(e,t){let r;if(!((e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127)&&!((16===e||24===e)&&t>=64&&t<=95))return!1;const i=e<=23?1:2;r=t>=64&&t<=95?1===i?Xy[e]:Zy[e]:1===i?Qy[e]:Jy[e];const n=this.channels[i];return!!n&&(n.setPAC(this.interpretPAC(r,t)),this.currentChannel=i,!0)}interpretPAC(e,t){let r;const i={color:null,italics:!1,indent:null,underline:!1,row:e};return r=t>95?t-96:t-64,i.underline=!(1&~r),r<=13?i.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(i.italics=!0,i.color="white"):i.indent=4*Math.floor((r-16)/2),i}parseChars(e,t){let r,i=null,n=null;if(e>=25?(r=2,n=e-8):(r=1,n=e),n>=17&&n<=19){let e;e=17===n?t+80:18===n?t+112:t+144,this.logger.log(2,()=>"Special char '"+Yy(e)+"' in channel "+r),i=[e]}else e>=32&&e<=127&&(i=0===t?[e]:[e,t]);return i&&this.logger.log(3,()=>"Char codes = "+rb(i).join(",")),i}parseBackgroundAttributes(e,t){if(!((16===e||24===e)&&t>=32&&t<=47)&&!((23===e||31===e)&&t>=45&&t<=47))return!1;let r;const i={};16===e||24===e?(r=Math.floor((t-32)/2),i.background=eb[r],t%2==1&&(i.background=i.background+"_semi")):45===t?i.background="transparent":(i.foreground="black",47===t&&(i.underline=!0));const n=e<=23?1:2;return this.channels[n].setBkgData(i),!0}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){const t=this.channels[e];t&&t.reset()}cb(null,null,this.cmdHistory)}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){const r=this.channels[t];r&&r.cueSplitAtTime(e)}}}function cb(e,t,r){r.a=e,r.b=t}function db(e,t,r){return r.a===e&&r.b===t}var ub=function(){if(null!=Ap&&Ap.VTTCue)return self.VTTCue;const e=["","lr","rl"],t=["start","middle","end","left","right"];function r(e,t){if("string"!=typeof t)return!1;if(!Array.isArray(e))return!1;const r=t.toLowerCase();return!!~e.indexOf(r)&&r}function i(e){return r(t,e)}function n(e,...t){let r=1;for(;r<arguments.length;r++){const t=arguments[r];for(const r in t)e[r]=t[r]}return e}function s(t,s,a){const o=this,l={enumerable:!0};o.hasBeenReset=!1;let c="",d=!1,u=t,h=s,f=a,p=null,m="",g=!0,v="auto",y="start",b=50,E="middle",w=50,S="middle";Object.defineProperty(o,"id",n({},l,{get:function(){return c},set:function(e){c=""+e}})),Object.defineProperty(o,"pauseOnExit",n({},l,{get:function(){return d},set:function(e){d=!!e}})),Object.defineProperty(o,"startTime",n({},l,{get:function(){return u},set:function(e){if("number"!=typeof e)throw new TypeError("Start time must be set to a number.");u=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"endTime",n({},l,{get:function(){return h},set:function(e){if("number"!=typeof e)throw new TypeError("End time must be set to a number.");h=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"text",n({},l,{get:function(){return f},set:function(e){f=""+e,this.hasBeenReset=!0}})),Object.defineProperty(o,"region",n({},l,{get:function(){return p},set:function(e){p=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"vertical",n({},l,{get:function(){return m},set:function(t){const i=function(t){return r(e,t)}(t);if(!1===i)throw new SyntaxError("An invalid or illegal string was specified.");m=i,this.hasBeenReset=!0}})),Object.defineProperty(o,"snapToLines",n({},l,{get:function(){return g},set:function(e){g=!!e,this.hasBeenReset=!0}})),Object.defineProperty(o,"line",n({},l,{get:function(){return v},set:function(e){if("number"!=typeof e&&"auto"!==e)throw new SyntaxError("An invalid number or illegal string was specified.");v=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"lineAlign",n({},l,{get:function(){return y},set:function(e){const t=i(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");y=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"position",n({},l,{get:function(){return b},set:function(e){if(e<0||e>100)throw new Error("Position must be between 0 and 100.");b=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"positionAlign",n({},l,{get:function(){return E},set:function(e){const t=i(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");E=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"size",n({},l,{get:function(){return w},set:function(e){if(e<0||e>100)throw new Error("Size must be between 0 and 100.");w=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"align",n({},l,{get:function(){return S},set:function(e){const t=i(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");S=t,this.hasBeenReset=!0}})),o.displayState=void 0}return s.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},s}();class hb{decode(e,t){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}function fb(e){function t(e,t,r,i){return 3600*(0|e)+60*(0|t)+(0|r)+parseFloat(i||0)}const r=e.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return r?parseFloat(r[2])>59?t(r[2],r[3],0,r[4]):t(r[1],r[2],r[3],r[4]):null}class pb{constructor(){this.values=Object.create(null)}set(e,t){this.get(e)||""===t||(this.values[e]=t)}get(e,t,r){return r?this.has(e)?this.values[e]:t[r]:this.has(e)?this.values[e]:t}has(e){return e in this.values}alt(e,t,r){for(let i=0;i<r.length;++i)if(t===r[i]){this.set(e,t);break}}integer(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))}percent(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){const r=parseFloat(t);if(r>=0&&r<=100)return this.set(e,r),!0}return!1}}function mb(e,t,r,i){const n=i?e.split(i):[e];for(const e in n){if("string"!=typeof n[e])continue;const i=n[e].split(r);if(2!==i.length)continue;t(i[0],i[1])}}const gb=new ub(0,0,""),vb="middle"===gb.align?"middle":"center";function yb(e,t,r){const i=e;function n(){const t=fb(e);if(null===t)throw new Error("Malformed timestamp: "+i);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function s(){e=e.replace(/^\s+/,"")}if(s(),t.startTime=n(),s(),"--\x3e"!==e.slice(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+i);e=e.slice(3),s(),t.endTime=n(),s(),function(e,t){const i=new pb;mb(e,function(e,t){let n;switch(e){case"region":for(let n=r.length-1;n>=0;n--)if(r[n].id===t){i.set(e,r[n].region);break}break;case"vertical":i.alt(e,t,["rl","lr"]);break;case"line":n=t.split(","),i.integer(e,n[0]),i.percent(e,n[0])&&i.set("snapToLines",!1),i.alt(e,n[0],["auto"]),2===n.length&&i.alt("lineAlign",n[1],["start",vb,"end"]);break;case"position":n=t.split(","),i.percent(e,n[0]),2===n.length&&i.alt("positionAlign",n[1],["start",vb,"end","line-left","line-right","auto"]);break;case"size":i.percent(e,t);break;case"align":i.alt(e,t,["start",vb,"end","left","right"])}},/:/,/\s/),t.region=i.get("region",null),t.vertical=i.get("vertical","");let n=i.get("line","auto");"auto"===n&&-1===gb.line&&(n=-1),t.line=n,t.lineAlign=i.get("lineAlign","start"),t.snapToLines=i.get("snapToLines",!0),t.size=i.get("size",100),t.align=i.get("align",vb);let s=i.get("position","auto");"auto"===s&&50===gb.position&&(s="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=s}(e,t)}function bb(e){return e.replace(/<br(?: \/)?>/gi,"\n")}class Eb{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new hb,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(e){const t=this;function r(){let e=t.buffer,r=0;for(e=bb(e);r<e.length&&"\r"!==e[r]&&"\n"!==e[r];)++r;const i=e.slice(0,r);return"\r"===e[r]&&++r,"\n"===e[r]&&++r,t.buffer=e.slice(r),i}function i(e){mb(e,function(e,t){},/:/)}e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));try{let e="";if("INITIAL"===t.state){if(!/\r\n|\n/.test(t.buffer))return this;e=r();const i=e.match(/^()?WEBVTT([ \t].*)?$/);if(null==i||!i[0])throw new Error("Malformed WebVTT signature.");t.state="HEADER"}let n=!1;for(;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(n?n=!1:e=r(),t.state){case"HEADER":/:/.test(e)?i(e):e||(t.state="ID");continue;case"NOTE":e||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(e)){t.state="NOTE";break}if(!e)continue;if(t.cue=new ub(0,0,""),t.state="CUE",-1===e.indexOf("--\x3e")){t.cue.id=e;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{yb(e,t.cue,t.regionList)}catch(e){t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{const r=-1!==e.indexOf("--\x3e");if(!e||r&&(n=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(null===t.cue)continue;t.cue.text&&(t.cue.text+="\n"),t.cue.text+=e}continue;case"BADCUE":e||(t.state="ID")}}}catch(e){"CUETEXT"===t.state&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state="INITIAL"===t.state?"BADWEBVTT":"BADCUE"}return this}flush(){const e=this;try{if((e.cue||"HEADER"===e.state)&&(e.buffer+="\n\n",e.parse()),"INITIAL"===e.state||"BADWEBVTT"===e.state)throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this}}const wb=/\r\n|\n\r|\n|\r/g,Sb=function(e,t,r=0){return e.slice(r,r+t.length)===t};function Tb(e,t,r){return Py(e.toString())+Py(t.toString())+Py(r)}function xb(e,t,r,i,n,s,a){const o=new Eb,l=Du(new Uint8Array(e)).trim().replace(wb,"\n").split("\n"),c=[],d=t?function(e,t=1){return Yg(e,9e4,1/t)}(t.baseTime,t.timescale):0;let u,h="00:00.000",f=0,p=0,m=!0;o.oncue=function(e){const s=r[i];let a=r.ccOffset;const o=(f-d)/9e4;if(null!=s&&s.new&&(void 0!==p?a=r.ccOffset=s.start:function(e,t,r){let i=e[t],n=e[i.prevCC];if(!n||!n.new&&i.new)return e.ccOffset=e.presentationOffset=i.start,void(i.new=!1);for(;null!=(s=n)&&s.new;){var s;e.ccOffset+=i.start-n.start,i.new=!1,i=n,n=e[i.prevCC]}e.presentationOffset=r}(r,i,o)),o){if(!t)return void(u=new Error("Missing initPTS for VTT MPEGTS"));a=o-r.presentationOffset}const l=e.endTime-e.startTime,h=tv(9e4*(e.startTime+a-p),9e4*n)/9e4;e.startTime=Math.max(h,0),e.endTime=Math.max(h+l,0);const m=e.text.trim();e.text=decodeURIComponent(encodeURIComponent(m)),e.id||(e.id=Tb(e.startTime,e.endTime,m)),e.endTime>0&&c.push(e)},o.onparsingerror=function(e){u=e},o.onflush=function(){u?a(u):s(c)},l.forEach(e=>{if(m){if(Sb(e,"X-TIMESTAMP-MAP=")){m=!1,e.slice(16).split(",").forEach(e=>{Sb(e,"LOCAL:")?h=e.slice(6):Sb(e,"MPEGTS:")&&(f=parseInt(e.slice(7)))});try{p=function(e){let t=parseInt(e.slice(-3));const r=parseInt(e.slice(-6,-4)),i=parseInt(e.slice(-9,-7)),n=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!(nu(t)&&nu(r)&&nu(i)&&nu(n)))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*r,t+=6e4*i,t+=36e5*n,t}(h)/1e3}catch(e){u=e}return}""===e&&(m=!1)}o.parse(e+"\n")}),o.flush()}const Ab="stpp.ttml.im1t",kb=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Ib=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,Lb={left:"start",center:"center",right:"end",start:"start",end:"end"};function Rb(e,t,r,i){const n=oh(new Uint8Array(e),["mdat"]);if(0===n.length)return void i(new Error("Could not parse IMSC1 mdat"));const s=n.map(e=>Du(e)),a=function(e,t,r=1,i=!1){return Yg(e,t,1/r,i)}(t.baseTime,1,t.timescale);try{s.forEach(e=>r(function(e,t){const r=(new DOMParser).parseFromString(e,"text/xml"),i=r.getElementsByTagName("tt")[0];if(!i)throw new Error("Invalid ttml");const n={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},s=Object.keys(n).reduce((e,t)=>(e[t]=i.getAttribute(`ttp:${t}`)||n[t],e),{}),a="preserve"!==i.getAttribute("xml:space"),o=Cb(Pb(i,"styling","style")),l=Cb(Pb(i,"layout","region")),c=Pb(i,"body","[begin]");return[].map.call(c,e=>{const r=Db(e,a);if(!r||!e.hasAttribute("begin"))return null;const i=Mb(e.getAttribute("begin"),s),n=Mb(e.getAttribute("dur"),s);let c=Mb(e.getAttribute("end"),s);if(null===i)throw Ob(e);if(null===c){if(null===n)throw Ob(e);c=i+n}const d=new ub(i-t,c-t,r);d.id=Tb(d.startTime,d.endTime,d.text);const u=function(e,t,r){const i="http://www.w3.org/ns/ttml#styling";let n=null;const s=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],a=null!=e&&e.hasAttribute("style")?e.getAttribute("style"):null;a&&r.hasOwnProperty(a)&&(n=r[a]);return s.reduce((r,s)=>{const a=_b(t,i,s)||_b(e,i,s)||_b(n,i,s);return a&&(r[s]=a),r},{})}(l[e.getAttribute("region")],o[e.getAttribute("style")],o),{textAlign:h}=u;if(h){const e=Lb[h];e&&(d.lineAlign=e),d.align=h}return Eu(d,u),d}).filter(e=>null!==e)}(e,a)))}catch(e){i(e)}}function Pb(e,t,r){const i=e.getElementsByTagName(t)[0];return i?[].slice.call(i.querySelectorAll(r)):[]}function Cb(e){return e.reduce((e,t)=>{const r=t.getAttribute("xml:id");return r&&(e[r]=t),e},{})}function Db(e,t){return[].slice.call(e.childNodes).reduce((e,r,i)=>{var n;return"br"===r.nodeName&&i?e+"\n":null!=(n=r.childNodes)&&n.length?Db(r,t):t?e+r.textContent.trim().replace(/\s+/g," "):e+r.textContent},"")}function _b(e,t,r){return e&&e.hasAttributeNS(t,r)?e.getAttributeNS(t,r):null}function Ob(e){return new Error(`Could not parse ttml timestamp ${e}`)}function Mb(e,t){if(!e)return null;let r=fb(e);return null===r&&(kb.test(e)?r=function(e,t){const r=kb.exec(e),i=(0|r[4])+(0|r[5])/t.subFrameRate;return 3600*(0|r[1])+60*(0|r[2])+(0|r[3])+i/t.frameRate}(e,t):Ib.test(e)&&(r=function(e,t){const r=Ib.exec(e),i=Number(r[1]);switch(r[2]){case"h":return 3600*i;case"m":return 60*i;case"ms":return 1e3*i;case"f":return i/t.frameRate;case"t":return i/t.tickRate}return i}(e,t))),r}class Nb{constructor(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}dispatchCue(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(e,t,r){(null===this.startTime||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}function Fb(e){return e.characteristics&&/transcribes-spoken-dialog/gi.test(e.characteristics)&&/describes-music-and-sound/gi.test(e.characteristics)?"captions":"subtitles"}function $b(e,t){return!!e&&e.kind===Fb(t)&&vv(t,e)}function Bb(e,t,r,i){return Math.min(t,i)-Math.max(e,r)}const Ub=/\s/,zb={newCue(e,t,r,i){const n=[];let s,a,o,l,c;const d=self.VTTCue||self.TextTrackCue;for(let h=0;h<i.rows.length;h++)if(s=i.rows[h],o=!0,l=0,c="",!s.isEmpty()){var u;for(let e=0;e<s.chars.length;e++)Ub.test(s.chars[e].uchar)&&o?l++:(c+=s.chars[e].uchar,o=!1);s.cueStartTime=t,t===r&&(r+=1e-4),l>=16?l--:l++;const i=bb(c.trim()),f=Tb(t,r,i);null!=e&&null!=(u=e.cues)&&u.getCueById(f)||(a=new d(t,r,i),a.id=f,a.line=h+1,a.align="left",a.position=10+Math.min(80,10*Math.floor(8*l/32)),n.push(a))}return e&&n.length&&(n.sort((e,t)=>"auto"===e.line||"auto"===t.line?0:e.line>8&&t.line>8?t.line-e.line:e.line-t.line),n.forEach(t=>ky(e,t))),n}};const Gb=/(\d+)-(\d+)\/(\d+)/;class jb{constructor(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||Hb,this.controller=new self.AbortController,this.stats=new Hu}destroy(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null}abortInternal(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())}abort(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(e,t,r){const i=this.stats;if(i.loading.start)throw new Error("Loader can only be used once.");i.loading.start=self.performance.now();const n=function(e,t){const r={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(Eu({},e.headers))};e.rangeEnd&&r.headers.set("Range","bytes="+e.rangeStart+"-"+String(e.rangeEnd-1));return r}(e,this.controller.signal),s="arraybuffer"===e.responseType,a=s?"byteLength":"length",{maxTimeToFirstByteMs:o,maxLoadTimeMs:l}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,n),self.clearTimeout(this.requestTimeout),t.timeout=o&&nu(o)?o:l,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(i,e,this.response))},t.timeout);(cv(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then(r=>{var n;this.response=this.loader=r;const a=Math.max(self.performance.now(),i.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=l,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(i,e,this.response))},l-(a-i.loading.start)),!r.ok){const{status:e,statusText:t}=r;throw new Vb(t||"fetch, bad network response",e,r)}i.loading.first=a,i.total=function(e){const t=e.get("Content-Range");if(t){const e=function(e){const t=Gb.exec(e);if(t)return parseInt(t[2])-parseInt(t[1])+1}(t);if(nu(e))return e}const r=e.get("Content-Length");if(r)return parseInt(r)}(r.headers)||i.total;const o=null==(n=this.callbacks)?void 0:n.onProgress;return o&&nu(t.highWaterMark)?this.loadProgressively(r,i,e,t.highWaterMark,o):s?r.arrayBuffer():"json"===e.responseType?r.json():r.text()}).then(r=>{var n,s;const o=this.response;if(!o)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),i.loading.end=Math.max(self.performance.now(),i.loading.first);const l=r[a];l&&(i.loaded=i.total=l);const c={url:o.url,data:r,code:o.status},d=null==(n=this.callbacks)?void 0:n.onProgress;d&&!nu(t.highWaterMark)&&d(i,e,r,o),null==(s=this.callbacks)||s.onSuccess(c,i,e,o)}).catch(t=>{var r;if(self.clearTimeout(this.requestTimeout),i.aborted)return;const n=t&&t.code||0,s=t?t.message:null;null==(r=this.callbacks)||r.onError({code:n,text:s},e,t?t.details:null,i)})}getCacheAge(){let e=null;if(this.response){const t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,t,r,i=0,n){const s=new $m,a=e.body.getReader(),o=()=>a.read().then(a=>{if(a.done)return s.dataLength&&n(t,r,s.flush().buffer,e),Promise.resolve(new ArrayBuffer(0));const l=a.value,c=l.length;return t.loaded+=c,c<i||s.dataLength?(s.push(l),s.dataLength>=i&&n(t,r,s.flush().buffer,e)):n(t,r,l.buffer,e),o()}).catch(()=>Promise.reject());return o()}}function Hb(e,t){return new self.Request(e.url,t)}class Vb extends Error{constructor(e,t,r){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=r}}const Wb=/^age:\s*[\d.]+\s*$/im;class Yb{constructor(e){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=null,this.loader=null,this.stats=void 0,this.xhrSetup=e&&e.xhrSetup||null,this.stats=new Hu,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null}abortInternal(){const e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,4!==e.readyState&&(this.stats.aborted=!0,e.abort()))}abort(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(e,t,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=r,this.loadInternal()}loadInternal(){const{config:e,context:t}=this;if(!e||!t)return;const r=this.loader=new self.XMLHttpRequest,i=this.stats;i.loading.first=0,i.loaded=0,i.aborted=!1;const n=this.xhrSetup;n?Promise.resolve().then(()=>{if(this.loader===r&&!this.stats.aborted)return n(r,t.url)}).catch(e=>{if(this.loader===r&&!this.stats.aborted)return r.open("GET",t.url,!0),n(r,t.url)}).then(()=>{this.loader!==r||this.stats.aborted||this.openAndSendXhr(r,t,e)}).catch(e=>{var n;null==(n=this.callbacks)||n.onError({code:r.status,text:e.message},t,r,i)}):this.openAndSendXhr(r,t,e)}openAndSendXhr(e,t,r){e.readyState||e.open("GET",t.url,!0);const i=t.headers,{maxTimeToFirstByteMs:n,maxLoadTimeMs:s}=r.loadPolicy;if(i)for(const t in i)e.setRequestHeader(t,i[t]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),r.timeout=n&&nu(n)?n:s,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),e.send()}readystatechange(){const{context:e,loader:t,stats:r}=this;if(!e||!t)return;const i=t.readyState,n=this.config;if(!r.aborted&&i>=2&&(0===r.loading.first&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),n.timeout!==n.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),n.timeout=n.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),n.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),4===i)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;const i=t.status,l="text"===t.responseType?t.responseText:null;if(i>=200&&i<300){const n=null!=l?l:t.response;if(null!=n){var s,a;r.loading.end=Math.max(self.performance.now(),r.loading.first);const o="arraybuffer"===t.responseType?n.byteLength:n.length;r.loaded=r.total=o,r.bwEstimate=8e3*r.total/(r.loading.end-r.loading.first);const l=null==(s=this.callbacks)?void 0:s.onProgress;l&&l(r,e,n,t);const c={url:t.responseURL,data:n,code:i};return void(null==(a=this.callbacks)||a.onSuccess(c,r,e,t))}}const c=n.loadPolicy.errorRetry;var o;if(Af(c,r.retry,!1,{url:e.url,data:void 0,code:i}))this.retry(c);else Ru.error(`${i} while loading ${e.url}`),null==(o=this.callbacks)||o.onError({code:i,text:t.statusText},e,t,r)}}loadtimeout(){if(!this.config)return;const e=this.config.loadPolicy.timeoutRetry;if(Af(e,this.stats.retry,!0))this.retry(e);else{var t;Ru.warn(`timeout while loading ${null==(t=this.context)?void 0:t.url}`);const e=this.callbacks;e&&(this.abortInternal(),e.onTimeout(this.stats,this.context,this.loader))}}retry(e){const{context:t,stats:r}=this;this.retryDelay=Tf(e,r.retry),r.retry++,Ru.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${null==t?void 0:t.url}, retrying ${r.retry}/${e.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}loadprogress(e){const t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}getCacheAge(){let e=null;if(this.loader&&Wb.test(this.loader.getAllResponseHeaders())){const t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}}const Kb=Su(Su({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,maxDevicePixelRatio:Number.POSITIVE_INFINITY,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,startOnSegmentBoundary:!1,maxBufferSize:6e7,maxFragLookUpTolerance:.25,maxBufferHole:.1,detectStallWithCurrentTimeMs:1250,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,nudgeOnVideoHole:!0,liveSyncMode:"edge",liveSyncDurationCount:3,liveSyncOnStallIncrease:1,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,ignorePlaylistParsingErrors:!1,loader:Yb,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:class extends Tu{constructor(e){super("abr",e.logger),this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.codecTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.rebufferNotice=-1,this.supportedCache={},this.bwEstimator=void 0,this._abandonRulesCheck=e=>{var t;const{fragCurrent:r,partCurrent:i,hls:n}=this,{autoLevelEnabled:s,media:a}=n;if(!r||!a)return;const o=performance.now(),l=i?i.stats:r.stats,c=i?i.duration:r.duration,d=o-l.loading.start,u=n.minAutoLevel,h=r.level,f=this._nextAutoLevel;if(l.aborted||l.loaded&&l.loaded===l.total||h<=u)return this.clearTimer(),void(this._nextAutoLevel=-1);if(!s)return;const p=f>-1&&f!==h,m=!!e||p;if(!m&&(a.paused||!a.playbackRate||!a.readyState))return;const g=n.mainForwardBufferInfo;if(!m&&null===g)return;const v=this.bwEstimator.getEstimateTTFB(),y=Math.abs(a.playbackRate);if(d<=Math.max(v,c/(2*y)*1e3))return;const b=g?g.len/y:0,E=l.loading.first?l.loading.first-l.loading.start:-1,w=l.loaded&&E>-1,S=this.getBwEstimate(),T=n.levels,x=T[h],A=Math.max(l.loaded,Math.round(c*(r.bitrate||x.averageBitrate)/8));let k=w?d-E:d;k<1&&w&&(k=Math.min(d,8*l.loaded/S));const I=w?1e3*l.loaded/k:0,L=v/1e3,R=I?(A-l.loaded)/I:8*A/S+L;if(R<=b)return;const P=I?8*I:S,C=!0===(null==(t=(null==e?void 0:e.details)||this.hls.latestLevelDetails)?void 0:t.live),D=this.hls.config.abrBandWidthUpFactor;let _,O=Number.POSITIVE_INFINITY;for(_=h-1;_>u;_--){const e=T[_].maxBitrate,t=!T[_].details||C;if(O=this.getTimeToLoadFrag(L,P,c*e,t),O<Math.min(b,c+L))break}if(O>=R)return;if(O>10*c)return;w?this.bwEstimator.sample(d-Math.min(v,E),l.loaded):this.bwEstimator.sampleTTFB(d);const M=T[_].maxBitrate;this.getBwEstimate()*D>M&&this.resetEstimator(M);const N=this.findBestLevel(M,u,_,0,b,1,1);N>-1&&(_=N),this.warn(`Fragment ${r.sn}${i?" part "+i.index:""} of level ${h} is loading too slowly;\n Fragment duration: ${r.duration.toFixed(3)}\n Time to underbuffer: ${b.toFixed(3)} s\n Estimated load time for current fragment: ${R.toFixed(3)} s\n Estimated load time for down switch fragment: ${O.toFixed(3)} s\n TTFB estimate: ${0|E} ms\n Current BW estimate: ${nu(S)?0|S:"Unknown"} bps\n New BW estimate: ${0|this.getBwEstimate()} bps\n Switching to level ${_} @ ${0|M} bps`),n.nextLoadLevel=n.nextAutoLevel=_,this.clearTimer();const F=()=>{if(this.clearTimer(),this.fragCurrent===r&&this.hls.loadLevel===_&&_>0){const e=this.getStarvationDelay();if(this.warn(`Aborting inflight request ${_>0?"and switching down":""}\n Fragment duration: ${r.duration.toFixed(3)} s\n Time to underbuffer: ${e.toFixed(3)} s`),r.abortRequests(),this.fragCurrent=this.partCurrent=null,_>u){let t=this.findBestLevel(this.hls.levels[u].bitrate,u,_,0,e,1,1);-1===t&&(t=u),this.hls.nextLoadLevel=this.hls.nextAutoLevel=t,this.resetEstimator(this.hls.levels[t].bitrate)}}};p||R>2*O?F():this.timer=self.setInterval(F,1e3*O),n.trigger(cu.FRAG_LOAD_EMERGENCY_ABORTED,{frag:r,part:i,stats:l})},this.hls=e,this.bwEstimator=this.initEstimator(),this.registerListeners()}resetEstimator(e){e&&(this.log(`setting initial bwe to ${e}`),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()}initEstimator(){const e=this.hls.config;return new yu(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){const{hls:e}=this;e.on(cu.MANIFEST_LOADING,this.onManifestLoading,this),e.on(cu.FRAG_LOADING,this.onFragLoading,this),e.on(cu.FRAG_LOADED,this.onFragLoaded,this),e.on(cu.FRAG_BUFFERED,this.onFragBuffered,this),e.on(cu.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(cu.LEVEL_LOADED,this.onLevelLoaded,this),e.on(cu.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(cu.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(cu.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e&&(e.off(cu.MANIFEST_LOADING,this.onManifestLoading,this),e.off(cu.FRAG_LOADING,this.onFragLoading,this),e.off(cu.FRAG_LOADED,this.onFragLoaded,this),e.off(cu.FRAG_BUFFERED,this.onFragBuffered,this),e.off(cu.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(cu.LEVEL_LOADED,this.onLevelLoaded,this),e.off(cu.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(cu.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(cu.ERROR,this.onError,this))}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=this.supportedCache=null,this.fragCurrent=this.partCurrent=null}onManifestLoading(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.supportedCache={},this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()}onLevelsUpdated(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null}onMaxAutoLevelUpdated(){this.firstSelection=-1,this.nextAutoLevelKey=""}onFragLoading(e,t){const r=t.frag;if(!this.ignoreFragment(r)){var i;if(!r.bitrateTest)this.fragCurrent=r,this.partCurrent=null!=(i=t.part)?i:null;this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}}onLevelSwitching(e,t){this.clearTimer()}onError(e,t){if(!t.fatal)switch(t.details){case lu.BUFFER_ADD_CODEC_ERROR:case lu.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case lu.FRAG_LOAD_TIMEOUT:{const e=t.frag,{fragCurrent:r,partCurrent:i}=this;if(e&&r&&e.sn===r.sn&&e.level===r.level){const t=performance.now(),r=i?i.stats:e.stats,n=t-r.loading.start,s=r.loading.first?r.loading.first-r.loading.start:-1;if(r.loaded&&s>-1){const e=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(n-Math.min(e,s),r.loaded)}else this.bwEstimator.sampleTTFB(n)}break}}}getTimeToLoadFrag(e,t,r,i){return e+r/t+(i?e+this.lastLevelLoadSec:0)}onLevelLoaded(e,t){const r=this.hls.config,{loading:i}=t.stats,n=i.end-i.first;nu(n)&&(this.lastLevelLoadSec=n/1e3),t.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD),this.timer>-1&&this._abandonRulesCheck(t.levelInfo)}onFragLoaded(e,{frag:t,part:r}){const i=r?r.stats:t.stats;if(t.type===pu&&this.bwEstimator.sampleTTFB(i.loading.first-i.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),t.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){const e=r?r.duration:t.duration,n=this.hls.levels[t.level],s=(n.loaded?n.loaded.bytes:0)+i.loaded,a=(n.loaded?n.loaded.duration:0)+e;n.loaded={bytes:s,duration:a},n.realBitrate=Math.round(8*s/a)}if(t.bitrateTest){const e={stats:i,frag:t,part:r,id:t.type};this.onFragBuffered(cu.FRAG_BUFFERED,e),t.bitrateTest=!1}else this.lastLoadedFragLevel=t.level}}onFragBuffered(e,t){const{frag:r,part:i}=t,n=null!=i&&i.stats.loaded?i.stats:r.stats;if(n.aborted)return;if(this.ignoreFragment(r))return;const s=n.parsing.end-n.loading.start-Math.min(n.loading.first-n.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(s,n.loaded),n.bwEstimate=this.getBwEstimate(),r.bitrateTest?this.bitrateTestDelay=s/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==pu||"initSegment"===e.sn}clearTimer(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}get firstAutoLevel(){const{maxAutoLevel:e,minAutoLevel:t}=this.hls,r=this.getBwEstimate(),i=this.hls.config.maxStarvationDelay,n=this.findBestLevel(r,t,e,0,i,1,1);if(n>-1)return n;const s=this.hls.firstLevel,a=Math.min(Math.max(s,t),e);return this.warn(`Could not find best starting auto level. Defaulting to first in playlist ${s} clamped to ${a}`),a}get forcedAutoLevel(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}get nextAutoLevel(){const e=this.forcedAutoLevel,t=this.bwEstimator.canEstimate(),r=this.lastLoadedFragLevel>-1;if(!(-1===e||t&&r&&this.nextAutoLevelKey!==this.getAutoLevelKey()))return e;const i=t&&r?this.getNextABRAutoLevel():this.firstAutoLevel;if(-1!==e){const t=this.hls.levels;if(t.length>Math.max(e,i)&&t[e].loadError<=t[i].loadError)return e}return this._nextAutoLevel=i,this.nextAutoLevelKey=this.getAutoLevelKey(),i}getAutoLevelKey(){return`${this.getBwEstimate()}_${this.getStarvationDelay().toFixed(2)}`}getNextABRAutoLevel(){const{fragCurrent:e,partCurrent:t,hls:r}=this;if(r.levels.length<=1)return r.loadLevel;const{maxAutoLevel:i,config:n,minAutoLevel:s}=r,a=t?t.duration:e?e.duration:0,o=this.getBwEstimate(),l=this.getStarvationDelay();let c=n.abrBandWidthFactor,d=n.abrBandWidthUpFactor;if(l){const e=this.findBestLevel(o,s,i,l,0,c,d);if(e>=0)return this.rebufferNotice=-1,e}let u=a?Math.min(a,n.maxStarvationDelay):n.maxStarvationDelay;if(!l){const e=this.bitrateTestDelay;if(e){u=(a?Math.min(a,n.maxLoadingDelay):n.maxLoadingDelay)-e,this.info(`bitrate test took ${Math.round(1e3*e)}ms, set first fragment max fetchDuration to ${Math.round(1e3*u)} ms`),c=d=1}}const h=this.findBestLevel(o,s,i,l,u,c,d);if(this.rebufferNotice!==h&&(this.rebufferNotice=h,this.info(`${l?"rebuffering expected":"buffer is empty"}, optimal quality level ${h}`)),h>-1)return h;const f=r.levels[s],p=r.loadLevelObj;return p&&(null==f?void 0:f.bitrate)<p.bitrate?s:r.loadLevel}getStarvationDelay(){const e=this.hls,t=e.media;if(!t)return 1/0;const r=t&&0!==t.playbackRate?Math.abs(t.playbackRate):1,i=e.mainForwardBufferInfo;return(i?i.len:0)/r}getBwEstimate(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}findBestLevel(e,t,r,i,n,s,a){var o;const l=i+n,c=this.lastLoadedFragLevel,d=-1===c?this.hls.firstLevel:c,{fragCurrent:u,partCurrent:h}=this,{levels:f,allAudioTracks:p,loadLevel:m,config:g}=this.hls;if(1===f.length)return 0;const v=f[d],y=!(null==(o=this.hls.latestLevelDetails)||!o.live),b=-1===m||-1===c;let E,w="SDR",S=(null==v?void 0:v.frameRate)||0;const{audioPreference:T,videoPreference:x}=g,A=this.audioTracksByGroup||(this.audioTracksByGroup=of(p));let k=-1;if(b){if(-1!==this.firstSelection)return this.firstSelection;const i=this.codecTiers||(this.codecTiers=function(e,t,r,i){return e.slice(r,i+1).reduce((e,r,i)=>{if(!r.codecSet)return e;const n=r.audioGroups;let s=e[r.codecSet];s||(e[r.codecSet]=s={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:i,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!n,fragmentError:0}),s.minBitrate=Math.min(s.minBitrate,r.bitrate);const a=Math.min(r.height,r.width);return s.minHeight=Math.min(s.minHeight,a),s.minFramerate=Math.min(s.minFramerate,r.frameRate),s.minIndex=Math.min(s.minIndex,i),s.maxScore=Math.max(s.maxScore,r.score),s.fragmentError+=r.fragmentError,s.videoRanges[r.videoRange]=(s.videoRanges[r.videoRange]||0)+1,n&&n.forEach(e=>{if(!e)return;const r=t.groups[e];r&&(s.hasDefaultAudio=s.hasDefaultAudio||t.hasDefaultAudio?r.hasDefault:r.hasAutoSelect||!t.hasDefaultAudio&&!t.hasAutoSelectAudio,Object.keys(r.channels).forEach(e=>{s.channels[e]=(s.channels[e]||0)+r.channels[e]}))}),e},{})}(f,A,t,r)),n=function(e,t,r,i,n){const s=Object.keys(e),a=null==i?void 0:i.channels,o=null==i?void 0:i.audioCodec,l=null==n?void 0:n.videoCodec,c=a&&2===parseInt(a);let d=!1,u=!1,h=1/0,f=1/0,p=1/0,m=1/0,g=0,v=[];const{preferHDR:y,allowedVideoRanges:b}=nf(t,n);for(let t=s.length;t--;){const r=e[s[t]];d||(d=r.channels[2]>0),h=Math.min(h,r.minHeight),f=Math.min(f,r.minFramerate),p=Math.min(p,r.minBitrate),b.filter(e=>r.videoRanges[e]>0).length>0&&(u=!0)}h=nu(h)?h:0,f=nu(f)?f:0;const E=Math.max(1080,h),w=Math.max(30,f);p=nu(p)?p:r,r=Math.max(p,r),u||(t=void 0);const S=s.length>1;return{codecSet:s.reduce((t,i)=>{const n=e[i];if(i===t)return t;if(v=u?b.filter(e=>n.videoRanges[e]>0):[],S){if(n.minBitrate>r)return af(i,`min bitrate of ${n.minBitrate} > current estimate of ${r}`),t;if(!n.hasDefaultAudio)return af(i,"no renditions with default or auto-select sound found"),t;if(o&&i.indexOf(o.substring(0,4))%5!=0)return af(i,`audio codec preference "${o}" not found`),t;if(a&&!c){if(!n.channels[a])return af(i,`no renditions with ${a} channel sound found (channels options: ${Object.keys(n.channels)})`),t}else if((!o||c)&&d&&0===n.channels[2])return af(i,"no renditions with stereo sound found"),t;if(n.minHeight>E)return af(i,`min resolution of ${n.minHeight} > maximum of ${E}`),t;if(n.minFramerate>w)return af(i,`min framerate of ${n.minFramerate} > maximum of ${w}`),t;if(!v.some(e=>n.videoRanges[e]>0))return af(i,`no variants with VIDEO-RANGE of ${sf(v)} found`),t;if(l&&i.indexOf(l.substring(0,4))%5!=0)return af(i,`video codec preference "${l}" not found`),t;if(n.maxScore<g)return af(i,`max score of ${n.maxScore} < selected max of ${g}`),t}return t&&(Dh(i)>=Dh(t)||n.fragmentError>e[t].fragmentError)?t:(m=n.minIndex,g=n.maxScore,i)},void 0),videoRanges:v,preferHDR:y,minFramerate:f,minBitrate:p,minIndex:m}}(i,w,e,T,x),{codecSet:s,videoRanges:a,minFramerate:o,minBitrate:l,minIndex:c,preferHDR:d}=n;k=c,E=s,w=d?a[a.length-1]:a[0],S=o,e=Math.max(e,l),this.log(`picked start tier ${sf(n)}`)}else E=null==v?void 0:v.codecSet,w=null==v?void 0:v.videoRange;const I=h?h.duration:u?u.duration:0,L=this.bwEstimator.getEstimateTTFB()/1e3,R=[];for(let o=r;o>=t;o--){var P;const t=f[o],u=o>d;if(!t)continue;if(g.useMediaCapabilities&&!t.supportedResult&&!t.supportedPromise){const r=navigator.mediaCapabilities;"function"==typeof(null==r?void 0:r.decodingInfo)&&Hh(t,A,w,S,e,T)?(t.supportedPromise=Vh(t,A,r,this.supportedCache),t.supportedPromise.then(e=>{if(!this.hls)return;t.supportedResult=e;const r=this.hls.levels,i=r.indexOf(t);e.error?this.warn(`MediaCapabilities decodingInfo error: "${e.error}" for level ${i} ${sf(e)}`):e.supported?e.decodingInfoResults.some(e=>!1===e.smooth||!1===e.powerEfficient)&&this.log(`MediaCapabilities decodingInfo for level ${i} not smooth or powerEfficient: ${sf(e)}`):(this.warn(`Unsupported MediaCapabilities decodingInfo result for level ${i} ${sf(e)}`),i>-1&&r.length>1&&(this.log(`Removing unsupported level ${i}`),this.hls.removeLevel(i),-1===this.hls.loadLevel&&(this.hls.nextLoadLevel=0)))}).catch(e=>{this.warn(`Error handling MediaCapabilities decodingInfo: ${e}`)})):t.supportedResult=Gh}if((E&&t.codecSet!==E||w&&t.videoRange!==w||u&&S>t.frameRate||!u&&S>0&&S<t.frameRate||null!=(P=t.supportedResult)&&null!=(P=P.decodingInfoResults)&&P.some(e=>!1===e.smooth))&&(!b||o!==k)){R.push(o);continue}const p=t.details,v=(h?null==p?void 0:p.partTarget:null==p?void 0:p.averagetargetduration)||I;let x;x=u?a*e:s*e;const C=I&&i>=2*I&&0===n?t.averageBitrate:t.maxBitrate,D=this.getTimeToLoadFrag(L,x,C*v,void 0===p);if(x>=C&&(o===c||0===t.loadError&&0===t.fragmentError)&&(D<=L||!nu(D)||y&&!this.bitrateTestDelay||D<l)){const e=this.forcedAutoLevel;return o===m||-1!==e&&e===m||(R.length&&this.trace(`Skipped level(s) ${R.join(",")} of ${r} max with CODECS and VIDEO-RANGE:"${f[R[0]].codecs}" ${f[R[0]].videoRange}; not compatible with "${E}" ${w}`),this.info(`switch candidate:${d}->${o} adjustedbw(${Math.round(x)})-bitrate=${Math.round(x-C)} ttfb:${L.toFixed(1)} avgDuration:${v.toFixed(1)} maxFetchDuration:${l.toFixed(1)} fetchDuration:${D.toFixed(1)} firstSelection:${b} codecSet:${t.codecSet} videoRange:${t.videoRange} hls.loadLevel:${m}`)),b&&(this.firstSelection=o),o}}return-1}set nextAutoLevel(e){const t=this.deriveNextAutoLevel(e);this._nextAutoLevel!==t&&(this.nextAutoLevelKey="",this._nextAutoLevel=t)}deriveNextAutoLevel(e){const{maxAutoLevel:t,minAutoLevel:r}=this.hls;return Math.min(Math.max(e,r),t)}},bufferController:class extends Tu{constructor(e,t){var r;super("buffer-controller",e.logger),this.hls=void 0,this.fragmentTracker=void 0,this.details=null,this._objectUrl=null,this.operationQueue=null,this.bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.blockedAudioAppend=null,this.lastVideoAppendEnd=0,this.appendSource=void 0,this.transferData=void 0,this.overrides=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.sourceBuffers=[[null,null],[null,null]],this._onEndStreaming=e=>{var t;this.hls&&"open"===(null==(t=this.mediaSource)?void 0:t.readyState)&&this.hls.pauseBuffering()},this._onStartStreaming=e=>{this.hls&&this.hls.resumeBuffering()},this._onMediaSourceOpen=e=>{const{media:t,mediaSource:r}=this;e&&this.log("Media source opened"),t&&r&&(r.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("emptied",this._onMediaEmptied),this.updateDuration(),this.hls.trigger(cu.MEDIA_ATTACHED,{media:t,mediaSource:r}),null!==this.mediaSource&&this.checkPendingTracks())},this._onMediaSourceClose=()=>{this.log("Media source closed")},this._onMediaSourceEnded=()=>{this.log("Media source ended")},this._onMediaEmptied=()=>{const{mediaSrc:e,_objectUrl:t}=this;e!==t&&this.error(`Media element src was set while attaching MediaSource (${t} > ${e})`)},this.hls=e,this.fragmentTracker=t,this.appendSource=(r=Pu(e.config.preferManagedMediaSource),"undefined"!=typeof self&&r===self.ManagedMediaSource),this.initTracks(),this.registerListeners()}hasSourceTypes(){return Object.keys(this.tracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.transferData=this.overrides=void 0,this.operationQueue&&(this.operationQueue.destroy(),this.operationQueue=null),this.hls=this.fragmentTracker=null,this._onMediaSourceOpen=this._onMediaSourceClose=null,this._onMediaSourceEnded=null,this._onStartStreaming=this._onEndStreaming=null}registerListeners(){const{hls:e}=this;e.on(cu.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(cu.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(cu.MANIFEST_LOADING,this.onManifestLoading,this),e.on(cu.MANIFEST_PARSED,this.onManifestParsed,this),e.on(cu.BUFFER_RESET,this.onBufferReset,this),e.on(cu.BUFFER_APPENDING,this.onBufferAppending,this),e.on(cu.BUFFER_CODECS,this.onBufferCodecs,this),e.on(cu.BUFFER_EOS,this.onBufferEos,this),e.on(cu.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(cu.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(cu.FRAG_PARSED,this.onFragParsed,this),e.on(cu.FRAG_CHANGED,this.onFragChanged,this),e.on(cu.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(cu.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(cu.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(cu.MANIFEST_LOADING,this.onManifestLoading,this),e.off(cu.MANIFEST_PARSED,this.onManifestParsed,this),e.off(cu.BUFFER_RESET,this.onBufferReset,this),e.off(cu.BUFFER_APPENDING,this.onBufferAppending,this),e.off(cu.BUFFER_CODECS,this.onBufferCodecs,this),e.off(cu.BUFFER_EOS,this.onBufferEos,this),e.off(cu.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(cu.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(cu.FRAG_PARSED,this.onFragParsed,this),e.off(cu.FRAG_CHANGED,this.onFragChanged,this),e.off(cu.ERROR,this.onError,this)}transferMedia(){const{media:e,mediaSource:t}=this;if(!e)return null;const r={};if(this.operationQueue){const e=this.isUpdating();e||this.operationQueue.removeBlockers();const t=this.isQueued();(e||t)&&this.warn(`Transfering MediaSource with${t?" operations in queue":""}${e?" updating SourceBuffer(s)":""} ${this.operationQueue}`),this.operationQueue.destroy()}const i=this.transferData;return!this.sourceBufferCount&&i&&i.mediaSource===t?Eu(r,i.tracks):this.sourceBuffers.forEach(e=>{const[t]=e;t&&(r[t]=Eu({},this.tracks[t]),this.removeBuffer(t)),e[0]=e[1]=null}),{media:e,mediaSource:t,tracks:r}}initTracks(){this.sourceBuffers=[[null,null],[null,null]],this.tracks={},this.resetQueue(),this.resetAppendErrors(),this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.lastVideoAppendEnd=0}onManifestLoading(){this.bufferCodecEventsTotal=0,this.details=null}onManifestParsed(e,t){var r;let i=2;(t.audio&&!t.video||!t.altAudio)&&(i=1),this.bufferCodecEventsTotal=i,this.log(`${i} bufferCodec event(s) expected.`),null!=(r=this.transferData)&&r.mediaSource&&this.sourceBufferCount&&i&&this.bufferCreated()}onMediaAttaching(e,t){const r=this.media=t.media;this.transferData=this.overrides=void 0;const i=Pu(this.appendSource);if(i){const e=!!t.mediaSource;(e||t.overrides)&&(this.transferData=t,this.overrides=t.overrides);const n=this.mediaSource=t.mediaSource||new i;if(this.assignMediaSource(n),e)this._objectUrl=r.src,this.attachTransferred();else{const e=this._objectUrl=self.URL.createObjectURL(n);if(this.appendSource)try{r.removeAttribute("src");const t=self.ManagedMediaSource;r.disableRemotePlayback=r.disableRemotePlayback||t&&n instanceof t,Sv(r),function(e,t){const r=self.document.createElement("source");r.type="video/mp4",r.src=t,e.appendChild(r)}(r,e),r.load()}catch(t){r.src=e}else r.src=e}r.addEventListener("emptied",this._onMediaEmptied)}}assignMediaSource(e){var t,r;this.log(`${(null==(t=this.transferData)?void 0:t.mediaSource)===e?"transferred":"created"} media source: ${null==(r=e.constructor)?void 0:r.name}`),e.addEventListener("sourceopen",this._onMediaSourceOpen),e.addEventListener("sourceended",this._onMediaSourceEnded),e.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(e.addEventListener("startstreaming",this._onStartStreaming),e.addEventListener("endstreaming",this._onEndStreaming))}attachTransferred(){const e=this.media,t=this.transferData;if(!t||!e)return;const r=this.tracks,i=t.tracks,n=i?Object.keys(i):null,s=n?n.length:0,a=()=>{Promise.resolve().then(()=>{this.media&&this.mediaSourceOpenOrEnded&&this._onMediaSourceOpen()})};if(i&&n&&s){if(!this.tracksReady)return this.hls.config.startFragPrefetch=!0,void this.log("attachTransferred: waiting for SourceBuffer track info");if(this.log(`attachTransferred: (bufferCodecEventsTotal ${this.bufferCodecEventsTotal})\nrequired tracks: ${sf(r,(e,t)=>"initSegment"===e?void 0:t)};\ntransfer tracks: ${sf(i,(e,t)=>"initSegment"===e?void 0:t)}}`),!Cu(i,r)){t.mediaSource=null,t.tracks=void 0;const n=e.currentTime,s=this.details,a=Math.max(n,(null==s?void 0:s.fragments[0].start)||0);return a-n>1?void this.log(`attachTransferred: waiting for playback to reach new tracks start time ${n} -> ${a}`):(this.warn(`attachTransferred: resetting MediaSource for incompatible tracks ("${Object.keys(i)}"->"${Object.keys(r)}") start time: ${a} currentTime: ${n}`),this.onMediaDetaching(cu.MEDIA_DETACHING,{}),this.onMediaAttaching(cu.MEDIA_ATTACHING,t),void(e.currentTime=a))}this.transferData=void 0,n.forEach(e=>{const t=e,r=i[t];if(r){const e=r.buffer;if(e){const i=this.fragmentTracker,n=r.id;if(i.hasFragments(n)||i.hasParts(n)){const r=np.getBuffered(e);i.detectEvictedFragments(t,r,n,null,!0)}const s=Tv(t),a=[t,e];this.sourceBuffers[s]=a,e.updating&&this.operationQueue&&this.operationQueue.prependBlocker(t),this.trackSourceBuffer(t,r)}}}),a(),this.bufferCreated()}else this.log("attachTransferred: MediaSource w/o SourceBuffers"),a()}get mediaSourceOpenOrEnded(){var e;const t=null==(e=this.mediaSource)?void 0:e.readyState;return"open"===t||"ended"===t}onMediaDetaching(e,t){const r=!!t.transferMedia;this.transferData=this.overrides=void 0;const{media:i,mediaSource:n,_objectUrl:s}=this;if(n){if(this.log("media source "+(r?"transferring":"detaching")),r)this.sourceBuffers.forEach(([e])=>{e&&this.removeBuffer(e)}),this.resetQueue();else{if(this.mediaSourceOpenOrEnded){const e="open"===n.readyState;try{const t=n.sourceBuffers;for(let r=t.length;r--;)e&&t[r].abort(),n.removeSourceBuffer(t[r]);e&&n.endOfStream()}catch(e){this.warn(`onMediaDetaching: ${e.message} while calling endOfStream`)}}this.sourceBufferCount&&this.onBufferReset()}n.removeEventListener("sourceopen",this._onMediaSourceOpen),n.removeEventListener("sourceended",this._onMediaSourceEnded),n.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(n.removeEventListener("startstreaming",this._onStartStreaming),n.removeEventListener("endstreaming",this._onEndStreaming)),this.mediaSource=null,this._objectUrl=null}i&&(i.removeEventListener("emptied",this._onMediaEmptied),r||(s&&self.URL.revokeObjectURL(s),this.mediaSrc===s?(i.removeAttribute("src"),this.appendSource&&Sv(i),i.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null),this.hls.trigger(cu.MEDIA_DETACHED,t)}onBufferReset(){this.sourceBuffers.forEach(([e])=>{e&&this.resetBuffer(e)}),this.initTracks()}resetBuffer(e){var t;const r=null==(t=this.tracks[e])?void 0:t.buffer;if(this.removeBuffer(e),r)try{var i;null!=(i=this.mediaSource)&&i.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(r)}catch(t){this.warn(`onBufferReset ${e}`,t)}delete this.tracks[e]}removeBuffer(e){this.removeBufferListeners(e),this.sourceBuffers[Tv(e)]=[null,null];const t=this.tracks[e];t&&(t.buffer=void 0)}resetQueue(){this.operationQueue&&this.operationQueue.destroy(),this.operationQueue=new yv(this.tracks)}onBufferCodecs(e,t){var r;const i=this.tracks,n=Object.keys(t);this.log(`BUFFER_CODECS: "${n}" (current SB count ${this.sourceBufferCount})`);const s="audiovideo"in t&&(i.audio||i.video)||i.audiovideo&&("audio"in t||"video"in t),a=!s&&this.sourceBufferCount&&this.media&&n.some(e=>!i[e]);s||a?this.warn(`Unsupported transition between "${Object.keys(i)}" and "${n}" SourceBuffers`):(n.forEach(e=>{var r,n;const s=t[e],{id:a,codec:o,levelCodec:l,container:c,metadata:d,supplemental:u}=s;let h=i[e];const f=null==(r=this.transferData)||null==(r=r.tracks)?void 0:r[e],p=null!=f&&f.buffer?f:h,m=(null==p?void 0:p.pendingCodec)||(null==p?void 0:p.codec),g=null==p?void 0:p.levelCodec;h||(h=i[e]={buffer:void 0,listeners:[],codec:o,supplemental:u,container:c,levelCodec:l,metadata:d,id:a});const v=Nh(m,g),y=null==v?void 0:v.replace(bv,"$1");let b=Nh(o,l);const E=null==(n=b)?void 0:n.replace(bv,"$1");b&&v&&y!==E&&("audio"===e.slice(0,5)&&(b=Mh(b,this.appendSource)),this.log(`switching codec ${m} to ${b}`),b!==(h.pendingCodec||h.codec)&&(h.pendingCodec=b),h.container=c,this.appendChangeType(e,c,b))}),(this.tracksReady||this.sourceBufferCount)&&(t.tracks=this.sourceBufferTracks),this.sourceBufferCount||(this.bufferCodecEventsTotal>1&&!this.tracks.video&&!t.video&&"main"===(null==(r=t.audio)?void 0:r.id)&&(this.log("Main audio-only"),this.bufferCodecEventsTotal=1),this.mediaSourceOpenOrEnded&&this.checkPendingTracks()))}get sourceBufferTracks(){return Object.keys(this.tracks).reduce((e,t)=>{const r=this.tracks[t];return e[t]={id:r.id,container:r.container,codec:r.codec,levelCodec:r.levelCodec},e},{})}appendChangeType(e,t,r){const i=`${t};codecs=${r}`,n={label:`change-type=${i}`,execute:()=>{const n=this.tracks[e];if(n){const s=n.buffer;null!=s&&s.changeType&&(this.log(`changing ${e} sourceBuffer type to ${i}`),s.changeType(i),n.codec=r,n.container=t)}this.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:t=>{this.warn(`Failed to change ${e} SourceBuffer type`,t)}};this.append(n,e,this.isPending(this.tracks[e]))}blockAudio(e){var t;const r=e.start,i=r+.05*e.duration;if(!0===(null==(t=this.fragmentTracker.getAppendedFrag(r,pu))?void 0:t.gap))return;const n={label:"block-audio",execute:()=>{var e;const t=this.tracks.video;(this.lastVideoAppendEnd>i||null!=t&&t.buffer&&np.isBuffered(t.buffer,i)||!0===(null==(e=this.fragmentTracker.getAppendedFrag(i,pu))?void 0:e.gap))&&(this.blockedAudioAppend=null,this.shiftAndExecuteNext("audio"))},onStart:()=>{},onComplete:()=>{},onError:e=>{this.warn("Error executing block-audio operation",e)}};this.blockedAudioAppend={op:n,frag:e},this.append(n,"audio",!0)}unblockAudio(){const{blockedAudioAppend:e,operationQueue:t}=this;e&&t&&(this.blockedAudioAppend=null,t.unblockAudio(e.op))}onBufferAppending(e,t){const{tracks:r}=this,{data:i,type:n,parent:s,frag:a,part:o,chunkMeta:l,offset:c}=t,d=l.buffering[n],{sn:u,cc:h}=a,f=self.performance.now();d.start=f;const p=a.stats.buffering,m=o?o.stats.buffering:null;0===p.start&&(p.start=f),m&&0===m.start&&(m.start=f);const g=r.audio;let v=!1;"audio"===n&&"audio/mpeg"===(null==g?void 0:g.container)&&(v=!this.lastMpegAudioChunk||1===l.id||this.lastMpegAudioChunk.sn!==l.sn,this.lastMpegAudioChunk=l);const y=r.video,b=null==y?void 0:y.buffer;if(b&&"initSegment"!==u){const e=o||a,t=this.blockedAudioAppend;if("audio"!==n||"main"===s||this.blockedAudioAppend||y.ending||y.ended){if("video"===n){const r=e.end;if(t){const e=t.frag.start;(r>e||r<this.lastVideoAppendEnd||np.isBuffered(b,e))&&this.unblockAudio()}this.lastVideoAppendEnd=r}}else{const t=e.start+.05*e.duration,r=b.buffered,i=this.currentOp("video");r.length||i?!i&&!np.isBuffered(b,t)&&this.lastVideoAppendEnd<t&&this.blockAudio(e):this.blockAudio(e)}}const E=(o||a).start,w={label:`append-${n}`,execute:()=>{var e;d.executeStart=self.performance.now();const t=null==(e=this.tracks[n])?void 0:e.buffer;t&&(v?this.updateTimestampOffset(t,E,.1,n,u,h):void 0!==c&&nu(c)&&this.updateTimestampOffset(t,c,1e-6,n,u,h)),this.appendExecutor(i,n)},onStart:()=>{},onComplete:()=>{const e=self.performance.now();d.executeEnd=d.end=e,0===p.first&&(p.first=e),m&&0===m.first&&(m.first=e);const t={};this.sourceBuffers.forEach(([e,r])=>{e&&(t[e]=np.getBuffered(r))}),this.appendErrors[n]=0,"audio"===n||"video"===n?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger(cu.BUFFER_APPENDED,{type:n,frag:a,part:o,chunkMeta:l,parent:a.type,timeRanges:t})},onError:e=>{var t;const r={type:ou.MEDIA_ERROR,parent:a.type,details:lu.BUFFER_APPEND_ERROR,sourceBufferName:n,frag:a,part:o,chunkMeta:l,error:e,err:e,fatal:!1},i=null==(t=this.media)?void 0:t.error;if(e.code===DOMException.QUOTA_EXCEEDED_ERR||"QuotaExceededError"==e.name||"quota"in e)r.details=lu.BUFFER_FULL_ERROR;else if(e.code===DOMException.INVALID_STATE_ERR&&this.mediaSourceOpenOrEnded&&!i)r.errorAction=Mf(!0);else if(e.name===Ev&&0===this.sourceBufferCount)r.errorAction=Mf(!0);else{const e=++this.appendErrors[n];this.warn(`Failed ${e}/${this.hls.config.appendErrorMaxRetry} times to append segment in "${n}" sourceBuffer (${i||"no media error"})`),(e>=this.hls.config.appendErrorMaxRetry||i)&&(r.fatal=!0)}this.hls.trigger(cu.ERROR,r)}};this.log(`queuing "${n}" append sn: ${u}${o?" p: "+o.index:""} of ${a.type===pu?"level":"track"} ${a.level} cc: ${h}`),this.append(w,n,this.isPending(this.tracks[n]))}getFlushOp(e,t,r){return this.log(`queuing "${e}" remove ${t}-${r}`),{label:"remove",execute:()=>{this.removeExecutor(e,t,r)},onStart:()=>{},onComplete:()=>{this.hls.trigger(cu.BUFFER_FLUSHED,{type:e})},onError:i=>{this.warn(`Failed to remove ${t}-${r} from "${e}" SourceBuffer`,i)}}}onBufferFlushing(e,t){const{type:r,startOffset:i,endOffset:n}=t;r?this.append(this.getFlushOp(r,i,n),r):this.sourceBuffers.forEach(([e])=>{e&&this.append(this.getFlushOp(e,i,n),e)})}onFragParsed(e,t){const{frag:r,part:i}=t,n=[],s=i?i.elementaryStreams:r.elementaryStreams;s[Yu]?n.push("audiovideo"):(s[Vu]&&n.push("audio"),s[Wu]&&n.push("video"));0===n.length&&this.warn(`Fragments must have at least one ElementaryStreamType set. type: ${r.type} level: ${r.level} sn: ${r.sn}`),this.blockBuffers(()=>{const e=self.performance.now();r.stats.buffering.end=e,i&&(i.stats.buffering.end=e);const t=i?i.stats:r.stats;this.hls.trigger(cu.FRAG_BUFFERED,{frag:r,part:i,stats:t,id:r.type})},n).catch(e=>{this.warn(`Fragment buffered callback ${e}`),this.stepOperationQueue(this.sourceBufferTypes)})}onFragChanged(e,t){this.trimBuffers()}get bufferedToEnd(){return this.sourceBufferCount>0&&!this.sourceBuffers.some(([e])=>{if(e){const t=this.tracks[e];if(t)return!t.ended||t.ending}return!1})}onBufferEos(e,t){var r;this.sourceBuffers.forEach(([e])=>{if(e){const r=this.tracks[e];t.type&&t.type!==e||(r.ending=!0,r.ended||(r.ended=!0,this.log(`${e} buffer reached EOS`)))}});const i=!1!==(null==(r=this.overrides)?void 0:r.endOfStream);this.sourceBufferCount>0&&!this.sourceBuffers.some(([e])=>{var t;return e&&!(null!=(t=this.tracks[e])&&t.ended)})?i?(this.log("Queueing EOS"),this.blockUntilOpen(()=>{this.tracksEnded();const{mediaSource:e}=this;e&&"open"===e.readyState?(this.log("Calling mediaSource.endOfStream()"),e.endOfStream(),this.hls.trigger(cu.BUFFERED_TO_END,void 0)):e&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${e.readyState}`)})):(this.tracksEnded(),this.hls.trigger(cu.BUFFERED_TO_END,void 0)):"video"===t.type&&this.unblockAudio()}tracksEnded(){this.sourceBuffers.forEach(([e])=>{if(null!==e){const t=this.tracks[e];t&&(t.ending=!1)}})}onLevelUpdated(e,{details:t}){t.fragments.length&&(this.details=t,this.updateDuration())}updateDuration(){this.blockUntilOpen(()=>{const e=this.getDurationAndRange();e&&this.updateMediaSource(e)})}onError(e,t){if(t.details===lu.BUFFER_APPEND_ERROR&&t.frag){var r;const e=null==(r=t.errorAction)?void 0:r.nextAutoLevel;nu(e)&&e!==t.frag.level&&this.resetAppendErrors()}}resetAppendErrors(){this.appendErrors={audio:0,video:0,audiovideo:0}}trimBuffers(){const{hls:e,details:t,media:r}=this;if(!r||null===t)return;if(!this.sourceBufferCount)return;const i=e.config,n=r.currentTime,s=t.levelTargetDuration,a=t.live&&null!==i.liveBackBufferLength?i.liveBackBufferLength:i.backBufferLength;if(nu(a)&&a>=0){const e=Math.max(a,s),t=Math.floor(n/s)*s-e;this.flushBackBuffer(n,s,t)}const o=i.frontBufferFlushThreshold;if(nu(o)&&o>0){const e=Math.max(i.maxBufferLength,o),t=Math.max(e,s),r=Math.floor(n/s)*s+t;this.flushFrontBuffer(n,s,r)}}flushBackBuffer(e,t,r){this.sourceBuffers.forEach(([e,t])=>{if(t){const n=np.getBuffered(t);if(n.length>0&&r>n.start(0)){var i;this.hls.trigger(cu.BACK_BUFFER_REACHED,{bufferEnd:r});const t=this.tracks[e];if(null!=(i=this.details)&&i.live)this.hls.trigger(cu.LIVE_BACK_BUFFER_REACHED,{bufferEnd:r});else if(null!=t&&t.ended)return void this.log(`Cannot flush ${e} back buffer while SourceBuffer is in ended state`);this.hls.trigger(cu.BUFFER_FLUSHING,{startOffset:0,endOffset:r,type:e})}}})}flushFrontBuffer(e,t,r){this.sourceBuffers.forEach(([t,i])=>{if(i){const n=np.getBuffered(i),s=n.length;if(s<2)return;const a=n.start(s-1),o=n.end(s-1);if(r>a||e>=a&&e<=o)return;this.hls.trigger(cu.BUFFER_FLUSHING,{startOffset:a,endOffset:1/0,type:t})}})}getDurationAndRange(){var e;const{details:t,mediaSource:r}=this;if(!t||!this.media||"open"!==(null==r?void 0:r.readyState))return null;const i=t.edge;if(t.live&&this.hls.config.liveDurationInfinity){if(t.fragments.length&&r.setLiveSeekableRange){const e=Math.max(0,t.fragmentStart);return{duration:1/0,start:e,end:Math.max(e,i)}}return{duration:1/0}}const n=null==(e=this.overrides)?void 0:e.duration;if(n)return nu(n)?{duration:n}:null;const s=this.media.duration;return i>(nu(r.duration)?r.duration:0)&&i>s||!nu(s)?{duration:i}:null}updateMediaSource({duration:e,start:t,end:r}){const i=this.mediaSource;this.media&&i&&"open"===i.readyState&&(i.duration!==e&&(nu(e)&&this.log(`Updating MediaSource duration to ${e.toFixed(3)}`),i.duration=e),void 0!==t&&void 0!==r&&(this.log(`MediaSource duration is set to ${i.duration}. Setting seekable range to ${t}-${r}.`),i.setLiveSeekableRange(t,r)))}get tracksReady(){const e=this.pendingTrackCount;return e>0&&(e>=this.bufferCodecEventsTotal||this.isPending(this.tracks.audiovideo))}checkPendingTracks(){const{bufferCodecEventsTotal:e,pendingTrackCount:t,tracks:r}=this;if(this.log(`checkPendingTracks (pending: ${t} codec events expected: ${e}) ${sf(r)}`),this.tracksReady){var i;const e=null==(i=this.transferData)?void 0:i.tracks;e&&Object.keys(e).length?this.attachTransferred():this.createSourceBuffers()}}bufferCreated(){if(this.sourceBufferCount){const e={};this.sourceBuffers.forEach(([t,r])=>{if(t){const i=this.tracks[t];e[t]={buffer:r,container:i.container,codec:i.codec,supplemental:i.supplemental,levelCodec:i.levelCodec,id:i.id,metadata:i.metadata}}}),this.hls.trigger(cu.BUFFER_CREATED,{tracks:e}),this.log(`SourceBuffers created. Running queue: ${this.operationQueue}`),this.sourceBuffers.forEach(([e])=>{this.executeNext(e)})}else{const e=new Error("could not create source buffer for media codec(s)");this.hls.trigger(cu.ERROR,{type:ou.MEDIA_ERROR,details:lu.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:e,reason:e.message})}}createSourceBuffers(){const{tracks:e,sourceBuffers:t,mediaSource:r}=this;if(!r)throw new Error("createSourceBuffers called when mediaSource was null");for(const n in e){const s=n,a=e[s];if(this.isPending(a)){const e=this.getTrackCodec(a,s),n=`${a.container};codecs=${e}`;a.codec=e,this.log(`creating sourceBuffer(${n})${this.currentOp(s)?" Queued":""} ${sf(a)}`);try{const e=r.addSourceBuffer(n),i=Tv(s),o=[s,e];t[i]=o,a.buffer=e}catch(e){var i;return this.error(`error while trying to add sourceBuffer: ${e.message}`),this.shiftAndExecuteNext(s),null==(i=this.operationQueue)||i.removeBlockers(),delete this.tracks[s],void this.hls.trigger(cu.ERROR,{type:ou.MEDIA_ERROR,details:lu.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:e,sourceBufferName:s,mimeType:n,parent:a.id})}this.trackSourceBuffer(s,a)}}this.bufferCreated()}getTrackCodec(e,t){const r=e.supplemental;let i=e.codec;r&&("video"===t||"audiovideo"===t)&&Lh(r,"video")&&(i=function(e,t){const r=[];if(e){const t=e.split(",");for(let e=0;e<t.length;e++)Ih(t[e],"video")||r.push(t[e])}return t&&r.push(t),r.join(",")}(i,r));const n=Nh(i,e.levelCodec);return n?"audio"===t.slice(0,5)?Mh(n,this.appendSource):n:""}trackSourceBuffer(e,t){const r=t.buffer;if(!r)return;const i=this.getTrackCodec(t,e);this.tracks[e]={buffer:r,codec:i,container:t.container,levelCodec:t.levelCodec,supplemental:t.supplemental,metadata:t.metadata,id:t.id,listeners:[]},this.removeBufferListeners(e),this.addBufferListener(e,"updatestart",this.onSBUpdateStart),this.addBufferListener(e,"updateend",this.onSBUpdateEnd),this.addBufferListener(e,"error",this.onSBUpdateError),this.appendSource&&this.addBufferListener(e,"bufferedchange",(e,t)=>{const r=t.removedRanges;null!=r&&r.length&&this.hls.trigger(cu.BUFFER_FLUSHED,{type:e})})}get mediaSrc(){var e,t;const r=(null==(e=this.media)||null==(t=e.querySelector)?void 0:t.call(e,"source"))||this.media;return null==r?void 0:r.src}onSBUpdateStart(e){const t=this.currentOp(e);t&&t.onStart()}onSBUpdateEnd(e){var t;if("closed"===(null==(t=this.mediaSource)?void 0:t.readyState))return void this.resetBuffer(e);const r=this.currentOp(e);r&&(r.onComplete(),this.shiftAndExecuteNext(e))}onSBUpdateError(e,t){var r;const i=new Error(`${e} SourceBuffer error. MediaSource readyState: ${null==(r=this.mediaSource)?void 0:r.readyState}`);this.error(`${i}`,t),this.hls.trigger(cu.ERROR,{type:ou.MEDIA_ERROR,details:lu.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:i,fatal:!1});const n=this.currentOp(e);n&&n.onError(i)}updateTimestampOffset(e,t,r,i,n,s){const a=t-e.timestampOffset;Math.abs(a)>=r&&(this.log(`Updating ${i} SourceBuffer timestampOffset to ${t} (sn: ${n} cc: ${s})`),e.timestampOffset=t)}removeExecutor(e,t,r){const{media:i,mediaSource:n}=this,s=this.tracks[e],a=null==s?void 0:s.buffer;if(!i||!n||!a)return this.warn(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`),void this.shiftAndExecuteNext(e);const o=nu(i.duration)?i.duration:1/0,l=nu(n.duration)?n.duration:1/0,c=Math.max(0,t),d=Math.min(r,o,l);d>c&&(!s.ending||s.ended)?(s.ended=!1,this.log(`Removing [${c},${d}] from the ${e} SourceBuffer`),a.remove(c,d)):this.shiftAndExecuteNext(e)}appendExecutor(e,t){const r=this.tracks[t],i=null==r?void 0:r.buffer;if(!i)throw new wv(`Attempting to append to the ${t} SourceBuffer, but it does not exist`);r.ending=!1,r.ended=!1,i.appendBuffer(e)}blockUntilOpen(e){if(this.isUpdating()||this.isQueued())this.blockBuffers(e).catch(e=>{this.warn(`SourceBuffer blocked callback ${e}`),this.stepOperationQueue(this.sourceBufferTypes)});else try{e()}catch(e){this.warn(`Callback run without blocking ${this.operationQueue} ${e}`)}}isUpdating(){return this.sourceBuffers.some(([e,t])=>e&&t.updating)}isQueued(){return this.sourceBuffers.some(([e])=>e&&!!this.currentOp(e))}isPending(e){return!!e&&!e.buffer}blockBuffers(e,t=this.sourceBufferTypes){if(!t.length)return this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);const{operationQueue:r}=this,i=t.map(e=>this.appendBlocker(e));return t.length>1&&!!this.blockedAudioAppend&&this.unblockAudio(),Promise.all(i).then(t=>{r===this.operationQueue&&(e(),this.stepOperationQueue(this.sourceBufferTypes))})}stepOperationQueue(e){e.forEach(e=>{var t;const r=null==(t=this.tracks[e])?void 0:t.buffer;r&&!r.updating&&this.shiftAndExecuteNext(e)})}append(e,t,r){this.operationQueue&&this.operationQueue.append(e,t,r)}appendBlocker(e){if(this.operationQueue)return this.operationQueue.appendBlocker(e)}currentOp(e){return this.operationQueue?this.operationQueue.current(e):null}executeNext(e){e&&this.operationQueue&&this.operationQueue.executeNext(e)}shiftAndExecuteNext(e){this.operationQueue&&this.operationQueue.shiftAndExecuteNext(e)}get pendingTrackCount(){return Object.keys(this.tracks).reduce((e,t)=>e+(this.isPending(this.tracks[t])?1:0),0)}get sourceBufferCount(){return this.sourceBuffers.reduce((e,[t])=>e+(t?1:0),0)}get sourceBufferTypes(){return this.sourceBuffers.map(([e])=>e).filter(e=>!!e)}addBufferListener(e,t,r){const i=this.tracks[e];if(!i)return;const n=i.buffer;if(!n)return;const s=r.bind(this,e);i.listeners.push({event:t,listener:s}),n.addEventListener(t,s)}removeBufferListeners(e){const t=this.tracks[e];if(!t)return;const r=t.buffer;r&&(t.listeners.forEach(e=>{r.removeEventListener(e.event,e.listener)}),t.listeners.length=0)}},capLevelController:xv,errorController:class extends Tu{constructor(e){super("error-controller",e.logger),this.hls=void 0,this.playlistError=0,this.hls=e,this.registerListeners()}registerListeners(){const e=this.hls;e.on(cu.ERROR,this.onError,this),e.on(cu.MANIFEST_LOADING,this.onManifestLoading,this),e.on(cu.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const e=this.hls;e&&(e.off(cu.ERROR,this.onError,this),e.off(cu.ERROR,this.onErrorOut,this),e.off(cu.MANIFEST_LOADING,this.onManifestLoading,this),e.off(cu.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null}startLoad(e){}stopLoad(){this.playlistError=0}getVariantLevelIndex(e){return(null==e?void 0:e.type)===pu?e.level:this.getVariantIndex()}getVariantIndex(){var e;const t=this.hls,r=t.currentLevel;return null!=(e=t.loadLevelObj)&&e.details||-1===r?t.loadLevel:r}variantHasKey(e,t){if(e){var r;if(null!=(r=e.details)&&r.hasKey(t))return!0;const i=e.audioGroups;if(i){return this.hls.allAudioTracks.filter(e=>i.indexOf(e.groupId)>=0).some(e=>{var r;return null==(r=e.details)?void 0:r.hasKey(t)})}}return!1}onManifestLoading(){this.playlistError=0}onLevelUpdated(){this.playlistError=0}onError(e,t){var r;if(t.fatal)return;const i=this.hls,n=t.context;switch(t.details){case lu.FRAG_LOAD_ERROR:case lu.FRAG_LOAD_TIMEOUT:case lu.KEY_LOAD_ERROR:case lu.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case lu.FRAG_PARSING_ERROR:if(null!=(r=t.frag)&&r.gap)return void(t.errorAction=Mf());case lu.FRAG_GAP:case lu.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=Lf);case lu.LEVEL_EMPTY_ERROR:case lu.LEVEL_PARSING_ERROR:{var s;const e=t.parent===pu?t.level:i.loadLevel;t.details===lu.LEVEL_EMPTY_ERROR&&null!=(s=t.context)&&null!=(s=s.levelDetails)&&s.live?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,e):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,e))}return;case lu.LEVEL_LOAD_ERROR:case lu.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==n?void 0:n.level)&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.level)));case lu.AUDIO_TRACK_LOAD_ERROR:case lu.AUDIO_TRACK_LOAD_TIMEOUT:case lu.SUBTITLE_LOAD_ERROR:case lu.SUBTITLE_TRACK_LOAD_TIMEOUT:if(n){const e=i.loadLevelObj;if(e&&(n.type===hu&&e.hasAudioGroup(n.groupId)||n.type===fu&&e.hasSubtitleGroup(n.groupId)))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,i.loadLevel),t.errorAction.action=Lf,void(t.errorAction.flags=Df)}return;case lu.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:return void(t.errorAction={action:Lf,flags:_f});case lu.KEY_SYSTEM_SESSION_UPDATE_FAILED:case lu.KEY_SYSTEM_STATUS_INTERNAL_ERROR:case lu.KEY_SYSTEM_NO_SESSION:return void(t.errorAction={action:Lf,flags:Of});case lu.BUFFER_ADD_CODEC_ERROR:case lu.REMUX_ALLOC_ERROR:case lu.BUFFER_APPEND_ERROR:var a;if(!t.errorAction)t.errorAction=this.getLevelSwitchAction(t,null!=(a=t.level)?a:i.loadLevel);return;case lu.INTERNAL_EXCEPTION:case lu.BUFFER_APPENDING_ERROR:case lu.BUFFER_FULL_ERROR:case lu.LEVEL_SWITCH_ERROR:case lu.BUFFER_STALLED_ERROR:case lu.BUFFER_SEEK_OVER_HOLE:case lu.BUFFER_NUDGE_ON_STALL:return void(t.errorAction=Mf())}t.type===ou.KEY_SYSTEM_ERROR&&(t.levelRetry=!1,t.errorAction=Mf())}getPlaylistRetryOrSwitchAction(e,t){const r=Sf(this.hls.config.playlistLoadPolicy,e),i=this.playlistError++;if(Af(r,i,bf(e),e.response))return{action:Pf,flags:Cf,retryConfig:r,retryCount:i};const n=this.getLevelSwitchAction(e,t);return r&&(n.retryConfig=r,n.retryCount=i),n}getFragRetryOrSwitchAction(e){const t=this.hls,r=this.getVariantLevelIndex(e.frag),i=t.levels[r],{fragLoadPolicy:n,keyLoadPolicy:s}=t.config,a=Sf(Ef(e)?s:n,e),o=t.levels.reduce((e,t)=>e+t.fragmentError,0);if(i&&(e.details!==lu.FRAG_GAP&&i.fragmentError++,!wf(e))){if(Af(a,o,bf(e),e.response))return{action:Pf,flags:Cf,retryConfig:a,retryCount:o}}const l=this.getLevelSwitchAction(e,r);return a&&(l.retryConfig=a,l.retryCount=o),l}getLevelSwitchAction(e,t){const r=this.hls;null==t&&(t=r.loadLevel);const i=this.hls.levels[t];if(i){var n,s;const t=e.details;i.loadError++,t===lu.BUFFER_APPEND_ERROR&&i.fragmentError++;let l=-1;const{levels:c,loadLevel:d,minAutoLevel:u,maxAutoLevel:h}=r;r.autoLevelEnabled||r.config.preserveManualLevelOnError||(r.loadLevel=-1);const f=null==(n=e.frag)?void 0:n.type,p=(f===mu&&t===lu.FRAG_PARSING_ERROR||"audio"===e.sourceBufferName&&(t===lu.BUFFER_ADD_CODEC_ERROR||t===lu.BUFFER_APPEND_ERROR))&&c.some(({audioCodec:e})=>i.audioCodec!==e),m="video"===e.sourceBufferName&&(t===lu.BUFFER_ADD_CODEC_ERROR||t===lu.BUFFER_APPEND_ERROR)&&c.some(({codecSet:e,audioCodec:t})=>i.codecSet!==e&&i.audioCodec===t),{type:g,groupId:v}=null!=(s=e.context)?s:{};for(let r=c.length;r--;){const n=(r+d)%c.length;if(n!==d&&n>=u&&n<=h&&0===c[n].loadError){var a,o;const r=c[n];if(t===lu.FRAG_GAP&&f===pu&&e.frag){const t=c[n].details;if(t){const r=mf(e.frag,t.fragments,e.frag.start);if(null!=r&&r.gap)continue}}else{if(g===hu&&r.hasAudioGroup(v)||g===fu&&r.hasSubtitleGroup(v))continue;if(f===mu&&null!=(a=i.audioGroups)&&a.some(e=>r.hasAudioGroup(e))||f===gu&&null!=(o=i.subtitleGroups)&&o.some(e=>r.hasSubtitleGroup(e))||p&&i.audioCodec===r.audioCodec||m&&i.codecSet===r.codecSet||!p&&i.codecSet!==r.codecSet)continue}l=n;break}}if(l>-1&&r.loadLevel!==l)return e.levelRetry=!0,this.playlistError=0,{action:Lf,flags:Cf,nextAutoLevel:l}}return{action:Lf,flags:Df}}onErrorOut(e,t){var r;switch(null==(r=t.errorAction)?void 0:r.action){case If:break;case Lf:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===lu.FRAG_GAP?/MediaSource readyState: ended/.test(t.error.message)&&(this.warn(`MediaSource ended after "${t.sourceBufferName}" sourceBuffer append error. Attempting to recover from media error.`),this.hls.recoverMediaError()):t.fatal=!0}t.fatal&&this.hls.stopLoad()}sendAlternateToPenaltyBox(e){const t=this.hls,r=e.errorAction;if(!r)return;const{flags:i}=r,n=r.nextAutoLevel;switch(i){case Cf:this.switchLevel(e,n);break;case _f:{const i=this.getVariantLevelIndex(e.frag),n=t.levels[i],s=null==n?void 0:n.attrs["HDCP-LEVEL"];if(r.hdcpLevel=s,"NONE"===s)this.warn("HDCP policy resticted output with HDCP-LEVEL=NONE");else if(s){t.maxHdcpLevel=Kh[Kh.indexOf(s)-1],r.resolved=!0,this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}}case Of:{const t=e.decryptdata;if(t){const i=this.hls.levels,n=i.length;for(let r=n;r--;){var s,a;if(this.variantHasKey(i[r],t))this.log(`Banned key found in level ${r} (${i[r].bitrate}bps) or audio group "${null==(s=i[r].audioGroups)?void 0:s.join(",")}" (${null==(a=e.frag)?void 0:a.type} fragment) ${_u(t.keyId||[])}`),i[r].fragmentError++,i[r].loadError++,this.log(`Removing level ${r} with key error (${e.error})`),this.hls.removeLevel(r)}const o=e.frag;if(this.hls.levels.length<n)r.resolved=!0;else if(o&&o.type!==pu){const e=o.decryptdata;e&&!t.matches(e)&&(r.resolved=!0)}}break}}r.resolved||this.switchLevel(e,n)}switchLevel(e,t){if(void 0!==t&&e.errorAction&&(this.warn(`switching to level ${t} after ${e.details}`),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel,e.details===lu.BUFFER_ADD_CODEC_ERROR&&e.mimeType&&"audiovideo"!==e.sourceBufferName)){const t=Uh(e.mimeType),r=this.hls.levels;for(let i=r.length;i--;)r[i][`${e.sourceBufferName}Codec`]===t&&(this.log(`Removing level ${i} for ${e.details} ("${t}" not supported)`),this.hls.removeLevel(i))}}},fpsController:class{constructor(e){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=e,this.registerListeners()}setStreamController(e){this.streamController=e}registerListeners(){this.hls.on(cu.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(cu.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListeners(){this.hls.off(cu.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(cu.MEDIA_DETACHING,this.onMediaDetaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){const r=this.hls.config;if(r.capLevelOnFPSDrop){const e=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=e,e&&"function"==typeof e.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}}onMediaDetaching(){this.media=null}checkFPS(e,t,r){const i=performance.now();if(t){if(this.lastTime){const e=i-this.lastTime,n=r-this.lastDroppedFrames,s=t-this.lastDecodedFrames,a=1e3*n/e,o=this.hls;if(o.trigger(cu.FPS_DROP,{currentDropped:n,currentDecoded:s,totalDroppedFrames:r}),a>0&&n>o.config.fpsDroppedMonitoringThreshold*s){let e=o.currentLevel;o.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+e),e>0&&(-1===o.autoLevelCapping||o.autoLevelCapping>=e)&&(e-=1,o.trigger(cu.FPS_DROP_LEVEL_CAPPING,{level:e,droppedLevel:o.currentLevel}),o.autoLevelCapping=e,this.streamController.nextLevelSwitch())}}this.lastTime=i,this.lastDroppedFrames=r,this.lastDecodedFrames=t}}checkFPSInterval(){const e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){const t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}},stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:Op,requireKeySystemAccessOnStart:!1,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableEmsgKLVMetadata:!1,enableID3MetadataCues:!0,enableInterstitialPlayback:!0,interstitialAppendInPlace:!0,interstitialLiveLookAhead:10,useMediaCapabilities:!0,preserveManualLevelOnError:!1,certLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null}},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},interstitialAssetListLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:3e4,timeoutRetry:{maxNumRetry:0,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:0,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},{cueHandler:zb,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:class extends Nm{constructor(e,t,r){super(e,t,r,"subtitle-stream-controller",gu),this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this.registerListeners()}onHandlerDestroying(){this.unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null}registerListeners(){super.registerListeners();const{hls:e}=this;e.on(cu.LEVEL_LOADED,this.onLevelLoaded,this),e.on(cu.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(cu.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(cu.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(cu.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(cu.BUFFER_FLUSHING,this.onBufferFlushing,this)}unregisterListeners(){super.unregisterListeners();const{hls:e}=this;e.off(cu.LEVEL_LOADED,this.onLevelLoaded,this),e.off(cu.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(cu.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(cu.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(cu.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(cu.BUFFER_FLUSHING,this.onBufferFlushing,this)}startLoad(e,t){this.stopLoad(),this.state=Am,this.setInterval(500),this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}onManifestLoading(){super.onManifestLoading(),this.mainDetails=null}onMediaDetaching(e,t){this.tracksBuffered=[],super.onMediaDetaching(e,t)}onLevelLoaded(e,t){this.mainDetails=t.details}onSubtitleFragProcessed(e,t){const{frag:r,success:i}=t;if(this.fragContextChanged(r)||(qu(r)&&(this.fragPrevious=r),this.state=Am),!i)return;const n=this.tracksBuffered[this.currentTrackId];if(!n)return;let s;const a=r.start;for(let e=0;e<n.length;e++)if(a>=n[e].start&&a<=n[e].end){s=n[e];break}const o=r.start+r.duration;s?s.end=o:(s={start:a,end:o},n.push(s)),this.fragmentTracker.fragBuffered(r),this.fragBufferedComplete(r,null),this.media&&this.tick()}onBufferFlushing(e,t){const{startOffset:r,endOffset:i}=t;if(0===r&&i!==Number.POSITIVE_INFINITY){const e=i-1;if(e<=0)return;t.endOffsetSubtitles=Math.max(0,e),this.tracksBuffered.forEach(t=>{for(let r=0;r<t.length;)if(t[r].end<=e)t.shift();else{if(!(t[r].start<e))break;t[r].start=e,r++}}),this.fragmentTracker.removeFragmentsInRange(r,e,gu)}}onError(e,t){const r=t.frag;(null==r?void 0:r.type)===gu&&(t.details===lu.FRAG_GAP&&this.fragmentTracker.fragBuffered(r,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==xm&&(this.state=Am))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){this.levels&&mv(this.levels,t)?this.levels=t.map(e=>new tf(e)):(this.tracksBuffered=[],this.levels=t.map(e=>{const t=new tf(e);return this.tracksBuffered[t.id]=[],t}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,gu),this.fragPrevious=null,this.mediaBuffer=null)}onSubtitleTrackSwitch(e,t){var r;if(this.currentTrackId=t.id,null==(r=this.levels)||!r.length||-1===this.currentTrackId)return void this.clearInterval();const i=this.levels[this.currentTrackId];null!=i&&i.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,i&&this.state!==xm&&this.setInterval(500)}onSubtitleTrackLoaded(e,t){var r;const{currentTrackId:i,levels:n}=this,{details:s,id:a}=t;if(!n)return void this.warn(`Subtitle tracks were reset while loading level ${a}`);const o=n[a];if(a>=n.length||!o)return;this.log(`Subtitle track ${a} loaded [${s.startSN},${s.endSN}]${s.lastPartSn?`[part-${s.lastPartSn}-${s.lastPartIndex}]`:""},duration:${s.totalduration}`),this.mediaBuffer=this.mediaBufferTimeRanges;let l=0;if(s.live||null!=(r=o.details)&&r.live){if(s.deltaUpdateFailed)return;const e=this.mainDetails;if(!e)return void(this.startFragRequested=!1);const t=e.fragments[0];var c;if(o.details)l=this.alignPlaylists(s,o.details,null==(c=this.levelLastLoaded)?void 0:c.details),0===l&&t&&(l=t.start,lm(s,l));else s.hasProgramDateTime&&e.hasProgramDateTime?(Em(s,e),l=s.fragmentStart):t&&(l=t.start,lm(s,l));e&&!this.startFragRequested&&this.setStartPosition(e,l)}if(o.details=s,this.levelLastLoaded=o,a===i&&(this.hls.trigger(cu.SUBTITLE_TRACK_UPDATED,{details:s,id:a,groupId:t.groupId}),this.tick(),s.live&&!this.fragCurrent&&this.media&&this.state===Am)){mf(null,s.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),o.details=void 0)}}_handleFragmentLoadComplete(e){const{frag:t,payload:r}=e,i=t.decryptdata,n=this.hls;if(!this.fragContextChanged(t)&&r&&r.byteLength>0&&null!=i&&i.key&&i.iv&&bp(i.method)){const e=performance.now();this.decrypter.decrypt(new Uint8Array(r),i.key.buffer,i.iv.buffer,Ep(i.method)).catch(e=>{throw n.trigger(cu.ERROR,{type:ou.MEDIA_ERROR,details:lu.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:t}),e}).then(r=>{const i=performance.now();n.trigger(cu.FRAG_DECRYPTED,{frag:t,payload:r,stats:{tstart:e,tdecrypt:i}})}).catch(e=>{this.warn(`${e.name}: ${e.message}`),this.state=Am})}}doTick(){if(this.media){if(this.state===Am){const{currentTrackId:e,levels:t}=this,r=null==t?void 0:t[e];if(!r||!t.length||!r.details)return;if(this.waitForLive(r))return;const{config:i}=this,n=this.getLoadPosition(),s=np.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],n,i.maxBufferHole),{end:a,len:o}=s,l=r.details;if(o>this.hls.maxBufferLength+l.levelTargetDuration)return;const c=l.fragments,d=c.length,u=l.edge;let h=null;const f=this.fragPrevious;if(a<u){const e=i.maxFragLookUpTolerance,t=a>u-e?0:e;h=mf(f,c,Math.max(c[0].start,a),t),!h&&f&&f.start<c[0].start&&(h=c[0])}else h=c[d-1];if(h=this.filterReplacedPrimary(h,r.details),!h)return;const p=c[h.sn-l.startSN-1];if(p&&p.cc===h.cc&&this.fragmentTracker.getState(p)===Nf&&(h=p),this.fragmentTracker.getState(h)===Nf){const e=this.mapToInitFragWhenRequired(h);e&&this.loadFragment(e,r,a)}}}else this.state=Am}loadFragment(e,t,r){qu(e)?super.loadFragment(e,t,r):this._loadInitSegment(e,t)}get mediaBufferTimeRanges(){return new Vy(this.tracksBuffered[this.currentTrackId]||[])}},subtitleTrackController:class extends pv{constructor(e){super(e,"subtitle-track-controller"),this.media=null,this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.onTextTracksChanged=()=>{if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let e=null;const t=Ry(this.media.textTracks);for(let r=0;r<t.length;r++)if("hidden"===t[r].mode)e=t[r];else if("showing"===t[r].mode){e=t[r];break}const r=this.findTrackForTextTrack(e);this.subtitleTrack!==r&&this.setSubtitleTrack(r)},this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,this.onTextTracksChanged=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes()}registerListeners(){const{hls:e}=this;e.on(cu.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(cu.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(cu.MANIFEST_LOADING,this.onManifestLoading,this),e.on(cu.MANIFEST_PARSED,this.onManifestParsed,this),e.on(cu.LEVEL_LOADING,this.onLevelLoading,this),e.on(cu.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(cu.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(cu.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(cu.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(cu.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(cu.MANIFEST_LOADING,this.onManifestLoading,this),e.off(cu.MANIFEST_PARSED,this.onManifestParsed,this),e.off(cu.LEVEL_LOADING,this.onLevelLoading,this),e.off(cu.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(cu.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(cu.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))}pollTrackChange(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.onTextTracksChanged,e)}onMediaDetaching(e,t){const r=this.media;if(!r)return;const i=!!t.transferMedia;if(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||r.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),this.subtitleTrack=-1,this.media=null,i)return;Ry(r.textTracks).forEach(e=>{Iy(e)})}onManifestLoading(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.subtitleTracks}onSubtitleTrackLoaded(e,t){const{id:r,groupId:i,details:n}=t,s=this.tracksInGroup[r];if(!s||s.groupId!==i)return void this.warn(`Subtitle track with id:${r} and group:${i} not found in active group ${null==s?void 0:s.groupId}`);const a=s.details;s.details=t.details,this.log(`Subtitle track ${r} "${s.name}" lang:${s.lang} group:${i} loaded [${n.startSN}-${n.endSN}]`),r===this.trackId&&this.playlistLoaded(r,t,a)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(!t)return;const r=t.subtitleGroups||null,i=this.groupIds;let n=this.currentTrack;if(!r||(null==i?void 0:i.length)!==(null==r?void 0:r.length)||null!=r&&r.some(e=>-1===(null==i?void 0:i.indexOf(e)))){this.groupIds=r,this.trackId=-1,this.currentTrack=null;const e=this.tracks.filter(e=>!r||-1!==r.indexOf(e.groupId));if(e.length)this.selectDefaultTrack&&!e.some(e=>e.default)&&(this.selectDefaultTrack=!1),e.forEach((e,t)=>{e.id=t});else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=e;const t=this.hls.config.subtitlePreference;if(!n&&t){this.selectDefaultTrack=!1;const r=cf(t,e);if(r>-1)n=e[r];else{const e=cf(t,this.tracks);n=this.tracks[e]}}let i=this.findTrackId(n);-1===i&&n&&(i=this.findTrackId(null));const s={subtitleTracks:e};this.log(`Updating subtitle tracks, ${e.length} track(s) found in "${null==r?void 0:r.join(",")}" group-id`),this.hls.trigger(cu.SUBTITLE_TRACKS_UPDATED,s),-1!==i&&-1===this.trackId&&this.setSubtitleTrack(i)}}findTrackId(e){const t=this.tracksInGroup,r=this.selectDefaultTrack;for(let i=0;i<t.length;i++){const n=t[i];if((!r||n.default)&&(r||e)&&(!e||df(n,e)))return i}if(e){for(let r=0;r<t.length;r++){const i=t[r];if(gv(e.attrs,i.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return r}for(let r=0;r<t.length;r++){const i=t[r];if(gv(e.attrs,i.attrs,["LANGUAGE"]))return r}}return-1}findTrackForTextTrack(e){if(e){const t=this.tracksInGroup;for(let r=0;r<t.length;r++){if(vv(t[r],e))return r}}return-1}onError(e,t){!t.fatal&&t.context&&(t.context.type!==fu||t.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(t.context.groupId)||this.checkRetry(t))}get allSubtitleTracks(){return this.tracks}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(e){this.selectDefaultTrack=!1,this.setSubtitleTrack(e)}setSubtitleOption(e){if(this.hls.config.subtitlePreference=e,e){if(-1===e.id)return this.setSubtitleTrack(-1),null;const t=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,t.length){const r=this.currentTrack;if(r&&df(e,r))return r;const i=cf(e,this.tracksInGroup);if(i>-1){const e=this.tracksInGroup[i];return this.setSubtitleTrack(i),e}if(r)return null;{const r=cf(e,t);if(r>-1)return t[r]}}}return null}loadPlaylist(e){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentTrack)&&this.scheduleLoading(this.currentTrack,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);const r=e.id,i=e.groupId,n=this.getUrlWithDirectives(e.url,t),s=e.details,a=null==s?void 0:s.age;this.log(`Loading subtitle ${r} "${e.name}" lang:${e.lang} group:${i}${void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:""}${a&&s.live?" age "+a.toFixed(1)+(s.type&&" "+s.type||""):""} ${n}`),this.hls.trigger(cu.SUBTITLE_TRACK_LOADING,{url:n,id:r,groupId:i,deliveryDirectives:t||null,track:e})}toggleTrackModes(){const{media:e}=this;if(!e)return;const t=Ry(e.textTracks),r=this.currentTrack;let i;if(r&&(i=t.filter(e=>vv(r,e))[0],i||this.warn(`Unable to find subtitle TextTrack with name "${r.name}" and language "${r.lang}"`)),[].slice.call(t).forEach(e=>{"disabled"!==e.mode&&e!==i&&(e.mode="disabled")}),i){const e=this.subtitleDisplay?"showing":"hidden";i.mode!==e&&(i.mode=e)}}setSubtitleTrack(e){const t=this.tracksInGroup;if(!this.media)return void(this.queuedDefaultTrack=e);if(e<-1||e>=t.length||!nu(e))return void this.warn(`Invalid subtitle track id: ${e}`);this.selectDefaultTrack=!1;const r=this.currentTrack,i=t[e]||null;if(this.trackId=e,this.currentTrack=i,this.toggleTrackModes(),!i)return void this.hls.trigger(cu.SUBTITLE_TRACK_SWITCH,{id:e});const n=!!i.details&&!i.details.live;if(e===this.trackId&&i===r&&n)return;this.log(`Switching to subtitle-track ${e}`+(i?` "${i.name}" lang:${i.lang} group:${i.groupId}`:""));const{id:s,groupId:a="",name:o,type:l,url:c}=i;this.hls.trigger(cu.SUBTITLE_TRACK_SWITCH,{id:s,groupId:a,name:o,type:l,url:c});const d=this.switchParams(i.url,null==r?void 0:r.details,i.details);this.loadPlaylist(d)}},timelineController:class{constructor(e){this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},e.on(cu.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(cu.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(cu.MANIFEST_LOADING,this.onManifestLoading,this),e.on(cu.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(cu.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(cu.FRAG_LOADING,this.onFragLoading,this),e.on(cu.FRAG_LOADED,this.onFragLoaded,this),e.on(cu.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(cu.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(cu.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(cu.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(cu.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:e}=this;e.off(cu.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(cu.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(cu.MANIFEST_LOADING,this.onManifestLoading,this),e.off(cu.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(cu.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(cu.FRAG_LOADING,this.onFragLoading,this),e.off(cu.FRAG_LOADED,this.onFragLoaded,this),e.off(cu.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(cu.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(cu.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(cu.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(cu.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.media=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){const e=new Nb(this,"textTrack1"),t=new Nb(this,"textTrack2"),r=new Nb(this,"textTrack3"),i=new Nb(this,"textTrack4");this.cea608Parser1=new lb(1,e,t),this.cea608Parser2=new lb(3,r,i)}addCues(e,t,r,i,n){let s=!1;for(let e=n.length;e--;){const i=n[e],a=Bb(i[0],i[1],t,r);if(a>=0&&(i[0]=Math.min(i[0],t),i[1]=Math.max(i[1],r),s=!0,a/(r-t)>.5))return}if(s||n.push([t,r]),this.config.renderTextTracksNatively){const n=this.captionsTracks[e];this.Cues.newCue(n,t,r,i)}else{const n=this.Cues.newCue(null,t,r,i);this.hls.trigger(cu.CUES_PARSED,{type:"captions",cues:n,track:e})}}onInitPtsFound(e,{frag:t,id:r,initPTS:i,timescale:n,trackId:s}){const{unparsedVttFrags:a}=this;r===pu&&(this.initPTS[t.cc]={baseTime:i,timescale:n,trackId:s}),a.length&&(this.unparsedVttFrags=[],a.forEach(e=>{this.initPTS[e.frag.cc]?this.onFragLoaded(cu.FRAG_LOADED,e):this.hls.trigger(cu.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e.frag,error:new Error("Subtitle discontinuity domain does not match main")})}))}getExistingTrack(e,t){const{media:r}=this;if(r)for(let i=0;i<r.textTracks.length;i++){const n=r.textTracks[i];if($b(n,{name:e,lang:t,characteristics:"transcribes-spoken-dialog,describes-music-and-sound"}))return n}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(this.captionsTracks[e])return;const{captionsProperties:t,captionsTracks:r,media:i}=this,{label:n,languageCode:s}=t[e],a=this.getExistingTrack(n,s);if(a)r[e]=a,Iy(r[e]),Ay(r[e],i);else{const t=this.createTextTrack("captions",n,s);t&&(t[e]=!0,r[e]=t)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;const t=this.captionsProperties[e];if(!t)return;const r={_id:e,label:t.label,kind:"captions",default:!!t.media&&!!t.media.default,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=r,this.hls.trigger(cu.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[r]})}createTextTrack(e,t,r){const i=this.media;if(i)return i.addTextTrack(e,t,r)}onMediaAttaching(e,t){this.media=t.media,t.mediaSource||this._cleanTracks()}onMediaDetaching(e,t){const r=!!t.transferMedia;if(this.media=null,r)return;const{captionsTracks:i}=this;Object.keys(i).forEach(e=>{Iy(i[e]),delete i[e]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}_cleanTracks(){const{media:e}=this;if(!e)return;const t=e.textTracks;if(t)for(let e=0;e<t.length;e++)Iy(t[e])}onSubtitleTracksUpdated(e,t){const r=t.subtitleTracks||[],i=r.some(e=>e.textCodec===Ab);if(this.config.enableWebVTT||i&&this.config.enableIMSC1){if(mv(this.tracks,r))return void(this.tracks=r);if(this.textTracks=[],this.tracks=r,this.config.renderTextTracksNatively){const e=this.media,t=e?Ry(e.textTracks):null;if(this.tracks.forEach((e,r)=>{let i;if(t){let r=null;for(let i=0;i<t.length;i++)if(t[i]&&$b(t[i],e)){r=t[i],t[i]=null;break}r&&(i=r)}if(i)Iy(i);else{const t=Fb(e);i=this.createTextTrack(t,e.name,e.lang),i&&(i.mode="disabled")}i&&this.textTracks.push(i)}),null!=t&&t.length){const e=t.filter(e=>null!==e).map(e=>e.label);e.length&&this.hls.logger.warn(`Media element contains unused subtitle tracks: ${e.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`)}}else if(this.tracks.length){const e=this.tracks.map(e=>({label:e.name,kind:e.type.toLowerCase(),default:e.default,subtitleTrack:e}));this.hls.trigger(cu.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:e})}}}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(e=>{const t=/(?:CC|SERVICE)([1-4])/.exec(e.instreamId);if(!t)return;const r=`textTrack${t[1]}`,i=this.captionsProperties[r];i&&(i.label=e.name,e.lang&&(i.languageCode=e.lang),i.media=e)})}closedCaptionsForLevel(e){const t=this.hls.levels[e.level];return null==t?void 0:t.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){if(this.enabled&&t.frag.type===pu){var r,i;const{cea608Parser1:e,cea608Parser2:n,lastSn:s}=this,{cc:a,sn:o}=t.frag,l=null!=(r=null==(i=t.part)?void 0:i.index)?r:-1;e&&n&&(o!==s+1||o===s&&l!==this.lastPartIndex+1||a!==this.lastCc)&&(e.reset(),n.reset()),this.lastCc=a,this.lastSn=o,this.lastPartIndex=l}}onFragLoaded(e,t){const{frag:r,payload:i}=t;if(r.type===gu)if(i.byteLength){const e=r.decryptdata,n="stats"in t;if(null==e||!e.encrypted||n){const e=this.tracks[r.level],n=this.vttCCs;n[r.cc]||(n[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),e&&e.textCodec===Ab?this._parseIMSC1(r,i):this._parseVTTs(t)}}else this.hls.trigger(cu.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){const r=this.hls;Rb(t,this.initPTS[e.cc],t=>{this._appendCues(t,e.level),r.trigger(cu.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},t=>{r.logger.log(`Failed to parse IMSC1: ${t}`),r.trigger(cu.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:t})})}_parseVTTs(e){var t;const{frag:r,payload:i}=e,{initPTS:n,unparsedVttFrags:s}=this,a=n.length-1;if(!n[r.cc]&&-1===a)return void s.push(e);const o=this.hls;xb(null!=(t=r.initSegment)&&t.data?vh(r.initSegment.data,new Uint8Array(i)).buffer:i,this.initPTS[r.cc],this.vttCCs,r.cc,r.start,e=>{this._appendCues(e,r.level),o.trigger(cu.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:r})},t=>{const n="Missing initPTS for VTT MPEGTS"===t.message;n?s.push(e):this._fallbackToIMSC1(r,i),o.logger.log(`Failed to parse VTT cue: ${t}`),n&&a>r.cc||o.trigger(cu.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:t})})}_fallbackToIMSC1(e,t){const r=this.tracks[e.level];r.textCodec||Rb(t,this.initPTS[e.cc],()=>{r.textCodec=Ab,this._parseIMSC1(e,t)},()=>{r.textCodec="wvtt"})}_appendCues(e,t){const r=this.hls;if(this.config.renderTextTracksNatively){const r=this.textTracks[t];if(!r||"disabled"===r.mode)return;e.forEach(e=>ky(r,e))}else{const i=this.tracks[t];if(!i)return;const n=i.default?"default":"subtitles"+t;r.trigger(cu.CUES_PARSED,{type:"subtitles",cues:e,track:n})}}onFragDecrypted(e,t){const{frag:r}=t;r.type===gu&&this.onFragLoaded(cu.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){if(!this.enabled||!this.config.enableCEA708Captions)return;const{frag:r,samples:i}=t;if(r.type!==pu||"NONE"!==this.closedCaptionsForLevel(r))for(let e=0;e<i.length;e++){const t=i[e].bytes;if(t){this.cea608Parser1||this.initCea608Parsers();const r=this.extractCea608Data(t);this.cea608Parser1.addData(i[e].pts,r[0]),this.cea608Parser2.addData(i[e].pts,r[1])}}}onBufferFlushing(e,{startOffset:t,endOffset:r,endOffsetSubtitles:i,type:n}){const{media:s}=this;if(s&&!(s.currentTime<r)){if(!n||"video"===n){const{captionsTracks:e}=this;Object.keys(e).forEach(i=>Ly(e[i],t,r))}if(this.config.renderTextTracksNatively&&0===t&&void 0!==i){const{textTracks:e}=this;Object.keys(e).forEach(r=>Ly(e[r],t,i))}}}extractCea608Data(e){const t=[[],[]],r=31&e[0];let i=2;for(let n=0;n<r;n++){const r=e[i++],n=127&e[i++],s=127&e[i++];if(0===n&&0===s)continue;if(!!(4&r)){const e=3&r;0!==e&&1!==e||(t[e].push(n),t[e].push(s))}}return t}},audioStreamController:class extends Nm{constructor(e,t,r){super(e,t,r,"audio-stream-controller",mu),this.mainAnchor=null,this.mainFragLoading=null,this.audioOnly=!1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.flushing=!1,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this.registerListeners()}onHandlerDestroying(){this.unregisterListeners(),super.onHandlerDestroying(),this.resetItem()}resetItem(){this.mainDetails=this.mainAnchor=this.mainFragLoading=this.bufferedTrack=this.switchingTrack=this.waitingData=this.cachedTrackLoadedData=null}registerListeners(){super.registerListeners();const{hls:e}=this;e.on(cu.LEVEL_LOADED,this.onLevelLoaded,this),e.on(cu.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(cu.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(cu.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(cu.BUFFER_RESET,this.onBufferReset,this),e.on(cu.BUFFER_CREATED,this.onBufferCreated,this),e.on(cu.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(cu.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(cu.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(cu.FRAG_LOADING,this.onFragLoading,this),e.on(cu.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){const{hls:e}=this;e&&(super.unregisterListeners(),e.off(cu.LEVEL_LOADED,this.onLevelLoaded,this),e.off(cu.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(cu.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(cu.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(cu.BUFFER_RESET,this.onBufferReset,this),e.off(cu.BUFFER_CREATED,this.onBufferCreated,this),e.off(cu.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(cu.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(cu.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(cu.FRAG_LOADING,this.onFragLoading,this),e.off(cu.FRAG_BUFFERED,this.onFragBuffered,this))}onInitPtsFound(e,{frag:t,id:r,initPTS:i,timescale:n,trackId:s}){if(r===pu){const e=t.cc,r=this.fragCurrent;if(this.initPTS[e]={baseTime:i,timescale:n,trackId:s},this.log(`InitPTS for cc: ${e} found from main: ${i/n} (${i}/${n}) trackId: ${s}`),this.mainAnchor=t,this.state===Om){const r=this.waitingData;(!r&&!this.loadingParts||r&&r.frag.cc!==e)&&this.syncWithAnchor(t,null==r?void 0:r.frag)}else!this.hls.hasEnoughToStart&&r&&r.cc!==e?(r.abortRequests(),this.syncWithAnchor(t,r)):this.state===Am&&this.tick()}}getLoadPosition(){return!this.startFragRequested&&this.nextLoadPosition>=0?this.nextLoadPosition:super.getLoadPosition()}syncWithAnchor(e,t){var r;const i=(null==(r=this.mainFragLoading)?void 0:r.frag)||null;if(t&&(null==i?void 0:i.cc)===t.cc)return;const n=(i||e).cc,s=yf(this.getLevelDetails(),n,this.getLoadPosition());s&&(this.log(`Syncing with main frag at ${s.start} cc ${s.cc}`),this.startFragRequested=!1,this.nextLoadPosition=s.start,this.resetLoadingState(),this.state===Am&&this.doTickIdle())}startLoad(e,t){if(!this.levels)return this.startPosition=e,void(this.state=xm);const r=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),r>0&&-1===e?(this.log(`Override startPosition with lastCurrentTime @${r.toFixed(3)}`),e=r,this.state=Am):this.state=Rm,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}doTick(){switch(this.state){case Am:this.doTickIdle();break;case Rm:{const{levels:e,trackId:t}=this,r=null==e?void 0:e[t],i=null==r?void 0:r.details;if(i&&!this.waitForLive(r)){if(this.waitForCdnTuneIn(i))break;this.state=Om}break}case Lm:this.checkRetryDate();break;case Om:{const e=this.waitingData;if(e){const{frag:t,part:r,cache:i,complete:n}=e,s=this.mainAnchor;if(void 0!==this.initPTS[t.cc]){this.waitingData=null,this.state=Im;const e={frag:t,part:r,payload:i.flush().buffer,networkDetails:null};this._handleFragmentLoadProgress(e),n&&super._handleFragmentLoadComplete(e)}else s&&s.cc!==e.frag.cc&&this.syncWithAnchor(s,e.frag)}else this.state=Am}}this.onTickEnd()}resetLoadingState(){const e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null),super.resetLoadingState()}onTickEnd(){const{media:e}=this;null!=e&&e.readyState&&(this.lastCurrentTime=e.currentTime)}doTickIdle(){var e;const{hls:t,levels:r,media:i,trackId:n}=this,s=t.config;if(!this.buffering||!i&&!this.primaryPrefetch&&(this.startFragRequested||!s.startFragPrefetch)||null==r||!r[n])return;const a=r[n],o=a.details;if(!o||this.waitForLive(a)||this.waitForCdnTuneIn(o))return this.state=Rm,void(this.startFragRequested=!1);const l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,Vu,mu));const c=this.getFwdBufferInfo(l,mu);if(null===c)return;if(!this.switchingTrack&&this._streamEnded(c,o))return t.trigger(cu.BUFFER_EOS,{type:"audio"}),void(this.state=Dm);const d=c.len,u=t.maxBufferLength,h=o.fragments,f=h[0].start,p=this.getLoadPosition(),m=this.flushing?p:c.end;if(this.switchingTrack&&i){const e=p;o.PTSKnown&&e<f&&(c.end>f||c.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),i.currentTime=f+.05)}if(d>=u&&!this.switchingTrack&&m<h[h.length-1].start)return;let g=this.getNextFragment(m,o);if(g&&this.isLoopLoading(g,m)&&(g=this.getNextFragmentLoopLoading(g,o,c,pu,u)),!g)return void(this.bufferFlushed=!0);let v=(null==(e=this.mainFragLoading)?void 0:e.frag)||null;if(!this.audioOnly&&this.startFragRequested&&v&&qu(g)&&!g.endList&&(!o.live||!this.loadingParts&&m<this.hls.liveSyncPosition)&&(this.fragmentTracker.getState(v)===Bf&&(this.mainFragLoading=v=null),v&&qu(v))){if(g.start>v.end){const e=this.fragmentTracker.getFragAtPos(m,pu);e&&e.end>v.end&&(v=e,this.mainFragLoading={frag:e,targetBufferTime:null})}if(g.start>v.end)return}this.loadFragment(g,a,m)}onMediaDetaching(e,t){this.bufferFlushed=this.flushing=!1,super.onMediaDetaching(e,t)}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(e=>new tf(e))}onAudioTrackSwitching(e,t){const r=!!t.url;this.trackId=t.id;const{fragCurrent:i}=this;i&&(i.abortRequests(),this.removeUnbufferedFrags(i.start)),this.resetLoadingState(),r?(this.switchingTrack=t,this.flushAudioIfNeeded(t),this.state!==xm&&(this.setInterval(100),this.state=Am,this.tick())):(this.resetTransmuxer(),this.switchingTrack=null,this.bufferedTrack=t,this.clearInterval())}onManifestLoading(){super.onManifestLoading(),this.bufferFlushed=this.flushing=this.audioOnly=!1,this.resetItem(),this.trackId=-1}onLevelLoaded(e,t){this.mainDetails=t.details;const r=this.cachedTrackLoadedData;r&&(this.cachedTrackLoadedData=null,this.onAudioTrackLoaded(cu.AUDIO_TRACK_LOADED,r))}onAudioTrackLoaded(e,t){var r;const{levels:i}=this,{details:n,id:s,groupId:a,track:o}=t;if(!i)return void this.warn(`Audio tracks reset while loading track ${s} "${o.name}" of "${a}"`);const l=this.mainDetails;if(!l||n.endCC>l.endCC||l.expired)return this.cachedTrackLoadedData=t,void(this.state!==xm&&(this.state=Rm));this.cachedTrackLoadedData=null,this.log(`Audio track ${s} "${o.name}" of "${a}" loaded [${n.startSN},${n.endSN}]${n.lastPartSn?`[part-${n.lastPartSn}-${n.lastPartIndex}]`:""},duration:${n.totalduration}`);const c=i[s];let d=0;if(n.live||null!=(r=c.details)&&r.live){if(this.checkLiveUpdate(n),n.deltaUpdateFailed)return;var u;if(c.details)d=this.alignPlaylists(n,c.details,null==(u=this.levelLastLoaded)?void 0:u.details);n.alignedSliding||(bm(n,l),n.alignedSliding||Em(n,l),d=n.fragmentStart)}c.details=n,this.levelLastLoaded=c,this.startFragRequested||this.setStartPosition(l,d),this.hls.trigger(cu.AUDIO_TRACK_UPDATED,{details:n,id:s,groupId:t.groupId}),this.state!==Rm||this.waitForCdnTuneIn(n)||(this.state=Am),this.tick()}_handleFragmentLoadProgress(e){var t;const r=e.frag,{part:i,payload:n}=e,{config:s,trackId:a,levels:o}=this;if(!o)return void this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);const l=o[a];if(!l)return void this.warn("Audio track is undefined on fragment load progress");const c=l.details;if(!c)return this.warn("Audio track details undefined on fragment load progress"),void this.removeUnbufferedFrags(r.start);const d=s.defaultAudioCodec||l.audioCodec||"mp4a.40.2";let u=this.transmuxer;u||(u=this.transmuxer=new fv(this.hls,mu,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const h=this.initPTS[r.cc],f=null==(t=r.initSegment)?void 0:t.data;if(void 0!==h){const e=!1,t=i?i.index:-1,s=-1!==t,a=new rp(r.level,r.sn,r.stats.chunkCount,n.byteLength,t,s);u.push(n,f,d,"",r,i,c.totalduration,e,a,h)}else{this.log(`Unknown video PTS for cc ${r.cc}, waiting for video PTS before demuxing audio frag ${r.sn} of [${c.startSN} ,${c.endSN}],track ${a}`);const{cache:e}=this.waitingData=this.waitingData||{frag:r,part:i,cache:new $m,complete:!1};e.push(new Uint8Array(n)),this.state!==xm&&(this.state=Om)}}_handleFragmentLoadComplete(e){this.waitingData?this.waitingData.complete=!0:super._handleFragmentLoadComplete(e)}onBufferReset(){this.mediaBuffer=null}onBufferCreated(e,t){this.bufferFlushed=this.flushing=!1;const r=t.tracks.audio;r&&(this.mediaBuffer=r.buffer||null)}onFragLoading(e,t){!this.audioOnly&&t.frag.type===pu&&qu(t.frag)&&(this.mainFragLoading=t,this.state===Am&&this.tick())}onFragBuffered(e,t){const{frag:r,part:i}=t;if(r.type===mu)if(this.fragContextChanged(r))this.warn(`Fragment ${r.sn}${i?" p: "+i.index:""} of level ${r.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);else{if(qu(r)){this.fragPrevious=r;const e=this.switchingTrack;e&&(this.bufferedTrack=e,this.switchingTrack=null,this.hls.trigger(cu.AUDIO_TRACK_SWITCHED,Su({},e)))}this.fragBufferedComplete(r,i),this.media&&this.tick()}else this.audioOnly||r.type!==pu||r.elementaryStreams.video||r.elementaryStreams.audiovideo||(this.audioOnly=!0,this.mainFragLoading=null)}onError(e,t){var r;if(t.fatal)this.state=_m;else switch(t.details){case lu.FRAG_GAP:case lu.FRAG_PARSING_ERROR:case lu.FRAG_DECRYPT_ERROR:case lu.FRAG_LOAD_ERROR:case lu.FRAG_LOAD_TIMEOUT:case lu.KEY_LOAD_ERROR:case lu.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(mu,t);break;case lu.AUDIO_TRACK_LOAD_ERROR:case lu.AUDIO_TRACK_LOAD_TIMEOUT:case lu.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==Rm||(null==(r=t.context)?void 0:r.type)!==hu||(this.state=Am);break;case lu.BUFFER_ADD_CODEC_ERROR:case lu.BUFFER_APPEND_ERROR:if("audio"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)||this.resetLoadingState();break;case lu.BUFFER_FULL_ERROR:if("audio"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case lu.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}onBufferFlushing(e,{type:t}){t!==Wu&&(this.flushing=!0)}onBufferFlushed(e,{type:t}){if(t!==Wu){this.flushing=!1,this.bufferFlushed=!0,this.state===Dm&&(this.state=Am);const e=this.mediaBuffer||this.media;e&&(this.afterBufferFlushed(e,t,mu),this.tick())}}_handleTransmuxComplete(e){var t;const r="audio",{hls:i}=this,{remuxResult:n,chunkMeta:s}=e,a=this.getCurrentContext(s);if(!a)return void this.resetWhenMissingContext(s);const{frag:o,part:l,level:c}=a,{details:d}=c,{audio:u,text:h,id3:f,initSegment:p}=n;if(!this.fragContextChanged(o)&&d){if(this.state=Pm,this.switchingTrack&&u&&this.completeAudioSwitch(this.switchingTrack),null!=p&&p.tracks){const e=o.initSegment||o;if(this.unhandledEncryptionError(p,o))return;this._bufferInitSegment(c,p.tracks,e,s),i.trigger(cu.FRAG_PARSING_INIT_SEGMENT,{frag:e,id:r,tracks:p.tracks})}if(u){const{startPTS:e,endPTS:t,startDTS:r,endDTS:i}=u;l&&(l.elementaryStreams[Vu]={startPTS:e,endPTS:t,startDTS:r,endDTS:i}),o.setElementaryStreamInfo(Vu,e,t,r,i),this.bufferFragmentData(u,o,l,s)}if(null!=f&&null!=(t=f.samples)&&t.length){const e=Eu({id:r,frag:o,details:d},f);i.trigger(cu.FRAG_PARSING_METADATA,e)}if(h){const e=Eu({id:r,frag:o,details:d},h);i.trigger(cu.FRAG_PARSING_USERDATA,e)}}else this.fragmentTracker.removeFragment(o)}_bufferInitSegment(e,t,r,i){if(this.state!==Pm)return;if(t.video&&delete t.video,t.audiovideo&&delete t.audiovideo,!t.audio)return;const n=t.audio;n.id=mu;const s=e.audioCodec;this.log(`Init audio buffer, container:${n.container}, codecs[level/parsed]=[${s}/${n.codec}]`),s&&1===s.split(",").length&&(n.levelCodec=s),this.hls.trigger(cu.BUFFER_CODECS,t);const a=n.initSegment;if(null!=a&&a.byteLength){const e={type:"audio",frag:r,part:null,chunkMeta:i,parent:r.type,data:a};this.hls.trigger(cu.BUFFER_APPENDING,e)}this.tickImmediate()}loadFragment(e,t,r){const i=this.fragmentTracker.getState(e);var n;if(this.switchingTrack||i===Nf||i===$f)if(qu(e))if(null!=(n=t.details)&&n.live&&!this.initPTS[e.cc]){this.log(`Waiting for video PTS in continuity counter ${e.cc} of live stream before loading audio fragment ${e.sn} of level ${this.trackId}`),this.state=Om;const r=this.mainDetails;r&&r.fragmentStart!==t.details.fragmentStart&&Em(t.details,r)}else super.loadFragment(e,t,r);else this._loadInitSegment(e,t);else this.clearTrackerIfNeeded(e)}flushAudioIfNeeded(e){if(this.media&&this.bufferedTrack){const{name:t,lang:r,assocLang:i,characteristics:n,audioCodec:s,channels:a}=this.bufferedTrack;df({name:t,lang:r,assocLang:i,characteristics:n,audioCodec:s,channels:a},e,uf)||(ff(e.url,this.hls)?(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null):this.bufferedTrack=e)}}completeAudioSwitch(e){const{hls:t}=this;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(cu.AUDIO_TRACK_SWITCHED,Su({},e))}},audioTrackController:class extends pv{constructor(e){super(e,"audio-track-controller"),this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){const{hls:e}=this;e.on(cu.MANIFEST_LOADING,this.onManifestLoading,this),e.on(cu.MANIFEST_PARSED,this.onManifestParsed,this),e.on(cu.LEVEL_LOADING,this.onLevelLoading,this),e.on(cu.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(cu.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(cu.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(cu.MANIFEST_LOADING,this.onManifestLoading,this),e.off(cu.MANIFEST_PARSED,this.onManifestParsed,this),e.off(cu.LEVEL_LOADING,this.onLevelLoading,this),e.off(cu.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(cu.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(cu.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.tracksInGroup=[],this.groupIds=null,this.currentTrack=null,this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.audioTracks||[]}onAudioTrackLoaded(e,t){const{id:r,groupId:i,details:n}=t,s=this.tracksInGroup[r];if(!s||s.groupId!==i)return void this.warn(`Audio track with id:${r} and group:${i} not found in active group ${null==s?void 0:s.groupId}`);const a=s.details;s.details=t.details,this.log(`Audio track ${r} "${s.name}" lang:${s.lang} group:${i} loaded [${n.startSN}-${n.endSN}]`),r===this.trackId&&this.playlistLoaded(r,t,a)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(!t)return;const r=t.audioGroups||null,i=this.groupIds;let n=this.currentTrack;if(!r||(null==i?void 0:i.length)!==(null==r?void 0:r.length)||null!=r&&r.some(e=>-1===(null==i?void 0:i.indexOf(e)))){this.groupIds=r,this.trackId=-1,this.currentTrack=null;const e=this.tracks.filter(e=>!r||-1!==r.indexOf(e.groupId));if(e.length)this.selectDefaultTrack&&!e.some(e=>e.default)&&(this.selectDefaultTrack=!1),e.forEach((e,t)=>{e.id=t});else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=e;const t=this.hls.config.audioPreference;if(!n&&t){const r=cf(t,e,uf);if(r>-1)n=e[r];else{const e=cf(t,this.tracks);n=this.tracks[e]}}let i=this.findTrackId(n);-1===i&&n&&(i=this.findTrackId(null));const a={audioTracks:e};this.log(`Updating audio tracks, ${e.length} track(s) found in group(s): ${null==r?void 0:r.join(",")}`),this.hls.trigger(cu.AUDIO_TRACKS_UPDATED,a);const o=this.trackId;if(-1!==i&&-1===o)this.setAudioTrack(i);else if(e.length&&-1===o){var s;const t=new Error(`No audio track selected for current audio group-ID(s): ${null==(s=this.groupIds)?void 0:s.join(",")} track count: ${e.length}`);this.warn(t.message),this.hls.trigger(cu.ERROR,{type:ou.MEDIA_ERROR,details:lu.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:t})}}}onError(e,t){!t.fatal&&t.context&&(t.context.type!==hu||t.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(t.context.groupId)||this.checkRetry(t))}get allAudioTracks(){return this.tracks}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}setAudioOption(e){const t=this.hls;if(t.config.audioPreference=e,e){const r=this.allAudioTracks;if(this.selectDefaultTrack=!1,r.length){const i=this.currentTrack;if(i&&df(e,i,uf))return i;const n=cf(e,this.tracksInGroup,uf);if(n>-1){const e=this.tracksInGroup[n];return this.setAudioTrack(n),e}if(i){let i=t.loadLevel;-1===i&&(i=t.firstAutoLevel);const n=function(e,t,r,i,n){const s=t[i],a=t.reduce((e,t,r)=>{const i=t.uri;return(e[i]||(e[i]=[])).push(r),e},{})[s.uri];a.length>1&&(i=Math.max.apply(Math,a));const o=s.videoRange,l=s.frameRate,c=s.codecSet.substring(0,4),d=hf(t,i,t=>{if(t.videoRange!==o||t.frameRate!==l||t.codecSet.substring(0,4)!==c)return!1;const i=t.audioGroups,s=r.filter(e=>!i||-1!==i.indexOf(e.groupId));return cf(e,s,n)>-1});return d>-1?d:hf(t,i,t=>{const i=t.audioGroups,s=r.filter(e=>!i||-1!==i.indexOf(e.groupId));return cf(e,s,n)>-1})}(e,t.levels,r,i,uf);if(-1===n)return null;t.nextLoadLevel=n}if(e.channels||e.audioCodec){const t=cf(e,r);if(t>-1)return r[t]}}}return null}setAudioTrack(e){const t=this.tracksInGroup;if(e<0||e>=t.length)return void this.warn(`Invalid audio track id: ${e}`);this.selectDefaultTrack=!1;const r=this.currentTrack,i=t[e],n=i.details&&!i.details.live;if(e===this.trackId&&i===r&&n)return;if(this.log(`Switching to audio-track ${e} "${i.name}" lang:${i.lang} group:${i.groupId} channels:${i.channels}`),this.trackId=e,this.currentTrack=i,this.hls.trigger(cu.AUDIO_TRACK_SWITCHING,Su({},i)),n)return;const s=this.switchParams(i.url,null==r?void 0:r.details,i.details);this.loadPlaylist(s)}findTrackId(e){const t=this.tracksInGroup;for(let r=0;r<t.length;r++){const i=t[r];if((!this.selectDefaultTrack||i.default)&&(!e||df(e,i,uf)))return r}if(e){const{name:r,lang:i,assocLang:n,characteristics:s,audioCodec:a,channels:o}=e;for(let e=0;e<t.length;e++){if(df({name:r,lang:i,assocLang:n,characteristics:s,audioCodec:a,channels:o},t[e],uf))return e}for(let r=0;r<t.length;r++){const i=t[r];if(gv(e.attrs,i.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return r}for(let r=0;r<t.length;r++){const i=t[r];if(gv(e.attrs,i.attrs,["LANGUAGE"]))return r}}return-1}loadPlaylist(e){super.loadPlaylist();const t=this.currentTrack;this.shouldLoadPlaylist(t)&&ff(t.url,this.hls)&&this.scheduleLoading(t,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);const r=e.id,i=e.groupId,n=this.getUrlWithDirectives(e.url,t),s=e.details,a=null==s?void 0:s.age;this.log(`Loading audio-track ${r} "${e.name}" lang:${e.lang} group:${i}${void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:""}${a&&s.live?" age "+a.toFixed(1)+(s.type&&" "+s.type||""):""} ${n}`),this.hls.trigger(cu.AUDIO_TRACK_LOADING,{url:n,id:r,groupId:i,deliveryDirectives:t||null,track:e})}},emeController:Ey,cmcdController:class{constructor(e){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.includeKeys=void 0,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=e=>{try{this.apply(e,{ot:Av.MANIFEST,su:!this.initialized})}catch(e){this.hls.logger.warn("Could not generate manifest CMCD data.",e)}},this.applyFragmentData=e=>{try{const{frag:t,part:r}=e,i=this.hls.levels[t.level],n=this.getObjectType(t),s={d:1e3*(r||t).duration,ot:n};n!==Av.VIDEO&&n!==Av.AUDIO&&n!=Av.MUXED||(s.br=i.bitrate/1e3,s.tb=this.getTopBandwidth(n)/1e3,s.bl=this.getBufferLength(n));const a=r?this.getNextPart(r):this.getNextFrag(t);null!=a&&a.url&&a.url!==t.url&&(s.nor=a.url),this.apply(e,s)}catch(e){this.hls.logger.warn("Could not generate segment CMCD data.",e)}},this.hls=e;const t=this.config=e.config,{cmcd:r}=t;null!=r&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=r.sessionId||e.sessionId,this.cid=r.contentId,this.useHeaders=!0===r.useHeaders,this.includeKeys=r.includeKeys,this.registerListeners())}registerListeners(){const e=this.hls;e.on(cu.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(cu.MEDIA_DETACHED,this.onMediaDetached,this),e.on(cu.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const e=this.hls;e.off(cu.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(cu.MEDIA_DETACHED,this.onMediaDetached,this),e.off(cu.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=this.media=null}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(e,t){var r,i;this.audioBuffer=null==(r=t.tracks.audio)?void 0:r.buffer,this.videoBuffer=null==(i=t.tracks.video)?void 0:i.buffer}createData(){var e;return{v:1,sf:kv.HLS,sid:this.sid,cid:this.cid,pr:null==(e=this.media)?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){Eu(t,this.createData());const r=t.ot===Av.INIT||t.ot===Av.VIDEO||t.ot===Av.MUXED;this.starved&&r&&(t.bs=!0,t.su=!0,this.starved=!1),null==t.su&&(t.su=this.buffering);const{includeKeys:i}=this;i&&(t=Object.keys(t).reduce((e,r)=>(i.includes(r)&&(e[r]=t[r]),e),{}));const n={baseUrl:e.url};this.useHeaders?(e.headers||(e.headers={}),py(e.headers,t,n)):e.url=vy(e.url,t,n)}getNextFrag(e){var t;const r=null==(t=this.hls.levels[e.level])?void 0:t.details;if(r){const t=e.sn-r.startSN;return r.fragments[t+1]}}getNextPart(e){var t;const{index:r,fragment:i}=e,n=null==(t=this.hls.levels[i.level])||null==(t=t.details)?void 0:t.partList;if(n){const{sn:e}=i;for(let t=n.length-1;t>=0;t--){const i=n[t];if(i.index===r&&i.fragment.sn===e)return n[t+1]}}}getObjectType(e){const{type:t}=e;return"subtitle"===t?Av.TIMED_TEXT:"initSegment"===e.sn?Av.INIT:"audio"===t?Av.AUDIO:"main"===t?this.hls.audioTracks.length?Av.VIDEO:Av.MUXED:void 0}getTopBandwidth(e){let t,r=0;const i=this.hls;if(e===Av.AUDIO)t=i.audioTracks;else{const e=i.maxAutoLevel,r=e>-1?e+1:i.levels.length;t=i.levels.slice(0,r)}return t.forEach(e=>{e.bitrate>r&&(r=e.bitrate)}),r>0?r:NaN}getBufferLength(e){const t=this.media,r=e===Av.AUDIO?this.audioBuffer:this.videoBuffer;if(!r||!t)return NaN;return 1e3*np.bufferInfo(r,t.currentTime,this.config.maxBufferHole).len}createPlaylistLoader(){const{pLoader:e}=this.config,t=this.applyPlaylistData,r=e||this.config.loader;return class{constructor(e){this.loader=void 0,this.loader=new r(e)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(e,r,i){t(e),this.loader.load(e,r,i)}}}createFragmentLoader(){const{fLoader:e}=this.config,t=this.applyFragmentData,r=e||this.config.loader;return class{constructor(e){this.loader=void 0,this.loader=new r(e)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(e,r,i){t(e),this.loader.load(e,r,i)}}}},contentSteeringController:class extends Tu{constructor(e){super("content-steering",e.logger),this.hls=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this._pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.registerListeners()}registerListeners(){const e=this.hls;e.on(cu.MANIFEST_LOADING,this.onManifestLoading,this),e.on(cu.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(cu.MANIFEST_PARSED,this.onManifestParsed,this),e.on(cu.ERROR,this.onError,this)}unregisterListeners(){const e=this.hls;e&&(e.off(cu.MANIFEST_LOADING,this.onManifestLoading,this),e.off(cu.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(cu.MANIFEST_PARSED,this.onManifestParsed,this),e.off(cu.ERROR,this.onError,this))}pathways(){return(this.levels||[]).reduce((e,t)=>(-1===e.indexOf(t.pathwayId)&&e.push(t.pathwayId),e),[])}get pathwayPriority(){return this._pathwayPriority}set pathwayPriority(e){this.updatePathwayPriority(e)}startLoad(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){const e=1e3*this.timeToLoad-(performance.now()-this.updated);if(e>0)return void this.scheduleRefresh(this.uri,e)}this.loadSteeringManifest(this.uri)}}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}clearTimeout(){-1!==this.reloadTimer&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(e){const t=this.levels;t&&(this.levels=t.filter(t=>t!==e))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(e,t){const{contentSteering:r}=t;null!==r&&(this.pathwayId=r.pathwayId,this.uri=r.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){const{errorAction:r}=t;if((null==r?void 0:r.action)===Lf&&r.flags===Df){const e=this.levels;let i=this._pathwayPriority,n=this.pathwayId;if(t.context){const{groupId:r,pathwayId:i,type:s}=t.context;r&&e?n=this.getPathwayForGroupId(r,s,n):i&&(n=i)}n in this.penalizedPathways||(this.penalizedPathways[n]=performance.now()),!i&&e&&(i=this.pathways()),i&&i.length>1&&(this.updatePathwayPriority(i),r.resolved=this.pathwayId!==n),t.details!==lu.BUFFER_APPEND_ERROR||t.fatal?r.resolved||this.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${n} levels: ${e?e.length:e} priorities: ${sf(i)} penalized: ${sf(this.penalizedPathways)}`):r.resolved=!0}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(0===t.length){const r=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${r}"`),t=this.getLevelsForPathway(r),this.pathwayId=r}return t.length!==e.length&&this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t}getLevelsForPathway(e){return null===this.levels?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){let t;this._pathwayPriority=e;const r=this.penalizedPathways,i=performance.now();Object.keys(r).forEach(e=>{i-r[e]>3e5&&delete r[e]});for(let i=0;i<e.length;i++){const n=e[i];if(n in r)continue;if(n===this.pathwayId)return;const s=this.hls.nextLoadLevel,a=this.hls.levels[s];if(t=this.getLevelsForPathway(n),t.length>0){this.log(`Setting Pathway to "${n}"`),this.pathwayId=n,fm(t),this.hls.trigger(cu.LEVELS_UPDATED,{levels:t});const e=this.hls.levels[s];a&&e&&this.levels&&(e.attrs["STABLE-VARIANT-ID"]!==a.attrs["STABLE-VARIANT-ID"]&&e.bitrate!==a.bitrate&&this.log(`Unstable Pathways change from bitrate ${a.bitrate} to ${e.bitrate}`),this.hls.nextLoadLevel=s);break}}}getPathwayForGroupId(e,t,r){const i=this.getLevelsForPathway(r).concat(this.levels||[]);for(let r=0;r<i.length;r++)if(t===hu&&i[r].hasAudioGroup(e)||t===fu&&i[r].hasSubtitleGroup(e))return i[r].pathwayId;return r}clonePathways(e){const t=this.levels;if(!t)return;const r={},i={};e.forEach(e=>{const{ID:n,"BASE-ID":s,"URI-REPLACEMENT":a}=e;if(t.some(e=>e.pathwayId===n))return;const o=this.getLevelsForPathway(s).map(e=>{const t=new hp(e.attrs);t["PATHWAY-ID"]=n;const s=t.AUDIO&&`${t.AUDIO}_clone_${n}`,o=t.SUBTITLES&&`${t.SUBTITLES}_clone_${n}`;s&&(r[t.AUDIO]=s,t.AUDIO=s),o&&(i[t.SUBTITLES]=o,t.SUBTITLES=o);const l=by(e.uri,t["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",a),c=new tf({attrs:t,audioCodec:e.audioCodec,bitrate:e.bitrate,height:e.height,name:e.name,url:l,videoCodec:e.videoCodec,width:e.width});if(e.audioGroups)for(let t=1;t<e.audioGroups.length;t++)c.addGroupId("audio",`${e.audioGroups[t]}_clone_${n}`);if(e.subtitleGroups)for(let t=1;t<e.subtitleGroups.length;t++)c.addGroupId("text",`${e.subtitleGroups[t]}_clone_${n}`);return c});t.push(...o),yy(this.audioTracks,r,a,n),yy(this.subtitleTracks,i,a,n)})}loadSteeringManifest(e){const t=this.hls.config,r=t.loader;let i;this.loader&&this.loader.destroy(),this.loader=new r(t);try{i=new self.URL(e)}catch(t){return this.enabled=!1,void this.log(`Failed to parse Steering Manifest URI: ${e}`)}if("data:"!==i.protocol){const e=0|(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate);i.searchParams.set("_HLS_pathway",this.pathwayId),i.searchParams.set("_HLS_throughput",""+e)}const n={responseType:"json",url:i.href},s=t.steeringManifestLoadPolicy.default,a=s.errorRetry||s.timeoutRetry||{},o={loadPolicy:s,timeout:s.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},l={onSuccess:(e,t,r,n)=>{this.log(`Loaded steering manifest: "${i}"`);const s=e.data;if(1!==(null==s?void 0:s.VERSION))return void this.log(`Steering VERSION ${s.VERSION} not supported!`);this.updated=performance.now(),this.timeToLoad=s.TTL;const{"RELOAD-URI":a,"PATHWAY-CLONES":o,"PATHWAY-PRIORITY":l}=s;if(a)try{this.uri=new self.URL(a,i).href}catch(e){return this.enabled=!1,void this.log(`Failed to parse Steering Manifest RELOAD-URI: ${a}`)}this.scheduleRefresh(this.uri||r.url),o&&this.clonePathways(o);const c={steeringManifest:s,url:i.toString()};this.hls.trigger(cu.STEERING_MANIFEST_LOADED,c),l&&this.updatePathwayPriority(l)},onError:(e,t,r,i)=>{if(this.log(`Error loading steering manifest: ${e.code} ${e.text} (${t.url})`),this.stopLoad(),410===e.code)return this.enabled=!1,void this.log(`Steering manifest ${t.url} no longer available`);let n=1e3*this.timeToLoad;if(429===e.code){const e=this.loader;if("function"==typeof(null==e?void 0:e.getResponseHeader)){const t=e.getResponseHeader("Retry-After");t&&(n=1e3*parseFloat(t))}return void this.log(`Steering manifest ${t.url} rate limited`)}this.scheduleRefresh(this.uri||t.url,n)},onTimeout:(e,t,r)=>{this.log(`Timeout loading steering manifest (${t.url})`),this.scheduleRefresh(this.uri||t.url)}};this.log(`Requesting steering manifest: ${i}`),this.loader.load(n,o,l)}scheduleRefresh(e,t=1e3*this.timeToLoad){this.clearTimeout(),this.reloadTimer=self.setTimeout(()=>{var t;const r=null==(t=this.hls)?void 0:t.media;!r||r.ended?this.scheduleRefresh(e,1e3*this.timeToLoad):this.loadSteeringManifest(e)},t)}},interstitialsController:class extends Tu{constructor(e,t){super("interstitials",e.logger),this.HlsPlayerClass=void 0,this.hls=void 0,this.assetListLoader=void 0,this.mediaSelection=null,this.altSelection=null,this.media=null,this.detachedData=null,this.requiredTracks=null,this.manager=null,this.playerQueue=[],this.bufferedPos=-1,this.timelinePos=-1,this.schedule=void 0,this.playingItem=null,this.bufferingItem=null,this.waitingItem=null,this.endedItem=null,this.playingAsset=null,this.endedAsset=null,this.bufferingAsset=null,this.shouldPlay=!1,this.onPlay=()=>{this.shouldPlay=!0},this.onPause=()=>{this.shouldPlay=!1},this.onSeeking=()=>{const e=this.currentTime;if(void 0===e||this.playbackDisabled||!this.schedule)return;const t=e-this.timelinePos;if(Math.abs(t)<1/7056e5)return;const r=t<=-.01;this.timelinePos=e,this.bufferedPos=e;const i=this.playingItem;if(!i)return void this.checkBuffer();if(r){this.schedule.resetErrorsInRange(e,e-t)&&this.updateSchedule(!0)}if(this.checkBuffer(),r&&e<i.start||e>=i.end){var n;const t=this.findItemIndex(i);let s=this.schedule.findItemIndexAtTime(e);if(-1===s&&(s=t+(r?-1:1),this.log(`seeked ${r?"back ":""}to position not covered by schedule ${e} (resolving from ${t} to ${s})`)),!this.isInterstitial(i)&&null!=(n=this.media)&&n.paused&&(this.shouldPlay=!1),!r&&s>t){const e=this.schedule.findJumpRestrictedIndex(t+1,s);if(e>t)return void this.setSchedulePosition(e)}return void this.setSchedulePosition(s)}const s=this.playingAsset;if(!s){if(this.playingLastItem&&this.isInterstitial(i)){const t=i.event.assetList[0];t&&(this.endedItem=this.playingItem,this.playingItem=null,this.setScheduleToAssetAtTime(e,t))}return}const a=s.timelineStart,o=s.duration||0;var l;(r&&e<a||e>=a+o)&&(null!=(l=i.event)&&l.appendInPlace&&(this.clearAssetPlayers(i.event,i),this.flushFrontBuffer(e)),this.setScheduleToAssetAtTime(e,s))},this.onTimeupdate=()=>{const e=this.currentTime;if(void 0===e||this.playbackDisabled)return;if(!(e>this.timelinePos))return;this.timelinePos=e,e>this.bufferedPos&&this.checkBuffer();const t=this.playingItem;if(!t||this.playingLastItem)return;if(e>=t.end){this.timelinePos=t.end;const e=this.findItemIndex(t);this.setSchedulePosition(e+1)}const r=this.playingAsset;if(!r)return;e>=r.timelineStart+(r.duration||0)&&this.setScheduleToAssetAtTime(e,r)},this.onScheduleUpdate=(e,t)=>{const r=this.schedule;if(!r)return;const i=this.playingItem,n=r.events||[],s=r.items||[],a=r.durations,o=e.map(e=>e.identifier),l=!(!n.length&&!o.length);(l||t)&&this.log(`INTERSTITIALS_UPDATED (${n.length}): ${n}\nSchedule: ${s.map(e=>zy(e))} pos: ${this.timelinePos}`),o.length&&this.log(`Removed events ${o}`);let c=null,d=null;i&&(c=this.updateItem(i,this.timelinePos),this.itemsMatch(i,c)?this.playingItem=c:this.waitingItem=this.endedItem=null),this.waitingItem=this.updateItem(this.waitingItem),this.endedItem=this.updateItem(this.endedItem);const u=this.bufferingItem;if(u&&(d=this.updateItem(u,this.bufferedPos),this.itemsMatch(u,d)?this.bufferingItem=d:u.event&&(this.bufferingItem=this.playingItem,this.clearInterstitial(u.event,null))),e.forEach(e=>{e.assetList.forEach(e=>{this.clearAssetPlayer(e.identifier,null)})}),this.playerQueue.forEach(e=>{if(e.interstitial.appendInPlace){const t=e.assetItem.timelineStart,r=e.timelineOffset-t;if(r)try{e.timelineOffset=t}catch(i){Math.abs(r)>Cy&&this.warn(`${i} ("${e.assetId}" ${e.timelineOffset}->${t})`)}}}),l||t){if(this.hls.trigger(cu.INTERSTITIALS_UPDATED,{events:n.slice(0),schedule:s.slice(0),durations:a,removedIds:o}),this.isInterstitial(i)&&o.includes(i.event.identifier))return this.warn(`Interstitial "${i.event.identifier}" removed while playing`),void this.primaryFallback(i.event);i&&this.trimInPlace(c,i),u&&d!==c&&this.trimInPlace(d,u),this.checkBuffer()}},this.hls=e,this.HlsPlayerClass=t,this.assetListLoader=new Gy(e),this.schedule=new Uy(this.onScheduleUpdate,e.logger),this.registerListeners()}registerListeners(){const e=this.hls;e&&(e.on(cu.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(cu.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(cu.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(cu.MANIFEST_LOADING,this.onManifestLoading,this),e.on(cu.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(cu.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(cu.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.on(cu.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(cu.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.on(cu.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.on(cu.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.on(cu.BUFFER_APPENDED,this.onBufferAppended,this),e.on(cu.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(cu.BUFFERED_TO_END,this.onBufferedToEnd,this),e.on(cu.MEDIA_ENDED,this.onMediaEnded,this),e.on(cu.ERROR,this.onError,this),e.on(cu.DESTROYING,this.onDestroying,this))}unregisterListeners(){const e=this.hls;e&&(e.off(cu.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(cu.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(cu.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(cu.MANIFEST_LOADING,this.onManifestLoading,this),e.off(cu.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(cu.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(cu.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.off(cu.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(cu.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.off(cu.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.off(cu.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.off(cu.BUFFER_CODECS,this.onBufferCodecs,this),e.off(cu.BUFFER_APPENDED,this.onBufferAppended,this),e.off(cu.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(cu.BUFFERED_TO_END,this.onBufferedToEnd,this),e.off(cu.MEDIA_ENDED,this.onMediaEnded,this),e.off(cu.ERROR,this.onError,this),e.off(cu.DESTROYING,this.onDestroying,this))}startLoad(){this.resumeBuffering()}stopLoad(){this.pauseBuffering()}resumeBuffering(){var e;null==(e=this.getBufferingPlayer())||e.resumeBuffering()}pauseBuffering(){var e;null==(e=this.getBufferingPlayer())||e.pauseBuffering()}destroy(){this.unregisterListeners(),this.stopLoad(),this.assetListLoader&&this.assetListLoader.destroy(),this.emptyPlayerQueue(),this.clearScheduleState(),this.schedule&&this.schedule.destroy(),this.media=this.detachedData=this.mediaSelection=this.requiredTracks=this.altSelection=this.schedule=this.manager=null,this.hls=this.HlsPlayerClass=this.log=null,this.assetListLoader=null,this.onPlay=this.onPause=this.onSeeking=this.onTimeupdate=null,this.onScheduleUpdate=null}onDestroying(){const e=this.primaryMedia||this.media;e&&this.removeMediaListeners(e)}removeMediaListeners(e){Sm(e,"play",this.onPlay),Sm(e,"pause",this.onPause),Sm(e,"seeking",this.onSeeking),Sm(e,"timeupdate",this.onTimeupdate)}onMediaAttaching(e,t){const r=this.media=t.media;wm(r,"seeking",this.onSeeking),wm(r,"timeupdate",this.onTimeupdate),wm(r,"play",this.onPlay),wm(r,"pause",this.onPause)}onMediaAttached(e,t){const r=this.effectivePlayingItem,i=this.detachedData;if(this.detachedData=null,null===r)this.checkStart();else if(!i){this.clearScheduleState();const e=this.findItemIndex(r);this.setSchedulePosition(e)}}clearScheduleState(){this.log("clear schedule state"),this.playingItem=this.bufferingItem=this.waitingItem=this.endedItem=this.playingAsset=this.endedAsset=this.bufferingAsset=null}onMediaDetaching(e,t){const r=!!t.transferMedia,i=this.media;if(this.media=null,!r&&(i&&this.removeMediaListeners(i),this.detachedData)){const e=this.getBufferingPlayer();e&&(this.log(`Removing schedule state for detachedData and ${e}`),this.playingAsset=this.endedAsset=this.bufferingAsset=this.bufferingItem=this.waitingItem=this.detachedData=null,e.detachMedia()),this.shouldPlay=!1}}get interstitialsManager(){if(!this.hls)return null;if(this.manager)return this.manager;const e=this,t=()=>e.bufferingItem||e.waitingItem,r=t=>t?e.getAssetPlayer(t.identifier):t,i=(t,i,s,a,o)=>{if(t){let l=t[i].start;const c=t.event;if(c){if("playout"===i||c.timelineOccupancy!==Dy.Point){const e=r(s);(null==e?void 0:e.interstitial)===c&&(l+=e.assetItem.startOffset+e[o])}}else{l+=("bufferedPos"===a?n():e[a])-t.start}return l}return 0},n=()=>{const t=e.bufferedPos;return t===Number.MAX_VALUE?s("primary"):Math.max(t,0)},s=t=>{var r,i;return null!=(r=e.primaryDetails)&&r.live?e.primaryDetails.edge:(null==(i=e.schedule)?void 0:i.durations[t])||0},a=(t,n)=>{var s,a;const o=e.effectivePlayingItem;if(null!=o&&null!=(s=o.event)&&s.restrictions.skip||!e.schedule)return;e.log(`seek to ${t} "${n}"`);const l=e.effectivePlayingItem,c=e.schedule.findItemIndexAtTime(t,n),d=null==(a=e.schedule.items)?void 0:a[c],u=e.getBufferingPlayer(),h=null==u?void 0:u.interstitial,f=null==h?void 0:h.appendInPlace,p=l&&e.itemsMatch(l,d);if(l&&(f||p)){const s=r(e.playingAsset),a=(null==s?void 0:s.media)||e.primaryMedia;if(a){const r="primary"===n?a.currentTime:i(l,n,e.playingAsset,"timelinePos","currentTime"),o=t-r,c=(f?r:a.currentTime)+o;if(c>=0&&(!s||f||c<=s.duration))return void(a.currentTime=c)}}if(d){let r=t;if("primary"!==n){const e=t-d[n].start;r=d.start+e}const i=!e.isInterstitial(d);if(e.isInterstitial(l)&&!l.event.appendInPlace||!i&&!d.event.appendInPlace){if(l){const s=e.findItemIndex(l);if(c>s){const t=e.schedule.findJumpRestrictedIndex(s+1,c);if(t>s)return void e.setSchedulePosition(t)}let a=0;if(i)e.timelinePos=r,e.checkBuffer();else{const e=d.event.assetList,r=t-(d[n]||d).start;for(let t=e.length;t--;){const i=e[t];if(i.duration&&r>=i.startOffset&&r<i.startOffset+i.duration){a=t;break}}}e.setSchedulePosition(c,a)}}else{const t=e.media||(f?null==u?void 0:u.media:null);t&&(t.currentTime=r)}}},o=()=>{const r=e.effectivePlayingItem;if(e.isInterstitial(r))return r;const i=t();return e.isInterstitial(i)?i:null},l={get bufferedEnd(){const r=t(),n=e.bufferingItem;var s;return n&&n===r&&(i(n,"playout",e.bufferingAsset,"bufferedPos","bufferedEnd")-n.playout.start||(null==(s=e.bufferingAsset)?void 0:s.startOffset))||0},get currentTime(){const t=o(),r=e.effectivePlayingItem;return r&&r===t?i(r,"playout",e.effectivePlayingAsset,"timelinePos","currentTime")-r.playout.start:0},set currentTime(t){const r=o(),i=e.effectivePlayingItem;i&&i===r&&a(t+i.playout.start,"playout")},get duration(){const e=o();return e?e.playout.end-e.playout.start:0},get assetPlayers(){var t;const r=null==(t=o())?void 0:t.event.assetList;return r?r.map(t=>e.getAssetPlayer(t.identifier)):[]},get playingIndex(){var t;const r=null==(t=o())?void 0:t.event;return r&&e.effectivePlayingAsset?r.findAssetIndex(e.effectivePlayingAsset):-1},get scheduleItem(){return o()}};return this.manager={get events(){var t;return(null==(t=e.schedule)||null==(t=t.events)?void 0:t.slice(0))||[]},get schedule(){var t;return(null==(t=e.schedule)||null==(t=t.items)?void 0:t.slice(0))||[]},get interstitialPlayer(){return o()?l:null},get playerQueue(){return e.playerQueue.slice(0)},get bufferingAsset(){return e.bufferingAsset},get bufferingItem(){return t()},get bufferingIndex(){const r=t();return e.findItemIndex(r)},get playingAsset(){return e.effectivePlayingAsset},get playingItem(){return e.effectivePlayingItem},get playingIndex(){const t=e.effectivePlayingItem;return e.findItemIndex(t)},primary:{get bufferedEnd(){return n()},get currentTime(){const t=e.timelinePos;return t>0?t:0},set currentTime(e){a(e,"primary")},get duration(){return s("primary")},get seekableStart(){var t;return(null==(t=e.primaryDetails)?void 0:t.fragmentStart)||0}},integrated:{get bufferedEnd(){return i(t(),"integrated",e.bufferingAsset,"bufferedPos","bufferedEnd")},get currentTime(){return i(e.effectivePlayingItem,"integrated",e.effectivePlayingAsset,"timelinePos","currentTime")},set currentTime(e){a(e,"integrated")},get duration(){return s("integrated")},get seekableStart(){var t;return((t,r)=>{var i;if(0!==t&&"primary"!==r&&null!=(i=e.schedule)&&i.length){var n;const i=e.schedule.findItemIndexAtTime(t),s=null==(n=e.schedule.items)?void 0:n[i];if(s)return t+(s[r].start-s.start)}return t})((null==(t=e.primaryDetails)?void 0:t.fragmentStart)||0,"integrated")}},skip:()=>{const t=e.effectivePlayingItem,r=null==t?void 0:t.event;if(r&&!r.restrictions.skip){const i=e.findItemIndex(t);if(r.appendInPlace){const e=t.playout.start+t.event.duration;a(e+.001,"playout")}else e.advanceAfterAssetEnded(r,i,1/0)}}}}get effectivePlayingItem(){return this.waitingItem||this.playingItem||this.endedItem}get effectivePlayingAsset(){return this.playingAsset||this.endedAsset}get playingLastItem(){var e;const t=this.playingItem,r=null==(e=this.schedule)?void 0:e.items;return!!(this.playbackStarted&&t&&r)&&this.findItemIndex(t)===r.length-1}get playbackStarted(){return null!==this.effectivePlayingItem}get currentTime(){var e,t;if(null===this.mediaSelection)return;const r=this.waitingItem||this.playingItem;if(this.isInterstitial(r)&&!r.event.appendInPlace)return;let i=this.media;!i&&null!=(e=this.bufferingItem)&&null!=(e=e.event)&&e.appendInPlace&&(i=this.primaryMedia);const n=null==(t=i)?void 0:t.currentTime;return void 0!==n&&nu(n)?n:void 0}get primaryMedia(){var e;return this.media||(null==(e=this.detachedData)?void 0:e.media)||null}isInterstitial(e){return!(null==e||!e.event)}retreiveMediaSource(e,t){const r=this.getAssetPlayer(e);r&&this.transferMediaFromPlayer(r,t)}transferMediaFromPlayer(e,t){const r=e.interstitial.appendInPlace,i=e.media;if(r&&i===this.primaryMedia){if(this.bufferingAsset=null,(!t||this.isInterstitial(t)&&!t.event.appendInPlace)&&t&&i)return void(this.detachedData={media:i});const r=e.transferMedia();this.log(`transfer MediaSource from ${e} ${sf(r)}`),this.detachedData=r}else t&&i&&(this.shouldPlay||(this.shouldPlay=!i.paused))}transferMediaTo(e,t){var r,i;if(e.media===t)return;let n=null;const s=this.hls,a=e!==s,o=a&&e.interstitial.appendInPlace,l=null==(r=this.detachedData)?void 0:r.mediaSource;let c;if(s.media)o&&(n=s.transferMedia(),this.detachedData=n),c="Primary";else if(l){const e=this.getBufferingPlayer();e?(n=e.transferMedia(),c=`${e}`):c="detached MediaSource"}else c="detached media";if(!n)if(l)n=this.detachedData,this.log(`using detachedData: MediaSource ${sf(n)}`);else if(!this.detachedData||s.media===t){const e=this.playerQueue;e.length>1&&e.forEach(e=>{if(a&&e.interstitial.appendInPlace!==o){const t=e.interstitial;this.clearInterstitial(e.interstitial,null),t.appendInPlace=!1,t.appendInPlace&&this.warn(`Could not change append strategy for queued assets ${t}`)}}),this.hls.detachMedia(),this.detachedData={media:t}}const d=n&&"mediaSource"in n&&"closed"!==(null==(i=n.mediaSource)?void 0:i.readyState),u=d&&n?n:t;this.log(`${d?"transfering MediaSource":"attaching media"} to ${a?e:"Primary"} from ${c} (media.currentTime: ${t.currentTime})`);const h=this.schedule;if(u===n&&h){const t=a&&e.assetId===h.assetIdAtEnd;u.overrides={duration:h.duration,endOfStream:!a||t,cueRemoval:!a}}e.attachMedia(u)}onInterstitialCueEnter(){this.onTimeupdate()}checkStart(){const e=this.schedule,t=null==e?void 0:e.events;if(!t||this.playbackDisabled||!this.media)return;-1===this.bufferedPos&&(this.bufferedPos=0);const r=this.timelinePos,i=this.effectivePlayingItem;if(-1===r){const r=this.hls.startPosition;if(this.log(Hy("checkStart",r)),this.timelinePos=r,t.length&&t[0].cue.pre){const r=e.findEventIndex(t[0].identifier);this.setSchedulePosition(r)}else if(r>=0||!this.primaryLive){const t=this.timelinePos=r>0?r:0,i=e.findItemIndexAtTime(t);this.setSchedulePosition(i)}}else if(i&&!this.playingItem){const t=e.findItemIndex(i);this.setSchedulePosition(t)}}advanceAssetBuffering(e,t){const r=e.event,i=r.findAssetIndex(t),n=Fy(r,i);if(r.isAssetPastPlayoutLimit(n)){if(this.schedule){var s;const t=null==(s=this.schedule.items)?void 0:s[this.findItemIndex(e)+1];t&&this.bufferedToItem(t)}}else this.bufferedToEvent(e,n)}advanceAfterAssetEnded(e,t,r){const i=Fy(e,r);if(e.isAssetPastPlayoutLimit(i)){if(this.schedule){const r=this.schedule.items;if(r){const i=t+1;if(i>=r.length)return void this.setSchedulePosition(-1);const n=e.resumeTime;this.timelinePos<n&&(this.log(Hy("advanceAfterAssetEnded",n)),this.timelinePos=n,e.appendInPlace&&this.advanceInPlace(n),this.checkBuffer(this.bufferedPos<n)),this.setSchedulePosition(i)}}}else{if(e.appendInPlace){const t=e.assetList[i];t&&this.advanceInPlace(t.timelineStart)}this.setSchedulePosition(t,i)}}setScheduleToAssetAtTime(e,t){const r=this.schedule;if(!r)return;const i=t.parentIdentifier,n=r.getEvent(i);if(n){const t=r.findEventIndex(i),s=r.findAssetIndex(n,e);this.advanceAfterAssetEnded(n,t,s-1)}}setSchedulePosition(e,t){var r;const i=null==(r=this.schedule)?void 0:r.items;if(!i||this.playbackDisabled)return;const n=e>=0?i[e]:null;this.log(`setSchedulePosition ${e}, ${t} (${n?zy(n):n}) pos: ${this.timelinePos}`);const s=this.waitingItem||this.playingItem,a=this.playingLastItem;if(this.isInterstitial(s)){const r=s.event,c=this.playingAsset,d=null==c?void 0:c.identifier,u=d?this.getAssetPlayer(d):null;if(u&&d&&(!this.eventItemsMatch(s,n)||void 0!==t&&d!==r.assetList[t].identifier)){var o;const t=r.findAssetIndex(c);if(this.log(`INTERSTITIAL_ASSET_ENDED ${t+1}/${r.assetList.length} ${$y(c)}`),this.endedAsset=c,this.playingAsset=null,this.hls.trigger(cu.INTERSTITIAL_ASSET_ENDED,{asset:c,assetListIndex:t,event:r,schedule:i.slice(0),scheduleIndex:e,player:u}),s!==this.playingItem)return void(this.itemsMatch(s,this.playingItem)&&!this.playingAsset&&this.advanceAfterAssetEnded(r,this.findItemIndex(this.playingItem),t));this.retreiveMediaSource(d,n),!u.media||null!=(o=this.detachedData)&&o.mediaSource||u.detachMedia()}if(!this.eventItemsMatch(s,n)&&(this.endedItem=s,this.playingItem=null,this.log(`INTERSTITIAL_ENDED ${r} ${zy(s)}`),r.hasPlayed=!0,this.hls.trigger(cu.INTERSTITIAL_ENDED,{event:r,schedule:i.slice(0),scheduleIndex:e}),r.cue.once)){var l;this.updateSchedule();const e=null==(l=this.schedule)?void 0:l.items;if(n&&e){const r=this.findItemIndex(n);this.advanceSchedule(r,e,t,s,a)}return}}this.advanceSchedule(e,i,t,s,a)}advanceSchedule(e,t,r,i,n){const s=this.schedule;if(!s)return;const a=t[e]||null,o=this.primaryMedia,l=this.playerQueue;if(l.length&&l.forEach(t=>{const r=t.interstitial,i=s.findEventIndex(r.identifier);(i<e||i>e+1)&&this.clearInterstitial(r,a)}),this.isInterstitial(a)){this.timelinePos=Math.min(Math.max(this.timelinePos,a.start),a.end);const n=a.event;if(void 0===r){const t=Fy(n,(r=s.findAssetIndex(n,this.timelinePos))-1);if(n.isAssetPastPlayoutLimit(t)||n.appendInPlace&&this.timelinePos===a.end)return void this.advanceAfterAssetEnded(n,e,r);r=t}const l=this.waitingItem;this.assetsBuffered(a,o)||this.setBufferingItem(a);let c=this.preloadAssets(n,r);if(this.eventItemsMatch(a,l||i)||(this.waitingItem=a,this.log(`INTERSTITIAL_STARTED ${zy(a)} ${n.appendInPlace?"append in place":""}`),this.hls.trigger(cu.INTERSTITIAL_STARTED,{event:n,schedule:t.slice(0),scheduleIndex:e})),!n.assetListLoaded)return void this.log(`Waiting for ASSET-LIST to complete loading ${n}`);if(n.assetListLoader&&(n.assetListLoader.destroy(),n.assetListLoader=void 0),!o)return void this.log(`Waiting for attachMedia to start Interstitial ${n}`);this.waitingItem=this.endedItem=null,this.playingItem=a;const d=n.assetList[r];if(!d)return void this.advanceAfterAssetEnded(n,e,r||0);if(c||(c=this.getAssetPlayer(d.identifier)),null===c||c.destroyed){const e=n.assetList.length;this.warn(`asset ${r+1}/${e} player destroyed ${n}`),c=this.createAssetPlayer(n,d,r),c.loadSource()}if(!this.eventItemsMatch(a,this.bufferingItem)&&n.appendInPlace&&this.isAssetBuffered(d))return;this.startAssetPlayer(c,r,t,e,o),this.shouldPlay&&jy(c.media)}else a?(this.resumePrimary(a,e,i),this.shouldPlay&&jy(this.hls.media)):n&&this.isInterstitial(i)&&(this.endedItem=null,this.playingItem=i,i.event.appendInPlace||this.attachPrimary(s.durations.primary,null))}get playbackDisabled(){return!1===this.hls.config.enableInterstitialPlayback}get primaryDetails(){var e;return null==(e=this.mediaSelection)?void 0:e.main.details}get primaryLive(){var e;return!(null==(e=this.primaryDetails)||!e.live)}resumePrimary(e,t,r){var i,n;if(this.playingItem=e,this.playingAsset=this.endedAsset=null,this.waitingItem=this.endedItem=null,this.bufferedToItem(e),this.log(`resuming ${zy(e)}`),null==(i=this.detachedData)||!i.mediaSource){let r=this.timelinePos;(r<e.start||r>=e.end)&&(r=this.getPrimaryResumption(e,t),this.log(Hy("resumePrimary",r)),this.timelinePos=r),this.attachPrimary(r,e)}if(!r)return;const s=null==(n=this.schedule)?void 0:n.items;s&&(this.log(`INTERSTITIALS_PRIMARY_RESUMED ${zy(e)}`),this.hls.trigger(cu.INTERSTITIALS_PRIMARY_RESUMED,{schedule:s.slice(0),scheduleIndex:t}),this.checkBuffer())}getPrimaryResumption(e,t){const r=e.start;if(this.primaryLive){const e=this.primaryDetails;if(0===t)return this.hls.startPosition;if(e&&(r<e.fragmentStart||r>e.edge))return this.hls.liveSyncPosition||-1}return r}isAssetBuffered(e){const t=this.getAssetPlayer(e.identifier);if(null!=t&&t.hls)return t.hls.bufferedToEnd;return np.bufferInfo(this.primaryMedia,this.timelinePos,0).end+1>=e.timelineStart+(e.duration||0)}attachPrimary(e,t,r){t?this.setBufferingItem(t):this.bufferingItem=this.playingItem,this.bufferingAsset=null;const i=this.primaryMedia;if(!i)return;const n=this.hls;n.media?this.checkBuffer():(this.transferMediaTo(n,i),r&&this.startLoadingPrimaryAt(e,r)),r||(this.log(Hy("attachPrimary",e)),this.timelinePos=e,this.startLoadingPrimaryAt(e,r))}startLoadingPrimaryAt(e,t){var r;const i=this.hls;!i.loadingEnabled||!i.media||Math.abs(((null==(r=i.mainForwardBufferInfo)?void 0:r.start)||i.media.currentTime)-e)>.5?i.startLoad(e,t):i.bufferingEnabled||i.resumeBuffering()}onManifestLoading(){var e;this.stopLoad(),null==(e=this.schedule)||e.reset(),this.emptyPlayerQueue(),this.clearScheduleState(),this.shouldPlay=!1,this.bufferedPos=this.timelinePos=-1,this.mediaSelection=this.altSelection=this.manager=this.requiredTracks=null,this.hls.off(cu.BUFFER_CODECS,this.onBufferCodecs,this),this.hls.on(cu.BUFFER_CODECS,this.onBufferCodecs,this)}onLevelUpdated(e,t){if(-1===t.level||!this.schedule)return;const r=this.hls.levels[t.level];if(!r.details)return;const i=Su(Su({},this.mediaSelection||this.altSelection),{},{main:r});this.mediaSelection=i,this.schedule.parseInterstitialDateRanges(i,this.hls.config.interstitialAppendInPlace),!this.effectivePlayingItem&&this.schedule.items&&this.checkStart()}onAudioTrackUpdated(e,t){const r=this.hls.audioTracks[t.id],i=this.mediaSelection;if(!i)return void(this.altSelection=Su(Su({},this.altSelection),{},{audio:r}));const n=Su(Su({},i),{},{audio:r});this.mediaSelection=n}onSubtitleTrackUpdated(e,t){const r=this.hls.subtitleTracks[t.id],i=this.mediaSelection;if(!i)return void(this.altSelection=Su(Su({},this.altSelection),{},{subtitles:r}));const n=Su(Su({},i),{},{subtitles:r});this.mediaSelection=n}onAudioTrackSwitching(e,t){const r=lf(t);this.playerQueue.forEach(({hls:e})=>e&&(e.setAudioOption(t)||e.setAudioOption(r)))}onSubtitleTrackSwitch(e,t){const r=lf(t);this.playerQueue.forEach(({hls:e})=>e&&(e.setSubtitleOption(t)||-1!==t.id&&e.setSubtitleOption(r)))}onBufferCodecs(e,t){const r=t.tracks;r&&(this.requiredTracks=r)}onBufferAppended(e,t){this.checkBuffer()}onBufferFlushed(e,t){const r=this.playingItem;if(r&&!this.itemsMatch(r,this.bufferingItem)&&!this.isInterstitial(r)){const e=this.timelinePos;this.bufferedPos=e,this.checkBuffer()}}onBufferedToEnd(e){if(!this.schedule)return;const t=this.schedule.events;if(this.bufferedPos<Number.MAX_VALUE&&t){for(let e=0;e<t.length;e++){const i=t[e];if(i.cue.post){var r;const e=this.schedule.findEventIndex(i.identifier),t=null==(r=this.schedule.items)?void 0:r[e];this.isInterstitial(t)&&this.eventItemsMatch(t,this.bufferingItem)&&this.bufferedToItem(t,0);break}}this.bufferedPos=Number.MAX_VALUE}}onMediaEnded(e){const t=this.playingItem;if(!this.playingLastItem&&t){const e=this.findItemIndex(t);this.setSchedulePosition(e+1)}else this.shouldPlay=!1}updateItem(e,t){var r;const i=null==(r=this.schedule)?void 0:r.items;if(e&&i){return i[this.findItemIndex(e,t)]||null}return null}trimInPlace(e,t){if(this.isInterstitial(e)&&e.event.appendInPlace&&t.end-e.end>.25){e.event.assetList.forEach((t,r)=>{e.event.isAssetPastPlayoutLimit(r)&&this.clearAssetPlayer(t.identifier,null)});const r=e.end+.25,i=np.bufferInfo(this.primaryMedia,r,0);if(i.end>r||(i.nextStart||0)>r){this.log(`trim buffered interstitial ${zy(e)} (was ${zy(t)})`);const i=!0;this.attachPrimary(r,null,i),this.flushFrontBuffer(r)}}}itemsMatch(e,t){return!!t&&(e===t||e.event&&t.event&&this.eventItemsMatch(e,t)||!e.event&&!t.event&&this.findItemIndex(e)===this.findItemIndex(t))}eventItemsMatch(e,t){var r;return!!t&&(e===t||e.event.identifier===(null==(r=t.event)?void 0:r.identifier))}findItemIndex(e,t){return e&&this.schedule?this.schedule.findItemIndex(e,t):-1}updateSchedule(e=!1){var t;const r=this.mediaSelection;r&&(null==(t=this.schedule)||t.updateSchedule(r,[],e))}checkBuffer(e){var t;const r=null==(t=this.schedule)?void 0:t.items;if(!r)return;const i=np.bufferInfo(this.primaryMedia,this.timelinePos,0);e&&(this.bufferedPos=this.timelinePos),e||(e=i.len<1),this.updateBufferedPos(i.end,r,e)}updateBufferedPos(e,t,r){const i=this.schedule,n=this.bufferingItem;if(this.bufferedPos>e||!i)return;if(1===t.length&&this.itemsMatch(t[0],n))return void(this.bufferedPos=e);const s=this.playingItem,a=this.findItemIndex(s);let o=i.findItemIndexAtTime(e);if(this.bufferedPos<e){var l;const r=this.findItemIndex(n),i=Math.min(r+1,t.length-1),s=t[i];if((-1===o&&n&&e>=n.end||null!=(l=s.event)&&l.appendInPlace&&e+.01>=s.start)&&(o=i),this.isInterstitial(n)){const e=n.event;if(i-a>1&&!1===e.appendInPlace)return;if(0===e.assetList.length&&e.assetListLoader)return}if(this.bufferedPos=e,o>r&&o>a)this.bufferedToItem(s);else{const t=this.primaryDetails;this.primaryLive&&t&&e>t.edge-t.targetduration&&s.start<t.edge+this.hls.config.interstitialLiveLookAhead&&this.isInterstitial(s)&&this.preloadAssets(s.event,0)}}else r&&s&&!this.itemsMatch(s,n)&&(o===a?this.bufferedToItem(s):o===a+1&&this.bufferedToItem(t[o]))}assetsBuffered(e,t){return 0!==e.event.assetList.length&&!e.event.assetList.some(e=>{const r=this.getAssetPlayer(e.identifier);return!(null!=r&&r.bufferedInPlaceToEnd(t))})}setBufferingItem(e){const t=this.bufferingItem,r=this.schedule;if(!this.itemsMatch(e,t)&&r){const{items:i,events:n}=r;if(!i||!n)return t;const s=this.isInterstitial(e),a=this.getBufferingPlayer();this.bufferingItem=e,this.bufferedPos=Math.max(e.start,Math.min(e.end,this.timelinePos));const o=a?a.remaining:t?t.end-this.timelinePos:0;if(this.log(`INTERSTITIALS_BUFFERED_TO_BOUNDARY ${zy(e)}`+(t?` (${o.toFixed(2)} remaining)`:"")),!this.playbackDisabled)if(s){const t=r.findAssetIndex(e.event,this.bufferedPos);e.event.assetList.forEach((e,r)=>{const i=this.getAssetPlayer(e.identifier);i&&(r===t&&i.loadSource(),i.resumeBuffering())})}else this.hls.resumeBuffering(),this.playerQueue.forEach(e=>e.pauseBuffering());this.hls.trigger(cu.INTERSTITIALS_BUFFERED_TO_BOUNDARY,{events:n.slice(0),schedule:i.slice(0),bufferingIndex:this.findItemIndex(e),playingIndex:this.findItemIndex(this.playingItem)})}else this.bufferingItem!==e&&(this.bufferingItem=e);return t}bufferedToItem(e,t=0){const r=this.setBufferingItem(e);if(!this.playbackDisabled)if(this.isInterstitial(e))this.bufferedToEvent(e,t);else if(null!==r){this.bufferingAsset=null;const t=this.detachedData;if(t)if(t.mediaSource){const t=!0;this.attachPrimary(e.start,e,t)}else this.preloadPrimary(e);else this.preloadPrimary(e)}}preloadPrimary(e){const t=this.findItemIndex(e),r=this.getPrimaryResumption(e,t);this.startLoadingPrimaryAt(r)}bufferedToEvent(e,t){const r=e.event,i=0===r.assetList.length&&!r.assetListLoader,n=r.cue.once;if(i||!n){const e=this.preloadAssets(r,t);if(null!=e&&e.interstitial.appendInPlace){const t=this.primaryMedia;t&&this.bufferAssetPlayer(e,t)}}}preloadAssets(e,t){const r=e.assetUrl,i=e.assetList.length,n=0===i&&!e.assetListLoader,s=e.cue.once;if(n){const n=e.timelineStart;if(e.appendInPlace){var a;const t=this.playingItem;this.isInterstitial(t)||(null==t||null==(a=t.nextEvent)?void 0:a.identifier)!==e.identifier||this.flushFrontBuffer(n+.25)}let s,o=0;if(!this.playingItem&&this.primaryLive&&(o=this.hls.startPosition,-1===o&&(o=this.hls.liveSyncPosition||0)),o&&!e.cue.pre&&!e.cue.post){const e=o-n;e>0&&(s=Math.round(1e3*e)/1e3)}if(this.log(`Load interstitial asset ${t+1}/${r?1:i} ${e}${s?` live-start: ${o} start-offset: ${s}`:""}`),r)return this.createAsset(e,0,0,n,e.duration,r);const l=this.assetListLoader.loadAssetList(e,s);l&&(e.assetListLoader=l)}else if(!s&&i){for(let r=t;r<i;r++){const t=e.assetList[r],i=this.getAssetPlayerQueueIndex(t.identifier);-1!==i&&!this.playerQueue[i].destroyed||t.error||this.createAssetPlayer(e,t,r)}const r=e.assetList[t];if(r){const e=this.getAssetPlayer(r.identifier);return e&&e.loadSource(),e}}return null}flushFrontBuffer(e){const t=this.requiredTracks;if(!t)return;this.log(`Removing front buffer starting at ${e}`);Object.keys(t).forEach(t=>{this.hls.trigger(cu.BUFFER_FLUSHING,{startOffset:e,endOffset:1/0,type:t})})}getAssetPlayerQueueIndex(e){const t=this.playerQueue;for(let r=0;r<t.length;r++)if(e===t[r].assetId)return r;return-1}getAssetPlayer(e){const t=this.getAssetPlayerQueueIndex(e);return this.playerQueue[t]||null}getBufferingPlayer(){const{playerQueue:e,primaryMedia:t}=this;if(t)for(let r=0;r<e.length;r++)if(e[r].media===t)return e[r];return null}createAsset(e,t,r,i,n,s){const a={parentIdentifier:e.identifier,identifier:_y(e,s,t),duration:n,startOffset:r,timelineStart:i,uri:s};return this.createAssetPlayer(e,a,t)}createAssetPlayer(e,t,r){const i=this.hls,n=i.userConfig;let s=n.videoPreference;const a=i.loadLevelObj||i.levels[i.currentLevel];(s||a)&&(s=Eu({},s),a.videoCodec&&(s.videoCodec=a.videoCodec),a.videoRange&&(s.allowedVideoRanges=[a.videoRange]));const o=i.audioTracks[i.audioTrack],l=i.subtitleTracks[i.subtitleTrack];let c=0;if(this.primaryLive||e.appendInPlace){const e=this.timelinePos-t.timelineStart;if(e>1){const r=t.duration;r&&e<r&&(c=e)}}const d=t.identifier,u=Su(Su({},n),{},{maxMaxBufferLength:Math.min(180,i.config.maxMaxBufferLength),autoStartLoad:!0,startFragPrefetch:!0,primarySessionId:i.sessionId,assetPlayerId:d,abrEwmaDefaultEstimate:i.bandwidthEstimate,interstitialsController:void 0,startPosition:c,liveDurationInfinity:!1,testBandwidth:!1,videoPreference:s,audioPreference:o||n.audioPreference,subtitlePreference:l||n.subtitlePreference});e.appendInPlace&&(e.appendInPlaceStarted=!0,t.timelineStart&&(u.timelineOffset=t.timelineStart));const h=u.cmcd;null!=h&&h.sessionId&&h.contentId&&(u.cmcd=Eu({},h,{contentId:Py(t.uri)})),this.getAssetPlayer(d)&&this.warn(`Duplicate date range identifier ${e} and asset ${d}`);const f=new By(this.HlsPlayerClass,u,e,t);this.playerQueue.push(f),e.assetList[r]=t;let p=!0;const m=i=>{if(i.live){var n;const t=new Error(`Interstitials MUST be VOD assets ${e}`),i={fatal:!0,type:ou.OTHER_ERROR,details:lu.INTERSTITIAL_ASSET_ITEM_ERROR,error:t},s=(null==(n=this.schedule)?void 0:n.findEventIndex(e.identifier))||-1;return void this.handleAssetItemError(i,e,s,r,t.message)}const s=i.edge-i.fragmentStart,a=t.duration;(p||null===a||s>a)&&(p=!1,this.log(`Interstitial asset "${d}" duration change ${a} > ${s}`),t.duration=s,this.updateSchedule())};f.on(cu.LEVEL_UPDATED,(e,{details:t})=>m(t)),f.on(cu.LEVEL_PTS_UPDATED,(e,{details:t})=>m(t)),f.on(cu.EVENT_CUE_ENTER,()=>this.onInterstitialCueEnter());const g=(e,t)=>{const r=this.getAssetPlayer(d);if(r&&t.tracks){r.off(cu.BUFFER_CODECS,g),r.tracks=t.tracks;const e=this.primaryMedia;this.bufferingAsset===r.assetItem&&e&&!r.media&&this.bufferAssetPlayer(r,e)}};f.on(cu.BUFFER_CODECS,g);f.on(cu.BUFFERED_TO_END,()=>{var r;const i=this.getAssetPlayer(d);if(this.log(`buffered to end of asset ${i}`),!i||!this.schedule)return;const n=this.schedule.findEventIndex(e.identifier),s=null==(r=this.schedule.items)?void 0:r[n];this.isInterstitial(s)&&this.advanceAssetBuffering(s,t)});const v=t=>()=>{if(!this.getAssetPlayer(d)||!this.schedule)return;this.shouldPlay=!0;const r=this.schedule.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,r,t)};return f.once(cu.MEDIA_ENDED,v(r)),f.once(cu.PLAYOUT_LIMIT_REACHED,v(1/0)),f.on(cu.ERROR,(t,i)=>{if(!this.schedule)return;const n=this.getAssetPlayer(d);if(i.details===lu.BUFFER_STALLED_ERROR)return null!=n&&n.appendInPlace?void this.handleInPlaceStall(e):(this.onTimeupdate(),void this.checkBuffer(!0));this.handleAssetItemError(i,e,this.schedule.findEventIndex(e.identifier),r,`Asset player error ${i.error} ${e}`)}),f.on(cu.DESTROYING,()=>{if(!this.getAssetPlayer(d)||!this.schedule)return;const t=new Error(`Asset player destroyed unexpectedly ${d}`),i={fatal:!0,type:ou.OTHER_ERROR,details:lu.INTERSTITIAL_ASSET_ITEM_ERROR,error:t};this.handleAssetItemError(i,e,this.schedule.findEventIndex(e.identifier),r,t.message)}),this.log(`INTERSTITIAL_ASSET_PLAYER_CREATED ${$y(t)}`),this.hls.trigger(cu.INTERSTITIAL_ASSET_PLAYER_CREATED,{asset:t,assetListIndex:r,event:e,player:f}),f}clearInterstitial(e,t){this.clearAssetPlayers(e,t),e.reset()}clearAssetPlayers(e,t){e.assetList.forEach(e=>{this.clearAssetPlayer(e.identifier,t)})}resetAssetPlayer(e){const t=this.getAssetPlayerQueueIndex(e);if(-1!==t){this.log(`reset asset player "${e}" after error`);const r=this.playerQueue[t];this.transferMediaFromPlayer(r,null),r.resetDetails()}}clearAssetPlayer(e,t){const r=this.getAssetPlayerQueueIndex(e);if(-1!==r){const e=this.playerQueue[r];this.log(`clear ${e} toSegment: ${t?zy(t):t}`),this.transferMediaFromPlayer(e,t),this.playerQueue.splice(r,1),e.destroy()}}emptyPlayerQueue(){let e;for(;e=this.playerQueue.pop();)e.destroy();this.playerQueue=[]}startAssetPlayer(e,t,r,i,n){const{interstitial:s,assetItem:a,assetId:o}=e,l=s.assetList.length,c=this.playingAsset;this.endedAsset=null,this.playingAsset=a,c&&c.identifier===o||(c&&(this.clearAssetPlayer(c.identifier,r[i]),delete c.error),this.log(`INTERSTITIAL_ASSET_STARTED ${t+1}/${l} ${$y(a)}`),this.hls.trigger(cu.INTERSTITIAL_ASSET_STARTED,{asset:a,assetListIndex:t,event:s,schedule:r.slice(0),scheduleIndex:i,player:e})),this.bufferAssetPlayer(e,n)}bufferAssetPlayer(e,t){var r,i;if(!this.schedule)return;const{interstitial:n,assetItem:s}=e,a=this.schedule.findEventIndex(n.identifier),o=null==(r=this.schedule.items)?void 0:r[a];if(!o)return;e.loadSource(),this.setBufferingItem(o),this.bufferingAsset=s;const l=this.getBufferingPlayer();if(l===e)return;const c=n.appendInPlace;if(c&&!1===(null==l?void 0:l.interstitial.appendInPlace))return;const d=(null==l?void 0:l.tracks)||(null==(i=this.detachedData)?void 0:i.tracks)||this.requiredTracks;if(c&&s!==this.playingAsset){if(!e.tracks)return void this.log(`Waiting for track info before buffering ${e}`);if(d&&!Cu(d,e.tracks)){const t=new Error(`Asset ${$y(s)} SourceBuffer tracks ('${Object.keys(e.tracks)}') are not compatible with primary content tracks ('${Object.keys(d)}')`),r={fatal:!0,type:ou.OTHER_ERROR,details:lu.INTERSTITIAL_ASSET_ITEM_ERROR,error:t},i=n.findAssetIndex(s);return void this.handleAssetItemError(r,n,a,i,t.message)}}this.transferMediaTo(e,t)}handleInPlaceStall(e){const t=this.schedule,r=this.primaryMedia;if(!t||!r)return;const i=r.currentTime,n=t.findAssetIndex(e,i),s=e.assetList[n];if(s){const a=this.getAssetPlayer(s.identifier);if(a){const o=a.currentTime||i-s.timelineStart,l=a.duration-o;if(this.warn(`Stalled at ${o} of ${o+l} in ${a} ${e} (media.currentTime: ${i})`),o&&(l/r.playbackRate<.5||a.bufferedInPlaceToEnd(r))&&a.hls){const r=t.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,r,n)}}}}advanceInPlace(e){const t=this.primaryMedia;t&&t.currentTime<e&&(t.currentTime=e)}handleAssetItemError(e,t,r,i,n){if(e.details===lu.BUFFER_STALLED_ERROR)return;const s=t.assetList[i]||null;if(this.warn(`INTERSTITIAL_ASSET_ERROR ${s?$y(s):s} ${e.error}`),!this.schedule)return;const a=(null==s?void 0:s.identifier)||"",o=this.getAssetPlayerQueueIndex(a),l=this.playerQueue[o]||null,c=this.schedule.items,d=Eu({},e,{fatal:!1,errorAction:Mf(!0),asset:s,assetListIndex:i,event:t,schedule:c,scheduleIndex:r,player:l});if(this.hls.trigger(cu.INTERSTITIAL_ASSET_ERROR,d),!e.fatal)return;const u=this.playingAsset,h=this.bufferingAsset,f=new Error(n);if(s&&(this.clearAssetPlayer(a,null),s.error=f),t.assetList.some(e=>!e.error))for(let e=i;e<t.assetList.length;e++)this.resetAssetPlayer(t.assetList[e].identifier);else t.error=f;this.updateSchedule(!0),t.error?this.primaryFallback(t):u&&u.identifier===a?this.advanceAfterAssetEnded(t,r,i):h&&h.identifier===a&&this.isInterstitial(this.bufferingItem)&&this.advanceAssetBuffering(this.bufferingItem,h)}primaryFallback(e){const t=e.timelineStart,r=this.effectivePlayingItem;let i=this.timelinePos;if(r){this.log(`Fallback to primary from event "${e.identifier}" start: ${t} pos: ${i} playing: ${zy(r)} error: ${e.error}`),-1===i&&(i=this.hls.startPosition);const n=this.updateItem(r,i);this.itemsMatch(r,n)&&this.clearInterstitial(e,null),e.appendInPlace&&(this.attachPrimary(t,null),this.flushFrontBuffer(t))}else if(-1===i)return void this.checkStart();if(!this.schedule)return;const n=this.schedule.findItemIndexAtTime(i);this.setSchedulePosition(n)}onAssetListLoaded(e,t){var r,i;const n=t.event,s=n.identifier,a=t.assetListResponse.ASSETS;if(null==(r=this.schedule)||!r.hasEvent(s))return;const o=n.timelineStart,l=n.duration;let c=0;a.forEach((e,t)=>{const r=parseFloat(e.DURATION);this.createAsset(n,t,c,o+c,r,e.URI),c+=r}),n.duration=c,this.log(`Loaded asset-list with duration: ${c} (was: ${l}) ${n}`);const d=this.waitingItem,u=(null==d?void 0:d.event.identifier)===s;this.updateSchedule();const h=null==(i=this.bufferingItem)?void 0:i.event;if(u){var f;const e=this.schedule.findEventIndex(s),t=null==(f=this.schedule.items)?void 0:f[e];if(t){if(!this.playingItem&&this.timelinePos>t.end){if(this.schedule.findItemIndexAtTime(this.timelinePos)!==e)return n.error=new Error(`Interstitial ${a.length?"no longer within playback range":"asset-list is empty"} ${this.timelinePos} ${n}`),this.log(n.error.message),this.updateSchedule(!0),void this.primaryFallback(n)}this.setBufferingItem(t)}this.setSchedulePosition(e)}else if((null==h?void 0:h.identifier)===s){const e=n.assetList[0];if(e){const t=this.getAssetPlayer(e.identifier);if(h.appendInPlace){const e=this.primaryMedia;t&&e&&this.bufferAssetPlayer(t,e)}else t&&t.loadSource()}}}onError(e,t){if(this.schedule)switch(t.details){case lu.ASSET_LIST_PARSING_ERROR:case lu.ASSET_LIST_LOAD_ERROR:case lu.ASSET_LIST_LOAD_TIMEOUT:{const e=t.interstitial;e&&(this.updateSchedule(!0),this.primaryFallback(e));break}case lu.BUFFER_STALLED_ERROR:{const e=this.endedItem||this.waitingItem||this.playingItem;if(this.isInterstitial(e)&&e.event.appendInPlace)return void this.handleInPlaceStall(e.event);this.log(`Primary player stall @${this.timelinePos} bufferedPos: ${this.bufferedPos}`),this.onTimeupdate(),this.checkBuffer(!0);break}}}}});function qb(e){return e&&"object"==typeof e?Array.isArray(e)?e.map(qb):Object.keys(e).reduce((t,r)=>(t[r]=qb(e[r]),t),{}):e}function Xb(e,t){const r=e.loader;if(r!==jb&&r!==Yb)t.log("[config]: Custom loader detected, cannot enable progressive streaming"),e.progressive=!1;else{(function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(e){}return!1})()&&(e.loader=jb,e.progressive=!0,e.enableSoftwareAES=!0,t.log("[config]: Progressive streaming enabled, using FetchLoader"))}}class Qb extends tp{constructor(e,t){super("gap-controller",e.logger),this.hls=void 0,this.fragmentTracker=void 0,this.media=null,this.mediaSource=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.buffered={},this.lastCurrentTime=0,this.ended=0,this.waiting=0,this.onMediaPlaying=()=>{this.ended=0,this.waiting=0},this.onMediaWaiting=()=>{var e;null!=(e=this.media)&&e.seeking||(this.waiting=self.performance.now(),this.tick())},this.onMediaEnded=()=>{var e;this.hls&&(this.ended=(null==(e=this.media)?void 0:e.currentTime)||1,this.hls.trigger(cu.MEDIA_ENDED,{stalled:!1}))},this.hls=e,this.fragmentTracker=t,this.registerListeners()}registerListeners(){const{hls:e}=this;e&&(e.on(cu.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(cu.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(cu.BUFFER_APPENDED,this.onBufferAppended,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off(cu.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(cu.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(cu.BUFFER_APPENDED,this.onBufferAppended,this))}destroy(){super.destroy(),this.unregisterListeners(),this.media=this.hls=this.fragmentTracker=null,this.mediaSource=void 0}onMediaAttached(e,t){this.setInterval(100),this.mediaSource=t.mediaSource;const r=this.media=t.media;wm(r,"playing",this.onMediaPlaying),wm(r,"waiting",this.onMediaWaiting),wm(r,"ended",this.onMediaEnded)}onMediaDetaching(e,t){this.clearInterval();const{media:r}=this;r&&(Sm(r,"playing",this.onMediaPlaying),Sm(r,"waiting",this.onMediaWaiting),Sm(r,"ended",this.onMediaEnded),this.media=null),this.mediaSource=void 0}onBufferAppended(e,t){this.buffered=t.timeRanges}get hasBuffered(){return Object.keys(this.buffered).length>0}tick(){var e;if(null==(e=this.media)||!e.readyState||!this.hasBuffered)return;const t=this.media.currentTime;this.poll(t,this.lastCurrentTime),this.lastCurrentTime=t}poll(e,t){var r,i;const n=null==(r=this.hls)?void 0:r.config;if(!n)return;const s=this.media;if(!s)return;const{seeking:a}=s,o=this.seeking&&!a,l=!this.seeking&&a,c=s.paused&&!a||s.ended||0===s.playbackRate;if(this.seeking=a,e!==t)return t&&(this.ended=0),this.moved=!0,a||(this.nudgeRetry=0,n.nudgeOnVideoHole&&!c&&e>t&&this.nudgeOnVideoHole(e,t)),void(0===this.waiting&&this.stallResolved(e));if(l||o)return void(o&&this.stallResolved(e));if(c)return this.nudgeRetry=0,this.stallResolved(e),void(!this.ended&&s.ended&&this.hls&&(this.ended=e||1,this.hls.trigger(cu.MEDIA_ENDED,{stalled:!1})));if(!np.getBuffered(s).length)return void(this.nudgeRetry=0);const d=np.bufferInfo(s,e,0),u=d.nextStart||0,h=this.fragmentTracker;if(a&&h&&this.hls){const t=Zb(this.hls.inFlightFragments,e),r=d.len>2,i=!u||t||u-e>2&&!h.getPartialFragment(e);if(r||i)return;this.moved=!1}const f=null==(i=this.hls)?void 0:i.latestLevelDetails;if(!this.moved&&null!==this.stalled&&h){if(!(d.len>0)&&!u)return;const t=Math.max(u,d.start||0)-e,r=!(null==f||!f.live)?2*f.targetduration:2,i=eE(e,h);if(t>0&&(t<=r||i))return void(s.paused||this._trySkipBufferHole(i))}const p=n.detectStallWithCurrentTimeMs,m=self.performance.now(),g=this.waiting;let v=this.stalled;if(null===v){if(!(g>0&&m-g<p))return void(this.stalled=m);v=this.stalled=g}const y=m-v;if(!a&&(y>=p||g)&&this.hls){var b;if("ended"===(null==(b=this.mediaSource)?void 0:b.readyState)&&(null==f||!f.live)&&Math.abs(e-((null==f?void 0:f.edge)||0))<1){if(this.ended)return;return this.ended=e||1,void this.hls.trigger(cu.MEDIA_ENDED,{stalled:!0})}if(this._reportStall(d),!this.media||!this.hls)return}const E=np.bufferInfo(s,e,n.maxBufferHole);this._tryFixBufferStall(E,y,e)}stallResolved(e){const t=this.stalled;if(t&&this.hls&&(this.stalled=null,this.stallReported)){const r=self.performance.now()-t;this.log(`playback not stuck anymore @${e}, after ${Math.round(r)}ms`),this.stallReported=!1,this.waiting=0,this.hls.trigger(cu.STALL_RESOLVED,{})}}nudgeOnVideoHole(e,t){var r;const i=this.buffered.video;if(this.hls&&this.media&&this.fragmentTracker&&null!=(r=this.buffered.audio)&&r.length&&i&&i.length>1&&e>i.end(0)){const r=np.bufferedInfo(np.timeRangesToArray(this.buffered.audio),e,0);if(r.len>1&&t>=r.start){const r=np.timeRangesToArray(i),n=np.bufferedInfo(r,t,0).bufferedIndex;if(n>-1&&n<r.length-1){const t=np.bufferedInfo(r,e,0).bufferedIndex,i=r[n].end,s=r[n+1].start;if((-1===t||t>n)&&s-i<1&&e-i<2){const r=new Error(`nudging playhead to flush pipeline after video hole. currentTime: ${e} hole: ${i} -> ${s} buffered index: ${t}`);this.warn(r.message),this.media.currentTime+=1e-6;let n=eE(e,this.fragmentTracker);n&&"fragment"in n?n=n.fragment:n||(n=void 0);const a=np.bufferInfo(this.media,e,0);this.hls.trigger(cu.ERROR,{type:ou.MEDIA_ERROR,details:lu.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:r,reason:r.message,frag:n,buffer:a.len,bufferInfo:a})}}}}}_tryFixBufferStall(e,t,r){var i,n;const{fragmentTracker:s,media:a}=this,o=null==(i=this.hls)?void 0:i.config;if(!a||!s||!o)return;const l=null==(n=this.hls)?void 0:n.latestLevelDetails,c=eE(r,s);if(c||null!=l&&l.live&&r<l.fragmentStart){if(this._trySkipBufferHole(c)||!this.media)return}const d=e.buffered,u=this.adjacentTraversal(e,r);(d&&d.length>1&&e.len>o.maxBufferHole||e.nextStart&&(e.nextStart-r<o.maxBufferHole||u))&&(t>1e3*o.highBufferWatchdogPeriod||this.waiting)&&(this.warn("Trying to nudge playhead over buffer-hole"),this._tryNudgeBuffer(e))}adjacentTraversal(e,t){const r=this.fragmentTracker,i=e.nextStart;if(r&&i){const e=r.getFragAtPos(t,pu),n=r.getFragAtPos(i,pu);if(e&&n)return n.sn-e.sn<2}return!1}_reportStall(e){const{hls:t,media:r,stallReported:i,stalled:n}=this;if(!i&&null!==n&&r&&t){this.stallReported=!0;const i=new Error(`Playback stalling at @${r.currentTime} due to low buffer (${sf(e)})`);this.warn(i.message),t.trigger(cu.ERROR,{type:ou.MEDIA_ERROR,details:lu.BUFFER_STALLED_ERROR,fatal:!1,error:i,buffer:e.len,bufferInfo:e,stalled:{start:n}})}}_trySkipBufferHole(e){var t;const{fragmentTracker:r,media:i}=this,n=null==(t=this.hls)?void 0:t.config;if(!i||!r||!n)return 0;const s=i.currentTime,a=np.bufferInfo(i,s,0),o=s<a.start?a.start:a.nextStart;if(o&&this.hls){const t=a.len<=n.maxBufferHole,c=a.len>0&&a.len<1&&i.readyState<3,d=o-s;if(d>0&&(t||c)){if(d>n.maxBufferHole){let t=!1;if(0===s){const e=r.getAppendedFrag(0,pu);e&&o<e.end&&(t=!0)}if(!t&&e){var l;if(null==(l=this.hls.loadLevelObj)||!l.details)return 0;if(Zb(this.hls.inFlightFragments,o))return 0;let t=!1,i=e.end;for(;i<o;){const e=eE(i,r);if(!e){t=!0;break}i+=e.duration}if(t)return 0}}const t=Math.max(o+.05,s+.1);if(this.warn(`skipping hole, adjusting currentTime from ${s} to ${t}`),this.moved=!0,i.currentTime=t,null==e||!e.gap){const r=new Error(`fragment loaded with buffer holes, seeking from ${s} to ${t}`),i={type:ou.MEDIA_ERROR,details:lu.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:r,reason:r.message,buffer:a.len,bufferInfo:a};e&&("fragment"in e?i.part=e:i.frag=e),this.hls.trigger(cu.ERROR,i)}return t}}return 0}_tryNudgeBuffer(e){const{hls:t,media:r,nudgeRetry:i}=this,n=null==t?void 0:t.config;if(!r||!n)return 0;const s=r.currentTime;if(this.nudgeRetry++,i<n.nudgeMaxRetry){const a=s+(i+1)*n.nudgeOffset,o=new Error(`Nudging 'currentTime' from ${s} to ${a}`);this.warn(o.message),r.currentTime=a,t.trigger(cu.ERROR,{type:ou.MEDIA_ERROR,details:lu.BUFFER_NUDGE_ON_STALL,error:o,fatal:!1,buffer:e.len,bufferInfo:e})}else{const r=new Error(`Playhead still not moving while enough data buffered @${s} after ${n.nudgeMaxRetry} nudges`);this.error(r.message),t.trigger(cu.ERROR,{type:ou.MEDIA_ERROR,details:lu.BUFFER_STALLED_ERROR,error:r,fatal:!0,buffer:e.len,bufferInfo:e})}}}function Zb(e,t){const r=Jb(e.main);if(r&&r.start<=t)return r;const i=Jb(e.audio);return i&&i.start<=t?i:null}function Jb(e){if(!e)return null;switch(e.state){case Am:case xm:case Dm:case _m:return null}return e.frag}function eE(e,t){return t.getAppendedFrag(e,pu)||t.getPartialFragment(e)}function tE(){if("undefined"!=typeof self)return self.VTTCue||self.TextTrackCue}function rE(e,t,r,i,n){let s=new e(t,r,"");try{s.value=i,n&&(s.type=n)}catch(a){s=new e(t,r,sf(n?Su({type:n},i):i))}return s}const iE=(()=>{const e=tE();try{e&&new e(0,Number.POSITIVE_INFINITY,"")}catch(e){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();class nE{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=!0,this.assetCue=void 0,this.onEventCueEnter=()=>{this.hls&&this.hls.trigger(cu.EVENT_CUE_ENTER,{})},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=this.onEventCueEnter=null}_registerListeners(){const{hls:e}=this;e&&(e.on(cu.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(cu.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(cu.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(cu.MANIFEST_LOADING,this.onManifestLoading,this),e.on(cu.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(cu.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(cu.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(cu.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}_unregisterListeners(){const{hls:e}=this;e&&(e.off(cu.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(cu.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(cu.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(cu.MANIFEST_LOADING,this.onManifestLoading,this),e.off(cu.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(cu.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(cu.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(cu.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}onMediaAttaching(e,t){var r;this.media=t.media,!1===(null==(r=t.overrides)?void 0:r.cueRemoval)&&(this.removeCues=!1)}onMediaAttached(){var e;const t=null==(e=this.hls)?void 0:e.latestLevelDetails;t&&this.updateDateRangeCues(t)}onMediaDetaching(e,t){this.media=null;!!t.transferMedia||(this.id3Track&&(this.removeCues&&Iy(this.id3Track,this.onEventCueEnter),this.id3Track=null),this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){const t=this.getID3Track(e.textTracks);return t.mode="hidden",t}getID3Track(e){if(this.media){for(let t=0;t<e.length;t++){const r=e[t];if("metadata"===r.kind&&"id3"===r.label)return Ay(r,this.media),r}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media||!this.hls)return;const{enableEmsgMetadataCues:r,enableID3MetadataCues:i}=this.hls.config;if(!r&&!i)return;const{samples:n}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));const s=tE();if(s)for(let e=0;e<n.length;e++){const t=n[e].type;if(t===hg.emsg&&!r||!i)continue;const a=lg(n[e].data),o=n[e].pts;let l=o+n[e].duration;l>iE&&(l=iE);l-o<=0&&(l=o+.25);for(let e=0;e<a.length;e++){const r=a[e];if(!cg(r)){this.updateId3CueEnds(o,t);const e=rE(s,o,l,r,t);e&&this.id3Track.addCue(e)}}}}updateId3CueEnds(e,t){var r;const i=null==(r=this.id3Track)?void 0:r.cues;if(i)for(let r=i.length;r--;){const n=i[r];n.type===t&&n.startTime<e&&n.endTime===iE&&(n.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:r,type:i}){const{id3Track:n,hls:s}=this;if(!s)return;const{config:{enableEmsgMetadataCues:a,enableID3MetadataCues:o}}=s;if(n&&(a||o)){let e;e="audio"===i?e=>e.type===hg.audioId3&&o:"video"===i?e=>e.type===hg.emsg&&a:e=>e.type===hg.audioId3&&o||e.type===hg.emsg&&a,Ly(n,t,r,e)}}onLevelUpdated(e,{details:t}){this.updateDateRangeCues(t,!0)}onLevelPtsUpdated(e,t){Math.abs(t.drift)>.01&&this.updateDateRangeCues(t.details)}updateDateRangeCues(e,t){if(!this.hls||!this.media)return;const{assetPlayerId:r,timelineOffset:i,enableDateRangeMetadataCues:n,interstitialsController:s}=this.hls.config;if(!n)return;const a=tE();if(r&&i&&!s){const{fragmentStart:t,fragmentEnd:i}=e;let n=this.assetCue;n?(n.startTime=t,n.endTime=i):a&&(n=this.assetCue=rE(a,t,i,{assetPlayerId:this.hls.config.assetPlayerId},"hlsjs.interstitial.asset"),n&&(n.id=r,this.id3Track||(this.id3Track=this.createTrack(this.media)),this.id3Track.addCue(n),n.addEventListener("enter",this.onEventCueEnter)))}if(!e.hasProgramDateTime)return;const{id3Track:o}=this,{dateRanges:l}=e,c=Object.keys(l);let d=this.dateRangeCuesAppended;var u;if(o&&t)if(null!=(u=o.cues)&&u.length){const e=Object.keys(d).filter(e=>!c.includes(e));for(let t=e.length;t--;){var h;const r=e[t],i=null==(h=d[r])?void 0:h.cues;delete d[r],i&&Object.keys(i).forEach(e=>{const t=i[e];if(t){t.removeEventListener("enter",this.onEventCueEnter);try{o.removeCue(t)}catch(e){}}})}}else d=this.dateRangeCuesAppended={};const f=e.fragments[e.fragments.length-1];if(0!==c.length&&nu(null==f?void 0:f.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(let e=0;e<c.length;e++){const t=c[e],r=l[t],i=r.startTime,n=d[t],o=(null==n?void 0:n.cues)||{};let u=(null==n?void 0:n.durationKnown)||!1,h=iE;const{duration:f,endDate:p}=r;if(p&&null!==f)h=i+f,u=!0;else if(r.endOnNext&&!u){const e=c.reduce((e,t)=>{if(t!==r.id){const i=l[t];if(i.class===r.class&&i.startDate>r.startDate&&(!e||r.startDate<e.startDate))return i}return e},null);e&&(h=e.startTime,u=!0)}const m=Object.keys(r.attr);for(let e=0;e<m.length;e++){const l=m[e];if(!fp(l))continue;const c=o[l];if(c)!u||null!=n&&n.durationKnown?Math.abs(c.startTime-i)>.01&&(c.startTime=i,c.endTime=h):c.endTime=h;else if(a){let e=r.attr[l];pp(l)&&(e=Ou(e));const n=rE(a,i,h,{key:l,data:e},hg.dateRange);n&&(n.id=t,this.id3Track.addCue(n),o[l]=n,s&&("X-ASSET-LIST"!==l&&"X-ASSET-URL"!==l||n.addEventListener("enter",this.onEventCueEnter)))}}d[t]={cues:o,dateRange:r,durationKnown:u}}}}}class sE{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.currentTime=0,this.stallCount=0,this._latency=null,this._targetLatencyUpdated=!1,this.onTimeupdate=()=>{const{media:e}=this,t=this.levelDetails;if(!e||!t)return;this.currentTime=e.currentTime;const r=this.computeLatency();if(null===r)return;this._latency=r;const{lowLatencyMode:i,maxLiveSyncPlaybackRate:n}=this.config;if(!i||1===n||!t.live)return;const s=this.targetLatency;if(null===s)return;const a=r-s;if(a<Math.min(this.maxLatency,s+t.targetduration)&&a>.05&&this.forwardBufferLength>1){const t=Math.min(2,Math.max(1,n)),r=Math.round(2/(1+Math.exp(-.75*a-this.edgeStalled))*20)/20,i=Math.min(t,Math.max(1,r));this.changeMediaPlaybackRate(e,i)}else 1!==e.playbackRate&&0!==e.playbackRate&&this.changeMediaPlaybackRate(e,1)},this.hls=e,this.config=e.config,this.registerListeners()}get levelDetails(){var e;return(null==(e=this.hls)?void 0:e.latestLevelDetails)||null}get latency(){return this._latency||0}get maxLatency(){const{config:e}=this;if(void 0!==e.liveMaxLatencyDuration)return e.liveMaxLatencyDuration;const t=this.levelDetails;return t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){const e=this.levelDetails;if(null===e||null===this.hls)return null;const{holdBack:t,partHoldBack:r,targetduration:i}=e,{liveSyncDuration:n,liveSyncDurationCount:s,lowLatencyMode:a}=this.config,o=this.hls.userConfig;let l=a&&r||t;(this._targetLatencyUpdated||o.liveSyncDuration||o.liveSyncDurationCount||0===l)&&(l=void 0!==n?n:s*i);const c=i;return l+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,c)}set targetLatency(e){this.stallCount=0,this.config.liveSyncDuration=e,this._targetLatencyUpdated=!0}get liveSyncPosition(){const e=this.estimateLiveEdge(),t=this.targetLatency;if(null===e||null===t)return null;const r=this.levelDetails;if(null===r)return null;const i=r.edge,n=e-t-this.edgeStalled,s=i-r.totalduration,a=i-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(s,n),a)}get drift(){const e=this.levelDetails;return null===e?1:e.drift}get edgeStalled(){const e=this.levelDetails;if(null===e)return 0;const t=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.max(e.age-t,0)}get forwardBufferLength(){const{media:e}=this,t=this.levelDetails;if(!e||!t)return 0;const r=e.buffered.length;return(r?e.buffered.end(r-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null}registerListeners(){const{hls:e}=this;e&&(e.on(cu.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(cu.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(cu.MANIFEST_LOADING,this.onManifestLoading,this),e.on(cu.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(cu.ERROR,this.onError,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off(cu.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(cu.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(cu.MANIFEST_LOADING,this.onManifestLoading,this),e.off(cu.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(cu.ERROR,this.onError,this))}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.onTimeupdate)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.onTimeupdate),this.media=null)}onManifestLoading(){this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:t}){t.advanced&&this.onTimeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.onTimeupdate)}onError(e,t){var r;t.details===lu.BUFFER_STALLED_ERROR&&(this.stallCount++,this.hls&&null!=(r=this.levelDetails)&&r.live&&this.hls.logger.warn("[latency-controller]: Stall detected, adjusting target latency"))}changeMediaPlaybackRate(e,t){var r,i;e.playbackRate!==t&&(null==(r=this.hls)||r.logger.debug(`[latency-controller]: latency=${this.latency.toFixed(3)}, targetLatency=${null==(i=this.targetLatency)?void 0:i.toFixed(3)}, forwardBufferLength=${this.forwardBufferLength.toFixed(3)}: adjusting playback rate from ${e.playbackRate} to ${t}`),e.playbackRate=t)}estimateLiveEdge(){const e=this.levelDetails;return null===e?null:e.edge+e.age}computeLatency(){const e=this.estimateLiveEdge();return null===e?null:e-this.currentTime}}class aE extends pv{constructor(e,t){super(e,"level-controller"),this._levels=[],this._firstLevel=-1,this._maxAutoLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=t,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(cu.MANIFEST_LOADING,this.onManifestLoading,this),e.on(cu.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(cu.LEVEL_LOADED,this.onLevelLoaded,this),e.on(cu.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(cu.FRAG_BUFFERED,this.onFragBuffered,this),e.on(cu.ERROR,this.onError,this)}_unregisterListeners(){const{hls:e}=this;e.off(cu.MANIFEST_LOADING,this.onManifestLoading,this),e.off(cu.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(cu.LEVEL_LOADED,this.onLevelLoaded,this),e.off(cu.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(cu.FRAG_BUFFERED,this.onFragBuffered,this),e.off(cu.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}stopLoad(){this._levels.forEach(e=>{e.loadError=0,e.fragmentError=0}),super.stopLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1}onManifestLoading(e,t){this.resetLevels()}onManifestLoaded(e,t){const r=this.hls.config.preferManagedMediaSource,i=[],n={},s={};let a=!1,o=!1,l=!1;t.levels.forEach(e=>{const t=e.attrs;let{audioCodec:c,videoCodec:d}=e;c&&(e.audioCodec=c=Mh(c,r)||void 0),d&&(d=e.videoCodec=function(e){const t=e.split(",");for(let e=0;e<t.length;e++){const r=t[e].split(".");r.length>2&&"avc1"===r[0]&&(t[e]=`avc1.${parseInt(r[1]).toString(16)}${("000"+parseInt(r[2]).toString(16)).slice(-4)}`)}return t.join(",")}(d));const{width:u,height:h,unknownCodecs:f}=e,p=(null==f?void 0:f.length)||0;if(a||(a=!(!u||!h)),o||(o=!!d),l||(l=!!c),p||c&&!this.isAudioSupported(c)||d&&!this.isVideoSupported(d))return void this.log(`Some or all CODECS not supported "${t.CODECS}"`);const{CODECS:m,"FRAME-RATE":g,"HDCP-LEVEL":v,"PATHWAY-ID":y,RESOLUTION:b,"VIDEO-RANGE":E}=t,w=`${`${y||"."}-`}${e.bitrate}-${b}-${g}-${m}-${E}-${v}`;if(n[w])if(n[w].uri===e.url||e.attrs["PATHWAY-ID"])n[w].addGroupId("audio",t.AUDIO),n[w].addGroupId("text",t.SUBTITLES);else{const t=s[w]+=1;e.attrs["PATHWAY-ID"]=new Array(t+1).join(".");const r=this.createLevel(e);n[w]=r,i.push(r)}else{const t=this.createLevel(e);n[w]=t,s[w]=1,i.push(t)}}),this.filterAndSortMediaOptions(i,t,a,o,l)}createLevel(e){const t=new tf(e),r=e.supplemental;if(null!=r&&r.videoCodec&&!this.isVideoSupported(r.videoCodec)){const e=new Error(`SUPPLEMENTAL-CODECS not supported "${r.videoCodec}"`);this.log(e.message),t.supportedResult=jh(e,[])}return t}isAudioSupported(e){return Lh(e,"audio",this.hls.config.preferManagedMediaSource)}isVideoSupported(e){return Lh(e,"video",this.hls.config.preferManagedMediaSource)}filterAndSortMediaOptions(e,t,r,i,n){var s;let a=[],o=[],l=e;const c=(null==(s=t.stats)?void 0:s.parsing)||{};if((r||i)&&n&&(l=l.filter(({videoCodec:e,videoRange:t,width:r,height:i})=>{return(!!e||!(!r||!i))&&(!!(n=t)&&qh.indexOf(n)>-1);var n})),0===l.length)return Promise.resolve().then(()=>{if(this.hls){let e="no level with compatible codecs found in manifest",r=e;t.levels.length&&(r=`one or more CODECS in variant not supported: ${sf(t.levels.map(e=>e.attrs.CODECS).filter((e,t,r)=>r.indexOf(e)===t))}`,this.warn(r),e+=` (${r})`);const i=new Error(e);this.hls.trigger(cu.ERROR,{type:ou.MEDIA_ERROR,details:lu.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:i,reason:r})}}),void(c.end=performance.now());t.audioTracks&&(a=t.audioTracks.filter(e=>!e.audioCodec||this.isAudioSupported(e.audioCodec)),oE(a)),t.subtitles&&(o=t.subtitles,oE(o));const d=l.slice(0);l.sort((e,t)=>{if(e.attrs["HDCP-LEVEL"]!==t.attrs["HDCP-LEVEL"])return(e.attrs["HDCP-LEVEL"]||"")>(t.attrs["HDCP-LEVEL"]||"")?1:-1;if(r&&e.height!==t.height)return e.height-t.height;if(e.frameRate!==t.frameRate)return e.frameRate-t.frameRate;if(e.videoRange!==t.videoRange)return qh.indexOf(e.videoRange)-qh.indexOf(t.videoRange);if(e.videoCodec!==t.videoCodec){const r=Ch(e.videoCodec),i=Ch(t.videoCodec);if(r!==i)return i-r}if(e.uri===t.uri&&e.codecSet!==t.codecSet){const r=Dh(e.codecSet),i=Dh(t.codecSet);if(r!==i)return i-r}return e.averageBitrate!==t.averageBitrate?e.averageBitrate-t.averageBitrate:0});let u=d[0];if(this.steering&&(l=this.steering.filterParsedLevels(l),l.length!==d.length))for(let e=0;e<d.length;e++)if(d[e].pathwayId===l[0].pathwayId){u=d[e];break}this._levels=l;for(let e=0;e<l.length;e++)if(l[e]===u){var h;this._firstLevel=e;const t=u.bitrate,r=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${l.length} level(s) found, first bitrate: ${t}`),void 0===(null==(h=this.hls.userConfig)?void 0:h.abrEwmaDefaultEstimate)){const e=Math.min(t,this.hls.config.abrEwmaDefaultEstimateMax);e>r&&r===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=e)}break}const f=n&&!i,p=this.hls.config,m=!(!p.audioStreamController||!p.audioTrackController),g={levels:l,audioTracks:a,subtitleTracks:o,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:n,video:i,altAudio:m&&!f&&a.some(e=>!!e.url)};c.end=performance.now(),this.hls.trigger(cu.MANIFEST_PARSED,g)}get levels(){return 0===this._levels.length?null:this._levels}get loadLevelObj(){return this.currentLevel}get level(){return this.currentLevelIndex}set level(e){const t=this._levels;if(0===t.length)return;if(e<0||e>=t.length){const r=new Error("invalid level idx"),i=e<0;if(this.hls.trigger(cu.ERROR,{type:ou.OTHER_ERROR,details:lu.LEVEL_SWITCH_ERROR,level:e,fatal:i,error:r,reason:r.message}),i)return;e=Math.min(e,t.length-1)}const r=this.currentLevelIndex,i=this.currentLevel,n=i?i.attrs["PATHWAY-ID"]:void 0,s=t[e],a=s.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=s,r===e&&i&&n===a)return;this.log(`Switching to level ${e} (${s.height?s.height+"p ":""}${s.videoRange?s.videoRange+" ":""}${s.codecSet?s.codecSet+" ":""}@${s.bitrate})${a?" with Pathway "+a:""} from level ${r}${n?" with Pathway "+n:""}`);const o={level:e,attrs:s.attrs,details:s.details,bitrate:s.bitrate,averageBitrate:s.averageBitrate,maxBitrate:s.maxBitrate,realBitrate:s.realBitrate,width:s.width,height:s.height,codecSet:s.codecSet,audioCodec:s.audioCodec,videoCodec:s.videoCodec,audioGroups:s.audioGroups,subtitleGroups:s.subtitleGroups,loaded:s.loaded,loadError:s.loadError,fragmentError:s.fragmentError,name:s.name,id:s.id,uri:s.uri,url:s.url,urlId:0,audioGroupIds:s.audioGroupIds,textGroupIds:s.textGroupIds};this.hls.trigger(cu.LEVEL_SWITCHING,o);const l=s.details;if(!l||l.live){const e=this.switchParams(s.uri,null==i?void 0:i.details,l);this.loadPlaylist(e)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e}get startLevel(){if(void 0===this._startLevel){const e=this.hls.config.startLevel;return void 0!==e?e:this.hls.firstAutoLevel}return this._startLevel}set startLevel(e){this._startLevel=e}get pathways(){return this.steering?this.steering.pathways():[]}get pathwayPriority(){return this.steering?this.steering.pathwayPriority:null}set pathwayPriority(e){if(this.steering){const t=this.steering.pathways(),r=e.filter(e=>-1!==t.indexOf(e));if(e.length<1)return void this.warn(`pathwayPriority ${e} should contain at least one pathway from list: ${t}`);this.steering.pathwayPriority=r}}onError(e,t){!t.fatal&&t.context&&t.context.type===uu&&t.context.level===this.level&&this.checkRetry(t)}onFragBuffered(e,{frag:t}){if(void 0!==t&&t.type===pu){const e=t.elementaryStreams;if(!Object.keys(e).some(t=>!!e[t]))return;const r=this._levels[t.level];null!=r&&r.loadError&&(this.log(`Resetting level error count of ${r.loadError} on frag buffered`),r.loadError=0)}}onLevelLoaded(e,t){var r;const{level:i,details:n}=t,s=t.levelInfo;var a;if(!s)return this.warn(`Invalid level index ${i}`),void(null!=(a=t.deliveryDirectives)&&a.skip&&(n.deltaUpdateFailed=!0));if(s===this.currentLevel||t.withoutMultiVariant){0===s.fragmentError&&(s.loadError=0);let e=s.details;e===t.details&&e.advanced&&(e=void 0),this.playlistLoaded(i,t,e)}else null!=(r=t.deliveryDirectives)&&r.skip&&(n.deltaUpdateFailed=!0)}loadPlaylist(e){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLoading(this.currentLevel,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);const r=this.getUrlWithDirectives(e.uri,t),i=this.currentLevelIndex,n=e.attrs["PATHWAY-ID"],s=e.details,a=null==s?void 0:s.age;this.log(`Loading level index ${i}${void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:""}${n?" Pathway "+n:""}${a&&s.live?" age "+a.toFixed(1)+(s.type&&" "+s.type||""):""} ${r}`),this.hls.trigger(cu.LEVEL_LOADING,{url:r,level:i,levelInfo:e,pathwayId:e.attrs["PATHWAY-ID"],id:0,deliveryDirectives:t||null})}get nextLoadLevel(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}removeLevel(e){var t;if(1===this._levels.length)return;const r=this._levels.filter((t,r)=>r!==e||(this.steering&&this.steering.removeLevel(t),t===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,t.details&&t.details.fragments.forEach(e=>e.level=-1)),!1));fm(r),this._levels=r,this.currentLevelIndex>-1&&null!=(t=this.currentLevel)&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.manualLevelIndex>-1&&(this.manualLevelIndex=this.currentLevelIndex);const i=r.length-1;this._firstLevel=Math.min(this._firstLevel,i),this._startLevel&&(this._startLevel=Math.min(this._startLevel,i)),this.hls.trigger(cu.LEVELS_UPDATED,{levels:r})}onLevelsUpdated(e,{levels:t}){this._levels=t}checkMaxAutoUpdated(){const{autoLevelCapping:e,maxAutoLevel:t,maxHdcpLevel:r}=this.hls;this._maxAutoLevel!==t&&(this._maxAutoLevel=t,this.hls.trigger(cu.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:r}))}}function oE(e){const t={};e.forEach(e=>{const r=e.groupId||"";e.id=t[r]=t[r]||0,t[r]++})}function lE(){return self.SourceBuffer||self.WebKitSourceBuffer}function cE(){if(!Pu())return!1;const e=lE();return!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove}class dE extends Nm{constructor(e,t,r){super(e,t,r,"stream-controller",pu),this.audioCodecSwap=!1,this.level=-1,this._forceStartLoad=!1,this._hasEnoughToStart=!1,this.altAudio=0,this.audioOnly=!1,this.fragPlaying=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this.onMediaPlaying=()=>{this.tick()},this.onMediaSeeked=()=>{const e=this.media,t=e?e.currentTime:null;if(null===t||!nu(t))return;if(this.log(`Media seeked to ${t.toFixed(3)}`),!this.getBufferedFrag(t))return;const r=this.getFwdBufferInfoAtPos(e,t,pu,0);null!==r&&0!==r.len?this.tick():this.warn(`Main forward buffer length at ${t} on "seeked" event ${r?r.len:"empty"})`)},this.registerListeners()}registerListeners(){super.registerListeners();const{hls:e}=this;e.on(cu.MANIFEST_PARSED,this.onManifestParsed,this),e.on(cu.LEVEL_LOADING,this.onLevelLoading,this),e.on(cu.LEVEL_LOADED,this.onLevelLoaded,this),e.on(cu.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(cu.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(cu.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(cu.BUFFER_CREATED,this.onBufferCreated,this),e.on(cu.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(cu.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(cu.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){super.unregisterListeners();const{hls:e}=this;e.off(cu.MANIFEST_PARSED,this.onManifestParsed,this),e.off(cu.LEVEL_LOADED,this.onLevelLoaded,this),e.off(cu.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(cu.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(cu.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(cu.BUFFER_CREATED,this.onBufferCreated,this),e.off(cu.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(cu.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(cu.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),super.onHandlerDestroying()}startLoad(e,t){if(this.levels){const{lastCurrentTime:r,hls:i}=this;if(this.stopLoad(),this.setInterval(100),this.level=-1,!this.startFragRequested){let e=i.startLevel;-1===e&&(i.config.testBandwidth&&this.levels.length>1?(e=0,this.bitrateTest=!0):e=i.firstAutoLevel),i.nextLoadLevel=e,this.level=i.loadLevel,this._hasEnoughToStart=!!t}r>0&&-1===e&&!t&&(this.log(`Override startPosition with lastCurrentTime @${r.toFixed(3)}`),e=r),this.state=Am,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}else this._forceStartLoad=!0,this.state=xm}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case Mm:{const{levels:e,level:t}=this,r=null==e?void 0:e[t],i=null==r?void 0:r.details;if(i&&(!i.live||this.levelLastLoaded===r&&!this.waitForLive(r))){if(this.waitForCdnTuneIn(i))break;this.state=Am;break}if(this.hls.nextLoadLevel!==this.level){this.state=Am;break}break}case Lm:this.checkRetryDate()}this.state===Am&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){var e;super.onTickEnd(),null!=(e=this.media)&&e.readyState&&!1===this.media.seeking&&(this.lastCurrentTime=this.media.currentTime),this.checkFragmentChanged()}doTickIdle(){const{hls:e,levelLastLoaded:t,levels:r,media:i}=this;if(null===t||!i&&!this.primaryPrefetch&&(this.startFragRequested||!e.config.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;const n=this.buffering?e.nextLoadLevel:e.loadLevel;if(null==r||!r[n])return;const s=r[n],a=this.getMainFwdBufferInfo();if(null===a)return;const o=this.getLevelDetails();if(o&&this._streamEnded(a,o)){const e={};return 2===this.altAudio&&(e.type="video"),this.hls.trigger(cu.BUFFER_EOS,e),void(this.state=Dm)}if(!this.buffering)return;e.loadLevel!==n&&-1===e.manualLevel&&this.log(`Adapting to level ${n} from level ${this.level}`),this.level=e.nextLoadLevel=n;const l=s.details;if(!l||this.state===Mm||this.waitForLive(s))return this.level=n,this.state=Mm,void(this.startFragRequested=!1);const c=a.len,d=this.getMaxBufferLength(s.maxBitrate);if(c>=d)return;this.backtrackFragment&&this.backtrackFragment.start>a.end&&(this.backtrackFragment=null);const u=this.backtrackFragment?this.backtrackFragment.start:a.end;let h=this.getNextFragment(u,l);if(this.couldBacktrack&&!this.fragPrevious&&h&&qu(h)&&this.fragmentTracker.getState(h)!==Bf){var f;const e=(null!=(f=this.backtrackFragment)?f:h).sn-l.startSN,t=l.fragments[e-1];t&&h.cc===t.cc&&(h=t,this.fragmentTracker.removeFragment(t))}else this.backtrackFragment&&a.len&&(this.backtrackFragment=null);if(h&&this.isLoopLoading(h,u)){if(!h.gap){const e=this.audioOnly&&!this.altAudio?Vu:Wu,t=(e===Wu?this.videoBuffer:this.mediaBuffer)||this.media;t&&this.afterBufferFlushed(t,e,pu)}h=this.getNextFragmentLoopLoading(h,l,a,pu,d)}h&&(!h.initSegment||h.initSegment.data||this.bitrateTest||(h=h.initSegment),this.loadFragment(h,s,u))}loadFragment(e,t,r){const i=this.fragmentTracker.getState(e);i===Nf||i===$f?qu(e)?this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):super.loadFragment(e,t,r):this._loadInitSegment(e,t):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,pu)}followingBufferedFrag(e){return e?this.getBufferedFrag(e.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){const{levels:e,media:t}=this;if(null!=t&&t.readyState){let r;const i=this.getAppendedFrag(t.currentTime);i&&i.start>1&&this.flushMainBuffer(0,i.start-1);const n=this.getLevelDetails();if(null!=n&&n.live){const e=this.getMainFwdBufferInfo();if(!e||e.len<2*n.targetduration)return}if(!t.paused&&e){const t=e[this.hls.nextLoadLevel],i=this.fragLastKbps;r=i&&this.fragCurrent?this.fragCurrent.duration*t.maxBitrate/(1e3*i)+1:0}else r=0;const s=this.getBufferedFrag(t.currentTime+r);if(s){const e=this.followingBufferedFrag(s);if(e){this.abortCurrentFrag();const t=e.maxStartPTS?e.maxStartPTS:e.start,r=e.duration,i=Math.max(s.end,t+Math.min(Math.max(r-this.config.maxFragLookUpTolerance,r*(this.couldBacktrack?.5:.125)),r*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(i,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){const e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case km:case Im:case Lm:case Pm:case Cm:this.state=Am}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,2===this.altAudio?"video":null)}onMediaAttached(e,t){super.onMediaAttached(e,t);const r=t.media;wm(r,"playing",this.onMediaPlaying),wm(r,"seeked",this.onMediaSeeked)}onMediaDetaching(e,t){const{media:r}=this;r&&(Sm(r,"playing",this.onMediaPlaying),Sm(r,"seeked",this.onMediaSeeked)),this.videoBuffer=null,this.fragPlaying=null,super.onMediaDetaching(e,t);!!t.transferMedia||(this._hasEnoughToStart=!1)}onManifestLoading(){super.onManifestLoading(),this.log("Trigger BUFFER_RESET"),this.hls.trigger(cu.BUFFER_RESET,void 0),this.couldBacktrack=!1,this.fragLastKbps=0,this.fragPlaying=this.backtrackFragment=null,this.altAudio=0,this.audioOnly=!1}onManifestParsed(e,t){let r=!1,i=!1;for(let e=0;e<t.levels.length;e++){const n=t.levels[e].audioCodec;n&&(r=r||-1!==n.indexOf("mp4a.40.2"),i=i||-1!==n.indexOf("mp4a.40.5"))}this.audioCodecSwitch=r&&i&&!function(){var e;const t=lE();return"function"==typeof(null==t||null==(e=t.prototype)?void 0:e.changeType)}(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1}onLevelLoading(e,t){const{levels:r}=this;if(!r||this.state!==Am)return;const i=t.levelInfo;(!i.details||i.details.live&&(this.levelLastLoaded!==i||i.details.expired)||this.waitForCdnTuneIn(i.details))&&(this.state=Mm)}onLevelLoaded(e,t){var r;const{levels:i,startFragRequested:n}=this,s=t.level,a=t.details,o=a.totalduration;if(!i)return void this.warn(`Levels were reset while loading level ${s}`);this.log(`Level ${s} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""}, cc [${a.startCC}, ${a.endCC}] duration:${o}`);const l=t.levelInfo,c=this.fragCurrent;!c||this.state!==Im&&this.state!==Lm||c.level!==t.level&&c.loader&&this.abortCurrentFrag();let d=0;if(a.live||null!=(r=l.details)&&r.live){var u;if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;d=this.alignPlaylists(a,l.details,null==(u=this.levelLastLoaded)?void 0:u.details)}if(l.details=a,this.levelLastLoaded=l,n||this.setStartPosition(a,d),this.hls.trigger(cu.LEVEL_UPDATED,{details:a,level:s}),this.state===Mm){if(this.waitForCdnTuneIn(a))return;this.state=Am}n&&a.live&&this.synchronizeToLiveEdge(a),this.tick()}synchronizeToLiveEdge(e){const{config:t,media:r}=this;if(!r)return;const i=this.hls.liveSyncPosition,n=this.getLoadPosition(),s=e.fragmentStart,a=e.edge,o=n>=s-t.maxFragLookUpTolerance&&n<=a;if(null!==i&&r.duration>i&&(n<i||!o)){const s=void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;if((!o&&r.readyState<4||n<a-s)&&(this._hasEnoughToStart||(this.nextLoadPosition=i),r.readyState))if(this.warn(`Playback: ${n.toFixed(3)} is located too far from the end of live sliding playlist: ${a}, reset currentTime to : ${i.toFixed(3)}`),"buffered"===this.config.liveSyncMode){var l;const e=np.bufferInfo(r,i,0);if(null==(l=e.buffered)||!l.length)return void(r.currentTime=i);if(e.start<=n)return void(r.currentTime=i);const{nextStart:t}=np.bufferedInfo(e.buffered,n,0);t&&(r.currentTime=t)}else r.currentTime=i}}_handleFragmentLoadProgress(e){var t;const r=e.frag,{part:i,payload:n}=e,{levels:s}=this;if(!s)return void this.warn(`Levels were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);const a=s[r.level];if(!a)return void this.warn(`Level ${r.level} not found on progress`);const o=a.details;if(!o)return this.warn(`Dropping fragment ${r.sn} of level ${r.level} after level details were reset`),void this.fragmentTracker.removeFragment(r);const l=a.videoCodec,c=o.PTSKnown||!o.live,d=null==(t=r.initSegment)?void 0:t.data,u=this._getAudioCodec(a),h=this.transmuxer=this.transmuxer||new fv(this.hls,pu,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),f=i?i.index:-1,p=-1!==f,m=new rp(r.level,r.sn,r.stats.chunkCount,n.byteLength,f,p),g=this.initPTS[r.cc];h.push(n,d,u,l,r,i,o.totalduration,c,m,g)}onAudioTrackSwitching(e,t){const r=this.hls,i=0!==this.altAudio;if(ff(t.url,r))this.altAudio=1;else{if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;const e=this.fragCurrent;e&&(this.log("Switching to main audio track, cancel main fragment load"),e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();if(i)return this.altAudio=0,this.fragmentTracker.removeAllFragments(),r.once(cu.BUFFER_FLUSHED,()=>{this.hls&&this.hls.trigger(cu.AUDIO_TRACK_SWITCHED,t)}),void r.trigger(cu.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});r.trigger(cu.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){const r=ff(t.url,this.hls);if(r){const e=this.videoBuffer;e&&this.mediaBuffer!==e&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=e)}this.altAudio=r?2:0,this.tick()}onBufferCreated(e,t){const r=t.tracks;let i,n,s=!1;for(const e in r){const t=r[e];if("main"===t.id){if(n=e,i=t,"video"===e){const t=r[e];t&&(this.videoBuffer=t.buffer)}}else s=!0}s&&i?(this.log(`Alternate track found, use ${n}.buffered to schedule main fragment loading`),this.mediaBuffer=i.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){const{frag:r,part:i}=t,n=r.type===pu;if(n){if(this.fragContextChanged(r))return this.warn(`Fragment ${r.sn}${i?" p: "+i.index:""} of level ${r.level} finished buffering, but was aborted. state: ${this.state}`),void(this.state===Cm&&(this.state=Am));const e=i?i.stats:r.stats;this.fragLastKbps=Math.round(8*e.total/(e.buffering.end-e.loading.first)),qu(r)&&(this.fragPrevious=r),this.fragBufferedComplete(r,i)}const s=this.media;s&&(!this._hasEnoughToStart&&np.getBuffered(s).length&&(this._hasEnoughToStart=!0,this.seekToStartPos()),n&&this.tick())}get hasEnoughToStart(){return this._hasEnoughToStart}onError(e,t){var r;if(t.fatal)this.state=_m;else switch(t.details){case lu.FRAG_GAP:case lu.FRAG_PARSING_ERROR:case lu.FRAG_DECRYPT_ERROR:case lu.FRAG_LOAD_ERROR:case lu.FRAG_LOAD_TIMEOUT:case lu.KEY_LOAD_ERROR:case lu.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(pu,t);break;case lu.LEVEL_LOAD_ERROR:case lu.LEVEL_LOAD_TIMEOUT:case lu.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==Mm||(null==(r=t.context)?void 0:r.type)!==uu||(this.state=Am);break;case lu.BUFFER_ADD_CODEC_ERROR:case lu.BUFFER_APPEND_ERROR:if("main"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)&&this.resetLoadingState();break;case lu.BUFFER_FULL_ERROR:if("main"!==t.parent)return;if(this.reduceLengthAndFlushBuffer(t)){!this.config.interstitialsController&&this.config.assetPlayerId?this._hasEnoughToStart=!0:this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}break;case lu.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}onFragLoadEmergencyAborted(){this.state=Am,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==Vu||!this.altAudio){const e=(t===Wu?this.videoBuffer:this.mediaBuffer)||this.media;e&&(this.afterBufferFlushed(e,t,pu),this.tick())}}onLevelsUpdated(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level,-1===this.level&&this.resetWhenMissingContext(this.fragCurrent)),this.levels=t.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){const{media:e}=this;if(!e)return;const t=e.currentTime;let r=this.startPosition;if(r>=0&&t<r){if(e.seeking)return void this.log(`could not seek to ${r}, already seeking at ${t}`);const i=this.timelineOffset;i&&r&&(r+=i);const n=this.getLevelDetails(),s=np.getBuffered(e),a=s.length?s.start(0):0,o=a-r,l=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);(this.config.startOnSegmentBoundary||o>0&&(o<l||this.loadingParts&&o<2*((null==n?void 0:n.partTarget)||0)))&&(this.log(`adjusting start position by ${o} to match buffer start`),r+=o,this.startPosition=r),t<r&&(this.log(`seek to target start position ${r} from current time ${t} buffer start ${a}`),e.currentTime=r)}}_getAudioCodec(e){let t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t=-1!==t.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),t}_loadBitrateTestFrag(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then(e=>{const{hls:r}=this,i=null==e?void 0:e.frag;if(!i||this.fragContextChanged(i))return;t.fragmentError=0,this.state=Am,this.startFragRequested=!1,this.bitrateTest=!1;const n=i.stats;n.parsing.start=n.parsing.end=n.buffering.start=n.buffering.end=self.performance.now(),r.trigger(cu.FRAG_LOADED,e),i.bitrateTest=!1}).catch(t=>{this.state!==xm&&this.state!==_m&&(this.warn(t),this.resetFragmentLoading(e))})}_handleTransmuxComplete(e){const t=this.playlistType,{hls:r}=this,{remuxResult:i,chunkMeta:n}=e,s=this.getCurrentContext(n);if(!s)return void this.resetWhenMissingContext(n);const{frag:a,part:o,level:l}=s,{video:c,text:d,id3:u,initSegment:h}=i,{details:f}=l,p=this.altAudio?void 0:i.audio;if(this.fragContextChanged(a))this.fragmentTracker.removeFragment(a);else{if(this.state=Pm,h){const e=h.tracks;if(e){const i=a.initSegment||a;if(this.unhandledEncryptionError(h,a))return;this._bufferInitSegment(l,e,i,n),r.trigger(cu.FRAG_PARSING_INIT_SEGMENT,{frag:i,id:t,tracks:e})}const i=h.initPTS,s=h.timescale,o=this.initPTS[a.cc];if(nu(i)&&(!o||o.baseTime!==i||o.timescale!==s)){const e=h.trackId;this.initPTS[a.cc]={baseTime:i,timescale:s,trackId:e},r.trigger(cu.INIT_PTS_FOUND,{frag:a,id:t,initPTS:i,timescale:s,trackId:e})}}if(c&&f){p&&"audiovideo"===c.type&&this.logMuxedErr(a);const e=f.fragments[a.sn-1-f.startSN],t=a.sn===f.startSN,r=!e||a.cc>e.cc;if(!1!==i.independent){const{startPTS:e,endPTS:i,startDTS:s,endDTS:l}=c;if(o)o.elementaryStreams[c.type]={startPTS:e,endPTS:i,startDTS:s,endDTS:l};else if(c.firstKeyFrame&&c.independent&&1===n.id&&!r&&(this.couldBacktrack=!0),c.dropped&&c.independent){const n=this.getMainFwdBufferInfo(),s=(n?n.end:this.getLoadPosition())+this.config.maxBufferHole,o=c.firstKeyFramePTS?c.firstKeyFramePTS:e;if(!t&&s<o-this.config.maxBufferHole&&!r)return void this.backtrack(a);r&&(a.gap=!0),a.setElementaryStreamInfo(c.type,a.start,i,a.start,l,!0)}else t&&e-(f.appliedTimelineOffset||0)>2&&(a.gap=!0);a.setElementaryStreamInfo(c.type,e,i,s,l),this.backtrackFragment&&(this.backtrackFragment=a),this.bufferFragmentData(c,a,o,n,t||r)}else{if(!t&&!r)return void this.backtrack(a);a.gap=!0}}if(p){const{startPTS:e,endPTS:t,startDTS:r,endDTS:i}=p;o&&(o.elementaryStreams[Vu]={startPTS:e,endPTS:t,startDTS:r,endDTS:i}),a.setElementaryStreamInfo(Vu,e,t,r,i),this.bufferFragmentData(p,a,o,n)}if(f&&null!=u&&u.samples.length){const e={id:t,frag:a,details:f,samples:u.samples};r.trigger(cu.FRAG_PARSING_METADATA,e)}if(f&&d){const e={id:t,frag:a,details:f,samples:d.samples};r.trigger(cu.FRAG_PARSING_USERDATA,e)}}}logMuxedErr(e){this.warn(`${qu(e)?"Media":"Init"} segment with muxed audiovideo where only video expected: ${e.url}`)}_bufferInitSegment(e,t,r,i){if(this.state!==Pm)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&(delete t.audio,t.audiovideo&&this.logMuxedErr(r));const{audio:n,video:s,audiovideo:a}=t;if(n){const r=e.audioCodec;let i=Nh(n.codec,r);"mp4a"===i&&(i="mp4a.40.5");const s=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){i&&(i=-1!==i.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5");const e=n.metadata;e&&"channelCount"in e&&1!==(e.channelCount||1)&&-1===s.indexOf("firefox")&&(i="mp4a.40.5")}i&&-1!==i.indexOf("mp4a.40.5")&&-1!==s.indexOf("android")&&"audio/mpeg"!==n.container&&(i="mp4a.40.2",this.log(`Android: force audio codec to ${i}`)),r&&r!==i&&this.log(`Swapping manifest audio codec "${r}" for "${i}"`),n.levelCodec=i,n.id=pu,this.log(`Init audio buffer, container:${n.container}, codecs[selected/level/parsed]=[${i||""}/${r||""}/${n.codec}]`),delete t.audiovideo}if(s){s.levelCodec=e.videoCodec,s.id=pu;const r=s.codec;if(4===(null==r?void 0:r.length))switch(r){case"hvc1":case"hev1":s.codec="hvc1.1.6.L120.90";break;case"av01":s.codec="av01.0.04M.08";break;case"avc1":s.codec="avc1.42e01e"}this.log(`Init video buffer, container:${s.container}, codecs[level/parsed]=[${e.videoCodec||""}/${r}]${s.codec!==r?" parsed-corrected="+s.codec:""}${s.supplemental?" supplemental="+s.supplemental:""}`),delete t.audiovideo}a&&(this.log(`Init audiovideo buffer, container:${a.container}, codecs[level/parsed]=[${e.codecs}/${a.codec}]`),delete t.video,delete t.audio);const o=Object.keys(t);if(o.length){if(this.hls.trigger(cu.BUFFER_CODECS,t),!this.hls)return;o.forEach(e=>{const n=t[e].initSegment;null!=n&&n.byteLength&&this.hls.trigger(cu.BUFFER_APPENDING,{type:e,data:n,frag:r,part:null,chunkMeta:i,parent:r.type})})}this.tickImmediate()}getMainFwdBufferInfo(){const e=this.mediaBuffer&&2===this.altAudio?this.mediaBuffer:this.media;return this.getFwdBufferInfo(e,pu)}get maxBufferLength(){const{levels:e,level:t}=this,r=null==e?void 0:e[t];return r?this.getMaxBufferLength(r.maxBitrate):this.config.maxBufferLength}backtrack(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=Am}checkFragmentChanged(){const e=this.media;let t=null;if(e&&e.readyState>1&&!1===e.seeking){const r=e.currentTime;if(np.isBuffered(e,r)?t=this.getAppendedFrag(r):np.isBuffered(e,r+.1)&&(t=this.getAppendedFrag(r+.1)),t){this.backtrackFragment=null;const e=this.fragPlaying,r=t.level;e&&t.sn===e.sn&&e.level===r||(this.fragPlaying=t,this.hls.trigger(cu.FRAG_CHANGED,{frag:t}),e&&e.level===r||this.hls.trigger(cu.LEVEL_SWITCHED,{level:r}))}}}get nextLevel(){const e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){var e;if(this.fragPlaying)return this.fragPlaying;const t=(null==(e=this.media)?void 0:e.currentTime)||this.lastCurrentTime;return nu(t)?this.getAppendedFrag(t):null}get currentProgramDateTime(){var e;const t=(null==(e=this.media)?void 0:e.currentTime)||this.lastCurrentTime;if(nu(t)){const e=this.getLevelDetails(),r=this.currentFrag||(e?mf(null,e.fragments,t):null);if(r){const e=r.programDateTime;if(null!==e){const i=e+1e3*(t-r.start);return new Date(i)}}}return null}get currentLevel(){const e=this.currentFrag;return e?e.level:-1}get nextBufferedFrag(){const e=this.currentFrag;return e?this.followingBufferedFrag(e):null}get forceStartLoad(){return this._forceStartLoad}}class uE extends Tu{constructor(e,t){super("key-loader",t),this.config=void 0,this.keyIdToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(const r in this.keyIdToKeyInfo){const i=this.keyIdToKeyInfo[r].loader;if(i){var t;if(e&&e!==(null==(t=i.context)?void 0:t.frag.type))return;i.abort()}}}detach(){for(const e in this.keyIdToKeyInfo){const t=this.keyIdToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyIdToKeyInfo[e]}}destroy(){this.detach();for(const e in this.keyIdToKeyInfo){const t=this.keyIdToKeyInfo[e].loader;t&&t.destroy()}this.keyIdToKeyInfo={}}createKeyLoadError(e,t=lu.KEY_LOAD_ERROR,r,i,n){return new ep({type:ou.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:n,error:r,networkDetails:i})}loadClear(e,t,r){if(this.emeController&&this.config.emeEnabled&&!this.emeController.getSelectedKeySystemFormats().length){if(t.length)for(let i=0,n=t.length;i<n;i++){const s=t[i];if(e.cc<=s.cc&&(!qu(e)||!qu(s)||e.sn<s.sn)||!r&&i==n-1)return this.emeController.selectKeySystemFormat(s).then(e=>{if(!this.emeController)return;s.setKeyFormat(e);const t=Cp(e);return t?this.emeController.getKeySystemAccess([t]):void 0})}if(this.config.requireKeySystemAccessOnStart){const e=_p(this.config);if(e.length)return this.emeController.getKeySystemAccess(e)}}return null}load(e){return!e.decryptdata&&e.encrypted&&this.emeController&&this.config.emeEnabled?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}loadInternal(e,t){var r,i;t&&e.setKeyFormat(t);const n=e.decryptdata;if(!n){const r=new Error(t?`Expected frag.decryptdata to be defined after setting format ${t}`:`Missing decryption data on fragment in onKeyLoading (emeEnabled with controller: ${this.emeController&&this.config.emeEnabled})`);return Promise.reject(this.createKeyLoadError(e,lu.KEY_LOAD_ERROR,r))}const s=n.uri;if(!s)return Promise.reject(this.createKeyLoadError(e,lu.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${s}"`)));const a=hE(n);let o=this.keyIdToKeyInfo[a];if(null!=(r=o)&&r.decryptdata.key)return n.key=o.decryptdata.key,Promise.resolve({frag:e,keyInfo:o});if(this.emeController&&null!=(i=o)&&i.keyLoadPromise){switch(this.emeController.getKeyStatus(o.decryptdata)){case"usable":case"usable-in-future":return o.keyLoadPromise.then(t=>{const{keyInfo:r}=t;return n.key=r.decryptdata.key,{frag:e,keyInfo:r}})}}switch(this.log(`${this.keyIdToKeyInfo[a]?"Rel":"L"}oading${n.keyId?" keyId: "+_u(n.keyId):""} URI: ${n.uri} from ${e.type} ${e.level}`),o=this.keyIdToKeyInfo[a]={decryptdata:n,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},n.method){case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===n.keyFormat?this.loadKeyHTTP(o,e):this.loadKeyEME(o,e);case"AES-128":case"AES-256":case"AES-256-CTR":return this.loadKeyHTTP(o,e);default:return Promise.reject(this.createKeyLoadError(e,lu.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${n.method}"`)))}}loadKeyEME(e,t){const r={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var i;if(!e.decryptdata.keyId&&null!=(i=t.initSegment)&&i.data){const r=function(e){const t=[];return mh(e,e=>t.push(e.subarray(8,24))),t}(t.initSegment.data);if(r.length){let t=r[0];t.some(e=>0!==e)?(this.log(`Using keyId found in init segment ${_u(t)}`),$p.setKeyIdForUri(e.decryptdata.uri,t)):(t=$p.addKeyIdForUri(e.decryptdata.uri),this.log(`Generating keyId to patch media ${_u(t)}`)),e.decryptdata.keyId=t}}if(!e.decryptdata.keyId&&!qu(t))return Promise.resolve(r);const n=this.emeController.loadKey(r);return(e.keyLoadPromise=n.then(t=>(e.mediaKeySessionContext=t,r))).catch(r=>{throw e.keyLoadPromise=null,"data"in r&&(r.data.frag=t),r})}return Promise.resolve(r)}loadKeyHTTP(e,t){const r=this.config,i=new(0,r.loader)(r);return t.keyLoader=e.loader=i,e.keyLoadPromise=new Promise((n,s)=>{const a={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},o=r.keyLoadPolicy.default,l={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(e,t,r,i)=>{const{frag:a,keyInfo:o}=r,l=hE(o.decryptdata);if(!a.decryptdata||o!==this.keyIdToKeyInfo[l])return s(this.createKeyLoadError(a,lu.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),i));o.decryptdata.key=a.decryptdata.key=new Uint8Array(e.data),a.keyLoader=null,o.loader=null,n({frag:a,keyInfo:o})},onError:(e,r,i,n)=>{this.resetLoader(r),s(this.createKeyLoadError(t,lu.KEY_LOAD_ERROR,new Error(`HTTP Error ${e.code} loading key ${e.text}`),i,Su({url:a.url,data:void 0},e)))},onTimeout:(e,r,i)=>{this.resetLoader(r),s(this.createKeyLoadError(t,lu.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),i))},onAbort:(e,r,i)=>{this.resetLoader(r),s(this.createKeyLoadError(t,lu.INTERNAL_ABORTED,new Error("key loading aborted"),i))}};i.load(a,l,c)})}resetLoader(e){const{frag:t,keyInfo:r,url:i}=e,n=r.loader;t.keyLoader===n&&(t.keyLoader=null,r.loader=null);const s=hE(r.decryptdata)||i;delete this.keyIdToKeyInfo[s],n&&n.destroy()}}function hE(e){if(e.keyFormat!==Lp){const t=e.keyId;if(t)return _u(t)}return e.uri}function fE(e){const{type:t}=e;switch(t){case hu:return mu;case fu:return gu;default:return pu}}function pE(e,t){let r=e.url;return void 0!==r&&0!==r.indexOf("data:")||(r=t.url),r}class mE{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:e}=this;e.on(cu.MANIFEST_LOADING,this.onManifestLoading,this),e.on(cu.LEVEL_LOADING,this.onLevelLoading,this),e.on(cu.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(cu.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.on(cu.LEVELS_UPDATED,this.onLevelsUpdated,this)}unregisterListeners(){const{hls:e}=this;e.off(cu.MANIFEST_LOADING,this.onManifestLoading,this),e.off(cu.LEVEL_LOADING,this.onLevelLoading,this),e.off(cu.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(cu.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.off(cu.LEVELS_UPDATED,this.onLevelsUpdated,this)}createInternalLoader(e){const t=this.hls.config,r=t.pLoader,i=t.loader,n=new(r||i)(t);return this.loaders[e.type]=n,n}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e]}destroyInternalLoaders(){for(const e in this.loaders){const t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,t){const{url:r}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:du,url:r,deliveryDirectives:null,levelOrTrack:null})}onLevelLoading(e,t){const{id:r,level:i,pathwayId:n,url:s,deliveryDirectives:a,levelInfo:o}=t;this.load({id:r,level:i,pathwayId:n,responseType:"text",type:uu,url:s,deliveryDirectives:a,levelOrTrack:o})}onAudioTrackLoading(e,t){const{id:r,groupId:i,url:n,deliveryDirectives:s,track:a}=t;this.load({id:r,groupId:i,level:null,responseType:"text",type:hu,url:n,deliveryDirectives:s,levelOrTrack:a})}onSubtitleTrackLoading(e,t){const{id:r,groupId:i,url:n,deliveryDirectives:s,track:a}=t;this.load({id:r,groupId:i,level:null,responseType:"text",type:fu,url:n,deliveryDirectives:s,levelOrTrack:a})}onLevelsUpdated(e,t){const r=this.loaders[uu];if(r){const e=r.context;e&&!t.levels.some(t=>t===e.levelOrTrack)&&(r.abort(),delete this.loaders[uu])}}load(e){var t;const r=this.hls.config;let i,n=this.getInternalLoader(e);if(n){const t=this.hls.logger,r=n.context;if(r&&r.levelOrTrack===e.levelOrTrack&&(r.url===e.url||r.deliveryDirectives&&!e.deliveryDirectives))return void(r.url===e.url?t.log(`[playlist-loader]: ignore ${e.url} ongoing request`):t.log(`[playlist-loader]: ignore ${e.url} in favor of ${r.url}`));t.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),n.abort()}if(i=e.type===du?r.manifestLoadPolicy.default:Eu({},r.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),n=this.createInternalLoader(e),nu(null==(t=e.deliveryDirectives)?void 0:t.part)){let t;if(e.type===uu&&null!==e.level?t=this.hls.levels[e.level].details:e.type===hu&&null!==e.id?t=this.hls.audioTracks[e.id].details:e.type===fu&&null!==e.id&&(t=this.hls.subtitleTracks[e.id].details),t){const e=t.partTarget,r=t.targetduration;if(e&&r){const t=1e3*Math.max(3*e,.8*r);i=Eu({},i,{maxTimeToFirstByteMs:Math.min(t,i.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(t,i.maxTimeToFirstByteMs)})}}}const s=i.errorRetry||i.timeoutRetry||{},a={loadPolicy:i,timeout:i.maxLoadTimeMs,maxRetry:s.maxNumRetry||0,retryDelay:s.retryDelayMs||0,maxRetryDelay:s.maxRetryDelayMs||0},o={onSuccess:(e,t,r,i)=>{const n=this.getInternalLoader(r);this.resetInternalLoader(r.type);const s=e.data;t.parsing.start=performance.now(),Vp.isMediaPlaylist(s)||r.type!==du?this.handleTrackOrLevelPlaylist(e,t,r,i||null,n):this.handleMasterPlaylist(e,t,r,i)},onError:(e,t,r,i)=>{this.handleNetworkError(t,r,!1,e,i)},onTimeout:(e,t,r)=>{this.handleNetworkError(t,r,!0,void 0,e)}};n.load(e,a,o)}checkAutostartLoad(){if(!this.hls)return;const{config:{autoStartLoad:e,startPosition:t},forceStartLoad:r}=this.hls;(e||r)&&(this.hls.logger.log(`${e?"auto":"force"} startLoad with configured startPosition ${t}`),this.hls.startLoad(t))}handleMasterPlaylist(e,t,r,i){const n=this.hls,s=e.data,a=pE(e,r),o=Vp.parseMasterPlaylist(s,a);if(o.playlistParsingError)return t.parsing.end=performance.now(),void this.handleManifestParsingError(e,r,o.playlistParsingError,i,t);const{contentSteering:l,levels:c,sessionData:d,sessionKeys:u,startTimeOffset:h,variableList:f}=o;this.variableList=f,c.forEach(e=>{const{unknownCodecs:t}=e;if(t){const{preferManagedMediaSource:r}=this.hls.config;let{audioCodec:i,videoCodec:n}=e;for(let s=t.length;s--;){const a=t[s];Lh(a,"audio",r)?(e.audioCodec=i=i?`${i},${a}`:a,kh.audio[i.substring(0,4)]=2,t.splice(s,1)):Lh(a,"video",r)&&(e.videoCodec=n=n?`${n},${a}`:a,kh.video[n.substring(0,4)]=2,t.splice(s,1))}}});const{AUDIO:p=[],SUBTITLES:m,"CLOSED-CAPTIONS":g}=Vp.parseMasterPlaylistMedia(s,a,o);if(p.length){p.some(e=>!e.url)||!c[0].audioCodec||c[0].attrs.AUDIO||(this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),p.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new hp({}),bitrate:0,url:""}))}n.trigger(cu.MANIFEST_LOADED,{levels:c,audioTracks:p,subtitles:m,captions:g,contentSteering:l,url:a,stats:t,networkDetails:i,sessionData:d,sessionKeys:u,startTimeOffset:h,variableList:f})}handleTrackOrLevelPlaylist(e,t,r,i,n){const s=this.hls,{id:a,level:o,type:l}=r,c=pE(e,r),d=nu(o)?o:nu(a)?a:0,u=fE(r),h=Vp.parseLevelPlaylist(e.data,c,d,u,0,this.variableList);if(l===du){const e={attrs:new hp({}),bitrate:0,details:h,name:"",url:c};h.requestScheduled=t.loading.start+cm(h,0),s.trigger(cu.MANIFEST_LOADED,{levels:[e],audioTracks:[],url:c,stats:t,networkDetails:i,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),r.levelDetails=h,this.handlePlaylistLoaded(h,e,t,r,i,n)}handleManifestParsingError(e,t,r,i,n){this.hls.trigger(cu.ERROR,{type:ou.NETWORK_ERROR,details:lu.MANIFEST_PARSING_ERROR,fatal:t.type===du,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:i,stats:n})}handleNetworkError(e,t,r=!1,i,n){let s=`A network ${r?"timeout":"error"+(i?" (status "+i.code+")":"")} occurred while loading ${e.type}`;e.type===uu?s+=`: ${e.level} id: ${e.id}`:e.type!==hu&&e.type!==fu||(s+=` id: ${e.id} group-id: "${e.groupId}"`);const a=new Error(s);this.hls.logger.warn(`[playlist-loader]: ${s}`);let o=lu.UNKNOWN,l=!1;const c=this.getInternalLoader(e);switch(e.type){case du:o=r?lu.MANIFEST_LOAD_TIMEOUT:lu.MANIFEST_LOAD_ERROR,l=!0;break;case uu:o=r?lu.LEVEL_LOAD_TIMEOUT:lu.LEVEL_LOAD_ERROR,l=!1;break;case hu:o=r?lu.AUDIO_TRACK_LOAD_TIMEOUT:lu.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case fu:o=r?lu.SUBTITLE_TRACK_LOAD_TIMEOUT:lu.SUBTITLE_LOAD_ERROR,l=!1}c&&this.resetInternalLoader(e.type);const d={type:ou.NETWORK_ERROR,details:o,fatal:l,url:e.url,loader:c,context:e,error:a,networkDetails:t,stats:n};if(i){const r=(null==t?void 0:t.url)||e.url;d.response=Su({url:r,data:void 0},i)}this.hls.trigger(cu.ERROR,d)}handlePlaylistLoaded(e,t,r,i,n,s){const a=this.hls,{type:o,level:l,levelOrTrack:c,id:d,groupId:u,deliveryDirectives:h}=i,f=pE(t,i),p=fE(i);let m="number"==typeof i.level&&p===pu?l:void 0;const g=e.playlistParsingError;if(g){if(this.hls.logger.warn(`${g} ${e.url}`),!a.config.ignorePlaylistParsingErrors)return void a.trigger(cu.ERROR,{type:ou.NETWORK_ERROR,details:lu.LEVEL_PARSING_ERROR,fatal:!1,url:f,error:g,reason:g.message,response:t,context:i,level:m,parent:p,networkDetails:n,stats:r});e.playlistParsingError=null}if(!e.fragments.length){const s=e.playlistParsingError=new Error("No Segments found in Playlist");return void a.trigger(cu.ERROR,{type:ou.NETWORK_ERROR,details:lu.LEVEL_EMPTY_ERROR,fatal:!1,url:f,error:s,reason:s.message,response:t,context:i,level:m,parent:p,networkDetails:n,stats:r})}switch(e.live&&s&&(s.getCacheAge&&(e.ageHeader=s.getCacheAge()||0),s.getCacheAge&&!isNaN(e.ageHeader)||(e.ageHeader=0)),o){case du:case uu:if(m)if(c){if(c!==a.levels[m]){const e=a.levels.indexOf(c);e>-1&&(m=e)}}else m=0;a.trigger(cu.LEVEL_LOADED,{details:e,levelInfo:c||a.levels[0],level:m||0,id:d||0,stats:r,networkDetails:n,deliveryDirectives:h,withoutMultiVariant:o===du});break;case hu:a.trigger(cu.AUDIO_TRACK_LOADED,{details:e,track:c,id:d||0,groupId:u||"",stats:r,networkDetails:n,deliveryDirectives:h});break;case fu:a.trigger(cu.SUBTITLE_TRACK_LOADED,{details:e,track:c,id:d||0,groupId:u||"",stats:r,networkDetails:n,deliveryDirectives:h})}}}class gE{static get version(){return jm}static isMSESupported(){return cE()}static isSupported(){return function(){if(!cE())return!1;const e=Pu();return"function"==typeof(null==e?void 0:e.isTypeSupported)&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(t=>e.isTypeSupported(Ph(t,"video")))||["mp4a.40.2","fLaC"].some(t=>e.isTypeSupported(Ph(t,"audio"))))}()}static getMediaSource(){return Pu()}static get Events(){return cu}static get MetadataSchema(){return hg}static get ErrorTypes(){return ou}static get ErrorDetails(){return lu}static get DefaultConfig(){return gE.defaultConfig?gE.defaultConfig:Kb}static set DefaultConfig(e){gE.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.logger=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new Gm,this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioStreamController=void 0,this.subtititleStreamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.interstitialsController=void 0,this.gapController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this._url=null,this._sessionId=void 0,this.triggeringException=void 0,this.started=!1;const t=this.logger=function(e,t,r){const i=ku();if("object"==typeof console&&!0===e||"object"==typeof e){const n=["debug","log","info","warn","error"];n.forEach(t=>{i[t]=Iu(t,e,r)});try{i.log(`Debug logs enabled for "${t}" in hls.js version 1.6.15`)}catch(e){return ku()}n.forEach(t=>{Lu[t]=Iu(t,e)})}else Eu(Lu,i);return i}(e.debug||!1,"Hls instance",e.assetPlayerId),r=this.config=function(e,t,r){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==t.liveMaxLatencyDurationCount&&(void 0===t.liveSyncDurationCount||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==t.liveMaxLatencyDuration&&(void 0===t.liveSyncDuration||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const i=qb(e),n=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach(e=>{const s=`${"level"===e?"playlist":e}LoadPolicy`,a=void 0===t[s],o=[];n.forEach(r=>{const n=`${e}Loading${r}`,l=t[n];if(void 0!==l&&a){o.push(n);const e=i[s].default;switch(t[s]={default:e},r){case"TimeOut":e.maxLoadTimeMs=l,e.maxTimeToFirstByteMs=l;break;case"MaxRetry":e.errorRetry.maxNumRetry=l,e.timeoutRetry.maxNumRetry=l;break;case"RetryDelay":e.errorRetry.retryDelayMs=l,e.timeoutRetry.retryDelayMs=l;break;case"MaxRetryTimeout":e.errorRetry.maxRetryDelayMs=l,e.timeoutRetry.maxRetryDelayMs=l}}}),o.length&&r.warn(`hls.js config: "${o.join('", "')}" setting(s) are deprecated, use "${s}": ${sf(t[s])}`)}),Su(Su({},i),t)}(gE.DefaultConfig,e,t);this.userConfig=e,r.progressive&&Xb(r,t);const{abrController:i,bufferController:n,capLevelController:s,errorController:a,fpsController:o}=r,l=new a(this),c=this.abrController=new i(this),d=new Uf(this),u=r.interstitialsController,h=u?this.interstitialsController=new u(this,gE):null,f=this.bufferController=new n(this,d),p=this.capLevelController=new s(this),m=new o(this),g=new mE(this),v=r.contentSteeringController,y=v?new v(this):null,b=this.levelController=new aE(this,y),E=new nE(this),w=new uE(this.config,this.logger),S=this.streamController=new dE(this,d,w),T=this.gapController=new Qb(this,d);p.setStreamController(S),m.setStreamController(S);const x=[g,b,S];h&&x.splice(1,0,h),y&&x.splice(1,0,y),this.networkControllers=x;const A=[c,f,T,p,m,E,d];this.audioTrackController=this.createController(r.audioTrackController,x);const k=r.audioStreamController;k&&x.push(this.audioStreamController=new k(this,d,w)),this.subtitleTrackController=this.createController(r.subtitleTrackController,x);const I=r.subtitleStreamController;I&&x.push(this.subtititleStreamController=new I(this,d,w)),this.createController(r.timelineController,A),w.emeController=this.emeController=this.createController(r.emeController,A),this.cmcdController=this.createController(r.cmcdController,A),this.latencyController=this.createController(sE,A),this.coreComponents=A,x.push(l);const L=l.onErrorOut;"function"==typeof L&&this.on(cu.ERROR,L,l),this.on(cu.MANIFEST_LOADED,g.onManifestLoaded,g)}createController(e,t){if(e){const r=new e(this);return t&&t.push(r),r}return null}on(e,t,r=this){this._emitter.on(e,t,r)}once(e,t,r=this){this._emitter.once(e,t,r)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,r=this,i){this._emitter.off(e,t,r,i)}listeners(e){return this._emitter.listeners(e)}emit(e,t,r){return this._emitter.emit(e,t,r)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(t){if(this.logger.error("An internal error happened while handling event "+e+'. Error message: "'+t.message+'". Here is a stacktrace:',t),!this.triggeringException){this.triggeringException=!0;const r=e===cu.ERROR;this.trigger(cu.ERROR,{type:ou.OTHER_ERROR,details:lu.INTERNAL_EXCEPTION,fatal:r,event:e,error:t}),this.triggeringException=!1}}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){this.logger.log("destroy"),this.trigger(cu.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this._url=null,this.networkControllers.forEach(e=>e.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(e=>e.destroy()),this.coreComponents.length=0;const e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){if(!e||"media"in e&&!e.media){const t=new Error(`attachMedia failed: invalid argument (${e})`);return void this.trigger(cu.ERROR,{type:ou.OTHER_ERROR,details:lu.ATTACH_MEDIA_ERROR,fatal:!0,error:t})}this.logger.log("attachMedia"),this._media&&(this.logger.warn("media must be detached before attaching"),this.detachMedia());const t="media"in e,r=t?e.media:e,i=t?e:{media:r};this._media=r,this.trigger(cu.MEDIA_ATTACHING,i)}detachMedia(){this.logger.log("detachMedia"),this.trigger(cu.MEDIA_DETACHING,{}),this._media=null}transferMedia(){this._media=null;const e=this.bufferController.transferMedia();return this.trigger(cu.MEDIA_DETACHING,{transferMedia:e}),e}loadSource(e){this.stopLoad();const t=this.media,r=this._url,i=this._url=ju.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log(`loadSource:${i}`),t&&r&&(r!==i||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(cu.MANIFEST_LOADING,{url:e})}get url(){return this._url}get hasEnoughToStart(){return this.streamController.hasEnoughToStart}get startPosition(){return this.streamController.startPositionValue}startLoad(e=-1,t){this.logger.log(`startLoad(${e+(t?", <skip seek to start>":"")})`),this.started=!0,this.resumeBuffering();for(let r=0;r<this.networkControllers.length&&(this.networkControllers[r].startLoad(e,t),this.started&&this.networkControllers);r++);}stopLoad(){this.logger.log("stopLoad"),this.started=!1;for(let e=0;e<this.networkControllers.length&&(this.networkControllers[e].stopLoad(),!this.started&&this.networkControllers);e++);}get loadingEnabled(){return this.started}get bufferingEnabled(){return this.streamController.bufferingEnabled}resumeBuffering(){this.bufferingEnabled||(this.logger.log("resume buffering"),this.networkControllers.forEach(e=>{e.resumeBuffering&&e.resumeBuffering()}))}pauseBuffering(){this.bufferingEnabled&&(this.logger.log("pause buffering"),this.networkControllers.forEach(e=>{e.pauseBuffering&&e.pauseBuffering()}))}get inFlightFragments(){const e={[pu]:this.streamController.inFlightFrag};return this.audioStreamController&&(e[mu]=this.audioStreamController.inFlightFrag),this.subtititleStreamController&&(e[gu]=this.subtititleStreamController.inFlightFrag),e}swapAudioCodec(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){this.logger.log("recoverMediaError");const e=this._media,t=null==e?void 0:e.currentTime;this.detachMedia(),e&&(this.attachMedia(e),t&&this.startLoad(t))}removeLevel(e){this.levelController.removeLevel(e)}get sessionId(){let e=this._sessionId;return e||(e=this._sessionId=function(){try{return crypto.randomUUID()}catch(e){try{const e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch(e){let t=(new Date).getTime();const r="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const r=(t+16*Math.random())%16|0;return t=Math.floor(t/16),("x"==e?r:3&r|8).toString(16)});return r}}}()),e}get levels(){const e=this.levelController.levels;return e||[]}get latestLevelDetails(){return this.streamController.getLevelDetails()||null}get loadLevelObj(){return this.levelController.loadLevelObj}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){this.logger.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){this.logger.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){this.logger.log(`set loadLevel:${e}`),this.levelController.manualLevel=e}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(e){this.levelController.nextLoadLevel=e}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(e){this.logger.log(`set firstLevel:${e}`),this.levelController.firstLevel=e}get startLevel(){const e=this.levelController.startLevel;return-1===e&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e}set startLevel(e){this.logger.log(`set startLevel:${e}`),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){const t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimate():NaN}set bandwidthEstimate(e){this.abrController.resetEstimator(e)}get abrEwmaDefaultEstimate(){const{bwEstimator:e}=this.abrController;return e?e.defaultEstimate:NaN}get ttfbEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(this.logger.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){(function(e){return Kh.indexOf(e)>-1})(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}get autoLevelEnabled(){return-1===this.levelController.manualLevel}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){const{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;const r=e.length;for(let i=0;i<r;i++)if(e[i].maxBitrate>=t)return i;return 0}get maxAutoLevel(){const{levels:e,autoLevelCapping:t,maxHdcpLevel:r}=this;let i;if(i=-1===t&&null!=e&&e.length?e.length-1:t,r)for(let t=i;t--;){const i=e[t].attrs["HDCP-LEVEL"];if(i&&i<=r)return t}return i}get firstAutoLevel(){return this.abrController.firstAutoLevel}get nextAutoLevel(){return this.abrController.nextAutoLevel}set nextAutoLevel(e){this.abrController.nextAutoLevel=e}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get maxBufferLength(){return this.streamController.maxBufferLength}setAudioOption(e){var t;return(null==(t=this.audioTrackController)?void 0:t.setAudioOption(e))||null}setSubtitleOption(e){var t;return(null==(t=this.subtitleTrackController)?void 0:t.setSubtitleOption(e))||null}get allAudioTracks(){const e=this.audioTrackController;return e?e.allAudioTracks:[]}get audioTracks(){const e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){const e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){const t=this.audioTrackController;t&&(t.audioTrack=e)}get allSubtitleTracks(){const e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}get subtitleTracks(){const e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){const e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){const t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}get subtitleDisplay(){const e=this.subtitleTrackController;return!!e&&e.subtitleDisplay}set subtitleDisplay(e){const t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}set targetLatency(e){this.latencyController.targetLatency=e}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}get pathways(){return this.levelController.pathways}get pathwayPriority(){return this.levelController.pathwayPriority}set pathwayPriority(e){this.levelController.pathwayPriority=e}get bufferedToEnd(){var e;return!(null==(e=this.bufferController)||!e.bufferedToEnd)}get interstitialsManager(){var e;return(null==(e=this.interstitialsController)?void 0:e.interstitialsManager)||null}getMediaDecodingInfo(e,t=this.allAudioTracks){return Vh(e,of(t),navigator.mediaCapabilities)}}gE.defaultConfig=void 0;const vE=({file:e,startTime:a,poster:o,autoplay:l=!0,active:c=!0,visible:d=!0,muted:h=!0})=>{const f=r(null),{isReady:p,prewarm:m,setLowestResolution:g,startBufferBasedUpshift:v}=(({file:e,videoRef:t,autoplay:a=!0,startTime:o,enabled:l=!0,onReady:c,onError:d})=>{const h=r(null),f=r(null),p=r(0),m=r(0),g=r(!1),v=r(!1),[y,b]=s("idle"),[E,w]=s(0),[S,T]=s(!1),[A,k]=s([]),[I,L]=s("auto"),R=()=>{null!=f.current&&(clearTimeout(f.current),f.current=null)},P=(e=1e3)=>{if(null!=f.current)return;const t=p.current;if(t>=5)return b("error"),R(),void(null==d||d(new Error("Max retry reached")));const r=Math.min(15e3,e*Math.pow(2,Math.min(t,4)));b("loading"),console.log(`[HLS] schedule retry #${t+1} in ${r}ms`),f.current=window.setTimeout(()=>{f.current=null,p.current+=1,console.log(`[HLS] retryCount => ${p.current}`),w(e=>e+1)},r)};i(()=>{p.current=0,m.current=0,v.current=!1,T(!1),w(0),b(e?"loading":"idle"),R()},[e]);const C=n(()=>x(void 0,void 0,void 0,function*(){if(e)try{yield fetch(e,{method:"HEAD",mode:"cors",credentials:"omit"})}catch(e){}}),[e]);i(()=>{var r;const i=t.current;if(!i||!e||!l)return void(e&&!l&&(v.current=!1,T(!1),b("idle")));let n=()=>{};try{null===(r=h.current)||void 0===r||r.destroy()}catch(e){}if(h.current=null,v.current=!1,T(!1),b("loading"),gE.isSupported()){g.current=!1;const t=new gE({lowLatencyMode:!1,backBufferLength:0,maxBufferLength:2,maxMaxBufferLength:4,maxBufferSize:2e6,maxBufferHole:.5,startFragPrefetch:!0,capLevelToPlayerSize:!0});h.current=t;const r=()=>{const e=(t.levels||[]).map((e,t)=>{const r=e.height,i=e.width,n=e.bitrate,s=e.name;return{id:t,height:r,width:i,bitrate:n,name:s,label:s||(r?`${r}p`:`Level ${t}`)}});k(e);const r=t.currentLevel;L(null==r||r<0?"auto":r)},s=()=>{v.current||(v.current=!0,T(!0),b("ready"),p.current=0,R(),null==c||c(),a&&i.play().catch(()=>{}))};t.on(gE.Events.MANIFEST_PARSED,()=>{r(),a||_()}),t.on(gE.Events.FRAG_BUFFERED,s),t.on(gE.Events.BUFFER_APPENDED,s),t.on(gE.Events.LEVEL_SWITCHED,(e,t)=>{const r=null==t?void 0:t.level;L(null==r||r<0?"auto":r)}),t.on(gE.Events.ERROR,(e,r)=>{var i,n,s,a,o;const l=500===(null!==(a=null!==(n=null===(i=null==r?void 0:r.response)||void 0===i?void 0:i.code)&&void 0!==n?n:null===(s=null==r?void 0:r.response)||void 0===s?void 0:s.status)&&void 0!==a?a:null===(o=null==r?void 0:r.response)||void 0===o?void 0:o.statusCode);if(r.type!==gE.ErrorTypes.NETWORK_ERROR||r.fatal){if(r.fatal){if(r.type===gE.ErrorTypes.MEDIA_ERROR){if(m.current+=1,m.current<=2){try{t.recoverMediaError()}catch(e){}return void b("loading")}try{t.destroy()}catch(e){}return h.current=null,v.current=!1,T(!1),void P()}if(l){console.warn("[HLS] fatal 500 response - no retry");try{t.destroy()}catch(e){}return h.current=null,v.current=!1,T(!1),R(),b("error"),void(null==d||d(new Error("HTTP 500")))}try{t.destroy()}catch(e){}return h.current=null,v.current=!1,T(!1),void P()}}else{if(l){console.warn("[HLS] 500 response detected - no retry"),b("error");try{t.destroy()}catch(e){}return h.current=null,R(),void(null==d||d(new Error("HTTP 500")))}try{if(p.current>=5){b("error");try{t.destroy()}catch(e){}return h.current=null,void(null==d||d(new Error("Max retry reached")))}p.current+=1,console.log(`[HLS] non-fatal network retry => ${p.current}`),t.startLoad()}catch(e){}}}),t.attachMedia(i),t.loadSource(e),n=()=>{try{t.destroy()}catch(e){}h.current=null}}else if(i.canPlayType("application/vnd.apple.mpegURL")){g.current=!0,i.src!==e&&(i.src=e);const t=()=>{v.current||(v.current=!0,T(!0),b("ready"),p.current=0,R(),null==c||c(),a&&i.play().catch(()=>{}))},r=()=>{if(v.current=!1,T(!1),p.current>=5)return b("error"),void(null==d||d(new Error("Max retry reached")));P()};i.addEventListener("loadedmetadata",t),i.addEventListener("error",r),a&&i.play().catch(()=>{}),n=()=>{i.removeEventListener("loadedmetadata",t),i.removeEventListener("error",r)}}else b("error"),null==d||d(new Error("HLS not supported"));return()=>{n(),R()}},[e,E,a,c,d,t,l]),i(()=>{if(!S)return;if(null==o||o<=0)return;const e=t.current;if(e)try{Math.abs(e.currentTime-o)>.5&&(e.currentTime=o)}catch(e){}},[S,o,t]),i(()=>{const e=t.current;if(!e)return;const r=()=>b("ready"),i=()=>b("ready"),n=()=>{"error"!==y&&b("loading")},s=()=>b("loading"),a=()=>{b("error"),null==d||d()};return e.addEventListener("playing",r),e.addEventListener("canplay",i),e.addEventListener("waiting",n),e.addEventListener("stalled",s),e.addEventListener("error",a),()=>{e.removeEventListener("playing",r),e.removeEventListener("canplay",i),e.removeEventListener("waiting",n),e.removeEventListener("stalled",s),e.removeEventListener("error",a)}},[y,d,t]);const D=n(()=>{const e=h.current;e&&!g.current&&(console.log("Set auto resolution"),e.nextLevel=-1,L("auto"))},[]),_=n(()=>{var e,t;const r=h.current;if(!r)return;const i=r.levels||[];if(i.length){let n=0;for(let r=1;r<i.length;r++)(null!==(e=i[r].height)&&void 0!==e?e:99999)<(null!==(t=i[n].height)&&void 0!==t?t:99999)&&(n=r);r.currentLevel=n}},[]),O=n((e=2)=>{const r=h.current,i=t.current;if(!r||!i||g.current)return()=>{};let n=!1;const s=()=>{if(!n)if(r.autoLevelEnabled)n=!0;else try{i.buffered.length>0&&i.buffered.end(0)-i.currentTime>=e&&(r.nextLevel=-1,L("auto"),n=!0)}catch(e){}};return r.on(gE.Events.FRAG_BUFFERED,s),()=>{r.off(gE.Events.FRAG_BUFFERED,s)}},[t]);return{playbackStatus:y,isReady:S,qualities:A,currentLevel:I,isAutoQuality:u(()=>"auto"===I,[I]),canSetResolution:!g.current&&gE.isSupported(),setResolution:e=>{const t=h.current;if(!t||g.current)return;if("string"==typeof e&&"auto"===e.toLowerCase())return t.currentLevel=-1,void L("auto");const r="number"==typeof e?e:parseInt(e,10);if(!Number.isFinite(r)){const r=A.find(t=>t.label.toLowerCase()===String(e).toLowerCase());return void(r&&(t.currentLevel=r.id,L(r.id)))}const i=[...A].filter(e=>e.height).sort((e,t)=>(t.height||0)-(e.height||0)),n=i.find(e=>(e.height||0)<=r)||i[i.length-1];n&&(t.currentLevel=n.id,L(n.id))},setAutoResolution:D,prewarm:C,setLowestResolution:_,startBufferBasedUpshift:O}})({file:e,videoRef:f,autoplay:l,startTime:a,enabled:l||c});return i(()=>{m()},[m]),t.useEffect(()=>{var e,t;const r=f.current;if(r)if(c)null===(e=r.play)||void 0===e||e.call(r).catch(()=>{});else try{null===(t=r.pause)||void 0===t||t.call(r)}catch(e){}},[c,p]),i(()=>{if(!c)return;g();return v(2)},[c,g,v]),t.createElement("video",{ref:f,playsInline:!0,autoPlay:l,muted:h,poster:Dt(o||""),preload:"metadata",className:"w-full h-full object-cover object-center bg-black",style:{opacity:d&&p?1:0,transition:"opacity 200ms ease-in-out"}})},yE=({view:e})=>t.createElement("div",{className:"absolute",style:{top:8,left:8,borderRadius:"4px",color:"white",overflow:"hidden",fontSize:11}},t.createElement("span",{style:{backgroundColor:"rgba(62,213,69,0.71)",color:"white",padding:4,paddingLeft:9,paddingRight:9,display:"inline-block",lineHeight:1}},"다시보기"),t.createElement("span",{style:{backgroundColor:"rgba(58,58,58,0.52)",color:"white",padding:4,paddingLeft:9,paddingRight:9,display:"inline-block",lineHeight:1}},e," 시청")),bE=({content:e,aspectRatio:r="9/16",cursor:i="default",borderRadius:n,playback:s="hover"})=>{var a,o,l,c,d;const u=t.useRef(null),[h,f]=t.useState(!1),p=t.useRef(null),[m,g]=t.useState(!1),[v,y]=t.useState(!0),[b,E]=t.useState(!1),{boxSize:w}=ru(r,u),S=e.thumbPath||(null===(o=null===(a=null==e?void 0:e.designInfo)||void 0===a?void 0:a.thumbPath)||void 0===o?void 0:o.preview),T=3===e.status,{API_BASE_URL:x,PLAYER_BASE_URL:A}=gt(),k=`${x}/hls/${null===(l=e.replay)||void 0===l?void 0:l.objectId}`;t.useEffect(()=>{const e=u.current;if(!e)return;const t=new IntersectionObserver(e=>{const t=e[0];E(t.isIntersecting&&t.intersectionRatio>=.5)},{root:null,threshold:[0,.5,1]});return t.observe(e),()=>t.disconnect()},[s]),t.useEffect(()=>{var e;if("undefined"!=typeof window&&window.matchMedia)try{const t=window.matchMedia("(pointer: fine)"),r=()=>y(t.matches);return r(),null===(e=t.addEventListener)||void 0===e||e.call(t,"change",r),()=>{var e;return null===(e=t.removeEventListener)||void 0===e?void 0:e.call(t,"change",r)}}catch(e){}},[s]);const I=()=>{null!=p.current&&(clearTimeout(p.current),p.current=null)},L=()=>{g(!0),I(),f(!1)};t.useEffect(()=>{const e=()=>g(!1);return window.addEventListener("mouseup",e),window.addEventListener("touchend",e),window.addEventListener("pointerup",e),()=>{window.removeEventListener("mouseup",e),window.removeEventListener("touchend",e),window.removeEventListener("pointerup",e)}},[s]);const R="hover"===s&&v,P=Boolean(k&&("autoplay"===s&&b||R&&h));return t.createElement("div",{className:"w-full h-full flex flex-col items-center justify-center",ref:u,onMouseEnter:()=>{"hover"===s&&v&&(m||(I(),p.current=window.setTimeout(()=>{f(!0)},150)))},onMouseLeave:()=>{I(),f(!1)},onMouseDown:L,onTouchStart:L},t.createElement("div",{className:"relative rounded overflow-hidden",style:{width:w.width?`${w.width}px`:"100%",height:w.height?`${w.height}px`:"100%",borderRadius:`${null!=n?n:10}px`,backgroundRepeat:"no-repeat",backgroundPosition:"center",backgroundSize:"cover",aspectRatio:w.height?void 0:r,backgroundImage:S?`url(${Dt(S)})`:void 0,backgroundColor:S?void 0:"black"}},T?t.createElement("iframe",{src:`${A}/live/${e.eventId}`,className:"w-full h-full"}):t.createElement(t.Fragment,null,t.createElement("div",{className:"absolute inset-0 w-full h-full object-cover",style:{pointerEvents:"none"}},t.createElement(vE,{file:k,poster:S,autoplay:"autoplay"===s,active:"autoplay"===s&&b||R&&h,visible:P,muted:!0})),!P&&t.createElement(eu,null),t.createElement(yE,{view:null!==(d=null===(c=e.statistics)||void 0===c?void 0:c.pageView)&&void 0!==d?d:0}))))},EE=e=>{var r,i,n,s;const{content:a,title:o,aspectRatio:l="9/16",card:c,titleFontSize:d}=e,h=null!==(r=null==c?void 0:c.layout)&&void 0!==r?r:"slider",f=null!==(i=null==c?void 0:c.sliderPerView)&&void 0!==i?i:3,p=null!==(n=null==c?void 0:c.gridColumns)&&void 0!==n?n:3,m=null!==(s=null==c?void 0:c.gap)&&void 0!==s?s:12,g=null==c?void 0:c.width,v=g?"auto":f,y=u(()=>({fontSize:d?`${d}px`:void 0,fontWeight:600}),[d]),{PLAYER_BASE_URL:b}=gt();return a&&0!==a.length?t.createElement("div",{className:"flex flex-col w-full",style:{gap:m}},t.createElement("p",{className:"truncate",style:Object.assign(Object.assign({},y),{userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none",cursor:"default"})},o||("past"===e.liveType?"지난 라이브":"예정된 라이브")),"slider"===h?t.createElement("div",null,t.createElement(Pa,{key:`${v}-${null!=g?g:""}-${m}`,slidesPerView:v,spaceBetween:m},a.map(r=>{var i,n;return t.createElement(Ca,{key:r.eventId,style:g?{width:`${g}px`}:void 0},t.createElement("a",{href:`${b}/live/${r.eventId}`,target:"_blank",rel:"noopener noreferrer",className:"flex flex-col",style:{gap:6,textDecoration:"none",cursor:"pointer"}},"past"===e.liveType&&r.eventStatus!==Jd.READY?t.createElement(bE,{content:r,aspectRatio:l,cursor:"pointer",borderRadius:null==c?void 0:c.borderRadius,playback:e.playback}):t.createElement(iu,{content:r,aspectRatio:l,cursor:"pointer",borderRadius:null==c?void 0:c.borderRadius}),t.createElement("p",{className:"truncate",style:{color:null!==(n=null===(i=e.theme)||void 0===i?void 0:i.textColor)&&void 0!==n?n:"black",fontSize:14,userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"}},r.eventName)))}))):t.createElement("div",{style:{overflowY:"auto"}},t.createElement("div",{style:{display:"grid",gridTemplateColumns:g?`repeat(auto-fill, ${g}px)`:`repeat(${p}, minmax(0, 1fr))`,gap:m}},a.map(r=>{var i,n;return t.createElement("a",{key:r.eventId,href:`${b}/live/${r.eventId}`,target:"_blank",rel:"noopener noreferrer",className:"flex flex-col",style:{gap:6,textDecoration:"none",cursor:"pointer"}},"past"===e.liveType&&r.eventStatus!==Jd.READY?t.createElement(bE,{content:r,aspectRatio:l,cursor:"pointer",borderRadius:null==c?void 0:c.borderRadius,playback:e.playback}):t.createElement(iu,{content:r,aspectRatio:l,cursor:"pointer",borderRadius:null==c?void 0:c.borderRadius}),t.createElement("p",{className:"truncate",style:{color:null!==(n=null===(i=e.theme)||void 0===i?void 0:i.textColor)&&void 0!==n?n:"black",fontSize:14,userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"}},r.eventName))})))):null},wE=({content:e})=>{const r=t.useMemo(()=>qe(e.start).tz("Asia/Seoul").format("M월 D일 A HH:mm"),[e.start]),i=e.eventStatus!==Jd.READY;return t.createElement("div",{className:"flex-1 flex flex-col gap-5 items-center justify-center"},t.createElement("p",{style:{fontWeight:"bold",fontSize:"24px"}},e.eventName),!i&&t.createElement("p",null,r),t.createElement("button",{onClick:()=>{window.open(`https://player.midibus.im/live/${e.eventId}`,"_blank")},className:"rounded bg-black text-white cursor-pointer",style:{width:"70%",padding:"10px"}},"라이브 입장하기"))},SE=e=>{var r,i;const{content:n,aspectRatio:s="9/16",videoAlign:a}=e,o=null===(r=e.card)||void 0===r?void 0:r.borderRadius,l=null===(i=e.card)||void 0===i?void 0:i.width,{PLAYER_BASE_URL:c}=gt();return t.createElement("div",{className:"flex w-full h-full items-center justify-center"},"only"===a?t.createElement("a",{className:"w-full h-full",href:`${c}/live/${n.eventId}`,target:"_blank",rel:"noopener noreferrer",style:l?{width:`${l}px`}:void 0},t.createElement(iu,{content:n,aspectRatio:s,borderRadius:o,cursor:"pointer"})):"left"===a?t.createElement(t.Fragment,null,t.createElement("div",{className:"flex-1"},t.createElement("a",{href:`${c}/live/${n.eventId}`,target:"_blank",rel:"noopener noreferrer",style:l?{width:`${l}px`}:void 0},t.createElement(iu,{content:n,aspectRatio:s,borderRadius:o,cursor:"pointer"}))),t.createElement(wE,{content:n})):t.createElement(t.Fragment,null,t.createElement(wE,{content:n}),t.createElement("div",{className:"flex-1"},t.createElement("a",{href:`${c}/live/${n.eventId}`,target:"_blank",rel:"noopener noreferrer",style:l?{width:`${l}px`}:void 0},t.createElement(iu,{content:n,aspectRatio:s,borderRadius:o,cursor:"pointer"})))))},TE=e=>{var r;const{theme:i,titleFontSize:n,title:s}=e;return t.createElement("div",{className:"w-full h-full flex flex-col",style:{color:null!==(r=null==i?void 0:i.textColor)&&void 0!==r?r:"#252525"}},t.createElement("p",{style:Object.assign(Object.assign({},n&&{fontSize:n}),{fontWeight:"bold",color:null==i?void 0:i.textColor,paddingTop:"10px",paddingBottom:"10px",marginBottom:"30px"})},s||("past"===e.liveType?"지난 라이브":"예정된 라이브")),t.createElement("div",{className:"self-center text-center h-full flex flex-col items-center justify-center",style:{minHeight:"200px"}},t.createElement("p",{style:{fontSize:"20px",marginBottom:"10px"}},"past"===e.liveType?"지난 라이브가 없어요.":"예정된 라이브가 없어요."),t.createElement("span",{style:{fontWeight:"lighter"}},"past"===e.liveType?"다른 콘텐츠도 확인해 보세요.":"곧 혜택 가득한 라이브로 찾아올게요!")))};function xE(t){var{className:r}=t,i=T(t,["className"]);return e.createElement("div",Object.assign({className:St("animate-pulse rounded-md bg-gray-200",r)},i))}const AE=e=>{var r,i,n,s,a,o,l,c,d;const{card:u,aspectRatio:h="9/16",widgetType:f,layout:p,theme:m}=e,g=null!==(r=null==u?void 0:u.layout)&&void 0!==r?r:"slider",v=null!==(i=null==u?void 0:u.sliderPerView)&&void 0!==i?i:3,y=null!==(n=null==u?void 0:u.gridColumns)&&void 0!==n?n:3,b=null!==(s=null==u?void 0:u.gap)&&void 0!==s?s:12,E=null!==(a=null==u?void 0:u.borderRadius)&&void 0!==a?a:8,w=null!==(o=null==p?void 0:p.paddingTop)&&void 0!==o?o:0,S=null!==(l=null==p?void 0:p.paddingBottom)&&void 0!==l?l:0,T=null!==(c=null==p?void 0:p.paddingLeft)&&void 0!==c?c:0,x=null!==(d=null==p?void 0:p.paddingRight)&&void 0!==d?d:0,A="ONE"===f&&"past"!==e.liveType,k=A?1:(null==u?void 0:u.visibleCount)||6,I=A?1:"slider"===g?v:k;return t.createElement("div",{className:"w-full flex flex-col",style:{gap:b,paddingTop:w,paddingBottom:S,paddingLeft:T,paddingRight:x,backgroundColor:null==m?void 0:m.backgroundColor}},t.createElement(xE,{className:"h-5 w-36"}),t.createElement("div",{style:A||"scroll"!==g?{display:"flex",gap:b,overflow:"hidden"}:{display:"grid",gridTemplateColumns:`repeat(${y}, minmax(0, 1fr))`,gap:b}},Array.from({length:I}).map((e,r)=>t.createElement("div",{key:r,className:"flex flex-col flex-shrink-0",style:{flex:A||"slider"!==g?void 0:`0 0 calc((100% - ${b*(v-1)}px) / ${v})`,gap:6}},t.createElement(xE,{style:{aspectRatio:h,borderRadius:E,width:"100%"}}),t.createElement(xE,{className:"h-3.5 w-4/5"})))))},kE=e=>{var r,i,n,s;const{widgetType:a,theme:o,layout:l}=e,c=Zd(e=>e.liveWidget),d=null!==(r=null==l?void 0:l.paddingTop)&&void 0!==r?r:0,u=null!==(i=null==l?void 0:l.paddingBottom)&&void 0!==i?i:0,h=null!==(n=null==l?void 0:l.paddingLeft)&&void 0!==n?n:0,f=null!==(s=null==l?void 0:l.paddingRight)&&void 0!==s?s:0;return null===c?t.createElement(AE,Object.assign({},e)):0===c.length?t.createElement(TE,Object.assign({},e)):t.createElement("div",{className:"w-full h-full",style:{backgroundColor:null==o?void 0:o.backgroundColor,color:null==o?void 0:o.textColor,paddingTop:d,paddingBottom:u,paddingLeft:h,paddingRight:f}},"ONE"===a&&"past"!==e.liveType?t.createElement(SE,Object.assign({content:c[0]},e)):t.createElement(EE,Object.assign({content:c},e)))},IE=e=>{const r=Zd(e=>e.liveWidget),n=Zd(e=>e.setLiveWidget),{userId:s,card:a,includeRepresentative:o=!1,liveType:l}=e;return i(()=>{if(!s)return;if(r&&(null==a?void 0:a.visibleCount)&&r.length>Number(a.visibleCount))return void n(r.slice(0,null==a?void 0:a.visibleCount));const t=new AbortController;return x(void 0,void 0,void 0,function*(){const r=yield Yt(s,"past"===l?"FINISHED":"UPCOMING",(null==a?void 0:a.visibleCount)||6,o,e.sorting);if(!r||t.signal.aborted)return;n(r);const i=yield Promise.allSettled(r.map(e=>x(void 0,void 0,void 0,function*(){const t=yield((e,t)=>x(void 0,void 0,void 0,function*(){const{STATISTICS_BASE_URL:r}=gt(),i=`${r}/replay/${e}/${t}/summary`,n=yield fetch(i);if(404!==n.status){if(!n.ok){const e=yield n.text().catch(()=>"");return console.error(`[ReplayStatistics] ${n.status} ${n.statusText} ${e}`),{pageView:0,like:0}}return n.json()}}))(s,e.eventId);return Object.assign(Object.assign({},e),{statistics:t})})));t.signal.aborted||n(i.map((e,t)=>"fulfilled"===e.status?e.value:r[t]))}),()=>t.abort()},[s,null==a?void 0:a.visibleCount,l,e.sorting,o]),t.createElement(qr.div,{className:"w-full h-full"},t.createElement(_o,null),t.createElement(kE,Object.assign({},e)))},LE=e=>t.createElement(Qd,null,t.createElement(IE,Object.assign({},e)));var RE={exports:{}},PE={};function CE(e){var t,r,i="";if("string"==typeof e||"number"==typeof e)i+=e;else if("object"==typeof e)if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(r=CE(e[t]))&&(i&&(i+=" "),i+=r);else for(t in e)e[t]&&(i&&(i+=" "),i+=t);return i}function DE(){for(var e,t,r=0,i="";r<arguments.length;)(e=arguments[r++])&&(t=CE(e))&&(i&&(i+=" "),i+=t);return i}var _E,OE=He(Object.freeze({__proto__:null,clsx:DE,default:DE})),ME={},NE={};function FE(){if(_E)return NE;return _E=1,Object.defineProperty(NE,"__esModule",{value:!0}),NE.dontSetMe=function(e,t,r){if(e[t])return new Error("Invalid prop ".concat(t," passed to ").concat(r," - do not set this, set it on the child."))},NE.findInArray=function(e,t){for(let r=0,i=e.length;r<i;r++)if(t.apply(t,[e[r],r,e]))return e[r]},NE.int=function(e){return parseInt(e,10)},NE.isFunction=function(e){return"function"==typeof e||"[object Function]"===Object.prototype.toString.call(e)},NE.isNum=function(e){return"number"==typeof e&&!isNaN(e)},NE}var $E,BE,UE={};function zE(){if(BE)return ME;BE=1,Object.defineProperty(ME,"__esModule",{value:!0}),ME.addClassName=a,ME.addEvent=function(e,t,r,i){if(!e)return;const n={capture:!0,...i};e.addEventListener?e.addEventListener(t,r,n):e.attachEvent?e.attachEvent("on"+t,r):e["on"+t]=r},ME.addUserSelectStyles=function(e){if(!e)return;let t=e.getElementById("react-draggable-style-el");t||(t=e.createElement("style"),t.type="text/css",t.id="react-draggable-style-el",t.innerHTML=".react-draggable-transparent-selection *::-moz-selection {all: inherit;}\n",t.innerHTML+=".react-draggable-transparent-selection *::selection {all: inherit;}\n",e.getElementsByTagName("head")[0].appendChild(t));e.body&&a(e.body,"react-draggable-transparent-selection")},ME.createCSSTransform=function(e,r){const i=s(e,r,"px");return{[(0,t.browserPrefixToKey)("transform",t.default)]:i}},ME.createSVGTransform=function(e,t){return s(e,t,"")},ME.getTouch=function(t,r){return t.targetTouches&&(0,e.findInArray)(t.targetTouches,e=>r===e.identifier)||t.changedTouches&&(0,e.findInArray)(t.changedTouches,e=>r===e.identifier)},ME.getTouchIdentifier=function(e){if(e.targetTouches&&e.targetTouches[0])return e.targetTouches[0].identifier;if(e.changedTouches&&e.changedTouches[0])return e.changedTouches[0].identifier},ME.getTranslation=s,ME.innerHeight=function(t){let r=t.clientHeight;const i=t.ownerDocument.defaultView.getComputedStyle(t);return r-=(0,e.int)(i.paddingTop),r-=(0,e.int)(i.paddingBottom),r},ME.innerWidth=function(t){let r=t.clientWidth;const i=t.ownerDocument.defaultView.getComputedStyle(t);return r-=(0,e.int)(i.paddingLeft),r-=(0,e.int)(i.paddingRight),r},ME.matchesSelector=n,ME.matchesSelectorAndParentsTo=function(e,t,r){let i=e;do{if(n(i,t))return!0;if(i===r)return!1;i=i.parentNode}while(i);return!1},ME.offsetXYFromParent=function(e,t,r){const i=t===t.ownerDocument.body?{left:0,top:0}:t.getBoundingClientRect(),n=(e.clientX+t.scrollLeft-i.left)/r,s=(e.clientY+t.scrollTop-i.top)/r;return{x:n,y:s}},ME.outerHeight=function(t){let r=t.clientHeight;const i=t.ownerDocument.defaultView.getComputedStyle(t);return r+=(0,e.int)(i.borderTopWidth),r+=(0,e.int)(i.borderBottomWidth),r},ME.outerWidth=function(t){let r=t.clientWidth;const i=t.ownerDocument.defaultView.getComputedStyle(t);return r+=(0,e.int)(i.borderLeftWidth),r+=(0,e.int)(i.borderRightWidth),r},ME.removeClassName=o,ME.removeEvent=function(e,t,r,i){if(!e)return;const n={capture:!0,...i};e.removeEventListener?e.removeEventListener(t,r,n):e.detachEvent?e.detachEvent("on"+t,r):e["on"+t]=null},ME.removeUserSelectStyles=function(e){if(!e)return;try{if(e.body&&o(e.body,"react-draggable-transparent-selection"),e.selection)e.selection.empty();else{const t=(e.defaultView||window).getSelection();t&&"Caret"!==t.type&&t.removeAllRanges()}}catch(e){}};var e=FE(),t=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var i=r(t);if(i&&i.has(e))return i.get(e);var n={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if("default"!==a&&Object.prototype.hasOwnProperty.call(e,a)){var o=s?Object.getOwnPropertyDescriptor(e,a):null;o&&(o.get||o.set)?Object.defineProperty(n,a,o):n[a]=e[a]}n.default=e,i&&i.set(e,n);return n}(function(){if($E)return UE;$E=1,Object.defineProperty(UE,"__esModule",{value:!0}),UE.browserPrefixToKey=r,UE.browserPrefixToStyle=function(e,t){return t?"-".concat(t.toLowerCase(),"-").concat(e):e},UE.default=void 0,UE.getPrefix=t;const e=["Moz","Webkit","O","ms"];function t(){var t;let i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"transform";if("undefined"==typeof window)return"";const n=null===(t=window.document)||void 0===t||null===(t=t.documentElement)||void 0===t?void 0:t.style;if(!n)return"";if(i in n)return"";for(let t=0;t<e.length;t++)if(r(i,e[t])in n)return e[t];return""}function r(e,t){return t?"".concat(t).concat(function(e){let t="",r=!0;for(let i=0;i<e.length;i++)r?(t+=e[i].toUpperCase(),r=!1):"-"===e[i]?r=!0:t+=e[i];return t}(e)):e}return UE.default=t(),UE}());function r(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return(r=function(e){return e?i:t})(e)}let i="";function n(t,r){return i||(i=(0,e.findInArray)(["matches","webkitMatchesSelector","mozMatchesSelector","msMatchesSelector","oMatchesSelector"],function(r){return(0,e.isFunction)(t[r])})),!!(0,e.isFunction)(t[i])&&t[i](r)}function s(e,t,r){let{x:i,y:n}=e,s="translate(".concat(i).concat(r,",").concat(n).concat(r,")");if(t){const e="".concat("string"==typeof t.x?t.x:t.x+r),i="".concat("string"==typeof t.y?t.y:t.y+r);s="translate(".concat(e,", ").concat(i,")")+s}return s}function a(e,t){e.classList?e.classList.add(t):e.className.match(new RegExp("(?:^|\\s)".concat(t,"(?!\\S)")))||(e.className+=" ".concat(t))}function o(e,t){e.classList?e.classList.remove(t):e.className=e.className.replace(new RegExp("(?:^|\\s)".concat(t,"(?!\\S)"),"g"),"")}return ME}var GE,jE={};function HE(){if(GE)return jE;GE=1,Object.defineProperty(jE,"__esModule",{value:!0}),jE.canDragX=function(e){return"both"===e.props.axis||"x"===e.props.axis},jE.canDragY=function(e){return"both"===e.props.axis||"y"===e.props.axis},jE.createCoreData=function(t,i,n){const s=!(0,e.isNum)(t.lastX),a=r(t);return s?{node:a,deltaX:0,deltaY:0,lastX:i,lastY:n,x:i,y:n}:{node:a,deltaX:i-t.lastX,deltaY:n-t.lastY,lastX:t.lastX,lastY:t.lastY,x:i,y:n}},jE.createDraggableData=function(e,t){const r=e.props.scale;return{node:t.node,x:e.state.x+t.deltaX/r,y:e.state.y+t.deltaY/r,deltaX:t.deltaX/r,deltaY:t.deltaY/r,lastX:e.state.x,lastY:e.state.y}},jE.getBoundPosition=function(i,n,s){if(!i.props.bounds)return[n,s];let{bounds:a}=i.props;a="string"==typeof a?a:function(e){return{left:e.left,top:e.top,right:e.right,bottom:e.bottom}}(a);const o=r(i);if("string"==typeof a){const{ownerDocument:r}=o,i=r.defaultView;let n;if(n="parent"===a?o.parentNode:r.querySelector(a),!(n instanceof i.HTMLElement))throw new Error('Bounds selector "'+a+'" could not find an element.');const s=n,l=i.getComputedStyle(o),c=i.getComputedStyle(s);a={left:-o.offsetLeft+(0,e.int)(c.paddingLeft)+(0,e.int)(l.marginLeft),top:-o.offsetTop+(0,e.int)(c.paddingTop)+(0,e.int)(l.marginTop),right:(0,t.innerWidth)(s)-(0,t.outerWidth)(o)-o.offsetLeft+(0,e.int)(c.paddingRight)-(0,e.int)(l.marginRight),bottom:(0,t.innerHeight)(s)-(0,t.outerHeight)(o)-o.offsetTop+(0,e.int)(c.paddingBottom)-(0,e.int)(l.marginBottom)}}(0,e.isNum)(a.right)&&(n=Math.min(n,a.right));(0,e.isNum)(a.bottom)&&(s=Math.min(s,a.bottom));(0,e.isNum)(a.left)&&(n=Math.max(n,a.left));(0,e.isNum)(a.top)&&(s=Math.max(s,a.top));return[n,s]},jE.getControlPosition=function(e,i,n){const s="number"==typeof i?(0,t.getTouch)(e,i):null;if("number"==typeof i&&!s)return null;const a=r(n),o=n.props.offsetParent||a.offsetParent||a.ownerDocument.body;return(0,t.offsetXYFromParent)(s||e,o,n.props.scale)},jE.snapToGrid=function(e,t,r){const i=Math.round(t/e[0])*e[0],n=Math.round(r/e[1])*e[1];return[i,n]};var e=FE(),t=zE();function r(e){const t=e.findDOMNode();if(!t)throw new Error("<DraggableCore>: Unmounted during event!");return t}return jE}var VE,WE,YE,KE,qE={},XE={};function QE(){if(VE)return XE;return VE=1,Object.defineProperty(XE,"__esModule",{value:!0}),XE.default=function(){},XE}function ZE(){if(WE)return qE;WE=1,Object.defineProperty(qE,"__esModule",{value:!0}),qE.default=void 0;var e=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=c(t);if(r&&r.has(e))return r.get(e);var i={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in e)if("default"!==s&&Object.prototype.hasOwnProperty.call(e,s)){var a=n?Object.getOwnPropertyDescriptor(e,s):null;a&&(a.get||a.set)?Object.defineProperty(i,s,a):i[s]=e[s]}i.default=e,r&&r.set(e,i);return i}(t),r=l(Mr()),i=l(m),n=zE(),s=HE(),a=FE(),o=l(QE());function l(e){return e&&e.__esModule?e:{default:e}}function c(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(c=function(e){return e?r:t})(e)}function d(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const u={start:"touchstart",move:"touchmove",stop:"touchend"},h={start:"mousedown",move:"mousemove",stop:"mouseup"};let f=h,p=class extends e.Component{constructor(){super(...arguments),d(this,"dragging",!1),d(this,"lastX",NaN),d(this,"lastY",NaN),d(this,"touchIdentifier",null),d(this,"mounted",!1),d(this,"handleDragStart",e=>{if(this.props.onMouseDown(e),!this.props.allowAnyClick&&"number"==typeof e.button&&0!==e.button)return!1;const t=this.findDOMNode();if(!t||!t.ownerDocument||!t.ownerDocument.body)throw new Error("<DraggableCore> not mounted on DragStart!");const{ownerDocument:r}=t;if(this.props.disabled||!(e.target instanceof r.defaultView.Node)||this.props.handle&&!(0,n.matchesSelectorAndParentsTo)(e.target,this.props.handle,t)||this.props.cancel&&(0,n.matchesSelectorAndParentsTo)(e.target,this.props.cancel,t))return;"touchstart"===e.type&&e.preventDefault();const i=(0,n.getTouchIdentifier)(e);this.touchIdentifier=i;const a=(0,s.getControlPosition)(e,i,this);if(null==a)return;const{x:l,y:c}=a,d=(0,s.createCoreData)(this,l,c);(0,o.default)("DraggableCore: handleDragStart: %j",d),(0,o.default)("calling",this.props.onStart);!1!==this.props.onStart(e,d)&&!1!==this.mounted&&(this.props.enableUserSelectHack&&(0,n.addUserSelectStyles)(r),this.dragging=!0,this.lastX=l,this.lastY=c,(0,n.addEvent)(r,f.move,this.handleDrag),(0,n.addEvent)(r,f.stop,this.handleDragStop))}),d(this,"handleDrag",e=>{const t=(0,s.getControlPosition)(e,this.touchIdentifier,this);if(null==t)return;let{x:r,y:i}=t;if(Array.isArray(this.props.grid)){let e=r-this.lastX,t=i-this.lastY;if([e,t]=(0,s.snapToGrid)(this.props.grid,e,t),!e&&!t)return;r=this.lastX+e,i=this.lastY+t}const n=(0,s.createCoreData)(this,r,i);(0,o.default)("DraggableCore: handleDrag: %j",n);if(!1!==this.props.onDrag(e,n)&&!1!==this.mounted)this.lastX=r,this.lastY=i;else try{this.handleDragStop(new MouseEvent("mouseup"))}catch(e){const t=document.createEvent("MouseEvents");t.initMouseEvent("mouseup",!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),this.handleDragStop(t)}}),d(this,"handleDragStop",e=>{if(!this.dragging)return;const t=(0,s.getControlPosition)(e,this.touchIdentifier,this);if(null==t)return;let{x:r,y:i}=t;if(Array.isArray(this.props.grid)){let e=r-this.lastX||0,t=i-this.lastY||0;[e,t]=(0,s.snapToGrid)(this.props.grid,e,t),r=this.lastX+e,i=this.lastY+t}const a=(0,s.createCoreData)(this,r,i);if(!1===this.props.onStop(e,a)||!1===this.mounted)return!1;const l=this.findDOMNode();l&&this.props.enableUserSelectHack&&(0,n.removeUserSelectStyles)(l.ownerDocument),(0,o.default)("DraggableCore: handleDragStop: %j",a),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,l&&((0,o.default)("DraggableCore: Removing handlers"),(0,n.removeEvent)(l.ownerDocument,f.move,this.handleDrag),(0,n.removeEvent)(l.ownerDocument,f.stop,this.handleDragStop))}),d(this,"onMouseDown",e=>(f=h,this.handleDragStart(e))),d(this,"onMouseUp",e=>(f=h,this.handleDragStop(e))),d(this,"onTouchStart",e=>(f=u,this.handleDragStart(e))),d(this,"onTouchEnd",e=>(f=u,this.handleDragStop(e)))}componentDidMount(){this.mounted=!0;const e=this.findDOMNode();e&&(0,n.addEvent)(e,u.start,this.onTouchStart,{passive:!1})}componentWillUnmount(){this.mounted=!1;const e=this.findDOMNode();if(e){const{ownerDocument:t}=e;(0,n.removeEvent)(t,h.move,this.handleDrag),(0,n.removeEvent)(t,u.move,this.handleDrag),(0,n.removeEvent)(t,h.stop,this.handleDragStop),(0,n.removeEvent)(t,u.stop,this.handleDragStop),(0,n.removeEvent)(e,u.start,this.onTouchStart,{passive:!1}),this.props.enableUserSelectHack&&(0,n.removeUserSelectStyles)(t)}}findDOMNode(){var e,t;return null!==(e=this.props)&&void 0!==e&&e.nodeRef?null===(t=this.props)||void 0===t||null===(t=t.nodeRef)||void 0===t?void 0:t.current:i.default.findDOMNode(this)}render(){return e.cloneElement(e.Children.only(this.props.children),{onMouseDown:this.onMouseDown,onMouseUp:this.onMouseUp,onTouchEnd:this.onTouchEnd})}};return qE.default=p,d(p,"displayName","DraggableCore"),d(p,"propTypes",{allowAnyClick:r.default.bool,children:r.default.node.isRequired,disabled:r.default.bool,enableUserSelectHack:r.default.bool,offsetParent:function(e,t){if(e[t]&&1!==e[t].nodeType)throw new Error("Draggable's offsetParent must be a DOM Node.")},grid:r.default.arrayOf(r.default.number),handle:r.default.string,cancel:r.default.string,nodeRef:r.default.object,onStart:r.default.func,onDrag:r.default.func,onStop:r.default.func,onMouseDown:r.default.func,scale:r.default.number,className:a.dontSetMe,style:a.dontSetMe,transform:a.dontSetMe}),d(p,"defaultProps",{allowAnyClick:!1,disabled:!1,enableUserSelectHack:!0,onStart:function(){},onDrag:function(){},onStop:function(){},onMouseDown:function(){},scale:1}),qE}function JE(){return YE||(YE=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"DraggableCore",{enumerable:!0,get:function(){return c.default}}),e.default=void 0;var r=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=h(t);if(r&&r.has(e))return r.get(e);var i={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in e)if("default"!==s&&Object.prototype.hasOwnProperty.call(e,s)){var a=n?Object.getOwnPropertyDescriptor(e,s):null;a&&(a.get||a.set)?Object.defineProperty(i,s,a):i[s]=e[s]}i.default=e,r&&r.set(e,i);return i}(t),i=u(Mr()),n=u(m),s=u(OE),a=zE(),o=HE(),l=FE(),c=u(ZE()),d=u(QE());function u(e){return e&&e.__esModule?e:{default:e}}function h(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(h=function(e){return e?r:t})(e)}function f(){return f=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},f.apply(this,arguments)}function p(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class g extends r.Component{static getDerivedStateFromProps(e,t){let{position:r}=e,{prevPropsPosition:i}=t;return!r||i&&r.x===i.x&&r.y===i.y?null:((0,d.default)("Draggable: getDerivedStateFromProps %j",{position:r,prevPropsPosition:i}),{x:r.x,y:r.y,prevPropsPosition:{...r}})}constructor(e){super(e),p(this,"onDragStart",(e,t)=>{(0,d.default)("Draggable: onDragStart: %j",t);if(!1===this.props.onStart(e,(0,o.createDraggableData)(this,t)))return!1;this.setState({dragging:!0,dragged:!0})}),p(this,"onDrag",(e,t)=>{if(!this.state.dragging)return!1;(0,d.default)("Draggable: onDrag: %j",t);const r=(0,o.createDraggableData)(this,t),i={x:r.x,y:r.y,slackX:0,slackY:0};if(this.props.bounds){const{x:e,y:t}=i;i.x+=this.state.slackX,i.y+=this.state.slackY;const[n,s]=(0,o.getBoundPosition)(this,i.x,i.y);i.x=n,i.y=s,i.slackX=this.state.slackX+(e-i.x),i.slackY=this.state.slackY+(t-i.y),r.x=i.x,r.y=i.y,r.deltaX=i.x-this.state.x,r.deltaY=i.y-this.state.y}if(!1===this.props.onDrag(e,r))return!1;this.setState(i)}),p(this,"onDragStop",(e,t)=>{if(!this.state.dragging)return!1;if(!1===this.props.onStop(e,(0,o.createDraggableData)(this,t)))return!1;(0,d.default)("Draggable: onDragStop: %j",t);const r={dragging:!1,slackX:0,slackY:0};if(Boolean(this.props.position)){const{x:e,y:t}=this.props.position;r.x=e,r.y=t}this.setState(r)}),this.state={dragging:!1,dragged:!1,x:e.position?e.position.x:e.defaultPosition.x,y:e.position?e.position.y:e.defaultPosition.y,prevPropsPosition:{...e.position},slackX:0,slackY:0,isElementSVG:!1},!e.position||e.onDrag||e.onStop||console.warn("A `position` was applied to this <Draggable>, without drag handlers. This will make this component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the `position` of this element.")}componentDidMount(){void 0!==window.SVGElement&&this.findDOMNode()instanceof window.SVGElement&&this.setState({isElementSVG:!0})}componentWillUnmount(){this.setState({dragging:!1})}findDOMNode(){var e,t;return null!==(e=null===(t=this.props)||void 0===t||null===(t=t.nodeRef)||void 0===t?void 0:t.current)&&void 0!==e?e:n.default.findDOMNode(this)}render(){const{axis:e,bounds:t,children:i,defaultPosition:n,defaultClassName:l,defaultClassNameDragging:d,defaultClassNameDragged:u,position:h,positionOffset:p,scale:m,...g}=this.props;let v={},y=null;const b=!Boolean(h)||this.state.dragging,E=h||n,w={x:(0,o.canDragX)(this)&&b?this.state.x:E.x,y:(0,o.canDragY)(this)&&b?this.state.y:E.y};this.state.isElementSVG?y=(0,a.createSVGTransform)(w,p):v=(0,a.createCSSTransform)(w,p);const S=(0,s.default)(i.props.className||"",l,{[d]:this.state.dragging,[u]:this.state.dragged});return r.createElement(c.default,f({},g,{onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop}),r.cloneElement(r.Children.only(i),{className:S,style:{...i.props.style,...v},transform:y}))}}e.default=g,p(g,"displayName","Draggable"),p(g,"propTypes",{...c.default.propTypes,axis:i.default.oneOf(["both","x","y","none"]),bounds:i.default.oneOfType([i.default.shape({left:i.default.number,right:i.default.number,top:i.default.number,bottom:i.default.number}),i.default.string,i.default.oneOf([!1])]),defaultClassName:i.default.string,defaultClassNameDragging:i.default.string,defaultClassNameDragged:i.default.string,defaultPosition:i.default.shape({x:i.default.number,y:i.default.number}),positionOffset:i.default.shape({x:i.default.oneOfType([i.default.number,i.default.string]),y:i.default.oneOfType([i.default.number,i.default.string])}),position:i.default.shape({x:i.default.number,y:i.default.number}),className:l.dontSetMe,style:l.dontSetMe,transform:l.dontSetMe}),p(g,"defaultProps",{...c.default.defaultProps,axis:"both",bounds:!1,defaultClassName:"react-draggable",defaultClassNameDragging:"react-draggable-dragging",defaultClassNameDragged:"react-draggable-dragged",defaultPosition:{x:0,y:0},scale:1})}(PE)),PE}var ew=function(){if(KE)return RE.exports;KE=1;const{default:e,DraggableCore:t}=JE();return RE.exports=e,RE.exports.default=e,RE.exports.DraggableCore=t,RE.exports}(),tw=je(ew),rw=function(){return rw=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},rw.apply(this,arguments)},iw={width:"100%",height:"10px",top:"0px",left:"0px",cursor:"row-resize"},nw={width:"10px",height:"100%",top:"0px",left:"0px",cursor:"col-resize"},sw={width:"20px",height:"20px",position:"absolute",zIndex:1},aw={top:rw(rw({},iw),{top:"-5px"}),right:rw(rw({},nw),{left:void 0,right:"-5px"}),bottom:rw(rw({},iw),{top:void 0,bottom:"-5px"}),left:rw(rw({},nw),{left:"-5px"}),topRight:rw(rw({},sw),{right:"-10px",top:"-10px",cursor:"ne-resize"}),bottomRight:rw(rw({},sw),{right:"-10px",bottom:"-10px",cursor:"se-resize"}),bottomLeft:rw(rw({},sw),{left:"-10px",bottom:"-10px",cursor:"sw-resize"}),topLeft:rw(rw({},sw),{left:"-10px",top:"-10px",cursor:"nw-resize"})},ow=h(function(e){var t=e.onResizeStart,r=e.direction,i=e.children,s=e.replaceStyles,a=e.className,o=n(function(e){t(e,r)},[t,r]),l=n(function(e){t(e,r)},[t,r]),c=u(function(){return rw(rw({position:"absolute",userSelect:"none"},aw[r]),null!=s?s:{})},[s,r]);return b("div",{className:a||void 0,style:c,onMouseDown:o,onTouchStart:l,children:i})}),lw=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function i(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}}(),cw=function(){return cw=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},cw.apply(this,arguments)},dw={width:"auto",height:"auto"},uw=function(e,t,r){return Math.max(Math.min(e,r),t)},hw=function(e,t,r){var i=Math.round(e/t);return i*t+r*(i-1)},fw=function(e,t){return new RegExp(e,"i").test(t)},pw=function(e){return Boolean(e.touches&&e.touches.length)},mw=function(e,t,r){void 0===r&&(r=0);var i=t.reduce(function(r,i,n){return Math.abs(i-e)<Math.abs(t[r]-e)?n:r},0),n=Math.abs(t[i]-e);return 0===r||n<r?t[i]:e},gw=function(e){return"auto"===(e=e.toString())||e.endsWith("px")||e.endsWith("%")||e.endsWith("vh")||e.endsWith("vw")||e.endsWith("vmax")||e.endsWith("vmin")?e:"".concat(e,"px")},vw=function(e,t,r,i){if(e&&"string"==typeof e){if(e.endsWith("px"))return Number(e.replace("px",""));if(e.endsWith("%"))return t*(Number(e.replace("%",""))/100);if(e.endsWith("vw"))return r*(Number(e.replace("vw",""))/100);if(e.endsWith("vh"))return i*(Number(e.replace("vh",""))/100)}return e},yw=["as","ref","style","className","grid","gridGap","snap","bounds","boundsByDirection","size","defaultSize","minWidth","minHeight","maxWidth","maxHeight","lockAspectRatio","lockAspectRatioExtraWidth","lockAspectRatioExtraHeight","enable","handleStyles","handleClasses","handleWrapperStyle","handleWrapperClass","children","onResizeStart","onResize","onResizeStop","handleComponent","scale","resizeRatio","snapGap"],bw="__resizable_base__",Ew=function(e){function t(t){var r,i,n,s,a=e.call(this,t)||this;return a.ratio=1,a.resizable=null,a.parentLeft=0,a.parentTop=0,a.resizableLeft=0,a.resizableRight=0,a.resizableTop=0,a.resizableBottom=0,a.targetLeft=0,a.targetTop=0,a.delta={width:0,height:0},a.appendBase=function(){if(!a.resizable||!a.window)return null;var e=a.parentNode;if(!e)return null;var t=a.window.document.createElement("div");return t.style.width="100%",t.style.height="100%",t.style.position="absolute",t.style.transform="scale(0, 0)",t.style.left="0",t.style.flex="0 0 100%",t.classList?t.classList.add(bw):t.className+=bw,e.appendChild(t),t},a.removeBase=function(e){var t=a.parentNode;t&&t.removeChild(e)},a.state={isResizing:!1,width:null!==(i=null===(r=a.propsSize)||void 0===r?void 0:r.width)&&void 0!==i?i:"auto",height:null!==(s=null===(n=a.propsSize)||void 0===n?void 0:n.height)&&void 0!==s?s:"auto",direction:"right",original:{x:0,y:0,width:0,height:0},backgroundStyle:{height:"100%",width:"100%",backgroundColor:"rgba(0,0,0,0)",cursor:"auto",opacity:0,position:"fixed",zIndex:9999,top:"0",left:"0",bottom:"0",right:"0"},flexBasis:void 0},a.onResizeStart=a.onResizeStart.bind(a),a.onMouseMove=a.onMouseMove.bind(a),a.onMouseUp=a.onMouseUp.bind(a),a}return lw(t,e),Object.defineProperty(t.prototype,"parentNode",{get:function(){return this.resizable?this.resizable.parentNode:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"window",{get:function(){return this.resizable&&this.resizable.ownerDocument?this.resizable.ownerDocument.defaultView:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"propsSize",{get:function(){return this.props.size||this.props.defaultSize||dw},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"size",{get:function(){var e=0,t=0;if(this.resizable&&this.window){var r=this.resizable.offsetWidth,i=this.resizable.offsetHeight,n=this.resizable.style.position;"relative"!==n&&(this.resizable.style.position="relative"),e="auto"!==this.resizable.style.width?this.resizable.offsetWidth:r,t="auto"!==this.resizable.style.height?this.resizable.offsetHeight:i,this.resizable.style.position=n}return{width:e,height:t}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sizeStyle",{get:function(){var e=this,t=this.props.size,r=function(t){var r;if(void 0===e.state[t]||"auto"===e.state[t])return"auto";if(e.propsSize&&e.propsSize[t]&&(null===(r=e.propsSize[t])||void 0===r?void 0:r.toString().endsWith("%"))){if(e.state[t].toString().endsWith("%"))return e.state[t].toString();var i=e.getParentSize(),n=Number(e.state[t].toString().replace("px",""))/i[t]*100;return"".concat(n,"%")}return gw(e.state[t])};return{width:t&&void 0!==t.width&&!this.state.isResizing?gw(t.width):r("width"),height:t&&void 0!==t.height&&!this.state.isResizing?gw(t.height):r("height")}},enumerable:!1,configurable:!0}),t.prototype.getParentSize=function(){if(!this.parentNode)return this.window?{width:this.window.innerWidth,height:this.window.innerHeight}:{width:0,height:0};var e=this.appendBase();if(!e)return{width:0,height:0};var t=!1,r=this.parentNode.style.flexWrap;"wrap"!==r&&(t=!0,this.parentNode.style.flexWrap="wrap"),e.style.position="relative",e.style.minWidth="100%",e.style.minHeight="100%";var i={width:e.offsetWidth,height:e.offsetHeight};return t&&(this.parentNode.style.flexWrap=r),this.removeBase(e),i},t.prototype.bindEvents=function(){this.window&&(this.window.addEventListener("mouseup",this.onMouseUp),this.window.addEventListener("mousemove",this.onMouseMove),this.window.addEventListener("mouseleave",this.onMouseUp),this.window.addEventListener("touchmove",this.onMouseMove,{capture:!0,passive:!1}),this.window.addEventListener("touchend",this.onMouseUp))},t.prototype.unbindEvents=function(){this.window&&(this.window.removeEventListener("mouseup",this.onMouseUp),this.window.removeEventListener("mousemove",this.onMouseMove),this.window.removeEventListener("mouseleave",this.onMouseUp),this.window.removeEventListener("touchmove",this.onMouseMove,!0),this.window.removeEventListener("touchend",this.onMouseUp))},t.prototype.componentDidMount=function(){if(this.resizable&&this.window){var e=this.window.getComputedStyle(this.resizable);this.setState({width:this.state.width||this.size.width,height:this.state.height||this.size.height,flexBasis:"auto"!==e.flexBasis?e.flexBasis:void 0})}},t.prototype.componentWillUnmount=function(){this.window&&this.unbindEvents()},t.prototype.createSizeForCssProperty=function(e,t){var r=this.propsSize&&this.propsSize[t];return"auto"!==this.state[t]||this.state.original[t]!==e||void 0!==r&&"auto"!==r?e:"auto"},t.prototype.calculateNewMaxFromBoundary=function(e,t){var r,i,n=this.props.boundsByDirection,s=this.state.direction,a=n&&fw("left",s),o=n&&fw("top",s);if("parent"===this.props.bounds){var l=this.parentNode;l&&(r=a?this.resizableRight-this.parentLeft:l.offsetWidth+(this.parentLeft-this.resizableLeft),i=o?this.resizableBottom-this.parentTop:l.offsetHeight+(this.parentTop-this.resizableTop))}else"window"===this.props.bounds?this.window&&(r=a?this.resizableRight:this.window.innerWidth-this.resizableLeft,i=o?this.resizableBottom:this.window.innerHeight-this.resizableTop):this.props.bounds&&(r=a?this.resizableRight-this.targetLeft:this.props.bounds.offsetWidth+(this.targetLeft-this.resizableLeft),i=o?this.resizableBottom-this.targetTop:this.props.bounds.offsetHeight+(this.targetTop-this.resizableTop));return r&&Number.isFinite(r)&&(e=e&&e<r?e:r),i&&Number.isFinite(i)&&(t=t&&t<i?t:i),{maxWidth:e,maxHeight:t}},t.prototype.calculateNewSizeFromDirection=function(e,t){var r,i=this.props.scale||1,n=(r=this.props.resizeRatio||1,Array.isArray(r)?r:[r,r]),s=n[0],a=n[1],o=this.state,l=o.direction,c=o.original,d=this.props,u=d.lockAspectRatio,h=d.lockAspectRatioExtraHeight,f=d.lockAspectRatioExtraWidth,p=c.width,m=c.height,g=h||0,v=f||0;return fw("right",l)&&(p=c.width+(e-c.x)*s/i,u&&(m=(p-v)/this.ratio+g)),fw("left",l)&&(p=c.width-(e-c.x)*s/i,u&&(m=(p-v)/this.ratio+g)),fw("bottom",l)&&(m=c.height+(t-c.y)*a/i,u&&(p=(m-g)*this.ratio+v)),fw("top",l)&&(m=c.height-(t-c.y)*a/i,u&&(p=(m-g)*this.ratio+v)),{newWidth:p,newHeight:m}},t.prototype.calculateNewSizeFromAspectRatio=function(e,t,r,i){var n=this.props,s=n.lockAspectRatio,a=n.lockAspectRatioExtraHeight,o=n.lockAspectRatioExtraWidth,l=void 0===i.width?10:i.width,c=void 0===r.width||r.width<0?e:r.width,d=void 0===i.height?10:i.height,u=void 0===r.height||r.height<0?t:r.height,h=a||0,f=o||0;if(s){var p=(d-h)*this.ratio+f,m=(u-h)*this.ratio+f,g=(l-f)/this.ratio+h,v=(c-f)/this.ratio+h,y=Math.max(l,p),b=Math.min(c,m),E=Math.max(d,g),w=Math.min(u,v);e=uw(e,y,b),t=uw(t,E,w)}else e=uw(e,l,c),t=uw(t,d,u);return{newWidth:e,newHeight:t}},t.prototype.setBoundingClientRect=function(){var e=1/(this.props.scale||1);if("parent"===this.props.bounds){var t=this.parentNode;if(t){var r=t.getBoundingClientRect();this.parentLeft=r.left*e,this.parentTop=r.top*e}}if(this.props.bounds&&"string"!=typeof this.props.bounds){var i=this.props.bounds.getBoundingClientRect();this.targetLeft=i.left*e,this.targetTop=i.top*e}if(this.resizable){var n=this.resizable.getBoundingClientRect(),s=n.left,a=n.top,o=n.right,l=n.bottom;this.resizableLeft=s*e,this.resizableRight=o*e,this.resizableTop=a*e,this.resizableBottom=l*e}},t.prototype.onResizeStart=function(e,t){if(this.resizable&&this.window){var r,i=0,n=0;if(e.nativeEvent&&function(e){return Boolean((e.clientX||0===e.clientX)&&(e.clientY||0===e.clientY))}(e.nativeEvent)?(i=e.nativeEvent.clientX,n=e.nativeEvent.clientY):e.nativeEvent&&pw(e.nativeEvent)&&(i=e.nativeEvent.touches[0].clientX,n=e.nativeEvent.touches[0].clientY),this.props.onResizeStart)if(this.resizable)if(!1===this.props.onResizeStart(e,t,this.resizable))return;this.props.size&&(void 0!==this.props.size.height&&this.props.size.height!==this.state.height&&this.setState({height:this.props.size.height}),void 0!==this.props.size.width&&this.props.size.width!==this.state.width&&this.setState({width:this.props.size.width})),this.ratio="number"==typeof this.props.lockAspectRatio?this.props.lockAspectRatio:this.size.width/this.size.height;var s=this.window.getComputedStyle(this.resizable);if("auto"!==s.flexBasis){var a=this.parentNode;if(a){var o=this.window.getComputedStyle(a).flexDirection;this.flexDir=o.startsWith("row")?"row":"column",r=s.flexBasis}}this.setBoundingClientRect(),this.bindEvents();var l={original:{x:i,y:n,width:this.size.width,height:this.size.height},isResizing:!0,backgroundStyle:cw(cw({},this.state.backgroundStyle),{cursor:this.window.getComputedStyle(e.target).cursor||"auto"}),direction:t,flexBasis:r};this.setState(l)}},t.prototype.onMouseMove=function(e){var t=this;if(this.state.isResizing&&this.resizable&&this.window){if(this.window.TouchEvent&&pw(e))try{e.preventDefault(),e.stopPropagation()}catch(e){}var r=this.props,i=r.maxWidth,n=r.maxHeight,s=r.minWidth,a=r.minHeight,o=pw(e)?e.touches[0].clientX:e.clientX,l=pw(e)?e.touches[0].clientY:e.clientY,c=this.state,d=c.direction,u=c.original,h=c.width,f=c.height,p=this.getParentSize(),m=function(e,t,r,i,n,s,a){return i=vw(i,e.width,t,r),n=vw(n,e.height,t,r),s=vw(s,e.width,t,r),a=vw(a,e.height,t,r),{maxWidth:void 0===i?void 0:Number(i),maxHeight:void 0===n?void 0:Number(n),minWidth:void 0===s?void 0:Number(s),minHeight:void 0===a?void 0:Number(a)}}(p,this.window.innerWidth,this.window.innerHeight,i,n,s,a);i=m.maxWidth,n=m.maxHeight,s=m.minWidth,a=m.minHeight;var g=this.calculateNewSizeFromDirection(o,l),y=g.newHeight,b=g.newWidth,E=this.calculateNewMaxFromBoundary(i,n);this.props.snap&&this.props.snap.x&&(b=mw(b,this.props.snap.x,this.props.snapGap)),this.props.snap&&this.props.snap.y&&(y=mw(y,this.props.snap.y,this.props.snapGap));var w=this.calculateNewSizeFromAspectRatio(b,y,{width:E.maxWidth,height:E.maxHeight},{width:s,height:a});if(b=w.newWidth,y=w.newHeight,this.props.grid){var S=hw(b,this.props.grid[0],this.props.gridGap?this.props.gridGap[0]:0),T=hw(y,this.props.grid[1],this.props.gridGap?this.props.gridGap[1]:0),x=this.props.snapGap||0;b=0===x||Math.abs(S-b)<=x?S:b,y=0===x||Math.abs(T-y)<=x?T:y}var A={width:b-u.width,height:y-u.height};if(this.delta=A,h&&"string"==typeof h)if(h.endsWith("%")){var k=b/p.width*100;b="".concat(k,"%")}else if(h.endsWith("vw")){var I=b/this.window.innerWidth*100;b="".concat(I,"vw")}else if(h.endsWith("vh")){var L=b/this.window.innerHeight*100;b="".concat(L,"vh")}if(f&&"string"==typeof f)if(f.endsWith("%")){k=y/p.height*100;y="".concat(k,"%")}else if(f.endsWith("vw")){I=y/this.window.innerWidth*100;y="".concat(I,"vw")}else if(f.endsWith("vh")){L=y/this.window.innerHeight*100;y="".concat(L,"vh")}var R={width:this.createSizeForCssProperty(b,"width"),height:this.createSizeForCssProperty(y,"height")};"row"===this.flexDir?R.flexBasis=R.width:"column"===this.flexDir&&(R.flexBasis=R.height);var P=this.state.width!==R.width,C=this.state.height!==R.height,D=this.state.flexBasis!==R.flexBasis,_=P||C||D;_&&v(function(){t.setState(R)}),this.props.onResize&&_&&this.props.onResize(e,d,this.resizable,A)}},t.prototype.onMouseUp=function(e){var t,r,i=this.state,n=i.isResizing,s=i.direction;i.original,n&&this.resizable&&(this.props.onResizeStop&&this.props.onResizeStop(e,s,this.resizable,this.delta),this.props.size&&this.setState({width:null!==(t=this.props.size.width)&&void 0!==t?t:"auto",height:null!==(r=this.props.size.height)&&void 0!==r?r:"auto"}),this.unbindEvents(),this.setState({isResizing:!1,backgroundStyle:cw(cw({},this.state.backgroundStyle),{cursor:"auto"})}))},t.prototype.updateSize=function(e){var t,r;this.setState({width:null!==(t=e.width)&&void 0!==t?t:"auto",height:null!==(r=e.height)&&void 0!==r?r:"auto"})},t.prototype.renderResizer=function(){var e=this,t=this.props,r=t.enable,i=t.handleStyles,n=t.handleClasses,s=t.handleWrapperStyle,a=t.handleWrapperClass,o=t.handleComponent;if(!r)return null;var l=Object.keys(r).map(function(t){return!1!==r[t]?b(ow,{direction:t,onResizeStart:e.onResizeStart,replaceStyles:i&&i[t],className:n&&n[t],children:o&&o[t]?o[t]:null},t):null});return b("div",{className:a,style:s,children:l})},t.prototype.render=function(){var e=this,t=Object.keys(this.props).reduce(function(t,r){return-1!==yw.indexOf(r)||(t[r]=e.props[r]),t},{}),r=cw(cw(cw({position:"relative",userSelect:this.state.isResizing?"none":"auto"},this.props.style),this.sizeStyle),{maxWidth:this.props.maxWidth,maxHeight:this.props.maxHeight,minWidth:this.props.minWidth,minHeight:this.props.minHeight,boxSizing:"border-box",flexShrink:0});this.state.flexBasis&&(r.flexBasis=this.state.flexBasis);var i=this.props.as||"div";return w(i,cw({style:r,className:this.props.className},t,{ref:function(t){t&&(e.resizable=t)},children:[this.state.isResizing&&b("div",{style:this.state.backgroundStyle}),this.props.children,this.renderResizer()]}))},t.defaultProps={as:"div",onResizeStart:function(){},onResize:function(){},onResizeStop:function(){},enable:{top:!0,right:!0,bottom:!0,left:!0,topRight:!0,bottomRight:!0,bottomLeft:!0,topLeft:!0},style:{},grid:[1,1],gridGap:[0,0],lockAspectRatio:!1,lockAspectRatioExtraWidth:0,lockAspectRatioExtraHeight:0,scale:1,resizeRatio:1,snapGap:0},t}(f),ww=function(e,t){return ww=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},ww(e,t)};var Sw=function(){return Sw=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},Sw.apply(this,arguments)};var Tw={width:"auto",height:"auto",display:"inline-block",position:"absolute",top:0,left:0},xw=function(e){function t(t){var r=e.call(this,t)||this;return r.resizingPosition={x:0,y:0},r.offsetFromParent={left:0,top:0},r.resizableElement={current:null},r.originalPosition={x:0,y:0},r.state={resizing:!1,bounds:{top:0,right:0,bottom:0,left:0},maxWidth:t.maxWidth,maxHeight:t.maxHeight},r.onResizeStart=r.onResizeStart.bind(r),r.onResize=r.onResize.bind(r),r.onResizeStop=r.onResizeStop.bind(r),r.onDragStart=r.onDragStart.bind(r),r.onDrag=r.onDrag.bind(r),r.onDragStop=r.onDragStop.bind(r),r.getMaxSizesFromProps=r.getMaxSizesFromProps.bind(r),r}return function(e,t){function r(){this.constructor=e}ww(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}(t,e),t.prototype.componentDidMount=function(){this.updateOffsetFromParent();var e=this.offsetFromParent,t=e.left,r=e.top,i=this.getDraggablePosition(),n=i.x,s=i.y;this.draggable.setState({x:n-t,y:s-r}),this.forceUpdate()},t.prototype.getDraggablePosition=function(){var e=this.draggable.state;return{x:e.x,y:e.y}},t.prototype.getParent=function(){return this.resizable&&this.resizable.parentNode},t.prototype.getParentSize=function(){return this.resizable.getParentSize()},t.prototype.getMaxSizesFromProps=function(){return{maxWidth:void 0===this.props.maxWidth?Number.MAX_SAFE_INTEGER:this.props.maxWidth,maxHeight:void 0===this.props.maxHeight?Number.MAX_SAFE_INTEGER:this.props.maxHeight}},t.prototype.getSelfElement=function(){return this.resizable&&this.resizable.resizable},t.prototype.getOffsetHeight=function(e){var t=this.props.scale;switch(this.props.bounds){case"window":return window.innerHeight/t;case"body":return document.body.offsetHeight/t;default:return e.offsetHeight}},t.prototype.getOffsetWidth=function(e){var t=this.props.scale;switch(this.props.bounds){case"window":return window.innerWidth/t;case"body":return document.body.offsetWidth/t;default:return e.offsetWidth}},t.prototype.onDragStart=function(e,t){this.props.onDragStart&&this.props.onDragStart(e,t);var r=this.getDraggablePosition();if(this.originalPosition=r,this.props.bounds){var i,n=this.getParent(),s=this.props.scale;if("parent"===this.props.bounds)i=n;else{if("body"===this.props.bounds){var a=n.getBoundingClientRect(),o=a.left,l=a.top,c=document.body.getBoundingClientRect(),d=-(o-n.offsetLeft*s-c.left)/s,u=-(l-n.offsetTop*s-c.top)/s,h=(document.body.offsetWidth-this.resizable.size.width*s)/s+d,f=(document.body.offsetHeight-this.resizable.size.height*s)/s+u;return this.setState({bounds:{top:u,right:h,bottom:f,left:d}})}if("window"===this.props.bounds){if(!this.resizable)return;var p=n.getBoundingClientRect(),m=p.left,g=p.top,v=-(m-n.offsetLeft*s)/s,y=-(g-n.offsetTop*s)/s;h=(window.innerWidth-this.resizable.size.width*s)/s+v,f=(window.innerHeight-this.resizable.size.height*s)/s+y;return this.setState({bounds:{top:y,right:h,bottom:f,left:v}})}"string"==typeof this.props.bounds?i=document.querySelector(this.props.bounds):this.props.bounds instanceof HTMLElement&&(i=this.props.bounds)}if(i instanceof HTMLElement&&n instanceof HTMLElement){var b=i.getBoundingClientRect(),E=b.left,w=b.top,S=n.getBoundingClientRect(),T=(E-S.left)/s,x=w-S.top;if(this.resizable){this.updateOffsetFromParent();var A=this.offsetFromParent;this.setState({bounds:{top:x-A.top,right:T+(i.offsetWidth-this.resizable.size.width)-A.left/s,bottom:x+(i.offsetHeight-this.resizable.size.height)-A.top,left:T-A.left/s}})}}}},t.prototype.onDrag=function(e,t){if(this.props.onDrag){var r=this.offsetFromParent,i=r.left,n=r.top;return this.props.dragAxis&&"both"!==this.props.dragAxis?"x"===this.props.dragAxis?this.props.onDrag(e,Sw(Sw({},t),{x:t.x+i,y:this.originalPosition.y+n,deltaY:0})):"y"===this.props.dragAxis?this.props.onDrag(e,Sw(Sw({},t),{x:this.originalPosition.x+i,y:t.y+n,deltaX:0})):void 0:this.props.onDrag(e,Sw(Sw({},t),{x:t.x+i,y:t.y+n}))}},t.prototype.onDragStop=function(e,t){if(this.props.onDragStop){var r=this.offsetFromParent,i=r.left,n=r.top;return this.props.dragAxis&&"both"!==this.props.dragAxis?"x"===this.props.dragAxis?this.props.onDragStop(e,Sw(Sw({},t),{x:t.x+i,y:this.originalPosition.y+n,deltaY:0})):"y"===this.props.dragAxis?this.props.onDragStop(e,Sw(Sw({},t),{x:this.originalPosition.x+i,y:t.y+n,deltaX:0})):void 0:this.props.onDragStop(e,Sw(Sw({},t),{x:t.x+i,y:t.y+n}))}},t.prototype.onResizeStart=function(e,t,r){e.stopPropagation(),this.setState({resizing:!0});var i=this.props.scale,n=this.offsetFromParent,s=this.getDraggablePosition();if(this.resizingPosition={x:s.x+n.left,y:s.y+n.top},this.originalPosition=s,this.props.bounds){var a=this.getParent(),o=void 0;"parent"===this.props.bounds?o=a:"body"===this.props.bounds?o=document.body:"window"===this.props.bounds?o=window:"string"==typeof this.props.bounds?o=document.querySelector(this.props.bounds):this.props.bounds instanceof HTMLElement&&(o=this.props.bounds);var l=this.getSelfElement();if(l instanceof Element&&(o instanceof HTMLElement||o===window)&&a instanceof HTMLElement){var c=this.getMaxSizesFromProps(),d=c.maxWidth,u=c.maxHeight,h=this.getParentSize();if(d&&"string"==typeof d)if(d.endsWith("%")){var f=Number(d.replace("%",""))/100;d=h.width*f}else d.endsWith("px")&&(d=Number(d.replace("px","")));if(u&&"string"==typeof u)if(u.endsWith("%")){f=Number(u.replace("%",""))/100;u=h.height*f}else u.endsWith("px")&&(u=Number(u.replace("px","")));var p=l.getBoundingClientRect(),m=p.left,g=p.top,v="window"===this.props.bounds?{left:0,top:0}:o.getBoundingClientRect(),y=v.left,b=v.top,E=this.getOffsetWidth(o),w=this.getOffsetHeight(o),S=t.toLowerCase().endsWith("left"),T=t.toLowerCase().endsWith("right"),x=t.startsWith("top"),A=t.startsWith("bottom");if((S||x)&&this.resizable){var k=(m-y)/i+this.resizable.size.width;this.setState({maxWidth:k>Number(d)?d:k})}if(T||this.props.lockAspectRatio&&!S&&!x){k=E+(y-m)/i;this.setState({maxWidth:k>Number(d)?d:k})}if((x||S)&&this.resizable){k=(g-b)/i+this.resizable.size.height;this.setState({maxHeight:k>Number(u)?u:k})}if(A||this.props.lockAspectRatio&&!x&&!S){k=w+(b-g)/i;this.setState({maxHeight:k>Number(u)?u:k})}}}else this.setState({maxWidth:this.props.maxWidth,maxHeight:this.props.maxHeight});this.props.onResizeStart&&this.props.onResizeStart(e,t,r)},t.prototype.onResize=function(e,t,r,i){var n=this,s={x:this.originalPosition.x,y:this.originalPosition.y},a=-i.width,o=-i.height;["top","left","topLeft","bottomLeft","topRight"].includes(t)&&("bottomLeft"===t?s.x+=a:("topRight"===t||(s.x+=a),s.y+=o));var l=this.draggable.state;s.x===l.x&&s.y===l.y||v(function(){n.draggable.setState(s)}),this.updateOffsetFromParent();var c=this.offsetFromParent,d=this.getDraggablePosition().x+c.left,u=this.getDraggablePosition().y+c.top;this.resizingPosition={x:d,y:u},this.props.onResize&&this.props.onResize(e,t,r,i,{x:d,y:u})},t.prototype.onResizeStop=function(e,t,r,i){this.setState({resizing:!1});var n=this.getMaxSizesFromProps(),s=n.maxWidth,a=n.maxHeight;this.setState({maxWidth:s,maxHeight:a}),this.props.onResizeStop&&this.props.onResizeStop(e,t,r,i,this.resizingPosition)},t.prototype.updateSize=function(e){this.resizable&&this.resizable.updateSize({width:e.width,height:e.height})},t.prototype.updatePosition=function(e){this.draggable.setState(e)},t.prototype.updateOffsetFromParent=function(){var e=this.props.scale,t=this.getParent(),r=this.getSelfElement();if(!t||null===r)return{top:0,left:0};var i=t.getBoundingClientRect(),n=i.left,s=i.top,a=r.getBoundingClientRect(),o=this.getDraggablePosition(),l=t.scrollLeft,c=t.scrollTop;this.offsetFromParent={left:a.left-n+l-o.x*e,top:a.top-s+c-o.y*e}},t.prototype.render=function(){var e=this,t=this.props,r=t.disableDragging,i=t.style,n=t.dragHandleClassName,s=t.position,a=t.onMouseDown,o=t.onMouseUp,l=t.dragAxis,d=t.dragGrid,u=t.bounds,h=t.enableUserSelectHack,f=t.cancel,p=t.children;t.onResizeStart,t.onResize,t.onResizeStop,t.onDragStart,t.onDrag,t.onDragStop;var m=t.resizeHandleStyles,g=t.resizeHandleClasses,v=t.resizeHandleComponent,y=t.enableResizing,b=t.resizeGrid,E=t.resizeHandleWrapperClass,w=t.resizeHandleWrapperStyle,S=t.scale,T=t.allowAnyClick,x=t.dragPositionOffset,A=function(e,t){var r={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(r[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(i=Object.getOwnPropertySymbols(e);n<i.length;n++)t.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(e,i[n])&&(r[i[n]]=e[i[n]])}return r}(t,["disableDragging","style","dragHandleClassName","position","onMouseDown","onMouseUp","dragAxis","dragGrid","bounds","enableUserSelectHack","cancel","children","onResizeStart","onResize","onResizeStop","onDragStart","onDrag","onDragStop","resizeHandleStyles","resizeHandleClasses","resizeHandleComponent","enableResizing","resizeGrid","resizeHandleWrapperClass","resizeHandleWrapperStyle","scale","allowAnyClick","dragPositionOffset"]),k=this.props.default?Sw({},this.props.default):void 0;delete A.default;var I,L=r||n?{cursor:"auto"}:{cursor:"move"},R=Sw(Sw(Sw({},Tw),L),i),P=this.offsetFromParent,C=P.left,D=P.top;s&&(I={x:s.x-C,y:s.y-D});var _,O=this.state.resizing?void 0:I,M=this.state.resizing?"both":l;return c(tw,{ref:function(t){t&&(e.draggable=t)},handle:n?".".concat(n):void 0,defaultPosition:k,onMouseDown:a,onMouseUp:o,onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop,axis:M,disabled:r,grid:d,bounds:u?this.state.bounds:void 0,position:O,enableUserSelectHack:h,cancel:f,scale:S,allowAnyClick:T,nodeRef:this.resizableElement,positionOffset:x},c(Ew,Sw({},A,{ref:function(t){t&&(e.resizable=t,e.resizableElement.current=t.resizable)},defaultSize:k,size:this.props.size,enable:"boolean"==typeof y?(_=y,{bottom:_,bottomLeft:_,bottomRight:_,left:_,right:_,top:_,topLeft:_,topRight:_}):y,onResizeStart:this.onResizeStart,onResize:this.onResize,onResizeStop:this.onResizeStop,style:R,minWidth:this.props.minWidth,minHeight:this.props.minHeight,maxWidth:this.state.resizing?this.state.maxWidth:this.props.maxWidth,maxHeight:this.state.resizing?this.state.maxHeight:this.props.maxHeight,grid:b,handleWrapperClass:E,handleWrapperStyle:w,lockAspectRatio:this.props.lockAspectRatio,lockAspectRatioExtraWidth:this.props.lockAspectRatioExtraWidth,lockAspectRatioExtraHeight:this.props.lockAspectRatioExtraHeight,handleStyles:m,handleClasses:g,handleComponent:v,scale:this.props.scale}),p))},t.defaultProps={maxWidth:Number.MAX_SAFE_INTEGER,maxHeight:Number.MAX_SAFE_INTEGER,scale:1,onResizeStart:function(){},onResize:function(){},onResizeStop:function(){},onDragStart:function(){},onDrag:function(){},onDragStop:function(){}},t}(f);const Aw=({eventId:e})=>{const[r,i]=s(!1),{PLAYER_BASE_URL:n}=gt();if(r)return null;const{w:a,h:o,left:l,top:c}=(()=>{const e=window.visualViewport;return e?{w:e.width,h:e.height,left:e.offsetLeft,top:e.offsetTop}:{w:window.innerWidth,h:window.innerHeight,left:0,top:0}})();return t.createElement(xw,{minWidth:240,lockAspectRatio:9/17.05,style:{zIndex:99999},default:{width:240,height:455,x:l+a-240-50,y:c+o-427-28-50},bounds:"window",dragHandleClassName:"live-floating-drag-handle"},t.createElement("div",{className:"flex flex-col w-full h-full",style:{borderRadius:8,overflow:"hidden",boxShadow:"0 4px 24px rgba(0,0,0,0.4)"}},t.createElement("div",{className:"live-floating-drag-handle flex items-center justify-between",style:{height:28,minHeight:28,background:"#111",cursor:"grab",padding:"0 8px",userSelect:"none"}},t.createElement(oi,{size:16,color:"#888"}),t.createElement("button",{className:"cursor-pointer",style:{color:"#ccc",lineHeight:0},onClick:()=>i(!0),"aria-label":"Close"},t.createElement(gi,{size:16}))),t.createElement("iframe",{src:`${n}/live/${e}`,style:{flex:1,border:0,display:"block",minHeight:0},allow:"autoplay; fullscreen; picture-in-picture",allowFullScreen:!0,scrolling:"no",referrerPolicy:"no-referrer-when-downgrade"})))},kw=({eventId:e})=>e?t.createElement(qr.div,{style:{position:"fixed",inset:0,pointerEvents:"none",zIndex:99999}},t.createElement(_o,null),t.createElement("div",{style:{pointerEvents:"auto"}},t.createElement(Aw,{eventId:e}))):null;export{Bd as CollectionShowcase,qd as FloatingCollectionPlayer,Wd as FloatingPlayer,kw as LiveFloatingPlayer,LE as LiveWidget,Bo as PreviewPlayer,$o as ShoppingPlayer,or as ViewPlayer,Ld as WidgetPlayer,mt as configure};
|
|
40
|
+
*/function ki(t,r=[]){let i=[];const n=()=>{const r=i.map(t=>e.createContext(t));return function(i){const n=i?.[t]||r;return e.useMemo(()=>({[`__scope${t}`]:{...i,[t]:n}}),[i,n])}};return n.scopeName=t,[function(r,n){const s=e.createContext(n),a=i.length;i=[...i,n];const o=r=>{const{scope:i,children:n,...o}=r,l=i?.[t]?.[a]||s,c=e.useMemo(()=>o,Object.values(o));return b(l.Provider,{value:c,children:n})};return o.displayName=r+"Provider",[o,function(i,o){const l=o?.[t]?.[a]||s,c=e.useContext(l);if(c)return c;if(void 0!==n)return n;throw new Error(`\`${i}\` must be used within \`${r}\``)}]},Ii(n,...r)]}function Ii(...t){const r=t[0];if(1===t.length)return r;const i=()=>{const i=t.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(t){const n=i.reduce((e,{useScope:r,scopeName:i})=>({...e,...r(t)[`__scope${i}`]}),{});return e.useMemo(()=>({[`__scope${r.scopeName}`]:n}),[n])}};return i.scopeName=r.scopeName,i}function Li(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function Ri(...e){return t=>{let r=!1;const i=e.map(e=>{const i=Li(e,t);return r||"function"!=typeof i||(r=!0),i});if(r)return()=>{for(let t=0;t<i.length;t++){const r=i[t];"function"==typeof r?r():Li(e[t],null)}}}}function Pi(...t){return e.useCallback(Ri(...t),t)}var Ci=e.forwardRef((t,r)=>{const{children:i,...n}=t,s=e.Children.toArray(i),a=s.find(Oi);if(a){const t=a.props.children,i=s.map(r=>r===a?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:r);return b(Di,{...n,ref:r,children:e.isValidElement(t)?e.cloneElement(t,void 0,i):null})}return b(Di,{...n,ref:r,children:i})});Ci.displayName="Slot";var Di=e.forwardRef((t,r)=>{const{children:i,...n}=t;if(e.isValidElement(i)){const t=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;if(r)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r)return e.props.ref;return e.props.ref||e.ref}(i),s=function(e,t){const r={...t};for(const i in t){const n=e[i],s=t[i];/^on[A-Z]/.test(i)?n&&s?r[i]=(...e)=>{s(...e),n(...e)}:n&&(r[i]=n):"style"===i?r[i]={...n,...s}:"className"===i&&(r[i]=[n,s].filter(Boolean).join(" "))}return{...e,...r}}(n,i.props);return i.type!==e.Fragment&&(s.ref=r?Ri(r,t):t),e.cloneElement(i,s)}return e.Children.count(i)>1?e.Children.only(null):null});Di.displayName="SlotClone";var _i=({children:e})=>b(E,{children:e});function Oi(t){return e.isValidElement(t)&&t.type===_i}function Mi(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function Ni(...e){return t=>{let r=!1;const i=e.map(e=>{const i=Mi(e,t);return r||"function"!=typeof i||(r=!0),i});if(r)return()=>{for(let t=0;t<i.length;t++){const r=i[t];"function"==typeof r?r():Mi(e[t],null)}}}}function Fi(e,t,{checkForDefaultPrevented:r=!0}={}){return function(i){if(e?.(i),!1===r||!i.defaultPrevented)return t?.(i)}}function $i(t){const r=e.useRef(t);return e.useEffect(()=>{r.current=t}),e.useMemo(()=>(...e)=>r.current?.(...e),[])}function Bi({prop:t,defaultProp:r,onChange:i=()=>{}}){const[n,s]=function({defaultProp:t,onChange:r}){const i=e.useState(t),[n]=i,s=e.useRef(n),a=$i(r);return e.useEffect(()=>{s.current!==n&&(a(n),s.current=n)},[n,s,a]),i}({defaultProp:r,onChange:i}),a=void 0!==t,o=a?t:n,l=$i(i);return[o,e.useCallback(e=>{if(a){const r="function"==typeof e?e(t):e;r!==t&&l(r)}else s(e)},[a,t,s,l])]}var Ui=e.forwardRef((t,r)=>{const{children:i,...n}=t,s=e.Children.toArray(i),a=s.find(ji);if(a){const t=a.props.children,i=s.map(r=>r===a?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:r);return b(zi,{...n,ref:r,children:e.isValidElement(t)?e.cloneElement(t,void 0,i):null})}return b(zi,{...n,ref:r,children:i})});Ui.displayName="Slot";var zi=e.forwardRef((t,r)=>{const{children:i,...n}=t;if(e.isValidElement(i)){const t=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;if(r)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r)return e.props.ref;return e.props.ref||e.ref}(i),s=function(e,t){const r={...t};for(const i in t){const n=e[i],s=t[i];/^on[A-Z]/.test(i)?n&&s?r[i]=(...e)=>{s(...e),n(...e)}:n&&(r[i]=n):"style"===i?r[i]={...n,...s}:"className"===i&&(r[i]=[n,s].filter(Boolean).join(" "))}return{...e,...r}}(n,i.props);return i.type!==e.Fragment&&(s.ref=r?Ni(r,t):t),e.cloneElement(i,s)}return e.Children.count(i)>1?e.Children.only(null):null});zi.displayName="SlotClone";var Gi=({children:e})=>b(E,{children:e});function ji(t){return e.isValidElement(t)&&t.type===Gi}var Hi=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"].reduce((t,r)=>{const i=e.forwardRef((e,t)=>{const{asChild:i,...n}=e,s=i?Ui:r;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),b(s,{...n,ref:t})});return i.displayName=`Primitive.${r}`,{...t,[r]:i}},{}),Vi=Boolean(globalThis?.document)?e.useLayoutEffect:()=>{};function Wi(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function Yi(...e){return t=>{let r=!1;const i=e.map(e=>{const i=Wi(e,t);return r||"function"!=typeof i||(r=!0),i});if(r)return()=>{for(let t=0;t<i.length;t++){const r=i[t];"function"==typeof r?r():Wi(e[t],null)}}}}var Ki=e.forwardRef((t,r)=>{const{children:i,...n}=t,s=e.Children.toArray(i),a=s.find(Qi);if(a){const t=a.props.children,i=s.map(r=>r===a?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:r);return b(qi,{...n,ref:r,children:e.isValidElement(t)?e.cloneElement(t,void 0,i):null})}return b(qi,{...n,ref:r,children:i})});Ki.displayName="Slot";var qi=e.forwardRef((t,r)=>{const{children:i,...n}=t;if(e.isValidElement(i)){const t=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;if(r)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r)return e.props.ref;return e.props.ref||e.ref}(i),s=function(e,t){const r={...t};for(const i in t){const n=e[i],s=t[i];/^on[A-Z]/.test(i)?n&&s?r[i]=(...e)=>{s(...e),n(...e)}:n&&(r[i]=n):"style"===i?r[i]={...n,...s}:"className"===i&&(r[i]=[n,s].filter(Boolean).join(" "))}return{...e,...r}}(n,i.props);return i.type!==e.Fragment&&(s.ref=r?Yi(r,t):t),e.cloneElement(i,s)}return e.Children.count(i)>1?e.Children.only(null):null});qi.displayName="SlotClone";var Xi=({children:e})=>b(E,{children:e});function Qi(t){return e.isValidElement(t)&&t.type===Xi}var Zi=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"].reduce((t,r)=>{const i=e.forwardRef((e,t)=>{const{asChild:i,...n}=e,s=i?Ki:r;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),b(s,{...n,ref:t})});return i.displayName=`Primitive.${r}`,{...t,[r]:i}},{});function Ji(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function en(...t){return e.useCallback(function(...e){return t=>{let r=!1;const i=e.map(e=>{const i=Ji(e,t);return r||"function"!=typeof i||(r=!0),i});if(r)return()=>{for(let t=0;t<i.length;t++){const r=i[t];"function"==typeof r?r():Ji(e[t],null)}}}}(...t),t)}var tn=Boolean(globalThis?.document)?e.useLayoutEffect:()=>{};var rn=t=>{const{present:r,children:i}=t,n=function(t){const[r,i]=e.useState(),n=e.useRef({}),s=e.useRef(t),a=e.useRef("none"),o=t?"mounted":"unmounted",[l,c]=function(t,r){return e.useReducer((e,t)=>r[e][t]??e,t)}(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return e.useEffect(()=>{const e=nn(n.current);a.current="mounted"===l?e:"none"},[l]),tn(()=>{const e=n.current,r=s.current;if(r!==t){const i=a.current,n=nn(e);if(t)c("MOUNT");else if("none"===n||"none"===e?.display)c("UNMOUNT");else{c(r&&i!==n?"ANIMATION_OUT":"UNMOUNT")}s.current=t}},[t,c]),tn(()=>{if(r){let e;const t=r.ownerDocument.defaultView??window,i=i=>{const a=nn(n.current).includes(i.animationName);if(i.target===r&&a&&(c("ANIMATION_END"),!s.current)){const i=r.style.animationFillMode;r.style.animationFillMode="forwards",e=t.setTimeout(()=>{"forwards"===r.style.animationFillMode&&(r.style.animationFillMode=i)})}},o=e=>{e.target===r&&(a.current=nn(n.current))};return r.addEventListener("animationstart",o),r.addEventListener("animationcancel",i),r.addEventListener("animationend",i),()=>{t.clearTimeout(e),r.removeEventListener("animationstart",o),r.removeEventListener("animationcancel",i),r.removeEventListener("animationend",i)}}c("ANIMATION_END")},[r,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:e.useCallback(e=>{e&&(n.current=getComputedStyle(e)),i(e)},[])}}(r),s="function"==typeof i?i({present:n.isPresent}):e.Children.only(i),a=en(n.ref,function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;if(r)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r)return e.props.ref;return e.props.ref||e.ref}(s));return"function"==typeof i||n.isPresent?e.cloneElement(s,{ref:a}):null};function nn(e){return e?.animationName||"none"}rn.displayName="Presence";var sn=Boolean(globalThis?.document)?e.useLayoutEffect:()=>{},an=e["useId".toString()]||(()=>{}),on=0;function ln(t){const[r,i]=e.useState(an());return sn(()=>{i(e=>e??String(on++))},[t]),r?`radix-${r}`:""}var cn="Collapsible",[dn,un]=ki(cn),[hn,fn]=dn(cn),pn=e.forwardRef((t,r)=>{const{__scopeCollapsible:i,open:n,defaultOpen:s,disabled:a,onOpenChange:o,...l}=t,[c=!1,d]=Bi({prop:n,defaultProp:s,onChange:o});return b(hn,{scope:i,disabled:a,contentId:ln(),open:c,onOpenToggle:e.useCallback(()=>d(e=>!e),[d]),children:b(Zi.div,{"data-state":En(c),"data-disabled":a?"":void 0,...l,ref:r})})});pn.displayName=cn;var mn="CollapsibleTrigger",gn=e.forwardRef((e,t)=>{const{__scopeCollapsible:r,...i}=e,n=fn(mn,r);return b(Zi.button,{type:"button","aria-controls":n.contentId,"aria-expanded":n.open||!1,"data-state":En(n.open),"data-disabled":n.disabled?"":void 0,disabled:n.disabled,...i,ref:t,onClick:Fi(e.onClick,n.onOpenToggle)})});gn.displayName=mn;var vn="CollapsibleContent",yn=e.forwardRef((e,t)=>{const{forceMount:r,...i}=e,n=fn(vn,e.__scopeCollapsible);return b(rn,{present:r||n.open,children:({present:e})=>b(bn,{...i,ref:t,present:e})})});yn.displayName=vn;var bn=e.forwardRef((t,r)=>{const{__scopeCollapsible:i,present:n,children:s,...a}=t,o=fn(vn,i),[l,c]=e.useState(n),d=e.useRef(null),u=function(...t){return e.useCallback(Yi(...t),t)}(r,d),h=e.useRef(0),f=h.current,p=e.useRef(0),m=p.current,g=o.open||l,v=e.useRef(g),y=e.useRef(void 0);return e.useEffect(()=>{const e=requestAnimationFrame(()=>v.current=!1);return()=>cancelAnimationFrame(e)},[]),Vi(()=>{const e=d.current;if(e){y.current=y.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration="0s",e.style.animationName="none";const t=e.getBoundingClientRect();h.current=t.height,p.current=t.width,v.current||(e.style.transitionDuration=y.current.transitionDuration,e.style.animationName=y.current.animationName),c(n)}},[o.open,n]),b(Zi.div,{"data-state":En(o.open),"data-disabled":o.disabled?"":void 0,id:o.contentId,hidden:!g,...a,ref:u,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...t.style},children:g&&s})});function En(e){return e?"open":"closed"}var wn=pn,Sn=gn,Tn=yn,xn=e.createContext(void 0);var An="Accordion",kn=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[In,Ln,Rn]=function(e){const r=e+"CollectionProvider",[i,n]=ki(r),[s,a]=i(r,{collectionRef:{current:null},itemMap:new Map}),o=e=>{const{scope:r,children:i}=e,n=t.useRef(null),a=t.useRef(new Map).current;return b(s,{scope:r,itemMap:a,collectionRef:n,children:i})};o.displayName=r;const l=e+"CollectionSlot",c=t.forwardRef((e,t)=>{const{scope:r,children:i}=e,n=Pi(t,a(l,r).collectionRef);return b(Ci,{ref:n,children:i})});c.displayName=l;const d=e+"CollectionItemSlot",u="data-radix-collection-item",h=t.forwardRef((e,r)=>{const{scope:i,children:n,...s}=e,o=t.useRef(null),l=Pi(r,o),c=a(d,i);return t.useEffect(()=>(c.itemMap.set(o,{ref:o,...s}),()=>{c.itemMap.delete(o)})),b(Ci,{[u]:"",ref:l,children:n})});return h.displayName=d,[{Provider:o,Slot:c,ItemSlot:h},function(r){const i=a(e+"CollectionConsumer",r),n=t.useCallback(()=>{const e=i.collectionRef.current;if(!e)return[];const t=Array.from(e.querySelectorAll(`[${u}]`)),r=Array.from(i.itemMap.values()).sort((e,r)=>t.indexOf(e.ref.current)-t.indexOf(r.ref.current));return r},[i.collectionRef,i.itemMap]);return n},n]}(An),[Pn,Cn]=ki(An,[Rn,un]),Dn=un(),_n=t.forwardRef((e,t)=>{const{type:r,...i}=e,n=i,s=i;return b(In.Provider,{scope:e.__scopeAccordion,children:"multiple"===r?b(Bn,{...s,ref:t}):b($n,{...n,ref:t})})});_n.displayName=An;var[On,Mn]=Pn(An),[Nn,Fn]=Pn(An,{collapsible:!1}),$n=t.forwardRef((e,r)=>{const{value:i,defaultValue:n,onValueChange:s=()=>{},collapsible:a=!1,...o}=e,[l,c]=Bi({prop:i,defaultProp:n,onChange:s});return b(On,{scope:e.__scopeAccordion,value:l?[l]:[],onItemOpen:c,onItemClose:t.useCallback(()=>a&&c(""),[a,c]),children:b(Nn,{scope:e.__scopeAccordion,collapsible:a,children:b(Gn,{...o,ref:r})})})}),Bn=t.forwardRef((e,r)=>{const{value:i,defaultValue:n,onValueChange:s=()=>{},...a}=e,[o=[],l]=Bi({prop:i,defaultProp:n,onChange:s}),c=t.useCallback(e=>l((t=[])=>[...t,e]),[l]),d=t.useCallback(e=>l((t=[])=>t.filter(t=>t!==e)),[l]);return b(On,{scope:e.__scopeAccordion,value:o,onItemOpen:c,onItemClose:d,children:b(Nn,{scope:e.__scopeAccordion,collapsible:!0,children:b(Gn,{...a,ref:r})})})}),[Un,zn]=Pn(An),Gn=t.forwardRef((r,i)=>{const{__scopeAccordion:n,disabled:s,dir:a,orientation:o="vertical",...l}=r,c=function(...t){return e.useCallback(Ni(...t),t)}(t.useRef(null),i),d=Ln(n),u="ltr"===function(t){const r=e.useContext(xn);return t||r||"ltr"}(a),h=Fi(r.onKeyDown,e=>{if(!kn.includes(e.key))return;const t=e.target,r=d().filter(e=>!e.ref.current?.disabled),i=r.findIndex(e=>e.ref.current===t),n=r.length;if(-1===i)return;e.preventDefault();let s=i;const a=n-1,l=()=>{s=i+1,s>a&&(s=0)},c=()=>{s=i-1,s<0&&(s=a)};switch(e.key){case"Home":s=0;break;case"End":s=a;break;case"ArrowRight":"horizontal"===o&&(u?l():c());break;case"ArrowDown":"vertical"===o&&l();break;case"ArrowLeft":"horizontal"===o&&(u?c():l());break;case"ArrowUp":"vertical"===o&&c()}const h=s%n;r[h].ref.current?.focus()});return b(Un,{scope:n,disabled:s,direction:a,orientation:o,children:b(In.Slot,{scope:n,children:b(Hi.div,{...l,"data-orientation":o,ref:c,onKeyDown:s?void 0:h})})})}),jn="AccordionItem",[Hn,Vn]=Pn(jn),Wn=t.forwardRef((e,t)=>{const{__scopeAccordion:r,value:i,...n}=e,s=zn(jn,r),a=Mn(jn,r),o=Dn(r),l=ln(),c=i&&a.value.includes(i)||!1,d=s.disabled||e.disabled;return b(Hn,{scope:r,open:c,disabled:d,triggerId:l,children:b(wn,{"data-orientation":s.orientation,"data-state":Jn(c),...o,...n,ref:t,disabled:d,open:c,onOpenChange:e=>{e?a.onItemOpen(i):a.onItemClose(i)}})})});Wn.displayName=jn;var Yn="AccordionHeader",Kn=t.forwardRef((e,t)=>{const{__scopeAccordion:r,...i}=e,n=zn(An,r),s=Vn(Yn,r);return b(Hi.h3,{"data-orientation":n.orientation,"data-state":Jn(s.open),"data-disabled":s.disabled?"":void 0,...i,ref:t})});Kn.displayName=Yn;var qn="AccordionTrigger",Xn=t.forwardRef((e,t)=>{const{__scopeAccordion:r,...i}=e,n=zn(An,r),s=Vn(qn,r),a=Fn(qn,r),o=Dn(r);return b(In.ItemSlot,{scope:r,children:b(Sn,{"aria-disabled":s.open&&!a.collapsible||void 0,"data-orientation":n.orientation,id:s.triggerId,...o,...i,ref:t})})});Xn.displayName=qn;var Qn="AccordionContent",Zn=t.forwardRef((e,t)=>{const{__scopeAccordion:r,...i}=e,n=zn(An,r),s=Vn(Qn,r),a=Dn(r);return b(Tn,{role:"region","aria-labelledby":s.triggerId,"data-orientation":n.orientation,...a,...i,ref:t,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...e.style}})});function Jn(e){return e?"open":"closed"}Zn.displayName=Qn;var es=_n,ts=Wn,rs=Kn,is=Xn,ns=Zn;function ss(t){var r=T(t,[]);return e.createElement(es,Object.assign({"data-slot":"accordion"},r))}function as(t){var{className:r}=t,i=T(t,["className"]);return e.createElement(ts,Object.assign({"data-slot":"accordion-item",className:St("border-b last:border-b-0",r)},i))}function os(t){var{className:r,children:i}=t,n=T(t,["className","children"]);return e.createElement(rs,{className:"flex"},e.createElement(is,Object.assign({"data-slot":"accordion-trigger",className:St("focus-visible:border-ring focus-visible:ring-ring/50 flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180",r)},n),i,e.createElement(ri,{className:"text-muted-foreground pointer-events-none size-4 shrink-0 translate-y-0.5 transition-transform duration-200"})))}function ls(t){var{className:r,children:i}=t,n=T(t,["className","children"]);return e.createElement(ns,Object.assign({"data-slot":"accordion-content",className:"data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm"},n),e.createElement("div",{className:St("pt-0 pb-4",r)},i))}const cs=({title:e,content:r})=>t.createElement(ss,{style:{borderRadius:"0.625rem"},type:"single",collapsible:!0,className:"bg-white px-4",defaultValue:"item"},t.createElement(as,{value:"item"},t.createElement(os,{className:""},e),t.createElement(ls,{className:"text-gray-700"},r))),ds=({logo:e})=>t.createElement("div",{className:"w-full bg-zinc-700 h-[60px] flex"},t.createElement("div",{className:"my-0 mx-auto w-full px-[24px] flex items-center justify-between"},e?t.createElement("div",{className:"h-10 max-w-[160px]"},t.createElement("img",{src:e.thumbPath,alt:e.logoName,width:100,height:100,className:"object-contain w-full h-full"})):t.createElement("div",null),t.createElement("button",{className:"text-white cursor-pointer"},t.createElement(gi,null)))),us=e=>{const{isPreview:r,playerSettings:i,shortform:{description:n,productsInfo:s,logo:a,brand:o,title:l,shortsId:c},player:d}=e;return t.createElement("div",{className:"w-full h-full bg-[#f4f4f4] overflow-scroll"},t.createElement(ds,{logo:a}),t.createElement("div",{className:" w-full h-full flex justify-between p-10 gap-10"},t.createElement("div",{className:""},t.createElement("div",{className:"flex gap-4 w-full mb-2 h-[125px] flex-col"},o?t.createElement("div",{className:"items-center flex gap-3"},o.thumbPath&&t.createElement("div",{className:"w-16 h-16 bg-white rounded-full border "},t.createElement("img",{src:o.thumbPath,alt:o.brandName,width:100,height:100,className:"object-contain w-full h-full rounded-full"})),t.createElement("div",null,t.createElement("p",null,o.brandName),t.createElement("p",{className:"text-lg font-semibold"},l))):t.createElement("p",{className:"text-xl font-semibold"},l),t.createElement(vi,null)),t.createElement("div",{className:"w-full pb-10 flex gap-4 justify-center"},t.createElement("div",{className:"flex gap-3"},d),t.createElement("div",{className:"flex flex-col gap-4 justify-end"},t.createElement(Ti,{rounded:!0,shortsId:c,isPreview:r}),t.createElement(xi,{rounded:!0}),t.createElement(Ai,{rounded:!0})))),t.createElement("div",{className:"flex flex-col gap-4 max-w-[40%]"},n&&t.createElement(cs,{title:"숏클립 안내",content:t.createElement("p",{className:"font-medium"},n)}),t.createElement(cs,{title:"상품 목록",content:t.createElement(t.Fragment,null,t.createElement("div",{className:"max-h-[300px] overflow-y-auto font-medium"},s.map((e,i)=>t.createElement(t.Fragment,null,t.createElement(Ei,{product:e,contentId:c,isPreview:r}),i!==s.length-1&&t.createElement("div",{className:"h-1 w-full border-t my-2"})))),t.createElement("button",{className:"w-full mt-3 border rounded py-2 px-4 cursor-pointer",disabled:!(null==s?void 0:s.length)},"상품 전체 보기"))}),i.comment&&t.createElement(cs,{title:"댓글",content:t.createElement(wi,null)}))))};function hs(e){return null!==e&&"object"==typeof e&&"constructor"in e&&e.constructor===Object}function fs(e,t){void 0===e&&(e={}),void 0===t&&(t={}),Object.keys(t).forEach(r=>{void 0===e[r]?e[r]=t[r]:hs(t[r])&&hs(e[r])&&Object.keys(t[r]).length>0&&fs(e[r],t[r])})}const ps={body:{},addEventListener(){},removeEventListener(){},activeElement:{blur(){},nodeName:""},querySelector:()=>null,querySelectorAll:()=>[],getElementById:()=>null,createEvent:()=>({initEvent(){}}),createElement:()=>({children:[],childNodes:[],style:{},setAttribute(){},getElementsByTagName:()=>[]}),createElementNS:()=>({}),importNode:()=>null,location:{hash:"",host:"",hostname:"",href:"",origin:"",pathname:"",protocol:"",search:""}};function ms(){const e="undefined"!=typeof document?document:{};return fs(e,ps),e}const gs={document:ps,navigator:{userAgent:""},location:{hash:"",host:"",hostname:"",href:"",origin:"",pathname:"",protocol:"",search:""},history:{replaceState(){},pushState(){},go(){},back(){}},CustomEvent:function(){return this},addEventListener(){},removeEventListener(){},getComputedStyle:()=>({getPropertyValue:()=>""}),Image(){},Date(){},screen:{},setTimeout(){},clearTimeout(){},matchMedia:()=>({}),requestAnimationFrame:e=>"undefined"==typeof setTimeout?(e(),null):setTimeout(e,0),cancelAnimationFrame(e){"undefined"!=typeof setTimeout&&clearTimeout(e)}};function vs(){const e="undefined"!=typeof window?window:{};return fs(e,gs),e}function ys(e,t){return void 0===t&&(t=0),setTimeout(e,t)}function bs(){return Date.now()}function Es(e,t){void 0===t&&(t="x");const r=vs();let i,n,s;const a=function(e){const t=vs();let r;return t.getComputedStyle&&(r=t.getComputedStyle(e,null)),!r&&e.currentStyle&&(r=e.currentStyle),r||(r=e.style),r}(e);return r.WebKitCSSMatrix?(n=a.transform||a.webkitTransform,n.split(",").length>6&&(n=n.split(", ").map(e=>e.replace(",",".")).join(", ")),s=new r.WebKitCSSMatrix("none"===n?"":n)):(s=a.MozTransform||a.OTransform||a.MsTransform||a.msTransform||a.transform||a.getPropertyValue("transform").replace("translate(","matrix(1, 0, 0, 1,"),i=s.toString().split(",")),"x"===t&&(n=r.WebKitCSSMatrix?s.m41:16===i.length?parseFloat(i[12]):parseFloat(i[4])),"y"===t&&(n=r.WebKitCSSMatrix?s.m42:16===i.length?parseFloat(i[13]):parseFloat(i[5])),n||0}function ws(e){return"object"==typeof e&&null!==e&&e.constructor&&"Object"===Object.prototype.toString.call(e).slice(8,-1)}function Ss(e){return"undefined"!=typeof window&&void 0!==window.HTMLElement?e instanceof HTMLElement:e&&(1===e.nodeType||11===e.nodeType)}function Ts(){const e=Object(arguments.length<=0?void 0:arguments[0]),t=["__proto__","constructor","prototype"];for(let r=1;r<arguments.length;r+=1){const i=r<0||arguments.length<=r?void 0:arguments[r];if(null!=i&&!Ss(i)){const r=Object.keys(Object(i)).filter(e=>t.indexOf(e)<0);for(let t=0,n=r.length;t<n;t+=1){const n=r[t],s=Object.getOwnPropertyDescriptor(i,n);void 0!==s&&s.enumerable&&(ws(e[n])&&ws(i[n])?i[n].__swiper__?e[n]=i[n]:Ts(e[n],i[n]):!ws(e[n])&&ws(i[n])?(e[n]={},i[n].__swiper__?e[n]=i[n]:Ts(e[n],i[n])):e[n]=i[n])}}}return e}function xs(e,t,r){e.style.setProperty(t,r)}function As(e){let{swiper:t,targetPosition:r,side:i}=e;const n=vs(),s=-t.translate;let a,o=null;const l=t.params.speed;t.wrapperEl.style.scrollSnapType="none",n.cancelAnimationFrame(t.cssModeFrameID);const c=r>s?"next":"prev",d=(e,t)=>"next"===c&&e>=t||"prev"===c&&e<=t,u=()=>{a=(new Date).getTime(),null===o&&(o=a);const e=Math.max(Math.min((a-o)/l,1),0),c=.5-Math.cos(e*Math.PI)/2;let h=s+c*(r-s);if(d(h,r)&&(h=r),t.wrapperEl.scrollTo({[i]:h}),d(h,r))return t.wrapperEl.style.overflow="hidden",t.wrapperEl.style.scrollSnapType="",setTimeout(()=>{t.wrapperEl.style.overflow="",t.wrapperEl.scrollTo({[i]:h})}),void n.cancelAnimationFrame(t.cssModeFrameID);t.cssModeFrameID=n.requestAnimationFrame(u)};u()}function ks(e){return e.querySelector(".swiper-slide-transform")||e.shadowRoot&&e.shadowRoot.querySelector(".swiper-slide-transform")||e}function Is(e,t){void 0===t&&(t="");const r=[...e.children];return e instanceof HTMLSlotElement&&r.push(...e.assignedElements()),t?r.filter(e=>e.matches(t)):r}function Ls(e){try{return void console.warn(e)}catch(e){}}function Rs(e,t){void 0===t&&(t=[]);const r=document.createElement(e);return r.classList.add(...Array.isArray(t)?t:function(e){return void 0===e&&(e=""),e.trim().split(" ").filter(e=>!!e.trim())}(t)),r}function Ps(e,t){return vs().getComputedStyle(e,null).getPropertyValue(t)}function Cs(e){let t,r=e;if(r){for(t=0;null!==(r=r.previousSibling);)1===r.nodeType&&(t+=1);return t}}function Ds(e,t,r){const i=vs();return e["width"===t?"offsetWidth":"offsetHeight"]+parseFloat(i.getComputedStyle(e,null).getPropertyValue("width"===t?"margin-right":"margin-top"))+parseFloat(i.getComputedStyle(e,null).getPropertyValue("width"===t?"margin-left":"margin-bottom"))}function _s(e){return(Array.isArray(e)?e:[e]).filter(e=>!!e)}let Os,Ms,Ns;function Fs(){return Os||(Os=function(){const e=vs(),t=ms();return{smoothScroll:t.documentElement&&t.documentElement.style&&"scrollBehavior"in t.documentElement.style,touch:!!("ontouchstart"in e||e.DocumentTouch&&t instanceof e.DocumentTouch)}}()),Os}function $s(e){return void 0===e&&(e={}),Ms||(Ms=function(e){let{userAgent:t}=void 0===e?{}:e;const r=Fs(),i=vs(),n=i.navigator.platform,s=t||i.navigator.userAgent,a={ios:!1,android:!1},o=i.screen.width,l=i.screen.height,c=s.match(/(Android);?[\s\/]+([\d.]+)?/);let d=s.match(/(iPad).*OS\s([\d_]+)/);const u=s.match(/(iPod)(.*OS\s([\d_]+))?/),h=!d&&s.match(/(iPhone\sOS|iOS)\s([\d_]+)/),f="Win32"===n;let p="MacIntel"===n;return!d&&p&&r.touch&&["1024x1366","1366x1024","834x1194","1194x834","834x1112","1112x834","768x1024","1024x768","820x1180","1180x820","810x1080","1080x810"].indexOf(`${o}x${l}`)>=0&&(d=s.match(/(Version)\/([\d.]+)/),d||(d=[0,1,"13_0_0"]),p=!1),c&&!f&&(a.os="android",a.android=!0),(d||h||u)&&(a.os="ios",a.ios=!0),a}(e)),Ms}function Bs(){return Ns||(Ns=function(){const e=vs(),t=$s();let r=!1;function i(){const t=e.navigator.userAgent.toLowerCase();return t.indexOf("safari")>=0&&t.indexOf("chrome")<0&&t.indexOf("android")<0}if(i()){const t=String(e.navigator.userAgent);if(t.includes("Version/")){const[e,i]=t.split("Version/")[1].split(" ")[0].split(".").map(e=>Number(e));r=e<16||16===e&&i<2}}const n=/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(e.navigator.userAgent),s=i();return{isSafari:r||s,needPerspectiveFix:r,need3dFix:s||n&&t.ios,isWebView:n}}()),Ns}var Us={on(e,t,r){const i=this;if(!i.eventsListeners||i.destroyed)return i;if("function"!=typeof t)return i;const n=r?"unshift":"push";return e.split(" ").forEach(e=>{i.eventsListeners[e]||(i.eventsListeners[e]=[]),i.eventsListeners[e][n](t)}),i},once(e,t,r){const i=this;if(!i.eventsListeners||i.destroyed)return i;if("function"!=typeof t)return i;function n(){i.off(e,n),n.__emitterProxy&&delete n.__emitterProxy;for(var r=arguments.length,s=new Array(r),a=0;a<r;a++)s[a]=arguments[a];t.apply(i,s)}return n.__emitterProxy=t,i.on(e,n,r)},onAny(e,t){const r=this;if(!r.eventsListeners||r.destroyed)return r;if("function"!=typeof e)return r;const i=t?"unshift":"push";return r.eventsAnyListeners.indexOf(e)<0&&r.eventsAnyListeners[i](e),r},offAny(e){const t=this;if(!t.eventsListeners||t.destroyed)return t;if(!t.eventsAnyListeners)return t;const r=t.eventsAnyListeners.indexOf(e);return r>=0&&t.eventsAnyListeners.splice(r,1),t},off(e,t){const r=this;return!r.eventsListeners||r.destroyed?r:r.eventsListeners?(e.split(" ").forEach(e=>{void 0===t?r.eventsListeners[e]=[]:r.eventsListeners[e]&&r.eventsListeners[e].forEach((i,n)=>{(i===t||i.__emitterProxy&&i.__emitterProxy===t)&&r.eventsListeners[e].splice(n,1)})}),r):r},emit(){const e=this;if(!e.eventsListeners||e.destroyed)return e;if(!e.eventsListeners)return e;let t,r,i;for(var n=arguments.length,s=new Array(n),a=0;a<n;a++)s[a]=arguments[a];"string"==typeof s[0]||Array.isArray(s[0])?(t=s[0],r=s.slice(1,s.length),i=e):(t=s[0].events,r=s[0].data,i=s[0].context||e),r.unshift(i);return(Array.isArray(t)?t:t.split(" ")).forEach(t=>{e.eventsAnyListeners&&e.eventsAnyListeners.length&&e.eventsAnyListeners.forEach(e=>{e.apply(i,[t,...r])}),e.eventsListeners&&e.eventsListeners[t]&&e.eventsListeners[t].forEach(e=>{e.apply(i,r)})}),e}};const zs=(e,t,r)=>{t&&!e.classList.contains(r)?e.classList.add(r):!t&&e.classList.contains(r)&&e.classList.remove(r)};const Gs=(e,t,r)=>{t&&!e.classList.contains(r)?e.classList.add(r):!t&&e.classList.contains(r)&&e.classList.remove(r)};const js=(e,t)=>{if(!e||e.destroyed||!e.params)return;const r=t.closest(e.isElement?"swiper-slide":`.${e.params.slideClass}`);if(r){let t=r.querySelector(`.${e.params.lazyPreloaderClass}`);!t&&e.isElement&&(r.shadowRoot?t=r.shadowRoot.querySelector(`.${e.params.lazyPreloaderClass}`):requestAnimationFrame(()=>{r.shadowRoot&&(t=r.shadowRoot.querySelector(`.${e.params.lazyPreloaderClass}`),t&&t.remove())})),t&&t.remove()}},Hs=(e,t)=>{if(!e.slides[t])return;const r=e.slides[t].querySelector('[loading="lazy"]');r&&r.removeAttribute("loading")},Vs=e=>{if(!e||e.destroyed||!e.params)return;let t=e.params.lazyPreloadPrevNext;const r=e.slides.length;if(!r||!t||t<0)return;t=Math.min(t,r);const i="auto"===e.params.slidesPerView?e.slidesPerViewDynamic():Math.ceil(e.params.slidesPerView),n=e.activeIndex;if(e.params.grid&&e.params.grid.rows>1){const r=n,s=[r-t];return s.push(...Array.from({length:t}).map((e,t)=>r+i+t)),void e.slides.forEach((t,r)=>{s.includes(t.column)&&Hs(e,r)})}const s=n+i-1;if(e.params.rewind||e.params.loop)for(let i=n-t;i<=s+t;i+=1){const t=(i%r+r)%r;(t<n||t>s)&&Hs(e,t)}else for(let i=Math.max(n-t,0);i<=Math.min(s+t,r-1);i+=1)i!==n&&(i>s||i<n)&&Hs(e,i)};var Ws={updateSize:function(){const e=this;let t,r;const i=e.el;t=void 0!==e.params.width&&null!==e.params.width?e.params.width:i.clientWidth,r=void 0!==e.params.height&&null!==e.params.height?e.params.height:i.clientHeight,0===t&&e.isHorizontal()||0===r&&e.isVertical()||(t=t-parseInt(Ps(i,"padding-left")||0,10)-parseInt(Ps(i,"padding-right")||0,10),r=r-parseInt(Ps(i,"padding-top")||0,10)-parseInt(Ps(i,"padding-bottom")||0,10),Number.isNaN(t)&&(t=0),Number.isNaN(r)&&(r=0),Object.assign(e,{width:t,height:r,size:e.isHorizontal()?t:r}))},updateSlides:function(){const e=this;function t(t,r){return parseFloat(t.getPropertyValue(e.getDirectionLabel(r))||0)}const r=e.params,{wrapperEl:i,slidesEl:n,size:s,rtlTranslate:a,wrongRTL:o}=e,l=e.virtual&&r.virtual.enabled,c=l?e.virtual.slides.length:e.slides.length,d=Is(n,`.${e.params.slideClass}, swiper-slide`),u=l?e.virtual.slides.length:d.length;let h=[];const f=[],p=[];let m=r.slidesOffsetBefore;"function"==typeof m&&(m=r.slidesOffsetBefore.call(e));let g=r.slidesOffsetAfter;"function"==typeof g&&(g=r.slidesOffsetAfter.call(e));const v=e.snapGrid.length,y=e.slidesGrid.length;let b=r.spaceBetween,E=-m,w=0,S=0;if(void 0===s)return;"string"==typeof b&&b.indexOf("%")>=0?b=parseFloat(b.replace("%",""))/100*s:"string"==typeof b&&(b=parseFloat(b)),e.virtualSize=-b,d.forEach(e=>{a?e.style.marginLeft="":e.style.marginRight="",e.style.marginBottom="",e.style.marginTop=""}),r.centeredSlides&&r.cssMode&&(xs(i,"--swiper-centered-offset-before",""),xs(i,"--swiper-centered-offset-after",""));const T=r.grid&&r.grid.rows>1&&e.grid;let x;T?e.grid.initSlides(d):e.grid&&e.grid.unsetSlides();const A="auto"===r.slidesPerView&&r.breakpoints&&Object.keys(r.breakpoints).filter(e=>void 0!==r.breakpoints[e].slidesPerView).length>0;for(let i=0;i<u;i+=1){let n;if(x=0,d[i]&&(n=d[i]),T&&e.grid.updateSlide(i,n,d),!d[i]||"none"!==Ps(n,"display")){if("auto"===r.slidesPerView){A&&(d[i].style[e.getDirectionLabel("width")]="");const s=getComputedStyle(n),a=n.style.transform,o=n.style.webkitTransform;if(a&&(n.style.transform="none"),o&&(n.style.webkitTransform="none"),r.roundLengths)x=e.isHorizontal()?Ds(n,"width"):Ds(n,"height");else{const e=t(s,"width"),r=t(s,"padding-left"),i=t(s,"padding-right"),a=t(s,"margin-left"),o=t(s,"margin-right"),l=s.getPropertyValue("box-sizing");if(l&&"border-box"===l)x=e+a+o;else{const{clientWidth:t,offsetWidth:s}=n;x=e+r+i+a+o+(s-t)}}a&&(n.style.transform=a),o&&(n.style.webkitTransform=o),r.roundLengths&&(x=Math.floor(x))}else x=(s-(r.slidesPerView-1)*b)/r.slidesPerView,r.roundLengths&&(x=Math.floor(x)),d[i]&&(d[i].style[e.getDirectionLabel("width")]=`${x}px`);d[i]&&(d[i].swiperSlideSize=x),p.push(x),r.centeredSlides?(E=E+x/2+w/2+b,0===w&&0!==i&&(E=E-s/2-b),0===i&&(E=E-s/2-b),Math.abs(E)<.001&&(E=0),r.roundLengths&&(E=Math.floor(E)),S%r.slidesPerGroup===0&&h.push(E),f.push(E)):(r.roundLengths&&(E=Math.floor(E)),(S-Math.min(e.params.slidesPerGroupSkip,S))%e.params.slidesPerGroup===0&&h.push(E),f.push(E),E=E+x+b),e.virtualSize+=x+b,w=x,S+=1}}if(e.virtualSize=Math.max(e.virtualSize,s)+g,a&&o&&("slide"===r.effect||"coverflow"===r.effect)&&(i.style.width=`${e.virtualSize+b}px`),r.setWrapperSize&&(i.style[e.getDirectionLabel("width")]=`${e.virtualSize+b}px`),T&&e.grid.updateWrapperSize(x,h),!r.centeredSlides){const t=[];for(let i=0;i<h.length;i+=1){let n=h[i];r.roundLengths&&(n=Math.floor(n)),h[i]<=e.virtualSize-s&&t.push(n)}h=t,Math.floor(e.virtualSize-s)-Math.floor(h[h.length-1])>1&&h.push(e.virtualSize-s)}if(l&&r.loop){const t=p[0]+b;if(r.slidesPerGroup>1){const i=Math.ceil((e.virtual.slidesBefore+e.virtual.slidesAfter)/r.slidesPerGroup),n=t*r.slidesPerGroup;for(let e=0;e<i;e+=1)h.push(h[h.length-1]+n)}for(let i=0;i<e.virtual.slidesBefore+e.virtual.slidesAfter;i+=1)1===r.slidesPerGroup&&h.push(h[h.length-1]+t),f.push(f[f.length-1]+t),e.virtualSize+=t}if(0===h.length&&(h=[0]),0!==b){const t=e.isHorizontal()&&a?"marginLeft":e.getDirectionLabel("marginRight");d.filter((e,t)=>!(r.cssMode&&!r.loop)||t!==d.length-1).forEach(e=>{e.style[t]=`${b}px`})}if(r.centeredSlides&&r.centeredSlidesBounds){let e=0;p.forEach(t=>{e+=t+(b||0)}),e-=b;const t=e>s?e-s:0;h=h.map(e=>e<=0?-m:e>t?t+g:e)}if(r.centerInsufficientSlides){let e=0;p.forEach(t=>{e+=t+(b||0)}),e-=b;const t=(r.slidesOffsetBefore||0)+(r.slidesOffsetAfter||0);if(e+t<s){const r=(s-e-t)/2;h.forEach((e,t)=>{h[t]=e-r}),f.forEach((e,t)=>{f[t]=e+r})}}if(Object.assign(e,{slides:d,snapGrid:h,slidesGrid:f,slidesSizesGrid:p}),r.centeredSlides&&r.cssMode&&!r.centeredSlidesBounds){xs(i,"--swiper-centered-offset-before",-h[0]+"px"),xs(i,"--swiper-centered-offset-after",e.size/2-p[p.length-1]/2+"px");const t=-e.snapGrid[0],r=-e.slidesGrid[0];e.snapGrid=e.snapGrid.map(e=>e+t),e.slidesGrid=e.slidesGrid.map(e=>e+r)}if(u!==c&&e.emit("slidesLengthChange"),h.length!==v&&(e.params.watchOverflow&&e.checkOverflow(),e.emit("snapGridLengthChange")),f.length!==y&&e.emit("slidesGridLengthChange"),r.watchSlidesProgress&&e.updateSlidesOffset(),e.emit("slidesUpdated"),!(l||r.cssMode||"slide"!==r.effect&&"fade"!==r.effect)){const t=`${r.containerModifierClass}backface-hidden`,i=e.el.classList.contains(t);u<=r.maxBackfaceHiddenSlides?i||e.el.classList.add(t):i&&e.el.classList.remove(t)}},updateAutoHeight:function(e){const t=this,r=[],i=t.virtual&&t.params.virtual.enabled;let n,s=0;"number"==typeof e?t.setTransition(e):!0===e&&t.setTransition(t.params.speed);const a=e=>i?t.slides[t.getSlideIndexByData(e)]:t.slides[e];if("auto"!==t.params.slidesPerView&&t.params.slidesPerView>1)if(t.params.centeredSlides)(t.visibleSlides||[]).forEach(e=>{r.push(e)});else for(n=0;n<Math.ceil(t.params.slidesPerView);n+=1){const e=t.activeIndex+n;if(e>t.slides.length&&!i)break;r.push(a(e))}else r.push(a(t.activeIndex));for(n=0;n<r.length;n+=1)if(void 0!==r[n]){const e=r[n].offsetHeight;s=e>s?e:s}(s||0===s)&&(t.wrapperEl.style.height=`${s}px`)},updateSlidesOffset:function(){const e=this,t=e.slides,r=e.isElement?e.isHorizontal()?e.wrapperEl.offsetLeft:e.wrapperEl.offsetTop:0;for(let i=0;i<t.length;i+=1)t[i].swiperSlideOffset=(e.isHorizontal()?t[i].offsetLeft:t[i].offsetTop)-r-e.cssOverflowAdjustment()},updateSlidesProgress:function(e){void 0===e&&(e=this&&this.translate||0);const t=this,r=t.params,{slides:i,rtlTranslate:n,snapGrid:s}=t;if(0===i.length)return;void 0===i[0].swiperSlideOffset&&t.updateSlidesOffset();let a=-e;n&&(a=e),t.visibleSlidesIndexes=[],t.visibleSlides=[];let o=r.spaceBetween;"string"==typeof o&&o.indexOf("%")>=0?o=parseFloat(o.replace("%",""))/100*t.size:"string"==typeof o&&(o=parseFloat(o));for(let e=0;e<i.length;e+=1){const l=i[e];let c=l.swiperSlideOffset;r.cssMode&&r.centeredSlides&&(c-=i[0].swiperSlideOffset);const d=(a+(r.centeredSlides?t.minTranslate():0)-c)/(l.swiperSlideSize+o),u=(a-s[0]+(r.centeredSlides?t.minTranslate():0)-c)/(l.swiperSlideSize+o),h=-(a-c),f=h+t.slidesSizesGrid[e],p=h>=0&&h<=t.size-t.slidesSizesGrid[e],m=h>=0&&h<t.size-1||f>1&&f<=t.size||h<=0&&f>=t.size;m&&(t.visibleSlides.push(l),t.visibleSlidesIndexes.push(e)),zs(l,m,r.slideVisibleClass),zs(l,p,r.slideFullyVisibleClass),l.progress=n?-d:d,l.originalProgress=n?-u:u}},updateProgress:function(e){const t=this;if(void 0===e){const r=t.rtlTranslate?-1:1;e=t&&t.translate&&t.translate*r||0}const r=t.params,i=t.maxTranslate()-t.minTranslate();let{progress:n,isBeginning:s,isEnd:a,progressLoop:o}=t;const l=s,c=a;if(0===i)n=0,s=!0,a=!0;else{n=(e-t.minTranslate())/i;const r=Math.abs(e-t.minTranslate())<1,o=Math.abs(e-t.maxTranslate())<1;s=r||n<=0,a=o||n>=1,r&&(n=0),o&&(n=1)}if(r.loop){const r=t.getSlideIndexByData(0),i=t.getSlideIndexByData(t.slides.length-1),n=t.slidesGrid[r],s=t.slidesGrid[i],a=t.slidesGrid[t.slidesGrid.length-1],l=Math.abs(e);o=l>=n?(l-n)/a:(l+a-s)/a,o>1&&(o-=1)}Object.assign(t,{progress:n,progressLoop:o,isBeginning:s,isEnd:a}),(r.watchSlidesProgress||r.centeredSlides&&r.autoHeight)&&t.updateSlidesProgress(e),s&&!l&&t.emit("reachBeginning toEdge"),a&&!c&&t.emit("reachEnd toEdge"),(l&&!s||c&&!a)&&t.emit("fromEdge"),t.emit("progress",n)},updateSlidesClasses:function(){const e=this,{slides:t,params:r,slidesEl:i,activeIndex:n}=e,s=e.virtual&&r.virtual.enabled,a=e.grid&&r.grid&&r.grid.rows>1,o=e=>Is(i,`.${r.slideClass}${e}, swiper-slide${e}`)[0];let l,c,d;if(s)if(r.loop){let t=n-e.virtual.slidesBefore;t<0&&(t=e.virtual.slides.length+t),t>=e.virtual.slides.length&&(t-=e.virtual.slides.length),l=o(`[data-swiper-slide-index="${t}"]`)}else l=o(`[data-swiper-slide-index="${n}"]`);else a?(l=t.filter(e=>e.column===n)[0],d=t.filter(e=>e.column===n+1)[0],c=t.filter(e=>e.column===n-1)[0]):l=t[n];l&&(a||(d=function(e,t){const r=[];for(;e.nextElementSibling;){const i=e.nextElementSibling;t?i.matches(t)&&r.push(i):r.push(i),e=i}return r}(l,`.${r.slideClass}, swiper-slide`)[0],r.loop&&!d&&(d=t[0]),c=function(e,t){const r=[];for(;e.previousElementSibling;){const i=e.previousElementSibling;t?i.matches(t)&&r.push(i):r.push(i),e=i}return r}(l,`.${r.slideClass}, swiper-slide`)[0],r.loop&&0===!c&&(c=t[t.length-1]))),t.forEach(e=>{Gs(e,e===l,r.slideActiveClass),Gs(e,e===d,r.slideNextClass),Gs(e,e===c,r.slidePrevClass)}),e.emitSlidesClasses()},updateActiveIndex:function(e){const t=this,r=t.rtlTranslate?t.translate:-t.translate,{snapGrid:i,params:n,activeIndex:s,realIndex:a,snapIndex:o}=t;let l,c=e;const d=e=>{let r=e-t.virtual.slidesBefore;return r<0&&(r=t.virtual.slides.length+r),r>=t.virtual.slides.length&&(r-=t.virtual.slides.length),r};if(void 0===c&&(c=function(e){const{slidesGrid:t,params:r}=e,i=e.rtlTranslate?e.translate:-e.translate;let n;for(let e=0;e<t.length;e+=1)void 0!==t[e+1]?i>=t[e]&&i<t[e+1]-(t[e+1]-t[e])/2?n=e:i>=t[e]&&i<t[e+1]&&(n=e+1):i>=t[e]&&(n=e);return r.normalizeSlideIndex&&(n<0||void 0===n)&&(n=0),n}(t)),i.indexOf(r)>=0)l=i.indexOf(r);else{const e=Math.min(n.slidesPerGroupSkip,c);l=e+Math.floor((c-e)/n.slidesPerGroup)}if(l>=i.length&&(l=i.length-1),c===s&&!t.params.loop)return void(l!==o&&(t.snapIndex=l,t.emit("snapIndexChange")));if(c===s&&t.params.loop&&t.virtual&&t.params.virtual.enabled)return void(t.realIndex=d(c));const u=t.grid&&n.grid&&n.grid.rows>1;let h;if(t.virtual&&n.virtual.enabled&&n.loop)h=d(c);else if(u){const e=t.slides.filter(e=>e.column===c)[0];let r=parseInt(e.getAttribute("data-swiper-slide-index"),10);Number.isNaN(r)&&(r=Math.max(t.slides.indexOf(e),0)),h=Math.floor(r/n.grid.rows)}else if(t.slides[c]){const e=t.slides[c].getAttribute("data-swiper-slide-index");h=e?parseInt(e,10):c}else h=c;Object.assign(t,{previousSnapIndex:o,snapIndex:l,previousRealIndex:a,realIndex:h,previousIndex:s,activeIndex:c}),t.initialized&&Vs(t),t.emit("activeIndexChange"),t.emit("snapIndexChange"),(t.initialized||t.params.runCallbacksOnInit)&&(a!==h&&t.emit("realIndexChange"),t.emit("slideChange"))},updateClickedSlide:function(e,t){const r=this,i=r.params;let n=e.closest(`.${i.slideClass}, swiper-slide`);!n&&r.isElement&&t&&t.length>1&&t.includes(e)&&[...t.slice(t.indexOf(e)+1,t.length)].forEach(e=>{!n&&e.matches&&e.matches(`.${i.slideClass}, swiper-slide`)&&(n=e)});let s,a=!1;if(n)for(let e=0;e<r.slides.length;e+=1)if(r.slides[e]===n){a=!0,s=e;break}if(!n||!a)return r.clickedSlide=void 0,void(r.clickedIndex=void 0);r.clickedSlide=n,r.virtual&&r.params.virtual.enabled?r.clickedIndex=parseInt(n.getAttribute("data-swiper-slide-index"),10):r.clickedIndex=s,i.slideToClickedSlide&&void 0!==r.clickedIndex&&r.clickedIndex!==r.activeIndex&&r.slideToClickedSlide()}};var Ys={getTranslate:function(e){void 0===e&&(e=this.isHorizontal()?"x":"y");const{params:t,rtlTranslate:r,translate:i,wrapperEl:n}=this;if(t.virtualTranslate)return r?-i:i;if(t.cssMode)return i;let s=Es(n,e);return s+=this.cssOverflowAdjustment(),r&&(s=-s),s||0},setTranslate:function(e,t){const r=this,{rtlTranslate:i,params:n,wrapperEl:s,progress:a}=r;let o,l=0,c=0;r.isHorizontal()?l=i?-e:e:c=e,n.roundLengths&&(l=Math.floor(l),c=Math.floor(c)),r.previousTranslate=r.translate,r.translate=r.isHorizontal()?l:c,n.cssMode?s[r.isHorizontal()?"scrollLeft":"scrollTop"]=r.isHorizontal()?-l:-c:n.virtualTranslate||(r.isHorizontal()?l-=r.cssOverflowAdjustment():c-=r.cssOverflowAdjustment(),s.style.transform=`translate3d(${l}px, ${c}px, 0px)`);const d=r.maxTranslate()-r.minTranslate();o=0===d?0:(e-r.minTranslate())/d,o!==a&&r.updateProgress(e),r.emit("setTranslate",r.translate,t)},minTranslate:function(){return-this.snapGrid[0]},maxTranslate:function(){return-this.snapGrid[this.snapGrid.length-1]},translateTo:function(e,t,r,i,n){void 0===e&&(e=0),void 0===t&&(t=this.params.speed),void 0===r&&(r=!0),void 0===i&&(i=!0);const s=this,{params:a,wrapperEl:o}=s;if(s.animating&&a.preventInteractionOnTransition)return!1;const l=s.minTranslate(),c=s.maxTranslate();let d;if(d=i&&e>l?l:i&&e<c?c:e,s.updateProgress(d),a.cssMode){const e=s.isHorizontal();if(0===t)o[e?"scrollLeft":"scrollTop"]=-d;else{if(!s.support.smoothScroll)return As({swiper:s,targetPosition:-d,side:e?"left":"top"}),!0;o.scrollTo({[e?"left":"top"]:-d,behavior:"smooth"})}return!0}return 0===t?(s.setTransition(0),s.setTranslate(d),r&&(s.emit("beforeTransitionStart",t,n),s.emit("transitionEnd"))):(s.setTransition(t),s.setTranslate(d),r&&(s.emit("beforeTransitionStart",t,n),s.emit("transitionStart")),s.animating||(s.animating=!0,s.onTranslateToWrapperTransitionEnd||(s.onTranslateToWrapperTransitionEnd=function(e){s&&!s.destroyed&&e.target===this&&(s.wrapperEl.removeEventListener("transitionend",s.onTranslateToWrapperTransitionEnd),s.onTranslateToWrapperTransitionEnd=null,delete s.onTranslateToWrapperTransitionEnd,s.animating=!1,r&&s.emit("transitionEnd"))}),s.wrapperEl.addEventListener("transitionend",s.onTranslateToWrapperTransitionEnd))),!0}};function Ks(e){let{swiper:t,runCallbacks:r,direction:i,step:n}=e;const{activeIndex:s,previousIndex:a}=t;let o=i;if(o||(o=s>a?"next":s<a?"prev":"reset"),t.emit(`transition${n}`),r&&s!==a){if("reset"===o)return void t.emit(`slideResetTransition${n}`);t.emit(`slideChangeTransition${n}`),"next"===o?t.emit(`slideNextTransition${n}`):t.emit(`slidePrevTransition${n}`)}}var qs={setTransition:function(e,t){const r=this;r.params.cssMode||(r.wrapperEl.style.transitionDuration=`${e}ms`,r.wrapperEl.style.transitionDelay=0===e?"0ms":""),r.emit("setTransition",e,t)},transitionStart:function(e,t){void 0===e&&(e=!0);const r=this,{params:i}=r;i.cssMode||(i.autoHeight&&r.updateAutoHeight(),Ks({swiper:r,runCallbacks:e,direction:t,step:"Start"}))},transitionEnd:function(e,t){void 0===e&&(e=!0);const r=this,{params:i}=r;r.animating=!1,i.cssMode||(r.setTransition(0),Ks({swiper:r,runCallbacks:e,direction:t,step:"End"}))}};var Xs={slideTo:function(e,t,r,i,n){void 0===e&&(e=0),void 0===r&&(r=!0),"string"==typeof e&&(e=parseInt(e,10));const s=this;let a=e;a<0&&(a=0);const{params:o,snapGrid:l,slidesGrid:c,previousIndex:d,activeIndex:u,rtlTranslate:h,wrapperEl:f,enabled:p}=s;if(!p&&!i&&!n||s.destroyed||s.animating&&o.preventInteractionOnTransition)return!1;void 0===t&&(t=s.params.speed);const m=Math.min(s.params.slidesPerGroupSkip,a);let g=m+Math.floor((a-m)/s.params.slidesPerGroup);g>=l.length&&(g=l.length-1);const v=-l[g];if(o.normalizeSlideIndex)for(let e=0;e<c.length;e+=1){const t=-Math.floor(100*v),r=Math.floor(100*c[e]),i=Math.floor(100*c[e+1]);void 0!==c[e+1]?t>=r&&t<i-(i-r)/2?a=e:t>=r&&t<i&&(a=e+1):t>=r&&(a=e)}if(s.initialized&&a!==u){if(!s.allowSlideNext&&(h?v>s.translate&&v>s.minTranslate():v<s.translate&&v<s.minTranslate()))return!1;if(!s.allowSlidePrev&&v>s.translate&&v>s.maxTranslate()&&(u||0)!==a)return!1}let y;a!==(d||0)&&r&&s.emit("beforeSlideChangeStart"),s.updateProgress(v),y=a>u?"next":a<u?"prev":"reset";const b=s.virtual&&s.params.virtual.enabled;if(!(b&&n)&&(h&&-v===s.translate||!h&&v===s.translate))return s.updateActiveIndex(a),o.autoHeight&&s.updateAutoHeight(),s.updateSlidesClasses(),"slide"!==o.effect&&s.setTranslate(v),"reset"!==y&&(s.transitionStart(r,y),s.transitionEnd(r,y)),!1;if(o.cssMode){const e=s.isHorizontal(),r=h?v:-v;if(0===t)b&&(s.wrapperEl.style.scrollSnapType="none",s._immediateVirtual=!0),b&&!s._cssModeVirtualInitialSet&&s.params.initialSlide>0?(s._cssModeVirtualInitialSet=!0,requestAnimationFrame(()=>{f[e?"scrollLeft":"scrollTop"]=r})):f[e?"scrollLeft":"scrollTop"]=r,b&&requestAnimationFrame(()=>{s.wrapperEl.style.scrollSnapType="",s._immediateVirtual=!1});else{if(!s.support.smoothScroll)return As({swiper:s,targetPosition:r,side:e?"left":"top"}),!0;f.scrollTo({[e?"left":"top"]:r,behavior:"smooth"})}return!0}return s.setTransition(t),s.setTranslate(v),s.updateActiveIndex(a),s.updateSlidesClasses(),s.emit("beforeTransitionStart",t,i),s.transitionStart(r,y),0===t?s.transitionEnd(r,y):s.animating||(s.animating=!0,s.onSlideToWrapperTransitionEnd||(s.onSlideToWrapperTransitionEnd=function(e){s&&!s.destroyed&&e.target===this&&(s.wrapperEl.removeEventListener("transitionend",s.onSlideToWrapperTransitionEnd),s.onSlideToWrapperTransitionEnd=null,delete s.onSlideToWrapperTransitionEnd,s.transitionEnd(r,y))}),s.wrapperEl.addEventListener("transitionend",s.onSlideToWrapperTransitionEnd)),!0},slideToLoop:function(e,t,r,i){if(void 0===e&&(e=0),void 0===r&&(r=!0),"string"==typeof e){e=parseInt(e,10)}const n=this;if(n.destroyed)return;void 0===t&&(t=n.params.speed);const s=n.grid&&n.params.grid&&n.params.grid.rows>1;let a=e;if(n.params.loop)if(n.virtual&&n.params.virtual.enabled)a+=n.virtual.slidesBefore;else{let e;if(s){const t=a*n.params.grid.rows;e=n.slides.filter(e=>1*e.getAttribute("data-swiper-slide-index")===t)[0].column}else e=n.getSlideIndexByData(a);const t=s?Math.ceil(n.slides.length/n.params.grid.rows):n.slides.length,{centeredSlides:r}=n.params;let o=n.params.slidesPerView;"auto"===o?o=n.slidesPerViewDynamic():(o=Math.ceil(parseFloat(n.params.slidesPerView,10)),r&&o%2==0&&(o+=1));let l=t-e<o;if(r&&(l=l||e<Math.ceil(o/2)),i&&r&&"auto"!==n.params.slidesPerView&&!s&&(l=!1),l){const i=r?e<n.activeIndex?"prev":"next":e-n.activeIndex-1<n.params.slidesPerView?"next":"prev";n.loopFix({direction:i,slideTo:!0,activeSlideIndex:"next"===i?e+1:e-t+1,slideRealIndex:"next"===i?n.realIndex:void 0})}if(s){const e=a*n.params.grid.rows;a=n.slides.filter(t=>1*t.getAttribute("data-swiper-slide-index")===e)[0].column}else a=n.getSlideIndexByData(a)}return requestAnimationFrame(()=>{n.slideTo(a,t,r,i)}),n},slideNext:function(e,t,r){void 0===t&&(t=!0);const i=this,{enabled:n,params:s,animating:a}=i;if(!n||i.destroyed)return i;void 0===e&&(e=i.params.speed);let o=s.slidesPerGroup;"auto"===s.slidesPerView&&1===s.slidesPerGroup&&s.slidesPerGroupAuto&&(o=Math.max(i.slidesPerViewDynamic("current",!0),1));const l=i.activeIndex<s.slidesPerGroupSkip?1:o,c=i.virtual&&s.virtual.enabled;if(s.loop){if(a&&!c&&s.loopPreventsSliding)return!1;if(i.loopFix({direction:"next"}),i._clientLeft=i.wrapperEl.clientLeft,i.activeIndex===i.slides.length-1&&s.cssMode)return requestAnimationFrame(()=>{i.slideTo(i.activeIndex+l,e,t,r)}),!0}return s.rewind&&i.isEnd?i.slideTo(0,e,t,r):i.slideTo(i.activeIndex+l,e,t,r)},slidePrev:function(e,t,r){void 0===t&&(t=!0);const i=this,{params:n,snapGrid:s,slidesGrid:a,rtlTranslate:o,enabled:l,animating:c}=i;if(!l||i.destroyed)return i;void 0===e&&(e=i.params.speed);const d=i.virtual&&n.virtual.enabled;if(n.loop){if(c&&!d&&n.loopPreventsSliding)return!1;i.loopFix({direction:"prev"}),i._clientLeft=i.wrapperEl.clientLeft}function u(e){return e<0?-Math.floor(Math.abs(e)):Math.floor(e)}const h=u(o?i.translate:-i.translate),f=s.map(e=>u(e));let p=s[f.indexOf(h)-1];if(void 0===p&&n.cssMode){let e;s.forEach((t,r)=>{h>=t&&(e=r)}),void 0!==e&&(p=s[e>0?e-1:e])}let m=0;if(void 0!==p&&(m=a.indexOf(p),m<0&&(m=i.activeIndex-1),"auto"===n.slidesPerView&&1===n.slidesPerGroup&&n.slidesPerGroupAuto&&(m=m-i.slidesPerViewDynamic("previous",!0)+1,m=Math.max(m,0))),n.rewind&&i.isBeginning){const n=i.params.virtual&&i.params.virtual.enabled&&i.virtual?i.virtual.slides.length-1:i.slides.length-1;return i.slideTo(n,e,t,r)}return n.loop&&0===i.activeIndex&&n.cssMode?(requestAnimationFrame(()=>{i.slideTo(m,e,t,r)}),!0):i.slideTo(m,e,t,r)},slideReset:function(e,t,r){void 0===t&&(t=!0);const i=this;if(!i.destroyed)return void 0===e&&(e=i.params.speed),i.slideTo(i.activeIndex,e,t,r)},slideToClosest:function(e,t,r,i){void 0===t&&(t=!0),void 0===i&&(i=.5);const n=this;if(n.destroyed)return;void 0===e&&(e=n.params.speed);let s=n.activeIndex;const a=Math.min(n.params.slidesPerGroupSkip,s),o=a+Math.floor((s-a)/n.params.slidesPerGroup),l=n.rtlTranslate?n.translate:-n.translate;if(l>=n.snapGrid[o]){const e=n.snapGrid[o];l-e>(n.snapGrid[o+1]-e)*i&&(s+=n.params.slidesPerGroup)}else{const e=n.snapGrid[o-1];l-e<=(n.snapGrid[o]-e)*i&&(s-=n.params.slidesPerGroup)}return s=Math.max(s,0),s=Math.min(s,n.slidesGrid.length-1),n.slideTo(s,e,t,r)},slideToClickedSlide:function(){const e=this;if(e.destroyed)return;const{params:t,slidesEl:r}=e,i="auto"===t.slidesPerView?e.slidesPerViewDynamic():t.slidesPerView;let n,s=e.clickedIndex;const a=e.isElement?"swiper-slide":`.${t.slideClass}`;if(t.loop){if(e.animating)return;n=parseInt(e.clickedSlide.getAttribute("data-swiper-slide-index"),10),t.centeredSlides?s<e.loopedSlides-i/2||s>e.slides.length-e.loopedSlides+i/2?(e.loopFix(),s=e.getSlideIndex(Is(r,`${a}[data-swiper-slide-index="${n}"]`)[0]),ys(()=>{e.slideTo(s)})):e.slideTo(s):s>e.slides.length-i?(e.loopFix(),s=e.getSlideIndex(Is(r,`${a}[data-swiper-slide-index="${n}"]`)[0]),ys(()=>{e.slideTo(s)})):e.slideTo(s)}else e.slideTo(s)}};var Qs={loopCreate:function(e){const t=this,{params:r,slidesEl:i}=t;if(!r.loop||t.virtual&&t.params.virtual.enabled)return;const n=()=>{Is(i,`.${r.slideClass}, swiper-slide`).forEach((e,t)=>{e.setAttribute("data-swiper-slide-index",t)})},s=t.grid&&r.grid&&r.grid.rows>1,a=r.slidesPerGroup*(s?r.grid.rows:1),o=t.slides.length%a!==0,l=s&&t.slides.length%r.grid.rows!==0,c=e=>{for(let i=0;i<e;i+=1){const e=t.isElement?Rs("swiper-slide",[r.slideBlankClass]):Rs("div",[r.slideClass,r.slideBlankClass]);t.slidesEl.append(e)}};if(o){if(r.loopAddBlankSlides){c(a-t.slides.length%a),t.recalcSlides(),t.updateSlides()}else Ls("Swiper Loop Warning: The number of slides is not even to slidesPerGroup, loop mode may not function properly. You need to add more slides (or make duplicates, or empty slides)");n()}else if(l){if(r.loopAddBlankSlides){c(r.grid.rows-t.slides.length%r.grid.rows),t.recalcSlides(),t.updateSlides()}else Ls("Swiper Loop Warning: The number of slides is not even to grid.rows, loop mode may not function properly. You need to add more slides (or make duplicates, or empty slides)");n()}else n();t.loopFix({slideRealIndex:e,direction:r.centeredSlides?void 0:"next"})},loopFix:function(e){let{slideRealIndex:t,slideTo:r=!0,direction:i,setTranslate:n,activeSlideIndex:s,byController:a,byMousewheel:o}=void 0===e?{}:e;const l=this;if(!l.params.loop)return;l.emit("beforeLoopFix");const{slides:c,allowSlidePrev:d,allowSlideNext:u,slidesEl:h,params:f}=l,{centeredSlides:p}=f;if(l.allowSlidePrev=!0,l.allowSlideNext=!0,l.virtual&&f.virtual.enabled)return r&&(f.centeredSlides||0!==l.snapIndex?f.centeredSlides&&l.snapIndex<f.slidesPerView?l.slideTo(l.virtual.slides.length+l.snapIndex,0,!1,!0):l.snapIndex===l.snapGrid.length-1&&l.slideTo(l.virtual.slidesBefore,0,!1,!0):l.slideTo(l.virtual.slides.length,0,!1,!0)),l.allowSlidePrev=d,l.allowSlideNext=u,void l.emit("loopFix");let m=f.slidesPerView;"auto"===m?m=l.slidesPerViewDynamic():(m=Math.ceil(parseFloat(f.slidesPerView,10)),p&&m%2==0&&(m+=1));const g=f.slidesPerGroupAuto?m:f.slidesPerGroup;let v=g;v%g!==0&&(v+=g-v%g),v+=f.loopAdditionalSlides,l.loopedSlides=v;const y=l.grid&&f.grid&&f.grid.rows>1;c.length<m+v?Ls("Swiper Loop Warning: The number of slides is not enough for loop mode, it will be disabled and not function properly. You need to add more slides (or make duplicates) or lower the values of slidesPerView and slidesPerGroup parameters"):y&&"row"===f.grid.fill&&Ls("Swiper Loop Warning: Loop mode is not compatible with grid.fill = `row`");const b=[],E=[];let w=l.activeIndex;void 0===s?s=l.getSlideIndex(c.filter(e=>e.classList.contains(f.slideActiveClass))[0]):w=s;const S="next"===i||!i,T="prev"===i||!i;let x=0,A=0;const k=y?Math.ceil(c.length/f.grid.rows):c.length,I=(y?c[s].column:s)+(p&&void 0===n?-m/2+.5:0);if(I<v){x=Math.max(v-I,g);for(let e=0;e<v-I;e+=1){const t=e-Math.floor(e/k)*k;if(y){const e=k-t-1;for(let t=c.length-1;t>=0;t-=1)c[t].column===e&&b.push(t)}else b.push(k-t-1)}}else if(I+m>k-v){A=Math.max(I-(k-2*v),g);for(let e=0;e<A;e+=1){const t=e-Math.floor(e/k)*k;y?c.forEach((e,r)=>{e.column===t&&E.push(r)}):E.push(t)}}if(l.__preventObserver__=!0,requestAnimationFrame(()=>{l.__preventObserver__=!1}),T&&b.forEach(e=>{c[e].swiperLoopMoveDOM=!0,h.prepend(c[e]),c[e].swiperLoopMoveDOM=!1}),S&&E.forEach(e=>{c[e].swiperLoopMoveDOM=!0,h.append(c[e]),c[e].swiperLoopMoveDOM=!1}),l.recalcSlides(),"auto"===f.slidesPerView?l.updateSlides():y&&(b.length>0&&T||E.length>0&&S)&&l.slides.forEach((e,t)=>{l.grid.updateSlide(t,e,l.slides)}),f.watchSlidesProgress&&l.updateSlidesOffset(),r)if(b.length>0&&T){if(void 0===t){const e=l.slidesGrid[w],t=l.slidesGrid[w+x]-e;o?l.setTranslate(l.translate-t):(l.slideTo(w+Math.ceil(x),0,!1,!0),n&&(l.touchEventsData.startTranslate=l.touchEventsData.startTranslate-t,l.touchEventsData.currentTranslate=l.touchEventsData.currentTranslate-t))}else if(n){const e=y?b.length/f.grid.rows:b.length;l.slideTo(l.activeIndex+e,0,!1,!0),l.touchEventsData.currentTranslate=l.translate}}else if(E.length>0&&S)if(void 0===t){const e=l.slidesGrid[w],t=l.slidesGrid[w-A]-e;o?l.setTranslate(l.translate-t):(l.slideTo(w-A,0,!1,!0),n&&(l.touchEventsData.startTranslate=l.touchEventsData.startTranslate-t,l.touchEventsData.currentTranslate=l.touchEventsData.currentTranslate-t))}else{const e=y?E.length/f.grid.rows:E.length;l.slideTo(l.activeIndex-e,0,!1,!0)}if(l.allowSlidePrev=d,l.allowSlideNext=u,l.controller&&l.controller.control&&!a){const e={slideRealIndex:t,direction:i,setTranslate:n,activeSlideIndex:s,byController:!0};Array.isArray(l.controller.control)?l.controller.control.forEach(t=>{!t.destroyed&&t.params.loop&&t.loopFix({...e,slideTo:t.params.slidesPerView===f.slidesPerView&&r})}):l.controller.control instanceof l.constructor&&l.controller.control.params.loop&&l.controller.control.loopFix({...e,slideTo:l.controller.control.params.slidesPerView===f.slidesPerView&&r})}l.emit("loopFix")},loopDestroy:function(){const e=this,{params:t,slidesEl:r}=e;if(!t.loop||e.virtual&&e.params.virtual.enabled)return;e.recalcSlides();const i=[];e.slides.forEach(e=>{const t=void 0===e.swiperSlideIndex?1*e.getAttribute("data-swiper-slide-index"):e.swiperSlideIndex;i[t]=e}),e.slides.forEach(e=>{e.removeAttribute("data-swiper-slide-index")}),i.forEach(e=>{r.append(e)}),e.recalcSlides(),e.slideTo(e.realIndex,0)}};function Zs(e,t,r){const i=vs(),{params:n}=e,s=n.edgeSwipeDetection,a=n.edgeSwipeThreshold;return!s||!(r<=a||r>=i.innerWidth-a)||"prevent"===s&&(t.preventDefault(),!0)}function Js(e){const t=this,r=ms();let i=e;i.originalEvent&&(i=i.originalEvent);const n=t.touchEventsData;if("pointerdown"===i.type){if(null!==n.pointerId&&n.pointerId!==i.pointerId)return;n.pointerId=i.pointerId}else"touchstart"===i.type&&1===i.targetTouches.length&&(n.touchId=i.targetTouches[0].identifier);if("touchstart"===i.type)return void Zs(t,i,i.targetTouches[0].pageX);const{params:s,touches:a,enabled:o}=t;if(!o)return;if(!s.simulateTouch&&"mouse"===i.pointerType)return;if(t.animating&&s.preventInteractionOnTransition)return;!t.animating&&s.cssMode&&s.loop&&t.loopFix();let l=i.target;if("wrapper"===s.touchEventsTarget&&!function(e,t){const r=t.contains(e);if(!r&&t instanceof HTMLSlotElement)return[...t.assignedElements()].includes(e);return r}(l,t.wrapperEl))return;if("which"in i&&3===i.which)return;if("button"in i&&i.button>0)return;if(n.isTouched&&n.isMoved)return;const c=!!s.noSwipingClass&&""!==s.noSwipingClass,d=i.composedPath?i.composedPath():i.path;c&&i.target&&i.target.shadowRoot&&d&&(l=d[0]);const u=s.noSwipingSelector?s.noSwipingSelector:`.${s.noSwipingClass}`,h=!(!i.target||!i.target.shadowRoot);if(s.noSwiping&&(h?function(e,t){return void 0===t&&(t=this),function t(r){if(!r||r===ms()||r===vs())return null;r.assignedSlot&&(r=r.assignedSlot);const i=r.closest(e);return i||r.getRootNode?i||t(r.getRootNode().host):null}(t)}(u,l):l.closest(u)))return void(t.allowClick=!0);if(s.swipeHandler&&!l.closest(s.swipeHandler))return;a.currentX=i.pageX,a.currentY=i.pageY;const f=a.currentX,p=a.currentY;if(!Zs(t,i,f))return;Object.assign(n,{isTouched:!0,isMoved:!1,allowTouchCallbacks:!0,isScrolling:void 0,startMoving:void 0}),a.startX=f,a.startY=p,n.touchStartTime=bs(),t.allowClick=!0,t.updateSize(),t.swipeDirection=void 0,s.threshold>0&&(n.allowThresholdMove=!1);let m=!0;l.matches(n.focusableElements)&&(m=!1,"SELECT"===l.nodeName&&(n.isTouched=!1)),r.activeElement&&r.activeElement.matches(n.focusableElements)&&r.activeElement!==l&&("mouse"===i.pointerType||"mouse"!==i.pointerType&&!l.matches(n.focusableElements))&&r.activeElement.blur();const g=m&&t.allowTouchMove&&s.touchStartPreventDefault;!s.touchStartForcePreventDefault&&!g||l.isContentEditable||i.preventDefault(),s.freeMode&&s.freeMode.enabled&&t.freeMode&&t.animating&&!s.cssMode&&t.freeMode.onTouchStart(),t.emit("touchStart",i)}function ea(e){const t=ms(),r=this,i=r.touchEventsData,{params:n,touches:s,rtlTranslate:a,enabled:o}=r;if(!o)return;if(!n.simulateTouch&&"mouse"===e.pointerType)return;let l,c=e;if(c.originalEvent&&(c=c.originalEvent),"pointermove"===c.type){if(null!==i.touchId)return;if(c.pointerId!==i.pointerId)return}if("touchmove"===c.type){if(l=[...c.changedTouches].filter(e=>e.identifier===i.touchId)[0],!l||l.identifier!==i.touchId)return}else l=c;if(!i.isTouched)return void(i.startMoving&&i.isScrolling&&r.emit("touchMoveOpposite",c));const d=l.pageX,u=l.pageY;if(c.preventedByNestedSwiper)return s.startX=d,void(s.startY=u);if(!r.allowTouchMove)return c.target.matches(i.focusableElements)||(r.allowClick=!1),void(i.isTouched&&(Object.assign(s,{startX:d,startY:u,currentX:d,currentY:u}),i.touchStartTime=bs()));if(n.touchReleaseOnEdges&&!n.loop)if(r.isVertical()){if(u<s.startY&&r.translate<=r.maxTranslate()||u>s.startY&&r.translate>=r.minTranslate())return i.isTouched=!1,void(i.isMoved=!1)}else if(d<s.startX&&r.translate<=r.maxTranslate()||d>s.startX&&r.translate>=r.minTranslate())return;if(t.activeElement&&t.activeElement.matches(i.focusableElements)&&t.activeElement!==c.target&&"mouse"!==c.pointerType&&t.activeElement.blur(),t.activeElement&&c.target===t.activeElement&&c.target.matches(i.focusableElements))return i.isMoved=!0,void(r.allowClick=!1);i.allowTouchCallbacks&&r.emit("touchMove",c),s.previousX=s.currentX,s.previousY=s.currentY,s.currentX=d,s.currentY=u;const h=s.currentX-s.startX,f=s.currentY-s.startY;if(r.params.threshold&&Math.sqrt(h**2+f**2)<r.params.threshold)return;if(void 0===i.isScrolling){let e;r.isHorizontal()&&s.currentY===s.startY||r.isVertical()&&s.currentX===s.startX?i.isScrolling=!1:h*h+f*f>=25&&(e=180*Math.atan2(Math.abs(f),Math.abs(h))/Math.PI,i.isScrolling=r.isHorizontal()?e>n.touchAngle:90-e>n.touchAngle)}if(i.isScrolling&&r.emit("touchMoveOpposite",c),void 0===i.startMoving&&(s.currentX===s.startX&&s.currentY===s.startY||(i.startMoving=!0)),i.isScrolling||"touchmove"===c.type&&i.preventTouchMoveFromPointerMove)return void(i.isTouched=!1);if(!i.startMoving)return;r.allowClick=!1,!n.cssMode&&c.cancelable&&c.preventDefault(),n.touchMoveStopPropagation&&!n.nested&&c.stopPropagation();let p=r.isHorizontal()?h:f,m=r.isHorizontal()?s.currentX-s.previousX:s.currentY-s.previousY;n.oneWayMovement&&(p=Math.abs(p)*(a?1:-1),m=Math.abs(m)*(a?1:-1)),s.diff=p,p*=n.touchRatio,a&&(p=-p,m=-m);const g=r.touchesDirection;r.swipeDirection=p>0?"prev":"next",r.touchesDirection=m>0?"prev":"next";const v=r.params.loop&&!n.cssMode,y="next"===r.touchesDirection&&r.allowSlideNext||"prev"===r.touchesDirection&&r.allowSlidePrev;if(!i.isMoved){if(v&&y&&r.loopFix({direction:r.swipeDirection}),i.startTranslate=r.getTranslate(),r.setTransition(0),r.animating){const e=new window.CustomEvent("transitionend",{bubbles:!0,cancelable:!0,detail:{bySwiperTouchMove:!0}});r.wrapperEl.dispatchEvent(e)}i.allowMomentumBounce=!1,!n.grabCursor||!0!==r.allowSlideNext&&!0!==r.allowSlidePrev||r.setGrabCursor(!0),r.emit("sliderFirstMove",c)}if((new Date).getTime(),i.isMoved&&i.allowThresholdMove&&g!==r.touchesDirection&&v&&y&&Math.abs(p)>=1)return Object.assign(s,{startX:d,startY:u,currentX:d,currentY:u,startTranslate:i.currentTranslate}),i.loopSwapReset=!0,void(i.startTranslate=i.currentTranslate);r.emit("sliderMove",c),i.isMoved=!0,i.currentTranslate=p+i.startTranslate;let b=!0,E=n.resistanceRatio;if(n.touchReleaseOnEdges&&(E=0),p>0?(v&&y&&i.allowThresholdMove&&i.currentTranslate>(n.centeredSlides?r.minTranslate()-r.slidesSizesGrid[r.activeIndex+1]-("auto"!==n.slidesPerView&&r.slides.length-n.slidesPerView>=2?r.slidesSizesGrid[r.activeIndex+1]+r.params.spaceBetween:0)-r.params.spaceBetween:r.minTranslate())&&r.loopFix({direction:"prev",setTranslate:!0,activeSlideIndex:0}),i.currentTranslate>r.minTranslate()&&(b=!1,n.resistance&&(i.currentTranslate=r.minTranslate()-1+(-r.minTranslate()+i.startTranslate+p)**E))):p<0&&(v&&y&&i.allowThresholdMove&&i.currentTranslate<(n.centeredSlides?r.maxTranslate()+r.slidesSizesGrid[r.slidesSizesGrid.length-1]+r.params.spaceBetween+("auto"!==n.slidesPerView&&r.slides.length-n.slidesPerView>=2?r.slidesSizesGrid[r.slidesSizesGrid.length-1]+r.params.spaceBetween:0):r.maxTranslate())&&r.loopFix({direction:"next",setTranslate:!0,activeSlideIndex:r.slides.length-("auto"===n.slidesPerView?r.slidesPerViewDynamic():Math.ceil(parseFloat(n.slidesPerView,10)))}),i.currentTranslate<r.maxTranslate()&&(b=!1,n.resistance&&(i.currentTranslate=r.maxTranslate()+1-(r.maxTranslate()-i.startTranslate-p)**E))),b&&(c.preventedByNestedSwiper=!0),!r.allowSlideNext&&"next"===r.swipeDirection&&i.currentTranslate<i.startTranslate&&(i.currentTranslate=i.startTranslate),!r.allowSlidePrev&&"prev"===r.swipeDirection&&i.currentTranslate>i.startTranslate&&(i.currentTranslate=i.startTranslate),r.allowSlidePrev||r.allowSlideNext||(i.currentTranslate=i.startTranslate),n.threshold>0){if(!(Math.abs(p)>n.threshold||i.allowThresholdMove))return void(i.currentTranslate=i.startTranslate);if(!i.allowThresholdMove)return i.allowThresholdMove=!0,s.startX=s.currentX,s.startY=s.currentY,i.currentTranslate=i.startTranslate,void(s.diff=r.isHorizontal()?s.currentX-s.startX:s.currentY-s.startY)}n.followFinger&&!n.cssMode&&((n.freeMode&&n.freeMode.enabled&&r.freeMode||n.watchSlidesProgress)&&(r.updateActiveIndex(),r.updateSlidesClasses()),n.freeMode&&n.freeMode.enabled&&r.freeMode&&r.freeMode.onTouchMove(),r.updateProgress(i.currentTranslate),r.setTranslate(i.currentTranslate))}function ta(e){const t=this,r=t.touchEventsData;let i,n=e;n.originalEvent&&(n=n.originalEvent);if("touchend"===n.type||"touchcancel"===n.type){if(i=[...n.changedTouches].filter(e=>e.identifier===r.touchId)[0],!i||i.identifier!==r.touchId)return}else{if(null!==r.touchId)return;if(n.pointerId!==r.pointerId)return;i=n}if(["pointercancel","pointerout","pointerleave","contextmenu"].includes(n.type)){if(!(["pointercancel","contextmenu"].includes(n.type)&&(t.browser.isSafari||t.browser.isWebView)))return}r.pointerId=null,r.touchId=null;const{params:s,touches:a,rtlTranslate:o,slidesGrid:l,enabled:c}=t;if(!c)return;if(!s.simulateTouch&&"mouse"===n.pointerType)return;if(r.allowTouchCallbacks&&t.emit("touchEnd",n),r.allowTouchCallbacks=!1,!r.isTouched)return r.isMoved&&s.grabCursor&&t.setGrabCursor(!1),r.isMoved=!1,void(r.startMoving=!1);s.grabCursor&&r.isMoved&&r.isTouched&&(!0===t.allowSlideNext||!0===t.allowSlidePrev)&&t.setGrabCursor(!1);const d=bs(),u=d-r.touchStartTime;if(t.allowClick){const e=n.path||n.composedPath&&n.composedPath();t.updateClickedSlide(e&&e[0]||n.target,e),t.emit("tap click",n),u<300&&d-r.lastClickTime<300&&t.emit("doubleTap doubleClick",n)}if(r.lastClickTime=bs(),ys(()=>{t.destroyed||(t.allowClick=!0)}),!r.isTouched||!r.isMoved||!t.swipeDirection||0===a.diff&&!r.loopSwapReset||r.currentTranslate===r.startTranslate&&!r.loopSwapReset)return r.isTouched=!1,r.isMoved=!1,void(r.startMoving=!1);let h;if(r.isTouched=!1,r.isMoved=!1,r.startMoving=!1,h=s.followFinger?o?t.translate:-t.translate:-r.currentTranslate,s.cssMode)return;if(s.freeMode&&s.freeMode.enabled)return void t.freeMode.onTouchEnd({currentPos:h});const f=h>=-t.maxTranslate()&&!t.params.loop;let p=0,m=t.slidesSizesGrid[0];for(let e=0;e<l.length;e+=e<s.slidesPerGroupSkip?1:s.slidesPerGroup){const t=e<s.slidesPerGroupSkip-1?1:s.slidesPerGroup;void 0!==l[e+t]?(f||h>=l[e]&&h<l[e+t])&&(p=e,m=l[e+t]-l[e]):(f||h>=l[e])&&(p=e,m=l[l.length-1]-l[l.length-2])}let g=null,v=null;s.rewind&&(t.isBeginning?v=s.virtual&&s.virtual.enabled&&t.virtual?t.virtual.slides.length-1:t.slides.length-1:t.isEnd&&(g=0));const y=(h-l[p])/m,b=p<s.slidesPerGroupSkip-1?1:s.slidesPerGroup;if(u>s.longSwipesMs){if(!s.longSwipes)return void t.slideTo(t.activeIndex);"next"===t.swipeDirection&&(y>=s.longSwipesRatio?t.slideTo(s.rewind&&t.isEnd?g:p+b):t.slideTo(p)),"prev"===t.swipeDirection&&(y>1-s.longSwipesRatio?t.slideTo(p+b):null!==v&&y<0&&Math.abs(y)>s.longSwipesRatio?t.slideTo(v):t.slideTo(p))}else{if(!s.shortSwipes)return void t.slideTo(t.activeIndex);t.navigation&&(n.target===t.navigation.nextEl||n.target===t.navigation.prevEl)?n.target===t.navigation.nextEl?t.slideTo(p+b):t.slideTo(p):("next"===t.swipeDirection&&t.slideTo(null!==g?g:p+b),"prev"===t.swipeDirection&&t.slideTo(null!==v?v:p))}}function ra(){const e=this,{params:t,el:r}=e;if(r&&0===r.offsetWidth)return;t.breakpoints&&e.setBreakpoint();const{allowSlideNext:i,allowSlidePrev:n,snapGrid:s}=e,a=e.virtual&&e.params.virtual.enabled;e.allowSlideNext=!0,e.allowSlidePrev=!0,e.updateSize(),e.updateSlides(),e.updateSlidesClasses();const o=a&&t.loop;!("auto"===t.slidesPerView||t.slidesPerView>1)||!e.isEnd||e.isBeginning||e.params.centeredSlides||o?e.params.loop&&!a?e.slideToLoop(e.realIndex,0,!1,!0):e.slideTo(e.activeIndex,0,!1,!0):e.slideTo(e.slides.length-1,0,!1,!0),e.autoplay&&e.autoplay.running&&e.autoplay.paused&&(clearTimeout(e.autoplay.resizeTimeout),e.autoplay.resizeTimeout=setTimeout(()=>{e.autoplay&&e.autoplay.running&&e.autoplay.paused&&e.autoplay.resume()},500)),e.allowSlidePrev=n,e.allowSlideNext=i,e.params.watchOverflow&&s!==e.snapGrid&&e.checkOverflow()}function ia(e){const t=this;t.enabled&&(t.allowClick||(t.params.preventClicks&&e.preventDefault(),t.params.preventClicksPropagation&&t.animating&&(e.stopPropagation(),e.stopImmediatePropagation())))}function na(){const e=this,{wrapperEl:t,rtlTranslate:r,enabled:i}=e;if(!i)return;let n;e.previousTranslate=e.translate,e.isHorizontal()?e.translate=-t.scrollLeft:e.translate=-t.scrollTop,0===e.translate&&(e.translate=0),e.updateActiveIndex(),e.updateSlidesClasses();const s=e.maxTranslate()-e.minTranslate();n=0===s?0:(e.translate-e.minTranslate())/s,n!==e.progress&&e.updateProgress(r?-e.translate:e.translate),e.emit("setTranslate",e.translate,!1)}function sa(e){const t=this;js(t,e.target),t.params.cssMode||"auto"!==t.params.slidesPerView&&!t.params.autoHeight||t.update()}function aa(){const e=this;e.documentTouchHandlerProceeded||(e.documentTouchHandlerProceeded=!0,e.params.touchReleaseOnEdges&&(e.el.style.touchAction="auto"))}const oa=(e,t)=>{const r=ms(),{params:i,el:n,wrapperEl:s,device:a}=e,o=!!i.nested,l="on"===t?"addEventListener":"removeEventListener",c=t;n&&"string"!=typeof n&&(r[l]("touchstart",e.onDocumentTouchStart,{passive:!1,capture:o}),n[l]("touchstart",e.onTouchStart,{passive:!1}),n[l]("pointerdown",e.onTouchStart,{passive:!1}),r[l]("touchmove",e.onTouchMove,{passive:!1,capture:o}),r[l]("pointermove",e.onTouchMove,{passive:!1,capture:o}),r[l]("touchend",e.onTouchEnd,{passive:!0}),r[l]("pointerup",e.onTouchEnd,{passive:!0}),r[l]("pointercancel",e.onTouchEnd,{passive:!0}),r[l]("touchcancel",e.onTouchEnd,{passive:!0}),r[l]("pointerout",e.onTouchEnd,{passive:!0}),r[l]("pointerleave",e.onTouchEnd,{passive:!0}),r[l]("contextmenu",e.onTouchEnd,{passive:!0}),(i.preventClicks||i.preventClicksPropagation)&&n[l]("click",e.onClick,!0),i.cssMode&&s[l]("scroll",e.onScroll),i.updateOnWindowResize?e[c](a.ios||a.android?"resize orientationchange observerUpdate":"resize observerUpdate",ra,!0):e[c]("observerUpdate",ra,!0),n[l]("load",e.onLoad,{capture:!0}))};const la=(e,t)=>e.grid&&t.grid&&t.grid.rows>1;var ca={setBreakpoint:function(){const e=this,{realIndex:t,initialized:r,params:i,el:n}=e,s=i.breakpoints;if(!s||s&&0===Object.keys(s).length)return;const a=e.getBreakpoint(s,e.params.breakpointsBase,e.el);if(!a||e.currentBreakpoint===a)return;const o=(a in s?s[a]:void 0)||e.originalParams,l=la(e,i),c=la(e,o),d=e.params.grabCursor,u=o.grabCursor,h=i.enabled;l&&!c?(n.classList.remove(`${i.containerModifierClass}grid`,`${i.containerModifierClass}grid-column`),e.emitContainerClasses()):!l&&c&&(n.classList.add(`${i.containerModifierClass}grid`),(o.grid.fill&&"column"===o.grid.fill||!o.grid.fill&&"column"===i.grid.fill)&&n.classList.add(`${i.containerModifierClass}grid-column`),e.emitContainerClasses()),d&&!u?e.unsetGrabCursor():!d&&u&&e.setGrabCursor(),["navigation","pagination","scrollbar"].forEach(t=>{if(void 0===o[t])return;const r=i[t]&&i[t].enabled,n=o[t]&&o[t].enabled;r&&!n&&e[t].disable(),!r&&n&&e[t].enable()});const f=o.direction&&o.direction!==i.direction,p=i.loop&&(o.slidesPerView!==i.slidesPerView||f),m=i.loop;f&&r&&e.changeDirection(),Ts(e.params,o);const g=e.params.enabled,v=e.params.loop;Object.assign(e,{allowTouchMove:e.params.allowTouchMove,allowSlideNext:e.params.allowSlideNext,allowSlidePrev:e.params.allowSlidePrev}),h&&!g?e.disable():!h&&g&&e.enable(),e.currentBreakpoint=a,e.emit("_beforeBreakpoint",o),r&&(p?(e.loopDestroy(),e.loopCreate(t),e.updateSlides()):!m&&v?(e.loopCreate(t),e.updateSlides()):m&&!v&&e.loopDestroy()),e.emit("breakpoint",o)},getBreakpoint:function(e,t,r){if(void 0===t&&(t="window"),!e||"container"===t&&!r)return;let i=!1;const n=vs(),s="window"===t?n.innerHeight:r.clientHeight,a=Object.keys(e).map(e=>{if("string"==typeof e&&0===e.indexOf("@")){const t=parseFloat(e.substr(1));return{value:s*t,point:e}}return{value:e,point:e}});a.sort((e,t)=>parseInt(e.value,10)-parseInt(t.value,10));for(let e=0;e<a.length;e+=1){const{point:s,value:o}=a[e];"window"===t?n.matchMedia(`(min-width: ${o}px)`).matches&&(i=s):o<=r.clientWidth&&(i=s)}return i||"max"}};var da={init:!0,direction:"horizontal",oneWayMovement:!1,swiperElementNodeName:"SWIPER-CONTAINER",touchEventsTarget:"wrapper",initialSlide:0,speed:300,cssMode:!1,updateOnWindowResize:!0,resizeObserver:!0,nested:!1,createElements:!1,eventsPrefix:"swiper",enabled:!0,focusableElements:"input, select, option, textarea, button, video, label",width:null,height:null,preventInteractionOnTransition:!1,userAgent:null,url:null,edgeSwipeDetection:!1,edgeSwipeThreshold:20,autoHeight:!1,setWrapperSize:!1,virtualTranslate:!1,effect:"slide",breakpoints:void 0,breakpointsBase:"window",spaceBetween:0,slidesPerView:1,slidesPerGroup:1,slidesPerGroupSkip:0,slidesPerGroupAuto:!1,centeredSlides:!1,centeredSlidesBounds:!1,slidesOffsetBefore:0,slidesOffsetAfter:0,normalizeSlideIndex:!0,centerInsufficientSlides:!1,watchOverflow:!0,roundLengths:!1,touchRatio:1,touchAngle:45,simulateTouch:!0,shortSwipes:!0,longSwipes:!0,longSwipesRatio:.5,longSwipesMs:300,followFinger:!0,allowTouchMove:!0,threshold:5,touchMoveStopPropagation:!1,touchStartPreventDefault:!0,touchStartForcePreventDefault:!1,touchReleaseOnEdges:!1,uniqueNavElements:!0,resistance:!0,resistanceRatio:.85,watchSlidesProgress:!1,grabCursor:!1,preventClicks:!0,preventClicksPropagation:!0,slideToClickedSlide:!1,loop:!1,loopAddBlankSlides:!0,loopAdditionalSlides:0,loopPreventsSliding:!0,rewind:!1,allowSlidePrev:!0,allowSlideNext:!0,swipeHandler:null,noSwiping:!0,noSwipingClass:"swiper-no-swiping",noSwipingSelector:null,passiveListeners:!0,maxBackfaceHiddenSlides:10,containerModifierClass:"swiper-",slideClass:"swiper-slide",slideBlankClass:"swiper-slide-blank",slideActiveClass:"swiper-slide-active",slideVisibleClass:"swiper-slide-visible",slideFullyVisibleClass:"swiper-slide-fully-visible",slideNextClass:"swiper-slide-next",slidePrevClass:"swiper-slide-prev",wrapperClass:"swiper-wrapper",lazyPreloaderClass:"swiper-lazy-preloader",lazyPreloadPrevNext:0,runCallbacksOnInit:!0,_emitClasses:!1};function ua(e,t){return function(r){void 0===r&&(r={});const i=Object.keys(r)[0],n=r[i];"object"==typeof n&&null!==n?(!0===e[i]&&(e[i]={enabled:!0}),"navigation"===i&&e[i]&&e[i].enabled&&!e[i].prevEl&&!e[i].nextEl&&(e[i].auto=!0),["pagination","scrollbar"].indexOf(i)>=0&&e[i]&&e[i].enabled&&!e[i].el&&(e[i].auto=!0),i in e&&"enabled"in n?("object"!=typeof e[i]||"enabled"in e[i]||(e[i].enabled=!0),e[i]||(e[i]={enabled:!1}),Ts(t,r)):Ts(t,r)):Ts(t,r)}}const ha={eventsEmitter:Us,update:Ws,translate:Ys,transition:qs,slide:Xs,loop:Qs,grabCursor:{setGrabCursor:function(e){const t=this;if(!t.params.simulateTouch||t.params.watchOverflow&&t.isLocked||t.params.cssMode)return;const r="container"===t.params.touchEventsTarget?t.el:t.wrapperEl;t.isElement&&(t.__preventObserver__=!0),r.style.cursor="move",r.style.cursor=e?"grabbing":"grab",t.isElement&&requestAnimationFrame(()=>{t.__preventObserver__=!1})},unsetGrabCursor:function(){const e=this;e.params.watchOverflow&&e.isLocked||e.params.cssMode||(e.isElement&&(e.__preventObserver__=!0),e["container"===e.params.touchEventsTarget?"el":"wrapperEl"].style.cursor="",e.isElement&&requestAnimationFrame(()=>{e.__preventObserver__=!1}))}},events:{attachEvents:function(){const e=this,{params:t}=e;e.onTouchStart=Js.bind(e),e.onTouchMove=ea.bind(e),e.onTouchEnd=ta.bind(e),e.onDocumentTouchStart=aa.bind(e),t.cssMode&&(e.onScroll=na.bind(e)),e.onClick=ia.bind(e),e.onLoad=sa.bind(e),oa(e,"on")},detachEvents:function(){oa(this,"off")}},breakpoints:ca,checkOverflow:{checkOverflow:function(){const e=this,{isLocked:t,params:r}=e,{slidesOffsetBefore:i}=r;if(i){const t=e.slides.length-1,r=e.slidesGrid[t]+e.slidesSizesGrid[t]+2*i;e.isLocked=e.size>r}else e.isLocked=1===e.snapGrid.length;!0===r.allowSlideNext&&(e.allowSlideNext=!e.isLocked),!0===r.allowSlidePrev&&(e.allowSlidePrev=!e.isLocked),t&&t!==e.isLocked&&(e.isEnd=!1),t!==e.isLocked&&e.emit(e.isLocked?"lock":"unlock")}},classes:{addClasses:function(){const e=this,{classNames:t,params:r,rtl:i,el:n,device:s}=e,a=function(e,t){const r=[];return e.forEach(e=>{"object"==typeof e?Object.keys(e).forEach(i=>{e[i]&&r.push(t+i)}):"string"==typeof e&&r.push(t+e)}),r}(["initialized",r.direction,{"free-mode":e.params.freeMode&&r.freeMode.enabled},{autoheight:r.autoHeight},{rtl:i},{grid:r.grid&&r.grid.rows>1},{"grid-column":r.grid&&r.grid.rows>1&&"column"===r.grid.fill},{android:s.android},{ios:s.ios},{"css-mode":r.cssMode},{centered:r.cssMode&&r.centeredSlides},{"watch-progress":r.watchSlidesProgress}],r.containerModifierClass);t.push(...a),n.classList.add(...t),e.emitContainerClasses()},removeClasses:function(){const{el:e,classNames:t}=this;e&&"string"!=typeof e&&(e.classList.remove(...t),this.emitContainerClasses())}}},fa={};let pa=class e{constructor(){let t,r;for(var i=arguments.length,n=new Array(i),s=0;s<i;s++)n[s]=arguments[s];1===n.length&&n[0].constructor&&"Object"===Object.prototype.toString.call(n[0]).slice(8,-1)?r=n[0]:[t,r]=n,r||(r={}),r=Ts({},r),t&&!r.el&&(r.el=t);const a=ms();if(r.el&&"string"==typeof r.el&&a.querySelectorAll(r.el).length>1){const t=[];return a.querySelectorAll(r.el).forEach(i=>{const n=Ts({},r,{el:i});t.push(new e(n))}),t}const o=this;o.__swiper__=!0,o.support=Fs(),o.device=$s({userAgent:r.userAgent}),o.browser=Bs(),o.eventsListeners={},o.eventsAnyListeners=[],o.modules=[...o.__modules__],r.modules&&Array.isArray(r.modules)&&o.modules.push(...r.modules);const l={};o.modules.forEach(e=>{e({params:r,swiper:o,extendParams:ua(r,l),on:o.on.bind(o),once:o.once.bind(o),off:o.off.bind(o),emit:o.emit.bind(o)})});const c=Ts({},da,l);return o.params=Ts({},c,fa,r),o.originalParams=Ts({},o.params),o.passedParams=Ts({},r),o.params&&o.params.on&&Object.keys(o.params.on).forEach(e=>{o.on(e,o.params.on[e])}),o.params&&o.params.onAny&&o.onAny(o.params.onAny),Object.assign(o,{enabled:o.params.enabled,el:t,classNames:[],slides:[],slidesGrid:[],snapGrid:[],slidesSizesGrid:[],isHorizontal:()=>"horizontal"===o.params.direction,isVertical:()=>"vertical"===o.params.direction,activeIndex:0,realIndex:0,isBeginning:!0,isEnd:!1,translate:0,previousTranslate:0,progress:0,velocity:0,animating:!1,cssOverflowAdjustment(){return Math.trunc(this.translate/2**23)*2**23},allowSlideNext:o.params.allowSlideNext,allowSlidePrev:o.params.allowSlidePrev,touchEventsData:{isTouched:void 0,isMoved:void 0,allowTouchCallbacks:void 0,touchStartTime:void 0,isScrolling:void 0,currentTranslate:void 0,startTranslate:void 0,allowThresholdMove:void 0,focusableElements:o.params.focusableElements,lastClickTime:0,clickTimeout:void 0,velocities:[],allowMomentumBounce:void 0,startMoving:void 0,pointerId:null,touchId:null},allowClick:!0,allowTouchMove:o.params.allowTouchMove,touches:{startX:0,startY:0,currentX:0,currentY:0,diff:0},imagesToLoad:[],imagesLoaded:0}),o.emit("_swiper"),o.params.init&&o.init(),o}getDirectionLabel(e){return this.isHorizontal()?e:{width:"height","margin-top":"margin-left","margin-bottom ":"margin-right","margin-left":"margin-top","margin-right":"margin-bottom","padding-left":"padding-top","padding-right":"padding-bottom",marginRight:"marginBottom"}[e]}getSlideIndex(e){const{slidesEl:t,params:r}=this,i=Cs(Is(t,`.${r.slideClass}, swiper-slide`)[0]);return Cs(e)-i}getSlideIndexByData(e){return this.getSlideIndex(this.slides.filter(t=>1*t.getAttribute("data-swiper-slide-index")===e)[0])}recalcSlides(){const{slidesEl:e,params:t}=this;this.slides=Is(e,`.${t.slideClass}, swiper-slide`)}enable(){const e=this;e.enabled||(e.enabled=!0,e.params.grabCursor&&e.setGrabCursor(),e.emit("enable"))}disable(){const e=this;e.enabled&&(e.enabled=!1,e.params.grabCursor&&e.unsetGrabCursor(),e.emit("disable"))}setProgress(e,t){const r=this;e=Math.min(Math.max(e,0),1);const i=r.minTranslate(),n=(r.maxTranslate()-i)*e+i;r.translateTo(n,void 0===t?0:t),r.updateActiveIndex(),r.updateSlidesClasses()}emitContainerClasses(){const e=this;if(!e.params._emitClasses||!e.el)return;const t=e.el.className.split(" ").filter(t=>0===t.indexOf("swiper")||0===t.indexOf(e.params.containerModifierClass));e.emit("_containerClasses",t.join(" "))}getSlideClasses(e){const t=this;return t.destroyed?"":e.className.split(" ").filter(e=>0===e.indexOf("swiper-slide")||0===e.indexOf(t.params.slideClass)).join(" ")}emitSlidesClasses(){const e=this;if(!e.params._emitClasses||!e.el)return;const t=[];e.slides.forEach(r=>{const i=e.getSlideClasses(r);t.push({slideEl:r,classNames:i}),e.emit("_slideClass",r,i)}),e.emit("_slideClasses",t)}slidesPerViewDynamic(e,t){void 0===e&&(e="current"),void 0===t&&(t=!1);const{params:r,slides:i,slidesGrid:n,slidesSizesGrid:s,size:a,activeIndex:o}=this;let l=1;if("number"==typeof r.slidesPerView)return r.slidesPerView;if(r.centeredSlides){let e,t=i[o]?Math.ceil(i[o].swiperSlideSize):0;for(let r=o+1;r<i.length;r+=1)i[r]&&!e&&(t+=Math.ceil(i[r].swiperSlideSize),l+=1,t>a&&(e=!0));for(let r=o-1;r>=0;r-=1)i[r]&&!e&&(t+=i[r].swiperSlideSize,l+=1,t>a&&(e=!0))}else if("current"===e)for(let e=o+1;e<i.length;e+=1){(t?n[e]+s[e]-n[o]<a:n[e]-n[o]<a)&&(l+=1)}else for(let e=o-1;e>=0;e-=1){n[o]-n[e]<a&&(l+=1)}return l}update(){const e=this;if(!e||e.destroyed)return;const{snapGrid:t,params:r}=e;function i(){const t=e.rtlTranslate?-1*e.translate:e.translate,r=Math.min(Math.max(t,e.maxTranslate()),e.minTranslate());e.setTranslate(r),e.updateActiveIndex(),e.updateSlidesClasses()}let n;if(r.breakpoints&&e.setBreakpoint(),[...e.el.querySelectorAll('[loading="lazy"]')].forEach(t=>{t.complete&&js(e,t)}),e.updateSize(),e.updateSlides(),e.updateProgress(),e.updateSlidesClasses(),r.freeMode&&r.freeMode.enabled&&!r.cssMode)i(),r.autoHeight&&e.updateAutoHeight();else{if(("auto"===r.slidesPerView||r.slidesPerView>1)&&e.isEnd&&!r.centeredSlides){const t=e.virtual&&r.virtual.enabled?e.virtual.slides:e.slides;n=e.slideTo(t.length-1,0,!1,!0)}else n=e.slideTo(e.activeIndex,0,!1,!0);n||i()}r.watchOverflow&&t!==e.snapGrid&&e.checkOverflow(),e.emit("update")}changeDirection(e,t){void 0===t&&(t=!0);const r=this,i=r.params.direction;return e||(e="horizontal"===i?"vertical":"horizontal"),e===i||"horizontal"!==e&&"vertical"!==e||(r.el.classList.remove(`${r.params.containerModifierClass}${i}`),r.el.classList.add(`${r.params.containerModifierClass}${e}`),r.emitContainerClasses(),r.params.direction=e,r.slides.forEach(t=>{"vertical"===e?t.style.width="":t.style.height=""}),r.emit("changeDirection"),t&&r.update()),r}changeLanguageDirection(e){const t=this;t.rtl&&"rtl"===e||!t.rtl&&"ltr"===e||(t.rtl="rtl"===e,t.rtlTranslate="horizontal"===t.params.direction&&t.rtl,t.rtl?(t.el.classList.add(`${t.params.containerModifierClass}rtl`),t.el.dir="rtl"):(t.el.classList.remove(`${t.params.containerModifierClass}rtl`),t.el.dir="ltr"),t.update())}mount(e){const t=this;if(t.mounted)return!0;let r=e||t.params.el;if("string"==typeof r&&(r=document.querySelector(r)),!r)return!1;r.swiper=t,r.parentNode&&r.parentNode.host&&r.parentNode.host.nodeName===t.params.swiperElementNodeName.toUpperCase()&&(t.isElement=!0);const i=()=>`.${(t.params.wrapperClass||"").trim().split(" ").join(".")}`;let n=(()=>{if(r&&r.shadowRoot&&r.shadowRoot.querySelector){return r.shadowRoot.querySelector(i())}return Is(r,i())[0]})();return!n&&t.params.createElements&&(n=Rs("div",t.params.wrapperClass),r.append(n),Is(r,`.${t.params.slideClass}`).forEach(e=>{n.append(e)})),Object.assign(t,{el:r,wrapperEl:n,slidesEl:t.isElement&&!r.parentNode.host.slideSlots?r.parentNode.host:n,hostEl:t.isElement?r.parentNode.host:r,mounted:!0,rtl:"rtl"===r.dir.toLowerCase()||"rtl"===Ps(r,"direction"),rtlTranslate:"horizontal"===t.params.direction&&("rtl"===r.dir.toLowerCase()||"rtl"===Ps(r,"direction")),wrongRTL:"-webkit-box"===Ps(n,"display")}),!0}init(e){const t=this;if(t.initialized)return t;if(!1===t.mount(e))return t;t.emit("beforeInit"),t.params.breakpoints&&t.setBreakpoint(),t.addClasses(),t.updateSize(),t.updateSlides(),t.params.watchOverflow&&t.checkOverflow(),t.params.grabCursor&&t.enabled&&t.setGrabCursor(),t.params.loop&&t.virtual&&t.params.virtual.enabled?t.slideTo(t.params.initialSlide+t.virtual.slidesBefore,0,t.params.runCallbacksOnInit,!1,!0):t.slideTo(t.params.initialSlide,0,t.params.runCallbacksOnInit,!1,!0),t.params.loop&&t.loopCreate(),t.attachEvents();const r=[...t.el.querySelectorAll('[loading="lazy"]')];return t.isElement&&r.push(...t.hostEl.querySelectorAll('[loading="lazy"]')),r.forEach(e=>{e.complete?js(t,e):e.addEventListener("load",e=>{js(t,e.target)})}),Vs(t),t.initialized=!0,Vs(t),t.emit("init"),t.emit("afterInit"),t}destroy(e,t){void 0===e&&(e=!0),void 0===t&&(t=!0);const r=this,{params:i,el:n,wrapperEl:s,slides:a}=r;return void 0===r.params||r.destroyed||(r.emit("beforeDestroy"),r.initialized=!1,r.detachEvents(),i.loop&&r.loopDestroy(),t&&(r.removeClasses(),n&&"string"!=typeof n&&n.removeAttribute("style"),s&&s.removeAttribute("style"),a&&a.length&&a.forEach(e=>{e.classList.remove(i.slideVisibleClass,i.slideFullyVisibleClass,i.slideActiveClass,i.slideNextClass,i.slidePrevClass),e.removeAttribute("style"),e.removeAttribute("data-swiper-slide-index")})),r.emit("destroy"),Object.keys(r.eventsListeners).forEach(e=>{r.off(e)}),!1!==e&&(r.el&&"string"!=typeof r.el&&(r.el.swiper=null),function(e){const t=e;Object.keys(t).forEach(e=>{try{t[e]=null}catch(e){}try{delete t[e]}catch(e){}})}(r)),r.destroyed=!0),null}static extendDefaults(e){Ts(fa,e)}static get extendedDefaults(){return fa}static get defaults(){return da}static installModule(t){e.prototype.__modules__||(e.prototype.__modules__=[]);const r=e.prototype.__modules__;"function"==typeof t&&r.indexOf(t)<0&&r.push(t)}static use(t){return Array.isArray(t)?(t.forEach(t=>e.installModule(t)),e):(e.installModule(t),e)}};Object.keys(ha).forEach(e=>{Object.keys(ha[e]).forEach(t=>{pa.prototype[t]=ha[e][t]})}),pa.use([function(e){let{swiper:t,on:r,emit:i}=e;const n=vs();let s=null,a=null;const o=()=>{t&&!t.destroyed&&t.initialized&&(i("beforeResize"),i("resize"))},l=()=>{t&&!t.destroyed&&t.initialized&&i("orientationchange")};r("init",()=>{t.params.resizeObserver&&void 0!==n.ResizeObserver?t&&!t.destroyed&&t.initialized&&(s=new ResizeObserver(e=>{a=n.requestAnimationFrame(()=>{const{width:r,height:i}=t;let n=r,s=i;e.forEach(e=>{let{contentBoxSize:r,contentRect:i,target:a}=e;a&&a!==t.el||(n=i?i.width:(r[0]||r).inlineSize,s=i?i.height:(r[0]||r).blockSize)}),n===r&&s===i||o()})}),s.observe(t.el)):(n.addEventListener("resize",o),n.addEventListener("orientationchange",l))}),r("destroy",()=>{a&&n.cancelAnimationFrame(a),s&&s.unobserve&&t.el&&(s.unobserve(t.el),s=null),n.removeEventListener("resize",o),n.removeEventListener("orientationchange",l)})},function(e){let{swiper:t,extendParams:r,on:i,emit:n}=e;const s=[],a=vs(),o=function(e,r){void 0===r&&(r={});const i=new(a.MutationObserver||a.WebkitMutationObserver)(e=>{if(t.__preventObserver__)return;if(1===e.length)return void n("observerUpdate",e[0]);const r=function(){n("observerUpdate",e[0])};a.requestAnimationFrame?a.requestAnimationFrame(r):a.setTimeout(r,0)});i.observe(e,{attributes:void 0===r.attributes||r.attributes,childList:t.isElement||(void 0===r.childList||r).childList,characterData:void 0===r.characterData||r.characterData}),s.push(i)};r({observer:!1,observeParents:!1,observeSlideChildren:!1}),i("init",()=>{if(t.params.observer){if(t.params.observeParents){const e=function(e){const t=[];let r=e.parentElement;for(;r;)t.push(r),r=r.parentElement;return t}(t.hostEl);for(let t=0;t<e.length;t+=1)o(e[t])}o(t.hostEl,{childList:t.params.observeSlideChildren}),o(t.wrapperEl,{attributes:!1})}}),i("destroy",()=>{s.forEach(e=>{e.disconnect()}),s.splice(0,s.length)})}]);const ma=["eventsPrefix","injectStyles","injectStylesUrls","modules","init","_direction","oneWayMovement","swiperElementNodeName","touchEventsTarget","initialSlide","_speed","cssMode","updateOnWindowResize","resizeObserver","nested","focusableElements","_enabled","_width","_height","preventInteractionOnTransition","userAgent","url","_edgeSwipeDetection","_edgeSwipeThreshold","_freeMode","_autoHeight","setWrapperSize","virtualTranslate","_effect","breakpoints","breakpointsBase","_spaceBetween","_slidesPerView","maxBackfaceHiddenSlides","_grid","_slidesPerGroup","_slidesPerGroupSkip","_slidesPerGroupAuto","_centeredSlides","_centeredSlidesBounds","_slidesOffsetBefore","_slidesOffsetAfter","normalizeSlideIndex","_centerInsufficientSlides","_watchOverflow","roundLengths","touchRatio","touchAngle","simulateTouch","_shortSwipes","_longSwipes","longSwipesRatio","longSwipesMs","_followFinger","allowTouchMove","_threshold","touchMoveStopPropagation","touchStartPreventDefault","touchStartForcePreventDefault","touchReleaseOnEdges","uniqueNavElements","_resistance","_resistanceRatio","_watchSlidesProgress","_grabCursor","preventClicks","preventClicksPropagation","_slideToClickedSlide","_loop","loopAdditionalSlides","loopAddBlankSlides","loopPreventsSliding","_rewind","_allowSlidePrev","_allowSlideNext","_swipeHandler","_noSwiping","noSwipingClass","noSwipingSelector","passiveListeners","containerModifierClass","slideClass","slideActiveClass","slideVisibleClass","slideFullyVisibleClass","slideNextClass","slidePrevClass","slideBlankClass","wrapperClass","lazyPreloaderClass","lazyPreloadPrevNext","runCallbacksOnInit","observer","observeParents","observeSlideChildren","a11y","_autoplay","_controller","coverflowEffect","cubeEffect","fadeEffect","flipEffect","creativeEffect","cardsEffect","hashNavigation","history","keyboard","mousewheel","_navigation","_pagination","parallax","_scrollbar","_thumbs","virtual","zoom","control"];function ga(e){return"object"==typeof e&&null!==e&&e.constructor&&"Object"===Object.prototype.toString.call(e).slice(8,-1)&&!e.__swiper__}function va(e,t){const r=["__proto__","constructor","prototype"];Object.keys(t).filter(e=>r.indexOf(e)<0).forEach(r=>{void 0===e[r]?e[r]=t[r]:ga(t[r])&&ga(e[r])&&Object.keys(t[r]).length>0?t[r].__swiper__?e[r]=t[r]:va(e[r],t[r]):e[r]=t[r]})}function ya(e){return void 0===e&&(e={}),e.navigation&&void 0===e.navigation.nextEl&&void 0===e.navigation.prevEl}function ba(e){return void 0===e&&(e={}),e.pagination&&void 0===e.pagination.el}function Ea(e){return void 0===e&&(e={}),e.scrollbar&&void 0===e.scrollbar.el}function wa(e){void 0===e&&(e="");const t=e.split(" ").map(e=>e.trim()).filter(e=>!!e),r=[];return t.forEach(e=>{r.indexOf(e)<0&&r.push(e)}),r.join(" ")}function Sa(e){return void 0===e&&(e=""),e?e.includes("swiper-wrapper")?e:`swiper-wrapper ${e}`:"swiper-wrapper"}function Ta(){return Ta=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},Ta.apply(this,arguments)}function xa(e){return e.type&&e.type.displayName&&e.type.displayName.includes("SwiperSlide")}function Aa(e){const r=[];return t.Children.toArray(e).forEach(e=>{xa(e)?r.push(e):e.props&&e.props.children&&Aa(e.props.children).forEach(e=>r.push(e))}),r}function ka(e){const r=[],i={"container-start":[],"container-end":[],"wrapper-start":[],"wrapper-end":[]};return t.Children.toArray(e).forEach(e=>{if(xa(e))r.push(e);else if(e.props&&e.props.slot&&i[e.props.slot])i[e.props.slot].push(e);else if(e.props&&e.props.children){const t=Aa(e.props.children);t.length>0?t.forEach(e=>r.push(e)):i["container-end"].push(e)}else i["container-end"].push(e)}),{slides:r,slots:i}}function Ia(e,t){return"undefined"==typeof window?i(e,t):l(e,t)}const La=a(null),Ra=a(null),Pa=o(function(e,n){let{className:a,tag:o="div",wrapperTag:l="div",children:c,onSwiper:d,...u}=void 0===e?{}:e,h=!1;const[f,p]=s("swiper"),[m,g]=s(null),[v,y]=s(!1),b=r(!1),E=r(null),w=r(null),S=r(null),T=r(null),x=r(null),A=r(null),k=r(null),I=r(null),{params:L,passedParams:R,rest:P,events:C}=function(e,t){void 0===e&&(e={}),void 0===t&&(t=!0);const r={on:{}},i={},n={};va(r,da),r._emitClasses=!0,r.init=!1;const s={},a=ma.map(e=>e.replace(/_/,"")),o=Object.assign({},e);return Object.keys(o).forEach(o=>{void 0!==e[o]&&(a.indexOf(o)>=0?ga(e[o])?(r[o]={},n[o]={},va(r[o],e[o]),va(n[o],e[o])):(r[o]=e[o],n[o]=e[o]):0===o.search(/on[A-Z]/)&&"function"==typeof e[o]?t?i[`${o[2].toLowerCase()}${o.substr(3)}`]=e[o]:r.on[`${o[2].toLowerCase()}${o.substr(3)}`]=e[o]:s[o]=e[o])}),["navigation","pagination","scrollbar"].forEach(e=>{!0===r[e]&&(r[e]={}),!1===r[e]&&delete r[e]}),{params:r,passedParams:n,rest:s,events:i}}(u),{slides:D,slots:_}=ka(c),O=()=>{y(!v)};Object.assign(L.on,{_containerClasses(e,t){p(t)}});const M=()=>{Object.assign(L.on,C),h=!0;const e={...L};if(delete e.wrapperClass,w.current=new pa(e),w.current.virtual&&w.current.params.virtual.enabled){w.current.virtual.slides=D;const e={cache:!1,slides:D,renderExternal:g,renderExternalUpdate:!1};va(w.current.params.virtual,e),va(w.current.originalParams.virtual,e)}};E.current||M(),w.current&&w.current.on("_beforeBreakpoint",O);return i(()=>()=>{w.current&&w.current.off("_beforeBreakpoint",O)}),i(()=>{!b.current&&w.current&&(w.current.emitSlidesClasses(),b.current=!0)}),Ia(()=>{if(n&&(n.current=E.current),E.current)return w.current.destroyed&&M(),function(e,t){let{el:r,nextEl:i,prevEl:n,paginationEl:s,scrollbarEl:a,swiper:o}=e;ya(t)&&i&&n&&(o.params.navigation.nextEl=i,o.originalParams.navigation.nextEl=i,o.params.navigation.prevEl=n,o.originalParams.navigation.prevEl=n),ba(t)&&s&&(o.params.pagination.el=s,o.originalParams.pagination.el=s),Ea(t)&&a&&(o.params.scrollbar.el=a,o.originalParams.scrollbar.el=a),o.init(r)}({el:E.current,nextEl:x.current,prevEl:A.current,paginationEl:k.current,scrollbarEl:I.current,swiper:w.current},L),d&&!w.current.destroyed&&d(w.current),()=>{w.current&&!w.current.destroyed&&w.current.destroy(!0,!1)}},[]),Ia(()=>{!h&&C&&w.current&&Object.keys(C).forEach(e=>{w.current.on(e,C[e])});const e=function(e,t,r,i,n){const s=[];if(!t)return s;const a=e=>{s.indexOf(e)<0&&s.push(e)};if(r&&i){const e=i.map(n),t=r.map(n);e.join("")!==t.join("")&&a("children"),i.length!==r.length&&a("children")}return ma.filter(e=>"_"===e[0]).map(e=>e.replace(/_/,"")).forEach(r=>{if(r in e&&r in t)if(ga(e[r])&&ga(t[r])){const i=Object.keys(e[r]),n=Object.keys(t[r]);i.length!==n.length?a(r):(i.forEach(i=>{e[r][i]!==t[r][i]&&a(r)}),n.forEach(i=>{e[r][i]!==t[r][i]&&a(r)}))}else e[r]!==t[r]&&a(r)}),s}(R,S.current,D,T.current,e=>e.key);return S.current=R,T.current=D,e.length&&w.current&&!w.current.destroyed&&function(e){let{swiper:t,slides:r,passedParams:i,changedParams:n,nextEl:s,prevEl:a,scrollbarEl:o,paginationEl:l}=e;const c=n.filter(e=>"children"!==e&&"direction"!==e&&"wrapperClass"!==e),{params:d,pagination:u,navigation:h,scrollbar:f,virtual:p,thumbs:m}=t;let g,v,y,b,E,w,S,T;n.includes("thumbs")&&i.thumbs&&i.thumbs.swiper&&!i.thumbs.swiper.destroyed&&d.thumbs&&(!d.thumbs.swiper||d.thumbs.swiper.destroyed)&&(g=!0),n.includes("controller")&&i.controller&&i.controller.control&&d.controller&&!d.controller.control&&(v=!0),n.includes("pagination")&&i.pagination&&(i.pagination.el||l)&&(d.pagination||!1===d.pagination)&&u&&!u.el&&(y=!0),n.includes("scrollbar")&&i.scrollbar&&(i.scrollbar.el||o)&&(d.scrollbar||!1===d.scrollbar)&&f&&!f.el&&(b=!0),n.includes("navigation")&&i.navigation&&(i.navigation.prevEl||a)&&(i.navigation.nextEl||s)&&(d.navigation||!1===d.navigation)&&h&&!h.prevEl&&!h.nextEl&&(E=!0);const x=e=>{t[e]&&(t[e].destroy(),"navigation"===e?(t.isElement&&(t[e].prevEl.remove(),t[e].nextEl.remove()),d[e].prevEl=void 0,d[e].nextEl=void 0,t[e].prevEl=void 0,t[e].nextEl=void 0):(t.isElement&&t[e].el.remove(),d[e].el=void 0,t[e].el=void 0))};n.includes("loop")&&t.isElement&&(d.loop&&!i.loop?w=!0:!d.loop&&i.loop?S=!0:T=!0),c.forEach(e=>{if(ga(d[e])&&ga(i[e]))Object.assign(d[e],i[e]),"navigation"!==e&&"pagination"!==e&&"scrollbar"!==e||!("enabled"in i[e])||i[e].enabled||x(e);else{const t=i[e];!0!==t&&!1!==t||"navigation"!==e&&"pagination"!==e&&"scrollbar"!==e?d[e]=i[e]:!1===t&&x(e)}}),c.includes("controller")&&!v&&t.controller&&t.controller.control&&d.controller&&d.controller.control&&(t.controller.control=d.controller.control),n.includes("children")&&r&&p&&d.virtual.enabled?(p.slides=r,p.update(!0)):n.includes("virtual")&&p&&d.virtual.enabled&&(r&&(p.slides=r),p.update(!0)),n.includes("children")&&r&&d.loop&&(T=!0),g&&m.init()&&m.update(!0);v&&(t.controller.control=d.controller.control),y&&(!t.isElement||l&&"string"!=typeof l||(l=document.createElement("div"),l.classList.add("swiper-pagination"),l.part.add("pagination"),t.el.appendChild(l)),l&&(d.pagination.el=l),u.init(),u.render(),u.update()),b&&(!t.isElement||o&&"string"!=typeof o||(o=document.createElement("div"),o.classList.add("swiper-scrollbar"),o.part.add("scrollbar"),t.el.appendChild(o)),o&&(d.scrollbar.el=o),f.init(),f.updateSize(),f.setTranslate()),E&&(t.isElement&&(s&&"string"!=typeof s||(s=document.createElement("div"),s.classList.add("swiper-button-next"),s.innerHTML=t.hostEl.constructor.nextButtonSvg,s.part.add("button-next"),t.el.appendChild(s)),a&&"string"!=typeof a||(a=document.createElement("div"),a.classList.add("swiper-button-prev"),a.innerHTML=t.hostEl.constructor.prevButtonSvg,a.part.add("button-prev"),t.el.appendChild(a))),s&&(d.navigation.nextEl=s),a&&(d.navigation.prevEl=a),h.init(),h.update()),n.includes("allowSlideNext")&&(t.allowSlideNext=i.allowSlideNext),n.includes("allowSlidePrev")&&(t.allowSlidePrev=i.allowSlidePrev),n.includes("direction")&&t.changeDirection(i.direction,!1),(w||T)&&t.loopDestroy(),(S||T)&&t.loopCreate(),t.update()}({swiper:w.current,slides:D,passedParams:R,changedParams:e,nextEl:x.current,prevEl:A.current,scrollbarEl:I.current,paginationEl:k.current}),()=>{C&&w.current&&Object.keys(C).forEach(e=>{w.current.off(e,C[e])})}}),Ia(()=>{var e;!(e=w.current)||e.destroyed||!e.params.virtual||e.params.virtual&&!e.params.virtual.enabled||(e.updateSlides(),e.updateProgress(),e.updateSlidesClasses(),e.parallax&&e.params.parallax&&e.params.parallax.enabled&&e.parallax.setTranslate())},[m]),t.createElement(o,Ta({ref:E,className:wa(`${f}${a?` ${a}`:""}`)},P),t.createElement(Ra.Provider,{value:w.current},_["container-start"],t.createElement(l,{className:Sa(L.wrapperClass)},_["wrapper-start"],L.virtual?function(e,r,i){if(!i)return null;const n=e=>{let t=e;return e<0?t=r.length+e:t>=r.length&&(t-=r.length),t},s=e.isHorizontal()?{[e.rtlTranslate?"right":"left"]:`${i.offset}px`}:{top:`${i.offset}px`},{from:a,to:o}=i,l=e.params.loop?-r.length:0,c=e.params.loop?2*r.length:r.length,d=[];for(let e=l;e<c;e+=1)e>=a&&e<=o&&d.push(r[n(e)]);return d.map((r,i)=>t.cloneElement(r,{swiper:e,style:s,key:r.props.virtualIndex||r.key||`slide-${i}`}))}(w.current,D,m):D.map((e,r)=>t.cloneElement(e,{swiper:w.current,swiperSlideIndex:r})),_["wrapper-end"]),ya(L)&&t.createElement(t.Fragment,null,t.createElement("div",{ref:A,className:"swiper-button-prev"}),t.createElement("div",{ref:x,className:"swiper-button-next"})),Ea(L)&&t.createElement("div",{ref:I,className:"swiper-scrollbar"}),ba(L)&&t.createElement("div",{ref:k,className:"swiper-pagination"}),_["container-end"]))});Pa.displayName="Swiper";const Ca=o(function(e,i){let{tag:n="div",children:a,className:o="",swiper:l,zoom:c,lazy:d,virtualIndex:u,swiperSlideIndex:h,...f}=void 0===e?{}:e;const p=r(null),[m,g]=s("swiper-slide"),[v,y]=s(!1);function b(e,t,r){t===p.current&&g(r)}Ia(()=>{if(void 0!==h&&(p.current.swiperSlideIndex=h),i&&(i.current=p.current),p.current&&l){if(!l.destroyed)return l.on("_slideClass",b),()=>{l&&l.off("_slideClass",b)};"swiper-slide"!==m&&g("swiper-slide")}}),Ia(()=>{l&&p.current&&!l.destroyed&&g(l.getSlideClasses(p.current))},[l]);const E={isActive:m.indexOf("swiper-slide-active")>=0,isVisible:m.indexOf("swiper-slide-visible")>=0,isPrev:m.indexOf("swiper-slide-prev")>=0,isNext:m.indexOf("swiper-slide-next")>=0},w=()=>"function"==typeof a?a(E):a;return t.createElement(n,Ta({ref:p,className:wa(`${m}${o?` ${o}`:""}`),"data-swiper-slide-index":u,onLoad:()=>{y(!0)}},f),c&&t.createElement(La.Provider,{value:E},t.createElement("div",{className:"swiper-zoom-container","data-swiper-zoom":"number"==typeof c?c:void 0},w(),d&&!v&&t.createElement("div",{className:"swiper-lazy-preloader"}))),!c&&t.createElement(La.Provider,{value:E},w(),d&&!v&&t.createElement("div",{className:"swiper-lazy-preloader"})))});function Da(e){let{swiper:t,extendParams:r,on:i,emit:n}=e;const s=vs();let a;r({mousewheel:{enabled:!1,releaseOnEdges:!1,invert:!1,forceToAxis:!1,sensitivity:1,eventsTarget:"container",thresholdDelta:null,thresholdTime:null,noMousewheelClass:"swiper-no-mousewheel"}}),t.mousewheel={enabled:!1};let o,l=bs();const c=[];function d(){t.enabled&&(t.mouseEntered=!0)}function u(){t.enabled&&(t.mouseEntered=!1)}function h(e){return!(t.params.mousewheel.thresholdDelta&&e.delta<t.params.mousewheel.thresholdDelta)&&(!(t.params.mousewheel.thresholdTime&&bs()-l<t.params.mousewheel.thresholdTime)&&(e.delta>=6&&bs()-l<60||(e.direction<0?t.isEnd&&!t.params.loop||t.animating||(t.slideNext(),n("scroll",e.raw)):t.isBeginning&&!t.params.loop||t.animating||(t.slidePrev(),n("scroll",e.raw)),l=(new s.Date).getTime(),!1)))}function f(e){let r=e,i=!0;if(!t.enabled)return;if(e.target.closest(`.${t.params.mousewheel.noMousewheelClass}`))return;const s=t.params.mousewheel;t.params.cssMode&&r.preventDefault();let l=t.el;"container"!==t.params.mousewheel.eventsTarget&&(l=document.querySelector(t.params.mousewheel.eventsTarget));const d=l&&l.contains(r.target);if(!t.mouseEntered&&!d&&!s.releaseOnEdges)return!0;r.originalEvent&&(r=r.originalEvent);let u=0;const f=t.rtlTranslate?-1:1,p=function(e){let t=0,r=0,i=0,n=0;return"detail"in e&&(r=e.detail),"wheelDelta"in e&&(r=-e.wheelDelta/120),"wheelDeltaY"in e&&(r=-e.wheelDeltaY/120),"wheelDeltaX"in e&&(t=-e.wheelDeltaX/120),"axis"in e&&e.axis===e.HORIZONTAL_AXIS&&(t=r,r=0),i=10*t,n=10*r,"deltaY"in e&&(n=e.deltaY),"deltaX"in e&&(i=e.deltaX),e.shiftKey&&!i&&(i=n,n=0),(i||n)&&e.deltaMode&&(1===e.deltaMode?(i*=40,n*=40):(i*=800,n*=800)),i&&!t&&(t=i<1?-1:1),n&&!r&&(r=n<1?-1:1),{spinX:t,spinY:r,pixelX:i,pixelY:n}}(r);if(s.forceToAxis)if(t.isHorizontal()){if(!(Math.abs(p.pixelX)>Math.abs(p.pixelY)))return!0;u=-p.pixelX*f}else{if(!(Math.abs(p.pixelY)>Math.abs(p.pixelX)))return!0;u=-p.pixelY}else u=Math.abs(p.pixelX)>Math.abs(p.pixelY)?-p.pixelX*f:-p.pixelY;if(0===u)return!0;s.invert&&(u=-u);let m=t.getTranslate()+u*s.sensitivity;if(m>=t.minTranslate()&&(m=t.minTranslate()),m<=t.maxTranslate()&&(m=t.maxTranslate()),i=!!t.params.loop||!(m===t.minTranslate()||m===t.maxTranslate()),i&&t.params.nested&&r.stopPropagation(),t.params.freeMode&&t.params.freeMode.enabled){const e={time:bs(),delta:Math.abs(u),direction:Math.sign(u)},i=o&&e.time<o.time+500&&e.delta<=o.delta&&e.direction===o.direction;if(!i){o=void 0;let l=t.getTranslate()+u*s.sensitivity;const d=t.isBeginning,h=t.isEnd;if(l>=t.minTranslate()&&(l=t.minTranslate()),l<=t.maxTranslate()&&(l=t.maxTranslate()),t.setTransition(0),t.setTranslate(l),t.updateProgress(),t.updateActiveIndex(),t.updateSlidesClasses(),(!d&&t.isBeginning||!h&&t.isEnd)&&t.updateSlidesClasses(),t.params.loop&&t.loopFix({direction:e.direction<0?"next":"prev",byMousewheel:!0}),t.params.freeMode.sticky){clearTimeout(a),a=void 0,c.length>=15&&c.shift();const r=c.length?c[c.length-1]:void 0,i=c[0];if(c.push(e),r&&(e.delta>r.delta||e.direction!==r.direction))c.splice(0);else if(c.length>=15&&e.time-i.time<500&&i.delta-e.delta>=1&&e.delta<=6){const r=u>0?.8:.2;o=e,c.splice(0),a=ys(()=>{!t.destroyed&&t.params&&t.slideToClosest(t.params.speed,!0,void 0,r)},0)}a||(a=ys(()=>{if(t.destroyed||!t.params)return;o=e,c.splice(0),t.slideToClosest(t.params.speed,!0,void 0,.5)},500))}if(i||n("scroll",r),t.params.autoplay&&t.params.autoplayDisableOnInteraction&&t.autoplay.stop(),s.releaseOnEdges&&(l===t.minTranslate()||l===t.maxTranslate()))return!0}}else{const r={time:bs(),delta:Math.abs(u),direction:Math.sign(u),raw:e};c.length>=2&&c.shift();const i=c.length?c[c.length-1]:void 0;if(c.push(r),i?(r.direction!==i.direction||r.delta>i.delta||r.time>i.time+150)&&h(r):h(r),function(e){const r=t.params.mousewheel;if(e.direction<0){if(t.isEnd&&!t.params.loop&&r.releaseOnEdges)return!0}else if(t.isBeginning&&!t.params.loop&&r.releaseOnEdges)return!0;return!1}(r))return!0}return r.preventDefault?r.preventDefault():r.returnValue=!1,!1}function p(e){let r=t.el;"container"!==t.params.mousewheel.eventsTarget&&(r=document.querySelector(t.params.mousewheel.eventsTarget)),r[e]("mouseenter",d),r[e]("mouseleave",u),r[e]("wheel",f)}function m(){return t.params.cssMode?(t.wrapperEl.removeEventListener("wheel",f),!0):!t.mousewheel.enabled&&(p("addEventListener"),t.mousewheel.enabled=!0,!0)}function g(){return t.params.cssMode?(t.wrapperEl.addEventListener(event,f),!0):!!t.mousewheel.enabled&&(p("removeEventListener"),t.mousewheel.enabled=!1,!0)}i("init",()=>{!t.params.mousewheel.enabled&&t.params.cssMode&&g(),t.params.mousewheel.enabled&&m()}),i("destroy",()=>{t.params.cssMode&&m(),t.mousewheel.enabled&&g()}),Object.assign(t.mousewheel,{enable:m,disable:g})}function _a(e){let{swiper:t,extendParams:r,on:i,emit:n}=e;function s(e){let r;return e&&"string"==typeof e&&t.isElement&&(r=t.el.querySelector(e)||t.hostEl.querySelector(e),r)?r:(e&&("string"==typeof e&&(r=[...document.querySelectorAll(e)]),t.params.uniqueNavElements&&"string"==typeof e&&r&&r.length>1&&1===t.el.querySelectorAll(e).length?r=t.el.querySelector(e):r&&1===r.length&&(r=r[0])),e&&!r?e:r)}function a(e,r){const i=t.params.navigation;(e=_s(e)).forEach(e=>{e&&(e.classList[r?"add":"remove"](...i.disabledClass.split(" ")),"BUTTON"===e.tagName&&(e.disabled=r),t.params.watchOverflow&&t.enabled&&e.classList[t.isLocked?"add":"remove"](i.lockClass))})}function o(){const{nextEl:e,prevEl:r}=t.navigation;if(t.params.loop)return a(r,!1),void a(e,!1);a(r,t.isBeginning&&!t.params.rewind),a(e,t.isEnd&&!t.params.rewind)}function l(e){e.preventDefault(),(!t.isBeginning||t.params.loop||t.params.rewind)&&(t.slidePrev(),n("navigationPrev"))}function c(e){e.preventDefault(),(!t.isEnd||t.params.loop||t.params.rewind)&&(t.slideNext(),n("navigationNext"))}function d(){const e=t.params.navigation;if(t.params.navigation=function(e,t,r,i){return e.params.createElements&&Object.keys(i).forEach(n=>{if(!r[n]&&!0===r.auto){let s=Is(e.el,`.${i[n]}`)[0];s||(s=Rs("div",i[n]),s.className=i[n],e.el.append(s)),r[n]=s,t[n]=s}}),r}(t,t.originalParams.navigation,t.params.navigation,{nextEl:"swiper-button-next",prevEl:"swiper-button-prev"}),!e.nextEl&&!e.prevEl)return;let r=s(e.nextEl),i=s(e.prevEl);Object.assign(t.navigation,{nextEl:r,prevEl:i}),r=_s(r),i=_s(i);const n=(r,i)=>{r&&r.addEventListener("click","next"===i?c:l),!t.enabled&&r&&r.classList.add(...e.lockClass.split(" "))};r.forEach(e=>n(e,"next")),i.forEach(e=>n(e,"prev"))}function u(){let{nextEl:e,prevEl:r}=t.navigation;e=_s(e),r=_s(r);const i=(e,r)=>{e.removeEventListener("click","next"===r?c:l),e.classList.remove(...t.params.navigation.disabledClass.split(" "))};e.forEach(e=>i(e,"next")),r.forEach(e=>i(e,"prev"))}r({navigation:{nextEl:null,prevEl:null,hideOnClick:!1,disabledClass:"swiper-button-disabled",hiddenClass:"swiper-button-hidden",lockClass:"swiper-button-lock",navigationDisabledClass:"swiper-navigation-disabled"}}),t.navigation={nextEl:null,prevEl:null},i("init",()=>{!1===t.params.navigation.enabled?h():(d(),o())}),i("toEdge fromEdge lock unlock",()=>{o()}),i("destroy",()=>{u()}),i("enable disable",()=>{let{nextEl:e,prevEl:r}=t.navigation;e=_s(e),r=_s(r),t.enabled?o():[...e,...r].filter(e=>!!e).forEach(e=>e.classList.add(t.params.navigation.lockClass))}),i("click",(e,r)=>{let{nextEl:i,prevEl:s}=t.navigation;i=_s(i),s=_s(s);const a=r.target;let o=s.includes(a)||i.includes(a);if(t.isElement&&!o){const e=r.path||r.composedPath&&r.composedPath();e&&(o=e.find(e=>i.includes(e)||s.includes(e)))}if(t.params.navigation.hideOnClick&&!o){if(t.pagination&&t.params.pagination&&t.params.pagination.clickable&&(t.pagination.el===a||t.pagination.el.contains(a)))return;let e;i.length?e=i[0].classList.contains(t.params.navigation.hiddenClass):s.length&&(e=s[0].classList.contains(t.params.navigation.hiddenClass)),n(!0===e?"navigationShow":"navigationHide"),[...i,...s].filter(e=>!!e).forEach(e=>e.classList.toggle(t.params.navigation.hiddenClass))}});const h=()=>{t.el.classList.add(...t.params.navigation.navigationDisabledClass.split(" ")),u()};Object.assign(t.navigation,{enable:()=>{t.el.classList.remove(...t.params.navigation.navigationDisabledClass.split(" ")),d(),o()},disable:h,update:o,init:d,destroy:u})}function Oa(e){let t,r,{swiper:i,extendParams:n,on:s,emit:a,params:o}=e;i.autoplay={running:!1,paused:!1,timeLeft:0},n({autoplay:{enabled:!1,delay:3e3,waitForTransition:!0,disableOnInteraction:!1,stopOnLastSlide:!1,reverseDirection:!1,pauseOnMouseEnter:!1}});let l,c,d,u,h,f,p,m,g=o&&o.autoplay?o.autoplay.delay:3e3,v=o&&o.autoplay?o.autoplay.delay:3e3,y=(new Date).getTime();function b(e){i&&!i.destroyed&&i.wrapperEl&&e.target===i.wrapperEl&&(i.wrapperEl.removeEventListener("transitionend",b),m||e.detail&&e.detail.bySwiperTouchMove||A())}const E=()=>{if(i.destroyed||!i.autoplay.running)return;i.autoplay.paused?c=!0:c&&(v=l,c=!1);const e=i.autoplay.paused?l:y+v-(new Date).getTime();i.autoplay.timeLeft=e,a("autoplayTimeLeft",e,e/g),r=requestAnimationFrame(()=>{E()})},w=e=>{if(i.destroyed||!i.autoplay.running)return;cancelAnimationFrame(r),E();let n=void 0===e?i.params.autoplay.delay:e;g=i.params.autoplay.delay,v=i.params.autoplay.delay;const s=(()=>{let e;if(e=i.virtual&&i.params.virtual.enabled?i.slides.filter(e=>e.classList.contains("swiper-slide-active"))[0]:i.slides[i.activeIndex],!e)return;return parseInt(e.getAttribute("data-swiper-autoplay"),10)})();!Number.isNaN(s)&&s>0&&void 0===e&&(n=s,g=s,v=s),l=n;const o=i.params.speed,c=()=>{i&&!i.destroyed&&(i.params.autoplay.reverseDirection?!i.isBeginning||i.params.loop||i.params.rewind?(i.slidePrev(o,!0,!0),a("autoplay")):i.params.autoplay.stopOnLastSlide||(i.slideTo(i.slides.length-1,o,!0,!0),a("autoplay")):!i.isEnd||i.params.loop||i.params.rewind?(i.slideNext(o,!0,!0),a("autoplay")):i.params.autoplay.stopOnLastSlide||(i.slideTo(0,o,!0,!0),a("autoplay")),i.params.cssMode&&(y=(new Date).getTime(),requestAnimationFrame(()=>{w()})))};return n>0?(clearTimeout(t),t=setTimeout(()=>{c()},n)):requestAnimationFrame(()=>{c()}),n},S=()=>{y=(new Date).getTime(),i.autoplay.running=!0,w(),a("autoplayStart")},T=()=>{i.autoplay.running=!1,clearTimeout(t),cancelAnimationFrame(r),a("autoplayStop")},x=(e,r)=>{if(i.destroyed||!i.autoplay.running)return;clearTimeout(t),e||(p=!0);const n=()=>{a("autoplayPause"),i.params.autoplay.waitForTransition?i.wrapperEl.addEventListener("transitionend",b):A()};if(i.autoplay.paused=!0,r)return f&&(l=i.params.autoplay.delay),f=!1,void n();const s=l||i.params.autoplay.delay;l=s-((new Date).getTime()-y),i.isEnd&&l<0&&!i.params.loop||(l<0&&(l=0),n())},A=()=>{i.isEnd&&l<0&&!i.params.loop||i.destroyed||!i.autoplay.running||(y=(new Date).getTime(),p?(p=!1,w(l)):w(),i.autoplay.paused=!1,a("autoplayResume"))},k=()=>{if(i.destroyed||!i.autoplay.running)return;const e=ms();"hidden"===e.visibilityState&&(p=!0,x(!0)),"visible"===e.visibilityState&&A()},I=e=>{"mouse"===e.pointerType&&(p=!0,m=!0,i.animating||i.autoplay.paused||x(!0))},L=e=>{"mouse"===e.pointerType&&(m=!1,i.autoplay.paused&&A())};s("init",()=>{i.params.autoplay.enabled&&(i.params.autoplay.pauseOnMouseEnter&&(i.el.addEventListener("pointerenter",I),i.el.addEventListener("pointerleave",L)),ms().addEventListener("visibilitychange",k),S())}),s("destroy",()=>{i.el&&"string"!=typeof i.el&&(i.el.removeEventListener("pointerenter",I),i.el.removeEventListener("pointerleave",L)),ms().removeEventListener("visibilitychange",k),i.autoplay.running&&T()}),s("_freeModeStaticRelease",()=>{(u||p)&&A()}),s("_freeModeNoMomentumRelease",()=>{i.params.autoplay.disableOnInteraction?T():x(!0,!0)}),s("beforeTransitionStart",(e,t,r)=>{!i.destroyed&&i.autoplay.running&&(r||!i.params.autoplay.disableOnInteraction?x(!0,!0):T())}),s("sliderFirstMove",()=>{!i.destroyed&&i.autoplay.running&&(i.params.autoplay.disableOnInteraction?T():(d=!0,u=!1,p=!1,h=setTimeout(()=>{p=!0,u=!0,x(!0)},200)))}),s("touchEnd",()=>{if(!i.destroyed&&i.autoplay.running&&d){if(clearTimeout(h),clearTimeout(t),i.params.autoplay.disableOnInteraction)return u=!1,void(d=!1);u&&i.params.cssMode&&A(),u=!1,d=!1}}),s("slideChange",()=>{!i.destroyed&&i.autoplay.running&&(f=!0)}),Object.assign(i.autoplay,{start:S,stop:T,pause:x,resume:A})}function Ma(e){let t,r,i,n,{swiper:s,extendParams:a,on:o}=e;a({grid:{rows:1,fill:"column"}});const l=()=>{let e=s.params.spaceBetween;return"string"==typeof e&&e.indexOf("%")>=0?e=parseFloat(e.replace("%",""))/100*s.size:"string"==typeof e&&(e=parseFloat(e)),e};o("init",()=>{n=s.params.grid&&s.params.grid.rows>1}),o("update",()=>{const{params:e,el:t}=s,r=e.grid&&e.grid.rows>1;n&&!r?(t.classList.remove(`${e.containerModifierClass}grid`,`${e.containerModifierClass}grid-column`),i=1,s.emitContainerClasses()):!n&&r&&(t.classList.add(`${e.containerModifierClass}grid`),"column"===e.grid.fill&&t.classList.add(`${e.containerModifierClass}grid-column`),s.emitContainerClasses()),n=r}),s.grid={initSlides:e=>{const{slidesPerView:n}=s.params,{rows:a,fill:o}=s.params.grid,l=s.virtual&&s.params.virtual.enabled?s.virtual.slides.length:e.length;i=Math.floor(l/a),t=Math.floor(l/a)===l/a?l:Math.ceil(l/a)*a,"auto"!==n&&"row"===o&&(t=Math.max(t,n*a)),r=t/a},unsetSlides:()=>{s.slides&&s.slides.forEach(e=>{e.swiperSlideGridSet&&(e.style.height="",e.style[s.getDirectionLabel("margin-top")]="")})},updateSlide:(e,n,a)=>{const{slidesPerGroup:o}=s.params,c=l(),{rows:d,fill:u}=s.params.grid,h=s.virtual&&s.params.virtual.enabled?s.virtual.slides.length:a.length;let f,p,m;if("row"===u&&o>1){const r=Math.floor(e/(o*d)),i=e-d*o*r,s=0===r?o:Math.min(Math.ceil((h-r*d*o)/d),o);m=Math.floor(i/s),p=i-m*s+r*o,f=p+m*t/d,n.style.order=f}else"column"===u?(p=Math.floor(e/d),m=e-p*d,(p>i||p===i&&m===d-1)&&(m+=1,m>=d&&(m=0,p+=1))):(m=Math.floor(e/r),p=e-m*r);n.row=m,n.column=p,n.style.height=`calc((100% - ${(d-1)*c}px) / ${d})`,n.style[s.getDirectionLabel("margin-top")]=0!==m?c&&`${c}px`:"",n.swiperSlideGridSet=!0},updateWrapperSize:(e,r)=>{const{centeredSlides:i,roundLengths:n}=s.params,a=l(),{rows:o}=s.params.grid;if(s.virtualSize=(e+a)*t,s.virtualSize=Math.ceil(s.virtualSize/o)-a,s.params.cssMode||(s.wrapperEl.style[s.getDirectionLabel("width")]=`${s.virtualSize+a}px`),i){const e=[];for(let t=0;t<r.length;t+=1){let i=r[t];n&&(i=Math.floor(i)),r[t]<s.virtualSize+r[0]&&e.push(i)}r.splice(0,r.length),r.push(...e)}}}}function Na(e){const t=this,{params:r,slidesEl:i}=t;r.loop&&t.loopDestroy();const n=e=>{if("string"==typeof e){const t=document.createElement("div");t.innerHTML=e,i.append(t.children[0]),t.innerHTML=""}else i.append(e)};if("object"==typeof e&&"length"in e)for(let t=0;t<e.length;t+=1)e[t]&&n(e[t]);else n(e);t.recalcSlides(),r.loop&&t.loopCreate(),r.observer&&!t.isElement||t.update()}function Fa(e){const t=this,{params:r,activeIndex:i,slidesEl:n}=t;r.loop&&t.loopDestroy();let s=i+1;const a=e=>{if("string"==typeof e){const t=document.createElement("div");t.innerHTML=e,n.prepend(t.children[0]),t.innerHTML=""}else n.prepend(e)};if("object"==typeof e&&"length"in e){for(let t=0;t<e.length;t+=1)e[t]&&a(e[t]);s=i+e.length}else a(e);t.recalcSlides(),r.loop&&t.loopCreate(),r.observer&&!t.isElement||t.update(),t.slideTo(s,0,!1)}function $a(e,t){const r=this,{params:i,activeIndex:n,slidesEl:s}=r;let a=n;i.loop&&(a-=r.loopedSlides,r.loopDestroy(),r.recalcSlides());const o=r.slides.length;if(e<=0)return void r.prependSlide(t);if(e>=o)return void r.appendSlide(t);let l=a>e?a+1:a;const c=[];for(let t=o-1;t>=e;t-=1){const e=r.slides[t];e.remove(),c.unshift(e)}if("object"==typeof t&&"length"in t){for(let e=0;e<t.length;e+=1)t[e]&&s.append(t[e]);l=a>e?a+t.length:a}else s.append(t);for(let e=0;e<c.length;e+=1)s.append(c[e]);r.recalcSlides(),i.loop&&r.loopCreate(),i.observer&&!r.isElement||r.update(),i.loop?r.slideTo(l+r.loopedSlides,0,!1):r.slideTo(l,0,!1)}function Ba(e){const t=this,{params:r,activeIndex:i}=t;let n=i;r.loop&&(n-=t.loopedSlides,t.loopDestroy());let s,a=n;if("object"==typeof e&&"length"in e){for(let r=0;r<e.length;r+=1)s=e[r],t.slides[s]&&t.slides[s].remove(),s<a&&(a-=1);a=Math.max(a,0)}else s=e,t.slides[s]&&t.slides[s].remove(),s<a&&(a-=1),a=Math.max(a,0);t.recalcSlides(),r.loop&&t.loopCreate(),r.observer&&!t.isElement||t.update(),r.loop?t.slideTo(a+t.loopedSlides,0,!1):t.slideTo(a,0,!1)}function Ua(){const e=this,t=[];for(let r=0;r<e.slides.length;r+=1)t.push(r);e.removeSlide(t)}function za(e){let{swiper:t}=e;Object.assign(t,{appendSlide:Na.bind(t),prependSlide:Fa.bind(t),addSlide:$a.bind(t),removeSlide:Ba.bind(t),removeAllSlides:Ua.bind(t)})}function Ga(e,t){const r=ks(t);return r!==t&&(r.style.backfaceVisibility="hidden",r.style["-webkit-backface-visibility"]="hidden"),r}function ja(e){let{swiper:t,duration:r,transformElements:i,allSlides:n}=e;const{activeIndex:s}=t;if(t.params.virtualTranslate&&0!==r){let e,r=!1;e=n?i:i.filter(e=>{const r=e.classList.contains("swiper-slide-transform")?(e=>{if(!e.parentElement)return t.slides.filter(t=>t.shadowRoot&&t.shadowRoot===e.parentNode)[0];return e.parentElement})(e):e;return t.getSlideIndex(r)===s}),e.forEach(e=>{!function(e,t){t&&e.addEventListener("transitionend",function r(i){i.target===e&&(t.call(e,i),e.removeEventListener("transitionend",r))})}(e,()=>{if(r)return;if(!t||t.destroyed)return;r=!0,t.animating=!1;const e=new window.CustomEvent("transitionend",{bubbles:!0,cancelable:!0});t.wrapperEl.dispatchEvent(e)})})}}function Ha(e,t,r){const i=`swiper-slide-shadow swiper-slide-shadow-${e}`,n=ks(t);let s=n.querySelector(`.${i.split(" ").join(".")}`);return s||(s=Rs("div",i.split(" ")),n.append(s)),s}function Va(e){let{swiper:t,extendParams:r,on:i}=e;r({cardsEffect:{slideShadows:!0,rotate:!0,perSlideRotate:2,perSlideOffset:8}});!function(e){const{effect:t,swiper:r,on:i,setTranslate:n,setTransition:s,overwriteParams:a,perspective:o,recreateShadows:l,getEffectParams:c}=e;let d;i("beforeInit",()=>{if(r.params.effect!==t)return;r.classNames.push(`${r.params.containerModifierClass}${t}`),o&&o()&&r.classNames.push(`${r.params.containerModifierClass}3d`);const e=a?a():{};Object.assign(r.params,e),Object.assign(r.originalParams,e)}),i("setTranslate",()=>{r.params.effect===t&&n()}),i("setTransition",(e,i)=>{r.params.effect===t&&s(i)}),i("transitionEnd",()=>{if(r.params.effect===t&&l){if(!c||!c().slideShadows)return;r.slides.forEach(e=>{e.querySelectorAll(".swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left").forEach(e=>e.remove())}),l()}}),i("virtualUpdate",()=>{r.params.effect===t&&(r.slides.length||(d=!0),requestAnimationFrame(()=>{d&&r.slides&&r.slides.length&&(n(),d=!1)}))})}({effect:"cards",swiper:t,on:i,setTranslate:()=>{const{slides:e,activeIndex:r,rtlTranslate:i}=t,n=t.params.cardsEffect,{startTranslate:s,isTouched:a}=t.touchEventsData,o=i?-t.translate:t.translate;for(let l=0;l<e.length;l+=1){const c=e[l],d=c.progress,u=Math.min(Math.max(d,-4),4);let h=c.swiperSlideOffset;t.params.centeredSlides&&!t.params.cssMode&&(t.wrapperEl.style.transform=`translateX(${t.minTranslate()}px)`),t.params.centeredSlides&&t.params.cssMode&&(h-=e[0].swiperSlideOffset);let f=t.params.cssMode?-h-t.translate:-h,p=0;const m=-100*Math.abs(u);let g=1,v=-n.perSlideRotate*u,y=n.perSlideOffset-.75*Math.abs(u);const b=t.virtual&&t.params.virtual.enabled?t.virtual.from+l:l,E=(b===r||b===r-1)&&u>0&&u<1&&(a||t.params.cssMode)&&o<s,w=(b===r||b===r+1)&&u<0&&u>-1&&(a||t.params.cssMode)&&o>s;if(E||w){const e=(1-Math.abs((Math.abs(u)-.5)/.5))**.5;v+=-28*u*e,g+=-.5*e,y+=96*e,p=-25*e*Math.abs(u)+"%"}if(f=u<0?`calc(${f}px ${i?"-":"+"} (${y*Math.abs(u)}%))`:u>0?`calc(${f}px ${i?"-":"+"} (-${y*Math.abs(u)}%))`:`${f}px`,!t.isHorizontal()){const e=p;p=f,f=e}const S=u<0?""+(1+(1-g)*u):""+(1-(1-g)*u),T=`\n translate3d(${f}, ${p}, ${m}px)\n rotateZ(${n.rotate?i?-v:v:0}deg)\n scale(${S})\n `;if(n.slideShadows){let e=c.querySelector(".swiper-slide-shadow");e||(e=Ha("cards",c)),e&&(e.style.opacity=Math.min(Math.max((Math.abs(u)-.5)/.5,0),1))}c.style.zIndex=-Math.abs(Math.round(d))+e.length;Ga(0,c).style.transform=T}},setTransition:e=>{const r=t.slides.map(e=>ks(e));r.forEach(t=>{t.style.transitionDuration=`${e}ms`,t.querySelectorAll(".swiper-slide-shadow").forEach(t=>{t.style.transitionDuration=`${e}ms`})}),ja({swiper:t,duration:e,transformElements:r})},perspective:()=>!0,overwriteParams:()=>({watchSlidesProgress:!0,virtualTranslate:!t.params.cssMode})})}Ca.displayName="SwiperSlide";const Wa=({product:e,contentId:r,isPreview:i})=>{var n;const[a,o]=s(!1);return t.createElement("a",{href:null!==(n=e.linkPath)&&void 0!==n?n:void 0,"data-mgcode":e.mallProductCode,target:"_blank",rel:"noopener noreferrer",className:"apphref",onClick:t=>{r&&(i||Gt({contentProductId:e.eventProductId,contentId:r,productId:e.productId}),Mt(t.currentTarget)?t.preventDefault():e.linkPath&&(t.preventDefault(),window.open(e.linkPath,"_blank","noopener,noreferrer")))}},t.createElement("div",{className:"w-full h-full min-w-0 flex gap-2 flex-col"},t.createElement("div",{className:"mb-2 flex aspect-square w-full max-h-fit items-center justify-center overflow-hidden rounded border"},e.thumbPath&&!a?t.createElement(bi,{product:e,onError:()=>o(!0)}):t.createElement(yi,null)),t.createElement("div",{className:"justify-center flex flex-col min-w-0"},e.brand&&t.createElement("p",{className:"max-w-52 break-keep line-clamp-1 text-xs text-gray-500"},e.brand.brandName),t.createElement("p",{className:"break-keep line-clamp-2"},e.productName),t.createElement("div",{className:"break-keep"},t.createElement("span",{className:"font-semibold text-red-500"},e.discount,"%"," "),t.createElement("span",{className:"font-semibold"},Tt(e.sellingPrice,e.currency))))))},Ya=({products:e,contentId:i,isPreview:n})=>{const s=r(null);return e&&t.createElement("div",{className:"relative flex h-full w-full max-w-[830px] items-center"},e.length>3&&t.createElement("button",{"aria-label":"prev",onClick:()=>{var e;null===(e=s.current)||void 0===e||e.slidePrev()},className:"absolute left-0 top-1/2 z-10 -translate-y-1/2 cursor-pointer text-zinc-500"},t.createElement(ii,{size:32,strokeWidth:1})),t.createElement("div",{className:"w-full px-10"},t.createElement(Pa,{modules:[_a],onSwiper:e=>{s.current=e},slidesPerView:3,navigation:{prevEl:".slide__prev",nextEl:".slide__next"},spaceBetween:0},e.map(e=>t.createElement(Ca,{key:e.productId},t.createElement("div",{className:"h-full px-3 md:px-4 lg:px-5"},t.createElement(Wa,{product:e,contentId:i,isPreview:n})))))),e.length>3&&t.createElement("button",{"aria-label":"next",onClick:()=>{var e;null===(e=s.current)||void 0===e||e.slideNext()},className:"absolute right-0 top-1/2 z-10 -translate-y-1/2 cursor-pointer text-zinc-500"},t.createElement(ni,{size:32,strokeWidth:1})))},Ka=e=>{const{isPreview:r,player:i,shortform:n}=e;return t.createElement("div",{className:"flex h-full w-full gap-5 bg-white items-center"},t.createElement("div",{className:"h-full shrink-0"},i),t.createElement("div",{className:"flex h-full w-full min-w-44 max-w-[800px] items-center overflow-hidden text-sm"},t.createElement(Ya,{products:n.productsInfo,contentId:n.shortsId,isPreview:r})))},qa=({products:e,contentId:n,isPreview:a})=>{const o=r(null),l=r(null),[c,d]=s(4);return i(()=>{const e=l.current;if(!e)return;const t=()=>{const t=e.clientHeight;if(!t)return;const r=Math.max(1,Math.floor((t+12)/112));d(r)};t();const r=new ResizeObserver(()=>t());return r.observe(e),window.addEventListener("resize",t),()=>{r.disconnect(),window.removeEventListener("resize",t)}},[]),t.createElement("div",{className:"flex h-[80%] min-h-0 w-full flex-col items-center",style:{height:500}},e.length>c&&t.createElement(si,{size:50,strokeWidth:1,className:"slide__prev shrink-0 cursor-pointer text-zinc-500"}),t.createElement("div",{ref:l,className:"min-h-0 w-full max-w-full flex-1"},t.createElement(Pa,{modules:[Da,_a],mousewheel:!0,onSwiper:e=>{o.current=e},spaceBetween:12,className:"h-full min-h-0 w-full max-w-full",slidesPerView:c,direction:"vertical",navigation:{prevEl:".slide__prev",nextEl:".slide__next"}},e.map(e=>t.createElement(Ca,{key:e.productId},t.createElement("div",{className:"h-full items-center flex"},t.createElement(Ei,{product:e,contentId:n,isPreview:a})))))),e.length>c&&t.createElement(ri,{size:50,strokeWidth:1,className:"slide__next shrink-0 cursor-pointer text-zinc-500"}))},Xa=e=>{const{isPreview:r,playerSettings:i,shortform:{productsInfo:n,shortsId:s},player:a}=e;return t.createElement("div",{className:"flex h-full w-full gap-5"},t.createElement("div",{className:" h-full "},a),t.createElement("div",{className:"max-w-[800px] overflow-hidden"},t.createElement(qa,{products:n,contentId:s,isPreview:r})))},Qa=({products:e,contentId:i,isPreview:n})=>{const s=r(null),a=e.length>6;return t.createElement("div",{className:"relative flex h-full w-full max-w-[830px] items-center text-sm"},a&&t.createElement("button",{"aria-label":"prev",onClick:()=>{var e;null===(e=s.current)||void 0===e||e.slidePrev()},className:"absolute left-0 top-1/2 z-10 -translate-y-1/2 cursor-pointer text-zinc-500"},t.createElement(ii,{size:50,strokeWidth:1})),t.createElement("div",{className:"w-full px-14"},t.createElement(Pa,{onSwiper:e=>{s.current=e},slidesPerView:3,spaceBetween:20,modules:[Ma],grid:{rows:2,fill:"row"}},e.map(e=>t.createElement(Ca,{key:e.productId},t.createElement(Wa,{product:e,contentId:i,isPreview:n}))))),a&&t.createElement("button",{"aria-label":"next",onClick:()=>{var e;null===(e=s.current)||void 0===e||e.slideNext()},className:"absolute right-0 top-1/2 z-10 -translate-y-1/2 cursor-pointer text-zinc-500"},t.createElement(ni,{size:50,strokeWidth:1})))},Za=e=>{const{isPreview:r,player:i,shortform:{productsInfo:n,shortsId:s}}=e;return t.createElement("div",{className:"flex gap-4 w-full h-full min-w-[768px] items-center"},t.createElement("div",{className:"flex-1 w-full h-full flex justify-center"},i),t.createElement("div",{className:"flex-[2] w-full h-full overflow-hidden"},t.createElement(Qa,{products:n,contentId:s,isPreview:r})))},Ja="cursor-pointer text-zinc-500",eo=e=>{const{collection:i,shortform:n,setShortform:s}=e,a=r(null);return t.createElement(t.Fragment,null,i.contents.length>1&&t.createElement("div",{className:"self-center flex gap-4 flex-col"},t.createElement(si,{size:44,strokeWidth:1,className:Ja,onClick:()=>{var e;null===(e=a.current)||void 0===e||e.swiper.slidePrev()}}),t.createElement(ri,{size:44,strokeWidth:1,className:Ja,onClick:()=>{var e;null===(e=a.current)||void 0===e||e.swiper.slideNext()}})),t.createElement("div",{className:"h-full aspect-[9/16] relative"},t.createElement(Pa,{modules:[Da,za],mousewheel:!0,loop:i.contents.length>1,direction:"vertical",touchEventsTarget:"container",preventClicksPropagation:!1,preventClicks:!1,allowTouchMove:!1,slidesPerView:1.05,ref:a,className:"h-full z-10",onSlideChangeTransitionEnd:e=>{(e=>{const t=i.contents[e];t&&s(Object.assign({},t))})(e.realIndex)}},i.contents.map(e=>t.createElement(Ca,{key:e.shortsId,className:"rounded-xl overflow-hidden aspect-[9/16]"},t.createElement("div",{className:"h-[95%] mb-2"},n.shortsId===e.shortsId&&t.createElement("div",{className:"h-[95%] overflow-hidden rounded-xl absolute z-[999] w-full"},t.createElement(I,{file:xt(n.media.objectId)})),t.createElement("img",{src:Dt(e.thumbPath),alt:e.title,className:"rounded-xl w-full h-full bg-black "+(e.media.width>e.media.height?"object-contain":"object-cover")})))))))},to=()=>t.createElement("div",{className:"inline-block absolute pointer-events-none top-0 z-10 animate-float w-[24px] h-[24px]"},t.createElement(li,{className:"fill-red-500 text-transparent w-[24px] h-[24px]"})),ro=({shortsId:e,isPreview:r})=>{const n=ar(e=>e.isPreview),a=null!=r?r:n,[o,l]=s(a?123:0),[c,d]=s([]);i(()=>{a?l(123):x(void 0,void 0,void 0,function*(){try{const t=yield jt(e);l(t)}catch(e){return console.error(`Error in statistics getLikeInLive: ${e.toString()}`),0}})},[a,e]);return t.createElement("div",{className:"flex justify-center flex-col items-center relative"},t.createElement("button",{onClick:()=>x(void 0,void 0,void 0,function*(){(()=>{const e=Date.now();d(t=>[...t,e]),setTimeout(()=>{d(t=>t.filter(t=>t!==e))},2e3)})(),l(e=>e+1),a||(yield x(void 0,void 0,void 0,function*(){yield Ht(e)}))}),className:"z-[5] cursor-pointer","aria-label":"좋아요"},t.createElement("div",{className:"glass-panel flex h-10 w-10 items-center justify-center rounded-full"},t.createElement("img",{src:"https://mbus-asset.s3.ap-northeast-2.amazonaws.com/mcom-player/heart.png",width:24,height:24,className:"block h-6 w-6 object-contain",alt:"like"}))),c.map(e=>t.createElement(to,{key:e})),t.createElement("span",{className:"break-keep text-[10px]"},kt(o)))};var io,no,so={},ao={exports:{}},oo=ao.exports;function lo(){return io||(io=1,e=ao,t=ao.exports,function(r,i){var n="function",s="undefined",a="object",o="string",l="major",c="model",d="name",u="type",h="vendor",f="version",p="architecture",m="console",g="mobile",v="tablet",y="smarttv",b="wearable",E="embedded",w="Amazon",S="Apple",T="ASUS",x="BlackBerry",A="Browser",k="Chrome",I="Firefox",L="Google",R="Huawei",P="LG",C="Microsoft",D="Motorola",_="Opera",O="Samsung",M="Sharp",N="Sony",F="Xiaomi",$="Zebra",B="Facebook",U="Chromium OS",z="Mac OS",G=" Browser",j=function(e){for(var t={},r=0;r<e.length;r++)t[e[r].toUpperCase()]=e[r];return t},H=function(e,t){return typeof e===o&&-1!==V(t).indexOf(V(e))},V=function(e){return e.toLowerCase()},W=function(e,t){if(typeof e===o)return e=e.replace(/^\s\s*/,""),typeof t===s?e:e.substring(0,500)},Y=function(e,t){for(var r,s,o,l,c,d,u=0;u<t.length&&!c;){var h=t[u],f=t[u+1];for(r=s=0;r<h.length&&!c&&h[r];)if(c=h[r++].exec(e))for(o=0;o<f.length;o++)d=c[++s],typeof(l=f[o])===a&&l.length>0?2===l.length?typeof l[1]==n?this[l[0]]=l[1].call(this,d):this[l[0]]=l[1]:3===l.length?typeof l[1]!==n||l[1].exec&&l[1].test?this[l[0]]=d?d.replace(l[1],l[2]):i:this[l[0]]=d?l[1].call(this,d,l[2]):i:4===l.length&&(this[l[0]]=d?l[3].call(this,d.replace(l[1],l[2])):i):this[l]=d||i;u+=2}},K=function(e,t){for(var r in t)if(typeof t[r]===a&&t[r].length>0){for(var n=0;n<t[r].length;n++)if(H(t[r][n],e))return"?"===r?i:r}else if(H(t[r],e))return"?"===r?i:r;return t.hasOwnProperty("*")?t["*"]:e},q={ME:"4.90","NT 3.11":"NT3.51","NT 4.0":"NT4.0",2e3:"NT 5.0",XP:["NT 5.1","NT 5.2"],Vista:"NT 6.0",7:"NT 6.1",8:"NT 6.2",8.1:"NT 6.3",10:["NT 6.4","NT 10.0"],RT:"ARM"},X={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[f,[d,"Chrome"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[f,[d,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[d,f],[/opios[\/ ]+([\w\.]+)/i],[f,[d,_+" Mini"]],[/\bop(?:rg)?x\/([\w\.]+)/i],[f,[d,_+" GX"]],[/\bopr\/([\w\.]+)/i],[f,[d,_]],[/\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[\/ ]?([\w\.]+)/i],[f,[d,"Baidu"]],[/\b(?:mxbrowser|mxios|myie2)\/?([-\w\.]*)\b/i],[f,[d,"Maxthon"]],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer|sleipnir)[\/ ]?([\w\.]*)/i,/(avant|iemobile|slim(?:browser|boat|jet))[\/ ]?([\d\.]*)/i,/(?:ms|\()(ie) ([\w\.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|duckduckgo|klar|helio|(?=comodo_)?dragon)\/([-\w\.]+)/i,/(heytap|ovi|115)browser\/([\d\.]+)/i,/(weibo)__([\d\.]+)/i],[d,f],[/quark(?:pc)?\/([-\w\.]+)/i],[f,[d,"Quark"]],[/\bddg\/([\w\.]+)/i],[f,[d,"DuckDuckGo"]],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[f,[d,"UC"+A]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i,/micromessenger\/([\w\.]+)/i],[f,[d,"WeChat"]],[/konqueror\/([\w\.]+)/i],[f,[d,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[f,[d,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[f,[d,"Yandex"]],[/slbrowser\/([\w\.]+)/i],[f,[d,"Smart Lenovo "+A]],[/(avast|avg)\/([\w\.]+)/i],[[d,/(.+)/,"$1 Secure "+A],f],[/\bfocus\/([\w\.]+)/i],[f,[d,I+" Focus"]],[/\bopt\/([\w\.]+)/i],[f,[d,_+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[f,[d,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[f,[d,"Dolphin"]],[/coast\/([\w\.]+)/i],[f,[d,_+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[f,[d,"MIUI"+G]],[/fxios\/([\w\.-]+)/i],[f,[d,I]],[/\bqihoobrowser\/?([\w\.]*)/i],[f,[d,"360"]],[/\b(qq)\/([\w\.]+)/i],[[d,/(.+)/,"$1Browser"],f],[/(oculus|sailfish|huawei|vivo|pico)browser\/([\w\.]+)/i],[[d,/(.+)/,"$1"+G],f],[/samsungbrowser\/([\w\.]+)/i],[f,[d,O+" Internet"]],[/metasr[\/ ]?([\d\.]+)/i],[f,[d,"Sogou Explorer"]],[/(sogou)mo\w+\/([\d\.]+)/i],[[d,"Sogou Mobile"],f],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|2345(?=browser|chrome|explorer))\w*[\/ ]?v?([\w\.]+)/i],[d,f],[/(lbbrowser|rekonq)/i,/\[(linkedin)app\]/i],[d],[/ome\/([\w\.]+) \w* ?(iron) saf/i,/ome\/([\w\.]+).+qihu (360)[es]e/i],[f,d],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[d,B],f],[/(Klarna)\/([\w\.]+)/i,/(kakao(?:talk|story))[\/ ]([\w\.]+)/i,/(naver)\(.*?(\d+\.[\w\.]+).*\)/i,/safari (line)\/([\w\.]+)/i,/\b(line)\/([\w\.]+)\/iab/i,/(alipay)client\/([\w\.]+)/i,/(twitter)(?:and| f.+e\/([\w\.]+))/i,/(chromium|instagram|snapchat)[\/ ]([-\w\.]+)/i],[d,f],[/\bgsa\/([\w\.]+) .*safari\//i],[f,[d,"GSA"]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[f,[d,"TikTok"]],[/headlesschrome(?:\/([\w\.]+)| )/i],[f,[d,k+" Headless"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[d,k+" WebView"],f],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[f,[d,"Android "+A]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[d,f],[/version\/([\w\.\,]+) .*mobile\/\w+ (safari)/i],[f,[d,"Mobile Safari"]],[/version\/([\w(\.|\,)]+) .*(mobile ?safari|safari)/i],[f,d],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[d,[f,K,{"1.0":"/8",1.2:"/1",1.3:"/3","2.0":"/412","2.0.2":"/416","2.0.3":"/417","2.0.4":"/419","?":"/"}]],[/(webkit|khtml)\/([\w\.]+)/i],[d,f],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[d,"Netscape"],f],[/(wolvic|librewolf)\/([\w\.]+)/i],[d,f],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[f,[d,I+" Reality"]],[/ekiohf.+(flow)\/([\w\.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror)[\/ ]?([\w\.\+]+)/i,/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,/(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i,/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|obigo|mosaic|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/(links) \(([\w\.]+)/i],[d,[f,/_/g,"."]],[/(cobalt)\/([\w\.]+)/i],[d,[f,/master.|lts./,""]]],cpu:[[/(?:(amd|x(?:(?:86|64)[-_])?|wow|win)64)[;\)]/i],[[p,"amd64"]],[/(ia32(?=;))/i],[[p,V]],[/((?:i[346]|x)86)[;\)]/i],[[p,"ia32"]],[/\b(aarch64|arm(v?8e?l?|_?64))\b/i],[[p,"arm64"]],[/\b(arm(?:v[67])?ht?n?[fl]p?)\b/i],[[p,"armhf"]],[/windows (ce|mobile); ppc;/i],[[p,"arm"]],[/((?:ppc|powerpc)(?:64)?)(?: mac|;|\))/i],[[p,/ower/,"",V]],[/(sun4\w)[;\)]/i],[[p,"sparc"]],[/((?:avr32|ia64(?=;))|68k(?=\))|\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\b|pa-risc)/i],[[p,V]]],device:[[/\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i],[c,[h,O],[u,v]],[/\b((?:s[cgp]h|gt|sm)-(?![lr])\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,/samsung[- ]((?!sm-[lr])[-\w]+)/i,/sec-(sgh\w+)/i],[c,[h,O],[u,g]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i],[c,[h,S],[u,g]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[c,[h,S],[u,v]],[/(macintosh);/i],[c,[h,S]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[c,[h,M],[u,g]],[/(?:honor)([-\w ]+)[;\)]/i],[c,[h,"Honor"],[u,g]],[/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i],[c,[h,R],[u,v]],[/(?:huawei)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[c,[h,R],[u,g]],[/\b(poco[\w ]+|m2\d{3}j\d\d[a-z]{2})(?: bui|\))/i,/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,/oid[^\)]+; (m?[12][0-389][01]\w{3,6}[c-y])( bui|; wv|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite|pro)?)(?: bui|\))/i],[[c,/_/g," "],[h,F],[u,g]],[/oid[^\)]+; (2\d{4}(283|rpbf)[cgl])( bui|\))/i,/\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i],[[c,/_/g," "],[h,F],[u,v]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[c,[h,"OPPO"],[u,g]],[/\b(opd2\d{3}a?) bui/i],[c,[h,"OPPO"],[u,v]],[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[c,[h,"Vivo"],[u,g]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i],[c,[h,"Realme"],[u,g]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,/\bmot(?:orola)?[- ](\w*)/i,/((?:moto[\w\(\) ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i],[c,[h,D],[u,g]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[c,[h,D],[u,v]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[c,[h,P],[u,v]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+((?!browser|netcast|android tv)\w+)/i,/\blg-?([\d\w]+) bui/i],[c,[h,P],[u,g]],[/(ideatab[-\w ]+)/i,/lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i],[c,[h,"Lenovo"],[u,v]],[/(?:maemo|nokia).*(n900|lumia \d+)/i,/nokia[-_ ]?([-\w\.]*)/i],[[c,/_/g," "],[h,"Nokia"],[u,g]],[/(pixel c)\b/i],[c,[h,L],[u,v]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[c,[h,L],[u,g]],[/droid.+; (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i],[c,[h,N],[u,g]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[c,"Xperia Tablet"],[h,N],[u,v]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[c,[h,"OnePlus"],[u,g]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo(?!bc)\w\w)( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[c,[h,w],[u,v]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[c,/(.+)/g,"Fire Phone $1"],[h,w],[u,g]],[/(playbook);[-\w\),; ]+(rim)/i],[c,h,[u,v]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[c,[h,x],[u,g]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[c,[h,T],[u,v]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[c,[h,T],[u,g]],[/(nexus 9)/i],[c,[h,"HTC"],[u,v]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[h,[c,/_/g," "],[u,g]],[/droid [\w\.]+; ((?:8[14]9[16]|9(?:0(?:48|60|8[01])|1(?:3[27]|66)|2(?:6[69]|9[56])|466))[gqswx])\w*(\)| bui)/i],[c,[h,"TCL"],[u,v]],[/(itel) ((\w+))/i],[[h,V],c,[u,K,{tablet:["p10001l","w7001"],"*":"mobile"}]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[c,[h,"Acer"],[u,v]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[c,[h,"Meizu"],[u,g]],[/; ((?:power )?armor(?:[\w ]{0,8}))(?: bui|\))/i],[c,[h,"Ulefone"],[u,g]],[/; (energy ?\w+)(?: bui|\))/i,/; energizer ([\w ]+)(?: bui|\))/i],[c,[h,"Energizer"],[u,g]],[/; cat (b35);/i,/; (b15q?|s22 flip|s48c|s62 pro)(?: bui|\))/i],[c,[h,"Cat"],[u,g]],[/((?:new )?andromax[\w- ]+)(?: bui|\))/i],[c,[h,"Smartfren"],[u,g]],[/droid.+; (a(?:015|06[35]|142p?))/i],[c,[h,"Nothing"],[u,g]],[/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron|infinix|tecno|micromax|advan)[-_ ]?([-\w]*)/i,/; (imo) ((?!tab)[\w ]+?)(?: bui|\))/i,/(hp) ([\w ]+\w)/i,/(asus)-?(\w+)/i,/(microsoft); (lumia[\w ]+)/i,/(lenovo)[-_ ]?([-\w]+)/i,/(jolla)/i,/(oppo) ?([\w ]+) bui/i],[h,c,[u,g]],[/(imo) (tab \w+)/i,/(kobo)\s(ereader|touch)/i,/(archos) (gamepad2?)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i,/(nook)[\w ]+build\/(\w+)/i,/(dell) (strea[kpr\d ]*[\dko])/i,/(le[- ]+pan)[- ]+(\w{1,9}) bui/i,/(trinity)[- ]*(t\d{3}) bui/i,/(gigaset)[- ]+(q\w{1,9}) bui/i,/(vodafone) ([\w ]+)(?:\)| bui)/i],[h,c,[u,v]],[/(surface duo)/i],[c,[h,C],[u,v]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[c,[h,"Fairphone"],[u,g]],[/(u304aa)/i],[c,[h,"AT&T"],[u,g]],[/\bsie-(\w*)/i],[c,[h,"Siemens"],[u,g]],[/\b(rct\w+) b/i],[c,[h,"RCA"],[u,v]],[/\b(venue[\d ]{2,7}) b/i],[c,[h,"Dell"],[u,v]],[/\b(q(?:mv|ta)\w+) b/i],[c,[h,"Verizon"],[u,v]],[/\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i],[c,[h,"Barnes & Noble"],[u,v]],[/\b(tm\d{3}\w+) b/i],[c,[h,"NuVision"],[u,v]],[/\b(k88) b/i],[c,[h,"ZTE"],[u,v]],[/\b(nx\d{3}j) b/i],[c,[h,"ZTE"],[u,g]],[/\b(gen\d{3}) b.+49h/i],[c,[h,"Swiss"],[u,g]],[/\b(zur\d{3}) b/i],[c,[h,"Swiss"],[u,v]],[/\b((zeki)?tb.*\b) b/i],[c,[h,"Zeki"],[u,v]],[/\b([yr]\d{2}) b/i,/\b(dragon[- ]+touch |dt)(\w{5}) b/i],[[h,"Dragon Touch"],c,[u,v]],[/\b(ns-?\w{0,9}) b/i],[c,[h,"Insignia"],[u,v]],[/\b((nxa|next)-?\w{0,9}) b/i],[c,[h,"NextBook"],[u,v]],[/\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i],[[h,"Voice"],c,[u,g]],[/\b(lvtel\-)?(v1[12]) b/i],[[h,"LvTel"],c,[u,g]],[/\b(ph-1) /i],[c,[h,"Essential"],[u,g]],[/\b(v(100md|700na|7011|917g).*\b) b/i],[c,[h,"Envizen"],[u,v]],[/\b(trio[-\w\. ]+) b/i],[c,[h,"MachSpeed"],[u,v]],[/\btu_(1491) b/i],[c,[h,"Rotor"],[u,v]],[/(shield[\w ]+) b/i],[c,[h,"Nvidia"],[u,v]],[/(sprint) (\w+)/i],[h,c,[u,g]],[/(kin\.[onetw]{3})/i],[[c,/\./g," "],[h,C],[u,g]],[/droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[c,[h,$],[u,v]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[c,[h,$],[u,g]],[/smart-tv.+(samsung)/i],[h,[u,y]],[/hbbtv.+maple;(\d+)/i],[[c,/^/,"SmartTV"],[h,O],[u,y]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[h,P],[u,y]],[/(apple) ?tv/i],[h,[c,S+" TV"],[u,y]],[/crkey/i],[[c,k+"cast"],[h,L],[u,y]],[/droid.+aft(\w+)( bui|\))/i],[c,[h,w],[u,y]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[c,[h,M],[u,y]],[/(bravia[\w ]+)( bui|\))/i],[c,[h,N],[u,y]],[/(mitv-\w{5}) bui/i],[c,[h,F],[u,y]],[/Hbbtv.*(technisat) (.*);/i],[h,c,[u,y]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[h,W],[c,W],[u,y]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[u,y]],[/(ouya)/i,/(nintendo) ([wids3utch]+)/i],[h,c,[u,m]],[/droid.+; (shield) bui/i],[c,[h,"Nvidia"],[u,m]],[/(playstation [345portablevi]+)/i],[c,[h,N],[u,m]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[c,[h,C],[u,m]],[/\b(sm-[lr]\d\d[05][fnuw]?s?)\b/i],[c,[h,O],[u,b]],[/((pebble))app/i],[h,c,[u,b]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[c,[h,S],[u,b]],[/droid.+; (glass) \d/i],[c,[h,L],[u,b]],[/droid.+; (wt63?0{2,3})\)/i],[c,[h,$],[u,b]],[/droid.+; (glass) \d/i],[c,[h,L],[u,b]],[/(pico) (4|neo3(?: link|pro)?)/i],[h,c,[u,b]],[/; (quest( \d| pro)?)/i],[c,[h,B],[u,b]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[h,[u,E]],[/(aeobc)\b/i],[c,[h,w],[u,E]],[/droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew).+? mobile safari/i],[c,[u,g]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i],[c,[u,v]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[u,v]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[u,g]],[/(android[-\w\. ]{0,9});.+buil/i],[c,[h,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[f,[d,"EdgeHTML"]],[/(arkweb)\/([\w\.]+)/i],[d,f],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[f,[d,"Blink"]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna|servo)\/([\w\.]+)/i,/ekioh(flow)\/([\w\.]+)/i,/(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i,/(icab)[\/ ]([23]\.[\d\.]+)/i,/\b(libweb)/i],[d,f],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[f,d]],os:[[/microsoft (windows) (vista|xp)/i],[d,f],[/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i],[d,[f,K,q]],[/windows nt 6\.2; (arm)/i,/windows[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i,/(?:win(?=3|9|n)|win 9x )([nt\d\.]+)/i],[[f,K,q],[d,"Windows"]],[/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i,/(?:ios;fbsv\/|iphone.+ios[\/ ])([\d\.]+)/i,/cfnetwork\/.+darwin/i],[[f,/_/g,"."],[d,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[d,z],[f,/_/g,"."]],[/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i],[f,d],[/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish|openharmony)[-\/ ]?([\w\.]*)/i,/(blackberry)\w*\/([\w\.]*)/i,/(tizen|kaios)[\/ ]([\w\.]+)/i,/\((series40);/i],[d,f],[/\(bb(10);/i],[f,[d,x]],[/(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i],[f,[d,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[f,[d,I+" OS"]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[f,[d,"webOS"]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[f,[d,"watchOS"]],[/crkey\/([\d\.]+)/i],[f,[d,k+"cast"]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[d,U],f],[/panasonic;(viera)/i,/(netrange)mmh/i,/(nettv)\/(\d+\.[\w\.]+)/i,/(nintendo|playstation) ([wids345portablevuch]+)/i,/(xbox); +xbox ([^\);]+)/i,/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i,/(mint)[\/\(\) ]?(\w*)/i,/(mageia|vectorlinux)[; ]/i,/([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,/(hurd|linux) ?([\w\.]*)/i,/(gnu) ?([\w\.]*)/i,/\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i,/(haiku) (\w+)/i],[d,f],[/(sunos) ?([\w\.\d]*)/i],[[d,"Solaris"],f],[/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,/(aix) ((\d)(?=\.|\)| )[\w\.])*/i,/\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux|serenityos)/i,/(unix) ?([\w\.]*)/i],[d,f]]},Q=function(e,t){if(typeof e===a&&(t=e,e=i),!(this instanceof Q))return new Q(e,t).getResult();var m=typeof r!==s&&r.navigator?r.navigator:i,y=e||(m&&m.userAgent?m.userAgent:""),b=m&&m.userAgentData?m.userAgentData:i,E=t?function(e,t){var r={};for(var i in e)t[i]&&t[i].length%2==0?r[i]=t[i].concat(e[i]):r[i]=e[i];return r}(X,t):X,w=m&&m.userAgent==y;return this.getBrowser=function(){var e={};return e[d]=i,e[f]=i,Y.call(e,y,E.browser),e[l]=function(e){return typeof e===o?e.replace(/[^\d\.]/g,"").split(".")[0]:i}(e[f]),w&&m&&m.brave&&typeof m.brave.isBrave==n&&(e[d]="Brave"),e},this.getCPU=function(){var e={};return e[p]=i,Y.call(e,y,E.cpu),e},this.getDevice=function(){var e={};return e[h]=i,e[c]=i,e[u]=i,Y.call(e,y,E.device),w&&!e[u]&&b&&b.mobile&&(e[u]=g),w&&"Macintosh"==e[c]&&m&&typeof m.standalone!==s&&m.maxTouchPoints&&m.maxTouchPoints>2&&(e[c]="iPad",e[u]=v),e},this.getEngine=function(){var e={};return e[d]=i,e[f]=i,Y.call(e,y,E.engine),e},this.getOS=function(){var e={};return e[d]=i,e[f]=i,Y.call(e,y,E.os),w&&!e[d]&&b&&b.platform&&"Unknown"!=b.platform&&(e[d]=b.platform.replace(/chrome os/i,U).replace(/macos/i,z)),e},this.getResult=function(){return{ua:this.getUA(),browser:this.getBrowser(),engine:this.getEngine(),os:this.getOS(),device:this.getDevice(),cpu:this.getCPU()}},this.getUA=function(){return y},this.setUA=function(e){return y=typeof e===o&&e.length>500?W(e,500):e,this},this.setUA(y),this};Q.VERSION="1.0.40",Q.BROWSER=j([d,f,l]),Q.CPU=j([p]),Q.DEVICE=j([c,h,u,m,g,y,v,b,E]),Q.ENGINE=Q.OS=j([d,f]),e.exports&&(t=e.exports=Q),t.UAParser=Q;var Z=typeof r!==s&&(r.jQuery||r.Zepto);if(Z&&!Z.ua){var J=new Q;Z.ua=J.getResult(),Z.ua.get=function(){return J.getUA()},Z.ua.set=function(e){J.setUA(e);var t=J.getResult();for(var r in t)Z.ua[r]=t[r]}}}("object"==typeof window?window:oo)),ao.exports;var e,t}var co=function(){if(no)return so;no=1,Object.defineProperty(so,"__esModule",{value:!0});var e,r=t,i=(e=r)&&"object"==typeof e&&"default"in e?e.default:e,n=lo(),s=new n,a=s.getBrowser(),o=s.getCPU(),l=s.getDevice(),c=s.getEngine(),d=s.getOS(),u=s.getUA(),h=function(e){return s.setUA(e)},f=function(e){if(e){var t=new n(e);return{UA:t,browser:t.getBrowser(),cpu:t.getCPU(),device:t.getDevice(),engine:t.getEngine(),os:t.getOS(),ua:t.getUA(),setUserAgent:function(e){return t.setUA(e)}}}console.error("No userAgent string was provided")},p=Object.freeze({ClientUAInstance:s,browser:a,cpu:o,device:l,engine:c,os:d,ua:u,setUa:h,parseUserAgent:f});function m(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,i)}return r}function g(e){return g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},g(e)}function v(e,t,r){return t&&function(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}(e.prototype,t),e}function y(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function b(){return b=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},b.apply(this,arguments)}function E(e){return E=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},E(e)}function w(e,t){return w=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},w(e,t)}function S(e,t){if(null==e)return{};var r,i,n=function(e,t){if(null==e)return{};var r,i,n={},s=Object.keys(e);for(i=0;i<s.length;i++)r=s[i],t.indexOf(r)>=0||(n[r]=e[r]);return n}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(i=0;i<s.length;i++)r=s[i],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function T(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function x(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==r)return;var i,n,s=[],a=!0,o=!1;try{for(r=r.call(e);!(a=(i=r.next()).done)&&(s.push(i.value),!t||s.length!==t);a=!0);}catch(e){o=!0,n=e}finally{try{a||null==r.return||r.return()}finally{if(o)throw n}}return s}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return A(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return A(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function A(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}var k="mobile",I="tablet",L="smarttv",R="console",P="wearable",C="embedded",D=void 0,_={Chrome:"Chrome",Firefox:"Firefox",Opera:"Opera",Yandex:"Yandex",Safari:"Safari",InternetExplorer:"Internet Explorer",Edge:"Edge",Chromium:"Chromium",Ie:"IE",MobileSafari:"Mobile Safari",EdgeChromium:"Edge Chromium",MIUI:"MIUI Browser",SamsungBrowser:"Samsung Browser"},O={IOS:"iOS",Android:"Android",WindowsPhone:"Windows Phone",Windows:"Windows",MAC_OS:"Mac OS"},M={isMobile:!1,isTablet:!1,isBrowser:!1,isSmartTV:!1,isConsole:!1,isWearable:!1},N=function(e){return e||(arguments.length>1&&void 0!==arguments[1]?arguments[1]:"none")},F=function(){return!("undefined"==typeof window||!window.navigator&&!navigator)&&(window.navigator||navigator)},$=function(e){var t=F();return t&&t.platform&&(-1!==t.platform.indexOf(e)||"MacIntel"===t.platform&&t.maxTouchPoints>1&&!window.MSStream)},B=function(e,t,r,i){return function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?m(Object(r),!0).forEach(function(t){y(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):m(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}({},e,{vendor:N(t.vendor),model:N(t.model),os:N(r.name),osVersion:N(r.version),ua:N(i)})},U=function(e){return e.type===k},z=function(e){return e.type===I},G=function(e){var t=e.type;return t===k||t===I},j=function(e){return e.type===L},H=function(e){return e.type===D},V=function(e){return e.type===P},W=function(e){return e.type===R},Y=function(e){return e.type===C},K=function(e){var t=e.vendor;return N(t)},q=function(e){var t=e.model;return N(t)},X=function(e){var t=e.type;return N(t,"browser")},Q=function(e){return e.name===O.Android},Z=function(e){return e.name===O.Windows},J=function(e){return e.name===O.MAC_OS},ee=function(e){return e.name===O.WindowsPhone},te=function(e){return e.name===O.IOS},re=function(e){var t=e.version;return N(t)},ie=function(e){var t=e.name;return N(t)},ne=function(e){return e.name===_.Chrome},se=function(e){return e.name===_.Firefox},ae=function(e){return e.name===_.Chromium},oe=function(e){return e.name===_.Edge},le=function(e){return e.name===_.Yandex},ce=function(e){var t=e.name;return t===_.Safari||t===_.MobileSafari},de=function(e){return e.name===_.MobileSafari},ue=function(e){return e.name===_.Opera},he=function(e){var t=e.name;return t===_.InternetExplorer||t===_.Ie},fe=function(e){return e.name===_.MIUI},pe=function(e){return e.name===_.SamsungBrowser},me=function(e){var t=e.version;return N(t)},ge=function(e){var t=e.major;return N(t)},ve=function(e){var t=e.name;return N(t)},ye=function(e){var t=e.name;return N(t)},be=function(e){var t=e.version;return N(t)},Ee=function(){var e=F(),t=e&&e.userAgent&&e.userAgent.toLowerCase();return"string"==typeof t&&/electron/.test(t)},we=function(e){return"string"==typeof e&&-1!==e.indexOf("Edg/")},Se=function(){var e=F();return e&&(/iPad|iPhone|iPod/.test(e.platform)||"MacIntel"===e.platform&&e.maxTouchPoints>1)&&!window.MSStream},Te=function(){return $("iPad")},xe=function(){return $("iPhone")},Ae=function(){return $("iPod")},ke=function(e){return N(e)};function Ie(e){var t=e||p,r=t.device,i=t.browser,n=t.os,s=t.engine,a=t.ua;return{isSmartTV:j(r),isConsole:W(r),isWearable:V(r),isEmbedded:Y(r),isMobileSafari:de(i)||Te(),isChromium:ae(i),isMobile:G(r)||Te(),isMobileOnly:U(r),isTablet:z(r)||Te(),isBrowser:H(r),isDesktop:H(r),isAndroid:Q(n),isWinPhone:ee(n),isIOS:te(n)||Te(),isChrome:ne(i),isFirefox:se(i),isSafari:ce(i),isOpera:ue(i),isIE:he(i),osVersion:re(n),osName:ie(n),fullBrowserVersion:me(i),browserVersion:ge(i),browserName:ve(i),mobileVendor:K(r),mobileModel:q(r),engineName:ye(s),engineVersion:be(s),getUA:ke(a),isEdge:oe(i)||we(a),isYandex:le(i),deviceType:X(r),isIOS13:Se(),isIPad13:Te(),isIPhone13:xe(),isIPod13:Ae(),isElectron:Ee(),isEdgeChromium:we(a),isLegacyEdge:oe(i)&&!we(a),isWindows:Z(n),isMacOs:J(n),isMIUI:fe(i),isSamsungBrowser:pe(i)}}var Le=j(l),Re=W(l),Pe=V(l),Ce=Y(l),De=de(a)||Te(),_e=ae(a),Oe=G(l)||Te(),Me=U(l),Ne=z(l)||Te(),Fe=H(l),$e=H(l),Be=Q(d),Ue=ee(d),ze=te(d)||Te(),Ge=ne(a),je=se(a),He=ce(a),Ve=ue(a),We=he(a),Ye=re(d),Ke=ie(d),qe=me(a),Xe=ge(a),Qe=ve(a),Ze=K(l),Je=q(l),et=ye(c),tt=be(c),rt=ke(u),it=oe(a)||we(u),nt=le(a),st=X(l),at=Se(),ot=Te(),lt=xe(),ct=Ae(),dt=Ee(),ut=we(u),ht=oe(a)&&!we(u),ft=Z(d),pt=J(d),mt=fe(a),gt=pe(a);function vt(e){var t=e||window.navigator.userAgent;return f(t)}return so.AndroidView=function(e){var t=e.renderWithFragment,n=e.children,s=S(e,["renderWithFragment","children"]);return Be?t?i.createElement(r.Fragment,null,n):i.createElement("div",s,n):null},so.BrowserTypes=_,so.BrowserView=function(e){var t=e.renderWithFragment,n=e.children,s=S(e,["renderWithFragment","children"]);return Fe?t?i.createElement(r.Fragment,null,n):i.createElement("div",s,n):null},so.ConsoleView=function(e){var t=e.renderWithFragment,n=e.children,s=S(e,["renderWithFragment","children"]);return Re?t?i.createElement(r.Fragment,null,n):i.createElement("div",s,n):null},so.CustomView=function(e){var t=e.renderWithFragment,n=e.children;e.viewClassName,e.style;var s=e.condition,a=S(e,["renderWithFragment","children","viewClassName","style","condition"]);return s?t?i.createElement(r.Fragment,null,n):i.createElement("div",a,n):null},so.IEView=function(e){var t=e.renderWithFragment,n=e.children,s=S(e,["renderWithFragment","children"]);return We?t?i.createElement(r.Fragment,null,n):i.createElement("div",s,n):null},so.IOSView=function(e){var t=e.renderWithFragment,n=e.children,s=S(e,["renderWithFragment","children"]);return ze?t?i.createElement(r.Fragment,null,n):i.createElement("div",s,n):null},so.MobileOnlyView=function(e){var t=e.renderWithFragment,n=e.children;e.viewClassName,e.style;var s=S(e,["renderWithFragment","children","viewClassName","style"]);return Me?t?i.createElement(r.Fragment,null,n):i.createElement("div",s,n):null},so.MobileView=function(e){var t=e.renderWithFragment,n=e.children,s=S(e,["renderWithFragment","children"]);return Oe?t?i.createElement(r.Fragment,null,n):i.createElement("div",s,n):null},so.OsTypes=O,so.SmartTVView=function(e){var t=e.renderWithFragment,n=e.children,s=S(e,["renderWithFragment","children"]);return Le?t?i.createElement(r.Fragment,null,n):i.createElement("div",s,n):null},so.TabletView=function(e){var t=e.renderWithFragment,n=e.children,s=S(e,["renderWithFragment","children"]);return Ne?t?i.createElement(r.Fragment,null,n):i.createElement("div",s,n):null},so.WearableView=function(e){var t=e.renderWithFragment,n=e.children,s=S(e,["renderWithFragment","children"]);return Pe?t?i.createElement(r.Fragment,null,n):i.createElement("div",s,n):null},so.WinPhoneView=function(e){var t=e.renderWithFragment,n=e.children,s=S(e,["renderWithFragment","children"]);return Ue?t?i.createElement(r.Fragment,null,n):i.createElement("div",s,n):null},so.browserName=Qe,so.browserVersion=Xe,so.deviceDetect=function(e){var t=e?f(e):p,r=t.device,i=t.browser,n=t.engine,s=t.os,a=t.ua,o=function(e){switch(e){case k:return{isMobile:!0};case I:return{isTablet:!0};case L:return{isSmartTV:!0};case R:return{isConsole:!0};case P:return{isWearable:!0};case D:return{isBrowser:!0};case C:return{isEmbedded:!0};default:return M}}(r.type),l=o.isBrowser,c=o.isMobile,d=o.isTablet,u=o.isSmartTV,h=o.isConsole,m=o.isWearable,g=o.isEmbedded;return l?function(e,t,r,i,n){return{isBrowser:e,browserMajorVersion:N(t.major),browserFullVersion:N(t.version),browserName:N(t.name),engineName:N(r.name),engineVersion:N(r.version),osName:N(i.name),osVersion:N(i.version),userAgent:N(n)}}(l,i,n,s,a):u?function(e,t,r,i){return{isSmartTV:e,engineName:N(t.name),engineVersion:N(t.version),osName:N(r.name),osVersion:N(r.version),userAgent:N(i)}}(u,n,s,a):h?function(e,t,r,i){return{isConsole:e,engineName:N(t.name),engineVersion:N(t.version),osName:N(r.name),osVersion:N(r.version),userAgent:N(i)}}(h,n,s,a):c||d?B(o,r,s,a):m?function(e,t,r,i){return{isWearable:e,engineName:N(t.name),engineVersion:N(t.version),osName:N(r.name),osVersion:N(r.version),userAgent:N(i)}}(m,n,s,a):g?function(e,t,r,i,n){return{isEmbedded:e,vendor:N(t.vendor),model:N(t.model),engineName:N(r.name),engineVersion:N(r.version),osName:N(i.name),osVersion:N(i.version),userAgent:N(n)}}(g,r,n,s,a):void 0},so.deviceType=st,so.engineName=et,so.engineVersion=tt,so.fullBrowserVersion=qe,so.getSelectorsByUserAgent=function(e){if(e&&"string"==typeof e){var t=f(e);return Ie({device:t.device,browser:t.browser,os:t.os,engine:t.engine,ua:t.ua})}console.error("No valid user agent string was provided")},so.getUA=rt,so.isAndroid=Be,so.isBrowser=Fe,so.isChrome=Ge,so.isChromium=_e,so.isConsole=Re,so.isDesktop=$e,so.isEdge=it,so.isEdgeChromium=ut,so.isElectron=dt,so.isEmbedded=Ce,so.isFirefox=je,so.isIE=We,so.isIOS=ze,so.isIOS13=at,so.isIPad13=ot,so.isIPhone13=lt,so.isIPod13=ct,so.isLegacyEdge=ht,so.isMIUI=mt,so.isMacOs=pt,so.isMobile=Oe,so.isMobileOnly=Me,so.isMobileSafari=De,so.isOpera=Ve,so.isSafari=He,so.isSamsungBrowser=gt,so.isSmartTV=Le,so.isTablet=Ne,so.isWearable=Pe,so.isWinPhone=Ue,so.isWindows=ft,so.isYandex=nt,so.mobileModel=Je,so.mobileVendor=Ze,so.osName=Ke,so.osVersion=Ye,so.parseUserAgent=f,so.setUserAgent=function(e){return h(e)},so.useDeviceData=vt,so.useDeviceSelectors=function(e){var t=vt(e||window.navigator.userAgent);return[Ie(t),t]},so.useMobileOrientation=function(){var e=x(r.useState(function(){var e=window.innerWidth>window.innerHeight?90:0;return{isPortrait:0===e,isLandscape:90===e,orientation:0===e?"portrait":"landscape"}}),2),t=e[0],i=e[1],n=r.useCallback(function(){var e=window.innerWidth>window.innerHeight?90:0,r={isPortrait:0===e,isLandscape:90===e,orientation:0===e?"portrait":"landscape"};t.orientation!==r.orientation&&i(r)},[t.orientation]);return r.useEffect(function(){return void 0!==("undefined"==typeof window?"undefined":g(window))&&Oe&&(n(),window.addEventListener("load",n,!1),window.addEventListener("resize",n,!1)),function(){window.removeEventListener("resize",n,!1),window.removeEventListener("load",n,!1)}},[n]),t},so.withOrientationChange=function(e){return function(t){function r(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,r),(t=function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return T(e)}(this,E(r).call(this,e))).isEventListenerAdded=!1,t.handleOrientationChange=t.handleOrientationChange.bind(T(t)),t.onOrientationChange=t.onOrientationChange.bind(T(t)),t.onPageLoad=t.onPageLoad.bind(T(t)),t.state={isLandscape:!1,isPortrait:!1},t}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&w(e,t)}(r,t),v(r,[{key:"handleOrientationChange",value:function(){this.isEventListenerAdded||(this.isEventListenerAdded=!0);var e=window.innerWidth>window.innerHeight?90:0;this.setState({isPortrait:0===e,isLandscape:90===e})}},{key:"onOrientationChange",value:function(){this.handleOrientationChange()}},{key:"onPageLoad",value:function(){this.handleOrientationChange()}},{key:"componentDidMount",value:function(){void 0!==("undefined"==typeof window?"undefined":g(window))&&Oe&&(this.isEventListenerAdded?window.removeEventListener("load",this.onPageLoad,!1):(this.handleOrientationChange(),window.addEventListener("load",this.onPageLoad,!1)),window.addEventListener("resize",this.onOrientationChange,!1))}},{key:"componentWillUnmount",value:function(){window.removeEventListener("resize",this.onOrientationChange,!1)}},{key:"render",value:function(){return i.createElement(e,b({},this.props,{isLandscape:this.state.isLandscape,isPortrait:this.state.isPortrait}))}}]),r}(i.Component)},so}();function uo({message:e,duration:r=3e3,visible:n,setVisible:s}){return i(()=>{const e=setTimeout(()=>s(!1),r);return()=>clearTimeout(e)},[n]),n?t.createElement("div",{style:{position:"fixed",top:"1rem",left:"50%",transform:"translateX(-50%)",background:"rgba(0,0,0,0.8)",color:"#fff",padding:"0.75rem 1.25rem",borderRadius:"0.375rem",fontSize:"14px",zIndex:9999,boxShadow:"0 2px 10px rgba(0,0,0,0.2)"}},e):null}const ho=({shortForm:e,shareUrl:r})=>{const i=null!=r?r:window.location.href,[n,a]=s(!1);return t.createElement(t.Fragment,null,t.createElement("button",{onClick:()=>x(void 0,void 0,void 0,function*(){try{a(!0),co.isMobile&&navigator.share&&e?yield navigator.share({title:e.title,url:i}):(e=>{if(void 0!==navigator.clipboard)navigator.clipboard.writeText(e).then(()=>{});else{const t=document.createElement("textarea");t.value=e,document.body.appendChild(t),t.select(),t.setSelectionRange(0,99999);try{document.execCommand("copy")}catch(e){console.error("복사 실패",e)}t.setSelectionRange(0,0),document.body.removeChild(t)}})(i)}catch(e){console.error("Fail to copy on clipboard")}}),className:"cursor-pointer","aria-label":"공유"},t.createElement("div",{className:"glass-panel flex h-10 w-10 items-center justify-center rounded-full"},t.createElement("img",{src:"https://mbus-asset.s3.ap-northeast-2.amazonaws.com/mcom-player/share.png",alt:"share",width:24,height:24,className:"block h-6 w-6 object-contain"})),t.createElement(uo,{message:"공유 링크 복사 완료",setVisible:a,visible:n})))},fo=({product:e,contentId:r,height:i=80,onOpenProductList:n,additionalProductCount:a,isPreview:o,showPrice:l=!0})=>{var c;const{isPreview:d,priceText:u,memberOnly:h,isMemberLoggedIn:f}=ar(),p=null!=o?o:d,m=h&&!f,[g,v]=s(!1),y=t=>{if(t.stopPropagation(),n)return t.preventDefault(),void n();p||Gt({contentProductId:e.eventProductId,contentId:r,productId:e.productId});Mt(t.currentTarget)&&t.preventDefault()},b=t.createElement(t.Fragment,null,t.createElement("div",{className:"w-1/3 h-full shrink-0"},e.thumbPath&&!g?t.createElement(bi,{product:e,onError:()=>v(!0)}):t.createElement(yi,null)),t.createElement("div",{className:"flex flex-col text-left p-2 w-full justify-center"},e.brand&&t.createElement("span",{className:"break-keep line-clamp-1 text-gray-500",style:{fontSize:"10px"}},e.brand.brandName),t.createElement("div",{className:"mobile-product-name text-gray-800 text-ellipsis line-clamp-1 ",style:{fontSize:"11px"}},e.productName),l&&t.createElement("div",{className:"text-red-500 break-keep",style:{fontSize:"12px"}},m?t.createElement("span",{className:"font-semibold break-keep"},"판매가 회원 공개"):t.createElement(t.Fragment,null,u?u+" ":"할인가 ",t.createElement("span",{className:"font-semibold break-keep"},Tt(e.sellingPrice,e.currency)))))),E=Boolean(a)&&t.createElement("span",{className:"absolute -right-[5px] -top-[5px] rounded-full bg-black/65 px-1 py-0.5 text-[9px] font-semibold leading-none text-white","aria-label":`추가 상품 ${a}개`},"+",a);return n?t.createElement("button",{type:"button",style:{height:i},className:"relative flex w-full cursor-pointer items-center gap-2 border-0 bg-transparent p-0",onClickCapture:y,"aria-haspopup":"dialog"},b,E):t.createElement("a",{href:null!==(c=e.linkPath)&&void 0!==c?c:void 0,"data-mgcode":e.mallProductCode,target:"_blank",draggable:!1,rel:"noopener noreferrer",style:{height:i,textDecoration:"none",color:"inherit"},className:"apphref relative flex gap-2 items-center w-full",onClickCapture:y},b,E)},po=60,mo="15px",go=({products:e,contentId:n,height:s=80,onOpenSheet:a,isPreview:o,productBannerType:l="list",showPrice:c=!0})=>{const d=r(null),h=r(!1),f=r(null),p=r(null);i(()=>()=>{f.current&&clearTimeout(f.current)},[]);const m=u(()=>(e=>{if(!e.length)return[];if(e.length>=3)return e;const t=[...e];for(;t.length<3;)t.push(...e);return t})(e),[e]),g=1===(null==e?void 0:e.length);return(null==e?void 0:e.length)?"list"===l?t.createElement("div",{className:"mobile-product-carousel mobile-product-list w-full overflow-visible rounded-xl bg-white",style:{borderRadius:mo,height:s}},t.createElement(fo,{product:e[0],contentId:n,height:s,isPreview:o,showPrice:c,additionalProductCount:e.length>1?e.length-1:void 0,onOpenProductList:a?()=>a(e):void 0})):t.createElement("div",{ref:p,className:"mobile-product-carousel w-full",onPointerDownCapture:e=>{if(!d.current&&(f.current&&(clearTimeout(f.current),f.current=null),h.current=!1,d.current={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,maxDistance:0},"function"==typeof e.currentTarget.setPointerCapture))try{e.currentTarget.setPointerCapture(e.pointerId)}catch(e){}},onPointerMoveCapture:e=>{const t=d.current;t&&t.pointerId===e.pointerId&&(t.maxDistance=Math.max(t.maxDistance,Math.hypot(e.clientX-t.startX,e.clientY-t.startY)))},onPointerUpCapture:e=>{var t,r,i;const n=d.current;if(!n||n.pointerId!==e.pointerId)return;const s=Math.max(n.maxDistance,Math.hypot(e.clientX-n.startX,e.clientY-n.startY));if(d.current=null,"function"==typeof e.currentTarget.hasPointerCapture&&e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),s>10)return h.current=!0,void(f.current=setTimeout(()=>{h.current=!1,f.current=null},0));if(e.target.closest("a[href]"))return;const a=null!==(r=null===(t=p.current)||void 0===t?void 0:t.querySelector(".swiper-slide-active a[href]"))&&void 0!==r?r:null===(i=p.current)||void 0===i?void 0:i.querySelector("a[href]");null==a||a.click()},onPointerCancelCapture:e=>{const t=d.current;t&&t.pointerId===e.pointerId&&(d.current=null,"function"==typeof e.currentTarget.hasPointerCapture&&e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),h.current=!1,f.current&&(clearTimeout(f.current),f.current=null))},onLostPointerCapture:e=>{const t=d.current;(null==t?void 0:t.pointerId)===e.pointerId&&(d.current=null)},onClickCapture:e=>{h.current&&(e.preventDefault(),e.stopPropagation(),h.current=!1,f.current&&(clearTimeout(f.current),f.current=null))},style:{height:po}},g?t.createElement("div",{className:"mobile-single-product bg-white overflow-hidden rounded-xl w-full",style:{borderRadius:mo,height:po}},t.createElement(fo,{product:e[0],contentId:n,height:po,isPreview:o,showPrice:c})):t.createElement(Pa,{nested:!0,modules:[Va,Oa],slidesPerView:1.1,effect:"cards",autoplay:!0,loop:!0,grabCursor:!0,preventClicks:!1,preventClicksPropagation:!1,threshold:10,cardsEffect:{rotate:!1},className:"w-full",style:{height:po}},m.map((e,r)=>t.createElement(Ca,{key:r+e.productId,className:"bg-white overflow-hidden rounded-xl",style:{borderRadius:mo,height:po}},t.createElement(fo,{product:e,contentId:n,height:po,isPreview:o,showPrice:c}))))):null},vo=({product:e,productLength:r,hideMoreBadge:i=!1,contentId:n,lineClamp:s,showMoreBtn:a=!1,showPrice:o=!1,sheet:l=!1,imageSize:c,openProductPopup:d,isPreview:u})=>{var h;const f=ar(e=>e.isPreview),p=null!=u?u:f,m=t.createElement(t.Fragment,null,t.createElement("span",{className:"product-banner__clip","aria-hidden":!0},t.createElement("span",{className:"product-banner__sheen"})),t.createElement("div",{className:"relative",style:{width:l?60:null!=c?c:o?64:"40%",minWidth:l?60:null!=c?c:o?64:"40%",height:l?60:null!=c?c:o?64:void 0}},t.createElement("img",{style:{borderRadius:o||c?"7px":"8px"},className:"aspect-square object-cover w-full",src:Dt(e.thumbPath),alt:e.productName})),t.createElement("div",{style:{position:"relative",zIndex:2,minWidth:0,flex:1,paddingRight:24,display:l?"flex":void 0,flexDirection:l?"column":void 0,justifyContent:l?"center":void 0,alignSelf:l?"stretch":void 0}},t.createElement("p",{className:"product-banner__name",style:{display:"-webkit-box",WebkitLineClamp:s||2,WebkitBoxOrient:"vertical",overflow:"hidden",wordBreak:"break-word",fontWeight:400,color:"#494949"}},e.productName),o&&(l?t.createElement("p",{className:"product-banner__price"},e.discount>0&&t.createElement("span",{className:"product-banner__pct"},e.discount,"%"),t.createElement("span",{className:"product-banner__amt"},Tt(e.sellingPrice,e.currency)),e.discount>0&&e.price>e.sellingPrice&&t.createElement("span",{className:"product-banner__was"},Tt(e.price,e.currency))):t.createElement("p",{className:"product-banner__price",style:{marginTop:4,fontSize:"12px",lineHeight:1.2}},e.discount>0&&t.createElement("span",{style:{marginRight:4,color:"#ef4444",fontWeight:700}},e.discount,"%"),t.createElement("span",{style:{color:"#494949",fontWeight:700}},Tt(e.sellingPrice,e.currency))))),t.createElement("span",{className:"product-banner__arrow","aria-hidden":!0},"›"),!i&&t.createElement("span",{className:"absolute text-white",style:{top:-8,right:-8,zIndex:3,backgroundColor:"#797979",padding:"2px 6px",fontSize:"10px",lineHeight:1.3,borderRadius:"0.625rem"}},"+",r-1));return t.createElement(t.Fragment,null,i?t.createElement("a",{href:null!==(h=e.linkPath)&&void 0!==h?h:void 0,"data-mgcode":e.mallProductCode,target:"_blank",rel:"noopener noreferrer",className:`apphref product-banner ${o?"product-banner--priced ":""}${l?"product-banner--sheet":"border mbus-border"}`,style:{textDecoration:"none",color:"inherit"},onClickCapture:t=>{t.stopPropagation(),p||Gt({contentProductId:e.eventProductId,contentId:n,productId:e.productId});Mt(t.currentTarget)&&t.preventDefault()}},m):t.createElement("div",{className:`product-banner ${o?"product-banner--priced ":""}${l?"product-banner--sheet":"border mbus-border"}`},m),a&&r>1&&t.createElement("div",{onClick:d,className:" flex items-center justify-center border mbus-border cursor-pointer",style:{borderRadius:"0.625rem",padding:"10px",backgroundColor:"#f5f5f5",fontWeight:600}},"+ 더보기 (",r,")"))};function yo(){const[e,t]=s({width:window.innerWidth,height:window.innerHeight});return i(()=>{const e=()=>t({width:window.innerWidth,height:window.innerHeight});return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e}const bo=({products:e,contentId:r,singleColumn:i=!1,showPrice:n=!1,sheet:s=!1,isPreview:a})=>{const o=yo().width<430||co.isMobile;return t.createElement("div",{onWheel:e=>e.stopPropagation(),className:`grid ${s?"gap-0":"gap-2"} ${i||o?"grid-cols-1":"grid-cols-2"}`,style:{fontSize:13}},e.map(i=>t.createElement(vo,{key:i.productId,product:i,hideMoreBadge:!0,productLength:e.length,contentId:r,showPrice:n,sheet:s,isPreview:a})))},Eo=({products:e,contentId:n,showPrice:s,isPreview:a,onClose:o})=>{const l=r(null);return i(()=>{const e=l.current;if(!e)return;const t=e=>e.stopPropagation();return e.addEventListener("wheel",t,{passive:!0}),()=>e.removeEventListener("wheel",t)},[]),t.createElement(t.Fragment,null,t.createElement("div",{className:"product-sheet-backdrop","aria-hidden":!0,onClick:e=>{e.stopPropagation(),o()}}),t.createElement("section",{className:"product-sheet swiper-no-swiping","data-swiper-no-swiping":!0,onClick:e=>e.stopPropagation(),"aria-label":"상품목록"},t.createElement("div",{className:"product-sheet__handle","aria-hidden":!0}),t.createElement("header",{className:"product-sheet__header"},t.createElement("h2",null,"상품목록"),t.createElement("button",{type:"button",className:"cursor-pointer",onClick:e=>{e.stopPropagation(),o()},"aria-label":"상품목록 닫기"},t.createElement(gi,{size:20,color:"#374151"}))),t.createElement("div",{className:"product-sheet__list",ref:l},t.createElement(bo,{products:e,contentId:n,singleColumn:!0,showPrice:s,sheet:!0,isPreview:a}))))},wo="https://mbus-asset.s3.ap-northeast-2.amazonaws.com/mcom-player",So=({shortForm:e,isPopup:n,hideProductCarousel:a,hideOverlay:o,shareUrl:l,handleClose:c,productBannerHeight:d,productBannerType:u="list",like:h=!0,share:f=!0,onProductSheetOpenChange:p,trackStatistics:m=!0,isPreview:g})=>{var v,y;const[b,E]=s(!Boolean(n)),[w,S]=s(!0),[T,x]=s(null),A=r(!1),k=r(p);A.current=Boolean(T),k.current=p;const L=ar(e=>e.isPreview),R=null!=g?g:L,P=r();(null===(v=P.current)||void 0===v?void 0:v.shortsId)!==e.shortsId&&(P.current={shortsId:e.shortsId,uuid:null!==(y=e.uuid)&&void 0!==y?y:Lt()});const C=Object.assign(Object.assign({},e),{uuid:P.current.uuid}),{playtime:D}=Ft(m&&!R&&w);Jt({shortform:C,playtime:D,enabled:m&&!R}),i(()=>{(R||"slide"===u)&&x(null)},[u,R]),i(()=>{x(null)},[e.shortsId]),i(()=>{null==p||p(!!T)},[T,p]),i(()=>()=>{var e;A.current&&(null===(e=k.current)||void 0===e||e.call(k,!1))},[]);const _=()=>{E(e=>!e)},O=()=>{S(e=>!e)},{logo:M,productsInfo:N,thumbPath:F,title:$,media:B,brand:U,shortsId:z}=e,G=n?"mb-1 max-h-10 max-w-20 object-contain object-left":"mb-1 max-h-10 max-w-28 object-contain object-left",j=e=>{e.stopPropagation()},H=n?t.createElement("div",{className:"justify-self-end flex gap-2"},t.createElement("button",{className:"cursor-pointer text-white",onClick:O},t.createElement("div",{className:"glass-panel flex h-10 w-10 items-center justify-center rounded-full"},w?t.createElement(ui,{size:24}):t.createElement(hi,{size:24}))),t.createElement("button",{className:"cursor-pointer text-white",onClick:_},t.createElement("div",{className:"glass-panel flex h-10 w-10 items-center justify-center rounded-full"},t.createElement("img",{src:`${wo}/${b?"sound_off":"sound"}.png`,alt:b?"muted":"volume",width:24,height:24,className:"block h-6 w-6 object-contain"}))),c?t.createElement("button",{className:"cursor-pointer text-white",onClick:c},t.createElement("div",{className:"glass-panel flex h-10 w-10 items-center justify-center rounded-full"},t.createElement(gi,{size:24}))):null):t.createElement("div",{className:"mobile-top-controls flex flex-col gap-3 items-end"},t.createElement("button",{type:"button",className:"cursor-pointer text-white",onClick:e=>{j(e),_()},"aria-label":b?"음소거 해제":"음소거"},t.createElement("div",{className:"glass-panel flex h-10 w-10 items-center justify-center rounded-full"},t.createElement("img",{src:`${wo}/${b?"sound_off":"sound"}.png`,alt:b?"muted":"volume",width:24,height:24,className:"block h-6 w-6 object-contain"}))),c?t.createElement("button",{type:"button",className:"cursor-pointer text-white",onClick:e=>{j(e),c()},"aria-label":"닫기"},t.createElement("div",{className:"glass-panel flex h-10 w-10 items-center justify-center rounded-full"},t.createElement(gi,{size:24}))):null);return t.createElement("div",{className:"h-full w-full text-sm overflow-hidden text-white relative",onClick:n?void 0:O},t.createElement("div",{className:"mobile-player-overlay pointer-events-none absolute inset-0 z-[1] flex h-full w-full flex-col justify-between p-4 "+(o?"":"bg-gradient-to-b from-black/40 via-transparent to-black/40")},t.createElement("div",{className:"flex gap-2 justify-between pointer-events-auto",onClick:j},t.createElement("div",{className:"mobile-top-logo"},!o&&(null==M?void 0:M.thumbPath)?t.createElement("img",{className:G,src:M.thumbPath,alt:M.logoName,width:100,height:100}):null),!o&&H),t.createElement("div",{className:"h-full w-full"}),t.createElement("div",{className:"mobile-bottom-content mb-6 pointer-events-auto",onClick:j},!o&&t.createElement("div",{className:"mobile-content-summary flex justify-between items-end mb-3 gap-3"},t.createElement("div",{className:"w-full"},U&&t.createElement("div",{className:"items-center flex gap-3 mb-2"},t.createElement("div",{className:"mobile-brand-logo w-14 h-14 bg-white rounded-full border overflow-hidden shrink-0"},t.createElement("img",{src:U.thumbPath,alt:U.brandName,width:100,height:100,className:"object-contain w-full h-full"})),t.createElement("p",{className:"mb-2 text-start text-sm line-clamp-1"},null==U?void 0:U.brandName)),t.createElement("p",{className:"mobile-shortform-title text-start text-base line-clamp-2"},$)),t.createElement("div",{className:"flex flex-col gap-4 items-center"},h&&t.createElement(ro,{shortsId:z,isPreview:R}),f&&t.createElement("div",{className:"flex items-center justify-center"},t.createElement(ho,{shortForm:e,shareUrl:l})))),!a&&(null==N?void 0:N.length)>0&&t.createElement(go,{products:N,contentId:e.shortsId,height:d,productBannerType:u,isPreview:R,onOpenSheet:x}))),t.createElement(I,{file:xt(null==B?void 0:B.objectId),thumbnail:`${Dt(F)}`,mute:b,isVertical:(null==B?void 0:B.height)>(null==B?void 0:B.width),play:w}),T&&t.createElement(Eo,{products:T,contentId:z,showPrice:!0,isPreview:R,onClose:()=>x(null)}))},To="cursor-pointer text-zinc-500",xo=e=>{const{collection:i,shortform:n,setShortform:s,isPreview:a}=e,o=r(null);return t.createElement("div",{className:"flex h-full gap-2 items-center justify-center mx-auto"},t.createElement("div",{className:"flex flex-col gap-4"},t.createElement(si,{size:44,strokeWidth:1,className:To,onClick:()=>{var e;null===(e=o.current)||void 0===e||e.swiper.slidePrev()}}),t.createElement(ri,{size:44,strokeWidth:1,className:To,onClick:()=>{var e;null===(e=o.current)||void 0===e||e.swiper.slideNext()}})),t.createElement("div",{className:"h-full aspect-[9/16] max-w-fit relative"},t.createElement(Pa,{modules:[Da,za],mousewheel:!0,direction:"vertical",slidesPerView:1,ref:o,onSlideChangeTransitionEnd:e=>{(e=>{const t=i.contents[e];t&&s(Object.assign({},t))})(e.realIndex)},className:"h-full",preventClicksPropagation:!1,preventClicks:!1,noSwiping:!0,allowTouchMove:!1,loop:!0},i.contents.map(e=>t.createElement(Ca,{key:e.shortsId},t.createElement("div",{className:"flex justify-center gap-3 h-full"},n.shortsId===e.shortsId&&t.createElement("div",{className:"h-full absolute z-[999] w-full bg-white"},t.createElement(So,{shortForm:n,hideProductCarousel:!0,trackStatistics:!1,isPreview:a})),t.createElement("img",{src:Dt(e.thumbPath),alt:e.title,className:"w-full h-full bg-black "+(e.media.width>e.media.height?"object-contain":"object-cover")})))))))},Ao=()=>t.createElement("div",{className:"w-full h-full bg-black/50 absolute top-0 left-0 z-[999] flex items-center justify-center pointer-events-none"},t.createElement("div",{className:"flex flex-col gap-5 items-center justify-center"},t.createElement(ai,{size:80,strokeWidth:1.2,className:"text-white"}),t.createElement("p",{className:"text-white"},"위아래로 스와이프 해보세요"))),ko=e=>Math.max(0,Math.floor((Date.now()-e)/1e3)),Io=({collection:e,shortform:t,isPreview:n})=>{const s=r(null),a=r(null),o=r(0),l=e=>{e&&zt({contentId:e.contentId,uuid:e.uuid,type:wt.COLLECTION,userId:e.userId,playtime:ko(e.startedAt)})},c=e=>{if(!e)return;const t=ko(e.startedAt);zt({contentId:e.contentId,uuid:e.uuid,type:wt.SHORTS,userId:e.userId,playtime:t,isFinished:Boolean(e.duration&&t>=e.duration)})};i(()=>{const t=n||null==e?void 0:e.colId,r=s.current;if((null==r?void 0:r.contentId)===t)return;if(l(r),s.current=null,!e||!t)return;const i={contentId:t,uuid:Lt(),userId:e.userId,startedAt:Date.now()};s.current=i,Ut({contentId:i.contentId,uuid:i.uuid,type:wt.COLLECTION,userId:i.userId,isFirstPlay:!Pt(i.contentId)})},[null==e?void 0:e.colId,null==e?void 0:e.userId,n]),i(()=>{const e=n||null==t?void 0:t.shortsId,r=a.current;if((null==r?void 0:r.contentId)===e)return;if(c(r),a.current=null,!t||!e)return;const i={contentId:e,uuid:Lt(),userId:t.userId,startedAt:Date.now(),duration:At(t.media.duration)};a.current=i,Ut({contentId:i.contentId,uuid:i.uuid,type:wt.SHORTS,userId:i.userId,isFirstPlay:!Pt(i.contentId)})},[n,null==t?void 0:t.media.duration,null==t?void 0:t.shortsId,null==t?void 0:t.userId]),i(()=>{o.current+=1;const e=o.current;return()=>{Promise.resolve().then(()=>{o.current===e&&(l(s.current),c(a.current),s.current=null,a.current=null)})}},[])},Lo=({collection:e,playerSettings:r,isPreview:i=!1})=>{const[a,o]=s(e.contents[0]),[l,c]=s(!0);Io({collection:e,shortform:a,isPreview:i});const d=n(()=>{l&&c(!1)},[l]);return t.createElement("div",{className:"flex-1 md:flex md:justify-center w-full h-full bg-black relative",onClick:d},l&&t.createElement(Ao,null),t.createElement("div",{className:"h-full w-full"},t.createElement(Pa,{modules:[Da,za],loop:!0,mousewheel:!0,direction:"vertical",touchEventsTarget:"container",slidesPerView:1,onSlideChangeTransitionEnd:t=>{const r=e.contents[t.realIndex];o(Object.assign({},r))},className:"h-full md:aspect-[9/16] md:mx-auto"},e.contents.map(e=>t.createElement(Ca,{key:e.shortsId,className:"rounded-xl overflow-hidden"},a.shortsId===e.shortsId&&t.createElement("div",{className:"w-full h-full md:flex md:justify-center absolute z-[999]"},t.createElement(So,{shortForm:a,trackStatistics:!1,isPreview:i})),t.createElement("img",{src:Dt(e.thumbPath),alt:e.title,className:"rounded-xl w-full h-full bg-black "+(e.media.width>e.media.height?"object-contain":"object-cover")}))))))};const Ro='/*! tailwindcss v4.0.12 | MIT License | https://tailwindcss.com */@layer theme, base, components, utilities;@layer theme{:host,:root{--font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--color-red-500:oklch(0.637 0.237 25.331);--color-blue-200:oklch(0.882 0.059 254.128);--color-blue-300:oklch(0.809 0.105 251.813);--color-gray-200:oklch(0.928 0.006 264.531);--color-gray-400:oklch(0.707 0.022 261.325);--color-gray-500:oklch(0.551 0.027 264.364);--color-gray-700:oklch(0.373 0.034 259.733);--color-gray-800:oklch(0.278 0.033 256.848);--color-gray-900:oklch(0.21 0.034 264.665);--color-zinc-500:oklch(0.552 0.016 285.938);--color-zinc-700:oklch(0.37 0.013 285.805);--color-black:#000;--color-white:#fff;--spacing:0.25rem;--container-lg:32rem;--text-xs:0.75rem;--text-xs--line-height:1.33333;--text-sm:0.875rem;--text-sm--line-height:1.42857;--text-base:1rem;--text-base--line-height:1.5;--text-lg:1.125rem;--text-lg--line-height:1.55556;--text-xl:1.25rem;--text-xl--line-height:1.4;--font-weight-medium:500;--font-weight-semibold:600;--leading-tight:1.25;--ease-in:cubic-bezier(0.4,0,1,1);--ease-in-out:cubic-bezier(0.4,0,0.2,1);--animate-pulse:pulse 2s cubic-bezier(0.4,0,0.6,1) infinite;--aspect-video:16/9;--default-transition-duration:150ms;--default-transition-timing-function:cubic-bezier(0.4,0,0.2,1);--default-font-family:var(--font-sans);--default-font-feature-settings:var(--font-sans--font-feature-settings);--default-font-variation-settings:var(\n --font-sans--font-variation-settings\n );--default-mono-font-family:var(--font-mono);--default-mono-font-feature-settings:var(\n --font-mono--font-feature-settings\n );--default-mono-font-variation-settings:var(\n --font-mono--font-variation-settings\n );--animate-float:float 2s ease}}@layer base{*,::backdrop,::file-selector-button,:after,:before{border:0 solid;box-sizing:border-box;margin:0;padding:0}:host,html{-webkit-text-size-adjust:100%;font-feature-settings:var(--default-font-feature-settings,normal);-webkit-tap-highlight-color:transparent;font-family:var( --default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji" );font-variation-settings:var( --default-font-variation-settings,normal );line-height:1.5;tab-size:4}body{line-height:inherit}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-feature-settings:var( --default-mono-font-feature-settings,normal );font-family:var( --default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace );font-size:1em;font-variation-settings:var( --default-mono-font-variation-settings,normal )}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}menu,ol,ul{list-style:none}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}::file-selector-button,button,input,optgroup,select,textarea{font-feature-settings:inherit;background-color:transparent;border-radius:0;color:inherit;font:inherit;font-variation-settings:inherit;letter-spacing:inherit;opacity:1}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{color:color-mix(in oklab,currentColor 50%,transparent);opacity:1}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit,::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-hour-field,::-webkit-datetime-edit-meridiem-field,::-webkit-datetime-edit-millisecond-field,::-webkit-datetime-edit-minute-field,::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-second-field,::-webkit-datetime-edit-year-field{padding-block:0}:-moz-ui-invalid{box-shadow:none}::file-selector-button,button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer utilities{.pointer-events-auto{pointer-events:auto}.pointer-events-none{pointer-events:none}.visible{visibility:visible}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.inset-0{inset:calc(var(--spacing)*0)}.inset-x-0{inset-inline:calc(var(--spacing)*0)}.-top-\\[5px\\]{top:-5px}.top-0{top:calc(var(--spacing)*0)}.top-1\\/2{top:50%}.top-3{top:calc(var(--spacing)*3)}.top-4{top:calc(var(--spacing)*4)}.-right-\\[5px\\]{right:-5px}.right-0{right:calc(var(--spacing)*0)}.right-4{right:calc(var(--spacing)*4)}.bottom-0{bottom:calc(var(--spacing)*0)}.left-0{left:calc(var(--spacing)*0)}.left-3{left:calc(var(--spacing)*3)}.left-4{left:calc(var(--spacing)*4)}.z-10{z-index:10}.z-20{z-index:20}.z-50{z-index:50}.z-\\[1\\]{z-index:1}.z-\\[5\\]{z-index:5}.z-\\[10\\]{z-index:10}.z-\\[20\\]{z-index:20}.z-\\[999\\]{z-index:999}.container{width:100%;@media (width >= 40rem){max-width:40rem}@media (width >= 48rem){max-width:48rem}@media (width >= 64rem){max-width:64rem}@media (width >= 80rem){max-width:80rem}@media (width >= 96rem){max-width:96rem}}.mx-0{margin-inline:calc(var(--spacing)*0)}.mx-auto{margin-inline:auto}.my-0{margin-block:calc(var(--spacing)*0)}.my-2{margin-block:calc(var(--spacing)*2)}.mt-2{margin-top:calc(var(--spacing)*2)}.mt-3{margin-top:calc(var(--spacing)*3)}.mt-4{margin-top:calc(var(--spacing)*4)}.mb-1{margin-bottom:calc(var(--spacing)*1)}.mb-2{margin-bottom:calc(var(--spacing)*2)}.mb-3{margin-bottom:calc(var(--spacing)*3)}.mb-6{margin-bottom:calc(var(--spacing)*6)}.line-clamp-1{-webkit-line-clamp:1}.line-clamp-1,.line-clamp-2{-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.line-clamp-2{-webkit-line-clamp:2}.block{display:block}.contents{display:contents}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-block{display:inline-block}.table{display:table}.aspect-\\[9\\/16\\]{aspect-ratio:9/16}.aspect-square{aspect-ratio:1/1}.aspect-video{aspect-ratio:var(--aspect-video)}.size-3{height:calc(var(--spacing)*3);width:calc(var(--spacing)*3)}.size-4{height:calc(var(--spacing)*4);width:calc(var(--spacing)*4)}.h-1{height:calc(var(--spacing)*1)}.h-3\\.5{height:calc(var(--spacing)*3.5)}.h-4{height:calc(var(--spacing)*4)}.h-5{height:calc(var(--spacing)*5)}.h-6{height:calc(var(--spacing)*6)}.h-9{height:calc(var(--spacing)*9)}.h-10{height:calc(var(--spacing)*10)}.h-12{height:calc(var(--spacing)*12)}.h-14{height:calc(var(--spacing)*14)}.h-16{height:calc(var(--spacing)*16)}.h-\\[24px\\]{height:24px}.h-\\[60px\\]{height:60px}.h-\\[80\\%\\]{height:80%}.h-\\[95\\%\\]{height:95%}.h-\\[100px\\]{height:100px}.h-\\[125px\\]{height:125px}.h-\\[500px\\]{height:500px}.h-\\[600px\\]{height:600px}.h-full{height:100%}.max-h-10{max-height:calc(var(--spacing)*10)}.max-h-\\[150px\\]{max-height:150px}.max-h-\\[300px\\]{max-height:300px}.max-h-fit{max-height:fit-content}.max-h-full{max-height:100%}.min-h-0{min-height:calc(var(--spacing)*0)}.\\!w-auto{width:auto!important}.w-1\\/3{width:33.33333%}.w-4{width:calc(var(--spacing)*4)}.w-4\\/5{width:80%}.w-6{width:calc(var(--spacing)*6)}.w-9{width:calc(var(--spacing)*9)}.w-10{width:calc(var(--spacing)*10)}.w-12{width:calc(var(--spacing)*12)}.w-14{width:calc(var(--spacing)*14)}.w-16{width:calc(var(--spacing)*16)}.w-36{width:calc(var(--spacing)*36)}.w-\\[24px\\]{width:24px}.w-\\[400px\\]{width:400px}.w-\\[500px\\]{width:500px}.w-\\[1024px\\]{width:1024px}.w-full{width:100%}.max-w-20{max-width:calc(var(--spacing)*20)}.max-w-28{max-width:calc(var(--spacing)*28)}.max-w-52{max-width:calc(var(--spacing)*52)}.max-w-\\[40\\%\\]{max-width:40%}.max-w-\\[160px\\]{max-width:160px}.max-w-\\[800px\\]{max-width:800px}.max-w-\\[830px\\]{max-width:830px}.max-w-fit{max-width:fit-content}.max-w-full{max-width:100%}.max-w-lg{max-width:var(--container-lg)}.max-w-none{max-width:none}.min-w-0{min-width:calc(var(--spacing)*0)}.min-w-44{min-width:calc(var(--spacing)*44)}.min-w-\\[768px\\]{min-width:768px}.flex-1{flex:1}.flex-\\[2\\]{flex:2}.flex-shrink-0,.shrink-0{flex-shrink:0}.grow{flex-grow:1}.border-collapse{border-collapse:collapse}.-translate-y-1\\/2{--tw-translate-y:-50%}.-translate-y-1\\/2,.translate-y-0\\.5{translate:var(--tw-translate-x) var(--tw-translate-y)}.translate-y-0\\.5{--tw-translate-y:calc(var(--spacing)*0.5)}.transform{transform:var(--tw-rotate-x) var(--tw-rotate-y) var(--tw-rotate-z) var(--tw-skew-x) var(--tw-skew-y)}.animate-float{animation:var(--animate-float)}.animate-pulse{animation:var(--animate-pulse)}.cursor-default{cursor:default}.cursor-pointer{cursor:pointer}.touch-none{touch-action:none}.resize{resize:both}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-col-reverse{flex-direction:column-reverse}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-0{gap:calc(var(--spacing)*0)}.gap-1{gap:calc(var(--spacing)*1)}.gap-2{gap:calc(var(--spacing)*2)}.gap-3{gap:calc(var(--spacing)*3)}.gap-4{gap:calc(var(--spacing)*4)}.gap-5{gap:calc(var(--spacing)*5)}.gap-8{gap:calc(var(--spacing)*8)}.gap-10{gap:calc(var(--spacing)*10)}.self-center{align-self:center}.justify-self-end{justify-self:flex-end}.truncate{text-overflow:ellipsis;white-space:nowrap}.overflow-hidden,.truncate{overflow:hidden}.overflow-scroll{overflow:scroll}.overflow-visible{overflow:visible}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-\\[15px\\]{border-radius:15px}.rounded-full{border-radius:calc(infinity * 1px)}.rounded-lg{border-radius:var(--radius)}.rounded-md{border-radius:calc(var(--radius) - 2px)}.rounded-xl{border-radius:calc(var(--radius) + 4px)}.border{border-style:var(--tw-border-style);border-width:1px}.border-0{border-style:var(--tw-border-style);border-width:0}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-none{--tw-border-style:none;border-style:none}.bg-\\[\\#0ab060\\]{background-color:#0ab060}.bg-\\[\\#eeeeee\\]{background-color:#eee}.bg-\\[\\#f4f4f4\\]{background-color:#f4f4f4}.bg-\\[rgba\\(0\\,0\\,0\\,\\.3\\)\\]{background-color:rgba(0,0,0,.3)}.bg-black{background-color:var(--color-black)}.bg-black\\/40{background-color:color-mix(in oklab,var(--color-black) 40%,transparent)}.bg-black\\/50{background-color:color-mix(in oklab,var(--color-black) 50%,transparent)}.bg-black\\/65{background-color:color-mix(in oklab,var(--color-black) 65%,transparent)}.bg-blue-200{background-color:var(--color-blue-200)}.bg-blue-300{background-color:var(--color-blue-300)}.bg-gray-200{background-color:var(--color-gray-200)}.bg-transparent{background-color:transparent}.bg-white{background-color:var(--color-white)}.bg-zinc-700{background-color:var(--color-zinc-700)}.bg-gradient-to-b{--tw-gradient-position:to bottom in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.from-black\\/40{--tw-gradient-from:color-mix(in oklab,var(--color-black) 40%,transparent);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from) var(--tw-gradient-from-position),var(--tw-gradient-to) var(--tw-gradient-to-position))}.via-transparent{--tw-gradient-via:transparent;--tw-gradient-via-stops:var(--tw-gradient-position),var(--tw-gradient-from) var(--tw-gradient-from-position),var(--tw-gradient-via) var(--tw-gradient-via-position),var(--tw-gradient-to) var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-via-stops)}.to-black\\/40{--tw-gradient-to:color-mix(in oklab,var(--color-black) 40%,transparent);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from) var(--tw-gradient-from-position),var(--tw-gradient-to) var(--tw-gradient-to-position))}.fill-black{fill:var(--color-black)}.fill-red-500{fill:var(--color-red-500)}.fill-white{fill:var(--color-white)}.object-contain{object-fit:contain}.object-cover{object-fit:cover}.object-center{object-position:center}.object-left{object-position:left}.p-0{padding:calc(var(--spacing)*0)}.p-1{padding:calc(var(--spacing)*1)}.p-2{padding:calc(var(--spacing)*2)}.p-3{padding:calc(var(--spacing)*3)}.p-4{padding:calc(var(--spacing)*4)}.p-6{padding:calc(var(--spacing)*6)}.p-10{padding:calc(var(--spacing)*10)}.p-\\[3px\\]{padding:3px}.px-1{padding-inline:calc(var(--spacing)*1)}.px-2{padding-inline:calc(var(--spacing)*2)}.px-3{padding-inline:calc(var(--spacing)*3)}.px-4{padding-inline:calc(var(--spacing)*4)}.px-10{padding-inline:calc(var(--spacing)*10)}.px-14{padding-inline:calc(var(--spacing)*14)}.px-\\[24px\\]{padding-inline:24px}.py-0\\.5{padding-block:calc(var(--spacing)*.5)}.py-2{padding-block:calc(var(--spacing)*2)}.py-4{padding-block:calc(var(--spacing)*4)}.pt-0{padding-top:calc(var(--spacing)*0)}.pr-1{padding-right:calc(var(--spacing)*1)}.pb-4{padding-bottom:calc(var(--spacing)*4)}.pb-10{padding-bottom:calc(var(--spacing)*10)}.text-center{text-align:center}.text-left{text-align:left}.text-start{text-align:start}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xl{font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\\[9px\\]{font-size:9px}.text-\\[10px\\]{font-size:10px}.text-\\[12px\\]{font-size:12px}.leading-none{--tw-leading:1;line-height:1}.leading-tight{--tw-leading:var(--leading-tight);line-height:var(--leading-tight)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.break-keep{word-break:keep-all}.text-clip{text-overflow:clip}.text-ellipsis{text-overflow:ellipsis}.whitespace-nowrap{white-space:nowrap}.text-black{color:var(--color-black)}.text-gray-400{color:var(--color-gray-400)}.text-gray-500{color:var(--color-gray-500)}.text-gray-700{color:var(--color-gray-700)}.text-gray-800{color:var(--color-gray-800)}.text-gray-900{color:var(--color-gray-900)}.text-muted-foreground{color:var(--muted-foreground)}.text-red-500{color:var(--color-red-500)}.text-transparent{color:transparent}.text-white{color:var(--color-white)}.text-zinc-500{color:var(--color-zinc-500)}.line-through{text-decoration-line:line-through}.opacity-50{opacity:50%}.opacity-70{opacity:70%}.shadow,.shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,rgba(0,0,0,.1)),0 1px 2px -1px var(--tw-shadow-color,rgba(0,0,0,.1));box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-ring\\/30{--tw-ring-color:color-mix(in oklab,var(--ring) 30%,transparent)}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.blur{--tw-blur:blur(8px)}.blur,.filter{filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.transition{transition-duration:var(--tw-duration,var(--default-transition-duration));transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function))}.transition-\\[color\\,box-shadow\\]{transition-duration:var(--tw-duration,var(--default-transition-duration));transition-property:color,box-shadow;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function))}.transition-all{transition-duration:var(--tw-duration,var(--default-transition-duration));transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function))}.transition-opacity{transition-duration:var(--tw-duration,var(--default-transition-duration));transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function))}.transition-transform{transition-duration:var(--tw-duration,var(--default-transition-duration));transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function))}.duration-200{--tw-duration:200ms;transition-duration:.2s}.ease-in{--tw-ease:var(--ease-in);transition-timing-function:var(--ease-in)}.ease-in-out{--tw-ease:var(--ease-in-out);transition-timing-function:var(--ease-in-out)}.outline-none{--tw-outline-style:none;outline-style:none}.select-none{-webkit-user-select:none;user-select:none}.duration-200{animation-duration:.2s}.ease-in{animation-timing-function:cubic-bezier(.4,0,1,1)}.ease-in-out{animation-timing-function:cubic-bezier(.4,0,.2,1)}.fade-in{--tw-enter-opacity:0}.last\\:border-b-0{&:last-child{border-bottom-style:var(--tw-border-style);border-bottom-width:0}}.hover\\:underline{&:hover{@media (hover:hover){text-decoration-line:underline}}}.hover\\:opacity-100{&:hover{@media (hover:hover){opacity:100%}}}.hover\\:ring-4{&:hover{@media (hover:hover){--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(4px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentColor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}}}.focus\\:ring-2{&:focus{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentColor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}}.focus\\:ring-ring{&:focus{--tw-ring-color:var(--ring)}}.focus\\:ring-offset-2{&:focus{--tw-ring-offset-width:2px;--tw-ring-offset-shadow:var(--tw-ring-inset,) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color)}}.focus\\:ring-offset-background{&:focus{--tw-ring-offset-color:var(--background)}}.focus\\:outline-none{&:focus{--tw-outline-style:none;outline-style:none}}.focus-visible\\:border-ring{&:focus-visible{border-color:var(--ring)}}.focus-visible\\:ring-4{&:focus-visible{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(4px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentColor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}}.focus-visible\\:ring-\\[3px\\]{&:focus-visible{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(3px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentColor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}}.focus-visible\\:ring-ring\\/50{&:focus-visible{--tw-ring-color:color-mix(in oklab,var(--ring) 50%,transparent)}}.focus-visible\\:outline-hidden{&:focus-visible{--tw-outline-style:none;outline-style:none;@media (forced-colors:active){outline:2px solid transparent;outline-offset:2px}}}.disabled\\:pointer-events-none{&:disabled{pointer-events:none}}.disabled\\:opacity-50{&:disabled{opacity:50%}}.data-\\[disabled\\]\\:opacity-50{&[data-disabled]{opacity:50%}}.data-\\[orientation\\=horizontal\\]\\:h-1\\.5{&[data-orientation=horizontal]{height:calc(var(--spacing)*1.5)}}.data-\\[orientation\\=horizontal\\]\\:h-full{&[data-orientation=horizontal]{height:100%}}.data-\\[orientation\\=horizontal\\]\\:w-full{&[data-orientation=horizontal]{width:100%}}.data-\\[orientation\\=vertical\\]\\:h-full{&[data-orientation=vertical]{height:100%}}.data-\\[orientation\\=vertical\\]\\:min-h-44{&[data-orientation=vertical]{min-height:calc(var(--spacing)*44)}}.data-\\[orientation\\=vertical\\]\\:w-1\\.5{&[data-orientation=vertical]{width:calc(var(--spacing)*1.5)}}.data-\\[orientation\\=vertical\\]\\:w-auto{&[data-orientation=vertical]{width:auto}}.data-\\[orientation\\=vertical\\]\\:w-full{&[data-orientation=vertical]{width:100%}}.data-\\[orientation\\=vertical\\]\\:flex-col{&[data-orientation=vertical]{flex-direction:column}}.\\[\\&\\[data-state\\=open\\]\\>svg\\]\\:rotate-180,.lg\\:px-5,.md\\:aspect-\\[9\\/16\\],.md\\:flex,.md\\:justify-center,.md\\:mx-auto,.md\\:px-4,.sm\\:flex-row,.sm\\:justify-end,.sm\\:mx-0{&[data-state=open]>svg{rotate:180deg}}}:host,:root,body{--background:oklch(1 0 0);--foreground:oklch(0.145 0 0);--card:oklch(1 0 0);--card-foreground:oklch(0.145 0 0);--popover:oklch(1 0 0);--popover-foreground:oklch(0.145 0 0);--primary:oklch(0.205 0 0);--primary-foreground:oklch(0.985 0 0);--secondary:oklch(0.97 0 0);--secondary-foreground:oklch(0.205 0 0);--muted:oklch(0.97 0 0);--muted-foreground:oklch(0.556 0 0);--accent:oklch(0.97 0 0);--accent-foreground:oklch(0.205 0 0);--destructive:oklch(0.577 0.245 27.325);--destructive-foreground:oklch(0.577 0.245 27.325);--border:oklch(0.922 0 0);--input:oklch(0.922 0 0);--ring:oklch(0.708 0 0);--chart-1:oklch(0.646 0.222 41.116);--chart-2:oklch(0.6 0.118 184.704);--chart-3:oklch(0.398 0.07 227.392);--chart-4:oklch(0.828 0.189 84.429);--chart-5:oklch(0.769 0.188 70.08);--radius:0.625rem;--sidebar:oklch(0.985 0 0);--sidebar-foreground:oklch(0.145 0 0);--sidebar-primary:oklch(0.205 0 0);--sidebar-primary-foreground:oklch(0.985 0 0);--sidebar-accent:oklch(0.97 0 0);--sidebar-accent-foreground:oklch(0.205 0 0);--sidebar-border:oklch(0.922 0 0);--sidebar-ring:oklch(0.708 0 0);--mp-surface:#fff;--mp-surface-2:#f7f8fa;--mp-ink:#16181d;--mp-ink-2:#3d4657;--mp-muted:#8a90a0;--mp-line:#ebedf1;--mp-line-strong:#c4cad4;--mp-price:#d93025;outline:none}.dark{--background:oklch(0.145 0 0);--foreground:oklch(0.985 0 0);--card:oklch(0.145 0 0);--card-foreground:oklch(0.985 0 0);--popover:oklch(0.145 0 0);--popover-foreground:oklch(0.985 0 0);--primary:oklch(0.985 0 0);--primary-foreground:oklch(0.205 0 0);--secondary:oklch(0.269 0 0);--secondary-foreground:oklch(0.985 0 0);--muted:oklch(0.269 0 0);--muted-foreground:oklch(0.708 0 0);--accent:oklch(0.269 0 0);--accent-foreground:oklch(0.985 0 0);--destructive:oklch(0.396 0.141 25.723);--destructive-foreground:oklch(0.637 0.237 25.331);--border:oklch(0.269 0 0);--input:oklch(0.269 0 0);--ring:oklch(0.439 0 0);--chart-1:oklch(0.488 0.243 264.376);--chart-2:oklch(0.696 0.17 162.48);--chart-3:oklch(0.769 0.188 70.08);--chart-4:oklch(0.627 0.265 303.9);--chart-5:oklch(0.645 0.246 16.439);--sidebar:oklch(0.205 0 0);--sidebar-foreground:oklch(0.985 0 0);--sidebar-primary:oklch(0.488 0.243 264.376);--sidebar-primary-foreground:oklch(0.985 0 0);--sidebar-accent:oklch(0.269 0 0);--sidebar-accent-foreground:oklch(0.985 0 0);--sidebar-border:oklch(0.269 0 0);--sidebar-ring:oklch(0.439 0 0)}@layer base{*{border-color:var(--border);outline-color:color-mix(in oklab,var(--ring) 50%,transparent)}body{background-color:var(--background);color:var(--foreground)}}html.overflow-hidden{overflow:hidden}.scrollbar-hide::-webkit-scrollbar{display:none}.scrollbar-hide{-ms-overflow-style:none;scrollbar-width:none}.bg-insta{background-image:linear-gradient(to top right,#facc15,#ec4899,#9333ea)}.glass-panel{backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);background:hsla(0,0%,100%,.1);border:1px solid hsla(0,0%,100%,.1)}.floating-player--expanded-shopping .mobile-player-overlay{padding:12px}.floating-player--expanded-shopping .mobile-top-controls{gap:8px}.floating-collection-player .glass-panel,.floating-player .glass-panel{height:34px;width:34px}.floating-collection-player .glass-panel img,.floating-collection-player .glass-panel svg,.floating-player .glass-panel img,.floating-player .glass-panel svg{height:18px;width:18px}.floating-player--expanded-shopping .mobile-bottom-content{margin-bottom:0}.floating-player--expanded-shopping .mobile-content-summary{gap:8px;margin-bottom:8px}.floating-player--expanded-shopping .mobile-shortform-title{font-size:13px;line-height:1.4}.floating-collection-player .mobile-bottom-content{margin-bottom:8px}.floating-collection-player .mobile-brand-logo{height:40px;width:40px}.floating-collection-player .mobile-top-logo{margin-left:0}.floating-collection-player .mobile-shortform-title{font-size:13px;line-height:1.4}.floating-collection-player .mobile-content-summary{margin-bottom:8px}.floating-collection-player .product-banner__name{font-size:11px!important}.product-banner{align-items:center;background:#fff;border-radius:8px;cursor:pointer;display:flex;gap:8px;position:relative}.product-banner__clip{border-radius:inherit;overflow:hidden}.product-banner__clip,.product-banner__sheen{inset:0;pointer-events:none;position:absolute;z-index:1}.product-banner__sheen{background:linear-gradient(270deg,rgba(0,0,0,.1),transparent);transform:translateX(100%);transition:transform .3s ease}.product-banner:hover .product-banner__sheen{transform:translateX(0)}.product-banner__arrow{opacity:0;pointer-events:none;position:absolute;right:8px;top:50%;transform:translate(4px,-50%);transition:transform .3s ease,opacity .3s ease;z-index:2}.product-banner:hover .product-banner__arrow{opacity:1;transform:translateY(-50%)}.product-banner--sheet{align-items:center;background:transparent;border-radius:0;gap:12px;padding:11px 4px}.product-banner--sheet+.product-banner--sheet{border-top:1px solid var(--mp-line)}.product-banner--sheet .product-banner__clip{display:none}.product-banner--sheet .product-banner__arrow{color:var(--mp-line-strong);display:block;font-size:20px;opacity:.55;transform:translateY(-50%)}.product-banner--sheet .product-banner__name{color:var(--mp-ink-2);font-size:13.5px;font-weight:450;line-height:1.42}.product-banner--sheet .product-banner__price{align-items:baseline;display:flex;flex-wrap:wrap;font-variant-numeric:tabular-nums;gap:6px;margin-top:5px}.product-banner--sheet .product-banner__pct{color:var(--mp-price);font-size:13px;font-weight:700}.product-banner--sheet .product-banner__amt{color:var(--mp-ink);font-size:15px;font-weight:700;letter-spacing:-.01em}.product-banner--sheet .product-banner__was{color:var(--mp-muted);font-size:11.5px;text-decoration:line-through}.product-sheet-backdrop{background:transparent;inset:0;position:absolute;z-index:49}.product-sheet{animation:product-sheet-in .25s ease-out;background:#fff;border-radius:18px 18px 0 0;box-shadow:0 -4px 20px rgba(0,0,0,.12);display:flex;flex-direction:column;height:330px;inset:auto 0 0;max-height:82%;overflow:hidden;padding:8px 12px 16px;position:absolute;touch-action:pan-y;z-index:50}.product-sheet__handle{background:#e5e7eb;border-radius:999px;height:5px;margin:0 auto 14px;width:36px}.product-sheet__header{align-items:center;display:flex;justify-content:space-between}.product-sheet__header h2{color:#374151;font-size:14px;font-weight:700}.product-sheet__list{-webkit-overflow-scrolling:touch;flex:1 1 auto;margin-top:10px;min-height:0;overflow-y:auto;overscroll-behavior:contain;scrollbar-width:none;touch-action:pan-y}.product-sheet__list::-webkit-scrollbar{display:none}@keyframes product-sheet-in{0%{transform:translateY(100%)}to{transform:translateY(0)}}.collection-slider--carousel .collection-slider__slide{width:clamp(220px,28vw,320px)}.collection-slider__nav-layer{bottom:0;left:0;margin-inline:auto;pointer-events:none;position:absolute;right:0;top:0;z-index:20}.collection-slider__nav-layer>*{pointer-events:auto}.collection-slider__nav{align-items:center;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);background:rgba(0,0,0,.48);border:1px solid hsla(0,0%,100%,.24);border-radius:999px;color:#fff;cursor:pointer;display:flex;height:36px;justify-content:center;padding:0;position:absolute;top:50%;touch-action:manipulation;transform:translateY(-50%);transition:background-color .16s ease,transform .2s ease,opacity .2s ease;width:36px;z-index:20}.collection-slider__nav--prev{left:8px}.collection-slider__nav--next{right:8px}.collection-slider__nav.is-hidden{opacity:0;pointer-events:none}.collection-slider__nav--prev.is-hidden{transform:translateY(-50%) translateX(-6px)}.collection-slider__nav--next.is-hidden{transform:translateY(-50%) translateX(6px)}.collection-slider__nav-below{align-items:center;display:flex;gap:10px;justify-content:center;margin:14px auto 0}.collection-slider__nav-btn{align-items:center;background:var(--mp-surface);border:1px solid var(--mp-line);border-radius:999px;color:var(--mp-ink-2);cursor:pointer;display:flex;height:36px;justify-content:center;padding:0;touch-action:manipulation;transition:background-color .16s ease,border-color .16s ease,opacity .2s ease,transform .16s ease;width:36px}.collection-slider__nav-btn:hover:not(:disabled){background:var(--mp-surface-2);border-color:var(--mp-line-strong)}.collection-slider__nav-btn:active:not(:disabled){transform:scale(.94)}.collection-slider__nav-btn:focus-visible{outline:2px solid var(--mp-ink-2);outline-offset:2px}.collection-slider__nav-btn:disabled{cursor:default;opacity:.35}.collection-slider__nav:hover{background:rgba(0,0,0,.66)}.collection-slider__nav:active{transform:translateY(-50%) scale(.94)}.collection-slider__nav:focus-visible{outline:2px solid #fff;outline-offset:2px}@media (max-width:480px){.collection-slider--carousel .collection-slider__slide{width:min(78vw,280px)}.collection-slider__nav{height:34px;width:34px}}.product-dialog-container{max-height:70vh;max-width:min(82vw,500px);overflow-y:auto;width:100%}.product-dialog--list{background:var(--mp-surface);border-radius:18px;box-shadow:0 18px 48px -14px rgba(22,26,34,.28),0 2px 6px -2px rgba(22,26,34,.1)}.product-dialog--list [data-slot=dialog-title]{font-size:16px;font-weight:640;letter-spacing:-.01em}.product-dialog--list [data-slot=dialog-close]{align-items:center;background:var(--mp-surface-2);border-radius:8px;color:var(--mp-ink-2);display:flex;height:28px;justify-content:center;opacity:1;width:28px}.product-dialog-container.product-dialog--list{display:flex;flex-direction:column;overflow:hidden}.product-dialog--list .product-dialog__scroll{-webkit-overflow-scrolling:touch;-ms-overflow-style:none;flex:1 1 auto;min-height:0;overflow-y:auto;overscroll-behavior:contain;scrollbar-width:none}.product-dialog--list .product-dialog__scroll::-webkit-scrollbar{display:none}.border{border:1px solid oklch(.922 0 0)}.sc-info{align-items:center;color:inherit;cursor:pointer;display:flex;gap:11px;text-decoration:none}.sc-info--clean{margin-top:12px;min-height:56px}.sc-thumb{background:#f0f0ed;border-radius:10px;flex:none;height:54px;object-fit:cover;width:54px}.sc-stack{flex:none;height:54px;position:relative;width:58px}.sc-stack img{background:#f0f0ed;border:2px solid #fff;border-radius:9px;box-shadow:0 2px 7px rgba(0,0,0,.2);height:46px;object-fit:cover;position:absolute;width:46px}.sc-stack img:first-child{left:0;top:6px;transform:rotate(-7deg);transition:transform .3s ease}.sc-stack img:nth-child(2){left:6px;top:3px}.sc-stack img:nth-child(3){left:12px;top:0;transform:rotate(6deg);transition:transform .3s ease}.sc-glass-card:hover .sc-stack img:first-child,.sc-info:hover .sc-stack img:first-child{transform:translate(-3px,-1px) rotate(-11deg)}.sc-glass-card:hover .sc-stack img:nth-child(3),.sc-info:hover .sc-stack img:nth-child(3){transform:translate(3px,-1px) rotate(10deg)}.sc-body{flex:1;min-width:0}.sc-name{-webkit-line-clamp:2;-webkit-box-orient:vertical;color:#3f4046;display:-webkit-box;font-size:13px;font-weight:550;line-height:1.32;overflow:hidden;overflow-wrap:anywhere}.sc-price{align-items:baseline;display:flex;flex-wrap:wrap;font-size:13px;font-variant-numeric:tabular-nums;gap:6px;margin-top:3px}.sc-price .off{color:#f5391f;font-weight:700}.sc-price .amt{color:#222;font-weight:700}.sc-price .was{color:#9a9ca4;font-size:11.5px;font-weight:400;text-decoration:line-through}.sc-count{color:#8a8c92;font-size:11px}.sc-media-title-overlay{background:linear-gradient(0deg,rgba(0,0,0,.58),transparent);inset:auto 0 0;padding:28px 12px 12px;pointer-events:none;position:absolute;z-index:2}.sc-media-title{-webkit-line-clamp:2;-webkit-box-orient:vertical;color:#fff;display:-webkit-box;font-size:13px;font-weight:600;line-height:1.4;margin:0;overflow:hidden;text-shadow:0 1px 3px rgba(0,0,0,.55)}.sc-overlay{background:linear-gradient(0deg,rgba(0,0,0,.6),transparent);inset:auto 0 0 0;padding:12px;position:absolute;z-index:3}.sc-title{-webkit-line-clamp:1;-webkit-box-orient:vertical;color:#fff;display:-webkit-box;font-size:13px;font-weight:600;line-height:1.35;margin:0 0 8px;overflow:hidden;text-shadow:0 1px 3px rgba(0,0,0,.55)}.sc-glass-card{align-items:center;-webkit-backdrop-filter:blur(14px) saturate(1.2);backdrop-filter:blur(14px) saturate(1.2);background:hsla(0,0%,100%,.16);border:1px solid hsla(0,0%,100%,.28);border-radius:12px;box-shadow:0 8px 22px rgba(0,0,0,.26);cursor:pointer;display:flex;gap:10px;padding:9px;text-decoration:none}.sc-glass-card .sc-thumb{border-radius:8px;height:42px;width:42px}.sc-glass-card .sc-stack{height:44px;width:50px}.sc-glass-card .sc-stack img{border-color:hsla(0,0%,100%,.65);height:38px;width:38px}.sc-glass-card .sc-name{-webkit-line-clamp:2;color:#fff;font-size:12px;font-weight:600;text-shadow:0 1px 2px rgba(0,0,0,.4)}.sc-glass-card .sc-count{color:hsla(0,0%,100%,.75);margin-left:2px;white-space:nowrap}.sc-glass-card .sc-name--measure{-webkit-line-clamp:unset;display:block;left:-10000px;overflow:visible;pointer-events:none;position:fixed;top:0;visibility:hidden}.sc-glass-card .sc-price .amt{color:#fff}.sc-glass-card .sc-price .off{color:#ffd7cf}.sc-glass-card .sc-price .was{color:hsla(0,0%,100%,.7)}@media (max-width:480px){.sc-overlay{padding:8px}.sc-glass-card{-webkit-backdrop-filter:blur(10px) saturate(1.2);backdrop-filter:blur(10px) saturate(1.2);border:0;box-shadow:none;gap:8px;padding:7px}.sc-glass-card .sc-thumb{height:36px;width:36px}.sc-glass-card .sc-name{font-size:11px}}@media (prefers-reduced-motion:reduce){.collection-slider__nav,.collection-slider__nav-btn,.sc-stack img{transition:none}}@font-face{font-family:swiper-icons;font-style:normal;font-weight:400;src:url("data:application/font-woff;charset=utf-8;base64, d09GRgABAAAAAAZgABAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABGRlRNAAAGRAAAABoAAAAci6qHkUdERUYAAAWgAAAAIwAAACQAYABXR1BPUwAABhQAAAAuAAAANuAY7+xHU1VCAAAFxAAAAFAAAABm2fPczU9TLzIAAAHcAAAASgAAAGBP9V5RY21hcAAAAkQAAACIAAABYt6F0cBjdnQgAAACzAAAAAQAAAAEABEBRGdhc3AAAAWYAAAACAAAAAj//wADZ2x5ZgAAAywAAADMAAAD2MHtryVoZWFkAAABbAAAADAAAAA2E2+eoWhoZWEAAAGcAAAAHwAAACQC9gDzaG10eAAAAigAAAAZAAAArgJkABFsb2NhAAAC0AAAAFoAAABaFQAUGG1heHAAAAG8AAAAHwAAACAAcABAbmFtZQAAA/gAAAE5AAACXvFdBwlwb3N0AAAFNAAAAGIAAACE5s74hXjaY2BkYGAAYpf5Hu/j+W2+MnAzMYDAzaX6QjD6/4//Bxj5GA8AuRwMYGkAPywL13jaY2BkYGA88P8Agx4j+/8fQDYfA1AEBWgDAIB2BOoAeNpjYGRgYNBh4GdgYgABEMnIABJzYNADCQAACWgAsQB42mNgYfzCOIGBlYGB0YcxjYGBwR1Kf2WQZGhhYGBiYGVmgAFGBiQQkOaawtDAoMBQxXjg/wEGPcYDDA4wNUA2CCgwsAAAO4EL6gAAeNpj2M0gyAACqxgGNWBkZ2D4/wMA+xkDdgAAAHjaY2BgYGaAYBkGRgYQiAHyGMF8FgYHIM3DwMHABGQrMOgyWDLEM1T9/w8UBfEMgLzE////P/5//f/V/xv+r4eaAAeMbAxwIUYmIMHEgKYAYjUcsDAwsLKxc3BycfPw8jEQA/gZBASFhEVExcQlJKWkZWTl5BUUlZRVVNXUNTQZBgMAAMR+E+gAEQFEAAAAKgAqACoANAA+AEgAUgBcAGYAcAB6AIQAjgCYAKIArAC2AMAAygDUAN4A6ADyAPwBBgEQARoBJAEuATgBQgFMAVYBYAFqAXQBfgGIAZIBnAGmAbIBzgHsAAB42u2NMQ6CUAyGW568x9AneYYgm4MJbhKFaExIOAVX8ApewSt4Bic4AfeAid3VOBixDxfPYEza5O+Xfi04YADggiUIULCuEJK8VhO4bSvpdnktHI5QCYtdi2sl8ZnXaHlqUrNKzdKcT8cjlq+rwZSvIVczNiezsfnP/uznmfPFBNODM2K7MTQ45YEAZqGP81AmGGcF3iPqOop0r1SPTaTbVkfUe4HXj97wYE+yNwWYxwWu4v1ugWHgo3S1XdZEVqWM7ET0cfnLGxWfkgR42o2PvWrDMBSFj/IHLaF0zKjRgdiVMwScNRAoWUoH78Y2icB/yIY09An6AH2Bdu/UB+yxopYshQiEvnvu0dURgDt8QeC8PDw7Fpji3fEA4z/PEJ6YOB5hKh4dj3EvXhxPqH/SKUY3rJ7srZ4FZnh1PMAtPhwP6fl2PMJMPDgeQ4rY8YT6Gzao0eAEA409DuggmTnFnOcSCiEiLMgxCiTI6Cq5DZUd3Qmp10vO0LaLTd2cjN4fOumlc7lUYbSQcZFkutRG7g6JKZKy0RmdLY680CDnEJ+UMkpFFe1RN7nxdVpXrC4aTtnaurOnYercZg2YVmLN/d/gczfEimrE/fs/bOuq29Zmn8tloORaXgZgGa78yO9/cnXm2BpaGvq25Dv9S4E9+5SIc9PqupJKhYFSSl47+Qcr1mYNAAAAeNptw0cKwkAAAMDZJA8Q7OUJvkLsPfZ6zFVERPy8qHh2YER+3i/BP83vIBLLySsoKimrqKqpa2hp6+jq6RsYGhmbmJqZSy0sraxtbO3sHRydnEMU4uR6yx7JJXveP7WrDycAAAAAAAH//wACeNpjYGRgYOABYhkgZgJCZgZNBkYGLQZtIJsFLMYAAAw3ALgAeNolizEKgDAQBCchRbC2sFER0YD6qVQiBCv/H9ezGI6Z5XBAw8CBK/m5iQQVauVbXLnOrMZv2oLdKFa8Pjuru2hJzGabmOSLzNMzvutpB3N42mNgZGBg4GKQYzBhYMxJLMlj4GBgAYow/P/PAJJhLM6sSoWKfWCAAwDAjgbRAAB42mNgYGBkAIIbCZo5IPrmUn0hGA0AO8EFTQAA")}:root{--swiper-theme-color:#007aff}:host{display:block;margin-left:auto;margin-right:auto;position:relative;z-index:1}.swiper{display:block;list-style:none;margin-left:auto;margin-right:auto;overflow:hidden;padding:0;position:relative;z-index:1}.swiper-vertical>.swiper-wrapper{flex-direction:column}.swiper-wrapper{box-sizing:content-box;display:flex;height:100%;position:relative;transition-property:transform;transition-timing-function:var(--swiper-wrapper-transition-timing-function,initial);width:100%;z-index:1}.swiper-android .swiper-slide,.swiper-ios .swiper-slide,.swiper-wrapper{transform:translateZ(0)}.swiper-horizontal{touch-action:pan-y}.swiper-vertical{touch-action:pan-x}.swiper-slide{display:block;flex-shrink:0;height:100%;position:relative;transition-property:transform;width:100%}.swiper-slide-invisible-blank{visibility:hidden}.swiper-autoheight,.swiper-autoheight .swiper-slide{height:auto}.swiper-autoheight .swiper-wrapper{align-items:flex-start;transition-property:transform,height}.swiper-backface-hidden .swiper-slide{-webkit-backface-visibility:hidden;backface-visibility:hidden;transform:translateZ(0)}.swiper-3d.swiper-css-mode .swiper-wrapper{perspective:1200px}.swiper-3d .swiper-wrapper{transform-style:preserve-3d}.swiper-3d{perspective:1200px}.swiper-3d .swiper-cube-shadow,.swiper-3d .swiper-slide{transform-style:preserve-3d}.swiper-css-mode>.swiper-wrapper{-ms-overflow-style:none;overflow:auto;scrollbar-width:none}.swiper-css-mode>.swiper-wrapper::-webkit-scrollbar{display:none}.swiper-css-mode>.swiper-wrapper>.swiper-slide{scroll-snap-align:start start}.swiper-css-mode.swiper-horizontal>.swiper-wrapper{scroll-snap-type:x mandatory}.swiper-css-mode.swiper-vertical>.swiper-wrapper{scroll-snap-type:y mandatory}.swiper-css-mode.swiper-free-mode>.swiper-wrapper{scroll-snap-type:none}.swiper-css-mode.swiper-free-mode>.swiper-wrapper>.swiper-slide{scroll-snap-align:none}.swiper-css-mode.swiper-centered>.swiper-wrapper:before{content:"";flex-shrink:0;order:9999}.swiper-css-mode.swiper-centered>.swiper-wrapper>.swiper-slide{scroll-snap-align:center center;scroll-snap-stop:always}.swiper-css-mode.swiper-centered.swiper-horizontal>.swiper-wrapper>.swiper-slide:first-child{margin-inline-start:var(--swiper-centered-offset-before)}.swiper-css-mode.swiper-centered.swiper-horizontal>.swiper-wrapper:before{height:100%;min-height:1px;width:var(--swiper-centered-offset-after)}.swiper-css-mode.swiper-centered.swiper-vertical>.swiper-wrapper>.swiper-slide:first-child{margin-block-start:var(--swiper-centered-offset-before)}.swiper-css-mode.swiper-centered.swiper-vertical>.swiper-wrapper:before{height:var(--swiper-centered-offset-after);min-width:1px;width:100%}.swiper-3d .swiper-slide-shadow,.swiper-3d .swiper-slide-shadow-bottom,.swiper-3d .swiper-slide-shadow-left,.swiper-3d .swiper-slide-shadow-right,.swiper-3d .swiper-slide-shadow-top{height:100%;left:0;pointer-events:none;position:absolute;top:0;width:100%;z-index:10}.swiper-3d .swiper-slide-shadow{background:rgba(0,0,0,.15)}.swiper-3d .swiper-slide-shadow-left{background-image:linear-gradient(270deg,rgba(0,0,0,.5),transparent)}.swiper-3d .swiper-slide-shadow-right{background-image:linear-gradient(90deg,rgba(0,0,0,.5),transparent)}.swiper-3d .swiper-slide-shadow-top{background-image:linear-gradient(0deg,rgba(0,0,0,.5),transparent)}.swiper-3d .swiper-slide-shadow-bottom{background-image:linear-gradient(180deg,rgba(0,0,0,.5),transparent)}.swiper-lazy-preloader{border:4px solid var(--swiper-preloader-color,var(--swiper-theme-color));border-radius:50%;border-top:4px solid transparent;box-sizing:border-box;height:42px;left:50%;margin-left:-21px;margin-top:-21px;position:absolute;top:50%;transform-origin:50%;width:42px;z-index:10}.swiper-watch-progress .swiper-slide-visible .swiper-lazy-preloader,.swiper:not(.swiper-watch-progress) .swiper-lazy-preloader{animation:swiper-preloader-spin 1s linear infinite}.swiper-lazy-preloader-white{--swiper-preloader-color:#fff}.swiper-lazy-preloader-black{--swiper-preloader-color:#000}@keyframes swiper-preloader-spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}.swiper.swiper-cards{overflow:visible}.swiper-cards .swiper-slide{-webkit-backface-visibility:hidden;backface-visibility:hidden;overflow:hidden;transform-origin:center bottom}.swiper-grid>.swiper-wrapper{flex-wrap:wrap}.swiper-grid-column>.swiper-wrapper{flex-direction:column;flex-wrap:wrap}@keyframes enter{0%{opacity:var(--tw-enter-opacity,1);transform:translate3d(var(--tw-enter-translate-x,0),var(--tw-enter-translate-y,0),0) scale3d(var(--tw-enter-scale,1),var(--tw-enter-scale,1),var(--tw-enter-scale,1)) rotate(var(--tw-enter-rotate,0))}}@keyframes exit{to{opacity:var(--tw-exit-opacity,1);transform:translate3d(var(--tw-exit-translate-x,0),var(--tw-exit-translate-y,0),0) scale3d(var(--tw-exit-scale,1),var(--tw-exit-scale,1),var(--tw-exit-scale,1)) rotate(var(--tw-exit-rotate,0))}}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-rotate-x{syntax:"*";inherits:false;initial-value:rotateX(0)}@property --tw-rotate-y{syntax:"*";inherits:false;initial-value:rotateY(0)}@property --tw-rotate-z{syntax:"*";inherits:false;initial-value:rotateZ(0)}@property --tw-skew-x{syntax:"*";inherits:false;initial-value:skewX(0)}@property --tw-skew-y{syntax:"*";inherits:false;initial-value:skewY(0)}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-gradient-position{syntax:"*";inherits:false}@property --tw-gradient-from{syntax:"<color>";inherits:false;initial-value:#0000}@property --tw-gradient-via{syntax:"<color>";inherits:false;initial-value:#0000}@property --tw-gradient-to{syntax:"<color>";inherits:false;initial-value:#0000}@property --tw-gradient-stops{syntax:"*";inherits:false}@property --tw-gradient-via-stops{syntax:"*";inherits:false}@property --tw-gradient-from-position{syntax:"<length-percentage>";inherits:false;initial-value:0}@property --tw-gradient-via-position{syntax:"<length-percentage>";inherits:false;initial-value:50%}@property --tw-gradient-to-position{syntax:"<length-percentage>";inherits:false;initial-value:100%}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@property --tw-ease{syntax:"*";inherits:false}@keyframes pulse{50%{opacity:.5}}@keyframes float{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(-200px)}}',Po=Ro.trim().length>0,Co="undefined"!=typeof window&&"adoptedStyleSheets"in Document.prototype&&"undefined"!=typeof CSSStyleSheet&&"replaceSync"in CSSStyleSheet.prototype;let Do=null;function _o(e){return Do||(Do=new CSSStyleSheet,Do.replaceSync(e)),Do}const Oo="data-mc-player-tw-properties";let Mo=!1;function No(){const e=Po?Ro:function(){const e=[];for(const t of Array.from(document.styleSheets))try{e.push(Array.from(t.cssRules).map(e=>e.cssText).join("\n"))}catch(e){}return e.join("\n")}();return function(e){if(Mo||"undefined"==typeof document)return;if(Mo=!0,document.head.querySelector(`[${Oo}]`))return;const t=e.match(/@property\s+--[\w-]+\s*\{[^}]*\}/g);if(!(null==t?void 0:t.length))return;const r=document.createElement("style");r.setAttribute(Oo,""),r.textContent=t.join("\n"),document.head.appendChild(r)}(e),e}const Fo=({extra:e})=>{const r=No()+(e?"\n"+e:"");return t.createElement("style",null,r)};const $o=sr(e=>({open:!1,setOpen:t=>e({open:t})}));function Bo(){const[e,n]=t.useState(null),s=r(null),{open:a,setOpen:o}=$o();return i(()=>{s.current&&(s.current.style.display=a?"block":"none")},[a]),t.useLayoutEffect(()=>{const e=document.createElement("div");e.style.position="fixed",e.style.inset="0",e.style.zIndex="214748348",e.style.display="none",document.body.appendChild(e),s.current=e;const t=e.attachShadow({mode:"open"});!function(e){const t=No();if(Co)e.adoptedStyleSheets=[_o(t)];else{const r=document.createElement("style");r.textContent=t,e.appendChild(r)}}(t);const r=document.createElement("style");r.innerHTML="\n .product-dialog-container{\n max-height: 70vh;\n overflow-y: auto;\n width: 100%;\n max-width: min(82vw, 500px) !important;\n }\n ",t.appendChild(r);const i=document.createElement("div");return t.appendChild(i),n(i),()=>e.remove()},[]),{container:e,setOpen:o}}const Uo=t.createContext(null),zo=e=>{var r;const{isMobile:n}=e,a=ar(e=>e.setIsPreview),[o,l]=s("collection"in e?e.collection.contents[0]:null),c=null!==(r=e.isPreview)&&void 0!==r&&r;if(Io({collection:"collection"in e&&!n?e.collection:void 0,shortform:"shortform"in e?e.shortform:n?null:o,isPreview:c}),i(()=>{var t;const r=ar.getState().isPreview;return a(null!==(t=e.isPreview)&&void 0!==t&&t),()=>{a(r)}},[e.isPreview,a]),n){if("shortform"in e)return t.createElement(So,{shortForm:e.shortform,trackStatistics:!1,isPreview:c});if(e.collection)return t.createElement(Lo,{collection:e.collection,playerSettings:e.collection.player.shoppingPlayer,isPreview:c})}if("shortform"in e){const{layout:r}=e.shortform.player,i=e.shortform.player.shoppingPlayer;switch(r){case Kr.PLATFORM:return t.createElement(us,{shortform:e.shortform,playerSettings:i,isPreview:c,player:t.createElement("div",{className:"aspect-[9/16] h-full rounded-xl border overflow-hidden"},t.createElement(So,{shortForm:e.shortform,hideProductCarousel:!0,hideOverlay:!0,trackStatistics:!1,isPreview:c}))});case Kr.HORIZONTAL:return t.createElement(Ka,{shortform:e.shortform,playerSettings:i,isPreview:c,player:t.createElement("div",{className:"h-full aspect-[9/16]"},t.createElement(So,{shortForm:e.shortform,hideProductCarousel:!0,trackStatistics:!1,isPreview:c}))});case Kr.VERTICAL:return t.createElement(Xa,{shortform:e.shortform,playerSettings:i,isPreview:c,player:t.createElement("div",{className:"aspect-[9/16] h-full"},t.createElement(So,{shortForm:e.shortform,hideProductCarousel:!0,trackStatistics:!1,isPreview:c}))});case Kr.GRID:return t.createElement(Za,{shortform:e.shortform,playerSettings:i,isPreview:c,player:t.createElement("div",{className:"h-full aspect-[9/16]"},t.createElement(So,{shortForm:e.shortform,hideProductCarousel:!0,trackStatistics:!1,isPreview:c}))})}}else{if(!e.collection||!o)return null;{const{layout:r}=e.collection.player,i=e.collection.player.shoppingPlayer;switch(r){case Kr.PLATFORM:return t.createElement(us,{shortform:o,playerSettings:i,isPreview:c,player:t.createElement("div",{className:"w-full flex items-center justify-center gap-4",style:{height:"calc(-220px + 100vh)"}},t.createElement(eo,{collection:e.collection,playerSettings:i,shortform:o,setShortform:l}))});case Kr.HORIZONTAL:return t.createElement(Ka,{shortform:o,isPreview:c,playerSettings:Object.assign({},i),player:t.createElement(xo,{collection:e.collection,playerSettings:i,shortform:o,setShortform:l,isPreview:c})});case Kr.VERTICAL:return t.createElement(Xa,{isPreview:c,playerSettings:Object.assign({},i),shortform:o,player:t.createElement(xo,{collection:e.collection,playerSettings:i,shortform:o,setShortform:l,isPreview:c})});case Kr.GRID:return t.createElement(Za,{shortform:o,isPreview:c,playerSettings:Object.assign({},i),player:t.createElement(xo,{collection:e.collection,playerSettings:i,shortform:o,setShortform:l,isPreview:c})})}}}},Go=e=>{const{container:r}=Bo();return r?t.createElement(qr.div,{style:{display:"block",width:"100%",height:"100%"}},t.createElement(Fo,null),t.createElement(Uo.Provider,{value:r},t.createElement(zo,Object.assign({},e)))):null},jo=e=>{const{container:r}=Bo();return r?t.createElement(qr.div,{style:{display:"block",width:"100%",height:"100%"}},t.createElement(Fo,null),t.createElement(Uo.Provider,{value:r},t.createElement(So,Object.assign({},e,{isPreview:!0,trackStatistics:!1})))):null},Ho=t.createContext(null),Vo=({children:e})=>{const r=t.useRef(null);return r.current||(r.current=tr(e=>({collection:null,setCollection:t=>e({collection:t}),nextKey:"",setNextKey:t=>e({nextKey:t}),isFetching:!1,setIsFetching:t=>e({isFetching:t})}))),t.createElement(Ho.Provider,{value:r.current},e)},Wo=()=>(e=>{const r=t.useContext(Ho);if(!r)throw new Error("Missing CollectionProvider");return ir(r,e)})(e=>e),Yo=(e,t,n)=>{const{collection:s,setCollection:a,isFetching:o,setIsFetching:l,nextKey:c,setNextKey:d}=Wo(),u=ar(e=>e.isPreview),h=null!=n?n:u,f=(null==e?void 0:e.media)?At(e.media.duration):0,{resetPlaytime:p,playtime:m}=Ft(),{playtime:g,resetPlaytime:v}=Ft(),y=Qt(),b=r(new Set),E=r(new Set),w=()=>{if(!s)return;const{colId:t,uuid:r,userId:i}=s;if(h)return;const n=Ge,a=Math.floor((new Date).getTime()/1e3);localStorage.setItem(n,a.toString()),r&&!b.current.has(r)&&(b.current.add(r),zt({contentId:t,uuid:r,type:wt.COLLECTION,userId:i,playtime:g})),(null==e?void 0:e.uuid)&&!E.current.has(e.uuid)&&(E.current.add(e.uuid),zt({contentId:e.shortsId,uuid:e.uuid,type:wt.SHORTS,userId:e.userId,playtime:m,isFinished:m>=f})),v(),p()},S=r(w);S.current=w;const T=r(0);i(()=>{T.current+=1;const e=T.current;return()=>{Promise.resolve().then(()=>{T.current===e&&S.current()})}},[]),i(()=>{y||w()},[y]);return{onSlideChange:r=>x(void 0,void 0,void 0,function*(){if(e&&s&&(yield(e=>x(void 0,void 0,void 0,function*(){var t,r;if(!s)return;const{contents:i,count:n}=s;if((null!=n?n:Number.MAX_SAFE_INTEGER)>i.length&&e>=i.length-5&&!o){l(!0);try{const e=yield Vt({collectionId:s.colId,nextKey:c});if(!e||!(null===(t=e.contents)||void 0===t?void 0:t.length))return;d((null===(r=e.contents.at(-1))||void 0===r?void 0:r.shortsId)||"");const i=new Set(s.contents.map(e=>e.shortsId)),n=e.contents.filter(e=>!i.has(e.shortsId));if(!n.length)return;const o=s.contents.concat(n);a(Object.assign(Object.assign({},s),{contents:o}))}catch(e){console.error(e)}finally{l(!1)}}}))(r),!h)){const{shortsId:i,uuid:n,userId:a}=e;n&&!E.current.has(n)&&(E.current.add(n),zt({contentId:i,uuid:n,type:wt.SHORTS,playtime:m,isFinished:m>=f,userId:a})),p();const o=Lt(),l=s.contents[r];t(Object.assign(Object.assign({},l),{uuid:o})),yield Ut({contentId:l.shortsId,uuid:o,type:wt.SHORTS,userId:l.userId,isFirstPlay:!Pt(l.shortsId)})}}),onCollectionClose:w}},Ko=t.memo(({shortform:e,shareUrl:r,handleClose:i})=>t.createElement(t.Fragment,null,t.createElement("div",{onClick:e=>e.stopPropagation(),className:"overflow-hidden",style:{borderRadius:"10px",overflow:"hidden",width:"100%",height:"100%",backgroundRepeat:"no-repeat",backgroundPosition:"center",backgroundSize:"cover",backgroundImage:`url(${Dt(e.thumbPath)})`}},t.createElement(So,{handleClose:i,shortForm:e,isPopup:!0,trackStatistics:!1,shareUrl:r})))),qo=t.memo(({shortform:e})=>t.createElement("div",{onClick:e=>{e.stopPropagation()},style:{width:"100%",height:"100%",borderRadius:"10px",backgroundRepeat:"no-repeat",backgroundPosition:"center",backgroundSize:"cover",backgroundImage:`url(${e.thumbPath.includes("https")?e.thumbPath:`https://${e.thumbPath}`})`}})),Xo=({shortform:e,shareUrl:r,handleClose:i})=>{const{isActive:n}=d(La),s=d(Ra),a=yo().width<430||co.isMobile;return t.createElement("div",{className:"flex items-center justify-center w-full h-full select-none",onClick:e=>{i()}},t.createElement("div",{className:"max-h-full flex items-center justify-center",style:{width:"100%",aspectRatio:a?"auto":"9 / 16",height:a?"100dvh":"auto",maxHeight:a?void 0:"90vh",transform:a?void 0:`scale(${n?1:.8})`,transition:"transform 180ms ease"}},n?t.createElement("div",{className:"flex items-center justify-between w-full h-full text-white relative"},t.createElement("div",{className:"cursor-pointer absolute",onClick:e=>{e.stopPropagation(),s.slidePrev()},style:{zIndex:1e5,left:a?"0":"-30px",top:"50%",transform:"translateY(-50%)",width:30,height:30,display:"grid",placeItems:"center",pointerEvents:"auto"}},t.createElement(ii,{size:28})),t.createElement(Ko,{shortform:e,shareUrl:r,handleClose:i}),t.createElement("div",{className:"cursor-pointer absolute",style:{zIndex:1e5,right:a?"0":"-30px",top:"50%",transform:"translateY(-50%)",width:30,height:30,display:"grid",placeItems:"center",pointerEvents:"auto"},onClick:e=>{e.stopPropagation(),s.slideNext()}},t.createElement(ni,{size:28}))):t.createElement(qo,{shortform:e})))},Qo=({collection:e,initialShortsId:i,onSlideChange:n,onClosePlayer:s})=>{var a;const{PLAYER_BASE_URL:o}=gt(),l=u(()=>Math.max(e.contents.findIndex(e=>e.shortsId===i),0),[e.contents,i]),c=null!==(a=yo().width)&&void 0!==a?a:0,d=c<430||co.isMobile,h=d?1:c>=1200?4:c>=900?3:2,f=e.contents.length>=3,p=f?Math.min(h,e.contents.length-1):Math.min(h,e.contents.length),m=r(null);return t.createElement("div",{style:{minHeight:100,minWidth:300},className:"w-full"},t.createElement(Pa,{style:{minHeight:100,overflow:"visible"},initialSlide:l,ref:m,lazyPreloadPrevNext:2,className:"w-full",spaceBetween:d?8:c>=1200?24:c>=900?25:16,slidesPerView:p,grabCursor:!0,centeredSlides:1!==p,onSlideChangeTransitionEnd:t=>{const r=t.realIndex;null==n||n(r);const i=e.contents[f?(r+1)%e.contents.length:r+1];var s;i&&(s=xt(i.media.objectId),A||(A=document.createElement("video"),A.muted=!0,A.playsInline=!0,A.preload="metadata",A.loop=!0,A.style.cssText="position:fixed;left:-9999px;top:-9999px;width:1px;height:1px;opacity:0",document.body.appendChild(A)),k!==s&&(A.src=s,A.load(),k=s))},loop:f,onClick:e=>{const t=e.clickedIndex;if("number"!=typeof t||Number.isNaN(t))return;if(!f)return void e.slideTo(t);const r=t-e.activeIndex,i=Math.min(Math.abs(r),p);for(let t=0;t<i;t+=1)r>0?e.slideNext():e.slidePrev()}},e.contents.map(r=>t.createElement(Ca,{key:r.shortsId},t.createElement(Xo,{handleClose:s,shortform:r,shareUrl:`${o}/collection/${e.colId}?start=${r.shortsId}&layout=5`})))))},Zo=({shortform:e,onThumbnailClick:r,iconSize:i,exposeTitle:n,borderLine:s})=>{const a=u(()=>Ct(s),[s])?{background:"linear-gradient(#fff,#fff) padding-box, conic-gradient(#f58529,#f77737,#fd1d1d,#833ab4,#c13584,#f58529) border-box",border:"3px solid transparent"}:{background:"#fff",border:"3px solid #fff"};return t.createElement("div",{className:"flex flex-col w-full gap-2",onClick:()=>r(e.shortsId)},t.createElement("div",{className:"rounded-full overflow-hidden cursor-pointer",style:Object.assign({width:i,height:i,padding:4},a)},t.createElement("img",{src:Dt(e.thumbPath),alt:"thumbnail",className:"w-full h-full object-cover block rounded-full"})),n&&t.createElement("span",{style:{width:i},className:"text-black overflow-hidden text-[12px] whitespace-nowrap text-center text-clip cursor-default"},e.title))},Jo=({products:e,iconSize:r,contentId:i,setSelectedProducts:n,showMoreBtn:s,hideMoreBadge:a,showPrice:o,openInPortal:l=!0,imageSize:c})=>{const{setOpen:d}=$o(),u=()=>{n({productsInfo:e,shortsId:i}),l&&d(!0)};return t.createElement(t.Fragment,null,t.createElement("div",{onClick:()=>x(void 0,void 0,void 0,function*(){1===e.length||s||u()}),className:"flex flex-col gap-2 mt-4 text-gray-800",style:{maxWidth:r||"100%",fontSize:13}},t.createElement(vo,{showMoreBtn:s,lineClamp:2,product:e[0],contentId:i,productLength:e.length,hideMoreBadge:null!=a?a:1===e.length,showPrice:o,imageSize:c,openProductPopup:u})))},el=({product:e,maxWidth:r="100%",height:i,cardWidth:n})=>{const s=ar(e=>e.memberOnly&&!e.isMemberLoggedIn);return t.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,borderRadius:8,backgroundColor:"#ffffff",color:"#111827",maxWidth:r,height:i,width:"100%",paddingRight:8}},t.createElement("img",{src:Dt(e.thumbPath),alt:e.productName,style:{height:"100%",aspectRatio:"1 / 1",borderRadius:6,objectFit:"cover",flexShrink:0}}),t.createElement("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",justifyContent:"center"}},t.createElement("span",{style:{lineHeight:1.25,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",fontSize:12}},e.productName),t.createElement("span",{style:{lineHeight:1.25,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",fontSize:11}},(()=>{if(s)return t.createElement("span",{style:{color:"#dc2626",fontWeight:600}},"판매가 회원 공개");return"number"==typeof e.sellingPrice&&e.sellingPrice<e.price?"number"==typeof n&&n>=190?t.createElement(t.Fragment,null,t.createElement("span",{style:{color:"#dc2626",fontWeight:600,marginRight:4}},Tt(e.sellingPrice,e.currency)),t.createElement("span",{style:{color:"#9ca3af",textDecoration:"line-through"}},Tt(e.price,e.currency))):t.createElement("span",{style:{color:"#dc2626",fontWeight:600}},Tt(e.sellingPrice,e.currency)):t.createElement("span",{style:{color:"#dc2626",fontWeight:600}},Tt(e.price,e.currency))})())))},tl=({playUrl:e,poster:r})=>t.createElement("div",{className:"w-full h-full absolute top-0 left-0 z-10 pointer-events-none",style:{backgroundImage:`url(${r})`,backgroundSize:"cover",backgroundPosition:"center",backgroundRepeat:"no-repeat"}},t.createElement("video",{src:e,autoPlay:!0,muted:!0,preload:"auto",playsInline:!0,loop:!0,className:"w-full h-full object-cover"})),rl=({shortform:e,onThumbnailClick:r,onPreviewPlay:i,iconSize:n,exposeTitle:a,rounded:o,borderLine:l,titlePosition:c,exposeProductBanner:d,setSelectedProducts:h,iconRatio:f,hoverPlay:p,exposeProductBadge:m})=>{var g;const v=u(()=>Ct(l),[l]),[y,b]=s(!1),{API_BASE_URL:E}=gt();return t.createElement("div",{className:"relative"},t.createElement("div",{onMouseEnter:()=>{b(!0),p&&i(e.shortsId)},onMouseLeave:()=>b(!1),onClick:()=>r(e.shortsId),style:Object.assign({width:n,aspectRatio:f},o&&{borderRadius:"15px"}),className:`cursor-pointer p-[3px] ${o&&"rounded-[15px]"} ${v&&"bg-insta"} relative overflow-hidden`},y&&p&&t.createElement(tl,{playUrl:`${E}/direct/${e.media.objectId}`,poster:Dt(e.thumbPath)}),t.createElement("img",{style:Object.assign({},o&&{borderRadius:"15px"}),src:Dt(e.thumbPath),alt:"thumbnail",className:`w-full h-full object-cover ${o&&"rounded-[15px]"}`}),m&&(null===(g=e.productsInfo)||void 0===g?void 0:g.length)>0&&!(p&&y)&&t.createElement("div",{className:"absolute pointer-events-none flex items-center justify-center z-20",style:{left:2,right:2,bottom:10,height:"20%"}},t.createElement("div",{className:"h-full inline-block",style:{width:"95%"}},t.createElement(el,{product:e.productsInfo[0],maxWidth:"100%",height:"100%",cardWidth:n}))),a&&c===Be.INNER&&!(p&&y)&&t.createElement("p",{style:Object.assign({overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},m?{bottom:"22%"}:{}),className:"absolute bottom-0 left-0 w-full my-2 text-white px-2 z-10 text-[12px] cursor-default truncate"},e.title)),a&&c!==Be.INNER&&t.createElement("p",{style:{width:n,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},className:"my-2 text-[12px] cursor-default truncate"},e.title),d&&t.createElement(Jo,{setSelectedProducts:h,products:e.productsInfo,iconSize:n,contentId:e.shortsId}))},il=e=>{const{iconShape:r,collection:i}=e;return r===Ne.MANY?t.createElement(nl,Object.assign({},e)):t.createElement(sl,Object.assign({},e,{shortform:i.contents[0]}))},nl=e=>{const{collection:r}=e,{thumbnailAutoPlay:i}=e,{setCollection:n,nextKey:s,setNextKey:a,isFetching:o,setIsFetching:l}=Wo();return t.createElement(Pa,{freeMode:!0,slidesPerView:"auto",spaceBetween:12,onReachEnd:()=>x(void 0,void 0,void 0,function*(){var e,t,i;if(r&&!(o||(null!==(e=r.count)&&void 0!==e?e:Number.MAX_SAFE_INTEGER)<=r.contents.length)){l(!0);try{const e=yield Vt({collectionId:r.colId,nextKey:s});if(!e||!(null===(t=e.contents)||void 0===t?void 0:t.length))return;a((null===(i=e.contents.at(-1))||void 0===i?void 0:i.shortsId)||"");const o=new Set(r.contents.map(e=>e.shortsId)),l=e.contents.filter(e=>!o.has(e.shortsId));if(!l.length)return;n(Object.assign(Object.assign({},r),{contents:[...r.contents,...l]}))}catch(e){console.error(e)}finally{l(!1)}}}),modules:i?[Oa]:[],autoplay:!!i&&{delay:3e3,disableOnInteraction:!1,pauseOnMouseEnter:!0},loop:i||void 0},null==r?void 0:r.contents.map(r=>t.createElement(Ca,{key:r.shortsId,className:"!w-auto"},t.createElement(sl,Object.assign({},e,{shortform:r})))))},sl=e=>{const{iconForm:r}=e;return r===Me.INSTA?t.createElement(Zo,Object.assign({},e)):t.createElement(rl,Object.assign({},e))};function al(e,t,{checkForDefaultPrevented:r=!0}={}){return function(i){if(e?.(i),!1===r||!i.defaultPrevented)return t?.(i)}}function ol(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function ll(...e){return t=>{let r=!1;const i=e.map(e=>{const i=ol(e,t);return r||"function"!=typeof i||(r=!0),i});if(r)return()=>{for(let t=0;t<i.length;t++){const r=i[t];"function"==typeof r?r():ol(e[t],null)}}}}function cl(...t){return e.useCallback(ll(...t),t)}function dl(...t){const r=t[0];if(1===t.length)return r;const i=()=>{const i=t.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(t){const n=i.reduce((e,{useScope:r,scopeName:i})=>({...e,...r(t)[`__scope${i}`]}),{});return e.useMemo(()=>({[`__scope${r.scopeName}`]:n}),[n])}};return i.scopeName=r.scopeName,i}var ul=globalThis?.document?e.useLayoutEffect:()=>{},hl=e[" useId ".trim().toString()]||(()=>{}),fl=0;function pl(t){const[r,i]=e.useState(hl());return ul(()=>{t||i(e=>e??String(fl++))},[t]),t||(r?`radix-${r}`:"")}var ml=e[" useInsertionEffect ".trim().toString()]||ul;function gl({prop:t,defaultProp:r,onChange:i=()=>{},caller:n}){const[s,a,o]=function({defaultProp:t,onChange:r}){const[i,n]=e.useState(t),s=e.useRef(i),a=e.useRef(r);return ml(()=>{a.current=r},[r]),e.useEffect(()=>{s.current!==i&&(a.current?.(i),s.current=i)},[i,s]),[i,n,a]}({defaultProp:r,onChange:i}),l=void 0!==t,c=l?t:s;{const r=e.useRef(void 0!==t);e.useEffect(()=>{const e=r.current;if(e!==l){const t=e?"controlled":"uncontrolled",r=l?"controlled":"uncontrolled";console.warn(`${n} is changing from ${t} to ${r}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`)}r.current=l},[l,n])}const d=e.useCallback(e=>{if(l){const r=function(e){return"function"==typeof e}(e)?e(t):e;r!==t&&o.current?.(r)}else a(e)},[l,t,a,o]);return[c,d]}function vl(e,t,{checkForDefaultPrevented:r=!0}={}){return function(i){if(e?.(i),!1===r||!i.defaultPrevented)return t?.(i)}}function yl(t){const r=bl(t),i=e.forwardRef((t,i)=>{const{children:n,...s}=t,a=e.Children.toArray(n),o=a.find(wl);if(o){const t=o.props.children,n=a.map(r=>r===o?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:r);return b(r,{...s,ref:i,children:e.isValidElement(t)?e.cloneElement(t,void 0,n):null})}return b(r,{...s,ref:i,children:n})});return i.displayName=`${t}.Slot`,i}function bl(t){const r=e.forwardRef((t,r)=>{const{children:i,...n}=t;if(e.isValidElement(i)){const t=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;if(r)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r)return e.props.ref;return e.props.ref||e.ref}(i),s=function(e,t){const r={...t};for(const i in t){const n=e[i],s=t[i];/^on[A-Z]/.test(i)?n&&s?r[i]=(...e)=>{const t=s(...e);return n(...e),t}:n&&(r[i]=n):"style"===i?r[i]={...n,...s}:"className"===i&&(r[i]=[n,s].filter(Boolean).join(" "))}return{...e,...r}}(n,i.props);return i.type!==e.Fragment&&(s.ref=r?ll(r,t):t),e.cloneElement(i,s)}return e.Children.count(i)>1?e.Children.only(null):null});return r.displayName=`${t}.SlotClone`,r}var El=Symbol("radix.slottable");function wl(t){return e.isValidElement(t)&&"function"==typeof t.type&&"__radixId"in t.type&&t.type.__radixId===El}var Sl=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((t,r)=>{const i=yl(`Primitive.${r}`),n=e.forwardRef((e,t)=>{const{asChild:n,...s}=e,a=n?i:r;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),b(a,{...s,ref:t})});return n.displayName=`Primitive.${r}`,{...t,[r]:n}},{});function Tl(t){const r=e.useRef(t);return e.useEffect(()=>{r.current=t}),e.useMemo(()=>(...e)=>r.current?.(...e),[])}var xl,Al="dismissableLayer.update",kl="dismissableLayer.pointerDownOutside",Il="dismissableLayer.focusOutside",Ll=e.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Rl=e.forwardRef((t,r)=>{const{disableOutsidePointerEvents:i=!1,onEscapeKeyDown:n,onPointerDownOutside:s,onFocusOutside:a,onInteractOutside:o,onDismiss:l,...c}=t,d=e.useContext(Ll),[u,h]=e.useState(null),f=u?.ownerDocument??globalThis?.document,[,p]=e.useState({}),m=cl(r,e=>h(e)),g=Array.from(d.layers),[v]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),y=g.indexOf(v),E=u?g.indexOf(u):-1,w=d.layersWithOutsidePointerEventsDisabled.size>0,S=E>=y,T=function(t,r=globalThis?.document){const i=Tl(t),n=e.useRef(!1),s=e.useRef(()=>{});return e.useEffect(()=>{const e=e=>{if(e.target&&!n.current){let t=function(){Cl(kl,i,n,{discrete:!0})};const n={originalEvent:e};"touch"===e.pointerType?(r.removeEventListener("click",s.current),s.current=t,r.addEventListener("click",s.current,{once:!0})):t()}else r.removeEventListener("click",s.current);n.current=!1},t=window.setTimeout(()=>{r.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(t),r.removeEventListener("pointerdown",e),r.removeEventListener("click",s.current)}},[r,i]),{onPointerDownCapture:()=>n.current=!0}}(e=>{const t=e.target,r=[...d.branches].some(e=>e.contains(t));S&&!r&&(s?.(e),o?.(e),e.defaultPrevented||l?.())},f),x=function(t,r=globalThis?.document){const i=Tl(t),n=e.useRef(!1);return e.useEffect(()=>{const e=e=>{if(e.target&&!n.current){Cl(Il,i,{originalEvent:e},{discrete:!1})}};return r.addEventListener("focusin",e),()=>r.removeEventListener("focusin",e)},[r,i]),{onFocusCapture:()=>n.current=!0,onBlurCapture:()=>n.current=!1}}(e=>{const t=e.target;[...d.branches].some(e=>e.contains(t))||(a?.(e),o?.(e),e.defaultPrevented||l?.())},f);return function(t,r=globalThis?.document){const i=Tl(t);e.useEffect(()=>{const e=e=>{"Escape"===e.key&&i(e)};return r.addEventListener("keydown",e,{capture:!0}),()=>r.removeEventListener("keydown",e,{capture:!0})},[i,r])}(e=>{E===d.layers.size-1&&(n?.(e),!e.defaultPrevented&&l&&(e.preventDefault(),l()))},f),e.useEffect(()=>{if(u)return i&&(0===d.layersWithOutsidePointerEventsDisabled.size&&(xl=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(u)),d.layers.add(u),Pl(),()=>{i&&1===d.layersWithOutsidePointerEventsDisabled.size&&(f.body.style.pointerEvents=xl)}},[u,f,i,d]),e.useEffect(()=>()=>{u&&(d.layers.delete(u),d.layersWithOutsidePointerEventsDisabled.delete(u),Pl())},[u,d]),e.useEffect(()=>{const e=()=>p({});return document.addEventListener(Al,e),()=>document.removeEventListener(Al,e)},[]),b(Sl.div,{...c,ref:m,style:{pointerEvents:w?S?"auto":"none":void 0,...t.style},onFocusCapture:vl(t.onFocusCapture,x.onFocusCapture),onBlurCapture:vl(t.onBlurCapture,x.onBlurCapture),onPointerDownCapture:vl(t.onPointerDownCapture,T.onPointerDownCapture)})});Rl.displayName="DismissableLayer";function Pl(){const e=new CustomEvent(Al);document.dispatchEvent(e)}function Cl(e,t,r,{discrete:i}){const n=r.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});t&&n.addEventListener(e,t,{once:!0}),i?function(e,t){e&&p.flushSync(()=>e.dispatchEvent(t))}(n,s):n.dispatchEvent(s)}e.forwardRef((t,r)=>{const i=e.useContext(Ll),n=e.useRef(null),s=cl(r,n);return e.useEffect(()=>{const e=n.current;if(e)return i.branches.add(e),()=>{i.branches.delete(e)}},[i.branches]),b(Sl.div,{...t,ref:s})}).displayName="DismissableLayerBranch";var Dl="focusScope.autoFocusOnMount",_l="focusScope.autoFocusOnUnmount",Ol={bubbles:!1,cancelable:!0},Ml=e.forwardRef((t,r)=>{const{loop:i=!1,trapped:n=!1,onMountAutoFocus:s,onUnmountAutoFocus:a,...o}=t,[l,c]=e.useState(null),d=Tl(s),u=Tl(a),h=e.useRef(null),f=cl(r,e=>c(e)),p=e.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;e.useEffect(()=>{if(n){let e=function(e){if(p.paused||!l)return;const t=e.target;l.contains(t)?h.current=t:Bl(h.current,{select:!0})},t=function(e){if(p.paused||!l)return;const t=e.relatedTarget;null!==t&&(l.contains(t)||Bl(h.current,{select:!0}))},r=function(e){if(document.activeElement===document.body)for(const t of e)t.removedNodes.length>0&&Bl(l)};document.addEventListener("focusin",e),document.addEventListener("focusout",t);const i=new MutationObserver(r);return l&&i.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",t),i.disconnect()}}},[n,l,p.paused]),e.useEffect(()=>{if(l){Ul.add(p);const t=document.activeElement;if(!l.contains(t)){const r=new CustomEvent(Dl,Ol);l.addEventListener(Dl,d),l.dispatchEvent(r),r.defaultPrevented||(!function(e,{select:t=!1}={}){const r=document.activeElement;for(const i of e)if(Bl(i,{select:t}),document.activeElement!==r)return}((e=Nl(l),e.filter(e=>"A"!==e.tagName)),{select:!0}),document.activeElement===t&&Bl(l))}return()=>{l.removeEventListener(Dl,d),setTimeout(()=>{const e=new CustomEvent(_l,Ol);l.addEventListener(_l,u),l.dispatchEvent(e),e.defaultPrevented||Bl(t??document.body,{select:!0}),l.removeEventListener(_l,u),Ul.remove(p)},0)}}var e},[l,d,u,p]);const m=e.useCallback(e=>{if(!i&&!n)return;if(p.paused)return;const t="Tab"===e.key&&!e.altKey&&!e.ctrlKey&&!e.metaKey,r=document.activeElement;if(t&&r){const t=e.currentTarget,[n,s]=function(e){const t=Nl(e),r=Fl(t,e),i=Fl(t.reverse(),e);return[r,i]}(t);n&&s?e.shiftKey||r!==s?e.shiftKey&&r===n&&(e.preventDefault(),i&&Bl(s,{select:!0})):(e.preventDefault(),i&&Bl(n,{select:!0})):r===t&&e.preventDefault()}},[i,n,p.paused]);return b(Sl.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});function Nl(e){const t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{const t="INPUT"===e.tagName&&"hidden"===e.type;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)t.push(r.currentNode);return t}function Fl(e,t){for(const r of e)if(!$l(r,{upTo:t}))return r}function $l(e,{upTo:t}){if("hidden"===getComputedStyle(e).visibility)return!0;for(;e;){if(void 0!==t&&e===t)return!1;if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}function Bl(e,{select:t=!1}={}){if(e&&e.focus){const r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&function(e){return e instanceof HTMLInputElement&&"select"in e}(e)&&t&&e.select()}}Ml.displayName="FocusScope";var Ul=function(){let e=[];return{add(t){const r=e[0];t!==r&&r?.pause(),e=zl(e,t),e.unshift(t)},remove(t){e=zl(e,t),e[0]?.resume()}}}();function zl(e,t){const r=[...e],i=r.indexOf(t);return-1!==i&&r.splice(i,1),r}var Gl=e.forwardRef((t,r)=>{const{container:i,...n}=t,[s,a]=e.useState(!1);ul(()=>a(!0),[]);const o=i||s&&globalThis?.document?.body;return o?m.createPortal(b(Sl.div,{...n,ref:r}),o):null});Gl.displayName="Portal";var jl=t=>{const{present:r,children:i}=t,n=function(t){const[r,i]=e.useState(),n=e.useRef(null),s=e.useRef(t),a=e.useRef("none"),o=t?"mounted":"unmounted",[l,c]=function(t,r){return e.useReducer((e,t)=>r[e][t]??e,t)}(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return e.useEffect(()=>{const e=Hl(n.current);a.current="mounted"===l?e:"none"},[l]),ul(()=>{const e=n.current,r=s.current;if(r!==t){const i=a.current,n=Hl(e);if(t)c("MOUNT");else if("none"===n||"none"===e?.display)c("UNMOUNT");else{c(r&&i!==n?"ANIMATION_OUT":"UNMOUNT")}s.current=t}},[t,c]),ul(()=>{if(r){let e;const t=r.ownerDocument.defaultView??window,i=i=>{const a=Hl(n.current).includes(CSS.escape(i.animationName));if(i.target===r&&a&&(c("ANIMATION_END"),!s.current)){const i=r.style.animationFillMode;r.style.animationFillMode="forwards",e=t.setTimeout(()=>{"forwards"===r.style.animationFillMode&&(r.style.animationFillMode=i)})}},o=e=>{e.target===r&&(a.current=Hl(n.current))};return r.addEventListener("animationstart",o),r.addEventListener("animationcancel",i),r.addEventListener("animationend",i),()=>{t.clearTimeout(e),r.removeEventListener("animationstart",o),r.removeEventListener("animationcancel",i),r.removeEventListener("animationend",i)}}c("ANIMATION_END")},[r,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:e.useCallback(e=>{n.current=e?getComputedStyle(e):null,i(e)},[])}}(r),s="function"==typeof i?i({present:n.isPresent}):e.Children.only(i),a=cl(n.ref,function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;if(r)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r)return e.props.ref;return e.props.ref||e.ref}(s));return"function"==typeof i||n.isPresent?e.cloneElement(s,{ref:a}):null};function Hl(e){return e?.animationName||"none"}jl.displayName="Presence";var Vl=0;function Wl(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Yl="right-scroll-bar-position",Kl="width-before-scroll-bar";function ql(e,t){return"function"==typeof e?e(t):e&&(e.current=t),e}var Xl="undefined"!=typeof window?e.useLayoutEffect:e.useEffect,Ql=new WeakMap;function Zl(e,t){var r,i,n,a=(r=null,i=function(t){return e.forEach(function(e){return ql(e,t)})},(n=s(function(){return{value:r,callback:i,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0]).callback=i,n.facade);return Xl(function(){var t=Ql.get(a);if(t){var r=new Set(t),i=new Set(e),n=a.current;r.forEach(function(e){i.has(e)||ql(e,null)}),i.forEach(function(e){r.has(e)||ql(e,n)})}Ql.set(a,e)},[e]),a}function Jl(e){return e}var ec=function(t){var r=t.sideCar,i=T(t,["sideCar"]);if(!r)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var n=r.read();if(!n)throw new Error("Sidecar medium not found");return e.createElement(n,S({},i))};ec.isSideCarExport=!0;var tc=function(e){void 0===e&&(e={});var t=function(e,t){void 0===t&&(t=Jl);var r=[],i=!1,n={read:function(){if(i)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return r.length?r[r.length-1]:e},useMedium:function(e){var n=t(e,i);return r.push(n),function(){r=r.filter(function(e){return e!==n})}},assignSyncMedium:function(e){for(i=!0;r.length;){var t=r;r=[],t.forEach(e)}r={push:function(t){return e(t)},filter:function(){return r}}},assignMedium:function(e){i=!0;var t=[];if(r.length){var n=r;r=[],n.forEach(e),t=r}var s=function(){var r=t;t=[],r.forEach(e)},a=function(){return Promise.resolve().then(s)};a(),r={push:function(e){t.push(e),a()},filter:function(e){return t=t.filter(e),r}}}};return n}(null);return t.options=S({async:!0,ssr:!1},e),t}(),rc=function(){},ic=e.forwardRef(function(t,r){var i=e.useRef(null),n=e.useState({onScrollCapture:rc,onWheelCapture:rc,onTouchMoveCapture:rc}),s=n[0],a=n[1],o=t.forwardProps,l=t.children,c=t.className,d=t.removeScrollBar,u=t.enabled,h=t.shards,f=t.sideCar,p=t.noRelative,m=t.noIsolation,g=t.inert,v=t.allowPinchZoom,y=t.as,b=void 0===y?"div":y,E=t.gapMode,w=T(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),x=f,A=Zl([i,r]),k=S(S({},w),s);return e.createElement(e.Fragment,null,u&&e.createElement(x,{sideCar:tc,removeScrollBar:d,shards:h,noRelative:p,noIsolation:m,inert:g,setCallbacks:a,allowPinchZoom:!!v,lockRef:i,gapMode:E}),o?e.cloneElement(e.Children.only(l),S(S({},k),{ref:A})):e.createElement(b,S({},k,{className:c,ref:A}),l))});ic.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},ic.classNames={fullWidth:Kl,zeroRight:Yl};function nc(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=function(){if("undefined"!=typeof __webpack_nonce__)return __webpack_nonce__}();return t&&e.setAttribute("nonce",t),e}var sc=function(){var e=0,t=null;return{add:function(r){var i,n;0==e&&(t=nc())&&(n=r,(i=t).styleSheet?i.styleSheet.cssText=n:i.appendChild(document.createTextNode(n)),function(e){(document.head||document.getElementsByTagName("head")[0]).appendChild(e)}(t)),e++},remove:function(){! --e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},ac=function(){var t,r=(t=sc(),function(r,i){e.useEffect(function(){return t.add(r),function(){t.remove()}},[r&&i])});return function(e){var t=e.styles,i=e.dynamic;return r(t,i),null}},oc={left:0,top:0,right:0,gap:0},lc=function(e){return parseInt(e||"",10)||0},cc=function(e){if(void 0===e&&(e="margin"),"undefined"==typeof window)return oc;var t=function(e){var t=window.getComputedStyle(document.body),r=t["padding"===e?"paddingLeft":"marginLeft"],i=t["padding"===e?"paddingTop":"marginTop"],n=t["padding"===e?"paddingRight":"marginRight"];return[lc(r),lc(i),lc(n)]}(e),r=document.documentElement.clientWidth,i=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,i-r+t[2]-t[0])}},dc=ac(),uc="data-scroll-locked",hc=function(e,t,r,i){var n=e.left,s=e.top,a=e.right,o=e.gap;return void 0===r&&(r="margin"),"\n .".concat("with-scroll-bars-hidden"," {\n overflow: hidden ").concat(i,";\n padding-right: ").concat(o,"px ").concat(i,";\n }\n body[").concat(uc,"] {\n overflow: hidden ").concat(i,";\n overscroll-behavior: contain;\n ").concat([t&&"position: relative ".concat(i,";"),"margin"===r&&"\n padding-left: ".concat(n,"px;\n padding-top: ").concat(s,"px;\n padding-right: ").concat(a,"px;\n margin-left:0;\n margin-top:0;\n margin-right: ").concat(o,"px ").concat(i,";\n "),"padding"===r&&"padding-right: ".concat(o,"px ").concat(i,";")].filter(Boolean).join(""),"\n }\n \n .").concat(Yl," {\n right: ").concat(o,"px ").concat(i,";\n }\n \n .").concat(Kl," {\n margin-right: ").concat(o,"px ").concat(i,";\n }\n \n .").concat(Yl," .").concat(Yl," {\n right: 0 ").concat(i,";\n }\n \n .").concat(Kl," .").concat(Kl," {\n margin-right: 0 ").concat(i,";\n }\n \n body[").concat(uc,"] {\n ").concat("--removed-body-scroll-bar-size",": ").concat(o,"px;\n }\n")},fc=function(){var e=parseInt(document.body.getAttribute(uc)||"0",10);return isFinite(e)?e:0},pc=function(t){var r=t.noRelative,i=t.noImportant,n=t.gapMode,s=void 0===n?"margin":n;e.useEffect(function(){return document.body.setAttribute(uc,(fc()+1).toString()),function(){var e=fc()-1;e<=0?document.body.removeAttribute(uc):document.body.setAttribute(uc,e.toString())}},[]);var a=e.useMemo(function(){return cc(s)},[s]);return e.createElement(dc,{styles:hc(a,!r,s,i?"":"!important")})},mc=!1;if("undefined"!=typeof window)try{var gc=Object.defineProperty({},"passive",{get:function(){return mc=!0,!0}});window.addEventListener("test",gc,gc),window.removeEventListener("test",gc,gc)}catch(e){mc=!1}var vc=!!mc&&{passive:!1},yc=function(e,t){if(!(e instanceof Element))return!1;var r=window.getComputedStyle(e);return"hidden"!==r[t]&&!(r.overflowY===r.overflowX&&!function(e){return"TEXTAREA"===e.tagName}(e)&&"visible"===r[t])},bc=function(e,t){var r=t.ownerDocument,i=t;do{if("undefined"!=typeof ShadowRoot&&i instanceof ShadowRoot&&(i=i.host),Ec(e,i)){var n=wc(e,i);if(n[1]>n[2])return!0}i=i.parentNode}while(i&&i!==r.body);return!1},Ec=function(e,t){return"v"===e?function(e){return yc(e,"overflowY")}(t):function(e){return yc(e,"overflowX")}(t)},wc=function(e,t){return"v"===e?[(r=t).scrollTop,r.scrollHeight,r.clientHeight]:function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]}(t);var r},Sc=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Tc=function(e){return[e.deltaX,e.deltaY]},xc=function(e){return e&&"current"in e?e.current:e},Ac=function(e){return"\n .block-interactivity-".concat(e," {pointer-events: none;}\n .allow-interactivity-").concat(e," {pointer-events: all;}\n")},kc=0,Ic=[];function Lc(e){for(var t=null;null!==e;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var Rc,Pc=(Rc=function(t){var r=e.useRef([]),i=e.useRef([0,0]),n=e.useRef(),s=e.useState(kc++)[0],a=e.useState(ac)[0],o=e.useRef(t);e.useEffect(function(){o.current=t},[t]),e.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(s));var e=function(e,t,r){if(r||2===arguments.length)for(var i,n=0,s=t.length;n<s;n++)!i&&n in t||(i||(i=Array.prototype.slice.call(t,0,n)),i[n]=t[n]);return e.concat(i||Array.prototype.slice.call(t))}([t.lockRef.current],(t.shards||[]).map(xc),!0).filter(Boolean);return e.forEach(function(e){return e.classList.add("allow-interactivity-".concat(s))}),function(){document.body.classList.remove("block-interactivity-".concat(s)),e.forEach(function(e){return e.classList.remove("allow-interactivity-".concat(s))})}}},[t.inert,t.lockRef.current,t.shards]);var l=e.useCallback(function(e,t){if("touches"in e&&2===e.touches.length||"wheel"===e.type&&e.ctrlKey)return!o.current.allowPinchZoom;var r,s=Sc(e),a=i.current,l="deltaX"in e?e.deltaX:a[0]-s[0],c="deltaY"in e?e.deltaY:a[1]-s[1],d=e.target,u=Math.abs(l)>Math.abs(c)?"h":"v";if("touches"in e&&"h"===u&&"range"===d.type)return!1;var h=bc(u,d);if(!h)return!0;if(h?r=u:(r="v"===u?"h":"v",h=bc(u,d)),!h)return!1;if(!n.current&&"changedTouches"in e&&(l||c)&&(n.current=r),!r)return!0;var f=n.current||r;return function(e,t,r,i,n){var s=function(e,t){return"h"===e&&"rtl"===t?-1:1}(e,window.getComputedStyle(t).direction),a=s*i,o=r.target,l=t.contains(o),c=!1,d=a>0,u=0,h=0;do{if(!o)break;var f=wc(e,o),p=f[0],m=f[1]-f[2]-s*p;(p||m)&&Ec(e,o)&&(u+=m,h+=p);var g=o.parentNode;o=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!l&&o!==document.body||l&&(t.contains(o)||t===o));return d&&(Math.abs(u)<1||!n)?c=!0:d||!(Math.abs(h)<1)&&n||(c=!0),c}(f,t,e,"h"===f?l:c,!0)},[]),c=e.useCallback(function(e){var t=e;if(Ic.length&&Ic[Ic.length-1]===a){var i="deltaY"in t?Tc(t):Sc(t),n=r.current.filter(function(e){return e.name===t.type&&(e.target===t.target||t.target===e.shadowParent)&&function(e,t){return e[0]===t[0]&&e[1]===t[1]}(e.delta,i)})[0];if(n&&n.should)t.cancelable&&t.preventDefault();else if(!n){var s=(o.current.shards||[]).map(xc).filter(Boolean).filter(function(e){return e.contains(t.target)});(s.length>0?l(t,s[0]):!o.current.noIsolation)&&t.cancelable&&t.preventDefault()}}},[]),d=e.useCallback(function(e,t,i,n){var s={name:e,delta:t,target:i,should:n,shadowParent:Lc(i)};r.current.push(s),setTimeout(function(){r.current=r.current.filter(function(e){return e!==s})},1)},[]),u=e.useCallback(function(e){i.current=Sc(e),n.current=void 0},[]),h=e.useCallback(function(e){d(e.type,Tc(e),e.target,l(e,t.lockRef.current))},[]),f=e.useCallback(function(e){d(e.type,Sc(e),e.target,l(e,t.lockRef.current))},[]);e.useEffect(function(){return Ic.push(a),t.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:f}),document.addEventListener("wheel",c,vc),document.addEventListener("touchmove",c,vc),document.addEventListener("touchstart",u,vc),function(){Ic=Ic.filter(function(e){return e!==a}),document.removeEventListener("wheel",c,vc),document.removeEventListener("touchmove",c,vc),document.removeEventListener("touchstart",u,vc)}},[]);var p=t.removeScrollBar,m=t.inert;return e.createElement(e.Fragment,null,m?e.createElement(a,{styles:Ac(s)}):null,p?e.createElement(pc,{noRelative:t.noRelative,gapMode:t.gapMode}):null)},tc.useMedium(Rc),ec),Cc=e.forwardRef(function(t,r){return e.createElement(ic,S({},t,{ref:r,sideCar:Pc}))});Cc.classNames=ic.classNames;var Dc=new WeakMap,_c=new WeakMap,Oc={},Mc=0,Nc=function(e){return e&&(e.host||Nc(e.parentNode))},Fc=function(e,t,r,i){var n=function(e,t){return t.map(function(t){if(e.contains(t))return t;var r=Nc(t);return r&&e.contains(r)?r:(console.error("aria-hidden",t,"in not contained inside",e,". Doing nothing"),null)}).filter(function(e){return Boolean(e)})}(t,Array.isArray(e)?e:[e]);Oc[r]||(Oc[r]=new WeakMap);var s=Oc[r],a=[],o=new Set,l=new Set(n),c=function(e){e&&!o.has(e)&&(o.add(e),c(e.parentNode))};n.forEach(c);var d=function(e){e&&!l.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(o.has(e))d(e);else try{var t=e.getAttribute(i),n=null!==t&&"false"!==t,l=(Dc.get(e)||0)+1,c=(s.get(e)||0)+1;Dc.set(e,l),s.set(e,c),a.push(e),1===l&&n&&_c.set(e,!0),1===c&&e.setAttribute(r,"true"),n||e.setAttribute(i,"true")}catch(t){console.error("aria-hidden: cannot operate on ",e,t)}})};return d(t),o.clear(),Mc++,function(){a.forEach(function(e){var t=Dc.get(e)-1,n=s.get(e)-1;Dc.set(e,t),s.set(e,n),t||(_c.has(e)||e.removeAttribute(i),_c.delete(e)),n||e.removeAttribute(r)}),--Mc||(Dc=new WeakMap,Dc=new WeakMap,_c=new WeakMap,Oc={})}},$c=function(e,t,r){void 0===r&&(r="data-aria-hidden");var i=Array.from(Array.isArray(e)?e:[e]),n=function(e){return"undefined"==typeof document?null:(Array.isArray(e)?e[0]:e).ownerDocument.body}(e);return n?(i.push.apply(i,Array.from(n.querySelectorAll("[aria-live], script"))),Fc(i,n,r,"aria-hidden")):function(){return null}},Bc="Dialog",[Uc,zc]=function(t,r=[]){let i=[];const n=()=>{const r=i.map(t=>e.createContext(t));return function(i){const n=i?.[t]||r;return e.useMemo(()=>({[`__scope${t}`]:{...i,[t]:n}}),[i,n])}};return n.scopeName=t,[function(r,n){const s=e.createContext(n),a=i.length;i=[...i,n];const o=r=>{const{scope:i,children:n,...o}=r,l=i?.[t]?.[a]||s,c=e.useMemo(()=>o,Object.values(o));return b(l.Provider,{value:c,children:n})};return o.displayName=r+"Provider",[o,function(i,o){const l=o?.[t]?.[a]||s,c=e.useContext(l);if(c)return c;if(void 0!==n)return n;throw new Error(`\`${i}\` must be used within \`${r}\``)}]},dl(n,...r)]}(Bc),[Gc,jc]=Uc(Bc),Hc=t=>{const{__scopeDialog:r,children:i,open:n,defaultOpen:s,onOpenChange:a,modal:o=!0}=t,l=e.useRef(null),c=e.useRef(null),[d,u]=gl({prop:n,defaultProp:s??!1,onChange:a,caller:Bc});return b(Gc,{scope:r,triggerRef:l,contentRef:c,contentId:pl(),titleId:pl(),descriptionId:pl(),open:d,onOpenChange:u,onOpenToggle:e.useCallback(()=>u(e=>!e),[u]),modal:o,children:i})};Hc.displayName=Bc;var Vc="DialogTrigger";e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=jc(Vc,r),s=cl(t,n.triggerRef);return b(Sl.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":ud(n.open),...i,ref:s,onClick:al(e.onClick,n.onOpenToggle)})}).displayName=Vc;var Wc="DialogPortal",[Yc,Kc]=Uc(Wc,{forceMount:void 0}),qc=t=>{const{__scopeDialog:r,forceMount:i,children:n,container:s}=t,a=jc(Wc,r);return b(Yc,{scope:r,forceMount:i,children:e.Children.map(n,e=>b(jl,{present:i||a.open,children:b(Gl,{asChild:!0,container:s,children:e})}))})};qc.displayName=Wc;var Xc="DialogOverlay",Qc=e.forwardRef((e,t)=>{const r=Kc(Xc,e.__scopeDialog),{forceMount:i=r.forceMount,...n}=e,s=jc(Xc,e.__scopeDialog);return s.modal?b(jl,{present:i||s.open,children:b(Jc,{...n,ref:t})}):null});Qc.displayName=Xc;var Zc=yl("DialogOverlay.RemoveScroll"),Jc=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=jc(Xc,r);return b(Cc,{as:Zc,allowPinchZoom:!0,shards:[n.contentRef],children:b(Sl.div,{"data-state":ud(n.open),...i,ref:t,style:{pointerEvents:"auto",...i.style}})})}),ed="DialogContent",td=e.forwardRef((e,t)=>{const r=Kc(ed,e.__scopeDialog),{forceMount:i=r.forceMount,...n}=e,s=jc(ed,e.__scopeDialog);return b(jl,{present:i||s.open,children:s.modal?b(rd,{...n,ref:t}):b(id,{...n,ref:t})})});td.displayName=ed;var rd=e.forwardRef((t,r)=>{const i=jc(ed,t.__scopeDialog),n=e.useRef(null),s=cl(r,i.contentRef,n);return e.useEffect(()=>{const e=n.current;if(e)return $c(e)},[]),b(nd,{...t,ref:s,trapFocus:i.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:al(t.onCloseAutoFocus,e=>{e.preventDefault(),i.triggerRef.current?.focus()}),onPointerDownOutside:al(t.onPointerDownOutside,e=>{const t=e.detail.originalEvent,r=0===t.button&&!0===t.ctrlKey;(2===t.button||r)&&e.preventDefault()}),onFocusOutside:al(t.onFocusOutside,e=>e.preventDefault())})}),id=e.forwardRef((t,r)=>{const i=jc(ed,t.__scopeDialog),n=e.useRef(!1),s=e.useRef(!1);return b(nd,{...t,ref:r,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:e=>{t.onCloseAutoFocus?.(e),e.defaultPrevented||(n.current||i.triggerRef.current?.focus(),e.preventDefault()),n.current=!1,s.current=!1},onInteractOutside:e=>{t.onInteractOutside?.(e),e.defaultPrevented||(n.current=!0,"pointerdown"===e.detail.originalEvent.type&&(s.current=!0));const r=e.target,a=i.triggerRef.current?.contains(r);a&&e.preventDefault(),"focusin"===e.detail.originalEvent.type&&s.current&&e.preventDefault()}})}),nd=e.forwardRef((t,r)=>{const{__scopeDialog:i,trapFocus:n,onOpenAutoFocus:s,onCloseAutoFocus:a,...o}=t,l=jc(ed,i),c=e.useRef(null),d=cl(r,c);return e.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Wl()),document.body.insertAdjacentElement("beforeend",e[1]??Wl()),Vl++,()=>{1===Vl&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),Vl--}},[]),w(E,{children:[b(Ml,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:s,onUnmountAutoFocus:a,children:b(Rl,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":ud(l.open),...o,ref:d,onDismiss:()=>l.onOpenChange(!1)})}),w(E,{children:[b(md,{titleId:l.titleId}),b(gd,{contentRef:c,descriptionId:l.descriptionId})]})]})}),sd="DialogTitle",ad=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=jc(sd,r);return b(Sl.h2,{id:n.titleId,...i,ref:t})});ad.displayName=sd;var od="DialogDescription",ld=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=jc(od,r);return b(Sl.p,{id:n.descriptionId,...i,ref:t})});ld.displayName=od;var cd="DialogClose",dd=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=jc(cd,r);return b(Sl.button,{type:"button",...i,ref:t,onClick:al(e.onClick,()=>n.onOpenChange(!1))})});function ud(e){return e?"open":"closed"}dd.displayName=cd;var hd="DialogTitleWarning",[fd,pd]=function(t,r){const i=e.createContext(r),n=t=>{const{children:r,...n}=t,s=e.useMemo(()=>n,Object.values(n));return b(i.Provider,{value:s,children:r})};return n.displayName=t+"Provider",[n,function(n){const s=e.useContext(i);if(s)return s;if(void 0!==r)return r;throw new Error(`\`${n}\` must be used within \`${t}\``)}]}(hd,{contentName:ed,titleName:sd,docsSlug:"dialog"}),md=({titleId:t})=>{const r=pd(hd),i=`\`${r.contentName}\` requires a \`${r.titleName}\` for the component to be accessible for screen reader users.\n\nIf you want to hide the \`${r.titleName}\`, you can wrap it with our VisuallyHidden component.\n\nFor more information, see https://radix-ui.com/primitives/docs/components/${r.docsSlug}`;return e.useEffect(()=>{if(t){document.getElementById(t)||console.error(i)}},[i,t]),null},gd=({contentRef:t,descriptionId:r})=>{const i=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${pd("DialogDescriptionWarning").contentName}}.`;return e.useEffect(()=>{const e=t.current?.getAttribute("aria-describedby");if(r&&e){document.getElementById(r)||console.warn(i)}},[i,t,r]),null},vd=Hc,yd=qc,bd=Qc,Ed=td,wd=ad,Sd=dd;function Td(t){return e.createElement(vd,Object.assign({"data-slot":"dialog"},t))}function xd(t){var r=T(t,[]);return e.createElement(yd,Object.assign({"data-slot":"dialog-portal"},r))}function Ad(t){var{className:r}=t,i=T(t,["className"]);return e.createElement(bd,Object.assign({"data-slot":"dialog-overlay",className:St("fixed inset-0 z-50 bg-black/50",r)},i))}function kd(t){var{className:r,children:i,showCloseButton:n=!0,container:s}=t,a=T(t,["className","children","showCloseButton","container"]);return e.createElement(xd,{"data-slot":"dialog-portal",container:s},e.createElement(Ad,null),e.createElement(Ed,Object.assign({"data-slot":"dialog-content",style:{left:"50%",top:"50%",transform:"translate(-50%, -50%)",outline:"none"},className:St("fixed","z-50 grid w-full max-w-lg sm:mx-0 gap-4 p-6",r)},a),i,n&&e.createElement(Sd,{"data-slot":"dialog-close",style:{right:"calc(var(--spacing) * 4)",top:"calc(var(--spacing) * 4)",outline:"none"},className:St("absolute right-4 top-4 rounded opacity-70 transition-opacity","hover:opacity-100 focus:outline-none","focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:ring-offset-background","disabled:pointer-events-none"),"aria-label":"Close"},e.createElement(gi,{className:"h-4 w-4 pointer-events-none shrink-0",style:{height:"calc(var(--spacing) * 4)",width:"calc(var(--spacing) * 4)"}}))))}function Id(t){var{className:r}=t,i=T(t,["className"]);return e.createElement("div",Object.assign({"data-slot":"dialog-header",className:St("flex flex-col gap-2 text-left",r)},i))}function Ld(t){var{className:r}=t,i=T(t,["className"]);return e.createElement(wd,Object.assign({"data-slot":"dialog-title",className:St("text-lg leading-none font-semibold",r)},i))}function Rd({title:e,children:r,contentClassName:i,hideCloseButton:n=!1,portalContainer:s,description:a,autoFocusOnOpen:o=!0}){const{open:l,setOpen:c}=$o();return t.createElement(Td,{open:l,onOpenChange:c},t.createElement(kd,{container:s,className:i,showCloseButton:!n,onOpenAutoFocus:o?void 0:e=>{var t;e.preventDefault(),null===(t=e.currentTarget)||void 0===t||t.focus()}},e&&t.createElement(Id,null,t.createElement(Ld,{style:{color:"#494949"}},e||""),t.createElement(ld,{style:{color:"#5e5e5e",fontSize:"12.5px"}},a||"")),r))}const Pd=({widgetPlayerOption:e,setCollectionUuid:a,portalContainer:o})=>{const{PLAYER_BASE_URL:l}=gt(),{player:c}=e,[d,u]=s(null),{collection:h}=Wo(),{isPreview:f}=ar(),{onSlideChange:p,onCollectionClose:m}=Yo(d,u),g=r(null),v=r(new Set),y=n(e=>{f||h&&(v.current.has(e)||(v.current.add(e),Ut({contentId:e,uuid:Lt(),type:wt.SHORTS,userId:h.userId,isFirstPlay:!Rt(e)}).catch(e=>console.error("Error joining shorts PV:",e))))},[f,h]);i(()=>{if(f)return;if(!h)return;if(g.current===h.colId)return;g.current=h.colId;const e=Lt();a(e),Ut({contentId:h.colId,uuid:e,type:wt.COLLECTION,userId:h.userId,isFirstPlay:!Pt(h.colId)}).catch(e=>console.error("Error joining collection PV:",e))},[f,null==h?void 0:h.colId]);const{setOpen:b,open:E}=$o();i(()=>{E||(d&&(m(),u(null)),w&&S(null))},[E]);const[w,S]=s();return t.createElement(t.Fragment,null,h&&t.createElement(il,Object.assign({collection:h},e,{onThumbnailClick:e=>x(void 0,void 0,void 0,function*(){if(c===$e.POPUP){const t=Lt();if(u(Object.assign(Object.assign({},h.contents.find(t=>t.shortsId===e)),{uuid:t})),b(!0),f)return;try{yield Ut({contentId:e,uuid:t,type:wt.SHORTS,userId:h.userId,isFirstPlay:!Pt(e)})}catch(e){console.error("Error joining shorts PV:",e)}}else{const t=(e=>{switch(e){case $e.HORIZONTAL:return Ue.HORIZONTAL;case $e.VERTICAL:return Ue.VERTICAL;case $e.GRID:return Ue.PRODUCTS;case $e.TABLET:return Ue.TABLET;default:return Ue.PLATFORM}})(c),r=null==h?void 0:h.contents.findIndex(t=>t.shortsId===e);let i="";r&&(i=(null==h?void 0:h.contents[r-1].shortsId)||"");const n=new URLSearchParams(Object.assign(Object.assign({},i&&{nextKey:i}),{layout:String(t)}));open(`${l}/collection/${h.colId}?${n.toString()}`)}}),onPreviewPlay:y,setSelectedProducts:S})),w&&t.createElement(Rd,{portalContainer:o,title:"상품 목록",contentClassName:"p-4 product-dialog-container product-dialog--list",description:"연결된 전체 상품 정보를 확인해 보세요",autoFocusOnOpen:!1},t.createElement("div",{className:"product-dialog__scroll"},t.createElement(bo,{products:w.productsInfo,contentId:w.shortsId,singleColumn:!0,sheet:!0,isPreview:f,showPrice:!0}))),h&&d&&t.createElement(Rd,{portalContainer:o,hideCloseButton:!0,contentClassName:"w-full max-w-none p-0 mx-0"},t.createElement(Qo,{collection:h,initialShortsId:d.shortsId,onClosePlayer:()=>{b(!1)},onSlideChange:p})))};const Cd=e=>{const{collectionId:r,isPreview:n,priceText:s,memberOnly:a,container:o}=e,{setIsPreview:l,setPriceText:c,setMemberOnly:d,setIsMemberLoggedIn:u}=ar(),{setCollection:h,setNextKey:f,collection:p}=Wo();i(()=>{s&&c(s);const e=Boolean(n);e&&l(e),a&&(d(!0),u(Boolean(window.MEMBER_UID)))},[]),i(()=>{x(void 0,void 0,void 0,function*(){var e;const t=yield Vt({collectionId:r,size:10});if(!t)return;const{contents:i,count:n}=t;(null==i?void 0:i.length)&&f(null===(e=i.at(-1))||void 0===e?void 0:e.shortsId),h(Object.assign(Object.assign({},t),{count:n}))})},[r]);const m=function(e){var t,r,i,n,s,a,o,l,c,d,u,h;const f=null!==(t=e.iconForm)&&void 0!==t?t:Me.INSTA,p={collectionId:e.collectionId,iconForm:f,iconShape:null!==(r=e.iconShape)&&void 0!==r?r:Ne.MANY,iconSize:null!==(i=e.iconSize)&&void 0!==i?i:120,borderLine:null!==(n=e.borderLine)&&void 0!==n?n:Fe.DAY,exposeTitle:null===(s=e.exposeTitle)||void 0===s||s,player:null!==(a=e.player)&&void 0!==a?a:$e.POPUP,rounded:null===(o=e.rounded)||void 0===o||o,titlePosition:null!==(l=e.titlePosition)&&void 0!==l?l:Be.BOTTOM,exposeProductBanner:null!==(c=e.exposeProductBanner)&&void 0!==c&&c,exposeProductBadge:null!==(d=e.exposeProductBadge)&&void 0!==d&&d,priceText:e.priceText||"할인가",hoverPlay:null!==(u=e.hoverPlay)&&void 0!==u&&u,thumbnailAutoPlay:null!==(h=e.thumbnailAutoPlay)&&void 0!==h&&h};return f===Me.YOUTUBE?Object.assign(Object.assign({},p),{iconForm:Me.YOUTUBE,iconRatio:e.iconRatio||"9/16"}):Object.assign(Object.assign({},p),{iconForm:Me.INSTA})}(e),{containerRef:g}=function({collectionId:e,iconSize:r}){const{collection:i,setCollection:n,nextKey:s,setNextKey:a,isFetching:o,setIsFetching:l}=Wo(),c=t.useRef(null),[d,u]=t.useState(0);return t.useEffect(()=>{if(!c.current)return;const e=new ResizeObserver(e=>{var t,r,i;const n=null!==(i=null===(r=null===(t=e[0])||void 0===t?void 0:t.contentRect)||void 0===r?void 0:r.width)&&void 0!==i?i:0;u(n)});return e.observe(c.current),()=>e.disconnect()},[]),t.useEffect(()=>{var e;if(!i||!i.contents)return;const t=Math.max(1,r+12),c=Math.ceil((d||0)/t)+4,u=null!==(e=i.count)&&void 0!==e?e:Number.MAX_SAFE_INTEGER,h=Math.min(u,c);if(i.contents.length>=h||o)return;let f=!1;return(()=>{x(this,void 0,void 0,function*(){var e,t,r,o,c;try{l(!0);let d=i,u=s||(null===(e=d.contents.at(-1))||void 0===e?void 0:e.shortsId)||void 0;const p=new Set(d.contents.map(e=>e.shortsId));for(;!f&&d.contents.length<h;){const e=Math.max(6,h-d.contents.length),i=yield Vt({collectionId:d.colId,nextKey:u,size:e});if(!i||!(null===(t=i.contents)||void 0===t?void 0:t.length))break;u=null!==(o=null===(r=i.contents.at(-1))||void 0===r?void 0:r.shortsId)&&void 0!==o?o:u;const s=i.contents.filter(e=>!p.has(e.shortsId));if(!s.length)break;if(s.forEach(e=>p.add(e.shortsId)),d=Object.assign(Object.assign({},d),{contents:[...d.contents,...s]}),n(d),a(u||""),d.contents.length>=(null!==(c=d.count)&&void 0!==c?c:Number.MAX_SAFE_INTEGER))break}}finally{l(!1)}})})(),()=>{f=!0}},[null==i?void 0:i.colId,null==i?void 0:i.count,null==i?void 0:i.contents.length,d,r,o,s,n,l,a]),{containerRef:c}}({collectionId:r,iconSize:m.iconSize});return t.createElement(qr.div,null,t.createElement(Fo,null),t.createElement("div",{ref:g},t.createElement(Pd,{widgetPlayerOption:m,setCollectionUuid:e=>{h(Object.assign(Object.assign({},p),{uuid:e}))},portalContainer:o})))},Dd=e=>{const{container:r}=Bo();return r?t.createElement(Vo,null,t.createElement(Cd,Object.assign({},e,{container:r}))):null},_d=({products:e,stack:r})=>r&&e.length>1?t.createElement("span",{className:"sc-stack","aria-hidden":!0},e.slice(0,3).map(e=>t.createElement("img",{key:e.productId,src:Dt(e.thumbPath),alt:""}))):t.createElement("img",{className:"sc-thumb",src:Dt(e[0].thumbPath),alt:e[0].productName}),Od=({name:e,count:r})=>{const i=t.useRef(null),[n,s]=t.useState(e);return t.useLayoutEffect(()=>{const t=i.current,n=null==t?void 0:t.parentElement;if(!t||!n)return;const a=()=>{const i=t.clientWidth;if(i<=0)return;const a=document.createElement("span");a.className="sc-name sc-name--measure",a.style.width=`${i}px`;const o=document.createElement("span");o.className="sc-product-name";const l=document.createElement("span");l.className="sc-count",l.textContent=`외 ${r-1}개`,a.append(o,l),n.appendChild(a);const c=Number.parseFloat(getComputedStyle(a).lineHeight),d=e=>(o.textContent=e,a.scrollHeight<=2*c+.5);let u=e;if(!d(e)){const t=Array.from(e);let r=0,i=t.length;for(;r<i;){const e=Math.ceil((r+i)/2);d(`${t.slice(0,e).join("")}…`)?r=e:i=e-1}u=`${t.slice(0,r).join("")}…`}a.remove(),s(e=>e===u?e:u)};if(a(),"undefined"==typeof ResizeObserver)return;const o=new ResizeObserver(a);return o.observe(t),()=>o.disconnect()},[r,e]),t.createElement("span",{ref:i,className:"sc-name",title:e,"aria-label":`${e} 외 ${r-1}개`},t.createElement("span",{className:"sc-product-name"},n),t.createElement("span",{className:"sc-count"},"외 ",r-1,"개"))},Md=({rep:e,count:r,showPrice:i,isGlass:n})=>t.createElement("span",{className:"sc-body"},n&&r>1?t.createElement(Od,{name:e.productName,count:r}):t.createElement("span",{className:"sc-name"},e.productName,r>1&&t.createElement("span",{className:"sc-count"}," 외 ",r-1,"개")),i?t.createElement("span",{className:"sc-price"},e.discount>0&&t.createElement("span",{className:"off"},e.discount,"%"),t.createElement("span",{className:"amt"},Tt(e.sellingPrice,e.currency))):t.createElement(t.Fragment,null)),Nd=({products:e,contentId:r,variant:i,showPrice:n,isPreview:s=!1,onOpenList:a})=>{var o;const l=e[0],c=e.length>1,d=t.createElement(t.Fragment,null,t.createElement(_d,{products:e,stack:"clean"===i}),t.createElement(Md,{rep:l,count:e.length,showPrice:n,isGlass:"glass"===i})),u="glass"===i?"sc-glass-card":"sc-info sc-info--clean",h=c?t.createElement("div",{className:u,role:"button",tabIndex:0,onClick:a,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),a())}},d):t.createElement("a",{className:`${u} apphref`,href:null!==(o=l.linkPath)&&void 0!==o?o:void 0,target:"_blank",rel:"noopener noreferrer",onClick:()=>{s||Gt({contentProductId:l.eventProductId,contentId:r,productId:l.productId})}},d);return h},Fd=e=>{e.forEach(e=>{const t=Math.max(0,Math.floor((Date.now()-e.startedAt)/1e3));zt({contentId:e.contentId,uuid:e.uuid,type:wt.SHORTS,userId:e.userId,playtime:t,isFinished:e.duration>0&&t>=e.duration})}),e.clear()},$d=({portalContainer:e,aspectRatio:n,productPosition:a="below",showPrice:o=!1,showTitle:l,rounded:c=!0,isPreview:d=!1})=>{var u;const{collection:h}=Wo(),[f,p]=s(),{open:m,setOpen:g}=$o(),v=r(new Map);i(()=>{Fd(v.current)},[null==h?void 0:h.colId]),i(()=>{d&&Fd(v.current)},[d]),i(()=>()=>Fd(v.current),[]),i(()=>{!m&&f&&p(null)},[m,f]);const y=(e,t)=>{p({productsInfo:e,shortsId:t}),g(!0)},b=null!==(u=yo().width)&&void 0!==u?u:0,E=r(null),[w,S]=s(0),T=b<480?2:b<768?3:b<1024?4:5,x="overlay"===a,A=null!=l?l:x,k=Math.max(1,Math.floor((w+16)/236)),I=x?Math.min(T,k):T;return i(()=>{const e=E.current;if(!e)return;const t=()=>S(e.clientWidth);t();const r=new ResizeObserver(t);return r.observe(e),()=>r.disconnect()},[]),t.createElement(t.Fragment,null,t.createElement("div",{ref:E,className:"grid gap-4",style:{gridTemplateColumns:`repeat(${I}, minmax(0, 1fr))`}},null==h?void 0:h.contents.map(e=>{var r;const i=(null===(r=e.productsInfo)||void 0===r?void 0:r.length)>0;return t.createElement("div",{key:e.shortsId},t.createElement("div",{className:"overflow-hidden relative bg-black",style:{borderRadius:c?"15px":0,aspectRatio:null!=n?n:"9/16",boxShadow:"0 1px 2px rgba(0,0,0,0.06), 0 8px 22px rgba(0,0,0,0.08)"}},t.createElement("video",{loop:!0,className:"w-full h-full object-cover",muted:!0,autoPlay:!0,playsInline:!0,src:xt(e.media.objectId),poster:Dt(e.thumbPath),onPlay:()=>{var t;return((e,t,r)=>{if(d||v.current.has(e))return;const i={contentId:e,uuid:Lt(),userId:t,startedAt:Date.now(),duration:At(r)};v.current.set(e,i),Ut({contentId:e,uuid:i.uuid,type:wt.SHORTS,userId:t,isFirstPlay:!Pt(e)})})(e.shortsId,null!==(t=e.userId)&&void 0!==t?t:h.userId,e.media.duration)}}),!x&&A&&e.title&&t.createElement("div",{className:"sc-media-title-overlay"},t.createElement("p",{className:"sc-media-title"},e.title)),x&&(A||i)&&t.createElement("div",{className:"sc-overlay"},A&&e.title&&t.createElement("p",{className:"sc-title"},e.title),i&&t.createElement(Nd,{variant:"glass",products:e.productsInfo,contentId:e.shortsId,showPrice:o,isPreview:d,onOpenList:()=>y(e.productsInfo,e.shortsId)}))),!x&&i&&t.createElement(Nd,{variant:"clean",products:e.productsInfo,contentId:e.shortsId,showPrice:o,isPreview:d,onOpenList:()=>y(e.productsInfo,e.shortsId)}))})),f&&t.createElement(Rd,{portalContainer:e,title:"상품 목록",contentClassName:"p-4 product-dialog-container product-dialog--list",description:"연결된 전체 상품 정보를 확인해 보세요",autoFocusOnOpen:!1},t.createElement("div",{className:"product-dialog__scroll"},t.createElement(bo,{products:f.productsInfo,contentId:f.shortsId,showPrice:o,singleColumn:!0,sheet:!0,isPreview:d}))))},Bd=e=>{e.forEach(e=>{const t=Math.max(0,Math.floor((Date.now()-e.startedAt)/1e3));zt({contentId:e.contentId,uuid:e.uuid,type:wt.SHORTS,userId:e.userId,playtime:t,isFinished:e.duration>0&&t>=e.duration})}),e.clear()},Ud=({muted:e,src:n,poster:s,loop:a,onPlay:o,onEnded:l})=>{const c=r(null);return i(()=>{const e=c.current;e&&(e.load(),e.play().catch(()=>{}))},[n]),i(()=>{const e=c.current;e&&a&&e.ended&&(e.currentTime=0,e.play().catch(()=>{}))},[a]),t.createElement("video",{ref:c,loop:a,className:"w-full h-full object-cover",muted:e,autoPlay:!0,playsInline:!0,preload:"auto",src:n,poster:s,onPlay:o,onEnded:l})},zd=({aspectRatio:e,rounded:a=!0,variant:o="spotlight",productBannerType:l="list",productPosition:c="overlay",showTitle:d=!0,showPrice:u=!0,isPreview:h=!1,navigation:f=!0,navigationType:p="overlay",autoplayActiveOnly:m=!1,autoAdvanceOnEnd:g=!1})=>{const{collection:v}=Wo(),[y,b]=s(),[E,w]=s(0),[S,T]=s({}),[x,A]=s(!1),[k,I]=s(!1),[L,R]=s(!1),[P,C]=s(()=>new Set),[D,_]=s(()=>"undefined"==typeof IntersectionObserver),O=r(null),M=r(null),N=r(new Map),F=r(new Set);i(()=>{Bd(N.current),F.current.clear()},[null==v?void 0:v.colId]),i(()=>{h&&Bd(N.current)},[h]),i(()=>()=>Bd(N.current),[]),i(()=>{N.current.forEach(e=>{const t=null==v?void 0:v.contents.findIndex(t=>t.shortsId===e.contentId);(!D||void 0===t||t<0||!P.has(t))&&((e,t)=>{const r=e.get(t);if(!r)return;const i=Math.max(0,Math.floor((Date.now()-r.startedAt)/1e3));zt({contentId:r.contentId,uuid:r.uuid,type:wt.SHORTS,userId:r.userId,playtime:i,isFinished:r.duration>0&&i>=r.duration}),e.delete(t)})(N.current,e.contentId)})},[null==v?void 0:v.contents,D,P]);const $=n(e=>{var t;const r=new Set,i=null!==(t=e.params.slideVisibleClass)&&void 0!==t?t:"swiper-slide-visible";e.slides.forEach(e=>{if(!e.classList.contains(i))return;const t=e.getAttribute("data-swiper-slide-index");if(null===t)return;const n=Number(t);Number.isInteger(n)&&n>=0&&r.add(n)}),C(e=>{return i=r,(t=e).size===i.size&&[...t].every(e=>i.has(e))?e:r;var t,i})},[]),B=n(e=>{const t=f&&!e.isLocked,r=t&&!e.isBeginning,i=t&&!e.isEnd;A(e=>e===r?e:r),I(e=>e===i?e:i)},[f]),U=n(e=>{$(e),B(e)},[B,$]);i(()=>{const e=O.current;if(!e)return;if("undefined"==typeof IntersectionObserver)return void _(!0);const t=new IntersectionObserver(([e])=>_(e.isIntersecting),{root:null,threshold:[0]});return t.observe(e),()=>t.disconnect()},[null==v?void 0:v.colId]),i(()=>{const e=M.current;(null==e?void 0:e.mousewheel)&&(y?e.mousewheel.disable():e.mousewheel.enable())},[y]),i(()=>{b(null)},[l,o]);const z=n((e,t)=>{b({productsInfo:e,shortsId:t})},[]),G=n((e,t,r)=>{if(h||F.current.has(e))return;const i={contentId:e,uuid:Lt(),userId:t,startedAt:Date.now(),duration:At(r)};F.current.add(e),N.current.set(e,i),Ut({contentId:e,uuid:i.uuid,type:wt.SHORTS,userId:t,isFirstPlay:!Pt(e)})},[h]),j=n(()=>{const e=M.current;e&&(e.params.loop||!e.isEnd?e.slideNext():e.slideTo(0))},[]);if(!v)return null;const[H,V]=(null!=e?e:"9/16").split("/").map(Number),W=`max(320px, min(82vw, calc(80vh * ${H&&V?H/V:9/16})))`,Y="spotlight"===o;return t.createElement(t.Fragment,null,t.createElement("div",{ref:O,className:"relative flex items-center w-full"},t.createElement(Pa,{modules:[za,Da],centeredSlides:Y,loop:Y&&v.contents.length>1,spaceBetween:16,slidesPerView:"auto",watchSlidesProgress:!0,mousewheel:!0,allowTouchMove:!y,className:`collection-slider collection-slider--${o} w-full`,onSwiper:e=>{M.current=e,w(e.realIndex),U(e)},onResize:U,onSlidesUpdated:U,onSliderFirstMove:()=>R(!0),onTransitionStart:()=>R(!0),onTransitionEnd:e=>{var t;if(R(!1),w(e.realIndex),U(e),"spotlight"!==o)return;const r=null===(t=v.contents[e.realIndex])||void 0===t?void 0:t.shortsId;b(e=>e&&e.shortsId!==r?null:e)}},v.contents.map((e,r)=>{var i,n,s,f;const p=r===E,w=D&&P.has(r)&&(!m||p),x=(null===(i=e.productsInfo)||void 0===i?void 0:i.length)>0,A=d&&Boolean(e.title),k="below"===c,I=(null==y?void 0:y.shortsId)===e.shortsId&&(!Y||p);return t.createElement(Ca,{key:e.shortsId,virtualIndex:r,className:"collection-slider__slide",style:{width:Y?W:void 0}},t.createElement("div",{className:"relative overflow-hidden bg-black",onClick:()=>(e=>{var t,r;e!==E&&"spotlight"===o&&(v&&v.contents.length>1?null===(t=M.current)||void 0===t||t.slideToLoop(e):null===(r=M.current)||void 0===r||r.slideTo(e))})(r),style:{width:"100%",aspectRatio:`${H||9} / ${V||16}`,borderRadius:a?"15px":0,transform:!Y||p?"scale(1)":"scale(0.78)",transition:"transform 300ms ease",cursor:p?"default":"pointer"}},w?t.createElement(Ud,{muted:null===(n=S[r])||void 0===n||n,src:xt(e.media.objectId),poster:Dt(e.thumbPath),loop:!(g&&p),onPlay:()=>{var t;return G(e.shortsId,null!==(t=e.userId)&&void 0!==t?t:v.userId,e.media.duration)},onEnded:g&&p?j:void 0}):t.createElement("img",{className:"w-full h-full object-cover",src:Dt(e.thumbPath),alt:"",loading:"lazy",draggable:!1}),w&&t.createElement("button",{className:"absolute cursor-pointer text-white",style:{top:10,right:10,zIndex:3},onClick:e=>((e,t)=>{e.stopPropagation(),T(e=>{var r;return Object.assign(Object.assign({},e),{[t]:!(null===(r=e[t])||void 0===r||r)})})})(e,r),"aria-label":null===(s=S[r])||void 0===s||s?"음소거 해제":"음소거"},t.createElement("span",{className:"flex h-9 w-9 items-center justify-center rounded-full bg-black/40"},null===(f=S[r])||void 0===f||f?t.createElement(mi,{size:18}):t.createElement(pi,{size:18}))),k&&A&&t.createElement("div",{className:"sc-media-title-overlay"},t.createElement("p",{className:"sc-media-title"},e.title)),!k&&(A||x)&&t.createElement("div",{className:"absolute inset-x-0 bottom-0",style:{zIndex:2,padding:"12px",background:"linear-gradient(to top, rgba(0,0,0,0.65), rgba(0,0,0,0))"}},A&&t.createElement("p",{className:"line-clamp-2 text-white",style:{marginBottom:"12px",fontSize:"14px",fontWeight:600,lineHeight:1.4,textShadow:"0 1px 3px rgba(0,0,0,0.65)"}},e.title),x&&t.createElement("div",null,t.createElement(go,{products:e.productsInfo,contentId:e.shortsId,height:po,productBannerType:l,showPrice:u,isPreview:h,onOpenSheet:t=>z(t,e.shortsId)}))),I&&t.createElement(Eo,{products:y.productsInfo,contentId:y.shortsId,showPrice:u,isPreview:h,onClose:()=>b(null)})),k&&x&&t.createElement(Nd,{variant:"clean",products:e.productsInfo,contentId:e.shortsId,showPrice:u,isPreview:h,onOpenList:()=>z(e.productsInfo,e.shortsId)}))})),f&&"overlay"===p&&!y&&t.createElement("div",{className:"collection-slider__nav-layer",style:Y?{width:W}:void 0},t.createElement("button",{type:"button",className:"collection-slider__nav collection-slider__nav--prev"+(L||!x?" is-hidden":""),"aria-label":"이전 슬라이드","aria-hidden":L||!x,tabIndex:L||!x?-1:0,disabled:!x,onClick:e=>{var t;e.stopPropagation(),null===(t=M.current)||void 0===t||t.slidePrev()}},t.createElement(ii,{size:20,"aria-hidden":!0})),t.createElement("button",{type:"button",className:"collection-slider__nav collection-slider__nav--next"+(L||!k?" is-hidden":""),"aria-label":"다음 슬라이드","aria-hidden":L||!k,tabIndex:L||!k?-1:0,disabled:!k,onClick:e=>{var t;e.stopPropagation(),null===(t=M.current)||void 0===t||t.slideNext()}},t.createElement(ni,{size:20,"aria-hidden":!0})))),f&&"below"===p&&t.createElement("div",{className:"collection-slider__nav-below",style:Y?{width:W}:void 0},t.createElement("button",{type:"button",className:"collection-slider__nav-btn","aria-label":"이전 슬라이드",disabled:!x,onClick:e=>{var t;e.stopPropagation(),null===(t=M.current)||void 0===t||t.slidePrev()}},t.createElement(ii,{size:20,"aria-hidden":!0})),t.createElement("button",{type:"button",className:"collection-slider__nav-btn","aria-label":"다음 슬라이드",disabled:!k,onClick:e=>{var t;e.stopPropagation(),null===(t=M.current)||void 0===t||t.slideNext()}},t.createElement(ni,{size:20,"aria-hidden":!0}))))},Gd=({collectionId:e,aspectRatio:r,container:n,isPreview:s,layout:a,productBannerType:o,rounded:l,productPosition:c,showPrice:d,showTitle:u,navigation:h,navigationType:f,autoplayActiveOnly:p,autoAdvanceOnEnd:m})=>{const{setCollection:g,setNextKey:v}=Wo();return i(()=>{let t,r=!1;return x(void 0,void 0,void 0,function*(){var i,n;const a=yield Vt({collectionId:e,size:-1});if(!a||r)return;const{contents:o,count:l}=a;(null==o?void 0:o.length)&&v(null===(i=o.at(-1))||void 0===i?void 0:i.shortsId),g(Object.assign(Object.assign({},a),{count:l}));const c=null!==(n=a.colId)&&void 0!==n?n:e;s||(t={contentId:c,uuid:Lt(),userId:a.userId,startedAt:Date.now()},Ut({contentId:t.contentId,uuid:t.uuid,type:wt.COLLECTION,userId:t.userId,isFirstPlay:!Pt(t.contentId)}))}),()=>{r=!0,t&&zt({contentId:t.contentId,uuid:t.uuid,type:wt.COLLECTION,userId:t.userId,playtime:Math.max(0,Math.floor((Date.now()-t.startedAt)/1e3))})}},[e,s,g,v]),t.createElement(qr.div,null,t.createElement(Fo,null),"spotlight"===a||"carousel"===a?t.createElement(zd,{portalContainer:n,aspectRatio:r,rounded:l,variant:a,productBannerType:o,productPosition:c,showPrice:d,showTitle:u,isPreview:s,navigation:h,navigationType:f,autoplayActiveOnly:p,autoAdvanceOnEnd:m}):t.createElement($d,{portalContainer:n,aspectRatio:r,productPosition:c,showPrice:d,showTitle:u,rounded:l,isPreview:s}))},jd=e=>{const{container:r}=Bo();return r?t.createElement(Vo,null,t.createElement(Gd,Object.assign({},e,{container:r}))):null},Hd=sr(e=>({shortform:null,setShortform:t=>e({shortform:t})})),Vd=({shortform:e,setClose:r,compact:n=!1})=>{const[a,o]=t.useState(!0),[l,c]=s(!0),[d,u]=s(!1),h=t.useRef(null),f=()=>{h.current&&(window.clearTimeout(h.current),h.current=null)},p=(e=1500)=>{f(),h.current=window.setTimeout(()=>u(!1),e)};return i(()=>()=>f(),[]),t.createElement("div",{className:"relative w-full h-full",onClick:()=>{u(!0),p(2e3)},onMouseLeave:()=>p(800),onMouseEnter:()=>d&&p(1500)},t.createElement("div",{className:"absolute inset-0 bg-black",style:{zIndex:1,opacity:!n&&d?.4:0,transition:"opacity 300ms ease",pointerEvents:!n&&d?"auto":"none"}}),t.createElement("div",{className:"absolute inset-0",style:{zIndex:2,opacity:!n&&d?1:0,transition:"opacity 300ms ease",pointerEvents:!n&&d?"auto":"none"}},t.createElement("div",{className:"absolute text-white flex gap-2",style:{zIndex:3,top:8,right:8}},t.createElement("button",{type:"button",className:"cursor-pointer",onClick:e=>{e.stopPropagation(),o(e=>!e)},"aria-label":a?"음소거 해제":"음소거"},t.createElement("span",{className:"glass-panel flex items-center justify-center rounded-full"},a?t.createElement(mi,null):t.createElement(pi,null))),t.createElement("button",{type:"button",className:"cursor-pointer",onClick:e=>{null==e||e.stopPropagation(),r()},"aria-label":"닫기"},t.createElement("span",{className:"glass-panel flex items-center justify-center rounded-full"},t.createElement(gi,null)))),t.createElement("div",{className:"absolute inset-0 flex items-center justify-center",style:{pointerEvents:"none"}},t.createElement("button",{type:"button",onClick:e=>{null==e||e.stopPropagation(),c(e=>!e)},"aria-label":l?"일시정지":"재생",className:"cursor-pointer text-white",style:{pointerEvents:!n&&d?"auto":"none"}},t.createElement("span",{className:"glass-panel flex items-center justify-center rounded-full"},l?t.createElement(ui,null):t.createElement(hi,null))))),t.createElement(or,{shortform:e,mute:a,play:l,trackStatistics:!1}))},Wd={small:{width:160,height:284},large:{width:240,height:427}},Yd=2147483647,Kd=({size:e,pcInitialWidth:t,mobileInitialWidth:r})=>{const i="small"===e?r:t;return"number"==typeof i&&Number.isFinite(i)&&i>0?{width:i,height:Math.round(16*i/9)}:Wd[e]},qd=({shortsId:e,type:r,isPreview:i,productBannerType:n="list",like:a=!0,share:o=!0,horizontalPosition:l="right",verticalPosition:c="bottom",horizontalOffset:d=50,verticalOffset:u=50,initialSize:h,pcInitialWidth:f,mobileInitialWidth:p,cornerStyle:m="square"})=>{const{shortform:g}=Hd(),[v,y]=s(!1),[b,E]=s(()=>window.innerWidth<=430?"small":null!=h?h:"large"),{playtime:w}=Ft(!v),{leave:S}=Jt({shortform:g,playtime:w,enabled:!v&&!i}),T=()=>{g&&(y(!0),S())},x=Kd({size:b,pcInitialWidth:f,mobileInitialWidth:p}),A="large"===b&&"shopping"===r&&Boolean(null==g?void 0:g.productsInfo.length);return g&&!v&&t.createElement("div",{className:"floating-player "+(A?"floating-player--expanded-shopping":""),style:{position:"fixed",width:x.width,height:x.height,left:"left"===l?d:void 0,right:"right"===l?d:void 0,top:"top"===c?u:void 0,bottom:"bottom"===c?u:void 0,zIndex:Yd,borderRadius:"rounded"===m?16:0,overflow:"hidden"}},t.createElement("div",{className:"relative h-full w-full overflow-hidden bg-black"},"shopping"===r&&g.productsInfo.length>0?t.createElement(So,{shortForm:g,handleClose:T,trackStatistics:!1,isPreview:i,hideOverlay:"small"===b,hideProductCarousel:"small"===b,productBannerHeight:60,productBannerType:n,like:a,share:o}):t.createElement(Vd,{shortform:g,setClose:T,compact:"small"===b}),t.createElement("button",{type:"button",onClick:e=>{e.stopPropagation(),E(e=>"small"===e?"large":"small")},className:"small"===b?"absolute inset-0 flex cursor-pointer items-start justify-end p-3 text-white":"absolute left-3 top-3 cursor-pointer text-white",style:{zIndex:10},"aria-label":"small"===b?"플레이어 펼치기":"플레이어 접기"},t.createElement("span",{className:"glass-panel flex items-center justify-center rounded-full"},"small"===b?t.createElement(ci,null):t.createElement(di,null)))))},Xd=({shortsId:e,type:r,isPreview:n,productBannerType:s="list",like:a=!0,share:o=!0,horizontalPosition:l,verticalPosition:c,horizontalOffset:d,verticalOffset:u,initialSize:h,pcInitialWidth:f,mobileInitialWidth:p,cornerStyle:m})=>{const{setShortform:g,shortform:v}=Hd();return i(()=>{if(!e)return;let t=!1;return e&&x(void 0,void 0,void 0,function*(){const r=yield Wt(e,n);r&&!t&&g(Object.assign(Object.assign({},r),{uuid:Lt()}))}),()=>{t=!0}},[e,n,g]),v?t.createElement(qr.div,{style:{position:"fixed",inset:0,pointerEvents:"none",zIndex:Yd}},t.createElement(Fo,null),t.createElement("div",{style:{pointerEvents:"auto"}},t.createElement(qd,{shortsId:e,type:r,isPreview:n,productBannerType:s,like:a,share:o,horizontalPosition:l,verticalPosition:c,horizontalOffset:d,verticalOffset:u,initialSize:h,pcInitialWidth:f,mobileInitialWidth:p,cornerStyle:m}))):null},Qd=({navigation:e,like:i,share:n,isPreview:a,productBannerType:o="list",horizontalPosition:l="right",verticalPosition:c="bottom",horizontalOffset:d=50,verticalOffset:u=50,initialSize:h,pcInitialWidth:f,mobileInitialWidth:p,cornerStyle:m="square"})=>{var g,v;const{collection:y}=Wo(),[b,E]=s(!1),[w,S]=s(!1),[T,x]=s(null!==(v=null===(g=null==y?void 0:y.contents)||void 0===g?void 0:g[0])&&void 0!==v?v:null),[A,k]=s(()=>window.innerWidth<=430?"small":null!=h?h:"large"),I=r(null),{onSlideChange:L,onCollectionClose:R}=Yo(T,x,a);if(!y||b)return null;const P=()=>{R(),E(!0)},C=Kd({size:A,pcInitialWidth:f,mobileInitialWidth:p}),D="small"===A;return t.createElement("div",{className:"floating-collection-player",style:{position:"fixed",width:C.width,height:C.height,left:"left"===l?d:void 0,right:"right"===l?d:void 0,top:"top"===c?u:void 0,bottom:"bottom"===c?u:void 0,zIndex:Yd,borderRadius:"rounded"===m?16:0,overflow:"hidden"}},t.createElement("div",{className:"relative h-full w-full overflow-hidden bg-black"},t.createElement(Pa,{direction:"vertical",slidesPerView:1,loop:y.contents.length>1,mousewheel:!0,modules:[Da,za],ref:I,allowTouchMove:!D,className:"h-full w-full",onSlideChange:e=>{const t=y.contents[e.realIndex];t&&(x(t),L(e.realIndex))}},y.contents.map(e=>t.createElement(Ca,{key:e.shortsId},t.createElement("div",{className:"relative w-full h-full"},(null==T?void 0:T.shortsId)===e.shortsId&&t.createElement("div",{className:"absolute inset-0 z-[10]"},t.createElement(So,{shortForm:T,trackStatistics:!1,isPreview:a,productBannerHeight:64,productBannerType:o,handleClose:P,like:i,share:n,hideOverlay:D,hideProductCarousel:D,onProductSheetOpenChange:S})),t.createElement("img",{src:Dt(e.thumbPath),alt:e.title,className:"w-full h-full object-cover"}))))),e&&!D&&!w&&y.contents.length>1&&t.createElement("div",{className:"absolute left-4 top-1/2 -translate-y-1/2 z-[20] flex flex-col gap-2"},t.createElement("button",{type:"button",className:"cursor-pointer text-white",onClick:e=>{var t;e.stopPropagation(),null===(t=I.current)||void 0===t||t.swiper.slidePrev()},"aria-label":"이전 영상"},t.createElement("div",{className:"glass-panel flex h-9 w-9 items-center justify-center rounded-full bg-black/40"},t.createElement(si,{size:20}))),t.createElement("button",{type:"button",className:"cursor-pointer text-white",onClick:e=>{var t;e.stopPropagation(),null===(t=I.current)||void 0===t||t.swiper.slideNext()},"aria-label":"다음 영상"},t.createElement("div",{className:"glass-panel flex h-9 w-9 items-center justify-center rounded-full bg-black/40"},t.createElement(ri,{size:20})))),t.createElement("button",{type:"button",onClick:e=>{e.stopPropagation(),k(e=>"small"===e?"large":"small")},className:D?"absolute inset-0 flex cursor-pointer items-start justify-end p-3 text-white":"absolute left-3 top-3 cursor-pointer text-white",style:{zIndex:30},"aria-label":D?"플레이어 펼치기":"플레이어 접기"},t.createElement("span",{className:"glass-panel flex items-center justify-center rounded-full"},D?t.createElement(ci,null):t.createElement(di,null)))))},Zd=({collectionId:e,isPreview:n,navigation:s=!0,like:a=!0,share:o=!0,productBannerType:l="list",horizontalPosition:c,verticalPosition:d,horizontalOffset:u,verticalOffset:h,initialSize:f,pcInitialWidth:p,mobileInitialWidth:m,cornerStyle:g})=>{var v;const{collection:y,setCollection:b,setNextKey:E}=Wo(),{setIsPreview:w}=ar(),S=r(new Set),T=r(new Set);return i(()=>{const e=ar.getState().isPreview;return w(Boolean(n)),()=>{w(e)}},[n,w]),i(()=>{if(!e)return;let t=!1;return x(void 0,void 0,void 0,function*(){var r;const i=yield Vt({collectionId:e,size:10});if(!i||t)return;const{contents:n,count:s}=i;(null==n?void 0:n.length)&&E(null===(r=n.at(-1))||void 0===r?void 0:r.shortsId);const a=null==n?void 0:n[0],o=Lt(),l=a?Lt():void 0;b(Object.assign(Object.assign({},i),{count:s,uuid:o,contents:a?[Object.assign(Object.assign({},a),{uuid:l}),...n.slice(1)]:n}))}),()=>{t=!0}},[e,n,b,E]),i(()=>{if(n||!(null==y?void 0:y.uuid))return;S.current.has(y.uuid)||(S.current.add(y.uuid),Ut({contentId:y.colId,uuid:y.uuid,type:wt.COLLECTION,userId:y.userId,isFirstPlay:!Pt(y.colId)}));const e=y.contents[0];(null==e?void 0:e.uuid)&&!T.current.has(e.uuid)&&(T.current.add(e.uuid),Ut({contentId:e.shortsId,uuid:e.uuid,type:wt.SHORTS,userId:e.userId,isFirstPlay:!Pt(e.shortsId)}))},[y,n]),y&&(null===(v=y.contents)||void 0===v?void 0:v.length)?t.createElement(qr.div,{style:{position:"fixed",inset:0,pointerEvents:"none",zIndex:Yd}},t.createElement(Fo,null),t.createElement("div",{style:{pointerEvents:"auto"}},t.createElement(Qd,{key:`${y.uuid}:${Boolean(n)}`,navigation:s,like:a,share:o,productBannerType:l,isPreview:Boolean(n),horizontalPosition:c,verticalPosition:d,horizontalOffset:u,verticalOffset:h,initialSize:f,pcInitialWidth:p,mobileInitialWidth:m,cornerStyle:g}))):null},Jd=e=>t.createElement(Vo,null,t.createElement(Zd,Object.assign({},e))),eu=t.createContext(null),tu=({children:e})=>{const r=t.useRef(null);return r.current||(r.current=tr(e=>({liveWidget:null,setLiveWidget:t=>e({liveWidget:t}),nextKey:"",setNextKey:t=>e({nextKey:t}),isFetching:!1,setIsFetching:t=>e({isFetching:t})}))),t.createElement(eu.Provider,{value:r.current},e)};function ru(e){const r=t.useContext(eu);if(!r)throw new Error("Missing LiveWidgetProvider");return ir(r,e)}var iu;!function(e){e[e.READY=1]="READY",e[e.STREAMING=2]="STREAMING",e[e.PAUSED=3]="PAUSED"}(iu||(iu={}));const nu=({opacity:e=.4,className:r})=>{const i=Math.max(0,Math.min(1,e));return t.createElement("div",{"aria-hidden":!0,role:"presentation",className:`absolute inset-0 pointer-events-none ${null!=r?r:""}`,style:{backgroundColor:`rgba(0,0,0,${i})`,borderRadius:"inherit"}})},su=({content:e})=>{const{PLAYER_BASE_URL:r}=gt();return t.createElement("iframe",{src:`${r}/live/${e.eventId}`,className:"w-full h-full block",style:{border:0,display:"block"},allow:"autoplay; fullscreen; picture-in-picture",allowFullScreen:!0,scrolling:"no",referrerPolicy:"no-referrer-when-downgrade"})},au=(e,r)=>{const[i,n]=t.useState({}),[s,a]=t.useState({primary:20,secondary:12});return t.useLayoutEffect(()=>{n({})},[e]),t.useEffect(()=>{const t=r.current;if(!t)return;const i=()=>{const r=t.getBoundingClientRect(),i=Math.max(0,Math.floor(r.width)),s=Math.max(0,Math.floor(r.height)),[o,l]=e.includes("/")?e.split("/").map(e=>parseFloat(e)):[1,1],c=l/o;let d,u;i>0&&s>0?(d=i,u=Math.round(d*c),u>s&&(u=s,d=Math.round(u/c)),n({width:d,height:u})):n({});const h="number"==typeof d?d:i,f=Math.max(16,Math.round(.075*h)),p=Math.max(11,Math.round(.042*h));a({primary:f,secondary:p})};if("undefined"!=typeof ResizeObserver){const e=new ResizeObserver(()=>i());return e.observe(t),()=>e.disconnect()}{const e=()=>i();return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)}},[e]),{fontSize:s,boxSize:i}},ou=({content:e,aspectRatio:r="9/16",cursor:i="default",borderRadius:n})=>{var a,o;const{leftTime:l}=(e=>{const{start:t}=e,r=qe().tz("Asia/Seoul").unix(),[i,n]=s(t-r>0?t-r:0);return Nt(()=>{n(i<=0?0:e=>e-1)},1e3),{leftTime:i}})(e),c=null===(o=null===(a=null==e?void 0:e.designInfo)||void 0===a?void 0:a.thumbPath)||void 0===o?void 0:o.preview,d=t.useRef(null),{boxSize:u,fontSize:h}=au(r,d),{PLAYER_BASE_URL:f}=gt(),p=Math.floor(Date.now()/1e3),m="number"==typeof e.end&&e.end>0&&e.end<p;return t.createElement("div",{className:"w-full h-full flex items-center justify-center",ref:d},t.createElement("div",{className:"relative rounded overflow-hidden",style:{width:u.width?`${u.width}px`:"100%",height:u.height?`${u.height}px`:"100%",borderRadius:`${null!=n?n:10}px`,backgroundRepeat:"no-repeat",backgroundPosition:"center",backgroundSize:"cover",aspectRatio:u.height?void 0:r,backgroundImage:c?`url(${Dt(c)})`:void 0,backgroundColor:c?void 0:"black"}},1===e.openStatus?t.createElement(t.Fragment,null,t.createElement(su,{content:e}),t.createElement("a",{href:`${f}/live/${e.eventId}`,target:"_blank",rel:"noopener noreferrer","aria-label":`${e.eventName} 바로가기`,style:{position:"absolute",inset:0,zIndex:30,display:"block",textDecoration:"none",cursor:"pointer",background:"transparent"}})):m?t.createElement(t.Fragment,null,t.createElement(nu,null),t.createElement("div",{className:"text-white flex flex-col items-center justify-center absolute inset-0",style:{zIndex:10,gap:"12px",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none",cursor:i,pointerEvents:"none"}},t.createElement("p",{style:{fontSize:`${h.primary}px`,fontWeight:700}},"다시보기"),t.createElement("p",{style:{fontSize:`${h.secondary}px`}},"라이브가 종료되었습니다"))):t.createElement(t.Fragment,null,t.createElement(nu,null),t.createElement("div",{className:"text-white flex flex-col items-center justify-center absolute inset-0",style:{zIndex:10,gap:"20px",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none",cursor:i,pointerEvents:"none"}},t.createElement("p",{style:{fontSize:`${h.primary}px`}},((e,t)=>{if(e>86400)return qe.unix(t).tz("Asia/Seoul").format("M월 D일 A h시 mm분");const r=qe.duration(e,"seconds");return`${r.hours().toString().padStart(2,"0")}:${r.minutes().toString().padStart(2,"0")}:${r.seconds().toString().padStart(2,"0")}`})(l,e.start)),t.createElement("p",{style:{fontSize:`${h.secondary}px`}},"곧 라이브가 시작됩니다!")))))},lu=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},cu=Number.isSafeInteger||function(e){return"number"==typeof e&&Math.abs(e)<=du},du=Number.MAX_SAFE_INTEGER||9007199254740991;let uu=function(e){return e.NETWORK_ERROR="networkError",e.MEDIA_ERROR="mediaError",e.KEY_SYSTEM_ERROR="keySystemError",e.MUX_ERROR="muxError",e.OTHER_ERROR="otherError",e}({}),hu=function(e){return e.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",e.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",e.KEY_SYSTEM_NO_SESSION="keySystemNoSession",e.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",e.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",e.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",e.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",e.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",e.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR="keySystemDestroyMediaKeysError",e.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR="keySystemDestroyCloseSessionError",e.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR="keySystemDestroyRemoveSessionError",e.MANIFEST_LOAD_ERROR="manifestLoadError",e.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",e.MANIFEST_PARSING_ERROR="manifestParsingError",e.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",e.LEVEL_EMPTY_ERROR="levelEmptyError",e.LEVEL_LOAD_ERROR="levelLoadError",e.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",e.LEVEL_PARSING_ERROR="levelParsingError",e.LEVEL_SWITCH_ERROR="levelSwitchError",e.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",e.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",e.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",e.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",e.FRAG_LOAD_ERROR="fragLoadError",e.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",e.FRAG_DECRYPT_ERROR="fragDecryptError",e.FRAG_PARSING_ERROR="fragParsingError",e.FRAG_GAP="fragGap",e.REMUX_ALLOC_ERROR="remuxAllocError",e.KEY_LOAD_ERROR="keyLoadError",e.KEY_LOAD_TIMEOUT="keyLoadTimeOut",e.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",e.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",e.BUFFER_APPEND_ERROR="bufferAppendError",e.BUFFER_APPENDING_ERROR="bufferAppendingError",e.BUFFER_STALLED_ERROR="bufferStalledError",e.BUFFER_FULL_ERROR="bufferFullError",e.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",e.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",e.ASSET_LIST_LOAD_ERROR="assetListLoadError",e.ASSET_LIST_LOAD_TIMEOUT="assetListLoadTimeout",e.ASSET_LIST_PARSING_ERROR="assetListParsingError",e.INTERSTITIAL_ASSET_ITEM_ERROR="interstitialAssetItemError",e.INTERNAL_EXCEPTION="internalException",e.INTERNAL_ABORTED="aborted",e.ATTACH_MEDIA_ERROR="attachMediaError",e.UNKNOWN="unknown",e}({}),fu=function(e){return e.MEDIA_ATTACHING="hlsMediaAttaching",e.MEDIA_ATTACHED="hlsMediaAttached",e.MEDIA_DETACHING="hlsMediaDetaching",e.MEDIA_DETACHED="hlsMediaDetached",e.MEDIA_ENDED="hlsMediaEnded",e.STALL_RESOLVED="hlsStallResolved",e.BUFFER_RESET="hlsBufferReset",e.BUFFER_CODECS="hlsBufferCodecs",e.BUFFER_CREATED="hlsBufferCreated",e.BUFFER_APPENDING="hlsBufferAppending",e.BUFFER_APPENDED="hlsBufferAppended",e.BUFFER_EOS="hlsBufferEos",e.BUFFERED_TO_END="hlsBufferedToEnd",e.BUFFER_FLUSHING="hlsBufferFlushing",e.BUFFER_FLUSHED="hlsBufferFlushed",e.MANIFEST_LOADING="hlsManifestLoading",e.MANIFEST_LOADED="hlsManifestLoaded",e.MANIFEST_PARSED="hlsManifestParsed",e.LEVEL_SWITCHING="hlsLevelSwitching",e.LEVEL_SWITCHED="hlsLevelSwitched",e.LEVEL_LOADING="hlsLevelLoading",e.LEVEL_LOADED="hlsLevelLoaded",e.LEVEL_UPDATED="hlsLevelUpdated",e.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",e.LEVELS_UPDATED="hlsLevelsUpdated",e.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",e.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",e.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",e.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",e.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",e.AUDIO_TRACK_UPDATED="hlsAudioTrackUpdated",e.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",e.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",e.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",e.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",e.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",e.SUBTITLE_TRACK_UPDATED="hlsSubtitleTrackUpdated",e.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",e.CUES_PARSED="hlsCuesParsed",e.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",e.INIT_PTS_FOUND="hlsInitPtsFound",e.FRAG_LOADING="hlsFragLoading",e.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",e.FRAG_LOADED="hlsFragLoaded",e.FRAG_DECRYPTED="hlsFragDecrypted",e.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",e.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",e.FRAG_PARSING_METADATA="hlsFragParsingMetadata",e.FRAG_PARSED="hlsFragParsed",e.FRAG_BUFFERED="hlsFragBuffered",e.FRAG_CHANGED="hlsFragChanged",e.FPS_DROP="hlsFpsDrop",e.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",e.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",e.ERROR="hlsError",e.DESTROYING="hlsDestroying",e.KEY_LOADING="hlsKeyLoading",e.KEY_LOADED="hlsKeyLoaded",e.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",e.BACK_BUFFER_REACHED="hlsBackBufferReached",e.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",e.ASSET_LIST_LOADING="hlsAssetListLoading",e.ASSET_LIST_LOADED="hlsAssetListLoaded",e.INTERSTITIALS_UPDATED="hlsInterstitialsUpdated",e.INTERSTITIALS_BUFFERED_TO_BOUNDARY="hlsInterstitialsBufferedToBoundary",e.INTERSTITIAL_ASSET_PLAYER_CREATED="hlsInterstitialAssetPlayerCreated",e.INTERSTITIAL_STARTED="hlsInterstitialStarted",e.INTERSTITIAL_ASSET_STARTED="hlsInterstitialAssetStarted",e.INTERSTITIAL_ASSET_ENDED="hlsInterstitialAssetEnded",e.INTERSTITIAL_ASSET_ERROR="hlsInterstitialAssetError",e.INTERSTITIAL_ENDED="hlsInterstitialEnded",e.INTERSTITIALS_PRIMARY_RESUMED="hlsInterstitialsPrimaryResumed",e.PLAYOUT_LIMIT_REACHED="hlsPlayoutLimitReached",e.EVENT_CUE_ENTER="hlsEventCueEnter",e}({});var pu="manifest",mu="level",gu="audioTrack",vu="subtitleTrack",yu="main",bu="audio",Eu="subtitle";class wu{constructor(e,t=0,r=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=r}sample(e,t){const r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){const e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}}class Su{constructor(e,t,r,i=100){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=r,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new wu(e),this.fast_=new wu(t),this.defaultTTFB_=i,this.ttfb_=new wu(e)}update(e,t){const{slow_:r,fast_:i,ttfb_:n}=this;r.halfLife!==e&&(this.slow_=new wu(e,r.getEstimate(),r.getTotalWeight())),i.halfLife!==t&&(this.fast_=new wu(t,i.getEstimate(),i.getTotalWeight())),n.halfLife!==e&&(this.ttfb_=new wu(e,n.getEstimate(),n.getTotalWeight()))}sample(e,t){const r=(e=Math.max(e,this.minDelayMs_))/1e3,i=8*t/r;this.fast_.sample(r,i),this.slow_.sample(r,i)}sampleTTFB(e){const t=e/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(r,Math.max(e,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}get defaultEstimate(){return this.defaultEstimate_}destroy(){}}function Tu(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function xu(){return xu=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)({}).hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},xu.apply(null,arguments)}function Au(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,i)}return r}function ku(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Au(Object(r),!0).forEach(function(t){Tu(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Au(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}class Iu{constructor(e,t){this.trace=void 0,this.debug=void 0,this.log=void 0,this.warn=void 0,this.info=void 0,this.error=void 0;const r=`[${e}]:`;this.trace=Lu,this.debug=t.debug.bind(null,r),this.log=t.log.bind(null,r),this.warn=t.warn.bind(null,r),this.info=t.info.bind(null,r),this.error=t.error.bind(null,r)}}const Lu=function(){},Ru={trace:Lu,debug:Lu,log:Lu,warn:Lu,info:Lu,error:Lu};function Pu(){return xu({},Ru)}function Cu(e,t,r){return t[e]?t[e].bind(t):function(e,t){const r=self.console[e];return r?r.bind(self.console,`${t?"["+t+"] ":""}[${e}] >`):Lu}(e,r)}const Du=Pu();const _u=Du;function Ou(e=!0){if("undefined"==typeof self)return;return(e||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function Mu(e,t){const r=Object.keys(e),i=Object.keys(t),n=r.length,s=i.length;return!n||!s||n===s&&!r.some(e=>-1===i.indexOf(e))}function Nu(e,t=!1){if("undefined"!=typeof TextDecoder){const r=new TextDecoder("utf-8").decode(e);if(t){const e=r.indexOf("\0");return-1!==e?r.substring(0,e):r}return r.replace(/\0/g,"")}const r=e.length;let i,n,s,a="",o=0;for(;o<r;){if(i=e[o++],0===i&&t)return a;if(0!==i&&3!==i)switch(i>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:a+=String.fromCharCode(i);break;case 12:case 13:n=e[o++],a+=String.fromCharCode((31&i)<<6|63&n);break;case 14:n=e[o++],s=e[o++],a+=String.fromCharCode((15&i)<<12|(63&n)<<6|63&s)}}return a}function Fu(e){let t="";for(let r=0;r<e.length;r++){let i=e[r].toString(16);i.length<2&&(i="0"+i),t+=i}return t}function $u(e){return Uint8Array.from(e.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}function Bu(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Uu,zu={exports:{}};var Gu,ju,Hu,Vu,Wu,Yu=Uu?zu.exports:(Uu=1,Gu=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,ju=/^(?=([^\/?#]*))\1([^]*)$/,Hu=/(?:\/|^)\.(?=\/)/g,Vu=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,zu.exports=Wu={buildAbsoluteURL:function(e,t,r){if(r=r||{},e=e.trim(),!(t=t.trim())){if(!r.alwaysNormalize)return e;var i=Wu.parseURL(e);if(!i)throw new Error("Error trying to parse base URL.");return i.path=Wu.normalizePath(i.path),Wu.buildURLFromParts(i)}var n=Wu.parseURL(t);if(!n)throw new Error("Error trying to parse relative URL.");if(n.scheme)return r.alwaysNormalize?(n.path=Wu.normalizePath(n.path),Wu.buildURLFromParts(n)):t;var s=Wu.parseURL(e);if(!s)throw new Error("Error trying to parse base URL.");if(!s.netLoc&&s.path&&"/"!==s.path[0]){var a=ju.exec(s.path);s.netLoc=a[1],s.path=a[2]}s.netLoc&&!s.path&&(s.path="/");var o={scheme:s.scheme,netLoc:n.netLoc,path:null,params:n.params,query:n.query,fragment:n.fragment};if(!n.netLoc&&(o.netLoc=s.netLoc,"/"!==n.path[0]))if(n.path){var l=s.path,c=l.substring(0,l.lastIndexOf("/")+1)+n.path;o.path=Wu.normalizePath(c)}else o.path=s.path,n.params||(o.params=s.params,n.query||(o.query=s.query));return null===o.path&&(o.path=r.alwaysNormalize?Wu.normalizePath(n.path):n.path),Wu.buildURLFromParts(o)},parseURL:function(e){var t=Gu.exec(e);return t?{scheme:t[1]||"",netLoc:t[2]||"",path:t[3]||"",params:t[4]||"",query:t[5]||"",fragment:t[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(Hu,"");e.length!==(e=e.replace(Vu,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}});class Ku{constructor(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}}var qu="audio",Xu="video",Qu="audiovideo";class Zu{constructor(e){this._byteRange=null,this._url=null,this._stats=null,this._streams=null,this.base=void 0,this.relurl=void 0,"string"==typeof e&&(e={url:e}),this.base=e,function(e,t){const r=rh(e,t);r&&(r.enumerable=!0,Object.defineProperty(e,t,r))}(this,"stats")}setByteRange(e,t){const r=e.split("@",2);let i;i=1===r.length?(null==t?void 0:t.byteRangeEndOffset)||0:parseInt(r[1]),this._byteRange=[i,parseInt(r[0])+i]}get baseurl(){return this.base.url}get byteRange(){return null===this._byteRange?[]:this._byteRange}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get elementaryStreams(){return null===this._streams&&(this._streams={[qu]:null,[Xu]:null,[Qu]:null}),this._streams}set elementaryStreams(e){this._streams=e}get hasStats(){return null!==this._stats}get hasStreams(){return null!==this._streams}get stats(){return null===this._stats&&(this._stats=new Ku),this._stats}set stats(e){this._stats=e}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Yu.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}clearElementaryStreamInfo(){const{elementaryStreams:e}=this;e[qu]=null,e[Xu]=null,e[Qu]=null}}function Ju(e){return"initSegment"!==e.sn}class eh extends Zu{constructor(e,t){super(t),this._decryptdata=null,this._programDateTime=null,this._ref=null,this._bitrate=void 0,this.rawProgramDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.playlistOffset=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.urlId=0,this.type=e}get byteLength(){if(this.hasStats){const e=this.stats.total;if(e)return e}if(this.byteRange.length){const e=this.byteRange[0],t=this.byteRange[1];if(lu(e)&&lu(t))return t-e}return null}get bitrate(){return this.byteLength?8*this.byteLength/this.duration:this._bitrate?this._bitrate:null}set bitrate(e){this._bitrate=e}get decryptdata(){var e;const{levelkeys:t}=this;if(!t||t.NONE)return null;if(t.identity)this._decryptdata||(this._decryptdata=t.identity.getDecryptData(this.sn));else if(null==(e=this._decryptdata)||!e.keyId){const e=Object.keys(t);if(1===e.length){const r=this._decryptdata=t[e[0]]||null;r&&(this._decryptdata=r.getDecryptData(this.sn,t))}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(null===this.programDateTime)return null;const e=lu(this.duration)?this.duration:0;return this.programDateTime+1e3*e}get encrypted(){var e;if(null!=(e=this._decryptdata)&&e.encrypted)return!0;if(this.levelkeys){var t;const e=Object.keys(this.levelkeys),r=e.length;if(r>1||1===r&&null!=(t=this.levelkeys[e[0]])&&t.encrypted)return!0}return!1}get programDateTime(){return null===this._programDateTime&&this.rawProgramDateTime&&(this.programDateTime=Date.parse(this.rawProgramDateTime)),this._programDateTime}set programDateTime(e){lu(e)?this._programDateTime=e:this._programDateTime=this.rawProgramDateTime=null}get ref(){return Ju(this)?(this._ref||(this._ref={base:this.base,start:this.start,duration:this.duration,sn:this.sn,programDateTime:this.programDateTime}),this._ref):null}addStart(e){this.setStart(this.start+e)}setStart(e){this.start=e,this._ref&&(this._ref.start=e)}setDuration(e){this.duration=e,this._ref&&(this._ref.duration=e)}setKeyFormat(e){const t=this.levelkeys;if(t){var r;const i=t[e];!i||null!=(r=this._decryptdata)&&r.keyId||(this._decryptdata=i.getDecryptData(this.sn,t))}}abortRequests(){var e,t;null==(e=this.loader)||e.abort(),null==(t=this.keyLoader)||t.abort()}setElementaryStreamInfo(e,t,r,i,n,s=!1){const{elementaryStreams:a}=this,o=a[e];o?(o.startPTS=Math.min(o.startPTS,t),o.endPTS=Math.max(o.endPTS,r),o.startDTS=Math.min(o.startDTS,i),o.endDTS=Math.max(o.endDTS,n)):a[e]={startPTS:t,endPTS:r,startDTS:i,endDTS:n,partial:s}}}class th extends Zu{constructor(e,t,r,i,n){super(r),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=t,this.index=i;const s=e.enumeratedString("BYTERANGE");s&&this.setByteRange(s,n),n&&(this.fragOffset=n.fragOffset+n.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){const{elementaryStreams:e}=this;return!!(e.audio||e.video||e.audiovideo)}}function rh(e,t){const r=Object.getPrototypeOf(e);if(r){const e=Object.getOwnPropertyDescriptor(r,t);return e||rh(r,t)}}const ih=Math.pow(2,32)-1,nh=[].push,sh={video:1,audio:2,id3:3,text:4};function ah(e){return String.fromCharCode.apply(null,e)}function oh(e,t){const r=e[t]<<8|e[t+1];return r<0?65536+r:r}function lh(e,t){const r=dh(e,t);return r<0?4294967296+r:r}function ch(e,t){let r=lh(e,t);return r*=Math.pow(2,32),r+=lh(e,t+4),r}function dh(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function uh(e,t){const r=[];if(!t.length)return r;const i=e.byteLength;for(let n=0;n<i;){const s=lh(e,n),a=s>1?n+s:i;if(ah(e.subarray(n+4,n+8))===t[0])if(1===t.length)r.push(e.subarray(n+8,a));else{const i=uh(e.subarray(n+8,a),t.slice(1));i.length&&nh.apply(r,i)}n=a}return r}function hh(e){const t=[],r=e[0];let i=8;const n=lh(e,i);i+=4;let s=0,a=0;0===r?(s=lh(e,i),a=lh(e,i+4),i+=8):(s=ch(e,i),a=ch(e,i+8),i+=16),i+=2;let o=e.length+a;const l=oh(e,i);i+=2;for(let r=0;r<l;r++){let r=i;const s=lh(e,r);r+=4;const a=2147483647&s;if(1===(2147483648&s)>>>31)return _u.warn("SIDX has hierarchical references (not supported)"),null;const l=lh(e,r);r+=4,t.push({referenceSize:a,subsegmentDuration:l,info:{duration:l/n,start:o,end:o+a-1}}),o+=a,r+=4,i=r}return{earliestPresentationTime:s,timescale:n,version:r,referencesCount:l,references:t}}function fh(e){const t=[],r=uh(e,["moov","trak"]);for(let e=0;e<r.length;e++){const i=r[e],n=uh(i,["tkhd"])[0];if(n){let e=n[0];const r=lh(n,0===e?12:20),s=uh(i,["mdia","mdhd"])[0];if(s){e=s[0];const n=lh(s,0===e?12:20),a=uh(i,["mdia","hdlr"])[0];if(a){const e=ah(a.subarray(8,12)),s={soun:qu,vide:Xu}[e],o=ph(uh(i,["mdia","minf","stbl","stsd"])[0]);s?(t[r]={timescale:n,type:s,stsd:o},t[s]=ku({timescale:n,id:r},o)):t[r]={timescale:n,type:e,stsd:o}}}}}return uh(e,["moov","mvex","trex"]).forEach(e=>{const r=lh(e,4),i=t[r];i&&(i.default={duration:lh(e,12),flags:lh(e,20)})}),t}function ph(e){const t=e.subarray(8),r=t.subarray(86),i=ah(t.subarray(4,8));let n,s=i;const a="enca"===i||"encv"===i;if(a){const e=uh(t,[i])[0];uh(e.subarray("enca"===i?28:78),["sinf"]).forEach(e=>{const t=uh(e,["schm"])[0];if(t){const r=ah(t.subarray(4,8));if("cbcs"===r||"cenc"===r){const t=uh(e,["frma"])[0];t&&(s=ah(t))}}})}const o=s;switch(s){case"avc1":case"avc2":case"avc3":case"avc4":{const e=uh(r,["avcC"])[0];e&&e.length>3&&(s+="."+vh(e[1])+vh(e[2])+vh(e[3]),n=mh("avc1"===o?"dva1":"dvav",r));break}case"mp4a":{const e=uh(t,[i])[0],r=uh(e.subarray(28),["esds"])[0];if(r&&r.length>7){let e=4;if(3!==r[e++])break;e=gh(r,e),e+=2;const t=r[e++];if(128&t&&(e+=2),64&t&&(e+=r[e++]),4!==r[e++])break;e=gh(r,e);const i=r[e++];if(64!==i)break;if(s+="."+vh(i),e+=12,5!==r[e++])break;e=gh(r,e);const n=r[e++];let a=(248&n)>>3;31===a&&(a+=1+((7&n)<<3)+((224&r[e])>>5)),s+="."+a}break}case"hvc1":case"hev1":{const e=uh(r,["hvcC"])[0];if(e&&e.length>12){const t=e[1],r=["","A","B","C"][t>>6],i=31&t,n=lh(e,2),a=(32&t)>>5?"H":"L",o=e[12],l=e.subarray(6,12);s+="."+r+i,s+="."+function(e){let t=0;for(let r=0;r<32;r++)t|=(e>>r&1)<<31-r;return t>>>0}(n).toString(16).toUpperCase(),s+="."+a+o;let c="";for(let e=l.length;e--;){const t=l[e];if(t||c){c="."+t.toString(16).toUpperCase()+c}}s+=c}n=mh("hev1"==o?"dvhe":"dvh1",r);break}case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":s=mh(s,r)||s;break;case"vp09":{const e=uh(r,["vpcC"])[0];if(e&&e.length>6){const t=e[4],r=e[5],i=e[6]>>4&15;s+="."+yh(t)+"."+yh(r)+"."+yh(i)}break}case"av01":{const e=uh(r,["av1C"])[0];if(e&&e.length>2){const t=e[1]>>>5,i=31&e[1],a=e[2]>>>7?"H":"M",o=(64&e[2])>>6,l=(32&e[2])>>5,c=2===t&&o?l?12:10:o?10:8,d=(16&e[2])>>4,u=(8&e[2])>>3,h=(4&e[2])>>2,f=3&e[2],p=1,m=1,g=1,v=0;s+="."+t+"."+yh(i)+a+"."+yh(c)+"."+d+"."+u+h+f+"."+yh(p)+"."+yh(m)+"."+yh(g)+"."+v,n=mh("dav1",r)}break}}return{codec:s,encrypted:a,supplemental:n}}function mh(e,t){const r=uh(t,["dvvC"]),i=r.length?r[0]:uh(t,["dvcC"])[0];if(i){const t=i[2]>>1&127,r=i[2]<<5&32|i[3]>>3&31;return e+"."+yh(t)+"."+yh(r)}}function gh(e,t){const r=t+5;for(;128&e[t++]&&t<r;);return t}function vh(e){return("0"+e.toString(16).toUpperCase()).slice(-2)}function yh(e){return(e<10?"0":"")+e}function bh(e,t){uh(e,["moov","trak"]).forEach(e=>{const r=uh(e,["mdia","minf","stbl","stsd"])[0];if(!r)return;const i=r.subarray(8);let n=uh(i,["enca"]);const s=n.length>0;s||(n=uh(i,["encv"])),n.forEach(e=>{uh(s?e.subarray(28):e.subarray(78),["sinf"]).forEach(e=>{const r=Eh(e);r&&t(r,s)})})})}function Eh(e){const t=uh(e,["schm"])[0];if(t){const r=ah(t.subarray(4,8));if("cbcs"===r||"cenc"===r){const t=uh(e,["schi","tenc"])[0];if(t)return t}}}function wh(e,t){const r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}function Sh(e,t){const r=[],i=t.samples,n=t.timescale,s=t.id;let a=!1;return uh(i,["moof"]).map(o=>{const l=o.byteOffset-8;uh(o,["traf"]).map(o=>{const c=uh(o,["tfdt"]).map(e=>{const t=e[0];let r=lh(e,4);return 1===t&&(r*=Math.pow(2,32),r+=lh(e,8)),r/n})[0];return void 0!==c&&(e=c),uh(o,["tfhd"]).map(c=>{const d=lh(c,4),u=16777215&lh(c,0);let h=0;const f=!!(16&u);let p=0;const m=!!(32&u);let g=8;d===s&&(!!(1&u)&&(g+=8),!!(2&u)&&(g+=4),!!(8&u)&&(h=lh(c,g),g+=4),f&&(p=lh(c,g),g+=4),m&&(g+=4),"video"===t.type&&(a=Th(t.codec)),uh(o,["trun"]).map(s=>{const o=s[0],c=16777215&lh(s,0),d=!!(1&c);let u=0;const f=!!(4&c),m=!!(256&c);let g=0;const v=!!(512&c);let y=0;const b=!!(1024&c),E=!!(2048&c);let w=0;const S=lh(s,4);let T=8;d&&(u=lh(s,T),T+=4),f&&(T+=4);let x=u+l;for(let l=0;l<S;l++){if(m?(g=lh(s,T),T+=4):g=h,v?(y=lh(s,T),T+=4):y=p,b&&(T+=4),E&&(w=0===o?lh(s,T):dh(s,T),T+=4),t.type===Xu){let t=0;for(;t<y;){const s=lh(i,x);if(x+=4,xh(a,i[x])){Ah(i.subarray(x,x+s),a?2:1,e+w/n,r)}x+=s,t+=s+4}}e+=g/n}}))})})}),r}function Th(e){if(!e)return!1;const t=e.substring(0,4);return"hvc1"===t||"hev1"===t||"dvh1"===t||"dvhe"===t}function xh(e,t){if(e){const e=t>>1&63;return 39===e||40===e}return 6===(31&t)}function Ah(e,t,r,i){const n=kh(e);let s=0;s+=t;let a=0,o=0,l=0;for(;s<n.length;){a=0;do{if(s>=n.length)break;l=n[s++],a+=l}while(255===l);o=0;do{if(s>=n.length)break;l=n[s++],o+=l}while(255===l);const e=n.length-s;let t=s;if(o<e)s+=o;else if(o>e){_u.error(`Malformed SEI payload. ${o} is too small, only ${e} bytes left to parse.`);break}if(4===a){if(181===n[t++]){const e=oh(n,t);if(t+=2,49===e){const e=lh(n,t);if(t+=4,1195456820===e){const e=n[t++];if(3===e){const s=n[t++],o=64&s,l=o?2+3*(31&s):0,c=new Uint8Array(l);if(o){c[0]=s;for(let e=1;e<l;e++)c[e]=n[t++]}i.push({type:e,payloadType:a,pts:r,bytes:c})}}}}}else if(5===a&&o>16){const e=[];for(let r=0;r<16;r++){const i=n[t++].toString(16);e.push(1==i.length?"0"+i:i),3!==r&&5!==r&&7!==r&&9!==r||e.push("-")}const s=o-16,l=new Uint8Array(s);for(let e=0;e<s;e++)l[e]=n[t++];i.push({payloadType:a,pts:r,uuid:e.join(""),userData:Nu(l),userDataBytes:l})}}}function kh(e){const t=e.byteLength,r=[];let i=1;for(;i<t-2;)0===e[i]&&0===e[i+1]&&3===e[i+2]?(r.push(i+2),i+=2):i++;if(0===r.length)return e;const n=t-r.length,s=new Uint8Array(n);let a=0;for(i=0;i<n;a++,i++)a===r[0]&&(a++,r.shift()),s[i]=e[a];return s}function Ih(e,t,r){if(16!==e.byteLength)throw new RangeError("Invalid system id");let i,n,s;i=0,n=new Uint8Array,s=new Uint8Array;const a=new Uint8Array(4);return r.byteLength>0&&new DataView(a.buffer).setUint32(0,r.byteLength,!1),function(e,...t){const r=t.length;let i=8,n=r;for(;n--;)i+=t[n].byteLength;const s=new Uint8Array(i);for(s[0]=i>>24&255,s[1]=i>>16&255,s[2]=i>>8&255,s[3]=255&i,s.set(e,4),n=0,i=8;n<r;n++)s.set(t[n],i),i+=t[n].byteLength;return s}([112,115,115,104],new Uint8Array([0,0,0,0]),e,s,n,a,r)}function Lh(e){const t=e.getUint32(0),r=e.byteOffset,i=e.byteLength;if(i<t)return{offset:r,size:i};if(1886614376!==e.getUint32(4))return{offset:r,size:t};const n=e.getUint32(8)>>>24;if(0!==n&&1!==n)return{offset:r,size:t};const s=e.buffer,a=Fu(new Uint8Array(s,r+12,16));let o=null,l=null,c=0;if(0===n)c=28;else{const n=e.getUint32(28);if(!n||i<32+16*n)return{offset:r,size:t};o=[];for(let e=0;e<n;e++)o.push(new Uint8Array(s,r+32+16*e,16));c=32+16*n}if(!c)return{offset:r,size:t};const d=e.getUint32(c);return t-32<d?{offset:r,size:t}:(l=new Uint8Array(s,r+c+4,d),{version:n,systemId:a,kids:o,data:l,offset:r,size:t})}const Rh=()=>/\(Windows.+Firefox\//i.test(navigator.userAgent),Ph={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,dav1:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function Ch(e,t){const r=Ph[t];return!!r&&!!r[e.slice(0,4)]}function Dh(e,t,r=!0){return!e.split(",").some(e=>!_h(e,t,r))}function _h(e,t,r=!0){var i;const n=Ou(r);return null!=(i=null==n?void 0:n.isTypeSupported(Oh(e,t)))&&i}function Oh(e,t){return`${t}/mp4;codecs=${e}`}function Mh(e){if(e){const t=e.substring(0,4);return Ph.video[t]}return 2}function Nh(e){const t=Rh();return e.split(",").reduce((e,r)=>{const i=t&&Th(r)?9:Ph.video[r];return i?(2*i+e)/(e?3:2):(Ph.audio[r]+e)/(e?2:1)},0)}const Fh={};const $h=/flac|opus|mp4a\.40\.34/i;function Bh(e,t=!0){return e.replace($h,e=>function(e,t=!0){if(Fh[e])return Fh[e];const r={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[e];for(let n=0;n<r.length;n++){var i;if(_h(r[n],"audio",t))return Fh[e]=r[n],r[n];if("mp3"===r[n]&&null!=(i=Ou(t))&&i.isTypeSupported("audio/mpeg"))return""}return e}(e.toLowerCase(),t))}function Uh(e,t){if(e&&(e.length>4||-1!==["ac-3","ec-3","alac","fLaC","Opus"].indexOf(e))&&(zh(e,"audio")||zh(e,"video")))return e;if(t){const r=t.split(",");if(r.length>1){if(e)for(let t=r.length;t--;)if(r[t].substring(0,4)===e.substring(0,4))return r[t];return r[0]}}return t||e}function zh(e,t){return Ch(e,t)&&_h(e,t)}function Gh(e){if(e.startsWith("av01.")){const t=e.split("."),r=["0","111","01","01","01","0"];for(let e=t.length;e>4&&e<10;e++)t[e]=r[e-4];return t.join(".")}return e}function jh(e){const t=Ou(e)||{isTypeSupported:()=>!1};return{mpeg:t.isTypeSupported("audio/mpeg"),mp3:t.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:t.isTypeSupported('audio/mp4; codecs="ac-3"')}}function Hh(e){return e.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}const Vh={supported:!1,smooth:!1,powerEfficient:!1},Wh={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]};function Yh(e,t){return{supported:!1,configurations:t,decodingInfoResults:[Vh],error:e}}function Kh(e,t,r,i,n,s){const a=e.videoCodec,o=e.audioCodec?e.audioGroups:null,l=null==s?void 0:s.audioCodec,c=null==s?void 0:s.channels,d=c?parseInt(c):l?1/0:2;let u=null;if(null!=o&&o.length)try{u=1===o.length&&o[0]?t.groups[o[0]].channels:o.reduce((e,r)=>{if(r){const i=t.groups[r];if(!i)throw new Error(`Audio track group ${r} not found`);Object.keys(i.channels).forEach(t=>{e[t]=(e[t]||0)+i.channels[t]})}return e},{2:0})}catch(e){return!0}return void 0!==a&&(a.split(",").some(e=>Th(e))||e.width>1920&&e.height>1088||e.height>1920&&e.width>1088||e.frameRate>Math.max(i,30)||"SDR"!==e.videoRange&&e.videoRange!==r||e.bitrate>Math.max(n,8e6))||!!u&&lu(d)&&Object.keys(u).some(e=>parseInt(e)>d)}function qh(e,t,r,i={}){const n=e.videoCodec;if(!n&&!e.audioCodec||!r)return Promise.resolve(Wh);const s=[],a=function(e){var t;const r=null==(t=e.videoCodec)?void 0:t.split(","),i=Qh(e),n=e.width||640,s=e.height||480,a=e.frameRate||30,o=e.videoRange.toLowerCase();return r?r.map(e=>{const t={contentType:Oh(Gh(e),"video"),width:n,height:s,bitrate:i,framerate:a};return"sdr"!==o&&(t.transferFunction=o),t}):[]}(e),o=a.length,l=function(e,t,r){var i;const n=null==(i=e.audioCodec)?void 0:i.split(","),s=Qh(e);if(n&&e.audioGroups)return e.audioGroups.reduce((e,i)=>{var a;const o=i?null==(a=t.groups[i])?void 0:a.tracks:null;return o?o.reduce((e,t)=>{if(t.groupId===i){const i=parseFloat(t.channels||"");n.forEach(t=>{const n={contentType:Oh(t,"audio"),bitrate:r?Xh(t,s):s};i&&(n.channels=""+i),e.push(n)})}return e},e):e},[]);return[]}(e,t,o>0),c=l.length;for(let e=o||1*c||1;e--;){const t={type:"media-source"};if(o&&(t.video=a[e%o]),c){t.audio=l[e%c];const r=t.audio.bitrate;t.video&&r&&(t.video.bitrate-=r)}s.push(t)}if(n){const e=navigator.userAgent;if(n.split(",").some(e=>Th(e))&&Rh())return Promise.resolve(Yh(new Error(`Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent string: (${e})`),s))}return Promise.all(s.map(e=>{const t=function(e){let t="";const{audio:r,video:i}=e;if(i){t+=`${Hh(i.contentType)}_r${i.height}x${i.width}f${Math.ceil(i.framerate)}${i.transferFunction||"sd"}_${Math.ceil(i.bitrate/1e5)}`}if(r){t+=`${i?"_":""}${Hh(r.contentType)}_c${r.channels}`}return t}(e);return i[t]||(i[t]=r.decodingInfo(e))})).then(e=>({supported:!e.some(e=>!e.supported),configurations:s,decodingInfoResults:e})).catch(e=>({supported:!1,configurations:s,decodingInfoResults:[],error:e}))}function Xh(e,t){if(t<=1)return 1;let r=128e3;return"ec-3"===e?r=768e3:"ac-3"===e&&(r=64e4),Math.min(t/2,r)}function Qh(e){return 1e3*Math.ceil(Math.max(.9*e.bitrate,e.averageBitrate)/1e3)||1}const Zh=["NONE","TYPE-0","TYPE-1",null];const Jh=["SDR","PQ","HLG"];var ef="",tf="YES",rf="v2";function nf(e){const{canSkipUntil:t,canSkipDateRanges:r,age:i}=e;return t&&i<t/2?r?rf:tf:ef}class sf{constructor(e,t,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=r}addDirectives(e){const t=new self.URL(e);return void 0!==this.msn&&t.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}}class af{constructor(e){if(this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.supplemental=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.frameRate=e.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=e.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.codecSet=[e.videoCodec,e.audioCodec].filter(e=>!!e).map(e=>e.substring(0,4)).join(","),"supplemental"in e){var t;this.supplemental=e.supplemental;const r=null==(t=e.supplemental)?void 0:t.videoCodec;r&&r!==e.videoCodec&&(this.codecSet+=`,${r.substring(0,4)}`)}this.addGroupId("audio",e.attrs.AUDIO),this.addGroupId("text",e.attrs.SUBTITLES)}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get averageBitrate(){return this._avgBitrate||this.realBitrate||this.bitrate}get attrs(){return this._attrs[0]}get codecs(){return this.attrs.CODECS||""}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get videoRange(){return this.attrs["VIDEO-RANGE"]||"SDR"}get score(){return this.attrs.optionalFloat("SCORE",0)}get uri(){return this.url[0]||""}hasAudioGroup(e){return of(this._audioGroups,e)}hasSubtitleGroup(e){return of(this._subtitleGroups,e)}get audioGroups(){return this._audioGroups}get subtitleGroups(){return this._subtitleGroups}addGroupId(e,t){if(t)if("audio"===e){let e=this._audioGroups;e||(e=this._audioGroups=[]),-1===e.indexOf(t)&&e.push(t)}else if("text"===e){let e=this._subtitleGroups;e||(e=this._subtitleGroups=[]),-1===e.indexOf(t)&&e.push(t)}}get urlId(){return 0}set urlId(e){}get audioGroupIds(){return this.audioGroups?[this.audioGroupId]:void 0}get textGroupIds(){return this.subtitleGroups?[this.textGroupId]:void 0}get audioGroupId(){var e;return null==(e=this.audioGroups)?void 0:e[0]}get textGroupId(){var e;return null==(e=this.subtitleGroups)?void 0:e[0]}addFallback(){}}function of(e,t){return!(!t||!e)&&-1!==e.indexOf(t)}function lf(e,t){let r=!1,i=[];if(e&&(r="SDR"!==e,i=[e]),t){i=t.allowedVideoRanges||Jh.slice(0);const e="SDR"!==i.join("")&&!t.videoCodec;r=void 0!==t.preferHDR?t.preferHDR:e&&function(){if("function"==typeof matchMedia){const e=matchMedia("(dynamic-range: high)"),t=matchMedia("bad query");if(e.media!==t.media)return!0===e.matches}return!1}(),r||(i=["SDR"])}return{preferHDR:r,allowedVideoRanges:i}}const cf=(e,t)=>JSON.stringify(e,(e=>{const t=new WeakSet;return(r,i)=>{if(e&&(i=e(r,i)),"object"==typeof i&&null!==i){if(t.has(i))return;t.add(i)}return i}})(t));function df(e,t){_u.log(`[abr] start candidates with "${e}" ignored because ${t}`)}function uf(e){return e.reduce((e,t)=>{let r=e.groups[t.groupId];r||(r=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),r.tracks.push(t);const i=t.channels||"2";return r.channels[i]=(r.channels[i]||0)+1,r.hasDefault=r.hasDefault||t.default,r.hasAutoSelect=r.hasAutoSelect||t.autoselect,r.hasDefault&&(e.hasDefaultAudio=!0),r.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function hf(e){if(!e)return e;const{lang:t,assocLang:r,characteristics:i,channels:n,audioCodec:s}=e;return{lang:t,assocLang:r,characteristics:i,channels:n,audioCodec:s}}function ff(e,t,r){if("attrs"in e){const r=t.indexOf(e);if(-1!==r)return r}for(let i=0;i<t.length;i++){if(pf(e,t[i],r))return i}return-1}function pf(e,t,r){const{groupId:i,name:n,lang:s,assocLang:a,default:o}=e,l=e.forced;return(void 0===i||t.groupId===i)&&(void 0===n||t.name===n)&&(void 0===s||function(e,t="--"){if(e.length===t.length)return e===t;return e.startsWith(t)||t.startsWith(e)}(s,t.lang))&&(void 0===s||t.assocLang===a)&&(void 0===o||t.default===o)&&(void 0===l||t.forced===l)&&(!("characteristics"in e)||function(e,t=""){const r=e.split(","),i=t.split(",");return r.length===i.length&&!r.some(e=>-1===i.indexOf(e))}(e.characteristics||"",t.characteristics))&&(void 0===r||r(e,t))}function mf(e,t){const{audioCodec:r,channels:i}=e;return!(void 0!==r&&(t.audioCodec||"").substring(0,4)!==r.substring(0,4)||void 0!==i&&i!==(t.channels||"2"))}function gf(e,t,r){for(let i=t;i>-1;i--)if(r(e[i]))return i;for(let i=t+1;i<e.length;i++)if(r(e[i]))return i;return-1}function vf(e,t){var r;return!!e&&e!==(null==(r=t.loadLevelObj)?void 0:r.uri)}const yf=function(e,t){let r=0,i=e.length-1,n=null,s=null;for(;r<=i;){n=(r+i)/2|0,s=e[n];const a=t(s);if(a>0)r=n+1;else{if(!(a<0))return s;i=n-1}}return null};function bf(e,t,r=0,i=0,n=.005){let s=null;if(e){s=t[1+e.sn-t[0].sn]||null;const i=e.endDTS-r;i>0&&i<15e-7&&(r+=15e-7),s&&e.level!==s.level&&s.end<=e.end&&(s=t[2+e.sn-t[0].sn]||null)}else 0===r&&0===t[0].start&&(s=t[0]);if(s&&((!e||e.level===s.level)&&0===Ef(r,i,s)||function(e,t,r){if(t&&0===t.start&&t.level<e.level&&(t.endPTS||0)>0){const i=t.tagList.reduce((e,t)=>("INF"===t[0]&&(e+=parseFloat(t[1])),e),r);return e.start<=i}return!1}(s,e,Math.min(n,i))))return s;const a=yf(t,Ef.bind(null,r,i));return!a||a===e&&s?s:a}function Ef(e=0,t=0,r){if(r.start<=e&&r.start+r.duration>e)return 0;const i=Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return r.start+r.duration-i<=e?1:r.start-i>e&&r.start?-1:0}function wf(e,t,r){const i=1e3*Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return(r.endProgramDateTime||0)-i>e}function Sf(e,t,r){if(e&&e.startCC<=t&&e.endCC>=t){let i=e.fragments;const{fragmentHint:n}=e;let s;return n&&(i=i.concat(n)),yf(i,e=>e.cc<t?1:e.cc>t?-1:(s=e,e.end<=r?1:e.start>r?-1:0)),s||null}return null}function Tf(e){switch(e.details){case hu.FRAG_LOAD_TIMEOUT:case hu.KEY_LOAD_TIMEOUT:case hu.LEVEL_LOAD_TIMEOUT:case hu.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function xf(e){return e.details.startsWith("key")}function Af(e){return xf(e)&&!!e.frag&&!e.frag.decryptdata}function kf(e,t){const r=Tf(t);return e.default[(r?"timeout":"error")+"Retry"]}function If(e,t){const r="linear"===e.backoff?1:Math.pow(2,t);return Math.min(r*e.retryDelayMs,e.maxRetryDelayMs)}function Lf(e){return ku(ku({},e),{errorRetry:null,timeoutRetry:null})}function Rf(e,t,r,i){if(!e)return!1;const n=null==i?void 0:i.code,s=t<e.maxNumRetry&&(function(e){return Pf(e)||!!e&&(e<400||e>499)}(n)||!!r);return e.shouldRetry?e.shouldRetry(e,t,r,i,s):s}function Pf(e){return 0===e&&!1===navigator.onLine}var Cf=0,Df=2,_f=3,Of=5,Mf=0,Nf=1,Ff=2,$f=4;function Bf(e){const t={action:Cf,flags:Mf};return e&&(t.resolved=!0),t}var Uf="NOT_LOADED",zf="APPENDING",Gf="PARTIAL",jf="OK";class Hf{constructor(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}_registerListeners(){const{hls:e}=this;e&&(e.on(fu.MANIFEST_LOADING,this.onManifestLoading,this),e.on(fu.BUFFER_APPENDED,this.onBufferAppended,this),e.on(fu.FRAG_BUFFERED,this.onFragBuffered,this),e.on(fu.FRAG_LOADED,this.onFragLoaded,this))}_unregisterListeners(){const{hls:e}=this;e&&(e.off(fu.MANIFEST_LOADING,this.onManifestLoading,this),e.off(fu.BUFFER_APPENDED,this.onBufferAppended,this),e.off(fu.FRAG_BUFFERED,this.onFragBuffered,this),e.off(fu.FRAG_LOADED,this.onFragLoaded,this))}destroy(){this._unregisterListeners(),this.hls=this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){const r=this.activePartLists[t];if(r)for(let t=r.length;t--;){const i=r[t];if(!i)break;if(i.start<=e&&e<=i.end&&i.loaded)return i}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){return this.getFragAtPos(e,t,!0)}getFragAtPos(e,t,r){const{fragments:i}=this,n=Object.keys(i);for(let s=n.length;s--;){const a=i[n[s]];if((null==a?void 0:a.body.type)===t&&(!r||a.buffered)){const t=a.body;if(t.start<=e&&e<=t.end)return t}}return null}detectEvictedFragments(e,t,r,i,n){this.timeRanges&&(this.timeRanges[e]=t);const s=(null==i?void 0:i.fragment.sn)||-1;Object.keys(this.fragments).forEach(i=>{const a=this.fragments[i];if(!a)return;if(s>=a.body.sn)return;if(!a.buffered&&(!a.loaded||n))return void(a.body.type===r&&this.removeFragment(a.body));const o=a.range[e];o&&(0!==o.time.length?o.time.some(e=>{const r=!this.isTimeBuffered(e.startPTS,e.endPTS,t);return r&&this.removeFragment(a.body),r}):this.removeFragment(a.body))})}detectPartialFragments(e){const t=this.timeRanges;if(!t||"initSegment"===e.frag.sn)return;const r=e.frag,i=Wf(r),n=this.fragments[i];if(!n||n.buffered&&r.gap)return;const s=!r.relurl;Object.keys(t).forEach(i=>{const a=r.elementaryStreams[i];if(!a)return;const o=t[i],l=s||!0===a.partial;n.range[i]=this.getBufferedTimes(r,e.part,l,o)}),n.loaded=null,Object.keys(n.range).length?(this.bufferedEnd(n,r),Vf(n)||this.removeParts(r.sn-1,r.type)):this.removeFragment(n.body)}bufferedEnd(e,t){e.buffered=!0;(e.body.endList=t.endList||e.body.endList)&&(this.endListFragments[e.body.type]=e)}removeParts(e,t){const r=this.activePartLists[t];r&&(this.activePartLists[t]=Yf(r,t=>t.fragment.sn>=e))}fragBuffered(e,t){const r=Wf(e);let i=this.fragments[r];!i&&t&&(i=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),i&&(i.loaded=null,this.bufferedEnd(i,e))}getBufferedTimes(e,t,r,i){const n={time:[],partial:r},s=e.start,a=e.end,o=e.minEndPTS||a,l=e.maxStartPTS||s;for(let e=0;e<i.length;e++){const t=i.start(e)-this.bufferPadding,r=i.end(e)+this.bufferPadding;if(l>=t&&o<=r){n.time.push({startPTS:Math.max(s,i.start(e)),endPTS:Math.min(a,i.end(e))});break}if(s<r&&a>t){const t=Math.max(s,i.start(e)),r=Math.min(a,i.end(e));r>t&&(n.partial=!0,n.time.push({startPTS:t,endPTS:r}))}else if(a<=t)break}return n}getPartialFragment(e){let t,r,i,n=null,s=0;const{bufferPadding:a,fragments:o}=this;return Object.keys(o).forEach(l=>{const c=o[l];c&&Vf(c)&&(r=c.body.start-a,i=c.body.end+a,e>=r&&e<=i&&(t=Math.min(e-r,i-e),s<=t&&(n=c.body,s=t)))}),n}isEndListAppended(e){const t=this.endListFragments[e];return void 0!==t&&(t.buffered||Vf(t))}getState(e){const t=Wf(e),r=this.fragments[t];return r?r.buffered?Vf(r)?Gf:jf:zf:Uf}isTimeBuffered(e,t,r){let i,n;for(let s=0;s<r.length;s++){if(i=r.start(s)-this.bufferPadding,n=r.end(s)+this.bufferPadding,e>=i&&t<=n)return!0;if(t<=i)return!1}return!1}onManifestLoading(){this.removeAllFragments()}onFragLoaded(e,t){if("initSegment"===t.frag.sn||t.frag.bitrateTest)return;const r=t.frag,i=t.part?null:t,n=Wf(r);this.fragments[n]={body:r,appendedPTS:null,loaded:i,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){const{frag:r,part:i,timeRanges:n,type:s}=t;if("initSegment"===r.sn)return;const a=r.type;if(i){let e=this.activePartLists[a];e||(this.activePartLists[a]=e=[]),e.push(i)}this.timeRanges=n;const o=n[s];this.detectEvictedFragments(s,o,a,i)}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){const t=Wf(e);return!!this.fragments[t]}hasFragments(e){const{fragments:t}=this,r=Object.keys(t);if(!e)return r.length>0;for(let i=r.length;i--;){const n=t[r[i]];if((null==n?void 0:n.body.type)===e)return!0}return!1}hasParts(e){var t;return!(null==(t=this.activePartLists[e])||!t.length)}removeFragmentsInRange(e,t,r,i,n){i&&!this.hasGaps||Object.keys(this.fragments).forEach(s=>{const a=this.fragments[s];if(!a)return;const o=a.body;o.type!==r||i&&!o.gap||o.start<t&&o.end>e&&(a.buffered||n)&&this.removeFragment(o)})}removeFragment(e){const t=Wf(e);e.clearElementaryStreamInfo();const r=this.activePartLists[e.type];if(r){const t=e.sn;this.activePartLists[e.type]=Yf(r,e=>e.fragment.sn!==t)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){var e;this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1;const t=null==(e=this.hls)||null==(e=e.latestLevelDetails)?void 0:e.partList;t&&t.forEach(e=>e.clearElementaryStreamInfo())}}function Vf(e){var t,r,i;return e.buffered&&!!(e.body.gap||null!=(t=e.range.video)&&t.partial||null!=(r=e.range.audio)&&r.partial||null!=(i=e.range.audiovideo)&&i.partial)}function Wf(e){return`${e.type}_${e.level}_${e.sn}`}function Yf(e,t){return e.filter(e=>{const r=t(e);return r||e.clearElementaryStreamInfo(),r})}var Kf=0,qf=1;class Xf{constructor(e,t,r){this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=e,this.aesIV=t,this.aesMode=r}decrypt(e,t){switch(this.aesMode){case Kf:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e);case qf:return this.subtle.decrypt({name:"AES-CTR",counter:this.aesIV,length:64},t,e);default:throw new Error(`[AESCrypto] invalid aes mode ${this.aesMode}`)}}}class Qf{constructor(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}uint8ArrayToUint32Array_(e){const t=new DataView(e),r=new Uint32Array(4);for(let e=0;e<4;e++)r[e]=t.getUint32(4*e);return r}initTable(){const e=this.sBox,t=this.invSBox,r=this.subMix,i=r[0],n=r[1],s=r[2],a=r[3],o=this.invSubMix,l=o[0],c=o[1],d=o[2],u=o[3],h=new Uint32Array(256);let f=0,p=0,m=0;for(m=0;m<256;m++)h[m]=m<128?m<<1:m<<1^283;for(m=0;m<256;m++){let r=p^p<<1^p<<2^p<<3^p<<4;r=r>>>8^255&r^99,e[f]=r,t[r]=f;const o=h[f],m=h[o],g=h[m];let v=257*h[r]^16843008*r;i[f]=v<<24|v>>>8,n[f]=v<<16|v>>>16,s[f]=v<<8|v>>>24,a[f]=v,v=16843009*g^65537*m^257*o^16843008*f,l[r]=v<<24|v>>>8,c[r]=v<<16|v>>>16,d[r]=v<<8|v>>>24,u[r]=v,f?(f=o^h[h[h[g^o]]],p^=h[h[p]]):f=p=1}}expandKey(e){const t=this.uint8ArrayToUint32Array_(e);let r=!0,i=0;for(;i<t.length&&r;)r=t[i]===this.key[i],i++;if(r)return;this.key=t;const n=this.keySize=t.length;if(4!==n&&6!==n&&8!==n)throw new Error("Invalid aes key size="+n);const s=this.ksRows=4*(n+6+1);let a,o;const l=this.keySchedule=new Uint32Array(s),c=this.invKeySchedule=new Uint32Array(s),d=this.sBox,u=this.rcon,h=this.invSubMix,f=h[0],p=h[1],m=h[2],g=h[3];let v,y;for(a=0;a<s;a++)a<n?v=l[a]=t[a]:(y=v,a%n===0?(y=y<<8|y>>>24,y=d[y>>>24]<<24|d[y>>>16&255]<<16|d[y>>>8&255]<<8|d[255&y],y^=u[a/n|0]<<24):n>6&&a%n===4&&(y=d[y>>>24]<<24|d[y>>>16&255]<<16|d[y>>>8&255]<<8|d[255&y]),l[a]=v=(l[a-n]^y)>>>0);for(o=0;o<s;o++)a=s-o,y=3&o?l[a]:l[a-4],c[o]=o<4||a<=4?y:f[d[y>>>24]]^p[d[y>>>16&255]]^m[d[y>>>8&255]]^g[d[255&y]],c[o]=c[o]>>>0}networkToHostOrderSwap(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24}decrypt(e,t,r){const i=this.keySize+6,n=this.invKeySchedule,s=this.invSBox,a=this.invSubMix,o=a[0],l=a[1],c=a[2],d=a[3],u=this.uint8ArrayToUint32Array_(r);let h=u[0],f=u[1],p=u[2],m=u[3];const g=new Int32Array(e),v=new Int32Array(g.length);let y,b,E,w,S,T,x,A,k,I,L,R,P,C;const D=this.networkToHostOrderSwap;for(;t<g.length;){for(k=D(g[t]),I=D(g[t+1]),L=D(g[t+2]),R=D(g[t+3]),S=k^n[0],T=R^n[1],x=L^n[2],A=I^n[3],P=4,C=1;C<i;C++)y=o[S>>>24]^l[T>>16&255]^c[x>>8&255]^d[255&A]^n[P],b=o[T>>>24]^l[x>>16&255]^c[A>>8&255]^d[255&S]^n[P+1],E=o[x>>>24]^l[A>>16&255]^c[S>>8&255]^d[255&T]^n[P+2],w=o[A>>>24]^l[S>>16&255]^c[T>>8&255]^d[255&x]^n[P+3],S=y,T=b,x=E,A=w,P+=4;y=s[S>>>24]<<24^s[T>>16&255]<<16^s[x>>8&255]<<8^s[255&A]^n[P],b=s[T>>>24]<<24^s[x>>16&255]<<16^s[A>>8&255]<<8^s[255&S]^n[P+1],E=s[x>>>24]<<24^s[A>>16&255]<<16^s[S>>8&255]<<8^s[255&T]^n[P+2],w=s[A>>>24]<<24^s[S>>16&255]<<16^s[T>>8&255]<<8^s[255&x]^n[P+3],v[t]=D(y^h),v[t+1]=D(w^f),v[t+2]=D(E^p),v[t+3]=D(b^m),h=k,f=I,p=L,m=R,t+=4}return v.buffer}}class Zf{constructor(e,t,r){this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=e,this.key=t,this.aesMode=r}expandKey(){const e=function(e){switch(e){case Kf:return"AES-CBC";case qf:return"AES-CTR";default:throw new Error(`[FastAESKey] invalid aes mode ${e}`)}}(this.aesMode);return this.subtle.importKey("raw",this.key,{name:e},!1,["encrypt","decrypt"])}}class Jf{constructor(e,{removePKCS7Padding:t=!0}={}){if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.enableSoftwareAES=void 0,this.enableSoftwareAES=e.enableSoftwareAES,this.removePKCS7Padding=t,t)try{const e=self.crypto;e&&(this.subtle=e.subtle||e.webkitSubtle)}catch(e){}this.useSoftware=!this.subtle}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}isSync(){return this.useSoftware}flush(){const{currentResult:e,remainderData:t}=this;if(!e||t)return this.reset(),null;const r=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?function(e){const t=e.byteLength,r=t&&new DataView(e.buffer).getUint8(t-1);return r?e.slice(0,t-r):e}(r):r}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,r,i){return this.useSoftware?new Promise((n,s)=>{const a=ArrayBuffer.isView(e)?e:new Uint8Array(e);this.softwareDecrypt(a,t,r,i);const o=this.flush();o?n(o.buffer):s(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,r,i)}softwareDecrypt(e,t,r,i){const{currentIV:n,currentResult:s,remainderData:a}=this;if(i!==Kf||16!==t.byteLength)return _u.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),a&&(e=wh(a,e),this.remainderData=null);const o=this.getValidChunk(e);if(!o.length)return null;n&&(r=n);let l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new Qf),l.expandKey(t);const c=s;return this.currentResult=l.decrypt(o.buffer,0,r),this.currentIV=o.slice(-16).buffer,c||null}webCryptoDecrypt(e,t,r,i){if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,r,i));this.key=t,this.fastAesKey=new Zf(this.subtle,t,i)}return this.fastAesKey.expandKey().then(t=>{if(!this.subtle)return Promise.reject(new Error("web crypto not initialized"));this.logOnce("WebCrypto AES decrypt");return new Xf(this.subtle,new Uint8Array(r),i).decrypt(e.buffer,t)}).catch(n=>(_u.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${n.name}: ${n.message}`),this.onWebCryptoError(e,t,r,i)))}onWebCryptoError(e,t,r,i){const n=this.enableSoftwareAES;if(n){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r,i);const n=this.flush();if(n)return n.buffer}throw new Error("WebCrypto"+(n?" and softwareDecrypt":"")+": failed to decrypt data")}getValidChunk(e){let t=e;const r=e.length-e.length%16;return r!==e.length&&(t=e.slice(0,r),this.remainderData=e.slice(r)),t}logOnce(e){this.logEnabled&&(_u.log(`[decrypter]: ${e}`),this.logEnabled=!1)}}const ep=Math.pow(2,17);class tp{constructor(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(e,t){const r=e.url;if(!r)return Promise.reject(new np({type:uu.NETWORK_ERROR,details:hu.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error("Fragment does not have a "+(r?"part list":"url")),networkDetails:null}));this.abort();const i=this.config,n=i.fLoader,s=i.loader;return new Promise((a,o)=>{if(this.loader&&this.loader.destroy(),e.gap){if(e.tagList.some(e=>"GAP"===e[0]))return void o(ip(e));e.gap=!1}const l=this.loader=n?new n(i):new s(i),c=rp(e);e.loader=l;const d=Lf(i.fragLoadPolicy.default),u={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===e.sn?1/0:ep};e.stats=l.stats;const h={onSuccess:(t,r,i,n)=>{this.resetLoader(e,l);let s=t.data;i.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(s.slice(0,16)),s=s.slice(16)),a({frag:e,part:null,payload:s,networkDetails:n})},onError:(t,i,n,s)=>{this.resetLoader(e,l),o(new np({type:uu.NETWORK_ERROR,details:hu.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:ku({url:r,data:void 0},t),error:new Error(`HTTP Error ${t.code} ${t.text}`),networkDetails:n,stats:s}))},onAbort:(t,r,i)=>{this.resetLoader(e,l),o(new np({type:uu.NETWORK_ERROR,details:hu.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:i,stats:t}))},onTimeout:(t,r,i)=>{this.resetLoader(e,l),o(new np({type:uu.NETWORK_ERROR,details:hu.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${u.timeout}ms`),networkDetails:i,stats:t}))}};t&&(h.onProgress=(r,i,n,s)=>t({frag:e,part:null,payload:n,networkDetails:s})),l.load(c,u,h)})}loadPart(e,t,r){this.abort();const i=this.config,n=i.fLoader,s=i.loader;return new Promise((a,o)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap)return void o(ip(e,t));const l=this.loader=n?new n(i):new s(i),c=rp(e,t);e.loader=l;const d=Lf(i.fragLoadPolicy.default),u={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:ep};t.stats=l.stats,l.load(c,u,{onSuccess:(i,n,s,o)=>{this.resetLoader(e,l),this.updateStatsFromPart(e,t);const c={frag:e,part:t,payload:i.data,networkDetails:o};r(c),a(c)},onError:(r,i,n,s)=>{this.resetLoader(e,l),o(new np({type:uu.NETWORK_ERROR,details:hu.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:ku({url:c.url,data:void 0},r),error:new Error(`HTTP Error ${r.code} ${r.text}`),networkDetails:n,stats:s}))},onAbort:(r,i,n)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,l),o(new np({type:uu.NETWORK_ERROR,details:hu.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:n,stats:r}))},onTimeout:(r,i,n)=>{this.resetLoader(e,l),o(new np({type:uu.NETWORK_ERROR,details:hu.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${u.timeout}ms`),networkDetails:n,stats:r}))}})})}updateStatsFromPart(e,t){const r=e.stats,i=t.stats,n=i.total;if(r.loaded+=i.loaded,n){const i=Math.round(e.duration/t.duration),s=Math.min(Math.round(r.loaded/n),i),a=(i-s)*Math.round(r.loaded/s);r.total=r.loaded+a}else r.total=Math.max(r.loaded,r.total);const s=r.loading,a=i.loading;s.start?s.first+=a.first-a.start:(s.start=a.start,s.first=a.first),s.end=a.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}function rp(e,t=null){const r=t||e,i={frag:e,part:t,responseType:"arraybuffer",url:r.url,headers:{},rangeStart:0,rangeEnd:0},n=r.byteRangeStartOffset,s=r.byteRangeEndOffset;if(lu(n)&&lu(s)){var a;let t=n,r=s;if("initSegment"===e.sn&&("AES-128"===(o=null==(a=e.decryptdata)?void 0:a.method)||"AES-256"===o)){const e=s-n;e%16&&(r=s+(16-e%16)),0!==n&&(i.resetIV=!0,t=n-16)}i.rangeStart=t,i.rangeEnd=r}var o;return i}function ip(e,t){const r=new Error(`GAP ${e.gap?"tag":"attribute"} found`),i={type:uu.MEDIA_ERROR,details:hu.FRAG_GAP,fatal:!1,frag:e,error:r,networkDetails:null};return t&&(i.part=t),(t||e).stats.aborted=!0,new np(i)}class np extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class sp extends Iu{constructor(e,t){super(e,t),this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(e){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)}clearInterval(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)}clearNextTick(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)}tick(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}class ap{constructor(e,t,r,i=0,n=-1,s=!1){this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=e,this.sn=t,this.id=r,this.size=i,this.part=n,this.partial=s}}const op={length:0,start:()=>0,end:()=>0};class lp{static isBuffered(e,t){if(e){const r=lp.getBuffered(e);for(let e=r.length;e--;)if(t>=r.start(e)&&t<=r.end(e))return!0}return!1}static bufferedRanges(e){if(e){const t=lp.getBuffered(e);return lp.timeRangesToArray(t)}return[]}static timeRangesToArray(e){const t=[];for(let r=0;r<e.length;r++)t.push({start:e.start(r),end:e.end(r)});return t}static bufferInfo(e,t,r){if(e){const i=lp.bufferedRanges(e);if(i.length)return lp.bufferedInfo(i,t,r)}return{len:0,start:t,end:t,bufferedIndex:-1}}static bufferedInfo(e,t,r){t=Math.max(0,t),e.length>1&&e.sort((e,t)=>e.start-t.start||t.end-e.end);let i=-1,n=[];if(r)for(let s=0;s<e.length;s++){t>=e[s].start&&t<=e[s].end&&(i=s);const a=n.length;if(a){const t=n[a-1].end;e[s].start-t<r?e[s].end>t&&(n[a-1].end=e[s].end):n.push(e[s])}else n.push(e[s])}else n=e;let s,a=0,o=t,l=t;for(let e=0;e<n.length;e++){const c=n[e].start,d=n[e].end;if(-1===i&&t>=c&&t<=d&&(i=e),t+r>=c&&t<d)o=c,l=d,a=l-t;else if(t+r<c){s=c;break}}return{len:a,start:o||0,end:l||0,nextStart:s,buffered:e,bufferedIndex:i}}static getBuffered(e){try{return e.buffered||op}catch(e){return _u.log("failed to get media.buffered",e),op}}}const cp=/\{\$([a-zA-Z0-9-_]+)\}/g;function dp(e){return cp.test(e)}function up(e,t){if(null!==e.variableList||e.hasVariableRefs){const r=e.variableList;return t.replace(cp,t=>{const i=t.substring(2,t.length-1),n=null==r?void 0:r[i];return void 0===n?(e.playlistParsingError||(e.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${i}"`)),t):n})}return t}function hp(e,t,r){let i,n,s=e.variableList;if(s||(e.variableList=s={}),"QUERYPARAM"in t){i=t.QUERYPARAM;try{const e=new self.URL(r).searchParams;if(!e.has(i))throw new Error(`"${i}" does not match any query parameter in URI: "${r}"`);n=e.get(i)}catch(t){e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${t.message}`))}}else i=t.NAME,n=t.VALUE;i in s?e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${i}"`)):s[i]=n||""}function fp(e,t,r){const i=t.IMPORT;if(r&&i in r){let t=e.variableList;t||(e.variableList=t={}),t[i]=r[i]}else e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${i}"`))}const pp=/^(\d+)x(\d+)$/,mp=/(.+?)=(".*?"|.*?)(?:,|$)/g;class gp{constructor(e,t){"string"==typeof e&&(e=gp.parseAttrList(e,t)),xu(this,e)}get clientAttrs(){return Object.keys(this).filter(e=>"X-"===e.substring(0,2))}decimalInteger(e){const t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}hexadecimalInteger(e){if(this[e]){let t=(this[e]||"0x").slice(2);t=(1&t.length?"0":"")+t;const r=new Uint8Array(t.length/2);for(let e=0;e<t.length/2;e++)r[e]=parseInt(t.slice(2*e,2*e+2),16);return r}return null}hexadecimalIntegerAsNumber(e){const t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,t){const r=this[e];return r?parseFloat(r):t}enumeratedString(e){return this[e]}enumeratedStringList(e,t){const r=this[e];return(r?r.split(/[ ,]+/):[]).reduce((e,t)=>(e[t.toLowerCase()]=!0,e),t)}bool(e){return"YES"===this[e]}decimalResolution(e){const t=pp.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e,t){let r;const i={};for(mp.lastIndex=0;null!==(r=mp.exec(e));){const n=r[1].trim();let s=r[2];const a=0===s.indexOf('"')&&s.lastIndexOf('"')===s.length-1;let o=!1;if(a)s=s.slice(1,-1);else switch(n){case"IV":case"SCTE35-CMD":case"SCTE35-IN":case"SCTE35-OUT":o=!0}if(t&&(a||o))s=up(t,s);else if(!o&&!a)switch(n){case"CLOSED-CAPTIONS":if("NONE"===s)break;case"ALLOWED-CPC":case"CLASS":case"ASSOC-LANGUAGE":case"AUDIO":case"BYTERANGE":case"CHANNELS":case"CHARACTERISTICS":case"CODECS":case"DATA-ID":case"END-DATE":case"GROUP-ID":case"ID":case"IMPORT":case"INSTREAM-ID":case"KEYFORMAT":case"KEYFORMATVERSIONS":case"LANGUAGE":case"NAME":case"PATHWAY-ID":case"QUERYPARAM":case"RECENTLY-REMOVED-DATERANGES":case"SERVER-URI":case"STABLE-RENDITION-ID":case"STABLE-VARIANT-ID":case"START-DATE":case"SUBTITLES":case"SUPPLEMENTAL-CODECS":case"URI":case"VALUE":case"VIDEO":case"X-ASSET-LIST":case"X-ASSET-URI":_u.warn(`${e}: attribute ${n} is missing quotes`)}i[n]=s}return i}}function vp(e){return"ID"!==e&&"CLASS"!==e&&"CUE"!==e&&"START-DATE"!==e&&"DURATION"!==e&&"END-DATE"!==e&&"END-ON-NEXT"!==e}function yp(e){return"SCTE35-OUT"===e||"SCTE35-IN"===e||"SCTE35-CMD"===e}class bp{constructor(e,t,r=0){var i;if(this.attr=void 0,this.tagAnchor=void 0,this.tagOrder=void 0,this._startDate=void 0,this._endDate=void 0,this._dateAtEnd=void 0,this._cue=void 0,this._badValueForSameId=void 0,this.tagAnchor=(null==t?void 0:t.tagAnchor)||null,this.tagOrder=null!=(i=null==t?void 0:t.tagOrder)?i:r,t){const r=t.attr;for(const t in r)if(Object.prototype.hasOwnProperty.call(e,t)&&e[t]!==r[t]){_u.warn(`DATERANGE tag attribute: "${t}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=t;break}e=xu(new gp({}),r,e)}if(this.attr=e,t?(this._startDate=t._startDate,this._cue=t._cue,this._endDate=t._endDate,this._dateAtEnd=t._dateAtEnd):this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){const e=(null==t?void 0:t.endDate)||new Date(this.attr["END-DATE"]);lu(e.getTime())&&(this._endDate=e)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get cue(){const e=this._cue;return void 0===e?this._cue=this.attr.enumeratedStringList(this.attr.CUE?"CUE":"X-CUE",{pre:!1,post:!1,once:!1}):e}get startTime(){const{tagAnchor:e}=this;return null===e||null===e.programDateTime?(_u.warn(`Expected tagAnchor Fragment with PDT set for DateRange "${this.id}": ${e}`),NaN):e.start+(this.startDate.getTime()-e.programDateTime)/1e3}get startDate(){return this._startDate}get endDate(){const e=this._endDate||this._dateAtEnd;if(e)return e;const t=this.duration;return null!==t?this._dateAtEnd=new Date(this._startDate.getTime()+1e3*t):null}get duration(){if("DURATION"in this.attr){const e=this.attr.decimalFloatingPoint("DURATION");if(lu(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isInterstitial(){return"com.apple.hls.interstitial"===this.class}get isValid(){return!!this.id&&!this._badValueForSameId&&lu(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)&&(!this.attr.CUE||!this.cue.pre&&!this.cue.post||this.cue.pre!==this.cue.post)&&(!this.isInterstitial||"X-ASSET-URI"in this.attr||"X-ASSET-LIST"in this.attr)}}class Ep{constructor(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.dateRangeTagCount=0,this.live=!0,this.requestScheduled=-1,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.appliedTimelineOffset=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}reloaded(e){if(!e)return this.advanced=!0,void(this.updated=!0);const t=this.lastPartSn-e.lastPartSn,r=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!r||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||0===t&&r>0,this.updated||this.advanced?this.misses=Math.floor(.6*e.misses):this.misses=e.misses+1}hasKey(e){return this.encryptedFragments.some(t=>{let r=t.decryptdata;return r||(t.setKeyFormat(e.keyFormat),r=t.decryptdata),!!r&&e.matches(r)})}get hasProgramDateTime(){return!!this.fragments.length&&lu(this.fragments[this.fragments.length-1].programDateTime)}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||10}get drift(){const e=this.driftEndTime-this.driftStartTime;if(e>0){return 1e3*(this.driftEnd-this.driftStart)/e}return 1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){return this.fragments.length?this.fragments[this.fragments.length-1].end:0}get fragmentStart(){return this.fragments.length?this.fragments[0].start:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].index:-1}get maxPartIndex(){const e=this.partList;if(e){const t=this.lastPartIndex;if(-1!==t){for(let r=e.length;r--;)if(e[r].index>t)return e[r].index;return t}}return 0}get lastPartSn(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}get expired(){if(this.live&&this.age&&this.misses<3){const e=this.partEnd-this.fragmentStart;return this.age>Math.max(e,this.totalduration)+this.levelTargetDuration}return!1}}function wp(e,t){return e.length===t.length&&!e.some((e,r)=>e!==t[r])}function Sp(e,t){return!e&&!t||!(!e||!t)&&wp(e,t)}function Tp(e){return"AES-128"===e||"AES-256"===e||"AES-256-CTR"===e}function xp(e){switch(e){case"AES-128":case"AES-256":return Kf;case"AES-256-CTR":return qf;default:throw new Error(`invalid full segment method ${e}`)}}function Ap(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0))}function kp(e){return Uint8Array.from(unescape(encodeURIComponent(e)),e=>e.charCodeAt(0))}function Ip(e){const t=function(e,t,r){const i=e[t];e[t]=e[r],e[r]=i};t(e,0,3),t(e,1,2),t(e,4,5),t(e,6,7)}function Lp(e){const t=e.split(":");let r=null;if("data"===t[0]&&2===t.length){const e=t[1].split(";"),i=e[e.length-1].split(",");if(2===i.length){const t="base64"===i[0],n=i[1];t?(e.splice(-1,1),r=Ap(n)):r=function(e){const t=kp(e).subarray(0,16),r=new Uint8Array(16);return r.set(t,16-t.length),r}(n)}}return r}const Rp="undefined"!=typeof self?self:void 0;var Pp={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Cp="org.w3.clearkey",Dp="com.apple.streamingkeydelivery",_p="com.microsoft.playready",Op="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function Mp(e){switch(e){case Dp:return Pp.FAIRPLAY;case _p:return Pp.PLAYREADY;case Op:return Pp.WIDEVINE;case Cp:return Pp.CLEARKEY}}function Np(e){switch(e){case Pp.FAIRPLAY:return Dp;case Pp.PLAYREADY:return _p;case Pp.WIDEVINE:return Op;case Pp.CLEARKEY:return Cp}}function Fp(e){const{drmSystems:t,widevineLicenseUrl:r}=e,i=t?[Pp.FAIRPLAY,Pp.WIDEVINE,Pp.PLAYREADY,Pp.CLEARKEY].filter(e=>!!t[e]):[];return!i[Pp.WIDEVINE]&&r&&i.push(Pp.WIDEVINE),i}const $p=null!=Rp&&null!=(Bp=Rp.navigator)&&Bp.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;var Bp;function Up(e){const t=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),r=String.fromCharCode.apply(null,Array.from(t)),i=r.substring(r.indexOf("<"),r.length),n=(new DOMParser).parseFromString(i,"text/xml").getElementsByTagName("KID")[0];if(n){const e=n.childNodes[0]?n.childNodes[0].nodeValue:n.getAttribute("VALUE");if(e){const t=Ap(e).subarray(0,16);return Ip(t),t}}return null}let zp={};class Gp{static clearKeyUriToKeyIdMap(){zp={}}static setKeyIdForUri(e,t){zp[e]=t}static addKeyIdForUri(e){const t=Object.keys(zp).length%Number.MAX_SAFE_INTEGER,r=new Uint8Array(16);return new DataView(r.buffer,12,4).setUint32(0,t),zp[e]=r,r}constructor(e,t,r,i=[1],n=null,s){this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=e,this.uri=t,this.keyFormat=r,this.keyFormatVersions=i,this.iv=n,this.encrypted=!!e&&"NONE"!==e,this.isCommonEncryption=this.encrypted&&!Tp(e),null!=s&&s.startsWith("0x")&&(this.keyId=new Uint8Array($u(s)))}matches(e){return e.uri===this.uri&&e.method===this.method&&e.encrypted===this.encrypted&&e.keyFormat===this.keyFormat&&wp(e.keyFormatVersions,this.keyFormatVersions)&&Sp(e.iv,this.iv)&&Sp(e.keyId,this.keyId)}isSupported(){if(this.method){if(Tp(this.method)||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method;switch(this.keyFormat){case Dp:case Op:case _p:case Cp:return-1!==["SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)}}return!1}getDecryptData(e,t){if(!this.encrypted||!this.uri)return null;if(Tp(this.method)){let t=this.iv;t||("number"!=typeof e&&(_u.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0),t=function(e){const t=new Uint8Array(16);for(let r=12;r<16;r++)t[r]=e>>8*(15-r)&255;return t}(e));return new Gp(this.method,this.uri,"identity",this.keyFormatVersions,t)}if(this.keyId){const e=zp[this.uri];if(e&&!wp(this.keyId,e)&&Gp.setKeyIdForUri(this.uri,this.keyId),this.pssh)return this}const r=Lp(this.uri);if(r)switch(this.keyFormat){case Op:if(this.pssh=r,!this.keyId){const e=function(e){const t=[];if(e instanceof ArrayBuffer){const r=e.byteLength;let i=0;for(;i+32<r;){const r=Lh(new DataView(e,i));t.push(r),i+=r.size}}return t}(r.buffer);if(e.length){var i;const t=e[0];this.keyId=null!=(i=t.kids)&&i.length?t.kids[0]:null}}this.keyId||(this.keyId=jp(t));break;case _p:{const e=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=Ih(e,0,r),this.keyId=Up(r);break}default:{let e=r.subarray(0,16);if(16!==e.length){const t=new Uint8Array(16);t.set(e,16-e.length),e=t}this.keyId=e;break}}if(!this.keyId||16!==this.keyId.byteLength){let e;e=function(e){const t=null==e?void 0:e[Op];if(t)return t.keyId;return null}(t),e||(e=jp(t),e||(e=zp[this.uri])),e&&(this.keyId=e,Gp.setKeyIdForUri(this.uri,e))}return this}}function jp(e){const t=null==e?void 0:e[_p];if(t){const e=Lp(t.uri);if(e)return Up(e)}return null}const Hp=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,Vp=/#EXT-X-MEDIA:(.*)/g,Wp=/^#EXT(?:INF|-X-TARGETDURATION):/m,Yp=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),Kp=new RegExp([/#EXT-X-(PROGRAM-DATE-TIME|BYTERANGE|DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|"));class qp{static findGroup(e,t){for(let r=0;r<e.length;r++){const i=e[r];if(i.id===t)return i}}static resolve(e,t){return Yu.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return Wp.test(e)}static parseMasterPlaylist(e,t){const r={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:dp(e)},i=[];if(Hp.lastIndex=0,!e.startsWith("#EXTM3U"))return r.playlistParsingError=new Error("no EXTM3U delimiter"),r;let n;for(;null!=(n=Hp.exec(e));)if(n[1]){var s;const e=new gp(n[1],r),a=up(r,n[2]),o={attrs:e,bitrate:e.decimalInteger("BANDWIDTH")||e.decimalInteger("AVERAGE-BANDWIDTH"),name:e.NAME,url:qp.resolve(a,t)},l=e.decimalResolution("RESOLUTION");l&&(o.width=l.width,o.height=l.height),em(e.CODECS,o);const c=e["SUPPLEMENTAL-CODECS"];c&&(o.supplemental={},em(c,o.supplemental)),null!=(s=o.unknownCodecs)&&s.length||i.push(o),r.levels.push(o)}else if(n[3]){const e=n[3],i=n[4];switch(e){case"SESSION-DATA":{const e=new gp(i,r),t=e["DATA-ID"];t&&(null===r.sessionData&&(r.sessionData={}),r.sessionData[t]=e);break}case"SESSION-KEY":{const e=Zp(i,t,r);e.encrypted&&e.isSupported()?(null===r.sessionKeys&&(r.sessionKeys=[]),r.sessionKeys.push(e)):_u.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${i}"`);break}case"DEFINE":hp(r,new gp(i,r),t);break;case"CONTENT-STEERING":{const e=new gp(i,r);r.contentSteering={uri:qp.resolve(e["SERVER-URI"],t),pathwayId:e["PATHWAY-ID"]||"."};break}case"START":r.startTimeOffset=Jp(i)}}const a=i.length>0&&i.length<r.levels.length;return r.levels=a?i:r.levels,0===r.levels.length&&(r.playlistParsingError=new Error("no levels found in manifest")),r}static parseMasterPlaylistMedia(e,t,r){let i;const n={},s=r.levels,a={AUDIO:s.map(e=>({id:e.attrs.AUDIO,audioCodec:e.audioCodec})),SUBTITLES:s.map(e=>({id:e.attrs.SUBTITLES,textCodec:e.textCodec})),"CLOSED-CAPTIONS":[]};let o=0;for(Vp.lastIndex=0;null!==(i=Vp.exec(e));){const e=new gp(i[1],r),s=e.TYPE;if(s){const r=a[s],i=n[s]||[];n[s]=i;const l=e.LANGUAGE,c=e["ASSOC-LANGUAGE"],d=e.CHANNELS,u=e.CHARACTERISTICS,h=e["INSTREAM-ID"],f={attrs:e,bitrate:0,id:o++,groupId:e["GROUP-ID"]||"",name:e.NAME||l||"",type:s,default:e.bool("DEFAULT"),autoselect:e.bool("AUTOSELECT"),forced:e.bool("FORCED"),lang:l,url:e.URI?qp.resolve(e.URI,t):""};if(c&&(f.assocLang=c),d&&(f.channels=d),u&&(f.characteristics=u),h&&(f.instreamId=h),null!=r&&r.length){const e=qp.findGroup(r,f.groupId)||r[0];tm(f,e,"audioCodec"),tm(f,e,"textCodec")}i.push(f)}}return n}static parseLevelPlaylist(e,t,r,i,n,s){var a;const o={url:t},l=new Ep(t),c=l.fragments,d=[];let u,h,f,p,m=null,g=0,v=0,y=0,b=0,E=0,w=null,S=new eh(i,o),T=-1,x=!1,A=null;if(Yp.lastIndex=0,l.m3u8=e,l.hasVariableRefs=dp(e),"#EXTM3U"!==(null==(a=Yp.exec(e))?void 0:a[0]))return l.playlistParsingError=new Error("Missing format identifier #EXTM3U"),l;for(;null!==(u=Yp.exec(e));){x&&(x=!1,S=new eh(i,o),S.playlistOffset=y,S.setStart(y),S.sn=g,S.cc=b,E&&(S.bitrate=E),S.level=r,m&&(S.initSegment=m,m.rawProgramDateTime&&(S.rawProgramDateTime=m.rawProgramDateTime,m.rawProgramDateTime=null),A&&(S.setByteRange(A),A=null)));const e=u[1];if(e){S.duration=parseFloat(e);const t=(" "+u[2]).slice(1);S.title=t||null,S.tagList.push(t?["INF",e,t]:["INF",e])}else if(u[3]){if(lu(S.duration)){S.playlistOffset=y,S.setStart(y),f&&nm(S,f,l),S.sn=g,S.level=r,S.cc=b,c.push(S);const e=(" "+u[3]).slice(1);S.relurl=up(l,e),rm(S,w,d),w=S,y+=S.duration,g++,v=0,x=!0}}else{if(u=u[0].match(Kp),!u){_u.warn("No matches on slow regex match for level playlist!");continue}for(h=1;h<u.length&&void 0===u[h];h++);const e=(" "+u[h]).slice(1),n=(" "+u[h+1]).slice(1),a=u[h+2]?(" "+u[h+2]).slice(1):null;switch(e){case"BYTERANGE":w?S.setByteRange(n,w):S.setByteRange(n);break;case"PROGRAM-DATE-TIME":S.rawProgramDateTime=n,S.tagList.push(["PROGRAM-DATE-TIME",n]),-1===T&&(T=c.length);break;case"PLAYLIST-TYPE":l.type&&sm(l,e,u),l.type=n.toUpperCase();break;case"MEDIA-SEQUENCE":0!==l.startSN?sm(l,e,u):c.length>0&&am(l,e,u),g=l.startSN=parseInt(n);break;case"SKIP":{l.skippedSegments&&sm(l,e,u);const t=new gp(n,l),r=t.decimalInteger("SKIPPED-SEGMENTS");if(lu(r)){l.skippedSegments+=r;for(let e=r;e--;)c.push(null);g+=r}const i=t.enumeratedString("RECENTLY-REMOVED-DATERANGES");i&&(l.recentlyRemovedDateranges=(l.recentlyRemovedDateranges||[]).concat(i.split("\t")));break}case"TARGETDURATION":0!==l.targetduration&&sm(l,e,u),l.targetduration=Math.max(parseInt(n),1);break;case"VERSION":null!==l.version&&sm(l,e,u),l.version=parseInt(n);break;case"INDEPENDENT-SEGMENTS":break;case"ENDLIST":l.live||sm(l,e,u),l.live=!1;break;case"#":(n||a)&&S.tagList.push(a?[n,a]:[n]);break;case"DISCONTINUITY":b++,S.tagList.push(["DIS"]);break;case"GAP":S.gap=!0,S.tagList.push([e]);break;case"BITRATE":S.tagList.push([e,n]),E=1e3*parseInt(n),lu(E)?S.bitrate=E:E=0;break;case"DATERANGE":{const e=new gp(n,l),t=new bp(e,l.dateRanges[e.ID],l.dateRangeTagCount);l.dateRangeTagCount++,t.isValid||l.skippedSegments?l.dateRanges[t.id]=t:_u.warn(`Ignoring invalid DATERANGE tag: "${n}"`),S.tagList.push(["EXT-X-DATERANGE",n]);break}case"DEFINE":{const e=new gp(n,l);"IMPORT"in e?fp(l,e,s):hp(l,e,t)}break;case"DISCONTINUITY-SEQUENCE":0!==l.startCC?sm(l,e,u):c.length>0&&am(l,e,u),l.startCC=b=parseInt(n);break;case"KEY":{const e=Zp(n,t,l);if(e.isSupported()){if("NONE"===e.method){f=void 0;break}f||(f={});const t=f[e.keyFormat];null!=t&&t.matches(e)||(t&&(f=xu({},f)),f[e.keyFormat]=e)}else _u.warn(`[Keys] Ignoring unsupported EXT-X-KEY tag: "${n}"`);break}case"START":l.startTimeOffset=Jp(n);break;case"MAP":{const e=new gp(n,l);if(S.duration){const t=new eh(i,o);im(t,e,r,f),m=t,S.initSegment=m,m.rawProgramDateTime&&!S.rawProgramDateTime&&(S.rawProgramDateTime=m.rawProgramDateTime)}else{const t=S.byteRangeEndOffset;if(t){const e=S.byteRangeStartOffset;A=`${t-e}@${e}`}else A=null;im(S,e,r,f),m=S,x=!0}m.cc=b;break}case"SERVER-CONTROL":p&&sm(l,e,u),p=new gp(n),l.canBlockReload=p.bool("CAN-BLOCK-RELOAD"),l.canSkipUntil=p.optionalFloat("CAN-SKIP-UNTIL",0),l.canSkipDateRanges=l.canSkipUntil>0&&p.bool("CAN-SKIP-DATERANGES"),l.partHoldBack=p.optionalFloat("PART-HOLD-BACK",0),l.holdBack=p.optionalFloat("HOLD-BACK",0);break;case"PART-INF":{l.partTarget&&sm(l,e,u);const t=new gp(n);l.partTarget=t.decimalFloatingPoint("PART-TARGET");break}case"PART":{let e=l.partList;e||(e=l.partList=[]);const t=v>0?e[e.length-1]:void 0,r=v++,i=new gp(n,l),s=new th(i,S,o,r,t);e.push(s),S.duration+=s.duration;break}case"PRELOAD-HINT":{const e=new gp(n,l);l.preloadHint=e;break}case"RENDITION-REPORT":{const e=new gp(n,l);l.renditionReports=l.renditionReports||[],l.renditionReports.push(e);break}default:_u.warn(`line parsed but not handled: ${u}`)}}}w&&!w.relurl?(c.pop(),y-=w.duration,l.partList&&(l.fragmentHint=w)):l.partList&&(rm(S,w,d),S.cc=b,l.fragmentHint=S,f&&nm(S,f,l)),l.targetduration||(l.playlistParsingError=new Error("Missing Target Duration"));const k=c.length,I=c[0],L=c[k-1];if(y+=l.skippedSegments*l.targetduration,y>0&&k&&L){l.averagetargetduration=y/k;const e=L.sn;l.endSN="initSegment"!==e?e:0,l.live||(L.endList=!0),T>0&&(!function(e,t){let r=e[t];for(let i=t;i--;){const t=e[i];if(!t)return;t.programDateTime=r.programDateTime-1e3*t.duration,r=t}}(c,T),I&&d.unshift(I))}return l.fragmentHint&&(y+=l.fragmentHint.duration),l.totalduration=y,d.length&&l.dateRangeTagCount&&I&&Xp(d,l),l.endCC=b,l}}function Xp(e,t){let r=e.length;if(!r){if(!t.hasProgramDateTime)return;{const i=t.fragments[t.fragments.length-1];e.push(i),r++}}const i=e[r-1],n=t.live?1/0:t.totalduration,s=Object.keys(t.dateRanges);for(let o=s.length;o--;){const l=t.dateRanges[s[o]],c=l.startDate.getTime();l.tagAnchor=i.ref;for(let i=r;i--;){var a;if((null==(a=e[i])?void 0:a.sn)<t.startSN)break;const r=Qp(t,c,e,i,n);if(-1!==r){l.tagAnchor=t.fragments[r].ref;break}}}}function Qp(e,t,r,i,n){const s=r[i];if(s){const o=s.programDateTime;if(t>=o||0===i){var a;if(t<=o+1e3*(((null==(a=r[i+1])?void 0:a.start)||n)-s.start)){const n=r[i].sn-e.startSN;if(n<0)return-1;const s=e.fragments;if(s.length>r.length){for(let a=(r[i+1]||s[s.length-1]).sn-e.startSN;a>n;a--){const e=s[a].programDateTime;if(t>=e&&t<e+1e3*s[a].duration)return a}}return n}}}return-1}function Zp(e,t,r){var i,n;const s=new gp(e,r),a=null!=(i=s.METHOD)?i:"",o=s.URI,l=s.hexadecimalInteger("IV"),c=s.KEYFORMATVERSIONS,d=null!=(n=s.KEYFORMAT)?n:"identity";o&&s.IV&&!l&&_u.error(`Invalid IV: ${s.IV}`);const u=o?qp.resolve(o,t):"",h=(c||"1").split("/").map(Number).filter(Number.isFinite);return new Gp(a,u,d,h,l,s.KEYID)}function Jp(e){const t=new gp(e).decimalFloatingPoint("TIME-OFFSET");return lu(t)?t:null}function em(e,t){let r=(e||"").split(/[ ,]+/).filter(e=>e);["video","audio","text"].forEach(e=>{const i=r.filter(t=>Ch(t,e));i.length&&(t[`${e}Codec`]=i.map(e=>e.split("/")[0]).join(","),r=r.filter(e=>-1===i.indexOf(e)))}),t.unknownCodecs=r}function tm(e,t,r){const i=t[r];i&&(e[r]=i)}function rm(e,t,r){e.rawProgramDateTime?r.push(e):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime)}function im(e,t,r,i){e.relurl=t.URI,t.BYTERANGE&&e.setByteRange(t.BYTERANGE),e.level=r,e.sn="initSegment",i&&(e.levelkeys=i),e.initSegment=null}function nm(e,t,r){e.levelkeys=t;const{encryptedFragments:i}=r;i.length&&i[i.length-1].levelkeys===t||!Object.keys(t).some(e=>t[e].isCommonEncryption)||i.push(e)}function sm(e,t,r){e.playlistParsingError=new Error(`#EXT-X-${t} must not appear more than once (${r[0]})`)}function am(e,t,r){e.playlistParsingError=new Error(`#EXT-X-${t} must appear before the first Media Segment (${r[0]})`)}function om(e,t){const r=t.startPTS;if(lu(r)){let i,n=0;t.sn>e.sn?(n=r-e.start,i=e):(n=e.start-r,i=t),i.duration!==n&&i.setDuration(n)}else if(t.sn>e.sn){e.cc===t.cc&&e.minEndPTS?t.setStart(e.start+(e.minEndPTS-e.start)):t.setStart(e.start+e.duration)}else t.setStart(Math.max(e.start-t.duration,0))}function lm(e,t,r,i,n,s,a){i-r<=0&&(a.warn("Fragment should have a positive duration",t),i=r+t.duration,s=n+t.duration);let o=r,l=i;const c=t.startPTS,d=t.endPTS;if(lu(c)){const u=Math.abs(c-r);e&&u>e.totalduration?a.warn(`media timestamps and playlist times differ by ${u}s for level ${t.level} ${e.url}`):lu(t.deltaPTS)?t.deltaPTS=Math.max(u,t.deltaPTS):t.deltaPTS=u,o=Math.max(r,c),r=Math.min(r,c),n=void 0!==t.startDTS?Math.min(n,t.startDTS):n,l=Math.min(i,d),i=Math.max(i,d),s=void 0!==t.endDTS?Math.max(s,t.endDTS):s}const u=r-t.start;0!==t.start&&t.setStart(r),t.setDuration(i-t.start),t.startPTS=r,t.maxStartPTS=o,t.startDTS=n,t.endPTS=i,t.minEndPTS=l,t.endDTS=s;const h=t.sn;if(!e||h<e.startSN||h>e.endSN)return 0;let f;const p=h-e.startSN,m=e.fragments;for(m[p]=t,f=p;f>0;f--)om(m[f],m[f-1]);for(f=p;f<m.length-1;f++)om(m[f],m[f+1]);return e.fragmentHint&&om(m[m.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,u}function cm(e,t,r){if(e===t)return;let i=null;const n=e.fragments;for(let e=n.length-1;e>=0;e--){const t=n[e].initSegment;if(t){i=t;break}}let s;e.fragmentHint&&delete e.fragmentHint.endPTS,function(e,t,r){const i=t.skippedSegments,n=Math.max(e.startSN,t.startSN)-t.startSN,s=(e.fragmentHint?1:0)+(i?t.endSN:Math.min(e.endSN,t.endSN))-t.startSN,a=t.startSN-e.startSN,o=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,l=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments;for(let c=n;c<=s;c++){const n=l[a+c];let s=o[c];if(i&&!s&&n&&(s=t.fragments[c]=n),n&&s){r(n,s,c,o);const i=n.relurl,a=s.relurl;if(i&&ym(i,a))return void(t.playlistParsingError=dm(`media sequence mismatch ${s.sn}:`,e,t,n,s));if(n.cc!==s.cc)return void(t.playlistParsingError=dm(`discontinuity sequence mismatch (${n.cc}!=${s.cc})`,e,t,n,s))}}}(e,t,(e,r,n,a)=>{if((!t.startCC||t.skippedSegments)&&r.cc!==e.cc){const i=e.cc-r.cc;for(let e=n;e<a.length;e++)a[e].cc+=i;t.endCC=a[a.length-1].cc}lu(e.startPTS)&&lu(e.endPTS)&&(r.setStart(r.startPTS=e.startPTS),r.startDTS=e.startDTS,r.maxStartPTS=e.maxStartPTS,r.endPTS=e.endPTS,r.endDTS=e.endDTS,r.minEndPTS=e.minEndPTS,r.setDuration(e.endPTS-e.startPTS),r.duration&&(s=r),t.PTSKnown=t.alignedSliding=!0),e.hasStreams&&(r.elementaryStreams=e.elementaryStreams),r.loader=e.loader,e.hasStats&&(r.stats=e.stats),e.initSegment&&(r.initSegment=e.initSegment,i=e.initSegment)});const a=t.fragments,o=t.fragmentHint?a.concat(t.fragmentHint):a;if(i&&o.forEach(e=>{var t;!e||e.initSegment&&e.initSegment.relurl!==(null==(t=i)?void 0:t.relurl)||(e.initSegment=i)}),t.skippedSegments){if(t.deltaUpdateFailed=a.some(e=>!e),t.deltaUpdateFailed){r.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let e=t.skippedSegments;e--;)a.shift();t.startSN=a[0].sn}else{t.canSkipDateRanges&&(t.dateRanges=function(e,t,r){const{dateRanges:i,recentlyRemovedDateranges:n}=t,s=xu({},e);n&&n.forEach(e=>{delete s[e]});const a=Object.keys(s).length;if(!a)return i;return Object.keys(i).forEach(e=>{const t=s[e],n=new bp(i[e].attr,t);n.isValid?(s[e]=n,t||(n.tagOrder+=a)):r.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${cf(i[e].attr)}"`)}),s}(e.dateRanges,t,r));const i=e.fragments.filter(e=>e.rawProgramDateTime);if(e.hasProgramDateTime&&!t.hasProgramDateTime)for(let e=1;e<o.length;e++)null===o[e].programDateTime&&rm(o[e],o[e-1],i);Xp(i,t)}t.endCC=a[a.length-1].cc}if(!t.startCC){var l;const r=pm(e,t.startSN-1);t.startCC=null!=(l=null==r?void 0:r.cc)?l:a[0].cc}!function(e,t,r){if(e&&t){let i=0;for(let n=0,s=e.length;n<=s;n++){const s=e[n],a=t[n+i];s&&a&&s.index===a.index&&s.fragment.sn===a.fragment.sn?r(s,a):i--}}}(e.partList,t.partList,(e,t)=>{t.elementaryStreams=e.elementaryStreams,t.stats=e.stats}),s?lm(t,s,s.startPTS,s.endPTS,s.startDTS,s.endDTS,r):um(e,t),a.length&&(t.totalduration=t.edge-a[0].start),t.driftStartTime=e.driftStartTime,t.driftStart=e.driftStart;const c=t.advancedDateTime;if(t.advanced&&c){const e=t.edge;t.driftStart||(t.driftStartTime=c,t.driftStart=e),t.driftEndTime=c,t.driftEnd=e}else t.driftEndTime=e.driftEndTime,t.driftEnd=e.driftEnd,t.advancedDateTime=e.advancedDateTime;-1===t.requestScheduled&&(t.requestScheduled=e.requestScheduled)}function dm(e,t,r,i,n){return new Error(`${e} ${n.url}\nPlaylist starting @${t.startSN}\n${t.m3u8}\n\nPlaylist starting @${r.startSN}\n${r.m3u8}`)}function um(e,t,r=!0){const i=t.startSN+t.skippedSegments-e.startSN,n=e.fragments,s=i>=0;let a=0;if(s&&i<n.length)a=n[i].start;else if(s&&t.startSN===e.endSN+1)a=e.fragmentEnd;else if(s&&r)a=e.fragmentStart+i*t.levelTargetDuration;else{if(t.skippedSegments||0!==t.fragmentStart)return;a=e.fragmentStart}hm(t,a)}function hm(e,t){if(t){const r=e.fragments;for(let i=e.skippedSegments;i<r.length;i++)r[i].addStart(t);e.fragmentHint&&e.fragmentHint.addStart(t)}}function fm(e,t=1/0){let r=1e3*e.targetduration;if(e.updated){const i=e.fragments,n=4;if(i.length&&r*n>t){const e=1e3*i[i.length-1].duration;e<r&&(r=e)}}else r/=2;return Math.round(r)}function pm(e,t,r){if(!e)return null;let i=e.fragments[t-e.startSN];return i||(i=e.fragmentHint,i&&i.sn===t?i:t<e.startSN&&r&&r.sn===t?r:null)}function mm(e,t,r){return e?gm(e.partList,t,r):null}function gm(e,t,r){if(e)for(let i=e.length;i--;){const n=e[i];if(n.index===r&&n.fragment.sn===t)return n}return null}function vm(e){e.forEach((e,t)=>{var r;null==(r=e.details)||r.fragments.forEach(e=>{e.level=t,e.initSegment&&(e.initSegment.level=t)})})}function ym(e,t){return!(e===t||!t)&&bm(e)!==bm(t)}function bm(e){return e.replace(/\?[^?]*$/,"")}function Em(e,t){for(let i=0,n=e.length;i<n;i++){var r;if((null==(r=e[i])?void 0:r.cc)===t)return e[i]}return null}function wm(e,t){const r=e.start+t;e.startPTS=r,e.setStart(r),e.endPTS=r+e.duration}function Sm(e,t){const r=t.fragments;for(let t=0,i=r.length;t<i;t++)wm(r[t],e);t.fragmentHint&&wm(t.fragmentHint,e),t.alignedSliding=!0}function Tm(e,t){if(!function(e,t){return!!(e&&t.startCC<e.endCC&&t.endCC>e.startCC)}(t,e))return;const r=Math.min(t.endCC,e.endCC),i=Em(t.fragments,r),n=Em(e.fragments,r);if(!i||!n)return;_u.log(`Aligning playlist at start of dicontinuity sequence ${r}`);Sm(i.start-n.start,e)}function xm(e,t){if(!e.hasProgramDateTime||!t.hasProgramDateTime)return;const r=e.fragments,i=t.fragments;if(!r.length||!i.length)return;let n,s;const a=Math.min(t.endCC,e.endCC);t.startCC<a&&e.startCC<a&&(n=Em(i,a),s=Em(r,a)),n&&s||(n=i[Math.floor(i.length/2)],s=Em(r,n.cc)||r[Math.floor(r.length/2)]);const o=n.programDateTime,l=s.programDateTime;if(!o||!l)return;Sm((l-o)/1e3-(s.start-n.start),e)}function Am(e,t,r){km(e,t,r),e.addEventListener(t,r)}function km(e,t,r){e.removeEventListener(t,r)}const Im=function(e){let t="";const r=e.length;for(let i=0;i<r;i++)t+=`[${e.start(i).toFixed(3)}-${e.end(i).toFixed(3)}]`;return t},Lm="STOPPED",Rm="IDLE",Pm="KEY_LOADING",Cm="FRAG_LOADING",Dm="FRAG_LOADING_WAITING_RETRY",_m="WAITING_TRACK",Om="PARSING",Mm="PARSED",Nm="ENDED",Fm="ERROR",$m="WAITING_INIT_PTS",Bm="WAITING_LEVEL";class Um extends sp{constructor(e,t,r,i,n){super(i,e.logger),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=Lm,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.buffering=!0,this.loadingParts=!1,this.loopSn=void 0,this.onMediaSeeking=()=>{const{config:e,fragCurrent:t,media:r,mediaBuffer:i,state:n}=this,s=r?r.currentTime:0,a=lp.bufferInfo(i||r,s,e.maxBufferHole),o=!a.len;if(this.log(`Media seeking to ${lu(s)?s.toFixed(3):s}, state: ${n}, ${o?"out of":"in"} buffer`),this.state===Nm)this.resetLoadingState();else if(t){const r=e.maxFragLookUpTolerance,i=t.start-r,n=t.start+t.duration+r;if(o||n<a.start||i>a.end){const e=s>n;(s<i||e)&&(e&&t.loader&&(this.log(`Cancelling fragment load for seek (sn: ${t.sn})`),t.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}if(r){this.fragmentTracker.removeFragmentsInRange(s,1/0,this.playlistType,!0);if(s>this.lastCurrentTime&&(this.lastCurrentTime=s),!this.loadingParts){const e=Math.max(a.end,s),t=this.shouldLoadParts(this.getLevelDetails(),e);t&&(this.log(`LL-Part loading ON after seeking to ${s.toFixed(2)} with buffer @${e.toFixed(2)}`),this.loadingParts=t)}}this.hls.hasEnoughToStart||(this.log(`Setting ${o?"startPosition":"nextLoadPosition"} to ${s} for seek without enough to start`),this.nextLoadPosition=s,o&&(this.startPosition=s)),o&&this.state===Rm&&this.tickImmediate()},this.onMediaEnded=()=>{this.log("setting startPosition to 0 because media ended"),this.startPosition=this.lastCurrentTime=0},this.playlistType=n,this.hls=e,this.fragmentLoader=new tp(e.config),this.keyLoader=r,this.fragmentTracker=t,this.config=e.config,this.decrypter=new Jf(e.config)}registerListeners(){const{hls:e}=this;e.on(fu.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(fu.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(fu.MANIFEST_LOADING,this.onManifestLoading,this),e.on(fu.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(fu.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(fu.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(fu.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(fu.MANIFEST_LOADING,this.onManifestLoading,this),e.off(fu.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(fu.ERROR,this.onError,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){if(this.state===Lm)return;this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);const e=this.fragCurrent;null!=e&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=Lm}get startPositionValue(){const{nextLoadPosition:e,startPosition:t}=this;return-1===t&&e?e:t}get bufferingEnabled(){return this.buffering}pauseBuffering(){this.buffering=!1}resumeBuffering(){this.buffering=!0}get inFlightFrag(){return{frag:this.fragCurrent,state:this.state}}_streamEnded(e,t){if(t.live||!this.media)return!1;const r=e.end||0,i=this.config.timelineOffset||0;if(r<=i)return!1;const n=e.buffered;this.config.maxBufferHole&&n&&n.length>1&&(e=lp.bufferedInfo(n,e.start,0));const s=e.nextStart;if(s&&s>i&&s<t.edge)return!1;if(this.media.currentTime<e.start)return!1;const a=t.partList;if(null!=a&&a.length){const e=a[a.length-1];return lp.isBuffered(this.media,e.start+e.duration/2)}const o=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(o)}getLevelDetails(){if(this.levels&&null!==this.levelLastLoaded)return this.levelLastLoaded.details}get timelineOffset(){const e=this.config.timelineOffset;var t;return e?(null==(t=this.getLevelDetails())?void 0:t.appliedTimelineOffset)||e:0}onMediaAttached(e,t){const r=this.media=this.mediaBuffer=t.media;Am(r,"seeking",this.onMediaSeeking),Am(r,"ended",this.onMediaEnded);const i=this.config;this.levels&&i.autoStartLoad&&this.state===Lm&&this.startLoad(i.startPosition)}onMediaDetaching(e,t){const r=!!t.transferMedia,i=this.media;if(null!==i){if(i.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),km(i,"seeking",this.onMediaSeeking),km(i,"ended",this.onMediaEnded),this.keyLoader&&!r&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loopSn=void 0,r)return this.resetLoadingState(),void this.resetTransmuxer();this.loadingParts=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}}onManifestLoading(){this.initPTS=[],this.levels=this.levelLastLoaded=this.fragCurrent=null,this.lastCurrentTime=this.startPosition=0,this.startFragRequested=!1}onError(e,t){}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset}onHandlerDestroying(){this.stopLoad(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),super.onHandlerDestroying(),this.hls=this.onMediaSeeking=this.onMediaEnded=null}onHandlerDestroyed(){this.state=Lm,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed()}loadFragment(e,t,r){this.startFragRequested=!0,this._loadFragForPlayback(e,t,r)}_loadFragForPlayback(e,t,r){this._doFragLoad(e,t,r,e=>{const t=e.frag;if(this.fragContextChanged(t))return this.warn(`${t.type} sn: ${t.sn}${e.part?" part: "+e.part.index:""} of ${this.fragInfo(t,!1,e.part)}) was dropped during download.`),void this.fragmentTracker.removeFragment(t);t.stats.chunkCount++,this._handleFragmentLoadProgress(e)}).then(e=>{if(!e)return;const t=this.state,r=e.frag;this.fragContextChanged(r)?(t===Cm||!this.fragCurrent&&t===Om)&&(this.fragmentTracker.removeFragment(r),this.state=Rm):("payload"in e&&(this.log(`Loaded ${r.type} sn: ${r.sn} of ${this.playlistLabel()} ${r.level}`),this.hls.trigger(fu.FRAG_LOADED,e)),this._handleFragmentLoadComplete(e))}).catch(t=>{this.state!==Lm&&this.state!==Fm&&(this.warn(`Frag error: ${(null==t?void 0:t.message)||t}`),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var t;const{fragmentTracker:r}=this;if(r.getState(e)===zf){const t=e.type,i=this.getFwdBufferInfo(this.mediaBuffer,t),n=Math.max(e.duration,i?i.len:this.config.maxBufferLength),s=this.backtrackFragment;(1===(s?e.sn-s.sn:0)||this.reduceMaxBufferLength(n,e.duration))&&r.removeFragment(e)}else 0===(null==(t=this.mediaBuffer)?void 0:t.buffered.length)?r.removeAllFragments():r.hasParts(e.type)&&(r.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),r.getState(e)===Gf&&r.removeFragment(e))}checkLiveUpdate(e){if(e.updated&&!e.live){const t=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)}waitForLive(e){const t=e.details;return(null==t?void 0:t.live)&&"EVENT"!==t.type&&(this.levelLastLoaded!==e||t.expired)}flushMainBuffer(e,t,r=null){if(!(e-t))return;const i={startOffset:e,endOffset:t,type:r};this.hls.trigger(fu.BUFFER_FLUSHING,i)}_loadInitSegment(e,t){this._doFragLoad(e,t).then(e=>{const t=null==e?void 0:e.frag;if(!t||this.fragContextChanged(t)||!this.levels)throw new Error("init load aborted");return e}).then(e=>{const{hls:t}=this,{frag:r,payload:i}=e,n=r.decryptdata;if(i&&i.byteLength>0&&null!=n&&n.key&&n.iv&&Tp(n.method)){const s=self.performance.now();return this.decrypter.decrypt(new Uint8Array(i),n.key.buffer,n.iv.buffer,xp(n.method)).catch(e=>{throw t.trigger(fu.ERROR,{type:uu.MEDIA_ERROR,details:hu.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:r}),e}).then(i=>{const n=self.performance.now();return t.trigger(fu.FRAG_DECRYPTED,{frag:r,payload:i,stats:{tstart:s,tdecrypt:n}}),e.payload=i,this.completeInitSegmentLoad(e)})}return this.completeInitSegmentLoad(e)}).catch(t=>{this.state!==Lm&&this.state!==Fm&&(this.warn(t),this.resetFragmentLoading(e))})}completeInitSegmentLoad(e){const{levels:t}=this;if(!t)throw new Error("init load aborted, missing levels");const r=e.frag.stats;this.state!==Lm&&(this.state=Rm),e.frag.data=new Uint8Array(e.payload),r.parsing.start=r.buffering.start=self.performance.now(),r.parsing.end=r.buffering.end=self.performance.now(),this.tick()}unhandledEncryptionError(e,t){var r,i;const n=e.tracks;if(n&&!t.encrypted&&(null!=(r=n.audio)&&r.encrypted||null!=(i=n.video)&&i.encrypted)&&(!this.config.emeEnabled||!this.keyLoader.emeController)){const e=this.media,r=new Error(`Encrypted track with no key in ${this.fragInfo(t)} (media ${e?"attached mediaKeys: "+e.mediaKeys:"detached"})`);return this.warn(r.message),!e||e.mediaKeys?!1:(this.hls.trigger(fu.ERROR,{type:uu.KEY_SYSTEM_ERROR,details:hu.KEY_SYSTEM_NO_KEYS,fatal:!1,error:r,frag:t}),this.resetTransmuxer(),!0)}return!1}fragContextChanged(e){const{fragCurrent:t}=this;return!e||!t||e.sn!==t.sn||e.level!==t.level}fragBufferedComplete(e,t){const r=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)} > buffer:${r?Im(lp.getBuffered(r)):"(detached)"})`),Ju(e)){var i;if(e.type!==Eu){const t=e.elementaryStreams;if(!Object.keys(t).some(e=>!!t[e]))return void(this.state=Rm)}const t=null==(i=this.levels)?void 0:i[e.level];null!=t&&t.fragmentError&&(this.log(`Resetting level fragment error count of ${t.fragmentError} on frag buffered`),t.fragmentError=0)}this.state=Rm}_handleFragmentLoadComplete(e){const{transmuxer:t}=this;if(!t)return;const{frag:r,part:i,partsLoaded:n}=e,s=!n||0===n.length||n.some(e=>!e),a=new ap(r.level,r.sn,r.stats.chunkCount+1,0,i?i.index:-1,!s);t.flush(a)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,r=null,i){var n;this.fragCurrent=e;const s=t.details;if(!this.levels||!s)throw new Error(`frag load aborted, missing level${s?"":" detail"}s`);let a=null;if(!e.encrypted||null!=(n=e.decryptdata)&&n.key)e.encrypted||(a=this.keyLoader.loadClear(e,s.encryptedFragments,this.startFragRequested),a&&this.log("[eme] blocking frag load until media-keys acquired"));else if(this.log(`Loading key for ${e.sn} of [${s.startSN}-${s.endSN}], ${this.playlistLabel()} ${e.level}`),this.state=Pm,this.fragCurrent=e,a=this.keyLoader.load(e).then(e=>{if(!this.fragContextChanged(e.frag))return this.hls.trigger(fu.KEY_LOADED,e),this.state===Pm&&(this.state=Rm),e}),this.hls.trigger(fu.KEY_LOADING,{frag:e}),null===this.fragCurrent)return this.log("context changed in KEY_LOADING"),Promise.resolve(null);const o=this.fragPrevious;if(Ju(e)&&(!o||e.sn!==o.sn)){const r=this.shouldLoadParts(t.details,e.end);r!==this.loadingParts&&(this.log(`LL-Part loading ${r?"ON":"OFF"} loading sn ${null==o?void 0:o.sn}->${e.sn}`),this.loadingParts=r)}if(r=Math.max(e.start,r||0),this.loadingParts&&Ju(e)){const n=s.partList;if(n&&i){r>s.fragmentEnd&&s.fragmentHint&&(e=s.fragmentHint);const o=this.getNextPart(n,e,r);if(o>-1){const l=n[o];let c;return e=this.fragCurrent=l.fragment,this.log(`Loading ${e.type} sn: ${e.sn} part: ${l.index} (${o}/${n.length-1}) of ${this.fragInfo(e,!1,l)}) cc: ${e.cc} [${s.startSN}-${s.endSN}], target: ${parseFloat(r.toFixed(3))}`),this.nextLoadPosition=l.start+l.duration,this.state=Cm,c=a?a.then(r=>!r||this.fragContextChanged(r.frag)?null:this.doFragPartsLoad(e,l,t,i)).catch(e=>this.handleFragLoadError(e)):this.doFragPartsLoad(e,l,t,i).catch(e=>this.handleFragLoadError(e)),this.hls.trigger(fu.FRAG_LOADING,{frag:e,part:l,targetBufferTime:r}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):c}if(!e.url||this.loadedEndOfParts(n,r))return Promise.resolve(null)}}var l;if(Ju(e)&&this.loadingParts)this.log(`LL-Part loading OFF after next part miss @${r.toFixed(2)} Check buffer at sn: ${e.sn} loaded parts: ${null==(l=s.partList)?void 0:l.filter(e=>e.loaded).map(e=>`[${e.start}-${e.end}]`)}`),this.loadingParts=!1;else if(!e.url)return Promise.resolve(null);this.log(`Loading ${e.type} sn: ${e.sn} of ${this.fragInfo(e,!1)}) cc: ${e.cc} ${"["+s.startSN+"-"+s.endSN+"]"}, target: ${parseFloat(r.toFixed(3))}`),lu(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=Cm;const c=this.config.progressive&&e.type!==Eu;let d;return d=c&&a?a.then(t=>!t||this.fragContextChanged(t.frag)?null:this.fragmentLoader.load(e,i)).catch(e=>this.handleFragLoadError(e)):Promise.all([this.fragmentLoader.load(e,c?i:void 0),a]).then(([e])=>(!c&&i&&i(e),e)).catch(e=>this.handleFragLoadError(e)),this.hls.trigger(fu.FRAG_LOADING,{frag:e,targetBufferTime:r}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):d}doFragPartsLoad(e,t,r,i){return new Promise((n,s)=>{var a;const o=[],l=null==(a=r.details)?void 0:a.partList,c=t=>{this.fragmentLoader.loadPart(e,t,i).then(i=>{o[t.index]=i;const s=i.part;this.hls.trigger(fu.FRAG_LOADED,i);const a=mm(r.details,e.sn,t.index+1)||gm(l,e.sn,t.index+1);if(!a)return n({frag:e,part:s,partsLoaded:o});c(a)}).catch(s)};c(t)})}handleFragLoadError(e){if("data"in e){const t=e.data;t.frag&&t.details===hu.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):t.frag&&t.type===uu.KEY_SYSTEM_ERROR?(t.frag.abortRequests(),this.resetStartWhenNotLoaded(),this.resetFragmentLoading(t.frag)):this.hls.trigger(fu.ERROR,t)}else this.hls.trigger(fu.ERROR,{type:uu.OTHER_ERROR,details:hu.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){const t=this.getCurrentContext(e);if(!t||this.state!==Om)return void(this.fragCurrent||this.state===Lm||this.state===Fm||(this.state=Rm));const{frag:r,part:i,level:n}=t,s=self.performance.now();r.stats.parsing.end=s,i&&(i.stats.parsing.end=s);const a=this.getLevelDetails(),o=a&&r.sn>a.endSN||this.shouldLoadParts(a,r.end);o!==this.loadingParts&&(this.log(`LL-Part loading ${o?"ON":"OFF"} after parsing segment ending @${r.end.toFixed(2)}`),this.loadingParts=o),this.updateLevelTiming(r,i,n,e.partial)}shouldLoadParts(e,t){if(this.config.lowLatencyMode){if(!e)return this.loadingParts;if(e.partList){var r;const n=e.partList[0];if(n.fragment.type===Eu)return!1;if(t>=n.end+((null==(r=e.fragmentHint)?void 0:r.duration)||0)){var i;if((this.hls.hasEnoughToStart?(null==(i=this.media)?void 0:i.currentTime)||this.lastCurrentTime:this.getLoadPosition())>n.start-n.fragment.duration)return!0}}}return!1}getCurrentContext(e){const{levels:t,fragCurrent:r}=this,{level:i,sn:n,part:s}=e;if(null==t||!t[i])return this.warn(`Levels object was unset while buffering fragment ${n} of ${this.playlistLabel()} ${i}. The current chunk will not be buffered.`),null;const a=t[i],o=a.details,l=s>-1?mm(o,n,s):null,c=l?l.fragment:pm(o,n,r);return c?(r&&r!==c&&(c.stats=r.stats),{frag:c,part:l,level:a}):null}bufferFragmentData(e,t,r,i,n){if(this.state!==Om)return;const{data1:s,data2:a}=e;let o=s;if(a&&(o=wh(s,a)),!o.length)return;const l=this.initPTS[t.cc],c=l?-l.baseTime/l.timescale:void 0,d={type:e.type,frag:t,part:r,chunkMeta:i,offset:c,parent:t.type,data:o};if(this.hls.trigger(fu.BUFFER_APPENDING,d),e.dropped&&e.independent&&!r){if(n)return;this.flushBufferGap(t)}}flushBufferGap(e){const t=this.media;if(!t)return;if(!lp.isBuffered(t,t.currentTime))return void this.flushMainBuffer(0,e.start);const r=t.currentTime,i=lp.bufferInfo(t,r,0),n=e.duration,s=Math.min(2*this.config.maxFragLookUpTolerance,.25*n),a=Math.max(Math.min(e.start-s,i.end-s),r+s);e.start-a>s&&this.flushMainBuffer(a,e.start)}getFwdBufferInfo(e,t){var r;const i=this.getLoadPosition();if(!lu(i))return null;const n=this.lastCurrentTime>i||null!=(r=this.media)&&r.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(e,i,t,n)}getFwdBufferInfoAtPos(e,t,r,i){const n=lp.bufferInfo(e,t,i);if(0===n.len&&void 0!==n.nextStart){const s=this.fragmentTracker.getBufferedFrag(t,r);if(s&&(n.nextStart<=s.end||s.gap)){const r=Math.max(Math.min(n.nextStart,s.end)-t,i);return lp.bufferInfo(e,t,r)}}return n}getMaxBufferLength(e){const{config:t}=this;let r;return r=e?Math.max(8*t.maxBufferSize/e,t.maxBufferLength):t.maxBufferLength,Math.min(r,t.maxMaxBufferLength)}reduceMaxBufferLength(e,t){const r=this.config,i=Math.max(Math.min(e-t,r.maxBufferLength),t),n=Math.max(e-3*t,r.maxMaxBufferLength/2,i);return n>=i&&(r.maxMaxBufferLength=n,this.warn(`Reduce max buffer length to ${n}s`),!0)}getAppendedFrag(e,t=yu){const r=this.fragmentTracker?this.fragmentTracker.getAppendedFrag(e,t):null;return r&&"fragment"in r?r.fragment:r}getNextFragment(e,t){const r=t.fragments,i=r.length;if(!i)return null;const{config:n}=this,s=r[0].start,a=n.lowLatencyMode&&!!t.partList;let o=null;if(t.live){const r=n.initialLiveManifestSize;if(i<r)return this.warn(`Not enough fragments to start playback (have: ${i}, need: ${r})`),null;if(!t.PTSKnown&&!this.startFragRequested&&-1===this.startPosition||e<s){var l;a&&!this.loadingParts&&(this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=!0),o=this.getInitialLiveFragment(t);const r=this.hls.startPosition,i=this.hls.liveSyncPosition,n=o?(-1!==r&&r>=s?r:i)||o.start:e;this.log(`Setting startPosition to ${n} to match start frag at live edge. mainStart: ${r} liveSyncPosition: ${i} frag.start: ${null==(l=o)?void 0:l.start}`),this.startPosition=this.nextLoadPosition=n}}else e<=s&&(o=r[0]);if(!o){const r=this.loadingParts?t.partEnd:t.fragmentEnd;o=this.getFragmentAtPosition(e,r,t)}let c=this.filterReplacedPrimary(o,t);if(!c&&o){const e=o.sn-t.startSN;c=this.filterReplacedPrimary(r[e+1]||null,t)}return this.mapToInitFragWhenRequired(c)}isLoopLoading(e,t){const r=this.fragmentTracker.getState(e);return(r===jf||r===Gf&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,r,i,n){let s=null;if(e.gap&&(s=this.getNextFragment(this.nextLoadPosition,t),s&&!s.gap&&r.nextStart)){const e=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,r.nextStart,i,0);if(null!==e&&r.len+e.len>=n){const e=s.sn;return this.loopSn!==e&&(this.log(`buffer full after gaps in "${i}" playlist starting at sn: ${e}`),this.loopSn=e),null}}return this.loopSn=void 0,s}get primaryPrefetch(){if(zm(this.config)){var e;if(null==(e=this.hls.interstitialsManager)||null==(e=e.playingItem)?void 0:e.event)return!0}return!1}filterReplacedPrimary(e,t){if(!e)return e;if(zm(this.config)&&e.type!==Eu){const r=this.hls.interstitialsManager,i=null==r?void 0:r.bufferingItem;if(i){const r=i.event;if(r){if(r.appendInPlace||Math.abs(e.start-i.start)>1||0===i.start)return null}else{if(e.end<=i.start&&!1===(null==t?void 0:t.live))return null;if(e.start>i.end&&i.nextEvent&&(i.nextEvent.appendInPlace||e.start-i.end>1))return null}}const n=null==r?void 0:r.playerQueue;if(n)for(let t=n.length;t--;){const r=n[t].interstitial;if(r.appendInPlace&&e.start>=r.startTime&&e.end<=r.resumeTime)return null}}return e}mapToInitFragWhenRequired(e){return null==e||!e.initSegment||e.initSegment.data||this.bitrateTest?e:e.initSegment}getNextPart(e,t,r){let i=-1,n=!1,s=!0;for(let a=0,o=e.length;a<o;a++){const o=e[a];if(s=s&&!o.independent,i>-1&&r<o.start)break;const l=o.loaded;l?i=-1:(n||(o.independent||s)&&o.fragment===t)&&(o.fragment!==t&&this.warn(`Need buffer at ${r} but next unloaded part starts at ${o.start}`),i=a),n=l}return i}loadedEndOfParts(e,t){let r;for(let i=e.length;i--;){if(r=e[i],!r.loaded)return!1;if(t>r.start)return!0}return!1}getInitialLiveFragment(e){const t=e.fragments,r=this.fragPrevious;let i=null;if(r){if(e.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${r.programDateTime}`),i=function(e,t,r){if(null===t||!Array.isArray(e)||!e.length||!lu(t))return null;if(t<(e[0].programDateTime||0))return null;if(t>=(e[e.length-1].endProgramDateTime||0))return null;for(let i=0;i<e.length;++i){const n=e[i];if(wf(t,r,n))return n}return null}(t,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),!i){const n=r.sn+1;if(n>=e.startSN&&n<=e.endSN){const s=t[n-e.startSN];r.cc===s.cc&&(i=s,this.log(`Live playlist, switching playlist, load frag with next SN: ${i.sn}`))}i||(i=Sf(e,r.cc,r.end),i&&this.log(`Live playlist, switching playlist, load frag with same CC: ${i.sn}`))}}else{const t=this.hls.liveSyncPosition;null!==t&&(i=this.getFragmentAtPosition(t,this.bitrateTest?e.fragmentEnd:e.edge,e))}return i}getFragmentAtPosition(e,t,r){const{config:i}=this;let{fragPrevious:n}=this,{fragments:s,endSN:a}=r;const{fragmentHint:o}=r,{maxFragLookUpTolerance:l}=i,c=r.partList,d=!!(this.loadingParts&&null!=c&&c.length&&o);let u;if(d&&!this.bitrateTest&&c[c.length-1].fragment.sn===o.sn&&(s=s.concat(o),a=o.sn),e<t){var h;u=bf(n,s,e,e<this.lastCurrentTime||e>t-l||null!=(h=this.media)&&h.paused||!this.startFragRequested?0:l)}else u=s[s.length-1];if(u){const e=u.sn-r.startSN,t=this.fragmentTracker.getState(u);if((t===jf||t===Gf&&u.gap)&&(n=u),n&&u.sn===n.sn&&(!d||c[0].fragment.sn>u.sn||!r.live)){if(u.level===n.level){const t=s[e+1];u=u.sn<a&&this.fragmentTracker.getState(t)!==jf?t:null}}}return u}alignPlaylists(e,t,r){const i=e.fragments.length;if(!i)return this.warn("No fragments in live playlist"),0;const n=e.fragmentStart,s=!t,a=e.alignedSliding&&lu(n);if(s||!a&&!n){!function(e,t){e&&(Tm(t,e),t.alignedSliding||xm(t,e),t.alignedSliding||t.skippedSegments||um(e,t,!1))}(r,e);const n=e.fragmentStart;return this.log(`Live playlist sliding: ${n.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} fragments: ${i}`),n}return n}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,3*e.partTarget)}setStartPosition(e,t){let r=this.startPosition;r<t&&(r=-1);const i=this.timelineOffset;if(-1===r){const n=null!==this.startTimeOffset,s=n?this.startTimeOffset:e.startTimeOffset;null!==s&&lu(s)?(r=t+s,s<0&&(r+=e.edge),r=Math.min(Math.max(t,r),t+e.totalduration),this.log(`Setting startPosition to ${r} for start time offset ${s} found in ${n?"multivariant":"media"} playlist`),this.startPosition=r):e.live?(r=this.hls.liveSyncPosition||t,this.log(`Setting startPosition to -1 to start at live edge ${r}`),this.startPosition=-1):(this.log("setting startPosition to 0 by default"),this.startPosition=r=0),this.lastCurrentTime=r+i}this.nextLoadPosition=r+i}getLoadPosition(){var e;const{media:t}=this;let r=0;return null!=(e=this.hls)&&e.hasEnoughToStart&&t?r=t.currentTime:this.nextLoadPosition>=0&&(r=this.nextLoadPosition),r}handleFragLoadAborted(e,t){this.transmuxer&&e.type===this.playlistType&&Ju(e)&&e.stats.aborted&&(this.log(`Fragment ${e.sn}${t?" part "+t.index:""} of ${this.playlistLabel()} ${e.level} was aborted`),this.resetFragmentLoading(e))}resetFragmentLoading(e){this.fragCurrent&&(this.fragContextChanged(e)||this.state===Dm)||(this.state=Rm)}onFragmentOrKeyLoadError(e,t){var r;if(t.chunkMeta&&!t.frag){const e=this.getCurrentContext(t.chunkMeta);e&&(t.frag=e.frag)}const i=t.frag;if(!i||i.type!==e||!this.levels)return;var n;if(this.fragContextChanged(i))return void this.warn(`Frag load error must match current frag to retry ${i.url} > ${null==(n=this.fragCurrent)?void 0:n.url}`);const s=t.details===hu.FRAG_GAP;s&&this.fragmentTracker.fragBuffered(i,!0);const a=t.errorAction;if(!a)return void(this.state=Fm);const{action:o,flags:l,retryCount:c=0,retryConfig:d}=a,u=!!d,h=u&&o===Of,f=u&&!a.resolved&&l===Nf,p=null==(r=this.hls.latestLevelDetails)?void 0:r.live;if(!h&&f&&Ju(i)&&!i.endList&&p&&!Af(t))this.resetFragmentErrors(e),this.treatAsGap(i),a.resolved=!0;else if((h||f)&&c<d.maxNumRetry){var m;const r=Pf(null==(m=t.response)?void 0:m.code),n=If(d,c);if(this.resetStartWhenNotLoaded(),this.retryDate=self.performance.now()+n,this.state=Dm,a.resolved=!0,r)return this.log("Waiting for connection (offline)"),this.retryDate=1/0,void(t.reason="offline");this.warn(`Fragment ${i.sn} of ${e} ${i.level} errored with ${t.details}, retrying loading ${c+1}/${d.maxNumRetry} in ${n}ms`)}else if(d){if(this.resetFragmentErrors(e),!(c<d.maxNumRetry))return void this.warn(`${t.details} reached or exceeded max retry (${c})`);s||o===_f||(a.resolved=!0)}else this.state=o===Df?Bm:Fm;this.tickImmediate()}checkRetryDate(){const e=self.performance.now(),t=this.retryDate,r=t===1/0;(!t||e>=t||r&&!Pf(0))&&(r&&this.log("Connection restored (online)"),this.resetStartWhenNotLoaded(),this.state=Rm)}reduceLengthAndFlushBuffer(e){if(this.state===Om||this.state===Mm){const t=e.frag,r=e.parent,i=this.getFwdBufferInfo(this.mediaBuffer,r),n=i&&i.len>.5;n&&this.reduceMaxBufferLength(i.len,(null==t?void 0:t.duration)||10);const s=!n;return s&&this.warn(`Buffer full error while media.currentTime (${this.getLoadPosition()}) is not buffered, flush ${r} buffer`),t&&(this.fragmentTracker.removeFragment(t),this.nextLoadPosition=t.start),this.resetLoadingState(),s}return!1}resetFragmentErrors(e){e===bu&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==Lm&&(this.state=Rm)}afterBufferFlushed(e,t,r){if(!e)return;const i=lp.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,i,r),this.state===Nm&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==Lm&&(this.state=Rm)}resetStartWhenNotLoaded(){if(!this.hls.hasEnoughToStart){this.startFragRequested=!1;const e=this.levelLastLoaded,t=e?e.details:null;null!=t&&t.live?(this.log("resetting startPosition for live start"),this.startPosition=-1,this.setStartPosition(t,t.fragmentStart),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(e){this.log(`Loading context changed while buffering sn ${e.sn} of ${this.playlistLabel()} ${-1===e.level?"<removed>":e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(),this.resetLoadingState()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(e,t,r,i){const n=r.details;if(!n)return void this.warn("level.details undefined");if(!Object.keys(e.elementaryStreams).reduce((t,s)=>{const a=e.elementaryStreams[s];if(a){const o=a.endPTS-a.startPTS;if(o<=0)return this.warn(`Could not parse fragment ${e.sn} ${s} duration reliably (${o})`),t||!1;const l=i?0:lm(n,e,a.startPTS,a.endPTS,a.startDTS,a.endDTS,this);return this.hls.trigger(fu.LEVEL_PTS_UPDATED,{details:n,level:r,drift:l,type:s,frag:e,start:a.startPTS,end:a.endPTS}),!0}return t},!1)){var s;const t=null===(null==(s=this.transmuxer)?void 0:s.error);if((0===r.fragmentError||t&&(r.fragmentError<2||e.endList))&&this.treatAsGap(e,r),t){const t=new Error(`Found no media in fragment ${e.sn} of ${this.playlistLabel()} ${e.level} resetting transmuxer to fallback to playlist timing`);if(this.warn(t.message),this.hls.trigger(fu.ERROR,{type:uu.MEDIA_ERROR,details:hu.FRAG_PARSING_ERROR,fatal:!1,error:t,frag:e,reason:`Found no media in msn ${e.sn} of ${this.playlistLabel()} "${r.url}"`}),!this.hls)return;this.resetTransmuxer()}}this.state=Mm,this.log(`Parsed ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)})`),this.hls.trigger(fu.FRAG_PARSED,{frag:e,part:t})}playlistLabel(){return this.playlistType===yu?"level":"track"}fragInfo(e,t=!0,r){var i,n;return`${this.playlistLabel()} ${e.level} (${r?"part":"frag"}:[${(null!=(i=t&&!r?e.startPTS:(r||e).start)?i:NaN).toFixed(3)}-${(null!=(n=t&&!r?e.endPTS:(r||e).end)?n:NaN).toFixed(3)}]${r&&"main"===e.type?"INDEPENDENT="+(r.independent?"YES":"NO"):""}`}treatAsGap(e,t){t&&t.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)}resetTransmuxer(){var e;null==(e=this.transmuxer)||e.reset()}recoverWorkerError(e){"demuxerWorker"===e.event&&(this.fragmentTracker.removeAllFragments(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),this.resetStartWhenNotLoaded(),this.resetLoadingState())}set state(e){const t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}get state(){return this._state}}function zm(e){return!!e.interstitialsController&&!1!==e.enableInterstitialPlayback}class Gm{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){const{chunks:e,dataLength:t}=this;let r;return e.length?(r=1===e.length?e[0]:function(e,t){const r=new Uint8Array(t);let i=0;for(let t=0;t<e.length;t++){const n=e[t];r.set(n,i),i+=n.length}return r}(e,t),this.reset(),r):new Uint8Array(0)}reset(){this.chunks.length=0,this.dataLength=0}}var jm,Hm={exports:{}};var Vm=(jm||(jm=1,function(e){var t=Object.prototype.hasOwnProperty,r="~";function i(){}function n(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function s(e,t,i,s,a){if("function"!=typeof i)throw new TypeError("The listener must be a function");var o=new n(i,s||e,a),l=r?r+t:t;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],o]:e._events[l].push(o):(e._events[l]=o,e._eventsCount++),e}function a(e,t){0===--e._eventsCount?e._events=new i:delete e._events[t]}function o(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(r=!1)),o.prototype.eventNames=function(){var e,i,n=[];if(0===this._eventsCount)return n;for(i in e=this._events)t.call(e,i)&&n.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},o.prototype.listeners=function(e){var t=r?r+e:e,i=this._events[t];if(!i)return[];if(i.fn)return[i.fn];for(var n=0,s=i.length,a=new Array(s);n<s;n++)a[n]=i[n].fn;return a},o.prototype.listenerCount=function(e){var t=r?r+e:e,i=this._events[t];return i?i.fn?1:i.length:0},o.prototype.emit=function(e,t,i,n,s,a){var o=r?r+e:e;if(!this._events[o])return!1;var l,c,d=this._events[o],u=arguments.length;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),u){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,t),!0;case 3:return d.fn.call(d.context,t,i),!0;case 4:return d.fn.call(d.context,t,i,n),!0;case 5:return d.fn.call(d.context,t,i,n,s),!0;case 6:return d.fn.call(d.context,t,i,n,s,a),!0}for(c=1,l=new Array(u-1);c<u;c++)l[c-1]=arguments[c];d.fn.apply(d.context,l)}else{var h,f=d.length;for(c=0;c<f;c++)switch(d[c].once&&this.removeListener(e,d[c].fn,void 0,!0),u){case 1:d[c].fn.call(d[c].context);break;case 2:d[c].fn.call(d[c].context,t);break;case 3:d[c].fn.call(d[c].context,t,i);break;case 4:d[c].fn.call(d[c].context,t,i,n);break;default:if(!l)for(h=1,l=new Array(u-1);h<u;h++)l[h-1]=arguments[h];d[c].fn.apply(d[c].context,l)}}return!0},o.prototype.on=function(e,t,r){return s(this,e,t,r,!1)},o.prototype.once=function(e,t,r){return s(this,e,t,r,!0)},o.prototype.removeListener=function(e,t,i,n){var s=r?r+e:e;if(!this._events[s])return this;if(!t)return a(this,s),this;var o=this._events[s];if(o.fn)o.fn!==t||n&&!o.once||i&&o.context!==i||a(this,s);else{for(var l=0,c=[],d=o.length;l<d;l++)(o[l].fn!==t||n&&!o[l].once||i&&o[l].context!==i)&&c.push(o[l]);c.length?this._events[s]=1===c.length?c[0]:c:a(this,s)}return this},o.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&a(this,t)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=r,o.EventEmitter=o,e.exports=o}(Hm)),Hm.exports),Wm=Bu(Vm);const Ym="1.6.15",Km={};function qm(e,t){return t+10<=e.length&&51===e[t]&&68===e[t+1]&&73===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128}function Xm(e,t){return t+10<=e.length&&73===e[t]&&68===e[t+1]&&51===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128}function Qm(e,t){let r=0;return r=(127&e[t])<<21,r|=(127&e[t+1])<<14,r|=(127&e[t+2])<<7,r|=127&e[t+3],r}function Zm(e,t){const r=t;let i=0;for(;Xm(e,t);){i+=10;i+=Qm(e,t+6),qm(e,t+10)&&(i+=10),t+=i}if(i>0)return e.subarray(r,r+i)}function Jm(e,t){return 255===e[t]&&240==(246&e[t+1])}function eg(e,t){return 1&e[t+1]?7:9}function tg(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function rg(e,t){return t+1<e.length&&Jm(e,t)}function ig(e,t){if(rg(e,t)){const r=eg(e,t);if(t+r>=e.length)return!1;const i=tg(e,t);if(i<=r)return!1;const n=t+i;return n===e.length||rg(e,n)}return!1}function ng(e,t,r,i,n){if(!e.samplerate){const s=function(e,t,r,i){const n=t[r+2],s=n>>2&15;if(s>12){const t=new Error(`invalid ADTS sampling index:${s}`);return void e.emit(fu.ERROR,fu.ERROR,{type:uu.MEDIA_ERROR,details:hu.FRAG_PARSING_ERROR,fatal:!0,error:t,reason:t.message})}const a=1+(n>>6&3),o=t[r+3]>>6&3|(1&n)<<2,l="mp4a.40."+a,c=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][s];let d=s;5!==a&&29!==a||(d-=3);const u=[a<<3|(14&d)>>1,(1&d)<<7|o<<3];return _u.log(`manifest codec:${i}, parsed codec:${l}, channels:${o}, rate:${c} (ADTS object type:${a} sampling index:${s})`),{config:u,samplerate:c,channelCount:o,codec:l,parsedCodec:l,manifestCodec:i}}(t,r,i,n);if(!s)return;xu(e,s)}}function sg(e){return 9216e4/e}function ag(e,t,r,i,n){const s=i+n*sg(e.samplerate),a=function(e,t){const r=eg(e,t);if(t+r<=e.length){const i=tg(e,t)-r;if(i>0)return{headerLength:r,frameLength:i}}}(t,r);let o;if(a){const{frameLength:i,headerLength:n}=a,l=n+i,c=Math.max(0,r+l-t.length);c?(o=new Uint8Array(l-n),o.set(t.subarray(r+n,t.length),0)):o=t.subarray(r+n,r+l);const d={unit:o,pts:s};return c||e.samples.push(d),{sample:d,length:l,missing:c}}const l=t.length-r;o=new Uint8Array(l),o.set(t.subarray(r,t.length),0);return{sample:{unit:o,pts:s},length:l,missing:-1}}function og(e,t){return Xm(e,t)&&Qm(e,t+6)+10<=e.length-t}function lg(e,t=0,r=1/0){return function(e,t,r,i){const n=function(e){return e instanceof ArrayBuffer?e:e.buffer}(e);let s=1;"BYTES_PER_ELEMENT"in i&&(s=i.BYTES_PER_ELEMENT);const a=(u=e,u&&u.buffer instanceof ArrayBuffer&&void 0!==u.byteLength&&void 0!==u.byteOffset?e.byteOffset:0),o=(a+e.byteLength)/s,l=(a+t)/s,c=Math.floor(Math.max(0,Math.min(l,o))),d=Math.floor(Math.min(c+Math.max(r,0),o));var u;return new i(n,c,d-c)}(e,t,r,Uint8Array)}function cg(e){const t={key:e.type,description:"",data:"",mimeType:null,pictureType:null};if(e.size<2)return;if(3!==e.data[0])return void console.log("Ignore frame with unrecognized character encoding");const r=e.data.subarray(1).indexOf(0);if(-1===r)return;const i=Nu(lg(e.data,1,r)),n=e.data[2+r],s=e.data.subarray(3+r).indexOf(0);if(-1===s)return;const a=Nu(lg(e.data,3+r,s));let o;return o="--\x3e"===i?Nu(lg(e.data,4+r+s)):function(e){return e instanceof ArrayBuffer?e:0==e.byteOffset&&e.byteLength==e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer}(e.data.subarray(4+r+s)),t.mimeType=i,t.pictureType=n,t.description=a,t.data=o,t}function dg(e){return"PRIV"===e.type?function(e){if(e.size<2)return;const t=Nu(e.data,!0),r=new Uint8Array(e.data.subarray(t.length+1));return{key:e.type,info:t,data:r.buffer}}(e):"W"===e.type[0]?function(e){if("WXXX"===e.type){if(e.size<2)return;let t=1;const r=Nu(e.data.subarray(t),!0);t+=r.length+1;const i=Nu(e.data.subarray(t));return{key:e.type,info:r,data:i}}const t=Nu(e.data);return{key:e.type,info:"",data:t}}(e):"APIC"===e.type?cg(e):function(e){if(e.size<2)return;if("TXXX"===e.type){let t=1;const r=Nu(e.data.subarray(t),!0);t+=r.length+1;const i=Nu(e.data.subarray(t));return{key:e.type,info:r,data:i}}const t=Nu(e.data.subarray(1));return{key:e.type,info:"",data:t}}(e)}function ug(e){const t=String.fromCharCode(e[0],e[1],e[2],e[3]),r=Qm(e,4);return{type:t,size:r,data:e.subarray(10,10+r)}}function hg(e){let t=0;const r=[];for(;Xm(e,t);){const i=Qm(e,t+6);e[t+5]>>6&1&&(t+=10),t+=10;const n=t+i;for(;t+10<n;){const i=ug(e.subarray(t)),n=dg(i);n&&r.push(n),t+=i.size+10}qm(e,t)&&(t+=10)}return r}function fg(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info}function pg(e){if(8===e.data.byteLength){const t=new Uint8Array(e.data),r=1&t[3];let i=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return i/=45,r&&(i+=47721858.84),Math.round(i)}}function mg(e){const t=hg(e);for(let e=0;e<t.length;e++){const r=t[e];if(fg(r))return pg(r)}}let gg=function(e){return e.audioId3="org.id3",e.dateRange="com.apple.quicktime.HLS",e.emsg="https://aomedia.org/emsg/ID3",e.misbklv="urn:misb:KLV:bin:1910.1",e}({});function vg(e="",t=9e4){return{type:e,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}class yg{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(e,t,r,i){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(e){this.initPTS=e,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(e,t){return!1}appendFrame(e,t,r){}demux(e,t){this.cachedData&&(e=wh(this.cachedData,e),this.cachedData=null);let r,i=Zm(e,0),n=i?i.length:0;const s=this._audioTrack,a=this._id3Track,o=i?mg(i):void 0,l=e.length;for((null===this.basePTS||0===this.frameIndex&&lu(o))&&(this.basePTS=bg(o,t,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),i&&i.length>0&&a.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:gg.audioId3,duration:Number.POSITIVE_INFINITY});n<l;){if(this.canParse(e,n)){const t=this.appendFrame(s,e,n);t?(this.frameIndex++,this.lastPTS=t.sample.pts,n+=t.length,r=n):n=l}else og(e,n)?(i=Zm(e,n),a.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:gg.audioId3,duration:Number.POSITIVE_INFINITY}),n+=i.length,r=n):n++;if(n===l&&r!==l){const t=e.slice(r);this.cachedData?this.cachedData=wh(this.cachedData,t):this.cachedData=t}}return{audioTrack:s,videoTrack:vg(),id3Track:a,textTrack:vg()}}demuxSampleAes(e,t,r){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(e){const t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:vg(),id3Track:this._id3Track,textTrack:vg()}}destroy(){this.cachedData=null,this._audioTrack=this._id3Track=void 0}}const bg=(e,t,r)=>{if(lu(e))return 90*e;return 9e4*t+(r?9e4*r.baseTime/r.timescale:0)};let Eg=null;const wg=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],Sg=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],Tg=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],xg=[0,1,1,4];function Ag(e,t,r,i,n){if(r+24>t.length)return;const s=kg(t,r);if(s&&r+s.frameLength<=t.length){const a=i+n*(9e4*s.samplesPerFrame/s.sampleRate),o={unit:t.subarray(r,r+s.frameLength),pts:a,dts:a};return e.config=[],e.channelCount=s.channelCount,e.samplerate=s.sampleRate,e.samples.push(o),{sample:o,length:s.frameLength,missing:0}}}function kg(e,t){const r=e[t+1]>>3&3,i=e[t+1]>>1&3,n=e[t+2]>>4&15,s=e[t+2]>>2&3;if(1!==r&&0!==n&&15!==n&&3!==s){const a=e[t+2]>>1&1,o=e[t+3]>>6,l=1e3*wg[14*(3===r?3-i:3===i?3:4)+n-1],c=Sg[3*(3===r?0:2===r?1:2)+s],d=3===o?1:2,u=Tg[r][i],h=xg[i],f=8*u*h,p=Math.floor(u*l/c+a)*h;if(null===Eg){const e=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Eg=e?parseInt(e[1]):0}return!!Eg&&Eg<=87&&2===i&&l>=224e3&&0===o&&(e[t+3]=128|e[t+3]),{sampleRate:c,channelCount:d,frameLength:p,samplesPerFrame:f}}}function Ig(e,t){return!(255!==e[t]||224&~e[t+1]||!(6&e[t+1]))}function Lg(e,t){return t+1<e.length&&Ig(e,t)}function Rg(e,t){if(t+1<e.length&&Ig(e,t)){const r=4,i=kg(e,t);let n=r;null!=i&&i.frameLength&&(n=i.frameLength);const s=t+n;return s===e.length||Lg(e,s)}return!1}const Pg=(e,t)=>{let r=0,i=5;t+=i;const n=new Uint32Array(1),s=new Uint32Array(1),a=new Uint8Array(1);for(;i>0;){a[0]=e[t];const o=Math.min(i,8),l=8-o;s[0]=4278190080>>>24+l<<l,n[0]=(a[0]&s[0])>>l,r=r?r<<o|n[0]:n[0],t+=1,i-=o}return r};class Cg extends yg{constructor(e){super(),this.observer=void 0,this.observer=e}resetInitSegment(e,t,r,i){super.resetInitSegment(e,t,r,i),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:t,duration:i,inputTimeScale:9e4,dropped:0}}canParse(e,t){return t+64<e.length}appendFrame(e,t,r){const i=Dg(e,t,r,this.basePTS,this.frameIndex);if(-1!==i){return{sample:e.samples[e.samples.length-1],length:i,missing:0}}}static probe(e){if(!e)return!1;const t=Zm(e,0);if(!t)return!1;const r=t.length;return 11===e[r]&&119===e[r+1]&&void 0!==mg(t)&&Pg(e,r)<16}}function Dg(e,t,r,i,n){if(r+8>t.length)return-1;if(11!==t[r]||119!==t[r+1])return-1;const s=t[r+4]>>6;if(s>=3)return-1;const a=[48e3,44100,32e3][s],o=63&t[r+4],l=2*[64,69,96,64,70,96,80,87,120,80,88,120,96,104,144,96,105,144,112,121,168,112,122,168,128,139,192,128,140,192,160,174,240,160,175,240,192,208,288,192,209,288,224,243,336,224,244,336,256,278,384,256,279,384,320,348,480,320,349,480,384,417,576,384,418,576,448,487,672,448,488,672,512,557,768,512,558,768,640,696,960,640,697,960,768,835,1152,768,836,1152,896,975,1344,896,976,1344,1024,1114,1536,1024,1115,1536,1152,1253,1728,1152,1254,1728,1280,1393,1920,1280,1394,1920][3*o+s];if(r+l>t.length)return-1;const c=t[r+6]>>5;let d=0;2===c?d+=2:(1&c&&1!==c&&(d+=2),4&c&&(d+=2));const u=(t[r+6]<<8|t[r+7])>>12-d&1,h=[2,1,2,3,3,4,4,5][c]+u,f=t[r+5]>>3,p=7&t[r+5],m=new Uint8Array([s<<6|f<<1|p>>2,(3&p)<<6|c<<3|u<<2|o>>4,o<<4&224]),g=i+n*(1536/a*9e4),v=t.subarray(r,r+l);return e.config=m,e.channelCount=h,e.samplerate=a,e.samples.push({unit:v,pts:g}),l}const _g=/\/emsg[-/]ID3/i;function Og(e,t){return lu(e.presentationTime)?e.presentationTime/e.timeScale:t+e.presentationTimeDelta/e.timeScale}class Mg{constructor(e,t,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new Jf(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,Kf)}decryptAacSample(e,t,r){const i=e[t].unit;if(i.length<=16)return;const n=i.subarray(16,i.length-i.length%16),s=n.buffer.slice(n.byteOffset,n.byteOffset+n.length);this.decryptBuffer(s).then(n=>{const s=new Uint8Array(n);i.set(s,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,r)}).catch(r)}decryptAacSamples(e,t,r){for(;;t++){if(t>=e.length)return void r();if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,r),!this.decrypter.isSync()))return}}getAvcEncryptedData(e){const t=16*Math.floor((e.length-48)/160)+16,r=new Int8Array(t);let i=0;for(let t=32;t<e.length-16;t+=160,i+=16)r.set(e.subarray(t,t+16),i);return r}getAvcDecryptedUnit(e,t){const r=new Uint8Array(t);let i=0;for(let t=32;t<e.length-16;t+=160,i+=16)e.set(r.subarray(i,i+16),t);return e}decryptAvcSample(e,t,r,i,n){const s=kh(n.data),a=this.getAvcEncryptedData(s);this.decryptBuffer(a.buffer).then(a=>{n.data=this.getAvcDecryptedUnit(s,a),this.decrypter.isSync()||this.decryptAvcSamples(e,t,r+1,i)}).catch(i)}decryptAvcSamples(e,t,r,i){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length)return void i();const n=e[t].units;for(;!(r>=n.length);r++){const s=n[r];if(!(s.data.length<=48||1!==s.type&&5!==s.type||(this.decryptAvcSample(e,t,r,i,s),this.decrypter.isSync())))return}}}}class Ng{constructor(){this.VideoSample=null}createVideoSample(e,t,r){return{key:e,frame:!1,pts:t,dts:r,units:[],length:0}}getLastNalUnit(e){var t;let r,i=this.VideoSample;if(i&&0!==i.units.length||(i=e[e.length-1]),null!=(t=i)&&t.units){const e=i.units;r=e[e.length-1]}return r}pushAccessUnit(e,t){if(e.units.length&&e.frame){if(void 0===e.pts){const r=t.samples,i=r.length;if(!i)return void t.dropped++;{const t=r[i-1];e.pts=t.pts,e.dts=t.dts}}t.samples.push(e)}}parseNALu(e,t,r){const i=t.byteLength;let n=e.naluState||0;const s=n,a=[];let o,l,c,d=0,u=-1,h=0;for(-1===n&&(u=0,h=this.getNALuType(t,0),n=0,d=1);d<i;)if(o=t[d++],n)if(1!==n)if(o)if(1===o){if(l=d-n-1,u>=0){const e={data:t.subarray(u,l),type:h};a.push(e)}else{const r=this.getLastNalUnit(e.samples);r&&(s&&d<=4-s&&r.state&&(r.data=r.data.subarray(0,r.data.byteLength-s)),l>0&&(r.data=wh(r.data,t.subarray(0,l)),r.state=0))}d<i?(c=this.getNALuType(t,d),u=d,h=c,n=0):n=-1}else n=0;else n=3;else n=o?0:2;else n=o?0:1;if(u>=0&&n>=0){const e={data:t.subarray(u,i),type:h,state:n};a.push(e)}if(0===a.length){const r=this.getLastNalUnit(e.samples);r&&(r.data=wh(r.data,t))}return e.naluState=n,a}}class Fg{constructor(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){const e=this.data,t=this.bytesAvailable,r=e.byteLength-t,i=new Uint8Array(4),n=Math.min(4,t);if(0===n)throw new Error("no bytes available");i.set(e.subarray(r,r+n)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*n,this.bytesAvailable-=n}skipBits(e){let t;e=Math.min(e,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(t=(e-=this.bitsAvailable)>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}readBits(e){let t=Math.min(this.bitsAvailable,e);const r=this.word>>>32-t;if(e>32&&_u.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return t=e-t,t>0&&this.bitsAvailable?r<<t|this.readBits(t):r}skipLZ(){let e;for(e=0;e<this.bitsAvailable;++e)if(this.word&2147483648>>>e)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){const e=this.skipLZ();return this.readBits(e+1)-1}readEG(){const e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}readBoolean(){return 1===this.readBits(1)}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}}class $g extends Ng{parsePES(e,t,r,i){const n=this.parseNALu(e,r.data,i);let s,a=this.VideoSample,o=!1;r.data=null,a&&n.length&&!e.audFound&&(this.pushAccessUnit(a,e),a=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts)),n.forEach(i=>{var n,l;switch(i.type){case 1:{let t=!1;s=!0;const n=i.data;if(o&&n.length>4){const e=this.readSliceType(n);2!==e&&4!==e&&7!==e&&9!==e||(t=!0)}var c;if(t)null!=(c=a)&&c.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null);a||(a=this.VideoSample=this.createVideoSample(!0,r.pts,r.dts)),a.frame=!0,a.key=t;break}case 5:s=!0,null!=(n=a)&&n.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null),a||(a=this.VideoSample=this.createVideoSample(!0,r.pts,r.dts)),a.key=!0,a.frame=!0;break;case 6:s=!0,Ah(i.data,1,r.pts,t.samples);break;case 7:{var d,u;s=!0,o=!0;const t=i.data,r=this.readSPS(t);if(!e.sps||e.width!==r.width||e.height!==r.height||(null==(d=e.pixelRatio)?void 0:d[0])!==r.pixelRatio[0]||(null==(u=e.pixelRatio)?void 0:u[1])!==r.pixelRatio[1]){e.width=r.width,e.height=r.height,e.pixelRatio=r.pixelRatio,e.sps=[t];const i=t.subarray(1,4);let n="avc1.";for(let e=0;e<3;e++){let t=i[e].toString(16);t.length<2&&(t="0"+t),n+=t}e.codec=n}break}case 8:s=!0,e.pps=[i.data];break;case 9:s=!0,e.audFound=!0,null!=(l=a)&&l.frame&&(this.pushAccessUnit(a,e),a=null),a||(a=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts));break;case 12:s=!0;break;default:s=!1}if(a&&s){a.units.push(i)}}),i&&a&&(this.pushAccessUnit(a,e),this.VideoSample=null)}getNALuType(e,t){return 31&e[t]}readSliceType(e){const t=new Fg(e);return t.readUByte(),t.readUEG(),t.readUEG()}skipScalingList(e,t){let r,i=8,n=8;for(let s=0;s<e;s++)0!==n&&(r=t.readEG(),n=(i+r+256)%256),i=0===n?i:n}readSPS(e){const t=new Fg(e);let r,i,n,s=0,a=0,o=0,l=0;const c=t.readUByte.bind(t),d=t.readBits.bind(t),u=t.readUEG.bind(t),h=t.readBoolean.bind(t),f=t.skipBits.bind(t),p=t.skipEG.bind(t),m=t.skipUEG.bind(t),g=this.skipScalingList.bind(this);c();const v=c();if(d(5),f(3),c(),m(),100===v||110===v||122===v||244===v||44===v||83===v||86===v||118===v||128===v){const e=u();if(3===e&&f(1),m(),m(),f(1),h())for(i=3!==e?8:12,n=0;n<i;n++)h()&&g(n<6?16:64,t)}m();const y=u();if(0===y)u();else if(1===y)for(f(1),p(),p(),r=u(),n=0;n<r;n++)p();m(),f(1);const b=u(),E=u(),w=d(1);0===w&&f(1),f(1),h()&&(s=u(),a=u(),o=u(),l=u());let S=[1,1];if(h()&&h()){switch(c()){case 1:S=[1,1];break;case 2:S=[12,11];break;case 3:S=[10,11];break;case 4:S=[16,11];break;case 5:S=[40,33];break;case 6:S=[24,11];break;case 7:S=[20,11];break;case 8:S=[32,11];break;case 9:S=[80,33];break;case 10:S=[18,11];break;case 11:S=[15,11];break;case 12:S=[64,33];break;case 13:S=[160,99];break;case 14:S=[4,3];break;case 15:S=[3,2];break;case 16:S=[2,1];break;case 255:S=[c()<<8|c(),c()<<8|c()]}}return{width:Math.ceil(16*(b+1)-2*s-2*a),height:(2-w)*(E+1)*16-(w?2:4)*(o+l),pixelRatio:S}}}class Bg extends Ng{constructor(...e){super(...e),this.initVPS=null}parsePES(e,t,r,i){const n=this.parseNALu(e,r.data,i);let s,a=this.VideoSample,o=!1;r.data=null,a&&n.length&&!e.audFound&&(this.pushAccessUnit(a,e),a=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts)),n.forEach(i=>{var n,l;switch(i.type){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:a||(a=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts)),a.frame=!0,s=!0;break;case 16:case 17:case 18:case 21:var c;if(s=!0,o)null!=(c=a)&&c.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null);a||(a=this.VideoSample=this.createVideoSample(!0,r.pts,r.dts)),a.key=!0,a.frame=!0;break;case 19:case 20:s=!0,null!=(n=a)&&n.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null),a||(a=this.VideoSample=this.createVideoSample(!0,r.pts,r.dts)),a.key=!0,a.frame=!0;break;case 39:s=!0,Ah(i.data,2,r.pts,t.samples);break;case 32:s=!0,e.vps||("object"!=typeof e.params&&(e.params={}),e.params=xu(e.params,this.readVPS(i.data)),this.initVPS=i.data),e.vps=[i.data];break;case 33:if(s=!0,o=!0,void 0===e.vps||e.vps[0]===this.initVPS||void 0===e.sps||this.matchSPS(e.sps[0],i.data)||(this.initVPS=e.vps[0],e.sps=e.pps=void 0),!e.sps){const t=this.readSPS(i.data);e.width=t.width,e.height=t.height,e.pixelRatio=t.pixelRatio,e.codec=t.codecString,e.sps=[],"object"!=typeof e.params&&(e.params={});for(const r in t.params)e.params[r]=t.params[r]}this.pushParameterSet(e.sps,i.data,e.vps),a||(a=this.VideoSample=this.createVideoSample(!0,r.pts,r.dts)),a.key=!0;break;case 34:if(s=!0,"object"==typeof e.params){if(!e.pps){e.pps=[];const t=this.readPPS(i.data);for(const r in t)e.params[r]=t[r]}this.pushParameterSet(e.pps,i.data,e.vps)}break;case 35:s=!0,e.audFound=!0,null!=(l=a)&&l.frame&&(this.pushAccessUnit(a,e),a=null),a||(a=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts));break;default:s=!1}if(a&&s){a.units.push(i)}}),i&&a&&(this.pushAccessUnit(a,e),this.VideoSample=null)}pushParameterSet(e,t,r){(r&&r[0]===this.initVPS||!r&&!e.length)&&e.push(t)}getNALuType(e,t){return(126&e[t])>>>1}ebsp2rbsp(e){const t=new Uint8Array(e.byteLength);let r=0;for(let i=0;i<e.byteLength;i++)i>=2&&3===e[i]&&0===e[i-1]&&0===e[i-2]||(t[r]=e[i],r++);return new Uint8Array(t.buffer,0,r)}pushAccessUnit(e,t){super.pushAccessUnit(e,t),this.initVPS&&(this.initVPS=null)}readVPS(e){const t=new Fg(e);t.readUByte(),t.readUByte(),t.readBits(4),t.skipBits(2),t.readBits(6);return{numTemporalLayers:t.readBits(3)+1,temporalIdNested:t.readBoolean()}}readSPS(e){const t=new Fg(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.readBits(4);const r=t.readBits(3);t.readBoolean();const i=t.readBits(2),n=t.readBoolean(),s=t.readBits(5),a=t.readUByte(),o=t.readUByte(),l=t.readUByte(),c=t.readUByte(),d=t.readUByte(),u=t.readUByte(),h=t.readUByte(),f=t.readUByte(),p=t.readUByte(),m=t.readUByte(),g=t.readUByte(),v=[],y=[];for(let e=0;e<r;e++)v.push(t.readBoolean()),y.push(t.readBoolean());if(r>0)for(let e=r;e<8;e++)t.readBits(2);for(let e=0;e<r;e++)v[e]&&(t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte()),y[e]&&t.readUByte();t.readUEG();const b=t.readUEG();3==b&&t.skipBits(1);const E=t.readUEG(),w=t.readUEG(),S=t.readBoolean();let T=0,x=0,A=0,k=0;S&&(T+=t.readUEG(),x+=t.readUEG(),A+=t.readUEG(),k+=t.readUEG());const I=t.readUEG(),L=t.readUEG(),R=t.readUEG();for(let e=t.readBoolean()?0:r;e<=r;e++)t.skipUEG(),t.skipUEG(),t.skipUEG();t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG();if(t.readBoolean()){if(t.readBoolean())for(let e=0;e<4;e++)for(let r=0;r<(3===e?2:6);r++){if(t.readBoolean()){const r=Math.min(64,1<<4+(e<<1));e>1&&t.readEG();for(let e=0;e<r;e++)t.readEG()}else t.readUEG()}}t.readBoolean(),t.readBoolean();t.readBoolean()&&(t.readUByte(),t.skipUEG(),t.skipUEG(),t.readBoolean());const P=t.readUEG();let C=0;for(let e=0;e<P;e++){let r=!1;if(0!==e&&(r=t.readBoolean()),r){e===P&&t.readUEG(),t.readBoolean(),t.readUEG();let r=0;for(let e=0;e<=C;e++){const e=t.readBoolean();let i=!1;e||(i=t.readBoolean()),(e||i)&&r++}C=r}else{const e=t.readUEG(),r=t.readUEG();C=e+r;for(let r=0;r<e;r++)t.readUEG(),t.readBoolean();for(let e=0;e<r;e++)t.readUEG(),t.readBoolean()}}if(t.readBoolean()){const e=t.readUEG();for(let r=0;r<e;r++){for(let e=0;e<R+4;e++)t.readBits(1);t.readBits(1)}}let D=0,_=1,O=1,M=!0,N=1,F=0;t.readBoolean(),t.readBoolean();let $=!1;if(t.readBoolean()){if(t.readBoolean()){const e=t.readUByte();e>0&&e<16?(_=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][e-1],O=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][e-1]):255===e&&(_=t.readBits(16),O=t.readBits(16))}t.readBoolean()&&t.readBoolean();if(t.readBoolean()){t.readBits(3),t.readBoolean();t.readBoolean()&&(t.readUByte(),t.readUByte(),t.readUByte())}t.readBoolean()&&(t.readUEG(),t.readUEG()),t.readBoolean(),t.readBoolean(),t.readBoolean(),$=t.readBoolean(),$&&(t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG());if(t.readBoolean()){N=t.readBits(32),F=t.readBits(32);t.readBoolean()&&t.readUEG();if(t.readBoolean()){const e=t.readBoolean(),i=t.readBoolean();let n=!1;(e||i)&&(n=t.readBoolean(),n&&(t.readUByte(),t.readBits(5),t.readBoolean(),t.readBits(5)),t.readBits(4),t.readBits(4),n&&t.readBits(4),t.readBits(5),t.readBits(5),t.readBits(5));for(let s=0;s<=r;s++){M=t.readBoolean();let r=!1;M||t.readBoolean()?t.readEG():r=t.readBoolean();const s=r?1:t.readUEG()+1;if(e)for(let e=0;e<s;e++)t.readUEG(),t.readUEG(),n&&(t.readUEG(),t.readUEG()),t.skipBits(1);if(i)for(let e=0;e<s;e++)t.readUEG(),t.readUEG(),n&&(t.readUEG(),t.readUEG()),t.skipBits(1)}}}t.readBoolean()&&(t.readBoolean(),t.readBoolean(),t.readBoolean(),D=t.readUEG())}let B=E,U=w;if(S){let e=1,t=1;1===b?e=t=2:2==b&&(e=2),B=E-e*x-e*T,U=w-t*k-t*A}const z=i?["A","B","C"][i]:"",G=a<<24|o<<16|l<<8|c;let j=0;for(let e=0;e<32;e++)j=(j|(G>>e&1)<<31-e)>>>0;let H=j.toString(16);1===s&&"2"===H&&(H="6");return{codecString:`hvc1.${z}${s}.${H}.${n?"H":"L"}${g}.B0`,params:{general_tier_flag:n,general_profile_idc:s,general_profile_space:i,general_profile_compatibility_flags:[a,o,l,c],general_constraint_indicator_flags:[d,u,h,f,p,m],general_level_idc:g,bit_depth:I+8,bit_depth_luma_minus8:I,bit_depth_chroma_minus8:L,min_spatial_segmentation_idc:D,chroma_format_idc:b,frame_rate:{fixed:M,fps:F/N}},width:B,height:U,pixelRatio:[_,O]}}readPPS(e){const t=new Fg(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.skipUEG(),t.skipUEG(),t.skipBits(2),t.skipBits(3),t.skipBits(2),t.skipUEG(),t.skipUEG(),t.skipEG(),t.skipBits(2);t.readBoolean()&&t.skipUEG(),t.skipEG(),t.skipEG(),t.skipBits(4);const r=t.readBoolean(),i=t.readBoolean();let n=1;return i&&r?n=0:i?n=3:r&&(n=2),{parallelismType:n}}matchSPS(e,t){return String.fromCharCode.apply(null,e).substr(3)===String.fromCharCode.apply(null,t).substr(3)}}const Ug=188;class zg{constructor(e,t,r,i){this.logger=void 0,this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=e,this.config=t,this.typeSupported=r,this.logger=i,this.videoParser=null}static probe(e,t){const r=zg.syncOffset(e);return r>0&&t.warn(`MPEG2-TS detected but first sync word found @ offset ${r}`),-1!==r}static syncOffset(e){const t=e.length;let r=Math.min(940,t-Ug)+1,i=0;for(;i<r;){let n=!1,s=-1,a=0;for(let o=i;o<t;o+=Ug){if(71!==e[o]||t-o!==Ug&&71!==e[o+Ug]){if(a)return-1;break}if(a++,-1===s&&(s=o,0!==s&&(r=Math.min(s+18612,e.length-Ug)+1)),n||(n=0===Gg(e,o)),n&&a>1&&(0===s&&a>2||o+Ug>r))return s}i++}return-1}static createTrack(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:sh[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?t:void 0}}resetInitSegment(e,t,r,i){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=zg.createTrack("video"),this._videoTrack.duration=i,this._audioTrack=zg.createTrack("audio",i),this._id3Track=zg.createTrack("id3"),this._txtTrack=zg.createTrack("text"),this._audioTrack.segmentCodec="aac",this.videoParser=null,this.aacOverFlow=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=r}resetTimeStamp(){}resetContiguity(){const{_audioTrack:e,_videoTrack:t,_id3Track:r}=this;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.remainderData=null}demux(e,t,r=!1,i=!1){let n;r||(this.sampleAes=null);const s=this._videoTrack,a=this._audioTrack,o=this._id3Track,l=this._txtTrack;let c=s.pid,d=s.pesData,u=a.pid,h=o.pid,f=a.pesData,p=o.pesData,m=null,g=this.pmtParsed,v=this._pmtId,y=e.length;if(this.remainderData&&(y=(e=wh(this.remainderData,e)).length,this.remainderData=null),y<Ug&&!i)return this.remainderData=e,{audioTrack:a,videoTrack:s,id3Track:o,textTrack:l};const b=Math.max(0,zg.syncOffset(e));y-=(y-b)%Ug,y<e.byteLength&&!i&&(this.remainderData=new Uint8Array(e.buffer,y,e.buffer.byteLength-y));let E=0;for(let t=b;t<y;t+=Ug)if(71===e[t]){const i=!!(64&e[t+1]),y=Gg(e,t);let E;if((48&e[t+3])>>4>1){if(E=t+5+e[t+4],E===t+Ug)continue}else E=t+4;switch(y){case c:i&&(d&&(n=Yg(d,this.logger))&&(this.readyVideoParser(s.segmentCodec),null!==this.videoParser&&this.videoParser.parsePES(s,l,n,!1)),d={data:[],size:0}),d&&(d.data.push(e.subarray(E,t+Ug)),d.size+=t+Ug-E);break;case u:if(i){if(f&&(n=Yg(f,this.logger)))switch(a.segmentCodec){case"aac":this.parseAACPES(a,n);break;case"mp3":this.parseMPEGPES(a,n);break;case"ac3":this.parseAC3PES(a,n)}f={data:[],size:0}}f&&(f.data.push(e.subarray(E,t+Ug)),f.size+=t+Ug-E);break;case h:i&&(p&&(n=Yg(p,this.logger))&&this.parseID3PES(o,n),p={data:[],size:0}),p&&(p.data.push(e.subarray(E,t+Ug)),p.size+=t+Ug-E);break;case 0:i&&(E+=e[E]+1),v=this._pmtId=jg(e,E);break;case v:{i&&(E+=e[E]+1);const n=Hg(e,E,this.typeSupported,r,this.observer,this.logger);c=n.videoPid,c>0&&(s.pid=c,s.segmentCodec=n.segmentVideoCodec),u=n.audioPid,u>0&&(a.pid=u,a.segmentCodec=n.segmentAudioCodec),h=n.id3Pid,h>0&&(o.pid=h),null===m||g||(this.logger.warn(`MPEG-TS PMT found at ${t} after unknown PID '${m}'. Backtracking to sync byte @${b} to parse all TS packets.`),m=null,t=b-188),g=this.pmtParsed=!0;break}case 17:case 8191:break;default:m=y}}else E++;E>0&&Vg(this.observer,new Error(`Found ${E} TS packet/s that do not start with 0x47`),void 0,this.logger),s.pesData=d,a.pesData=f,o.pesData=p;const w={audioTrack:a,videoTrack:s,id3Track:o,textTrack:l};return i&&this.extractRemainingSamples(w),w}flush(){const{remainderData:e}=this;let t;return this.remainderData=null,t=e?this.demux(e,-1,!1,!0):{videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t}extractRemainingSamples(e){const{audioTrack:t,videoTrack:r,id3Track:i,textTrack:n}=e,s=r.pesData,a=t.pesData,o=i.pesData;let l;if(s&&(l=Yg(s,this.logger))?(this.readyVideoParser(r.segmentCodec),null!==this.videoParser&&(this.videoParser.parsePES(r,n,l,!0),r.pesData=null)):r.pesData=s,a&&(l=Yg(a,this.logger))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,l);break;case"mp3":this.parseMPEGPES(t,l);break;case"ac3":this.parseAC3PES(t,l)}t.pesData=null}else null!=a&&a.size&&this.logger.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=a;o&&(l=Yg(o,this.logger))?(this.parseID3PES(i,l),i.pesData=null):i.pesData=o}demuxSampleAes(e,t,r){const i=this.demux(e,r,!0,!this.config.progressive),n=this.sampleAes=new Mg(this.observer,this.config,t);return this.decrypt(i,n)}readyVideoParser(e){null===this.videoParser&&("avc"===e?this.videoParser=new $g:"hevc"===e&&(this.videoParser=new Bg))}decrypt(e,t){return new Promise(r=>{const{audioTrack:i,videoTrack:n}=e;i.samples&&"aac"===i.segmentCodec?t.decryptAacSamples(i.samples,0,()=>{n.samples?t.decryptAvcSamples(n.samples,0,0,()=>{r(e)}):r(e)}):n.samples&&t.decryptAvcSamples(n.samples,0,0,()=>{r(e)})})}destroy(){this.observer&&this.observer.removeAllListeners(),this.config=this.logger=this.observer=null,this.aacOverFlow=this.videoParser=this.remainderData=this.sampleAes=null,this._videoTrack=this._audioTrack=this._id3Track=this._txtTrack=void 0}parseAACPES(e,t){let r=0;const i=this.aacOverFlow;let n,s,a,o=t.data;if(i){this.aacOverFlow=null;const t=i.missing,n=i.sample.unit.byteLength;if(-1===t)o=wh(i.sample.unit,o);else{const s=n-t;i.sample.unit.set(o.subarray(0,t),s),e.samples.push(i.sample),r=i.missing}}for(n=r,s=o.length;n<s-1&&!rg(o,n);n++);if(n!==r){let e;const t=n<s-1;if(e=t?`AAC PES did not start with ADTS header,offset:${n}`:"No ADTS header found in AAC PES",Vg(this.observer,new Error(e),t,this.logger),!t)return}if(ng(e,this.observer,o,n,this.audioCodec),void 0!==t.pts)a=t.pts;else{if(!i)return void this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");{const t=sg(e.samplerate);a=i.sample.pts+t}}let l,c=0;for(;n<s;){if(l=ag(e,o,n,a,c),n+=l.length,l.missing){this.aacOverFlow=l;break}for(c++;n<s-1&&!rg(o,n);n++);}}parseMPEGPES(e,t){const r=t.data,i=r.length;let n=0,s=0;const a=t.pts;if(void 0!==a)for(;s<i;)if(Lg(r,s)){const t=Ag(e,r,s,a,n);if(!t)break;s+=t.length,n++}else s++;else this.logger.warn("[tsdemuxer]: MPEG PES unknown PTS")}parseAC3PES(e,t){{const r=t.data,i=t.pts;if(void 0===i)return void this.logger.warn("[tsdemuxer]: AC3 PES unknown PTS");const n=r.length;let s,a=0,o=0;for(;o<n&&(s=Dg(e,r,o,i,a++))>0;)o+=s}}parseID3PES(e,t){if(void 0===t.pts)return void this.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");const r=xu({},t,{type:this._videoTrack?gg.emsg:gg.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(r)}}function Gg(e,t){return((31&e[t+1])<<8)+e[t+2]}function jg(e,t){return(31&e[t+10])<<8|e[t+11]}function Hg(e,t,r,i,n,s){const a={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},o=t+3+((15&e[t+1])<<8|e[t+2])-4;for(t+=12+((15&e[t+10])<<8|e[t+11]);t<o;){const o=Gg(e,t),l=(15&e[t+3])<<8|e[t+4];switch(e[t]){case 207:if(!i){Wg("ADTS AAC",s);break}case 15:-1===a.audioPid&&(a.audioPid=o);break;case 21:-1===a.id3Pid&&(a.id3Pid=o);break;case 219:if(!i){Wg("H.264",s);break}case 27:-1===a.videoPid&&(a.videoPid=o);break;case 3:case 4:r.mpeg||r.mp3?-1===a.audioPid&&(a.audioPid=o,a.segmentAudioCodec="mp3"):s.log("MPEG audio found, not supported in this browser");break;case 193:if(!i){Wg("AC-3",s);break}case 129:r.ac3?-1===a.audioPid&&(a.audioPid=o,a.segmentAudioCodec="ac3"):s.log("AC-3 audio found, not supported in this browser");break;case 6:if(-1===a.audioPid&&l>0){let i=t+5,n=l;for(;n>2;){if(106===e[i])!0!==r.ac3?s.log("AC-3 audio found, not supported in this browser for now"):(a.audioPid=o,a.segmentAudioCodec="ac3");const t=e[i+1]+2;i+=t,n-=t}}break;case 194:case 135:return Vg(n,new Error("Unsupported EC-3 in M2TS found"),void 0,s),a;case 36:-1===a.videoPid&&(a.videoPid=o,a.segmentVideoCodec="hevc",s.log("HEVC in M2TS found"))}t+=l+5}return a}function Vg(e,t,r,i){i.warn(`parsing error: ${t.message}`),e.emit(fu.ERROR,fu.ERROR,{type:uu.MEDIA_ERROR,details:hu.FRAG_PARSING_ERROR,fatal:!1,levelRetry:r,error:t,reason:t.message})}function Wg(e,t){t.log(`${e} with AES-128-CBC encryption found in unencrypted stream`)}function Yg(e,t){let r,i,n,s,a,o=0;const l=e.data;if(!e||0===e.size)return null;for(;l[0].length<19&&l.length>1;)l[0]=wh(l[0],l[1]),l.splice(1,1);r=l[0];if(1===(r[0]<<16)+(r[1]<<8)+r[2]){if(i=(r[4]<<8)+r[5],i&&i>e.size-6)return null;const c=r[7];192&c&&(s=536870912*(14&r[9])+4194304*(255&r[10])+16384*(254&r[11])+128*(255&r[12])+(254&r[13])/2,64&c?(a=536870912*(14&r[14])+4194304*(255&r[15])+16384*(254&r[16])+128*(255&r[17])+(254&r[18])/2,s-a>54e5&&(t.warn(`${Math.round((s-a)/9e4)}s delta between PTS and DTS, align them`),s=a)):a=s),n=r[8];let d=n+9;if(e.size<=d)return null;e.size-=d;const u=new Uint8Array(e.size);for(let e=0,t=l.length;e<t;e++){r=l[e];let t=r.byteLength;if(d){if(d>t){d-=t;continue}r=r.subarray(d),t-=d,d=0}u.set(r,o),o+=t}return i&&(i-=n+3),{data:u,pts:s,dts:a,len:i}}return null}class Kg{static getSilentFrame(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===t)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}}}const qg=Math.pow(2,32)-1;class Xg{static init(){let e;for(e in Xg.types={avc1:[],avcC:[],hvc1:[],hvcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},Xg.types)Xg.types.hasOwnProperty(e)&&(Xg.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);const t=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),r=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);Xg.HDLR_TYPES={video:t,audio:r};const i=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),n=new Uint8Array([0,0,0,0,0,0,0,0]);Xg.STTS=Xg.STSC=Xg.STCO=n,Xg.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),Xg.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),Xg.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),Xg.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const s=new Uint8Array([105,115,111,109]),a=new Uint8Array([97,118,99,49]),o=new Uint8Array([0,0,0,1]);Xg.FTYP=Xg.box(Xg.types.ftyp,s,o,s,a),Xg.DINF=Xg.box(Xg.types.dinf,Xg.box(Xg.types.dref,i))}static box(e,...t){let r=8,i=t.length;const n=i;for(;i--;)r+=t[i].byteLength;const s=new Uint8Array(r);for(s[0]=r>>24&255,s[1]=r>>16&255,s[2]=r>>8&255,s[3]=255&r,s.set(e,4),i=0,r=8;i<n;i++)s.set(t[i],r),r+=t[i].byteLength;return s}static hdlr(e){return Xg.box(Xg.types.hdlr,Xg.HDLR_TYPES[e])}static mdat(e){return Xg.box(Xg.types.mdat,e)}static mdhd(e,t){t*=e;const r=Math.floor(t/(qg+1)),i=Math.floor(t%(qg+1));return Xg.box(Xg.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,r>>24,r>>16&255,r>>8&255,255&r,i>>24,i>>16&255,i>>8&255,255&i,85,196,0,0]))}static mdia(e){return Xg.box(Xg.types.mdia,Xg.mdhd(e.timescale||0,e.duration||0),Xg.hdlr(e.type),Xg.minf(e))}static mfhd(e){return Xg.box(Xg.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e]))}static minf(e){return"audio"===e.type?Xg.box(Xg.types.minf,Xg.box(Xg.types.smhd,Xg.SMHD),Xg.DINF,Xg.stbl(e)):Xg.box(Xg.types.minf,Xg.box(Xg.types.vmhd,Xg.VMHD),Xg.DINF,Xg.stbl(e))}static moof(e,t,r){return Xg.box(Xg.types.moof,Xg.mfhd(e),Xg.traf(r,t))}static moov(e){let t=e.length;const r=[];for(;t--;)r[t]=Xg.trak(e[t]);return Xg.box.apply(null,[Xg.types.moov,Xg.mvhd(e[0].timescale||0,e[0].duration||0)].concat(r).concat(Xg.mvex(e)))}static mvex(e){let t=e.length;const r=[];for(;t--;)r[t]=Xg.trex(e[t]);return Xg.box.apply(null,[Xg.types.mvex,...r])}static mvhd(e,t){t*=e;const r=Math.floor(t/(qg+1)),i=Math.floor(t%(qg+1)),n=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,r>>24,r>>16&255,r>>8&255,255&r,i>>24,i>>16&255,i>>8&255,255&i,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return Xg.box(Xg.types.mvhd,n)}static sdtp(e){const t=e.samples||[],r=new Uint8Array(4+t.length);let i,n;for(i=0;i<t.length;i++)n=t[i].flags,r[i+4]=n.dependsOn<<4|n.isDependedOn<<2|n.hasRedundancy;return Xg.box(Xg.types.sdtp,r)}static stbl(e){return Xg.box(Xg.types.stbl,Xg.stsd(e),Xg.box(Xg.types.stts,Xg.STTS),Xg.box(Xg.types.stsc,Xg.STSC),Xg.box(Xg.types.stsz,Xg.STSZ),Xg.box(Xg.types.stco,Xg.STCO))}static avc1(e){let t,r,i,n=[],s=[];for(t=0;t<e.sps.length;t++)r=e.sps[t],i=r.byteLength,n.push(i>>>8&255),n.push(255&i),n=n.concat(Array.prototype.slice.call(r));for(t=0;t<e.pps.length;t++)r=e.pps[t],i=r.byteLength,s.push(i>>>8&255),s.push(255&i),s=s.concat(Array.prototype.slice.call(r));const a=Xg.box(Xg.types.avcC,new Uint8Array([1,n[3],n[4],n[5],255,224|e.sps.length].concat(n).concat([e.pps.length]).concat(s))),o=e.width,l=e.height,c=e.pixelRatio[0],d=e.pixelRatio[1];return Xg.box(Xg.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,o>>8&255,255&o,l>>8&255,255&l,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),a,Xg.box(Xg.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),Xg.box(Xg.types.pasp,new Uint8Array([c>>24,c>>16&255,c>>8&255,255&c,d>>24,d>>16&255,d>>8&255,255&d])))}static esds(e){const t=e.config;return new Uint8Array([0,0,0,0,3,25,0,1,0,4,17,64,21,0,0,0,0,0,0,0,0,0,0,0,5,2,...t,6,1,2])}static audioStsd(e){const t=e.samplerate||0;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount||0,0,16,0,0,0,0,t>>8&255,255&t,0,0])}static mp4a(e){return Xg.box(Xg.types.mp4a,Xg.audioStsd(e),Xg.box(Xg.types.esds,Xg.esds(e)))}static mp3(e){return Xg.box(Xg.types[".mp3"],Xg.audioStsd(e))}static ac3(e){return Xg.box(Xg.types["ac-3"],Xg.audioStsd(e),Xg.box(Xg.types.dac3,e.config))}static stsd(e){const{segmentCodec:t}=e;if("audio"===e.type){if("aac"===t)return Xg.box(Xg.types.stsd,Xg.STSD,Xg.mp4a(e));if("ac3"===t&&e.config)return Xg.box(Xg.types.stsd,Xg.STSD,Xg.ac3(e));if("mp3"===t&&"mp3"===e.codec)return Xg.box(Xg.types.stsd,Xg.STSD,Xg.mp3(e))}else{if(!e.pps||!e.sps)throw new Error("video track missing pps or sps");if("avc"===t)return Xg.box(Xg.types.stsd,Xg.STSD,Xg.avc1(e));if("hevc"===t&&e.vps)return Xg.box(Xg.types.stsd,Xg.STSD,Xg.hvc1(e))}throw new Error(`unsupported ${e.type} segment codec (${t}/${e.codec})`)}static tkhd(e){const t=e.id,r=(e.duration||0)*(e.timescale||0),i=e.width||0,n=e.height||0,s=Math.floor(r/(qg+1)),a=Math.floor(r%(qg+1));return Xg.box(Xg.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,0,0,0,0,s>>24,s>>16&255,s>>8&255,255&s,a>>24,a>>16&255,a>>8&255,255&a,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,i>>8&255,255&i,0,0,n>>8&255,255&n,0,0]))}static traf(e,t){const r=Xg.sdtp(e),i=e.id,n=Math.floor(t/(qg+1)),s=Math.floor(t%(qg+1));return Xg.box(Xg.types.traf,Xg.box(Xg.types.tfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i])),Xg.box(Xg.types.tfdt,new Uint8Array([1,0,0,0,n>>24,n>>16&255,n>>8&255,255&n,s>>24,s>>16&255,s>>8&255,255&s])),Xg.trun(e,r.length+16+20+8+16+8+8),r)}static trak(e){return e.duration=e.duration||4294967295,Xg.box(Xg.types.trak,Xg.tkhd(e),Xg.mdia(e))}static trex(e){const t=e.id;return Xg.box(Xg.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,t){const r=e.samples||[],i=r.length,n=12+16*i,s=new Uint8Array(n);let a,o,l,c,d,u;for(t+=8+n,s.set(["video"===e.type?1:0,0,15,1,i>>>24&255,i>>>16&255,i>>>8&255,255&i,t>>>24&255,t>>>16&255,t>>>8&255,255&t],0),a=0;a<i;a++)o=r[a],l=o.duration,c=o.size,d=o.flags,u=o.cts,s.set([l>>>24&255,l>>>16&255,l>>>8&255,255&l,c>>>24&255,c>>>16&255,c>>>8&255,255&c,d.isLeading<<2|d.dependsOn,d.isDependedOn<<6|d.hasRedundancy<<4|d.paddingValue<<1|d.isNonSync,61440&d.degradPrio,15&d.degradPrio,u>>>24&255,u>>>16&255,u>>>8&255,255&u],12+16*a);return Xg.box(Xg.types.trun,s)}static initSegment(e){Xg.types||Xg.init();const t=Xg.moov(e);return wh(Xg.FTYP,t)}static hvc1(e){const t=e.params,r=[e.vps,e.sps,e.pps],i=new Uint8Array([1,t.general_profile_space<<6|(t.general_tier_flag?32:0)|t.general_profile_idc,t.general_profile_compatibility_flags[0],t.general_profile_compatibility_flags[1],t.general_profile_compatibility_flags[2],t.general_profile_compatibility_flags[3],t.general_constraint_indicator_flags[0],t.general_constraint_indicator_flags[1],t.general_constraint_indicator_flags[2],t.general_constraint_indicator_flags[3],t.general_constraint_indicator_flags[4],t.general_constraint_indicator_flags[5],t.general_level_idc,240|t.min_spatial_segmentation_idc>>8,255&t.min_spatial_segmentation_idc,252|t.parallelismType,252|t.chroma_format_idc,248|t.bit_depth_luma_minus8,248|t.bit_depth_chroma_minus8,0,parseInt(t.frame_rate.fps),3|t.temporal_id_nested<<2|t.num_temporal_layers<<3|(t.frame_rate.fixed?64:0),r.length]);let n=i.length;for(let e=0;e<r.length;e+=1){n+=3;for(let t=0;t<r[e].length;t+=1)n+=2+r[e][t].length}const s=new Uint8Array(n);s.set(i,0),n=i.length;const a=r.length-1;for(let e=0;e<r.length;e+=1){s.set(new Uint8Array([32+e|(e===a?128:0),0,r[e].length]),n),n+=3;for(let t=0;t<r[e].length;t+=1)s.set(new Uint8Array([r[e][t].length>>8,255&r[e][t].length]),n),n+=2,s.set(r[e][t],n),n+=r[e][t].length}const o=Xg.box(Xg.types.hvcC,s),l=e.width,c=e.height,d=e.pixelRatio[0],u=e.pixelRatio[1];return Xg.box(Xg.types.hvc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,l>>8&255,255&l,c>>8&255,255&c,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,Xg.box(Xg.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),Xg.box(Xg.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,255&d,u>>24,u>>16&255,u>>8&255,255&u])))}}Xg.types=void 0,Xg.HDLR_TYPES=void 0,Xg.STTS=void 0,Xg.STSC=void 0,Xg.STCO=void 0,Xg.STSZ=void 0,Xg.VMHD=void 0,Xg.SMHD=void 0,Xg.STSD=void 0,Xg.FTYP=void 0,Xg.DINF=void 0;function Qg(e,t,r=1,i=!1){const n=e*t*r;return i?Math.round(n):n}function Zg(e,t=!1){return Qg(e,1e3,1/9e4,t)}function Jg(e){const{baseTime:t,timescale:r,trackId:i}=e;return`${t/r} (${t}/${r}) trackId: ${i}`}let ev,tv=null,rv=null;function iv(e,t,r,i){return{duration:t,size:r,cts:i,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:e?2:1,isNonSync:e?0:1}}}class nv extends Iu{constructor(e,t,r,i){if(super("mp4-remuxer",i),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextVideoTs=null,this.nextAudioTs=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=e,this.config=t,this.typeSupported=r,this.ISGenerated=!1,null===tv){const e=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);tv=e?parseInt(e[1]):0}if(null===rv){const e=navigator.userAgent.match(/Safari\/(\d+)/i);rv=e?parseInt(e[1]):0}}destroy(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}resetTimeStamp(e){const t=this._initPTS;t&&e&&e.trackId===t.trackId&&e.baseTime===t.baseTime&&e.timescale===t.timescale||this.log(`Reset initPTS: ${t?Jg(t):t} > ${e?Jg(e):e}`),this._initPTS=this._initDTS=e}resetNextTimestamp(){this.log("reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){this.log("ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}getVideoStartPts(e){let t=!1;const r=e[0].pts,i=e.reduce((e,i)=>{let n=i.pts,s=n-e;return s<-4294967296&&(t=!0,n=sv(n,r),s=n-e),s>0?e:n},r);return t&&this.debug("PTS rollover detected"),i}remux(e,t,r,i,n,s,a,o){let l,c,d,u,h,f,p=n,m=n;const g=e.pid>-1,v=t.pid>-1,y=t.samples.length,b=e.samples.length>0,E=a&&y>0||y>1;if((!g||b)&&(!v||E)||this.ISGenerated||a){if(this.ISGenerated){var w,S,T,x;const e=this.videoTrackConfig;(e&&(t.width!==e.width||t.height!==e.height||(null==(w=t.pixelRatio)?void 0:w[0])!==(null==(S=e.pixelRatio)?void 0:S[0])||(null==(T=t.pixelRatio)?void 0:T[1])!==(null==(x=e.pixelRatio)?void 0:x[1]))||!e&&E||null===this.nextAudioTs&&b)&&this.resetInitSegment()}this.ISGenerated||(d=this.generateIS(e,t,n,s));const r=this.isVideoContiguous;let i,a=-1;if(E&&(a=function(e){for(let t=0;t<e.length;t++)if(e[t].key)return t;return-1}(t.samples),!r&&this.config.forceKeyFrameOnDiscontinuity))if(f=!0,a>0){this.warn(`Dropped ${a} out of ${y} video samples due to a missing keyframe`);const e=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(a),t.dropped+=a,m+=(t.samples[0].pts-e)/t.inputTimeScale,i=m}else-1===a&&(this.warn(`No keyframe found out of ${y} video samples`),f=!1);if(this.ISGenerated){if(b&&E){const r=this.getVideoStartPts(t.samples),i=(sv(e.samples[0].pts,r)-r)/t.inputTimeScale;p+=Math.max(0,i),m+=Math.max(0,-i)}if(b){if(e.samplerate||(this.warn("regenerate InitSegment as audio detected"),d=this.generateIS(e,t,n,s)),c=this.remuxAudio(e,p,this.isAudioContiguous,s,v||E||o===bu?m:void 0),E){const i=c?c.endPTS-c.startPTS:0;t.inputTimeScale||(this.warn("regenerate InitSegment as video detected"),d=this.generateIS(e,t,n,s)),l=this.remuxVideo(t,m,r,i)}}else E&&(l=this.remuxVideo(t,m,r,0));l&&(l.firstKeyFrame=a,l.independent=-1!==a,l.firstKeyFramePTS=i)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(h=av(r,n,this._initPTS,this._initDTS)),i.samples.length&&(u=ov(i,n,this._initPTS))),{audio:c,video:l,initSegment:d,independent:f,text:u,id3:h}}computeInitPts(e,t,r,i){const n=Math.round(r*t);let s=sv(e,n);if(s<n+t)for(this.log(`Adjusting PTS for rollover in timeline near ${(n-s)/t} ${i}`);s<n+t;)s+=8589934592;return s-n}generateIS(e,t,r,i){const n=e.samples,s=t.samples,a=this.typeSupported,o={},l=this._initPTS;let c,d,u,h=!l||i,f="audio/mp4",p=-1;if(h&&(c=d=1/0),e.config&&n.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":a.mpeg?(f="audio/mpeg",e.codec=""):a.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3"}o.audio={id:"audio",container:f,codec:e.codec,initSegment:"mp3"===e.segmentCodec&&a.mpeg?new Uint8Array(0):Xg.initSegment([e]),metadata:{channelCount:e.channelCount}},h&&(p=e.id,u=e.inputTimeScale,l&&u===l.timescale?h=!1:c=d=this.computeInitPts(n[0].pts,u,r,"audio"))}if(t.sps&&t.pps&&s.length){if(t.timescale=t.inputTimeScale,o.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:Xg.initSegment([t]),metadata:{width:t.width,height:t.height}},h)if(p=t.id,u=t.inputTimeScale,l&&u===l.timescale)h=!1;else{const e=this.getVideoStartPts(s),t=sv(s[0].dts,e),i=this.computeInitPts(t,u,r,"video"),n=this.computeInitPts(e,u,r,"video");d=Math.min(d,i),c=Math.min(c,n)}this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(o).length)return this.ISGenerated=!0,h?(l&&this.warn(`Timestamps at playlist time: ${i?"":"~"}${r} ${c/u} != initPTS: ${l.baseTime/l.timescale} (${l.baseTime}/${l.timescale}) trackId: ${l.trackId}`),this.log(`Found initPTS at playlist time: ${r} offset: ${c/u} (${c}/${u}) trackId: ${p}`),this._initPTS={baseTime:c,timescale:u,trackId:p},this._initDTS={baseTime:d,timescale:u,trackId:p}):c=u=void 0,{tracks:o,initPTS:c,timescale:u,trackId:p}}remuxVideo(e,t,r,i){const n=e.inputTimeScale,s=e.samples,a=[],o=s.length,l=this._initPTS,c=l.baseTime*n/l.timescale;let d,u,h=this.nextVideoTs,f=8,p=this.videoSampleDuration,m=Number.POSITIVE_INFINITY,g=Number.NEGATIVE_INFINITY,v=!1;if(!r||null===h){const e=c+t*n,i=s[0].pts-sv(s[0].dts,s[0].pts);tv&&null!==h&&Math.abs(e-i-(h+c))<15e3?r=!0:h=e-i-c}const y=h+c;for(let e=0;e<o;e++){const t=s[e];t.pts=sv(t.pts,y),t.dts=sv(t.dts,y),t.dts<s[e>0?e-1:e].dts&&(v=!0)}v&&s.sort(function(e,t){const r=e.dts-t.dts,i=e.pts-t.pts;return r||i}),d=s[0].dts,u=s[s.length-1].dts;const b=u-d,E=b?Math.round(b/(o-1)):p||e.inputTimeScale/30;if(r){const r=d-y,i=r>E,n=r<-1;if((i||n)&&(i?this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${Zg(r,!0)} ms (${r}dts) hole between fragments detected at ${t.toFixed(3)}`):this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${Zg(-r,!0)} ms (${r}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!n||y>=s[0].pts||tv)){d=y;const e=s[0].pts-r;if(i)s[0].dts=d,s[0].pts=e;else{let t=!0;for(let i=0;i<s.length&&!(s[i].dts>e&&t);i++){const e=s[i].pts;if(s[i].dts-=r,s[i].pts-=r,i<s.length-1){const r=s[i+1].pts;t=r<=s[i].pts==r<=e}}}this.log(`Video: Initial PTS/DTS adjusted: ${Zg(e,!0)}/${Zg(d,!0)}, delta: ${Zg(r,!0)} ms`)}}d=Math.max(0,d);let w=0,S=0,T=d;for(let e=0;e<o;e++){const t=s[e],r=t.units,i=r.length;let n=0;for(let e=0;e<i;e++)n+=r[e].data.length;S+=n,w+=i,t.length=n,t.dts<T?(t.dts=T,T+=E/4|0||1):T=t.dts,m=Math.min(t.pts,m),g=Math.max(t.pts,g)}u=s[o-1].dts;const x=S+4*w+8;let A;try{A=new Uint8Array(x)}catch(e){return void this.observer.emit(fu.ERROR,fu.ERROR,{type:uu.MUX_ERROR,details:hu.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:x,reason:`fail allocating video mdat ${x}`})}const k=new DataView(A.buffer);k.setUint32(0,x),A.set(Xg.types.mdat,4);let I=!1,L=Number.POSITIVE_INFINITY,R=Number.POSITIVE_INFINITY,P=Number.NEGATIVE_INFINITY,C=Number.NEGATIVE_INFINITY;for(let e=0;e<o;e++){const t=s[e],r=t.units;let l,d=0;for(let e=0,t=r.length;e<t;e++){const t=r[e],i=t.data,n=t.data.byteLength;k.setUint32(f,n),f+=4,A.set(i,f),f+=n,d+=4+n}if(e<o-1)p=s[e+1].dts-t.dts,l=s[e+1].pts-t.pts;else{const r=this.config,a=e>0?t.dts-s[e-1].dts:E;if(l=e>0?t.pts-s[e-1].pts:E,r.stretchShortVideoTrack&&null!==this.nextAudioTs){const e=Math.floor(r.maxBufferHole*n),s=(i?m+i*n:this.nextAudioTs+c)-t.pts;s>e?(p=s-a,p<0?p=a:I=!0,this.log(`It is approximately ${s/90} ms to the next segment; using duration ${p/90} ms for the last video frame.`)):p=a}else p=a}const u=Math.round(t.pts-t.dts);L=Math.min(L,p),P=Math.max(P,p),R=Math.min(R,l),C=Math.max(C,l),a.push(iv(t.key,p,d,u))}if(a.length)if(tv){if(tv<70){const e=a[0].flags;e.dependsOn=2,e.isNonSync=0}}else if(rv&&C-R<P-L&&E/P<.025&&0===a[0].cts){this.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let e=d;for(let t=0,r=a.length;t<r;t++){const i=e+a[t].duration,n=e+a[t].cts;if(t<r-1){const e=i+a[t+1].cts;a[t].duration=e-n}else a[t].duration=t?a[t-1].duration:E;a[t].cts=0,e=i}}p=I||!p?E:p;const D=u+p;this.nextVideoTs=h=D-c,this.videoSampleDuration=p,this.isVideoContiguous=!0;const _={data1:Xg.moof(e.sequenceNumber++,d,xu(e,{samples:a})),data2:A,startPTS:(m-c)/n,endPTS:(g+p-c)/n,startDTS:(d-c)/n,endDTS:h/n,type:"video",hasAudio:!1,hasVideo:!0,nb:a.length,dropped:e.dropped};return e.samples=[],e.dropped=0,_}getSamplesPerFrame(e){switch(e.segmentCodec){case"mp3":return 1152;case"ac3":return 1536;default:return 1024}}remuxAudio(e,t,r,i,n){const s=e.inputTimeScale,a=s/(e.samplerate?e.samplerate:s),o=this.getSamplesPerFrame(e),l=o*a,c=this._initPTS,d="mp3"===e.segmentCodec&&this.typeSupported.mpeg,u=[],h=void 0!==n;let f=e.samples,p=d?0:8,m=this.nextAudioTs||-1;const g=c.baseTime*s/c.timescale,v=g+t*s;if(this.isAudioContiguous=r=r||f.length&&m>0&&(i&&Math.abs(v-(m+g))<9e3||Math.abs(sv(f[0].pts,v)-(m+g))<20*l),f.forEach(function(e){e.pts=sv(e.pts,v)}),!r||m<0){const e=f.length;if(f=f.filter(e=>e.pts>=0),e!==f.length&&this.warn(`Removed ${f.length-e} of ${e} samples (initPTS ${g} / ${s})`),!f.length)return;m=0===n?0:i&&!h?Math.max(0,v-g):f[0].pts-g}if("aac"===e.segmentCodec){const t=this.config.maxAudioFramesDrift;for(let r=0,i=m+g;r<f.length;r++){const n=f[r],a=n.pts,o=a-i,c=Math.abs(1e3*o/s);if(o<=-t*l&&h)0===r&&(this.warn(`Audio frame @ ${(a/s).toFixed(3)}s overlaps marker by ${Math.round(1e3*o/s)} ms.`),this.nextAudioTs=m=a-g,i=a);else if(o>=t*l&&c<1e4&&h){let t=Math.round(o/l);for(i=a-t*l;i<0&&t&&l;)t--,i+=l;0===r&&(this.nextAudioTs=m=i-g),this.warn(`Injecting ${t} audio frames @ ${((i-g)/s).toFixed(3)}s due to ${Math.round(1e3*o/s)} ms gap.`);for(let s=0;s<t;s++){let t=Kg.getSilentFrame(e.parsedCodec||e.manifestCodec||e.codec,e.channelCount);t||(this.log("Unable to get silent frame for given audio codec; duplicating last frame instead."),t=n.unit.subarray()),f.splice(r,0,{unit:t,pts:i}),i+=l,r++}}n.pts=i,i+=l}}let y,b=null,E=null,w=0,S=f.length;for(;S--;)w+=f[S].unit.byteLength;for(let t=0,i=f.length;t<i;t++){const i=f[t],n=i.unit;let s=i.pts;if(null!==E){u[t-1].duration=Math.round((s-E)/a)}else{if(r&&"aac"===e.segmentCodec&&(s=m+g),b=s,!(w>0))return;w+=p;try{y=new Uint8Array(w)}catch(e){return void this.observer.emit(fu.ERROR,fu.ERROR,{type:uu.MUX_ERROR,details:hu.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:w,reason:`fail allocating audio mdat ${w}`})}if(!d){new DataView(y.buffer).setUint32(0,w),y.set(Xg.types.mdat,4)}}y.set(n,p);const l=n.byteLength;p+=l,u.push(iv(!0,o,l,0)),E=s}const T=u.length;if(!T)return;const x=u[u.length-1];m=E-g,this.nextAudioTs=m+a*x.duration;const A=d?new Uint8Array(0):Xg.moof(e.sequenceNumber++,b/a,xu({},e,{samples:u}));e.samples=[];const k=(b-g)/s,I=this.nextAudioTs/s,L={data1:A,data2:y,startPTS:k,endPTS:I,startDTS:k,endDTS:I,type:"audio",hasAudio:!0,hasVideo:!1,nb:T};return this.isAudioContiguous=!0,L}}function sv(e,t){let r;if(null===t)return e;for(r=t<e?-8589934592:8589934592;Math.abs(e-t)>4294967296;)e+=r;return e}function av(e,t,r,i){const n=e.samples.length;if(!n)return;const s=e.inputTimeScale;for(let a=0;a<n;a++){const n=e.samples[a];n.pts=sv(n.pts-r.baseTime*s/r.timescale,t*s)/s,n.dts=sv(n.dts-i.baseTime*s/i.timescale,t*s)/s}const a=e.samples;return e.samples=[],{samples:a}}function ov(e,t,r){const i=e.samples.length;if(!i)return;const n=e.inputTimeScale;for(let s=0;s<i;s++){const i=e.samples[s];i.pts=sv(i.pts-r.baseTime*n/r.timescale,t*n)/n}e.samples.sort((e,t)=>e.pts-t.pts);const s=e.samples;return e.samples=[],{samples:s}}function lv(e,t,r=!1){return void 0!==(null==e?void 0:e.start)?(e.start+(r?e.duration:0))/e.timescale:t}function cv(e,t,r){const i=e.codec;if(i&&i.length>4)return i;if(t===qu){if("ec-3"===i||"ac-3"===i||"alac"===i)return i;if("fLaC"===i||"Opus"===i){return Bh(i,!1)}return r.warn(`Unhandled audio codec "${i}" in mp4 MAP`),i||"mp4a"}return r.warn(`Unhandled video codec "${i}" in mp4 MAP`),i||"avc1"}try{ev=self.performance.now.bind(self.performance)}catch(e){ev=Date.now}const dv=[{demux:class{constructor(e,t){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=t}resetTimeStamp(){}resetInitSegment(e,t,r,i){const n=this.videoTrack=vg("video",1),s=this.audioTrack=vg("audio",1),a=this.txtTrack=vg("text",1);if(this.id3Track=vg("id3",1),this.timeOffset=0,null==e||!e.byteLength)return;const o=fh(e);if(o.video){const{id:e,timescale:t,codec:r,supplemental:i}=o.video;n.id=e,n.timescale=a.timescale=t,n.codec=r,n.supplemental=i}if(o.audio){const{id:e,timescale:t,codec:r}=o.audio;s.id=e,s.timescale=t,s.codec=r}a.id=sh.text,n.sampleDuration=0,n.duration=s.duration=i}resetContiguity(){this.remainderData=null}static probe(e){return function(e){const t=e.byteLength;for(let r=0;r<t;){const i=lh(e,r);if(i>8&&109===e[r+4]&&111===e[r+5]&&111===e[r+6]&&102===e[r+7])return!0;r=i>1?r+i:t}return!1}(e)}demux(e,t){this.timeOffset=t;let r=e;const i=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=wh(this.remainderData,e));const t=function(e){const t={valid:null,remainder:null},r=uh(e,["moof"]);if(r.length<2)return t.remainder=e,t;const i=r[r.length-1];return t.valid=e.slice(0,i.byteOffset-8),t.remainder=e.slice(i.byteOffset-8),t}(r);this.remainderData=t.remainder,i.samples=t.valid||new Uint8Array}else i.samples=r;const s=this.extractID3Track(i,t);return n.samples=Sh(t,i),{videoTrack:i,audioTrack:this.audioTrack,id3Track:s,textTrack:this.txtTrack}}flush(){const e=this.timeOffset,t=this.videoTrack,r=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;const i=this.extractID3Track(t,this.timeOffset);return r.samples=Sh(e,t),{videoTrack:t,audioTrack:vg(),id3Track:i,textTrack:vg()}}extractID3Track(e,t){const r=this.id3Track;if(e.samples.length){const i=uh(e.samples,["emsg"]);i&&i.forEach(e=>{const i=function(e){const t=e[0];let r="",i="",n=0,s=0,a=0,o=0,l=0,c=0;if(0===t){for(;"\0"!==ah(e.subarray(c,c+1));)r+=ah(e.subarray(c,c+1)),c+=1;for(r+=ah(e.subarray(c,c+1)),c+=1;"\0"!==ah(e.subarray(c,c+1));)i+=ah(e.subarray(c,c+1)),c+=1;i+=ah(e.subarray(c,c+1)),c+=1,n=lh(e,12),s=lh(e,16),o=lh(e,20),l=lh(e,24),c=28}else if(1===t){c+=4,n=lh(e,c),c+=4;const t=lh(e,c);c+=4;const s=lh(e,c);for(c+=4,a=2**32*t+s,cu(a)||(a=Number.MAX_SAFE_INTEGER,_u.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=lh(e,c),c+=4,l=lh(e,c),c+=4;"\0"!==ah(e.subarray(c,c+1));)r+=ah(e.subarray(c,c+1)),c+=1;for(r+=ah(e.subarray(c,c+1)),c+=1;"\0"!==ah(e.subarray(c,c+1));)i+=ah(e.subarray(c,c+1)),c+=1;i+=ah(e.subarray(c,c+1)),c+=1}return{schemeIdUri:r,value:i,timeScale:n,presentationTime:a,presentationTimeDelta:s,eventDuration:o,id:l,payload:e.subarray(c,e.byteLength)}}(e);if(_g.test(i.schemeIdUri)){const e=Og(i,t);let n=4294967295===i.eventDuration?Number.POSITIVE_INFINITY:i.eventDuration/i.timeScale;n<=.001&&(n=Number.POSITIVE_INFINITY);const s=i.payload;r.samples.push({data:s,len:s.byteLength,dts:e,pts:e,type:gg.emsg,duration:n})}else if(this.config.enableEmsgKLVMetadata&&i.schemeIdUri.startsWith("urn:misb:KLV:bin:1910.1")){const e=Og(i,t);r.samples.push({data:i.payload,len:i.payload.byteLength,dts:e,pts:e,type:gg.misbklv,duration:Number.POSITIVE_INFINITY})}})}return r}demuxSampleAes(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){this.config=null,this.remainderData=null,this.videoTrack=this.audioTrack=this.id3Track=this.txtTrack=void 0}},remux:class extends Iu{constructor(e,t,r,i){super("passthrough-remuxer",i),this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null,this.isVideoContiguous=!1}destroy(){}resetTimeStamp(e){this.lastEndTime=null;const t=this.initPTS;t&&e&&t.baseTime===e.baseTime&&t.timescale===e.timescale||(this.initPTS=e)}resetNextTimestamp(){this.isVideoContiguous=!1,this.lastEndTime=null}resetInitSegment(e,t,r,i){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(e,i),this.emitInitSegment=!0}generateInitSegment(e,t){let{audioCodec:r,videoCodec:i}=this;if(null==e||!e.byteLength)return this.initTracks=void 0,void(this.initData=void 0);const{audio:n,video:s}=this.initData=fh(e);if(t)!function(e,t){if(!e||!t)return;const r=t.keyId;r&&t.isCommonEncryption&&bh(e,(e,t)=>{const i=e.subarray(8,24);i.some(e=>0!==e)||(_u.log(`[eme] Patching keyId in 'enc${t?"a":"v"}>sinf>>tenc' box: ${Fu(i)} -> ${Fu(r)}`),e.set(r,8))})}(e,t);else{const e=n||s;null!=e&&e.encrypted&&this.warn(`Init segment with encrypted track with has no key ("${e.codec}")!`)}n&&(r=cv(n,qu,this)),s&&(i=cv(s,Xu,this));const a={};n&&s?a.audiovideo={container:"video/mp4",codec:r+","+i,supplemental:s.supplemental,encrypted:s.encrypted,initSegment:e,id:"main"}:n?a.audio={container:"audio/mp4",codec:r,encrypted:n.encrypted,initSegment:e,id:"audio"}:s?a.video={container:"video/mp4",codec:i,supplemental:s.supplemental,encrypted:s.encrypted,initSegment:e,id:"main"}:this.warn("initSegment does not contain moov or trak boxes."),this.initTracks=a}remux(e,t,r,i,n,s){var a,o;let{initPTS:l,lastEndTime:c}=this;const d={audio:void 0,video:void 0,text:i,id3:r,initSegment:void 0};lu(c)||(c=this.lastEndTime=n||0);const u=t.samples;if(!u.length)return d;const h={initPTS:void 0,timescale:void 0,trackId:void 0};let f=this.initData;if(null!=(a=f)&&a.length||(this.generateInitSegment(u),f=this.initData),null==(o=f)||!o.length)return this.warn("Failed to generate initSegment."),d;this.emitInitSegment&&(h.tracks=this.initTracks,this.emitInitSegment=!1);const p=function(e,t,r){const i={},n=uh(e,["moof","traf"]);for(let e=0;e<n.length;e++){const s=n[e],a=uh(s,["tfhd"])[0],o=lh(a,4),l=t[o];if(!l)continue;i[o]||(i[o]={start:NaN,duration:0,sampleCount:0,timescale:l.timescale,type:l.type});const c=i[o],d=uh(s,["tfdt"])[0];if(d){const e=d[0];let t=lh(d,4);1===e&&(t===ih?r.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"):(t*=ih+1,t+=lh(d,8))),lu(t)&&(!lu(c.start)||t<c.start)&&(c.start=t)}const u=l.default,h=lh(a,0)|(null==u?void 0:u.flags);let f=(null==u?void 0:u.duration)||0;8&h&&(f=lh(a,2&h?12:8));const p=uh(s,["trun"]);let m=c.start||0,g=0,v=f;for(let e=0;e<p.length;e++){const t=p[e],r=lh(t,4),i=c.sampleCount;c.sampleCount+=r;const n=1&t[3],s=4&t[3],a=1&t[2],o=2&t[2],l=4&t[2],d=8&t[2];let u=8,h=r;for(n&&(u+=4),s&&r&&(1&t[u+1]||void 0!==c.keyFrameIndex||(c.keyFrameIndex=i),u+=4,a?(v=lh(t,u),u+=4):v=f,o&&(u+=4),d&&(u+=4),m+=v,g+=v,h--);h--;)a?(v=lh(t,u),u+=4):v=f,o&&(u+=4),l&&(1&t[u+1]||void 0===c.keyFrameIndex&&(c.keyFrameIndex=c.sampleCount-(h+1),c.keyFrameStart=m),u+=4),d&&(u+=4),m+=v,g+=v;!g&&f&&(g+=f*r)}c.duration+=g}if(!Object.keys(i).some(e=>i[e].duration)){let t=1/0,r=0;const n=uh(e,["sidx"]);for(let e=0;e<n.length;e++){const i=hh(n[e]);if(null!=i&&i.references){t=Math.min(t,i.earliestPresentationTime/i.timescale);const e=i.references.reduce((e,t)=>e+t.info.duration||0,0);r=Math.max(r,e+i.earliestPresentationTime/i.timescale)}}r&&lu(r)&&Object.keys(i).forEach(e=>{i[e].duration||(i[e].duration=r*i[e].timescale-i[e].start)})}return i}(u,f,this),m=f.audio?p[f.audio.id]:null,g=f.video?p[f.video.id]:null,v=lv(g,1/0),y=lv(m,1/0),b=lv(g,0,!0),E=lv(m,0,!0);let w=n,S=0;const T=m&&(!g||!l&&y<v||l&&l.trackId===f.audio.id),x=T?m:g;if(x){const e=x.timescale,t=x.start-n*e,r=T?f.audio.id:f.video.id;w=x.start/e,S=T?E-y:b-v,!s&&l||!function(e,t,r,i){if(null===e)return!0;const n=Math.max(i,1),s=t-e.baseTime/e.timescale;return Math.abs(s-r)>n}(l,w,n,S)&&e===l.timescale||(l&&this.warn(`Timestamps at playlist time: ${s?"":"~"}${n} ${t/e} != initPTS: ${l.baseTime/l.timescale} (${l.baseTime}/${l.timescale}) trackId: ${l.trackId}`),this.log(`Found initPTS at playlist time: ${n} offset: ${w-n} (${t}/${e}) trackId: ${r}`),l=null,h.initPTS=t,h.timescale=e,h.trackId=r)}else this.warn(`No audio or video samples found for initPTS at playlist time: ${n}`);l?(h.initPTS=l.baseTime,h.timescale=l.timescale,h.trackId=l.trackId):(h.timescale&&void 0!==h.trackId&&void 0!==h.initPTS||(this.warn("Could not set initPTS"),h.initPTS=w,h.timescale=1,h.trackId=-1),this.initPTS=l={baseTime:h.initPTS,timescale:h.timescale,trackId:h.trackId});const A=w-l.baseTime/l.timescale,k=A+S;S>0?this.lastEndTime=k:(this.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const I=!!f.audio,L=!!f.video;let R="";I&&(R+="audio"),L&&(R+="video");const P={data1:u,startPTS:A,startDTS:A,endPTS:k,endDTS:k,type:R,hasAudio:I,hasVideo:L,nb:1,dropped:0,encrypted:!!f.audio&&f.audio.encrypted||!!f.video&&f.video.encrypted};d.audio=I&&!L?P:void 0,d.video=L?P:void 0;const C=null==g?void 0:g.sampleCount;if(C){const e=g.keyFrameIndex,t=-1!==e;P.nb=C,P.dropped=0===e||this.isVideoContiguous?0:t?e:C,P.independent=t,P.firstKeyFrame=e,t&&g.keyFrameStart&&(P.firstKeyFramePTS=(g.keyFrameStart-l.baseTime)/l.timescale),this.isVideoContiguous||(d.independent=t),this.isVideoContiguous||(this.isVideoContiguous=t),P.dropped&&this.warn(`fmp4 does not start with IDR: firstIDR ${e}/${C} dropped: ${P.dropped} start: ${P.firstKeyFramePTS||"NA"}`)}return d.initSegment=h,d.id3=av(r,n,l,l),i.samples.length&&(d.text=ov(i,n,l)),d}}},{demux:zg,remux:nv},{demux:class extends yg{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t}resetInitSegment(e,t,r,i){super.resetInitSegment(e,t,r,i),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:i,inputTimeScale:9e4,dropped:0}}static probe(e,t){if(!e)return!1;const r=Zm(e,0);let i=(null==r?void 0:r.length)||0;if(Rg(e,i))return!1;for(let r=e.length;i<r;i++)if(ig(e,i))return t.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return function(e,t){return function(e,t){return t+5<e.length}(e,t)&&Jm(e,t)&&tg(e,t)<=e.length-t}(e,t)}appendFrame(e,t,r){ng(e,this.observer,t,r,e.manifestCodec);const i=ag(e,t,r,this.basePTS,this.frameIndex);if(i&&0===i.missing)return i}},remux:nv},{demux:class extends yg{resetInitSegment(e,t,r,i){super.resetInitSegment(e,t,r,i),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:i,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;const t=Zm(e,0);let r=(null==t?void 0:t.length)||0;if(t&&11===e[r]&&119===e[r+1]&&void 0!==mg(t)&&Pg(e,r)<=16)return!1;for(let t=e.length;r<t;r++)if(Rg(e,r))return _u.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return function(e,t){return Ig(e,t)&&4<=e.length-t}(e,t)}appendFrame(e,t,r){if(null!==this.basePTS)return Ag(e,t,r,this.basePTS,this.frameIndex)}},remux:nv}];dv.splice(2,0,{demux:Cg,remux:nv});class uv{constructor(e,t,r,i,n,s){this.asyncResult=!1,this.logger=void 0,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=t,this.config=r,this.id=n,this.logger=s}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,r,i){const n=r.transmuxing;n.executeStart=ev();let s=new Uint8Array(e);const{currentTransmuxState:a,transmuxConfig:o}=this;i&&(this.currentTransmuxState=i);const{contiguous:l,discontinuity:c,trackSwitch:d,accurateTimeOffset:u,timeOffset:h,initSegmentChange:f}=i||a,{audioCodec:p,videoCodec:m,defaultInitPts:g,duration:v,initSegmentData:y}=o,b=function(e,t){let r=null;e.byteLength>0&&null!=(null==t?void 0:t.key)&&null!==t.iv&&null!=t.method&&(r=t);return r}(s,t);if(b&&Tp(b.method)){const e=this.getDecrypter(),t=xp(b.method);if(!e.isSync())return this.asyncResult=!0,this.decryptionPromise=e.webCryptoDecrypt(s,b.key.buffer,b.iv.buffer,t).then(e=>{const t=this.push(e,null,r);return this.decryptionPromise=null,t}),this.decryptionPromise;{let i=e.softwareDecrypt(s,b.key.buffer,b.iv.buffer,t);if(r.part>-1){const t=e.flush();i=t?t.buffer:t}if(!i)return n.executeEnd=ev(),hv(r);s=new Uint8Array(i)}}const E=this.needsProbing(c,d);if(E){const e=this.configureTransmuxer(s);if(e)return this.logger.warn(`[transmuxer] ${e.message}`),this.observer.emit(fu.ERROR,fu.ERROR,{type:uu.MEDIA_ERROR,details:hu.FRAG_PARSING_ERROR,fatal:!1,error:e,reason:e.message}),n.executeEnd=ev(),hv(r)}(c||d||f||E)&&this.resetInitSegment(y,p,m,v,t),(c||f||E)&&this.resetInitialTimestamp(g),l||this.resetContiguity();const w=this.transmux(s,b,h,u,r);this.asyncResult=fv(w);const S=this.currentTransmuxState;return S.contiguous=!0,S.discontinuity=!1,S.trackSwitch=!1,n.executeEnd=ev(),w}flush(e){const t=e.transmuxing;t.executeStart=ev();const{decrypter:r,currentTransmuxState:i,decryptionPromise:n}=this;if(n)return this.asyncResult=!0,n.then(()=>this.flush(e));const s=[],{timeOffset:a}=i;if(r){const t=r.flush();t&&s.push(this.push(t.buffer,null,e))}const{demuxer:o,remuxer:l}=this;if(!o||!l){t.executeEnd=ev();const r=[hv(e)];return this.asyncResult?Promise.resolve(r):r}const c=o.flush(a);return fv(c)?(this.asyncResult=!0,c.then(t=>(this.flushRemux(s,t,e),s))):(this.flushRemux(s,c,e),this.asyncResult?Promise.resolve(s):s)}flushRemux(e,t,r){const{audioTrack:i,videoTrack:n,id3Track:s,textTrack:a}=t,{accurateTimeOffset:o,timeOffset:l}=this.currentTransmuxState;this.logger.log(`[transmuxer.ts]: Flushed ${this.id} sn: ${r.sn}${r.part>-1?" part: "+r.part:""} of ${this.id===yu?"level":"track"} ${r.level}`);const c=this.remuxer.remux(i,n,s,a,l,o,!0,this.id);e.push({remuxResult:c,chunkMeta:r}),r.transmuxing.executeEnd=ev()}resetInitialTimestamp(e){const{demuxer:t,remuxer:r}=this;t&&r&&(t.resetTimeStamp(e),r.resetTimeStamp(e))}resetContiguity(){const{demuxer:e,remuxer:t}=this;e&&t&&(e.resetContiguity(),t.resetNextTimestamp())}resetInitSegment(e,t,r,i,n){const{demuxer:s,remuxer:a}=this;s&&a&&(s.resetInitSegment(e,t,r,i),a.resetInitSegment(e,t,r,n))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,r,i,n){let s;return s=t&&"SAMPLE-AES"===t.method?this.transmuxSampleAes(e,t,r,i,n):this.transmuxUnencrypted(e,r,i,n),s}transmuxUnencrypted(e,t,r,i){const{audioTrack:n,videoTrack:s,id3Track:a,textTrack:o}=this.demuxer.demux(e,t,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(n,s,a,o,t,r,!1,this.id),chunkMeta:i}}transmuxSampleAes(e,t,r,i,n){return this.demuxer.demuxSampleAes(e,t,r).then(e=>({remuxResult:this.remuxer.remux(e.audioTrack,e.videoTrack,e.id3Track,e.textTrack,r,i,!1,this.id),chunkMeta:n}))}configureTransmuxer(e){const{config:t,observer:r,typeSupported:i}=this;let n;for(let t=0,r=dv.length;t<r;t++){var s;if(null!=(s=dv[t].demux)&&s.probe(e,this.logger)){n=dv[t];break}}if(!n)return new Error("Failed to find demuxer by probing fragment data");const a=this.demuxer,o=this.remuxer,l=n.remux,c=n.demux;o&&o instanceof l||(this.remuxer=new l(r,t,i,this.logger)),a&&a instanceof c||(this.demuxer=new c(r,t,i,this.logger),this.probe=c.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new Jf(this.config)),e}}const hv=e=>({remuxResult:{},chunkMeta:e});function fv(e){return"then"in e&&e.then instanceof Function}class pv{constructor(e,t,r,i,n){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=r,this.duration=i,this.defaultInitPts=n||null}}class mv{constructor(e,t,r,i,n,s){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=e,this.contiguous=t,this.accurateTimeOffset=r,this.trackSwitch=i,this.timeOffset=n,this.initSegmentChange=s}}let gv=0;class vv{constructor(e,t,r,i){this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=gv++,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.onWorkerMessage=e=>{const t=e.data,r=this.hls;if(r&&null!=t&&t.event&&t.instanceNo===this.instanceNo)switch(t.event){case"init":{var i;const e=null==(i=this.workerContext)?void 0:i.objectURL;e&&self.URL.revokeObjectURL(e);break}case"transmuxComplete":this.handleTransmuxComplete(t.data);break;case"flush":this.onFlush(t.data);break;case"workerLog":r.logger[t.data.logType]&&r.logger[t.data.logType](t.data.message);break;default:t.data=t.data||{},t.data.frag=this.frag,t.data.part=this.part,t.data.id=this.id,r.trigger(t.event,t.data)}},this.onWorkerError=e=>{if(!this.hls)return;const t=new Error(`${e.message} (${e.filename}:${e.lineno})`);this.hls.config.enableWorker=!1,this.hls.logger.warn(`Error in "${this.id}" Web Worker, fallback to inline`),this.hls.trigger(fu.ERROR,{type:uu.OTHER_ERROR,details:hu.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:t})};const n=e.config;this.hls=e,this.id=t,this.useWorker=!!n.enableWorker,this.onTransmuxComplete=r,this.onFlush=i;const s=(e,t)=>{(t=t||{}).frag=this.frag||void 0,e===fu.ERROR&&(t.parent=this.id,t.part=this.part,this.error=t.error),this.hls.trigger(e,t)};this.observer=new Wm,this.observer.on(fu.FRAG_DECRYPTED,s),this.observer.on(fu.ERROR,s);const a=jh(n.preferManagedMediaSource);if(this.useWorker&&"undefined"!=typeof Worker){const r=this.hls.logger;if(n.workerPath||"function"==typeof __HLS_WORKER_BUNDLE__){try{n.workerPath?(r.log(`loading Web Worker ${n.workerPath} for "${t}"`),this.workerContext=function(e){const t=Km[e];if(t)return t.clientCount++,t;const r=new self.URL(e,self.location.href).href,i={worker:new self.Worker(r),scriptURL:r,clientCount:1};return Km[e]=i,i}(n.workerPath)):(r.log(`injecting Web Worker for "${t}"`),this.workerContext=function(){const e=Km[Ym];if(e)return e.clientCount++,e;const t=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),r=self.URL.createObjectURL(t),i={worker:new self.Worker(r),objectURL:r,clientCount:1};return Km[Ym]=i,i}());const{worker:e}=this.workerContext;e.addEventListener("message",this.onWorkerMessage),e.addEventListener("error",this.onWorkerError),e.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:a,id:t,config:cf(n)})}catch(i){r.warn(`Error setting up "${t}" Web Worker, fallback to inline`,i),this.terminateWorker(),this.error=null,this.transmuxer=new uv(this.observer,a,n,"",t,e.logger)}return}}this.transmuxer=new uv(this.observer,a,n,"",t,e.logger)}reset(){if(this.frag=null,this.part=null,this.workerContext){const e=this.instanceNo;this.instanceNo=gv++;const t=this.hls.config,r=jh(t.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:e,typeSupported:r,id:this.id,config:cf(t)})}}terminateWorker(){if(this.workerContext){const{worker:e}=this.workerContext;this.workerContext=null,e.removeEventListener("message",this.onWorkerMessage),e.removeEventListener("error",this.onWorkerError),function(e){const t=Km[e||Ym];if(t&&1===t.clientCount--){const{worker:r,objectURL:i}=t;delete Km[e||Ym],i&&self.URL.revokeObjectURL(i),r.terminate()}}(this.hls.config.workerPath)}}destroy(){if(this.workerContext)this.terminateWorker(),this.onWorkerMessage=this.onWorkerError=null;else{const e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}const e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.part=null,this.observer=null,this.hls=null}push(e,t,r,i,n,s,a,o,l,c){var d,u;l.transmuxing.start=self.performance.now();const{instanceNo:h,transmuxer:f}=this,p=s?s.start:n.start,m=n.decryptdata,g=this.frag,v=!(g&&n.cc===g.cc),y=!(g&&l.level===g.level),b=g?l.sn-g.sn:-1,E=this.part?l.part-this.part.index:-1,w=0===b&&l.id>1&&l.id===(null==g?void 0:g.stats.chunkCount),S=!y&&(1===b||0===b&&(1===E||w&&E<=0)),T=self.performance.now();(y||b||0===n.stats.parsing.start)&&(n.stats.parsing.start=T),!s||!E&&S||(s.stats.parsing.start=T);const x=!(g&&(null==(d=n.initSegment)?void 0:d.url)===(null==(u=g.initSegment)?void 0:u.url)),A=new mv(v,S,o,y,p,x);if(!S||v||x){this.hls.logger.log(`[transmuxer-interface]: Starting new transmux session for ${n.type} sn: ${l.sn}${l.part>-1?" part: "+l.part:""} ${this.id===yu?"level":"track"}: ${l.level} id: ${l.id}\n discontinuity: ${v}\n trackSwitch: ${y}\n contiguous: ${S}\n accurateTimeOffset: ${o}\n timeOffset: ${p}\n initSegmentChange: ${x}`);const e=new pv(r,i,t,a,c);this.configureTransmuxer(e)}if(this.frag=n,this.part=s,this.workerContext)this.workerContext.worker.postMessage({instanceNo:h,cmd:"demux",data:e,decryptdata:m,chunkMeta:l,state:A},e instanceof ArrayBuffer?[e]:[]);else if(f){const t=f.push(e,m,l,A);fv(t)?t.then(e=>{this.handleTransmuxComplete(e)}).catch(e=>{this.transmuxerError(e,l,"transmuxer-interface push error")}):this.handleTransmuxComplete(t)}}flush(e){e.transmuxing.start=self.performance.now();const{instanceNo:t,transmuxer:r}=this;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:t,cmd:"flush",chunkMeta:e});else if(r){const t=r.flush(e);fv(t)?t.then(t=>{this.handleFlushResult(t,e)}).catch(t=>{this.transmuxerError(t,e,"transmuxer-interface flush error")}):this.handleFlushResult(t,e)}}transmuxerError(e,t,r){this.hls&&(this.error=e,this.hls.trigger(fu.ERROR,{type:uu.MEDIA_ERROR,details:hu.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,part:this.part||void 0,fatal:!1,error:e,err:e,reason:r}))}handleFlushResult(e,t){e.forEach(e=>{this.handleTransmuxComplete(e)}),this.onFlush(t)}configureTransmuxer(e){const{instanceNo:t,transmuxer:r}=this;this.workerContext?this.workerContext.worker.postMessage({instanceNo:t,cmd:"configure",config:e}):r&&r.configure(e)}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}}class yv extends Iu{constructor(e,t){super(t,e.logger),this.hls=void 0,this.canLoad=!1,this.timer=-1,this.hls=e}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){-1!==this.timer&&(self.clearTimeout(this.timer),this.timer=-1)}startLoad(){this.canLoad=!0,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(e,t,r){const i=null==t?void 0:t.renditionReports;if(i){let n=-1;for(let r=0;r<i.length;r++){const s=i[r];let a;try{a=new self.URL(s.URI,t.url).href}catch(e){this.warn(`Could not construct new URL for Rendition Report: ${e}`),a=s.URI||""}if(a===e){n=r;break}a===e.substring(0,a.length)&&(n=r)}if(-1!==n){const e=i[n],s=parseInt(e["LAST-MSN"])||t.lastPartSn;let a=parseInt(e["LAST-PART"])||t.lastPartIndex;if(this.hls.config.lowLatencyMode){const e=Math.min(t.age-t.partTarget,t.targetduration);a>=0&&e>t.partTarget&&(a+=1)}const o=r&&nf(r);return new sf(s,a>=0?a:void 0,o)}}}loadPlaylist(e){this.clearTimer()}loadingPlaylist(e,t){this.clearTimer()}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}getUrlWithDirectives(e,t){if(t)try{return t.addDirectives(e)}catch(e){this.warn(`Could not construct new URL with HLS Delivery Directives: ${e}`)}return e}playlistLoaded(e,t,r){const{details:i,stats:n}=t,s=self.performance.now(),a=n.loading.first?Math.max(0,s-n.loading.first):0;i.advancedDateTime=Date.now()-a;const o=this.hls.config.timelineOffset;if(o!==i.appliedTimelineOffset){const e=Math.max(o||0,0);i.appliedTimelineOffset=e,i.fragments.forEach(t=>{t.setStart(t.playlistOffset+e)})}if(i.live||null!=r&&r.live){const o="levelInfo"in t?t.levelInfo:t.track;if(i.reloaded(r),r&&i.fragments.length>0){cm(r,i,this);const e=i.playlistParsingError;if(e){this.warn(e);const r=this.hls;if(!r.config.ignorePlaylistParsingErrors){var l;const{networkDetails:s}=t;return void r.trigger(fu.ERROR,{type:uu.NETWORK_ERROR,details:hu.LEVEL_PARSING_ERROR,fatal:!1,url:i.url,error:e,reason:e.message,level:t.level||void 0,parent:null==(l=i.fragments[0])?void 0:l.type,networkDetails:s,stats:n})}i.playlistParsingError=null}}-1===i.requestScheduled&&(i.requestScheduled=n.loading.start);const c=this.hls.mainForwardBufferInfo,d=c?c.end-c.len:0,u=fm(i,1e3*(i.edge-d));if(i.requestScheduled+u<s?i.requestScheduled=s:i.requestScheduled+=u,this.log(`live playlist ${e} ${i.advanced?"REFRESHED "+i.lastPartSn+"-"+i.lastPartIndex:i.updated?"UPDATED":"MISSED"}`),!this.canLoad||!i.live)return;let h,f,p;if(i.canBlockReload&&i.endSN&&i.advanced){const e=this.hls.config.lowLatencyMode,n=i.lastPartSn,a=i.endSN,l=i.lastPartIndex,c=n===a;-1!==l?c?(f=a+1,p=e?0:l):(f=n,p=e?l+1:i.maxPartIndex):f=a+1;const d=i.age,u=d+i.ageHeader;let m=Math.min(u-i.partTarget,1.5*i.targetduration);if(m>0){if(u>3*i.targetduration)this.log(`Playlist last advanced ${d.toFixed(2)}s ago. Omitting segment and part directives.`),f=void 0,p=void 0;else if(null!=r&&r.tuneInGoal&&u-i.partTarget>r.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${r.tuneInGoal} to: ${m} with playlist age: ${i.age}`),m=0;else{const e=Math.floor(m/i.targetduration);if(f+=e,void 0!==p){p+=Math.round(m%i.targetduration/i.partTarget)}this.log(`CDN Tune-in age: ${i.ageHeader}s last advanced ${d.toFixed(2)}s goal: ${m} skip sn ${e} to part ${p}`)}i.tuneInGoal=m}if(h=this.getDeliveryDirectives(i,t.deliveryDirectives,f,p),e||!c)return i.requestScheduled=s,void this.loadingPlaylist(o,h)}else(i.canBlockReload||i.canSkipUntil)&&(h=this.getDeliveryDirectives(i,t.deliveryDirectives,f,p));h&&void 0!==f&&i.canBlockReload&&(i.requestScheduled=n.loading.first+Math.max(u-2*a,u/2)),this.scheduleLoading(o,h,i)}else this.clearTimer()}scheduleLoading(e,t,r){const i=r||e.details;if(!i)return void this.loadingPlaylist(e,t);const n=self.performance.now(),s=i.requestScheduled;if(n>=s)return void this.loadingPlaylist(e,t);const a=s-n;this.log(`reload live playlist ${e.name||e.bitrate+"bps"} in ${Math.round(a)} ms`),this.clearTimer(),this.timer=self.setTimeout(()=>this.loadingPlaylist(e,t),a)}getDeliveryDirectives(e,t,r,i){let n=nf(e);return null!=t&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,i=t.part,n=ef),new sf(r,i,n)}checkRetry(e){const t=e.details,r=Tf(e),i=e.errorAction,{action:n,retryCount:s=0,retryConfig:a}=i||{},o=!!i&&!!a&&(n===Of||!i.resolved&&n===Df);if(o){var l;if(s>=a.maxNumRetry)return!1;if(r&&null!=(l=e.context)&&l.deliveryDirectives)this.warn(`Retrying playlist loading ${s+1}/${a.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{const e=If(a,s);this.clearTimer(),this.timer=self.setTimeout(()=>this.loadPlaylist(),e),this.warn(`Retrying playlist loading ${s+1}/${a.maxNumRetry} after "${t}" in ${e}ms`)}e.levelRetry=!0,i.resolved=!0}return o}}function bv(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!Ev(e[r].attrs,t[r].attrs))return!1;return!0}function Ev(e,t,r){const i=e["STABLE-RENDITION-ID"];return i&&!r?i===t["STABLE-RENDITION-ID"]:!(r||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some(r=>e[r]!==t[r])}function wv(e,t){return t.label.toLowerCase()===e.name.toLowerCase()&&(!t.language||t.language.toLowerCase()===(e.lang||"").toLowerCase())}class Sv{constructor(e){this.tracks=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.tracks=e}destroy(){this.tracks=this.queues=null}append(e,t,r){if(null===this.queues||null===this.tracks)return;const i=this.queues[t];i.push(e),1!==i.length||r||this.executeNext(t)}appendBlocker(e){return new Promise(t=>{const r={label:"async-blocker",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.append(r,e)})}prependBlocker(e){return new Promise(t=>{if(this.queues){const r={label:"async-blocker-prepend",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.queues[e].unshift(r)}})}removeBlockers(){null!==this.queues&&[this.queues.video,this.queues.audio,this.queues.audiovideo].forEach(e=>{var t;const r=null==(t=e[0])?void 0:t.label;"async-blocker"!==r&&"async-blocker-prepend"!==r||(e[0].execute(),e.splice(0,1))})}unblockAudio(e){if(null===this.queues)return;this.queues.audio[0]===e&&this.shiftAndExecuteNext("audio")}executeNext(e){if(null===this.queues||null===this.tracks)return;const t=this.queues[e];if(t.length){const i=t[0];try{i.execute()}catch(t){var r;if(i.onError(t),null===this.queues||null===this.tracks)return;const n=null==(r=this.tracks[e])?void 0:r.buffer;null!=n&&n.updating||this.shiftAndExecuteNext(e)}}}shiftAndExecuteNext(e){null!==this.queues&&(this.queues[e].shift(),this.executeNext(e))}current(e){var t;return(null==(t=this.queues)?void 0:t[e][0])||null}toString(){const{queues:e,tracks:t}=this;return null===e||null===t?"<destroyed>":`\n${this.list("video")}\n${this.list("audio")}\n${this.list("audiovideo")}}`}list(e){var t,r;return null!=(t=this.queues)&&t[e]||null!=(r=this.tracks)&&r[e]?`${e}: (${this.listSbInfo(e)}) ${this.listOps(e)}`:""}listSbInfo(e){var t;const r=null==(t=this.tracks)?void 0:t[e],i=null==r?void 0:r.buffer;return i?`SourceBuffer${i.updating?" updating":""}${r.ended?" ended":""}${r.ending?" ending":""}`:"none"}listOps(e){var t;return(null==(t=this.queues)?void 0:t[e].map(e=>e.label).join(", "))||""}}const Tv=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,xv="HlsJsTrackRemovedError";class Av extends Error{constructor(e){super(e),this.name=xv}}function kv(e){const t=e.querySelectorAll("source");[].slice.call(t).forEach(t=>{e.removeChild(t)})}function Iv(e){return"audio"===e?1:0}class Lv{constructor(e){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(e){this.streamController=e}destroy(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){const{hls:e}=this;e.on(fu.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(fu.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(fu.MANIFEST_PARSED,this.onManifestParsed,this),e.on(fu.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(fu.BUFFER_CODECS,this.onBufferCodecs,this),e.on(fu.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:e}=this;e.off(fu.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(fu.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(fu.MANIFEST_PARSED,this.onManifestParsed,this),e.off(fu.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(fu.BUFFER_CODECS,this.onBufferCodecs,this),e.off(fu.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(e,t){const r=this.hls.levels[t.droppedLevel];this.isLevelAllowed(r)&&this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})}onMediaAttaching(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()}onManifestParsed(e,t){const r=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,r.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onLevelsUpdated(e,t){this.timer&&lu(this.autoLevelCapping)&&this.detectPlayerSize()}onBufferCodecs(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping(),this.media=null}detectPlayerSize(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0)return void(this.clientRect=null);const e=this.hls.levels;if(e.length){const t=this.hls,r=this.getMaxLevel(e.length-1);r!==this.autoLevelCapping&&t.logger.log(`Setting autoLevelCapping to ${r}: ${e[r].height}p@${e[r].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),t.autoLevelCapping=r,t.autoLevelEnabled&&t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}}getMaxLevel(e){const t=this.hls.levels;if(!t.length)return-1;const r=t.filter((t,r)=>this.isLevelAllowed(t)&&r<=e);return this.clientRect=null,Lv.getMaxLevelByMediaSize(r,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}stopCapping(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}getDimensions(){if(this.clientRect)return this.clientRect;const e=this.media,t={width:0,height:0};if(e){const r=e.getBoundingClientRect();t.width=r.width,t.height=r.height,t.width||t.height||(t.width=r.right-r.left||e.width||0,t.height=r.bottom-r.top||e.height||0)}return this.clientRect=t,t}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch(e){}return Math.min(e,this.hls.config.maxDevicePixelRatio)}isLevelAllowed(e){return!this.restrictedLevels.some(t=>e.bitrate===t.bitrate&&e.width===t.width&&e.height===t.height)}static getMaxLevelByMediaSize(e,t,r){if(null==e||!e.length)return-1;const i=(e,t)=>!t||(e.width!==t.width||e.height!==t.height);let n=e.length-1;const s=Math.max(t,r);for(let t=0;t<e.length;t+=1){const r=e[t];if((r.width>=s||r.height>=s)&&i(r,e[t+1])){n=t;break}}return n}}const Rv={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"},Pv={HLS:"h"};class Cv{constructor(e,t){Array.isArray(e)&&(e=e.map(e=>e instanceof Cv?e:new Cv(e))),this.value=e,this.params=t}}function Dv(e,t,r,i){return new Error(`failed to ${e} "${n=t,Array.isArray(n)?JSON.stringify(n):n instanceof Map?"Map{}":n instanceof Set?"Set{}":"object"==typeof n?JSON.stringify(n):String(n)}" as ${r}`,{cause:i});var n}function _v(e,t,r){return Dv("serialize",e,t,r)}class Ov{constructor(e){this.description=e}}const Mv="Bare Item";function Nv(e){if(!1===ArrayBuffer.isView(e))throw _v(e,"Byte Sequence");return`:${t=e,btoa(String.fromCharCode(...t))}:`;var t}function Fv(e){if(function(e){return e<-999999999999999||999999999999999<e}(e))throw _v(e,"Integer");return e.toString()}function $v(e,t){if(e<0)return-$v(-e,t);const r=Math.pow(10,t);if(Math.abs(e*r%1-.5)<Number.EPSILON){const t=Math.floor(e*r);return(t%2==0?t:t+1)/r}return Math.round(e*r)/r}function Bv(e){const t=$v(e,3);if(Math.floor(Math.abs(t)).toString().length>12)throw _v(e,"Decimal");const r=t.toString();return r.includes(".")?r:`${r}.0`}const Uv=/[\x00-\x1f\x7f]+/;function zv(e){const t=(r=e).description||r.toString().slice(7,-1);var r;if(!1===/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(t))throw _v(t,"Token");return t}function Gv(e){switch(typeof e){case"number":if(!lu(e))throw _v(e,Mv);return Number.isInteger(e)?Fv(e):Bv(e);case"string":return function(e){if(Uv.test(e))throw _v(e,"String");return`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}(e);case"symbol":return zv(e);case"boolean":return function(e){if("boolean"!=typeof e)throw _v(e,"Boolean");return e?"?1":"?0"}(e);case"object":if(e instanceof Date)return function(e){return`@${Fv(e.getTime()/1e3)}`}(e);if(e instanceof Uint8Array)return Nv(e);if(e instanceof Ov)return zv(e);default:throw _v(e,Mv)}}function jv(e){if(!1===/^[a-z*][a-z0-9\-_.*]*$/.test(e))throw _v(e,"Key");return e}function Hv(e){return null==e?"":Object.entries(e).map(([e,t])=>!0===t?`;${jv(e)}`:`;${jv(e)}=${Gv(t)}`).join("")}function Vv(e){return e instanceof Cv?`${Gv(e.value)}${Hv(e.params)}`:Gv(e)}function Wv(e,t={whitespace:!0}){if("object"!=typeof e||null==e)throw _v(e,"Dict");const r=e instanceof Map?e.entries():Object.entries(e),i=(null==t?void 0:t.whitespace)?" ":"";return Array.from(r).map(([e,t])=>{t instanceof Cv==!1&&(t=new Cv(t));let r=jv(e);var i;return!0===t.value?r+=Hv(t.params):(r+="=",Array.isArray(t.value)?r+=`(${(i=t).value.map(Vv).join(" ")})${Hv(i.params)}`:r+=Vv(t)),r}).join(`,${i}`)}function Yv(e,t){return Wv(e,t)}const Kv="CMCD-Object",qv="CMCD-Request",Xv="CMCD-Session",Qv="CMCD-Status",Zv={br:Kv,ab:Kv,d:Kv,ot:Kv,tb:Kv,tpb:Kv,lb:Kv,tab:Kv,lab:Kv,url:Kv,pb:qv,bl:qv,tbl:qv,dl:qv,ltc:qv,mtp:qv,nor:qv,nrr:qv,rc:qv,sn:qv,sta:qv,su:qv,ttfb:qv,ttfbb:qv,ttlb:qv,cmsdd:qv,cmsds:qv,smrt:qv,df:qv,cs:qv,ts:qv,cid:Xv,pr:Xv,sf:Xv,sid:Xv,st:Xv,v:Xv,msd:Xv,bs:Qv,bsd:Qv,cdn:Qv,rtp:Qv,bg:Qv,pt:Qv,ec:Qv,e:Qv},Jv=qv;function ey(e,t){const r={};if(!e)return r;const i=Object.keys(e),n=t?(s=t,Object.keys(s).reduce((e,t)=>{var r;return null===(r=s[t])||void 0===r||r.forEach(r=>e[r]=t),e},{})):{};var s;return i.reduce((t,r)=>{var i;const s=Zv[r]||n[r]||Jv;return(null!==(i=t[s])&&void 0!==i?i:t[s]={})[r]=e[r],t},r)}const ty="event";const ry=e=>Math.round(e),iy=(e,t)=>Array.isArray(e)?e.map(e=>iy(e,t)):e instanceof Cv&&"string"==typeof e.value?new Cv(iy(e.value,t),e.params):(t.baseUrl&&(e=function(e,t){const r=new URL(e),i=new URL(t);if(r.origin!==i.origin)return e;const n=r.pathname.split("/").slice(1),s=i.pathname.split("/").slice(1,-1);for(;n[0]===s[0];)n.shift(),s.shift();for(;s.length;)s.shift(),n.unshift("..");return n.join("/")+r.search+r.hash}(e,t.baseUrl)),1===t.version?encodeURIComponent(e):e),ny=e=>100*ry(e/100),sy={br:ry,d:ry,bl:ny,dl:ny,mtp:ny,nor:(e,t)=>{let r=e;return t.version>=2&&(e instanceof Cv&&"string"==typeof e.value?r=new Cv([e]):"string"==typeof e&&(r=[e])),iy(r,t)},rtp:ny,tb:ry},ay="request",oy="response",ly=["ab","bg","bl","br","bs","bsd","cdn","cid","cs","df","ec","lab","lb","ltc","msd","mtp","pb","pr","pt","sf","sid","sn","st","sta","tab","tb","tbl","tpb","ts","v"],cy=["e"],dy=/^[a-zA-Z0-9-.]+-[a-zA-Z0-9-.]+$/;function uy(e){return dy.test(e)}const hy=["d","dl","nor","ot","rtp","su"];const fy=["cmsdd","cmsds","rc","smrt","ttfb","ttfbb","ttlb","url"];const py=["bl","br","bs","cid","d","dl","mtp","nor","nrr","ot","pr","rtp","sf","sid","st","su","tb","v"];function my(e){return py.includes(e)||uy(e)}const gy={[oy]:function(e){return ly.includes(e)||hy.includes(e)||fy.includes(e)||uy(e)},[ty]:function(e){return ly.includes(e)||cy.includes(e)||uy(e)},[ay]:function(e){return ly.includes(e)||hy.includes(e)||uy(e)}};function vy(e,t={}){const r={};if(null==e||"object"!=typeof e)return r;const i=t.version||e.v||1,n=t.reportingMode||ay,s=1===i?my:gy[n];let a=Object.keys(e).filter(s);const o=t.filter;"function"==typeof o&&(a=a.filter(o));const l=n===oy||n===ty;l&&!a.includes("ts")&&a.push("ts"),i>1&&!a.includes("v")&&a.push("v");const c=xu({},sy,t.formatters),d={version:i,reportingMode:n,baseUrl:t.baseUrl};return a.sort().forEach(t=>{let n=e[t];const s=c[t];if("function"==typeof s&&(n=s(n,d)),"v"===t){if(1===i)return;n=i}"pr"==t&&1===n||(l&&"ts"===t&&!lu(n)&&(n=Date.now()),function(e){return"number"==typeof e?lu(e):null!=e&&""!==e&&!1!==e}(n)&&(function(e){return["ot","sf","st","e","sta"].includes(e)}(t)&&"string"==typeof n&&(n=new Ov(n)),r[t]=n))}),r}function yy(e,t,r){return xu(e,function(e,t={}){const r={};if(!e)return r;const i=ey(vy(e,t),null==t?void 0:t.customHeaderMap);return Object.entries(i).reduce((e,[t,r])=>{const i=Yv(r,{whitespace:!1});return i&&(e[t]=i),e},r)}(t,r))}function by(e,t={}){if(!e)return"";const r=function(e,t={}){return e?Yv(vy(e,t),{whitespace:!1}):""}(e,t);return encodeURIComponent(r)}const Ey=/CMCD=[^&#]+/;function wy(e,t,r){const i=function(e,t={}){return e?`CMCD=${by(e,t)}`:""}(t,r);if(!i)return e;if(Ey.test(e))return e.replace(Ey,i);const n=e.includes("?")?"&":"?";return`${e}${n}${i}`}function Sy(e,t,r,i){e&&Object.keys(t).forEach(n=>{const s=e.filter(e=>e.groupId===n).map(e=>{const s=xu({},e);return s.details=void 0,s.attrs=new gp(s.attrs),s.url=s.attrs.URI=Ty(e.url,e.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",r),s.groupId=s.attrs["GROUP-ID"]=t[n],s.attrs["PATHWAY-ID"]=i,s});e.push(...s)})}function Ty(e,t,r,i){const{HOST:n,PARAMS:s,[r]:a}=i;let o;t&&(o=null==a?void 0:a[t],o&&(e=o));const l=new self.URL(e);return n&&!o&&(l.host=n),s&&Object.keys(s).sort().forEach(e=>{e&&l.searchParams.set(e,s[e])}),l.href}class xy extends Iu{constructor(e){super("eme",e.logger),this.hls=void 0,this.config=void 0,this.media=null,this.mediaResolved=void 0,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.mediaKeys=null,this.setMediaKeysQueue=xy.CDMCleanupPromise?[xy.CDMCleanupPromise]:[],this.bannedKeyIds={},this.onMediaEncrypted=e=>{const{initDataType:t,initData:r}=e,i=`"${e.type}" event: init data type: "${t}"`;if(this.debug(i),null!==r){if(!this.keyFormatPromise){let e=Object.keys(this.keySystemAccessPromises);e.length||(e=Fp(this.config));const t=e.map(Np).filter(e=>!!e);this.keyFormatPromise=this.getKeyFormatPromise(t)}this.keyFormatPromise.then(n=>{const s=Mp(n);if("sinf"!==t||s!==Pp.FAIRPLAY)return void this.log(`Ignoring "${e.type}" event with init data type: "${t}" for selected key-system ${s}`);let a;try{const e=ah(new Uint8Array(r)),t=Eh(Ap(JSON.parse(e).sinf));if(!t)throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");a=new Uint8Array(t.subarray(8,24))}catch(e){return void this.warn(`${i} Failed to parse sinf: ${e}`)}const o=Fu(a),{keyIdToKeySessionPromise:l,mediaKeySessions:c}=this;let d=l[o];for(let e=0;e<c.length;e++){const i=c[e],n=i.decryptdata;if(!n.keyId)continue;const s=Fu(n.keyId);if(wp(a,n.keyId)||-1!==n.uri.replace(/-/g,"").indexOf(o)){if(d=l[s],!d)continue;if(n.pssh)break;delete l[s],n.pssh=new Uint8Array(r),n.keyId=a,d=l[o]=d.then(()=>this.generateRequestWithPreferredKeySession(i,t,r,"encrypted-event-key-match")),d.catch(e=>this.handleError(e));break}}d||this.handleError(new Error(`Key ID ${o} not encountered in playlist. Key-system sessions ${c.length}.`))}).catch(e=>this.handleError(e))}},this.onWaitingForKey=e=>{this.log(`"${e.type}" event`)},this.hls=e,this.config=e.config,this.registerListeners()}destroy(){this.onDestroying(),this.onMediaDetached();const e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.config=this.keyIdToKeySessionPromise=null,this.onMediaEncrypted=this.onWaitingForKey=null}registerListeners(){this.hls.on(fu.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(fu.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(fu.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(fu.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.on(fu.DESTROYING,this.onDestroying,this)}unregisterListeners(){this.hls.off(fu.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(fu.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(fu.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(fu.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.off(fu.DESTROYING,this.onDestroying,this)}getLicenseServerUrl(e){const{drmSystems:t,widevineLicenseUrl:r}=this.config,i=null==t?void 0:t[e];return i?i.licenseUrl:e===Pp.WIDEVINE&&r?r:void 0}getLicenseServerUrlOrThrow(e){const t=this.getLicenseServerUrl(e);if(void 0===t)throw new Error(`no license server URL configured for key-system "${e}"`);return t}getServerCertificateUrl(e){const{drmSystems:t}=this.config,r=null==t?void 0:t[e];if(r)return r.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}attemptKeySystemAccess(e){const t=this.hls.levels,r=(e,t,r)=>!!e&&r.indexOf(e)===t,i=t.map(e=>e.audioCodec).filter(r),n=t.map(e=>e.videoCodec).filter(r);return i.length+n.length===0&&n.push("avc1.42e01e"),new Promise((t,r)=>{const s=e=>{const a=e.shift();this.getMediaKeysPromise(a,i,n).then(e=>t({keySystem:a,mediaKeys:e})).catch(t=>{e.length?s(e):r(t instanceof Iy?t:new Iy({type:uu.KEY_SYSTEM_ERROR,details:hu.KEY_SYSTEM_NO_ACCESS,error:t,fatal:!0},t.message))})};s(e)})}requestMediaKeySystemAccess(e,t){const{requestMediaKeySystemAccessFunc:r}=this.config;if("function"!=typeof r){let e=`Configured requestMediaKeySystemAccess is not a function ${r}`;return null===$p&&"http:"===self.location.protocol&&(e=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(e))}return r(e,t)}getMediaKeysPromise(e,t,r){var i;const n=function(e,t,r,i){let n;switch(e){case Pp.FAIRPLAY:n=["cenc","sinf"];break;case Pp.WIDEVINE:case Pp.PLAYREADY:n=["cenc"];break;case Pp.CLEARKEY:n=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${e}`)}return function(e,t,r,i){return[{initDataTypes:e,persistentState:i.persistentState||"optional",distinctiveIdentifier:i.distinctiveIdentifier||"optional",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:t.map(e=>({contentType:`audio/mp4; codecs=${e}`,robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null})),videoCapabilities:r.map(e=>({contentType:`video/mp4; codecs=${e}`,robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}))}]}(n,t,r,i)}(e,t,r,this.config.drmSystemOptions||{});let s=this.keySystemAccessPromises[e],a=null==(i=s)?void 0:i.keySystemAccess;if(!a){this.log(`Requesting encrypted media "${e}" key-system access with config: ${cf(n)}`),a=this.requestMediaKeySystemAccess(e,n);const t=s=this.keySystemAccessPromises[e]={keySystemAccess:a};return a.catch(t=>{this.log(`Failed to obtain access to key-system "${e}": ${t}`)}),a.then(r=>{this.log(`Access for key-system "${r.keySystem}" obtained`);const i=this.fetchServerCertificate(e);this.log(`Create media-keys for "${e}"`);const n=t.mediaKeys=r.createMediaKeys().then(r=>(this.log(`Media-keys created for "${e}"`),t.hasMediaKeys=!0,i.then(t=>t?this.setMediaKeysServerCertificate(r,e,t):r)));return n.catch(t=>{this.error(`Failed to create media-keys for "${e}"}: ${t}`)}),n})}return a.then(()=>s.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:r}){this.log(`Creating key-system session "${t}" keyId: ${Fu(e.keyId||[])} keyUri: ${e.uri}`);const i=r.createSession(),n={decryptdata:e,keySystem:t,mediaKeys:r,mediaKeysSession:i,keyStatus:"status-pending"};return this.mediaKeySessions.push(n),n}renewKeySession(e){const t=e.decryptdata;if(t.pssh){const r=this.createMediaKeySessionContext(e),i=Ay(t),n="cenc";this.keyIdToKeySessionPromise[i]=this.generateRequestWithPreferredKeySession(r,n,t.pssh.buffer,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}updateKeySession(e,t){const r=e.mediaKeysSession;return this.log(`Updating key-session "${r.sessionId}" for keyId ${Fu(e.decryptdata.keyId||[])}\n } (data length: ${t.byteLength})`),r.update(t)}getSelectedKeySystemFormats(){return Object.keys(this.keySystemAccessPromises).map(e=>({keySystem:e,hasMediaKeys:this.keySystemAccessPromises[e].hasMediaKeys})).filter(({hasMediaKeys:e})=>!!e).map(({keySystem:e})=>Np(e)).filter(e=>!!e)}getKeySystemAccess(e){return this.getKeySystemSelectionPromise(e).then(({keySystem:e,mediaKeys:t})=>this.attemptSetMediaKeys(e,t))}selectKeySystem(e){return new Promise((t,r)=>{this.getKeySystemSelectionPromise(e).then(({keySystem:e})=>{const i=Np(e);i?t(i):r(new Error(`Unable to find format for key-system "${e}"`))}).catch(r)})}selectKeySystemFormat(e){const t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}getKeyFormatPromise(e){const t=Fp(this.config),r=e.map(Mp).filter(e=>!!e&&-1!==t.indexOf(e));return this.selectKeySystem(r)}getKeyStatus(e){const{mediaKeySessions:t}=this;for(let r=0;r<t.length;r++){const i=ky(e,t[r]);if(i)return i}}loadKey(e){const t=e.keyInfo.decryptdata,r=Ay(t),i=this.bannedKeyIds[r];if(i||"internal-error"===this.getKeyStatus(t)){const r=Ly(i||"internal-error",t);return this.handleError(r,e.frag),Promise.reject(r)}const n=`(keyId: ${r} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${n}`);const s=this.keyIdToKeySessionPromise[r];if(!s){const i=this.getKeySystemForKeyPromise(t).then(({keySystem:r,mediaKeys:i})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${n}`),this.attemptSetMediaKeys(r,i).then(()=>(this.throwIfDestroyed(),this.createMediaKeySessionContext({keySystem:r,mediaKeys:i,decryptdata:t}))))).then(e=>{const r=t.pssh?t.pssh.buffer:null;return this.generateRequestWithPreferredKeySession(e,"cenc",r,"playlist-key")});return i.catch(t=>this.handleError(t,e.frag)),this.keyIdToKeySessionPromise[r]=i,i}return s.catch(r=>{if(r instanceof Iy){const i=ku({},r.data);"internal-error"===this.getKeyStatus(t)&&(i.decryptdata=t);const n=new Iy(i,r.message);this.handleError(n,e.frag)}}),s}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e,t){if(this.hls)if(e instanceof Iy){t&&(e.data.frag=t);const r=e.data.decryptdata;this.error(`${e.message}${r?` (${Fu(r.keyId||[])})`:""}`),this.hls.trigger(fu.ERROR,e.data)}else this.error(e.message),this.hls.trigger(fu.ERROR,{type:uu.KEY_SYSTEM_ERROR,details:hu.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0})}getKeySystemForKeyPromise(e){const t=Ay(e),r=this.keyIdToKeySessionPromise[t];if(!r){const t=Mp(e.keyFormat),r=t?[t]:Fp(this.config);return this.attemptKeySystemAccess(r)}return r}getKeySystemSelectionPromise(e){if(e.length||(e=Fp(this.config)),0===e.length)throw new Iy({type:uu.KEY_SYSTEM_ERROR,details:hu.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${cf({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}attemptSetMediaKeys(e,t){if(this.mediaResolved=void 0,this.mediaKeys===t)return Promise.resolve();const r=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);const i=Promise.all(r).then(()=>this.media?this.media.setMediaKeys(t):new Promise((e,r)=>{this.mediaResolved=()=>{if(this.mediaResolved=void 0,!this.media)return r(new Error("Attempted to set mediaKeys without media element attached"));this.mediaKeys=t,this.media.setMediaKeys(t).then(e).catch(r)}}));return this.mediaKeys=t,this.setMediaKeysQueue.push(i),i.then(()=>{this.log(`Media-keys set for "${e}"`),r.push(i),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(e=>-1===r.indexOf(e))})}generateRequestWithPreferredKeySession(e,t,r,i){var n;const s=null==(n=this.config.drmSystems)||null==(n=n[e.keySystem])?void 0:n.generateRequest;if(s)try{const i=s.call(this.hls,t,r,e);if(!i)throw new Error("Invalid response from configured generateRequest filter");t=i.initDataType,r=i.initData?i.initData:null,e.decryptdata.pssh=r?new Uint8Array(r):null}catch(e){if(this.warn(e.message),this.hls&&this.hls.config.debug)throw e}if(null===r)return this.log(`Skipping key-session request for "${i}" (no initData)`),Promise.resolve(e);const a=Ay(e.decryptdata),o=e.decryptdata.uri;this.log(`Generating key-session request for "${i}" keyId: ${a} URI: ${o} (init data type: ${t} length: ${r.byteLength})`);const l=new Wm,c=e._onmessage=t=>{const r=e.mediaKeysSession;if(!r)return void l.emit("error",new Error("invalid state"));const{messageType:i,message:n}=t;this.log(`"${i}" message event for session "${r.sessionId}" message size: ${n.byteLength}`),"license-request"===i||"license-renewal"===i?this.renewLicense(e,n).catch(e=>{l.eventNames().length?l.emit("error",e):this.handleError(e)}):"license-release"===i?e.keySystem===Pp.FAIRPLAY&&this.updateKeySession(e,kp("acknowledged")).then(()=>this.removeSession(e)).catch(e=>this.handleError(e)):this.warn(`unhandled media key message type "${i}"`)},d=(e,t)=>{let r;t.keyStatus=e,e.startsWith("usable")?l.emit("resolved"):"internal-error"===e||"output-restricted"===e||"output-downscaled"===e?r=Ly(e,t.decryptdata):"expired"===e?r=new Error(`key expired (keyId: ${a})`):"released"===e?r=new Error("key released"):"status-pending"===e||this.warn(`unhandled key status change "${e}" (keyId: ${a})`),r&&(l.eventNames().length?l.emit("error",r):this.handleError(r))},u=e._onkeystatuseschange=t=>{if(!e.mediaKeysSession)return void l.emit("error",new Error("invalid state"));const r=this.getKeyStatuses(e);if(!Object.keys(r).some(e=>"status-pending"!==r[e]))return;if("expired"===r[a])return this.log(`Expired key ${cf(r)} in key-session "${e.mediaKeysSession.sessionId}"`),void this.renewKeySession(e);let i=r[a];if(i)d(i,e);else{var n;const t=1e3;e.keyStatusTimeouts||(e.keyStatusTimeouts={}),(n=e.keyStatusTimeouts)[a]||(n[a]=self.setTimeout(()=>{if(!e.mediaKeysSession||!this.mediaKeys)return;const r=this.getKeyStatus(e.decryptdata);if(r&&"status-pending"!==r)return this.log(`No status for keyId ${a} in key-session "${e.mediaKeysSession.sessionId}". Using session key-status ${r} from other session.`),d(r,e);this.log(`key status for ${a} in key-session "${e.mediaKeysSession.sessionId}" timed out after ${t}ms`),i="internal-error",d(i,e)},t)),this.log(`No status for keyId ${a} (${cf(r)}).`)}};Am(e.mediaKeysSession,"message",c),Am(e.mediaKeysSession,"keystatuseschange",u);const h=new Promise((e,t)=>{l.on("error",t),l.on("resolved",e)});return e.mediaKeysSession.generateRequest(t,r).then(()=>{this.log(`Request generated for key-session "${e.mediaKeysSession.sessionId}" keyId: ${a} URI: ${o}`)}).catch(t=>{throw new Iy({type:uu.KEY_SYSTEM_ERROR,details:hu.KEY_SYSTEM_NO_SESSION,error:t,decryptdata:e.decryptdata,fatal:!1},`Error generating key-session request: ${t}`)}).then(()=>h).catch(t=>(l.removeAllListeners(),this.removeSession(e).then(()=>{throw t}))).then(()=>(l.removeAllListeners(),e))}getKeyStatuses(e){const t={};return e.mediaKeysSession.keyStatuses.forEach((r,i)=>{if("string"==typeof i&&"object"==typeof r){const e=i;i=r,r=e}const n="buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i);if(e.keySystem===Pp.PLAYREADY&&16===n.length){const e=Fu(n);t[e]=r,Ip(n)}const s=Fu(n);"internal-error"===r&&(this.bannedKeyIds[s]=r),this.log(`key status change "${r}" for keyStatuses keyId: ${s} key-session "${e.mediaKeysSession.sessionId}"`),t[s]=r}),t}fetchServerCertificate(e){const t=this.config,r=new(0,t.loader)(t),i=this.getServerCertificateUrl(e);return i?(this.log(`Fetching server certificate for "${e}"`),new Promise((n,s)=>{const a={responseType:"arraybuffer",url:i},o=t.certLoadPolicy.default,l={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(e,t,r,i)=>{n(e.data)},onError:(t,r,n,o)=>{s(new Iy({type:uu.KEY_SYSTEM_ERROR,details:hu.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:n,response:ku({url:a.url,data:void 0},t)},`"${e}" certificate request failed (${i}). Status: ${t.code} (${t.text})`))},onTimeout:(t,r,n)=>{s(new Iy({type:uu.KEY_SYSTEM_ERROR,details:hu.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:n,response:{url:a.url,data:void 0}},`"${e}" certificate request timed out (${i})`))},onAbort:(e,t,r)=>{s(new Error("aborted"))}};r.load(a,l,c)})):Promise.resolve()}setMediaKeysServerCertificate(e,t,r){return new Promise((i,n)=>{e.setServerCertificate(r).then(n=>{this.log(`setServerCertificate ${n?"success":"not supported by CDM"} (${r.byteLength}) on "${t}"`),i(e)}).catch(e=>{n(new Iy({type:uu.KEY_SYSTEM_ERROR,details:hu.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:e,fatal:!0},e.message))})})}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then(t=>this.updateKeySession(e,new Uint8Array(t)).catch(t=>{throw new Iy({type:uu.KEY_SYSTEM_ERROR,details:hu.KEY_SYSTEM_SESSION_UPDATE_FAILED,decryptdata:e.decryptdata,error:t,fatal:!1},t.message)}))}unpackPlayReadyKeyMessage(e,t){const r=String.fromCharCode.apply(null,new Uint16Array(t.buffer));if(!r.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;const i=(new DOMParser).parseFromString(r,"application/xml"),n=i.querySelectorAll("HttpHeader");if(n.length>0){let t;for(let r=0,i=n.length;r<i;r++){var s,a;t=n[r];const i=null==(s=t.querySelector("name"))?void 0:s.textContent,o=null==(a=t.querySelector("value"))?void 0:a.textContent;i&&o&&e.setRequestHeader(i,o)}}const o=i.querySelector("Challenge"),l=null==o?void 0:o.textContent;if(!l)throw new Error("Cannot find <Challenge> in key message");return kp(atob(l))}setupLicenseXHR(e,t,r,i){const n=this.config.licenseXhrSetup;return n?Promise.resolve().then(()=>{if(!r.decryptdata)throw new Error("Key removed");return n.call(this.hls,e,t,r,i)}).catch(s=>{if(!r.decryptdata)throw s;return e.open("POST",t,!0),n.call(this.hls,e,t,r,i)}).then(r=>{e.readyState||e.open("POST",t,!0);return{xhr:e,licenseChallenge:r||i}}):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:i}))}requestLicense(e,t){const r=this.config.keyLoadPolicy.default;return new Promise((i,n)=>{const s=this.getLicenseServerUrlOrThrow(e.keySystem);this.log(`Sending license request to URL: ${s}`);const a=new XMLHttpRequest;a.responseType="arraybuffer",a.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return n(new Error("invalid state"));if(4===a.readyState)if(200===a.status){this._requestLicenseFailureCount=0;let t=a.response;this.log(`License received ${t instanceof ArrayBuffer?t.byteLength:t}`);const r=this.config.licenseResponseCallback;if(r)try{t=r.call(this.hls,a,s,e)}catch(e){this.error(e)}i(t)}else{const o=r.errorRetry,l=o?o.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>l||a.status>=400&&a.status<500)n(new Iy({type:uu.KEY_SYSTEM_ERROR,details:hu.KEY_SYSTEM_LICENSE_REQUEST_FAILED,decryptdata:e.decryptdata,fatal:!0,networkDetails:a,response:{url:s,data:void 0,code:a.status,text:a.statusText}},`License Request XHR failed (${s}). Status: ${a.status} (${a.statusText})`));else{const r=l-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${r} attempts left`),this.requestLicense(e,t).then(i,n)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=a,this.setupLicenseXHR(a,s,e,t).then(({xhr:t,licenseChallenge:r})=>{e.keySystem==Pp.PLAYREADY&&(r=this.unpackPlayReadyKeyMessage(t,r)),t.send(r)}).catch(n)})}onDestroying(){this.unregisterListeners(),this._clear()}onMediaAttached(e,t){if(!this.config.emeEnabled)return;const r=t.media;this.media=r,Am(r,"encrypted",this.onMediaEncrypted),Am(r,"waitingforkey",this.onWaitingForKey);const i=this.mediaResolved;i?i():this.mediaKeys=r.mediaKeys}onMediaDetached(){const e=this.media;e&&(km(e,"encrypted",this.onMediaEncrypted),km(e,"waitingforkey",this.onWaitingForKey),this.media=null,this.mediaKeys=null)}_clear(){var e;this._requestLicenseFailureCount=0,this.keyIdToKeySessionPromise={},this.bannedKeyIds={};const t=this.mediaResolved;if(t&&t(),!this.mediaKeys&&!this.mediaKeySessions.length)return;const r=this.media,i=this.mediaKeySessions.slice();this.mediaKeySessions=[],this.mediaKeys=null,Gp.clearKeyUriToKeyIdMap();const n=i.length;xy.CDMCleanupPromise=Promise.all(i.map(e=>this.removeSession(e)).concat((null==r||null==(e=r.setMediaKeys(null))?void 0:e.catch(e=>{this.log(`Could not clear media keys: ${e}`),this.hls&&this.hls.trigger(fu.ERROR,{type:uu.OTHER_ERROR,details:hu.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR,fatal:!1,error:new Error(`Could not clear media keys: ${e}`)})}))||Promise.resolve())).catch(e=>{this.log(`Could not close sessions and clear media keys: ${e}`),this.hls&&this.hls.trigger(fu.ERROR,{type:uu.OTHER_ERROR,details:hu.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close sessions and clear media keys: ${e}`)})}).then(()=>{n&&this.log("finished closing key sessions and clearing media keys")})}onManifestLoading(){this._clear()}onManifestLoaded(e,{sessionKeys:t}){if(t&&this.config.emeEnabled&&!this.keyFormatPromise){const e=t.reduce((e,t)=>(-1===e.indexOf(t.keyFormat)&&e.push(t.keyFormat),e),[]);this.log(`Selecting key-system from session-keys ${e.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(e)}}removeSession(e){const{mediaKeysSession:t,licenseXhr:r,decryptdata:i}=e;if(t){this.log(`Remove licenses and keys and close session "${t.sessionId}" keyId: ${Fu((null==i?void 0:i.keyId)||[])}`),e._onmessage&&(t.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(t.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),r&&r.readyState!==XMLHttpRequest.DONE&&r.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;const n=this.mediaKeySessions.indexOf(e);n>-1&&this.mediaKeySessions.splice(n,1);const{keyStatusTimeouts:s}=e;s&&Object.keys(s).forEach(e=>self.clearTimeout(s[e]));const{drmSystemOptions:a}=this.config,o=function(e){var t;return!(!e||"persistent-license"!==e.sessionType&&(null==(t=e.sessionTypes)||!t.some(e=>"persistent-license"===e)))}(a)?new Promise((e,r)=>{self.setTimeout(()=>r(new Error("MediaKeySession.remove() timeout")),8e3),t.remove().then(e).catch(r)}):Promise.resolve();return o.catch(e=>{this.log(`Could not remove session: ${e}`),this.hls&&this.hls.trigger(fu.ERROR,{type:uu.OTHER_ERROR,details:hu.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR,fatal:!1,error:new Error(`Could not remove session: ${e}`)})}).then(()=>t.close()).catch(e=>{this.log(`Could not close session: ${e}`),this.hls&&this.hls.trigger(fu.ERROR,{type:uu.OTHER_ERROR,details:hu.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close session: ${e}`)})})}return Promise.resolve()}}function Ay(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(null===e.keyId)throw new Error("keyId is null");return Fu(e.keyId)}function ky(e,t){return e.keyId&&t.mediaKeysSession.keyStatuses.has(e.keyId)?t.mediaKeysSession.keyStatuses.get(e.keyId):e.matches(t.decryptdata)?t.keyStatus:void 0}xy.CDMCleanupPromise=void 0;class Iy extends Error{constructor(e,t){super(t),this.data=void 0,e.error||(e.error=new Error(t)),this.data=e,e.err=e.error}}function Ly(e,t){const r="output-restricted"===e,i=r?hu.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:hu.KEY_SYSTEM_STATUS_INTERNAL_ERROR;return new Iy({type:uu.KEY_SYSTEM_ERROR,details:i,fatal:!1,decryptdata:t},r?"HDCP level output restricted":`key status changed to "${e}"`)}function Ry(e,t){let r;try{r=new Event("addtrack")}catch(e){r=document.createEvent("Event"),r.initEvent("addtrack",!1,!1)}r.track=e,t.dispatchEvent(r)}function Py(e,t){const r=e.mode;if("disabled"===r&&(e.mode="hidden"),e.cues&&!e.cues.getCueById(t.id))try{if(e.addCue(t),!e.cues.getCueById(t.id))throw new Error(`addCue is failed for: ${t}`)}catch(r){_u.debug(`[texttrack-utils]: ${r}`);try{const r=new self.TextTrackCue(t.startTime,t.endTime,t.text);r.id=t.id,e.addCue(r)}catch(e){_u.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${e}`)}}"disabled"===r&&(e.mode=r)}function Cy(e,t){const r=e.mode;if("disabled"===r&&(e.mode="hidden"),e.cues)for(let r=e.cues.length;r--;)t&&e.cues[r].removeEventListener("enter",t),e.removeCue(e.cues[r]);"disabled"===r&&(e.mode=r)}function Dy(e,t,r,i){const n=e.mode;if("disabled"===n&&(e.mode="hidden"),e.cues&&e.cues.length>0){const n=function(e,t,r){const i=[],n=function(e,t){if(t<=e[0].startTime)return 0;const r=e.length-1;if(t>e[r].endTime)return-1;let i,n=0,s=r;for(;n<=s;)if(i=Math.floor((s+n)/2),t<e[i].startTime)s=i-1;else{if(!(t>e[i].startTime&&n<r))return i;n=i+1}return e[n].startTime-t<t-e[s].startTime?n:s}(e,t);if(n>-1)for(let s=n,a=e.length;s<a;s++){const n=e[s];if(n.startTime>=t&&n.endTime<=r)i.push(n);else if(n.startTime>r)return i}return i}(e.cues,t,r);for(let t=0;t<n.length;t++)i&&!i(n[t])||e.removeCue(n[t])}"disabled"===n&&(e.mode=n)}function _y(e){const t=[];for(let r=0;r<e.length;r++){const i=e[r];"subtitles"!==i.kind&&"captions"!==i.kind||!i.label||t.push(e[r])}return t}function Oy(e){let t=5381,r=e.length;for(;r;)t=33*t^e.charCodeAt(--r);return(t>>>0).toString()}const My=.025;let Ny=function(e){return e[e.Point=0]="Point",e[e.Range=1]="Range",e}({});function Fy(e,t,r){return`${e.identifier}-${r+1}-${Oy(t)}`}class $y{constructor(e,t){this.base=void 0,this._duration=null,this._timelineStart=null,this.appendInPlaceDisabled=void 0,this.appendInPlaceStarted=void 0,this.dateRange=void 0,this.hasPlayed=!1,this.cumulativeDuration=0,this.resumeOffset=NaN,this.playoutLimit=NaN,this.restrictions={skip:!1,jump:!1},this.snapOptions={out:!1,in:!1},this.assetList=[],this.assetListLoader=void 0,this.assetListResponse=null,this.resumeAnchor=void 0,this.error=void 0,this.resetOnResume=void 0,this.base=t,this.dateRange=e,this.setDateRange(e)}setDateRange(e){this.dateRange=e,this.resumeOffset=e.attr.optionalFloat("X-RESUME-OFFSET",this.resumeOffset),this.playoutLimit=e.attr.optionalFloat("X-PLAYOUT-LIMIT",this.playoutLimit),this.restrictions=e.attr.enumeratedStringList("X-RESTRICT",this.restrictions),this.snapOptions=e.attr.enumeratedStringList("X-SNAP",this.snapOptions)}reset(){var e;this.appendInPlaceStarted=!1,null==(e=this.assetListLoader)||e.destroy(),this.assetListLoader=void 0,this.supplementsPrimary||(this.assetListResponse=null,this.assetList=[],this._duration=null)}isAssetPastPlayoutLimit(e){var t;if(e>0&&e>=this.assetList.length)return!0;const r=this.playoutLimit;if(e<=0||isNaN(r))return!1;if(0===r)return!0;return((null==(t=this.assetList[e])?void 0:t.startOffset)||0)>r}findAssetIndex(e){return this.assetList.indexOf(e)}get identifier(){return this.dateRange.id}get startDate(){return this.dateRange.startDate}get startTime(){const e=this.dateRange.startTime;if(this.snapOptions.out){const t=this.dateRange.tagAnchor;if(t)return By(e,t)}return e}get startOffset(){return this.cue.pre?0:this.startTime}get startIsAligned(){if(0===this.startTime||this.snapOptions.out)return!0;const e=this.dateRange.tagAnchor;if(e){const t=this.dateRange.startTime;return t-By(t,e)<.1}return!1}get resumptionOffset(){const e=this.resumeOffset,t=lu(e)?e:this.duration;return this.cumulativeDuration+t}get resumeTime(){const e=this.startOffset+this.resumptionOffset;if(this.snapOptions.in){const t=this.resumeAnchor;if(t)return By(e,t)}return e}get appendInPlace(){return!!this.appendInPlaceStarted||!this.appendInPlaceDisabled&&!(this.cue.once||this.cue.pre||!this.startIsAligned||!(isNaN(this.playoutLimit)&&isNaN(this.resumeOffset)||this.resumeOffset&&this.duration&&Math.abs(this.resumeOffset-this.duration)<My))}set appendInPlace(e){this.appendInPlaceStarted?this.resetOnResume=!e:this.appendInPlaceDisabled=!e}get timelineStart(){return null!==this._timelineStart?this._timelineStart:this.startTime}set timelineStart(e){this._timelineStart=e}get duration(){const e=this.playoutLimit;let t;return t=null!==this._duration?this._duration:this.dateRange.duration?this.dateRange.duration:this.dateRange.plannedDuration||0,!isNaN(e)&&e<t&&(t=e),t}set duration(e){this._duration=e}get cue(){return this.dateRange.cue}get timelineOccupancy(){return"RANGE"===this.dateRange.attr["X-TIMELINE-OCCUPIES"]?Ny.Range:Ny.Point}get supplementsPrimary(){return"PRIMARY"===this.dateRange.attr["X-TIMELINE-STYLE"]}get contentMayVary(){return"NO"!==this.dateRange.attr["X-CONTENT-MAY-VARY"]}get assetUrl(){return this.dateRange.attr["X-ASSET-URI"]}get assetListUrl(){return this.dateRange.attr["X-ASSET-LIST"]}get baseUrl(){return this.base.url}get assetListLoaded(){return this.assetList.length>0||null!==this.assetListResponse}toString(){return`["${(e=this).identifier}" ${e.cue.pre?"<pre>":e.cue.post?"<post>":""}${e.timelineStart.toFixed(2)}-${e.resumeTime.toFixed(2)}]`;var e}}function By(e,t){return e-t.start<t.duration/2&&!(Math.abs(e-(t.start+t.duration))<My)?t.start:t.start+t.duration}function Uy(e,t,r){const i=new self.URL(e,r);return"data:"!==i.protocol&&i.searchParams.set("_HLS_primary_id",t),i}function zy(e,t){for(;null!=(r=e.assetList[++t])&&r.error;)var r;return t}function Gy(e){const t=e.timelineStart,r=e.duration||0;return`["${e.identifier}" ${t.toFixed(2)}-${(t+r).toFixed(2)}]`}class jy{constructor(e,t,r,i){this.hls=void 0,this.interstitial=void 0,this.assetItem=void 0,this.tracks=null,this.hasDetails=!1,this.mediaAttached=null,this._currentTime=void 0,this._bufferedEosTime=void 0,this.checkPlayout=()=>{this.reachedPlayout(this.currentTime)&&this.hls&&this.hls.trigger(fu.PLAYOUT_LIMIT_REACHED,{})};const n=this.hls=new e(t);this.interstitial=r,this.assetItem=i;const s=()=>{this.hasDetails=!0};n.once(fu.LEVEL_LOADED,s),n.once(fu.AUDIO_TRACK_LOADED,s),n.once(fu.SUBTITLE_TRACK_LOADED,s),n.on(fu.MEDIA_ATTACHING,(e,{media:t})=>{this.removeMediaListeners(),this.mediaAttached=t;this.interstitial.playoutLimit&&(t.addEventListener("timeupdate",this.checkPlayout),this.appendInPlace&&n.on(fu.BUFFER_APPENDED,()=>{const e=this.bufferedEnd;this.reachedPlayout(e)&&(this._bufferedEosTime=e,n.trigger(fu.BUFFERED_TO_END,void 0))}))})}get appendInPlace(){return this.interstitial.appendInPlace}loadSource(){const e=this.hls;if(e)if(e.url)e.levels.length&&!e.started&&e.startLoad(-1,!0);else{let t=this.assetItem.uri;try{t=Uy(t,e.config.primarySessionId||"").href}catch(e){}e.loadSource(t)}}bufferedInPlaceToEnd(e){var t;if(!this.appendInPlace)return!1;if(null!=(t=this.hls)&&t.bufferedToEnd)return!0;if(!e)return!1;const r=Math.min(this._bufferedEosTime||1/0,this.duration),i=this.timelineOffset,n=lp.bufferInfo(e,i,0);return this.getAssetTime(n.end)>=r-.02}reachedPlayout(e){const t=this.interstitial.playoutLimit;return this.startOffset+e>=t}get destroyed(){var e;return!(null!=(e=this.hls)&&e.userConfig)}get assetId(){return this.assetItem.identifier}get interstitialId(){return this.assetItem.parentIdentifier}get media(){var e;return(null==(e=this.hls)?void 0:e.media)||null}get bufferedEnd(){const e=this.media||this.mediaAttached;if(!e)return this._bufferedEosTime?this._bufferedEosTime:this.currentTime;const t=lp.bufferInfo(e,e.currentTime,.001);return this.getAssetTime(t.end)}get currentTime(){const e=this.media||this.mediaAttached;return e?this.getAssetTime(e.currentTime):this._currentTime||0}get duration(){const e=this.assetItem.duration;if(!e)return 0;const t=this.interstitial.playoutLimit;if(t){const r=t-this.startOffset;if(r>0&&r<e)return r}return e}get remaining(){const e=this.duration;return e?Math.max(0,e-this.currentTime):0}get startOffset(){return this.assetItem.startOffset}get timelineOffset(){var e;return(null==(e=this.hls)?void 0:e.config.timelineOffset)||0}set timelineOffset(e){const t=this.timelineOffset;if(e!==t){const r=e-t;if(Math.abs(r)>1/9e4&&this.hls){if(this.hasDetails)throw new Error("Cannot set timelineOffset after playlists are loaded");this.hls.config.timelineOffset=e}}}getAssetTime(e){const t=this.timelineOffset,r=this.duration;return Math.min(Math.max(0,e-t),r)}removeMediaListeners(){const e=this.mediaAttached;e&&(this._currentTime=e.currentTime,this.bufferSnapShot(),e.removeEventListener("timeupdate",this.checkPlayout))}bufferSnapShot(){var e;this.mediaAttached&&(null!=(e=this.hls)&&e.bufferedToEnd&&(this._bufferedEosTime=this.bufferedEnd))}destroy(){this.removeMediaListeners(),this.hls&&this.hls.destroy(),this.hls=null,this.tracks=this.mediaAttached=this.checkPlayout=null}attachMedia(e){var t;this.loadSource(),null==(t=this.hls)||t.attachMedia(e)}detachMedia(){var e;this.removeMediaListeners(),this.mediaAttached=null,null==(e=this.hls)||e.detachMedia()}resumeBuffering(){var e;null==(e=this.hls)||e.resumeBuffering()}pauseBuffering(){var e;null==(e=this.hls)||e.pauseBuffering()}transferMedia(){var e;return this.bufferSnapShot(),(null==(e=this.hls)?void 0:e.transferMedia())||null}resetDetails(){const e=this.hls;if(e&&this.hasDetails){e.stopLoad();const t=e=>delete e.details;e.levels.forEach(t),e.allAudioTracks.forEach(t),e.allSubtitleTracks.forEach(t),this.hasDetails=!1}}on(e,t,r){var i;null==(i=this.hls)||i.on(e,t)}once(e,t,r){var i;null==(i=this.hls)||i.once(e,t)}off(e,t,r){var i;null==(i=this.hls)||i.off(e,t)}toString(){var e;return`HlsAssetPlayer: ${Gy(this.assetItem)} ${null==(e=this.hls)?void 0:e.sessionId} ${this.appendInPlace?"append-in-place":""}`}}class Hy extends Iu{constructor(e,t){super("interstitials-sched",t),this.onScheduleUpdate=void 0,this.eventMap={},this.events=null,this.items=null,this.durations={primary:0,playout:0,integrated:0},this.onScheduleUpdate=e}destroy(){this.reset(),this.onScheduleUpdate=null}reset(){this.eventMap={},this.setDurations(0,0,0),this.events&&this.events.forEach(e=>e.reset()),this.events=this.items=null}resetErrorsInRange(e,t){return this.events?this.events.reduce((r,i)=>e<=i.startOffset&&t>i.startOffset?(delete i.error,r+1):r,0):0}get duration(){const e=this.items;return e?e[e.length-1].end:0}get length(){return this.items?this.items.length:0}getEvent(e){return e&&this.eventMap[e]||null}hasEvent(e){return e in this.eventMap}findItemIndex(e,t){if(e.event)return this.findEventIndex(e.event.identifier);let r=-1;e.nextEvent?r=this.findEventIndex(e.nextEvent.identifier)-1:e.previousEvent&&(r=this.findEventIndex(e.previousEvent.identifier)+1);const i=this.items;if(i)for(i[r]||(void 0===t&&(t=e.start),r=this.findItemIndexAtTime(t));r>=0&&null!=(n=i[r])&&n.event;){var n;r--}return r}findItemIndexAtTime(e,t){const r=this.items;if(r)for(let i=0;i<r.length;i++){let n=r[i];if(t&&"primary"!==t&&(n=n[t]),e===n.start||e>n.start&&e<n.end)return i}return-1}findJumpRestrictedIndex(e,t){const r=this.items;if(r)for(let i=e;i<=t&&r[i];i++){const e=r[i].event;if(null!=e&&e.restrictions.jump&&!e.appendInPlace)return i}return-1}findEventIndex(e){const t=this.items;if(t)for(let i=t.length;i--;){var r;if((null==(r=t[i].event)?void 0:r.identifier)===e)return i}return-1}findAssetIndex(e,t){const r=e.assetList,i=r.length;if(i>1)for(let e=0;e<i;e++){const n=r[e];if(!n.error){const r=n.timelineStart;if(t===r||t>r&&(t<r+(n.duration||0)||e===i-1))return e}}return 0}get assetIdAtEnd(){var e;const t=null==(e=this.items)||null==(e=e[this.length-1])?void 0:e.event;if(t){const e=t.assetList,r=e[e.length-1];if(r)return r.identifier}return null}parseInterstitialDateRanges(e,t){const r=e.main.details,{dateRanges:i}=r,n=this.events,s=this.parseDateRanges(i,{url:r.url},t),a=Object.keys(i),o=n?n.filter(e=>!a.includes(e.identifier)):[];s.length&&s.sort((e,t)=>{const r=e.cue.pre,i=e.cue.post,n=t.cue.pre,s=t.cue.post;if(r&&!n)return-1;if(n&&!r)return 1;if(i&&!s)return 1;if(s&&!i)return-1;if(!(r||n||i||s)){const r=e.startTime,i=t.startTime;if(r!==i)return r-i}return e.dateRange.tagOrder-t.dateRange.tagOrder}),this.events=s,o.forEach(e=>{this.removeEvent(e)}),this.updateSchedule(e,o)}updateSchedule(e,t=[],r=!1){const i=this.events||[];if(i.length||t.length||this.length<2){const n=this.items,s=this.parseSchedule(i,e),a=r||t.length||(null==n?void 0:n.length)!==s.length||s.some((e,t)=>Math.abs(e.playout.start-n[t].playout.start)>.005||Math.abs(e.playout.end-n[t].playout.end)>.005);a&&(this.items=s,this.onScheduleUpdate(t,n))}}parseDateRanges(e,t,r){const i=[],n=Object.keys(e);for(let s=0;s<n.length;s++){const a=n[s],o=e[a];if(o.isInterstitial){let e=this.eventMap[a];e?e.setDateRange(o):(e=new $y(o,t),this.eventMap[a]=e,!1===r&&(e.appendInPlace=r)),i.push(e)}}return i}parseSchedule(e,t){const r=[],i=t.main.details,n=i.live?1/0:i.edge;let s=0;if((e=e.filter(e=>!(e.error||e.cue.once&&e.hasPlayed))).length){this.resolveOffsets(e,t);let i=0,o=0;if(e.forEach((t,a)=>{const l=t.cue.pre,c=t.cue.post,d=e[a-1]||null,u=t.appendInPlace,h=c?n:t.startOffset,f=t.duration,p=t.timelineOccupancy===Ny.Range?f:0,m=t.resumptionOffset,g=(null==d?void 0:d.startTime)===h,v=h+t.cumulativeDuration;let y=u?v+f:h+m;if(l||!c&&h<=0){const e=o;o+=p,t.timelineStart=v;const i=s;s+=f,r.push({event:t,start:v,end:y,playout:{start:i,end:s},integrated:{start:e,end:o}})}else{if(!(h<=n))return;{if(!g){const n=h-i;if(n>.033){const l=i,c=o;o+=n;const d=s;s+=n;const u={previousEvent:e[a-1]||null,nextEvent:t,start:l,end:l+n,playout:{start:d,end:s},integrated:{start:c,end:o}};r.push(u)}else n>0&&d&&(d.cumulativeDuration+=n,r[r.length-1].end=h)}c&&(y=v),t.timelineStart=v;const n=o;o+=p;const l=s;s+=f,r.push({event:t,start:v,end:y,playout:{start:l,end:s},integrated:{start:n,end:o}})}}const b=t.resumeTime;i=c||b>n?n:b}),i<n){var a;const e=i,t=o,l=n-i;o+=l;const c=s;s+=l,r.push({previousEvent:(null==(a=r[r.length-1])?void 0:a.event)||null,nextEvent:null,start:i,end:e+l,playout:{start:c,end:s},integrated:{start:t,end:o}})}this.setDurations(n,s,o)}else{const e=0;r.push({previousEvent:null,nextEvent:null,start:e,end:n,playout:{start:e,end:n},integrated:{start:e,end:n}}),this.setDurations(n,n,n)}return r}setDurations(e,t,r){this.durations={primary:e,playout:t,integrated:r}}resolveOffsets(e,t){const r=t.main.details,i=r.live?1/0:r.edge;let n=0,s=-1;e.forEach((a,o)=>{const l=a.cue.pre,c=a.cue.post,d=l?0:c?i:a.startTime;this.updateAssetDurations(a);if(s===d?a.cumulativeDuration=n:(n=0,s=d),!c&&a.snapOptions.in&&(a.resumeAnchor=bf(null,r.fragments,a.startOffset+a.resumptionOffset,0,0)||void 0),a.appendInPlace&&!a.appendInPlaceStarted){this.primaryCanResumeInPlaceAt(a,t)||(a.appendInPlace=!1)}if(!a.appendInPlace&&o+1<e.length){e[o+1].startTime-e[o].resumeTime<.033&&(e[o+1].appendInPlace=!1,e[o+1].appendInPlace&&this.warn(`Could not change append strategy for abutting event ${a}`))}const u=lu(a.resumeOffset)?a.resumeOffset:a.duration;n+=u})}primaryCanResumeInPlaceAt(e,t){const r=e.resumeTime,i=e.startTime+e.resumptionOffset;if(Math.abs(r-i)>My)return this.log(`"${e.identifier}" resumption ${r} not aligned with estimated timeline end ${i}`),!1;return!Object.keys(t).some(i=>{const n=t[i].details,s=n.edge;if(r>=s)return this.log(`"${e.identifier}" resumption ${r} past ${i} playlist end ${s}`),!1;const a=bf(null,n.fragments,r);if(!a)return this.log(`"${e.identifier}" resumption ${r} does not align with any fragments in ${i} playlist (${n.fragStart}-${n.fragmentEnd})`),!0;const o="audio"===i?.175:0;return!(Math.abs(a.start-r)<My+o||Math.abs(a.end-r)<My+o)&&(this.log(`"${e.identifier}" resumption ${r} not aligned with ${i} fragment bounds (${a.start}-${a.end} sn: ${a.sn} cc: ${a.cc})`),!0)})}updateAssetDurations(e){if(!e.assetListLoaded)return;const t=e.timelineStart;let r=0,i=!1,n=!1;for(let s=0;s<e.assetList.length;s++){const a=e.assetList[s],o=t+r;a.startOffset=r,a.timelineStart=o,i||(i=null===a.duration),n||(n=!!a.error);r+=a.error?0:a.duration||0}e.duration=i&&!n?Math.max(r,e.duration):r}removeEvent(e){e.reset(),delete this.eventMap[e.identifier]}}function Vy(e){return`[${e.event?'"'+e.event.identifier+'"':"primary"}: ${e.start.toFixed(2)}-${e.end.toFixed(2)}]`}class Wy{constructor(e){this.hls=void 0,this.hls=e}destroy(){this.hls=null}loadAssetList(e,t){const r=e.assetListUrl;let i;try{i=Uy(r,this.hls.sessionId,e.baseUrl)}catch(t){const i=this.assignAssetListError(e,hu.ASSET_LIST_LOAD_ERROR,t,r);return void this.hls.trigger(fu.ERROR,i)}t&&"data:"!==i.protocol&&i.searchParams.set("_HLS_start_offset",""+t);const n=this.hls.config,s=new(0,n.loader)(n),a={responseType:"json",url:i.href},o=n.interstitialAssetListLoadPolicy.default,l={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(t,r,i,n)=>{const s=t.data,a=null==s?void 0:s.ASSETS;if(!Array.isArray(a)){const t=this.assignAssetListError(e,hu.ASSET_LIST_PARSING_ERROR,new Error("Invalid interstitial asset list"),i.url,r,n);return void this.hls.trigger(fu.ERROR,t)}e.assetListResponse=s,this.hls.trigger(fu.ASSET_LIST_LOADED,{event:e,assetListResponse:s,networkDetails:n})},onError:(t,r,i,n)=>{const s=this.assignAssetListError(e,hu.ASSET_LIST_LOAD_ERROR,new Error(`Error loading X-ASSET-LIST: HTTP status ${t.code} ${t.text} (${r.url})`),r.url,n,i);this.hls.trigger(fu.ERROR,s)},onTimeout:(t,r,i)=>{const n=this.assignAssetListError(e,hu.ASSET_LIST_LOAD_TIMEOUT,new Error(`Timeout loading X-ASSET-LIST (${r.url})`),r.url,t,i);this.hls.trigger(fu.ERROR,n)}};return s.load(a,l,c),this.hls.trigger(fu.ASSET_LIST_LOADING,{event:e}),s}assignAssetListError(e,t,r,i,n,s){return e.error=r,{type:uu.NETWORK_ERROR,details:t,fatal:!1,interstitial:e,url:i,error:r,networkDetails:s,stats:n}}}function Yy(e){var t;null==e||null==(t=e.play())||t.catch(()=>{})}function Ky(e,t){return`[${e}] Advancing timeline position to ${t}`}class qy{constructor(e){this.buffered=void 0;const t=(t,r,i)=>{if((r>>>=0)>i-1)throw new DOMException(`Failed to execute '${t}' on 'TimeRanges': The index provided (${r}) is greater than the maximum bound (${i})`);return e[r][t]};this.buffered={get length(){return e.length},end:r=>t("end",r,e.length),start:r=>t("start",r,e.length)}}}const Xy={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},Qy=e=>String.fromCharCode(Xy[e]||e),Zy=15,Jy=100,eb={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},tb={17:2,18:4,21:6,22:8,23:10,19:13,20:15},rb={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},ib={25:2,26:4,29:6,30:8,31:10,27:13,28:15},nb=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class sb{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){const r="function"==typeof t?t():t;_u.log(`${this.time} [${e}] ${r}`)}}}const ab=function(e){const t=[];for(let r=0;r<e.length;r++)t.push(e[r].toString(16));return t};class ob{constructor(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}reset(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}setStyles(e){const t=["foreground","underline","italics","background","flash"];for(let r=0;r<t.length;r++){const i=t[r];e.hasOwnProperty(i)&&(this[i]=e[i])}}isDefault(){return"white"===this.foreground&&!this.underline&&!this.italics&&"black"===this.background&&!this.flash}equals(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash}copy(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}class lb{constructor(){this.uchar=" ",this.penState=new ob}reset(){this.uchar=" ",this.penState.reset()}setChar(e,t){this.uchar=e,this.penState.copy(t)}setPenState(e){this.penState.copy(e)}equals(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)}copy(e){this.uchar=e.uchar,this.penState.copy(e.penState)}isEmpty(){return" "===this.uchar&&this.penState.isDefault()}}class cb{constructor(e){this.chars=[],this.pos=0,this.currPenState=new ob,this.cueStartTime=null,this.logger=void 0;for(let e=0;e<Jy;e++)this.chars.push(new lb);this.logger=e}equals(e){for(let t=0;t<Jy;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}copy(e){for(let t=0;t<Jy;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<Jy;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e}setCursor(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>Jy&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=Jy)}moveCursor(e){const t=this.pos+e;if(e>1)for(let e=this.pos+1;e<t+1;e++)this.chars[e].setPenState(this.currPenState);this.setCursor(t)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(e){e>=144&&this.backSpace();const t=Qy(e);this.pos>=Jy?this.logger.log(0,()=>"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!"):(this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1))}clearFromPos(e){let t;for(t=e;t<Jy;t++)this.chars[t].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){const e=[];let t=!0;for(let r=0;r<Jy;r++){const i=this.chars[r].uchar;" "!==i&&(t=!1),e.push(i)}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e);this.chars[this.pos].setPenState(this.currPenState)}}class db{constructor(e){this.rows=[],this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let t=0;t<Zy;t++)this.rows.push(new cb(e));this.logger=e}reset(){for(let e=0;e<Zy;e++)this.rows[e].clear();this.currRow=14}equals(e){let t=!0;for(let r=0;r<Zy;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t}copy(e){for(let t=0;t<Zy;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<Zy;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e}backSpace(){this.rows[this.currRow].backSpace()}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow()}insertChar(e){this.rows[this.currRow].insertChar(e)}setPen(e){this.rows[this.currRow].setPenStyles(e)}moveCursor(e){this.rows[this.currRow].moveCursor(e)}setCursor(e){this.logger.log(2,"setCursor: "+e);this.rows[this.currRow].setCursor(e)}setPAC(e){this.logger.log(2,()=>"pacData = "+cf(e));let t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(let e=0;e<Zy;e++)this.rows[e].clear();const e=this.currRow+1-this.nrRollUpRows,r=this.lastOutputScreen;if(r){const i=r.rows[e].cueStartTime,n=this.logger.time;if(null!==i&&null!==n&&i<n)for(let i=0;i<this.nrRollUpRows;i++)this.rows[t-this.nrRollUpRows+i+1].copy(r.rows[e+i])}}this.currRow=t;const r=this.rows[this.currRow];if(null!==e.indent){const t=e.indent,i=Math.max(t-1,0);r.setCursor(e.indent),e.color=r.chars[i].penState.foreground}const i={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(i)}setBkgData(e){this.logger.log(2,()=>"bkgData = "+cf(e)),this.backSpace(),this.setPen(e),this.insertChar(32)}setRollUpRows(e){this.nrRollUpRows=e}rollUp(){if(null===this.nrRollUpRows)return void this.logger.log(3,"roll_up but nrRollUpRows not set yet");this.logger.log(1,()=>this.getDisplayText());const e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(2,"Rolling up")}getDisplayText(e){e=e||!1;const t=[];let r="",i=-1;for(let r=0;r<Zy;r++){const n=this.rows[r].getTextString();n&&(i=r+1,e?t.push("Row "+i+": '"+n+"'"):t.push(n.trim()))}return t.length>0&&(r=e?"["+t.join(" | ")+"]":t.join("\n")),r}getTextAndFormat(){return this.rows}}class ub{constructor(e,t,r){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new db(r),this.nonDisplayedMemory=new db(r),this.lastOutputScreen=new db(r),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=r}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(e){this.outputFilter=e}setPAC(e){this.writeScreen.setPAC(e)}setBkgData(e){this.writeScreen.setBkgData(e)}setMode(e){e!==this.mode&&(this.mode=e,this.logger.log(2,()=>"MODE="+e),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}insertChars(e){for(let t=0;t<e.length;t++)this.writeScreen.insertChar(e[t]);const t=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>t+": "+this.writeScreen.getDisplayText(!0)),"MODE_PAINT-ON"!==this.mode&&"MODE_ROLL-UP"!==this.mode||(this.logger.log(1,()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())}ccRCL(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}ccBS(){this.logger.log(2,"BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}ccAOF(){}ccAON(){}ccDER(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}ccRU(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){if(this.logger.log(2,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode){const e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}ccTO(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}ccMIDROW(e){const t={flash:!1};if(t.underline=e%2==1,t.italics=e>=46,t.italics)t.foreground="white";else{const r=Math.floor(e/2)-16,i=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=i[r]}this.logger.log(2,"MIDROW: "+cf(t)),this.writeScreen.setPen(t)}outputDataUpdate(e=!1){const t=this.logger.time;null!==t&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t):this.cueStartTime=t,this.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))}}class hb{constructor(e,t,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory={a:null,b:null},this.logger=void 0;const i=this.logger=new sb;this.channels=[null,new ub(e,t,i),new ub(e+1,r,i)]}getHandler(e){return this.channels[e].getHandler()}setHandler(e,t){this.channels[e].setHandler(t)}addData(e,t){this.logger.time=e;for(let e=0;e<t.length;e+=2){const r=127&t[e],i=127&t[e+1];let n=!1,s=null;if(0===r&&0===i)continue;this.logger.log(3,()=>"["+ab([t[e],t[e+1]])+"] -> ("+ab([r,i])+")");const a=this.cmdHistory;if(r>=16&&r<=31){if(pb(r,i,a)){fb(null,null,a),this.logger.log(3,()=>"Repeated command ("+ab([r,i])+") is dropped");continue}fb(r,i,this.cmdHistory),n=this.parseCmd(r,i),n||(n=this.parseMidrow(r,i)),n||(n=this.parsePAC(r,i)),n||(n=this.parseBackgroundAttributes(r,i))}else fb(null,null,a);if(!n&&(s=this.parseChars(r,i),s)){const e=this.currentChannel;if(e&&e>0){this.channels[e].insertChars(s)}else this.logger.log(2,"No channel found yet. TEXT-MODE?")}n||s||this.logger.log(2,()=>"Couldn't parse cleaned data "+ab([r,i])+" orig: "+ab([t[e],t[e+1]]))}}parseCmd(e,t){if(!((20===e||28===e||21===e||29===e)&&t>=32&&t<=47)&&!((23===e||31===e)&&t>=33&&t<=35))return!1;const r=20===e||21===e||23===e?1:2,i=this.channels[r];return 20===e||21===e||28===e||29===e?32===t?i.ccRCL():33===t?i.ccBS():34===t?i.ccAOF():35===t?i.ccAON():36===t?i.ccDER():37===t?i.ccRU(2):38===t?i.ccRU(3):39===t?i.ccRU(4):40===t?i.ccFON():41===t?i.ccRDC():42===t?i.ccTR():43===t?i.ccRTD():44===t?i.ccEDM():45===t?i.ccCR():46===t?i.ccENM():47===t&&i.ccEOC():i.ccTO(t-32),this.currentChannel=r,!0}parseMidrow(e,t){let r=0;if((17===e||25===e)&&t>=32&&t<=47){if(r=17===e?1:2,r!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;const i=this.channels[r];return!!i&&(i.ccMIDROW(t),this.logger.log(3,()=>"MIDROW ("+ab([e,t])+")"),!0)}return!1}parsePAC(e,t){let r;if(!((e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127)&&!((16===e||24===e)&&t>=64&&t<=95))return!1;const i=e<=23?1:2;r=t>=64&&t<=95?1===i?eb[e]:rb[e]:1===i?tb[e]:ib[e];const n=this.channels[i];return!!n&&(n.setPAC(this.interpretPAC(r,t)),this.currentChannel=i,!0)}interpretPAC(e,t){let r;const i={color:null,italics:!1,indent:null,underline:!1,row:e};return r=t>95?t-96:t-64,i.underline=!(1&~r),r<=13?i.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(i.italics=!0,i.color="white"):i.indent=4*Math.floor((r-16)/2),i}parseChars(e,t){let r,i=null,n=null;if(e>=25?(r=2,n=e-8):(r=1,n=e),n>=17&&n<=19){let e;e=17===n?t+80:18===n?t+112:t+144,this.logger.log(2,()=>"Special char '"+Qy(e)+"' in channel "+r),i=[e]}else e>=32&&e<=127&&(i=0===t?[e]:[e,t]);return i&&this.logger.log(3,()=>"Char codes = "+ab(i).join(",")),i}parseBackgroundAttributes(e,t){if(!((16===e||24===e)&&t>=32&&t<=47)&&!((23===e||31===e)&&t>=45&&t<=47))return!1;let r;const i={};16===e||24===e?(r=Math.floor((t-32)/2),i.background=nb[r],t%2==1&&(i.background=i.background+"_semi")):45===t?i.background="transparent":(i.foreground="black",47===t&&(i.underline=!0));const n=e<=23?1:2;return this.channels[n].setBkgData(i),!0}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){const t=this.channels[e];t&&t.reset()}fb(null,null,this.cmdHistory)}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){const r=this.channels[t];r&&r.cueSplitAtTime(e)}}}function fb(e,t,r){r.a=e,r.b=t}function pb(e,t,r){return r.a===e&&r.b===t}var mb=function(){if(null!=Rp&&Rp.VTTCue)return self.VTTCue;const e=["","lr","rl"],t=["start","middle","end","left","right"];function r(e,t){if("string"!=typeof t)return!1;if(!Array.isArray(e))return!1;const r=t.toLowerCase();return!!~e.indexOf(r)&&r}function i(e){return r(t,e)}function n(e,...t){let r=1;for(;r<arguments.length;r++){const t=arguments[r];for(const r in t)e[r]=t[r]}return e}function s(t,s,a){const o=this,l={enumerable:!0};o.hasBeenReset=!1;let c="",d=!1,u=t,h=s,f=a,p=null,m="",g=!0,v="auto",y="start",b=50,E="middle",w=50,S="middle";Object.defineProperty(o,"id",n({},l,{get:function(){return c},set:function(e){c=""+e}})),Object.defineProperty(o,"pauseOnExit",n({},l,{get:function(){return d},set:function(e){d=!!e}})),Object.defineProperty(o,"startTime",n({},l,{get:function(){return u},set:function(e){if("number"!=typeof e)throw new TypeError("Start time must be set to a number.");u=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"endTime",n({},l,{get:function(){return h},set:function(e){if("number"!=typeof e)throw new TypeError("End time must be set to a number.");h=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"text",n({},l,{get:function(){return f},set:function(e){f=""+e,this.hasBeenReset=!0}})),Object.defineProperty(o,"region",n({},l,{get:function(){return p},set:function(e){p=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"vertical",n({},l,{get:function(){return m},set:function(t){const i=function(t){return r(e,t)}(t);if(!1===i)throw new SyntaxError("An invalid or illegal string was specified.");m=i,this.hasBeenReset=!0}})),Object.defineProperty(o,"snapToLines",n({},l,{get:function(){return g},set:function(e){g=!!e,this.hasBeenReset=!0}})),Object.defineProperty(o,"line",n({},l,{get:function(){return v},set:function(e){if("number"!=typeof e&&"auto"!==e)throw new SyntaxError("An invalid number or illegal string was specified.");v=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"lineAlign",n({},l,{get:function(){return y},set:function(e){const t=i(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");y=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"position",n({},l,{get:function(){return b},set:function(e){if(e<0||e>100)throw new Error("Position must be between 0 and 100.");b=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"positionAlign",n({},l,{get:function(){return E},set:function(e){const t=i(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");E=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"size",n({},l,{get:function(){return w},set:function(e){if(e<0||e>100)throw new Error("Size must be between 0 and 100.");w=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"align",n({},l,{get:function(){return S},set:function(e){const t=i(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");S=t,this.hasBeenReset=!0}})),o.displayState=void 0}return s.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},s}();class gb{decode(e,t){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}function vb(e){function t(e,t,r,i){return 3600*(0|e)+60*(0|t)+(0|r)+parseFloat(i||0)}const r=e.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return r?parseFloat(r[2])>59?t(r[2],r[3],0,r[4]):t(r[1],r[2],r[3],r[4]):null}class yb{constructor(){this.values=Object.create(null)}set(e,t){this.get(e)||""===t||(this.values[e]=t)}get(e,t,r){return r?this.has(e)?this.values[e]:t[r]:this.has(e)?this.values[e]:t}has(e){return e in this.values}alt(e,t,r){for(let i=0;i<r.length;++i)if(t===r[i]){this.set(e,t);break}}integer(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))}percent(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){const r=parseFloat(t);if(r>=0&&r<=100)return this.set(e,r),!0}return!1}}function bb(e,t,r,i){const n=i?e.split(i):[e];for(const e in n){if("string"!=typeof n[e])continue;const i=n[e].split(r);if(2!==i.length)continue;t(i[0],i[1])}}const Eb=new mb(0,0,""),wb="middle"===Eb.align?"middle":"center";function Sb(e,t,r){const i=e;function n(){const t=vb(e);if(null===t)throw new Error("Malformed timestamp: "+i);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function s(){e=e.replace(/^\s+/,"")}if(s(),t.startTime=n(),s(),"--\x3e"!==e.slice(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+i);e=e.slice(3),s(),t.endTime=n(),s(),function(e,t){const i=new yb;bb(e,function(e,t){let n;switch(e){case"region":for(let n=r.length-1;n>=0;n--)if(r[n].id===t){i.set(e,r[n].region);break}break;case"vertical":i.alt(e,t,["rl","lr"]);break;case"line":n=t.split(","),i.integer(e,n[0]),i.percent(e,n[0])&&i.set("snapToLines",!1),i.alt(e,n[0],["auto"]),2===n.length&&i.alt("lineAlign",n[1],["start",wb,"end"]);break;case"position":n=t.split(","),i.percent(e,n[0]),2===n.length&&i.alt("positionAlign",n[1],["start",wb,"end","line-left","line-right","auto"]);break;case"size":i.percent(e,t);break;case"align":i.alt(e,t,["start",wb,"end","left","right"])}},/:/,/\s/),t.region=i.get("region",null),t.vertical=i.get("vertical","");let n=i.get("line","auto");"auto"===n&&-1===Eb.line&&(n=-1),t.line=n,t.lineAlign=i.get("lineAlign","start"),t.snapToLines=i.get("snapToLines",!0),t.size=i.get("size",100),t.align=i.get("align",wb);let s=i.get("position","auto");"auto"===s&&50===Eb.position&&(s="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=s}(e,t)}function Tb(e){return e.replace(/<br(?: \/)?>/gi,"\n")}class xb{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new gb,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(e){const t=this;function r(){let e=t.buffer,r=0;for(e=Tb(e);r<e.length&&"\r"!==e[r]&&"\n"!==e[r];)++r;const i=e.slice(0,r);return"\r"===e[r]&&++r,"\n"===e[r]&&++r,t.buffer=e.slice(r),i}function i(e){bb(e,function(e,t){},/:/)}e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));try{let e="";if("INITIAL"===t.state){if(!/\r\n|\n/.test(t.buffer))return this;e=r();const i=e.match(/^()?WEBVTT([ \t].*)?$/);if(null==i||!i[0])throw new Error("Malformed WebVTT signature.");t.state="HEADER"}let n=!1;for(;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(n?n=!1:e=r(),t.state){case"HEADER":/:/.test(e)?i(e):e||(t.state="ID");continue;case"NOTE":e||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(e)){t.state="NOTE";break}if(!e)continue;if(t.cue=new mb(0,0,""),t.state="CUE",-1===e.indexOf("--\x3e")){t.cue.id=e;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{Sb(e,t.cue,t.regionList)}catch(e){t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{const r=-1!==e.indexOf("--\x3e");if(!e||r&&(n=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(null===t.cue)continue;t.cue.text&&(t.cue.text+="\n"),t.cue.text+=e}continue;case"BADCUE":e||(t.state="ID")}}}catch(e){"CUETEXT"===t.state&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state="INITIAL"===t.state?"BADWEBVTT":"BADCUE"}return this}flush(){const e=this;try{if((e.cue||"HEADER"===e.state)&&(e.buffer+="\n\n",e.parse()),"INITIAL"===e.state||"BADWEBVTT"===e.state)throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this}}const Ab=/\r\n|\n\r|\n|\r/g,kb=function(e,t,r=0){return e.slice(r,r+t.length)===t};function Ib(e,t,r){return Oy(e.toString())+Oy(t.toString())+Oy(r)}function Lb(e,t,r,i,n,s,a){const o=new xb,l=Nu(new Uint8Array(e)).trim().replace(Ab,"\n").split("\n"),c=[],d=t?function(e,t=1){return Qg(e,9e4,1/t)}(t.baseTime,t.timescale):0;let u,h="00:00.000",f=0,p=0,m=!0;o.oncue=function(e){const s=r[i];let a=r.ccOffset;const o=(f-d)/9e4;if(null!=s&&s.new&&(void 0!==p?a=r.ccOffset=s.start:function(e,t,r){let i=e[t],n=e[i.prevCC];if(!n||!n.new&&i.new)return e.ccOffset=e.presentationOffset=i.start,void(i.new=!1);for(;null!=(s=n)&&s.new;){var s;e.ccOffset+=i.start-n.start,i.new=!1,i=n,n=e[i.prevCC]}e.presentationOffset=r}(r,i,o)),o){if(!t)return void(u=new Error("Missing initPTS for VTT MPEGTS"));a=o-r.presentationOffset}const l=e.endTime-e.startTime,h=sv(9e4*(e.startTime+a-p),9e4*n)/9e4;e.startTime=Math.max(h,0),e.endTime=Math.max(h+l,0);const m=e.text.trim();e.text=decodeURIComponent(encodeURIComponent(m)),e.id||(e.id=Ib(e.startTime,e.endTime,m)),e.endTime>0&&c.push(e)},o.onparsingerror=function(e){u=e},o.onflush=function(){u?a(u):s(c)},l.forEach(e=>{if(m){if(kb(e,"X-TIMESTAMP-MAP=")){m=!1,e.slice(16).split(",").forEach(e=>{kb(e,"LOCAL:")?h=e.slice(6):kb(e,"MPEGTS:")&&(f=parseInt(e.slice(7)))});try{p=function(e){let t=parseInt(e.slice(-3));const r=parseInt(e.slice(-6,-4)),i=parseInt(e.slice(-9,-7)),n=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!(lu(t)&&lu(r)&&lu(i)&&lu(n)))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*r,t+=6e4*i,t+=36e5*n,t}(h)/1e3}catch(e){u=e}return}""===e&&(m=!1)}o.parse(e+"\n")}),o.flush()}const Rb="stpp.ttml.im1t",Pb=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Cb=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,Db={left:"start",center:"center",right:"end",start:"start",end:"end"};function _b(e,t,r,i){const n=uh(new Uint8Array(e),["mdat"]);if(0===n.length)return void i(new Error("Could not parse IMSC1 mdat"));const s=n.map(e=>Nu(e)),a=function(e,t,r=1,i=!1){return Qg(e,t,1/r,i)}(t.baseTime,1,t.timescale);try{s.forEach(e=>r(function(e,t){const r=(new DOMParser).parseFromString(e,"text/xml"),i=r.getElementsByTagName("tt")[0];if(!i)throw new Error("Invalid ttml");const n={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},s=Object.keys(n).reduce((e,t)=>(e[t]=i.getAttribute(`ttp:${t}`)||n[t],e),{}),a="preserve"!==i.getAttribute("xml:space"),o=Mb(Ob(i,"styling","style")),l=Mb(Ob(i,"layout","region")),c=Ob(i,"body","[begin]");return[].map.call(c,e=>{const r=Nb(e,a);if(!r||!e.hasAttribute("begin"))return null;const i=Bb(e.getAttribute("begin"),s),n=Bb(e.getAttribute("dur"),s);let c=Bb(e.getAttribute("end"),s);if(null===i)throw $b(e);if(null===c){if(null===n)throw $b(e);c=i+n}const d=new mb(i-t,c-t,r);d.id=Ib(d.startTime,d.endTime,d.text);const u=function(e,t,r){const i="http://www.w3.org/ns/ttml#styling";let n=null;const s=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],a=null!=e&&e.hasAttribute("style")?e.getAttribute("style"):null;a&&r.hasOwnProperty(a)&&(n=r[a]);return s.reduce((r,s)=>{const a=Fb(t,i,s)||Fb(e,i,s)||Fb(n,i,s);return a&&(r[s]=a),r},{})}(l[e.getAttribute("region")],o[e.getAttribute("style")],o),{textAlign:h}=u;if(h){const e=Db[h];e&&(d.lineAlign=e),d.align=h}return xu(d,u),d}).filter(e=>null!==e)}(e,a)))}catch(e){i(e)}}function Ob(e,t,r){const i=e.getElementsByTagName(t)[0];return i?[].slice.call(i.querySelectorAll(r)):[]}function Mb(e){return e.reduce((e,t)=>{const r=t.getAttribute("xml:id");return r&&(e[r]=t),e},{})}function Nb(e,t){return[].slice.call(e.childNodes).reduce((e,r,i)=>{var n;return"br"===r.nodeName&&i?e+"\n":null!=(n=r.childNodes)&&n.length?Nb(r,t):t?e+r.textContent.trim().replace(/\s+/g," "):e+r.textContent},"")}function Fb(e,t,r){return e&&e.hasAttributeNS(t,r)?e.getAttributeNS(t,r):null}function $b(e){return new Error(`Could not parse ttml timestamp ${e}`)}function Bb(e,t){if(!e)return null;let r=vb(e);return null===r&&(Pb.test(e)?r=function(e,t){const r=Pb.exec(e),i=(0|r[4])+(0|r[5])/t.subFrameRate;return 3600*(0|r[1])+60*(0|r[2])+(0|r[3])+i/t.frameRate}(e,t):Cb.test(e)&&(r=function(e,t){const r=Cb.exec(e),i=Number(r[1]);switch(r[2]){case"h":return 3600*i;case"m":return 60*i;case"ms":return 1e3*i;case"f":return i/t.frameRate;case"t":return i/t.tickRate}return i}(e,t))),r}class Ub{constructor(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}dispatchCue(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(e,t,r){(null===this.startTime||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}function zb(e){return e.characteristics&&/transcribes-spoken-dialog/gi.test(e.characteristics)&&/describes-music-and-sound/gi.test(e.characteristics)?"captions":"subtitles"}function Gb(e,t){return!!e&&e.kind===zb(t)&&wv(t,e)}function jb(e,t,r,i){return Math.min(t,i)-Math.max(e,r)}const Hb=/\s/,Vb={newCue(e,t,r,i){const n=[];let s,a,o,l,c;const d=self.VTTCue||self.TextTrackCue;for(let h=0;h<i.rows.length;h++)if(s=i.rows[h],o=!0,l=0,c="",!s.isEmpty()){var u;for(let e=0;e<s.chars.length;e++)Hb.test(s.chars[e].uchar)&&o?l++:(c+=s.chars[e].uchar,o=!1);s.cueStartTime=t,t===r&&(r+=1e-4),l>=16?l--:l++;const i=Tb(c.trim()),f=Ib(t,r,i);null!=e&&null!=(u=e.cues)&&u.getCueById(f)||(a=new d(t,r,i),a.id=f,a.line=h+1,a.align="left",a.position=10+Math.min(80,10*Math.floor(8*l/32)),n.push(a))}return e&&n.length&&(n.sort((e,t)=>"auto"===e.line||"auto"===t.line?0:e.line>8&&t.line>8?t.line-e.line:e.line-t.line),n.forEach(t=>Py(e,t))),n}};const Wb=/(\d+)-(\d+)\/(\d+)/;class Yb{constructor(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||Kb,this.controller=new self.AbortController,this.stats=new Ku}destroy(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null}abortInternal(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())}abort(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(e,t,r){const i=this.stats;if(i.loading.start)throw new Error("Loader can only be used once.");i.loading.start=self.performance.now();const n=function(e,t){const r={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(xu({},e.headers))};e.rangeEnd&&r.headers.set("Range","bytes="+e.rangeStart+"-"+String(e.rangeEnd-1));return r}(e,this.controller.signal),s="arraybuffer"===e.responseType,a=s?"byteLength":"length",{maxTimeToFirstByteMs:o,maxLoadTimeMs:l}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,n),self.clearTimeout(this.requestTimeout),t.timeout=o&&lu(o)?o:l,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(i,e,this.response))},t.timeout);(fv(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then(r=>{var n;this.response=this.loader=r;const a=Math.max(self.performance.now(),i.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=l,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(i,e,this.response))},l-(a-i.loading.start)),!r.ok){const{status:e,statusText:t}=r;throw new qb(t||"fetch, bad network response",e,r)}i.loading.first=a,i.total=function(e){const t=e.get("Content-Range");if(t){const e=function(e){const t=Wb.exec(e);if(t)return parseInt(t[2])-parseInt(t[1])+1}(t);if(lu(e))return e}const r=e.get("Content-Length");if(r)return parseInt(r)}(r.headers)||i.total;const o=null==(n=this.callbacks)?void 0:n.onProgress;return o&&lu(t.highWaterMark)?this.loadProgressively(r,i,e,t.highWaterMark,o):s?r.arrayBuffer():"json"===e.responseType?r.json():r.text()}).then(r=>{var n,s;const o=this.response;if(!o)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),i.loading.end=Math.max(self.performance.now(),i.loading.first);const l=r[a];l&&(i.loaded=i.total=l);const c={url:o.url,data:r,code:o.status},d=null==(n=this.callbacks)?void 0:n.onProgress;d&&!lu(t.highWaterMark)&&d(i,e,r,o),null==(s=this.callbacks)||s.onSuccess(c,i,e,o)}).catch(t=>{var r;if(self.clearTimeout(this.requestTimeout),i.aborted)return;const n=t&&t.code||0,s=t?t.message:null;null==(r=this.callbacks)||r.onError({code:n,text:s},e,t?t.details:null,i)})}getCacheAge(){let e=null;if(this.response){const t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,t,r,i=0,n){const s=new Gm,a=e.body.getReader(),o=()=>a.read().then(a=>{if(a.done)return s.dataLength&&n(t,r,s.flush().buffer,e),Promise.resolve(new ArrayBuffer(0));const l=a.value,c=l.length;return t.loaded+=c,c<i||s.dataLength?(s.push(l),s.dataLength>=i&&n(t,r,s.flush().buffer,e)):n(t,r,l.buffer,e),o()}).catch(()=>Promise.reject());return o()}}function Kb(e,t){return new self.Request(e.url,t)}class qb extends Error{constructor(e,t,r){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=r}}const Xb=/^age:\s*[\d.]+\s*$/im;class Qb{constructor(e){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=null,this.loader=null,this.stats=void 0,this.xhrSetup=e&&e.xhrSetup||null,this.stats=new Ku,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null}abortInternal(){const e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,4!==e.readyState&&(this.stats.aborted=!0,e.abort()))}abort(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(e,t,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=r,this.loadInternal()}loadInternal(){const{config:e,context:t}=this;if(!e||!t)return;const r=this.loader=new self.XMLHttpRequest,i=this.stats;i.loading.first=0,i.loaded=0,i.aborted=!1;const n=this.xhrSetup;n?Promise.resolve().then(()=>{if(this.loader===r&&!this.stats.aborted)return n(r,t.url)}).catch(e=>{if(this.loader===r&&!this.stats.aborted)return r.open("GET",t.url,!0),n(r,t.url)}).then(()=>{this.loader!==r||this.stats.aborted||this.openAndSendXhr(r,t,e)}).catch(e=>{var n;null==(n=this.callbacks)||n.onError({code:r.status,text:e.message},t,r,i)}):this.openAndSendXhr(r,t,e)}openAndSendXhr(e,t,r){e.readyState||e.open("GET",t.url,!0);const i=t.headers,{maxTimeToFirstByteMs:n,maxLoadTimeMs:s}=r.loadPolicy;if(i)for(const t in i)e.setRequestHeader(t,i[t]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),r.timeout=n&&lu(n)?n:s,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),e.send()}readystatechange(){const{context:e,loader:t,stats:r}=this;if(!e||!t)return;const i=t.readyState,n=this.config;if(!r.aborted&&i>=2&&(0===r.loading.first&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),n.timeout!==n.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),n.timeout=n.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),n.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),4===i)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;const i=t.status,l="text"===t.responseType?t.responseText:null;if(i>=200&&i<300){const n=null!=l?l:t.response;if(null!=n){var s,a;r.loading.end=Math.max(self.performance.now(),r.loading.first);const o="arraybuffer"===t.responseType?n.byteLength:n.length;r.loaded=r.total=o,r.bwEstimate=8e3*r.total/(r.loading.end-r.loading.first);const l=null==(s=this.callbacks)?void 0:s.onProgress;l&&l(r,e,n,t);const c={url:t.responseURL,data:n,code:i};return void(null==(a=this.callbacks)||a.onSuccess(c,r,e,t))}}const c=n.loadPolicy.errorRetry;var o;if(Rf(c,r.retry,!1,{url:e.url,data:void 0,code:i}))this.retry(c);else _u.error(`${i} while loading ${e.url}`),null==(o=this.callbacks)||o.onError({code:i,text:t.statusText},e,t,r)}}loadtimeout(){if(!this.config)return;const e=this.config.loadPolicy.timeoutRetry;if(Rf(e,this.stats.retry,!0))this.retry(e);else{var t;_u.warn(`timeout while loading ${null==(t=this.context)?void 0:t.url}`);const e=this.callbacks;e&&(this.abortInternal(),e.onTimeout(this.stats,this.context,this.loader))}}retry(e){const{context:t,stats:r}=this;this.retryDelay=If(e,r.retry),r.retry++,_u.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${null==t?void 0:t.url}, retrying ${r.retry}/${e.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}loadprogress(e){const t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}getCacheAge(){let e=null;if(this.loader&&Xb.test(this.loader.getAllResponseHeaders())){const t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}}const Zb=ku(ku({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,maxDevicePixelRatio:Number.POSITIVE_INFINITY,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,startOnSegmentBoundary:!1,maxBufferSize:6e7,maxFragLookUpTolerance:.25,maxBufferHole:.1,detectStallWithCurrentTimeMs:1250,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,nudgeOnVideoHole:!0,liveSyncMode:"edge",liveSyncDurationCount:3,liveSyncOnStallIncrease:1,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,ignorePlaylistParsingErrors:!1,loader:Qb,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:class extends Iu{constructor(e){super("abr",e.logger),this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.codecTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.rebufferNotice=-1,this.supportedCache={},this.bwEstimator=void 0,this._abandonRulesCheck=e=>{var t;const{fragCurrent:r,partCurrent:i,hls:n}=this,{autoLevelEnabled:s,media:a}=n;if(!r||!a)return;const o=performance.now(),l=i?i.stats:r.stats,c=i?i.duration:r.duration,d=o-l.loading.start,u=n.minAutoLevel,h=r.level,f=this._nextAutoLevel;if(l.aborted||l.loaded&&l.loaded===l.total||h<=u)return this.clearTimer(),void(this._nextAutoLevel=-1);if(!s)return;const p=f>-1&&f!==h,m=!!e||p;if(!m&&(a.paused||!a.playbackRate||!a.readyState))return;const g=n.mainForwardBufferInfo;if(!m&&null===g)return;const v=this.bwEstimator.getEstimateTTFB(),y=Math.abs(a.playbackRate);if(d<=Math.max(v,c/(2*y)*1e3))return;const b=g?g.len/y:0,E=l.loading.first?l.loading.first-l.loading.start:-1,w=l.loaded&&E>-1,S=this.getBwEstimate(),T=n.levels,x=T[h],A=Math.max(l.loaded,Math.round(c*(r.bitrate||x.averageBitrate)/8));let k=w?d-E:d;k<1&&w&&(k=Math.min(d,8*l.loaded/S));const I=w?1e3*l.loaded/k:0,L=v/1e3,R=I?(A-l.loaded)/I:8*A/S+L;if(R<=b)return;const P=I?8*I:S,C=!0===(null==(t=(null==e?void 0:e.details)||this.hls.latestLevelDetails)?void 0:t.live),D=this.hls.config.abrBandWidthUpFactor;let _,O=Number.POSITIVE_INFINITY;for(_=h-1;_>u;_--){const e=T[_].maxBitrate,t=!T[_].details||C;if(O=this.getTimeToLoadFrag(L,P,c*e,t),O<Math.min(b,c+L))break}if(O>=R)return;if(O>10*c)return;w?this.bwEstimator.sample(d-Math.min(v,E),l.loaded):this.bwEstimator.sampleTTFB(d);const M=T[_].maxBitrate;this.getBwEstimate()*D>M&&this.resetEstimator(M);const N=this.findBestLevel(M,u,_,0,b,1,1);N>-1&&(_=N),this.warn(`Fragment ${r.sn}${i?" part "+i.index:""} of level ${h} is loading too slowly;\n Fragment duration: ${r.duration.toFixed(3)}\n Time to underbuffer: ${b.toFixed(3)} s\n Estimated load time for current fragment: ${R.toFixed(3)} s\n Estimated load time for down switch fragment: ${O.toFixed(3)} s\n TTFB estimate: ${0|E} ms\n Current BW estimate: ${lu(S)?0|S:"Unknown"} bps\n New BW estimate: ${0|this.getBwEstimate()} bps\n Switching to level ${_} @ ${0|M} bps`),n.nextLoadLevel=n.nextAutoLevel=_,this.clearTimer();const F=()=>{if(this.clearTimer(),this.fragCurrent===r&&this.hls.loadLevel===_&&_>0){const e=this.getStarvationDelay();if(this.warn(`Aborting inflight request ${_>0?"and switching down":""}\n Fragment duration: ${r.duration.toFixed(3)} s\n Time to underbuffer: ${e.toFixed(3)} s`),r.abortRequests(),this.fragCurrent=this.partCurrent=null,_>u){let t=this.findBestLevel(this.hls.levels[u].bitrate,u,_,0,e,1,1);-1===t&&(t=u),this.hls.nextLoadLevel=this.hls.nextAutoLevel=t,this.resetEstimator(this.hls.levels[t].bitrate)}}};p||R>2*O?F():this.timer=self.setInterval(F,1e3*O),n.trigger(fu.FRAG_LOAD_EMERGENCY_ABORTED,{frag:r,part:i,stats:l})},this.hls=e,this.bwEstimator=this.initEstimator(),this.registerListeners()}resetEstimator(e){e&&(this.log(`setting initial bwe to ${e}`),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()}initEstimator(){const e=this.hls.config;return new Su(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){const{hls:e}=this;e.on(fu.MANIFEST_LOADING,this.onManifestLoading,this),e.on(fu.FRAG_LOADING,this.onFragLoading,this),e.on(fu.FRAG_LOADED,this.onFragLoaded,this),e.on(fu.FRAG_BUFFERED,this.onFragBuffered,this),e.on(fu.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(fu.LEVEL_LOADED,this.onLevelLoaded,this),e.on(fu.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(fu.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(fu.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e&&(e.off(fu.MANIFEST_LOADING,this.onManifestLoading,this),e.off(fu.FRAG_LOADING,this.onFragLoading,this),e.off(fu.FRAG_LOADED,this.onFragLoaded,this),e.off(fu.FRAG_BUFFERED,this.onFragBuffered,this),e.off(fu.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(fu.LEVEL_LOADED,this.onLevelLoaded,this),e.off(fu.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(fu.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(fu.ERROR,this.onError,this))}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=this.supportedCache=null,this.fragCurrent=this.partCurrent=null}onManifestLoading(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.supportedCache={},this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()}onLevelsUpdated(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null}onMaxAutoLevelUpdated(){this.firstSelection=-1,this.nextAutoLevelKey=""}onFragLoading(e,t){const r=t.frag;if(!this.ignoreFragment(r)){var i;if(!r.bitrateTest)this.fragCurrent=r,this.partCurrent=null!=(i=t.part)?i:null;this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}}onLevelSwitching(e,t){this.clearTimer()}onError(e,t){if(!t.fatal)switch(t.details){case hu.BUFFER_ADD_CODEC_ERROR:case hu.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case hu.FRAG_LOAD_TIMEOUT:{const e=t.frag,{fragCurrent:r,partCurrent:i}=this;if(e&&r&&e.sn===r.sn&&e.level===r.level){const t=performance.now(),r=i?i.stats:e.stats,n=t-r.loading.start,s=r.loading.first?r.loading.first-r.loading.start:-1;if(r.loaded&&s>-1){const e=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(n-Math.min(e,s),r.loaded)}else this.bwEstimator.sampleTTFB(n)}break}}}getTimeToLoadFrag(e,t,r,i){return e+r/t+(i?e+this.lastLevelLoadSec:0)}onLevelLoaded(e,t){const r=this.hls.config,{loading:i}=t.stats,n=i.end-i.first;lu(n)&&(this.lastLevelLoadSec=n/1e3),t.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD),this.timer>-1&&this._abandonRulesCheck(t.levelInfo)}onFragLoaded(e,{frag:t,part:r}){const i=r?r.stats:t.stats;if(t.type===yu&&this.bwEstimator.sampleTTFB(i.loading.first-i.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),t.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){const e=r?r.duration:t.duration,n=this.hls.levels[t.level],s=(n.loaded?n.loaded.bytes:0)+i.loaded,a=(n.loaded?n.loaded.duration:0)+e;n.loaded={bytes:s,duration:a},n.realBitrate=Math.round(8*s/a)}if(t.bitrateTest){const e={stats:i,frag:t,part:r,id:t.type};this.onFragBuffered(fu.FRAG_BUFFERED,e),t.bitrateTest=!1}else this.lastLoadedFragLevel=t.level}}onFragBuffered(e,t){const{frag:r,part:i}=t,n=null!=i&&i.stats.loaded?i.stats:r.stats;if(n.aborted)return;if(this.ignoreFragment(r))return;const s=n.parsing.end-n.loading.start-Math.min(n.loading.first-n.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(s,n.loaded),n.bwEstimate=this.getBwEstimate(),r.bitrateTest?this.bitrateTestDelay=s/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==yu||"initSegment"===e.sn}clearTimer(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}get firstAutoLevel(){const{maxAutoLevel:e,minAutoLevel:t}=this.hls,r=this.getBwEstimate(),i=this.hls.config.maxStarvationDelay,n=this.findBestLevel(r,t,e,0,i,1,1);if(n>-1)return n;const s=this.hls.firstLevel,a=Math.min(Math.max(s,t),e);return this.warn(`Could not find best starting auto level. Defaulting to first in playlist ${s} clamped to ${a}`),a}get forcedAutoLevel(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}get nextAutoLevel(){const e=this.forcedAutoLevel,t=this.bwEstimator.canEstimate(),r=this.lastLoadedFragLevel>-1;if(!(-1===e||t&&r&&this.nextAutoLevelKey!==this.getAutoLevelKey()))return e;const i=t&&r?this.getNextABRAutoLevel():this.firstAutoLevel;if(-1!==e){const t=this.hls.levels;if(t.length>Math.max(e,i)&&t[e].loadError<=t[i].loadError)return e}return this._nextAutoLevel=i,this.nextAutoLevelKey=this.getAutoLevelKey(),i}getAutoLevelKey(){return`${this.getBwEstimate()}_${this.getStarvationDelay().toFixed(2)}`}getNextABRAutoLevel(){const{fragCurrent:e,partCurrent:t,hls:r}=this;if(r.levels.length<=1)return r.loadLevel;const{maxAutoLevel:i,config:n,minAutoLevel:s}=r,a=t?t.duration:e?e.duration:0,o=this.getBwEstimate(),l=this.getStarvationDelay();let c=n.abrBandWidthFactor,d=n.abrBandWidthUpFactor;if(l){const e=this.findBestLevel(o,s,i,l,0,c,d);if(e>=0)return this.rebufferNotice=-1,e}let u=a?Math.min(a,n.maxStarvationDelay):n.maxStarvationDelay;if(!l){const e=this.bitrateTestDelay;if(e){u=(a?Math.min(a,n.maxLoadingDelay):n.maxLoadingDelay)-e,this.info(`bitrate test took ${Math.round(1e3*e)}ms, set first fragment max fetchDuration to ${Math.round(1e3*u)} ms`),c=d=1}}const h=this.findBestLevel(o,s,i,l,u,c,d);if(this.rebufferNotice!==h&&(this.rebufferNotice=h,this.info(`${l?"rebuffering expected":"buffer is empty"}, optimal quality level ${h}`)),h>-1)return h;const f=r.levels[s],p=r.loadLevelObj;return p&&(null==f?void 0:f.bitrate)<p.bitrate?s:r.loadLevel}getStarvationDelay(){const e=this.hls,t=e.media;if(!t)return 1/0;const r=t&&0!==t.playbackRate?Math.abs(t.playbackRate):1,i=e.mainForwardBufferInfo;return(i?i.len:0)/r}getBwEstimate(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}findBestLevel(e,t,r,i,n,s,a){var o;const l=i+n,c=this.lastLoadedFragLevel,d=-1===c?this.hls.firstLevel:c,{fragCurrent:u,partCurrent:h}=this,{levels:f,allAudioTracks:p,loadLevel:m,config:g}=this.hls;if(1===f.length)return 0;const v=f[d],y=!(null==(o=this.hls.latestLevelDetails)||!o.live),b=-1===m||-1===c;let E,w="SDR",S=(null==v?void 0:v.frameRate)||0;const{audioPreference:T,videoPreference:x}=g,A=this.audioTracksByGroup||(this.audioTracksByGroup=uf(p));let k=-1;if(b){if(-1!==this.firstSelection)return this.firstSelection;const i=this.codecTiers||(this.codecTiers=function(e,t,r,i){return e.slice(r,i+1).reduce((e,r,i)=>{if(!r.codecSet)return e;const n=r.audioGroups;let s=e[r.codecSet];s||(e[r.codecSet]=s={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:i,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!n,fragmentError:0}),s.minBitrate=Math.min(s.minBitrate,r.bitrate);const a=Math.min(r.height,r.width);return s.minHeight=Math.min(s.minHeight,a),s.minFramerate=Math.min(s.minFramerate,r.frameRate),s.minIndex=Math.min(s.minIndex,i),s.maxScore=Math.max(s.maxScore,r.score),s.fragmentError+=r.fragmentError,s.videoRanges[r.videoRange]=(s.videoRanges[r.videoRange]||0)+1,n&&n.forEach(e=>{if(!e)return;const r=t.groups[e];r&&(s.hasDefaultAudio=s.hasDefaultAudio||t.hasDefaultAudio?r.hasDefault:r.hasAutoSelect||!t.hasDefaultAudio&&!t.hasAutoSelectAudio,Object.keys(r.channels).forEach(e=>{s.channels[e]=(s.channels[e]||0)+r.channels[e]}))}),e},{})}(f,A,t,r)),n=function(e,t,r,i,n){const s=Object.keys(e),a=null==i?void 0:i.channels,o=null==i?void 0:i.audioCodec,l=null==n?void 0:n.videoCodec,c=a&&2===parseInt(a);let d=!1,u=!1,h=1/0,f=1/0,p=1/0,m=1/0,g=0,v=[];const{preferHDR:y,allowedVideoRanges:b}=lf(t,n);for(let t=s.length;t--;){const r=e[s[t]];d||(d=r.channels[2]>0),h=Math.min(h,r.minHeight),f=Math.min(f,r.minFramerate),p=Math.min(p,r.minBitrate),b.filter(e=>r.videoRanges[e]>0).length>0&&(u=!0)}h=lu(h)?h:0,f=lu(f)?f:0;const E=Math.max(1080,h),w=Math.max(30,f);p=lu(p)?p:r,r=Math.max(p,r),u||(t=void 0);const S=s.length>1;return{codecSet:s.reduce((t,i)=>{const n=e[i];if(i===t)return t;if(v=u?b.filter(e=>n.videoRanges[e]>0):[],S){if(n.minBitrate>r)return df(i,`min bitrate of ${n.minBitrate} > current estimate of ${r}`),t;if(!n.hasDefaultAudio)return df(i,"no renditions with default or auto-select sound found"),t;if(o&&i.indexOf(o.substring(0,4))%5!=0)return df(i,`audio codec preference "${o}" not found`),t;if(a&&!c){if(!n.channels[a])return df(i,`no renditions with ${a} channel sound found (channels options: ${Object.keys(n.channels)})`),t}else if((!o||c)&&d&&0===n.channels[2])return df(i,"no renditions with stereo sound found"),t;if(n.minHeight>E)return df(i,`min resolution of ${n.minHeight} > maximum of ${E}`),t;if(n.minFramerate>w)return df(i,`min framerate of ${n.minFramerate} > maximum of ${w}`),t;if(!v.some(e=>n.videoRanges[e]>0))return df(i,`no variants with VIDEO-RANGE of ${cf(v)} found`),t;if(l&&i.indexOf(l.substring(0,4))%5!=0)return df(i,`video codec preference "${l}" not found`),t;if(n.maxScore<g)return df(i,`max score of ${n.maxScore} < selected max of ${g}`),t}return t&&(Nh(i)>=Nh(t)||n.fragmentError>e[t].fragmentError)?t:(m=n.minIndex,g=n.maxScore,i)},void 0),videoRanges:v,preferHDR:y,minFramerate:f,minBitrate:p,minIndex:m}}(i,w,e,T,x),{codecSet:s,videoRanges:a,minFramerate:o,minBitrate:l,minIndex:c,preferHDR:d}=n;k=c,E=s,w=d?a[a.length-1]:a[0],S=o,e=Math.max(e,l),this.log(`picked start tier ${cf(n)}`)}else E=null==v?void 0:v.codecSet,w=null==v?void 0:v.videoRange;const I=h?h.duration:u?u.duration:0,L=this.bwEstimator.getEstimateTTFB()/1e3,R=[];for(let o=r;o>=t;o--){var P;const t=f[o],u=o>d;if(!t)continue;if(g.useMediaCapabilities&&!t.supportedResult&&!t.supportedPromise){const r=navigator.mediaCapabilities;"function"==typeof(null==r?void 0:r.decodingInfo)&&Kh(t,A,w,S,e,T)?(t.supportedPromise=qh(t,A,r,this.supportedCache),t.supportedPromise.then(e=>{if(!this.hls)return;t.supportedResult=e;const r=this.hls.levels,i=r.indexOf(t);e.error?this.warn(`MediaCapabilities decodingInfo error: "${e.error}" for level ${i} ${cf(e)}`):e.supported?e.decodingInfoResults.some(e=>!1===e.smooth||!1===e.powerEfficient)&&this.log(`MediaCapabilities decodingInfo for level ${i} not smooth or powerEfficient: ${cf(e)}`):(this.warn(`Unsupported MediaCapabilities decodingInfo result for level ${i} ${cf(e)}`),i>-1&&r.length>1&&(this.log(`Removing unsupported level ${i}`),this.hls.removeLevel(i),-1===this.hls.loadLevel&&(this.hls.nextLoadLevel=0)))}).catch(e=>{this.warn(`Error handling MediaCapabilities decodingInfo: ${e}`)})):t.supportedResult=Wh}if((E&&t.codecSet!==E||w&&t.videoRange!==w||u&&S>t.frameRate||!u&&S>0&&S<t.frameRate||null!=(P=t.supportedResult)&&null!=(P=P.decodingInfoResults)&&P.some(e=>!1===e.smooth))&&(!b||o!==k)){R.push(o);continue}const p=t.details,v=(h?null==p?void 0:p.partTarget:null==p?void 0:p.averagetargetduration)||I;let x;x=u?a*e:s*e;const C=I&&i>=2*I&&0===n?t.averageBitrate:t.maxBitrate,D=this.getTimeToLoadFrag(L,x,C*v,void 0===p);if(x>=C&&(o===c||0===t.loadError&&0===t.fragmentError)&&(D<=L||!lu(D)||y&&!this.bitrateTestDelay||D<l)){const e=this.forcedAutoLevel;return o===m||-1!==e&&e===m||(R.length&&this.trace(`Skipped level(s) ${R.join(",")} of ${r} max with CODECS and VIDEO-RANGE:"${f[R[0]].codecs}" ${f[R[0]].videoRange}; not compatible with "${E}" ${w}`),this.info(`switch candidate:${d}->${o} adjustedbw(${Math.round(x)})-bitrate=${Math.round(x-C)} ttfb:${L.toFixed(1)} avgDuration:${v.toFixed(1)} maxFetchDuration:${l.toFixed(1)} fetchDuration:${D.toFixed(1)} firstSelection:${b} codecSet:${t.codecSet} videoRange:${t.videoRange} hls.loadLevel:${m}`)),b&&(this.firstSelection=o),o}}return-1}set nextAutoLevel(e){const t=this.deriveNextAutoLevel(e);this._nextAutoLevel!==t&&(this.nextAutoLevelKey="",this._nextAutoLevel=t)}deriveNextAutoLevel(e){const{maxAutoLevel:t,minAutoLevel:r}=this.hls;return Math.min(Math.max(e,r),t)}},bufferController:class extends Iu{constructor(e,t){var r;super("buffer-controller",e.logger),this.hls=void 0,this.fragmentTracker=void 0,this.details=null,this._objectUrl=null,this.operationQueue=null,this.bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.blockedAudioAppend=null,this.lastVideoAppendEnd=0,this.appendSource=void 0,this.transferData=void 0,this.overrides=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.sourceBuffers=[[null,null],[null,null]],this._onEndStreaming=e=>{var t;this.hls&&"open"===(null==(t=this.mediaSource)?void 0:t.readyState)&&this.hls.pauseBuffering()},this._onStartStreaming=e=>{this.hls&&this.hls.resumeBuffering()},this._onMediaSourceOpen=e=>{const{media:t,mediaSource:r}=this;e&&this.log("Media source opened"),t&&r&&(r.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("emptied",this._onMediaEmptied),this.updateDuration(),this.hls.trigger(fu.MEDIA_ATTACHED,{media:t,mediaSource:r}),null!==this.mediaSource&&this.checkPendingTracks())},this._onMediaSourceClose=()=>{this.log("Media source closed")},this._onMediaSourceEnded=()=>{this.log("Media source ended")},this._onMediaEmptied=()=>{const{mediaSrc:e,_objectUrl:t}=this;e!==t&&this.error(`Media element src was set while attaching MediaSource (${t} > ${e})`)},this.hls=e,this.fragmentTracker=t,this.appendSource=(r=Ou(e.config.preferManagedMediaSource),"undefined"!=typeof self&&r===self.ManagedMediaSource),this.initTracks(),this.registerListeners()}hasSourceTypes(){return Object.keys(this.tracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.transferData=this.overrides=void 0,this.operationQueue&&(this.operationQueue.destroy(),this.operationQueue=null),this.hls=this.fragmentTracker=null,this._onMediaSourceOpen=this._onMediaSourceClose=null,this._onMediaSourceEnded=null,this._onStartStreaming=this._onEndStreaming=null}registerListeners(){const{hls:e}=this;e.on(fu.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(fu.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(fu.MANIFEST_LOADING,this.onManifestLoading,this),e.on(fu.MANIFEST_PARSED,this.onManifestParsed,this),e.on(fu.BUFFER_RESET,this.onBufferReset,this),e.on(fu.BUFFER_APPENDING,this.onBufferAppending,this),e.on(fu.BUFFER_CODECS,this.onBufferCodecs,this),e.on(fu.BUFFER_EOS,this.onBufferEos,this),e.on(fu.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(fu.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(fu.FRAG_PARSED,this.onFragParsed,this),e.on(fu.FRAG_CHANGED,this.onFragChanged,this),e.on(fu.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(fu.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(fu.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(fu.MANIFEST_LOADING,this.onManifestLoading,this),e.off(fu.MANIFEST_PARSED,this.onManifestParsed,this),e.off(fu.BUFFER_RESET,this.onBufferReset,this),e.off(fu.BUFFER_APPENDING,this.onBufferAppending,this),e.off(fu.BUFFER_CODECS,this.onBufferCodecs,this),e.off(fu.BUFFER_EOS,this.onBufferEos,this),e.off(fu.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(fu.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(fu.FRAG_PARSED,this.onFragParsed,this),e.off(fu.FRAG_CHANGED,this.onFragChanged,this),e.off(fu.ERROR,this.onError,this)}transferMedia(){const{media:e,mediaSource:t}=this;if(!e)return null;const r={};if(this.operationQueue){const e=this.isUpdating();e||this.operationQueue.removeBlockers();const t=this.isQueued();(e||t)&&this.warn(`Transfering MediaSource with${t?" operations in queue":""}${e?" updating SourceBuffer(s)":""} ${this.operationQueue}`),this.operationQueue.destroy()}const i=this.transferData;return!this.sourceBufferCount&&i&&i.mediaSource===t?xu(r,i.tracks):this.sourceBuffers.forEach(e=>{const[t]=e;t&&(r[t]=xu({},this.tracks[t]),this.removeBuffer(t)),e[0]=e[1]=null}),{media:e,mediaSource:t,tracks:r}}initTracks(){this.sourceBuffers=[[null,null],[null,null]],this.tracks={},this.resetQueue(),this.resetAppendErrors(),this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.lastVideoAppendEnd=0}onManifestLoading(){this.bufferCodecEventsTotal=0,this.details=null}onManifestParsed(e,t){var r;let i=2;(t.audio&&!t.video||!t.altAudio)&&(i=1),this.bufferCodecEventsTotal=i,this.log(`${i} bufferCodec event(s) expected.`),null!=(r=this.transferData)&&r.mediaSource&&this.sourceBufferCount&&i&&this.bufferCreated()}onMediaAttaching(e,t){const r=this.media=t.media;this.transferData=this.overrides=void 0;const i=Ou(this.appendSource);if(i){const e=!!t.mediaSource;(e||t.overrides)&&(this.transferData=t,this.overrides=t.overrides);const n=this.mediaSource=t.mediaSource||new i;if(this.assignMediaSource(n),e)this._objectUrl=r.src,this.attachTransferred();else{const e=this._objectUrl=self.URL.createObjectURL(n);if(this.appendSource)try{r.removeAttribute("src");const t=self.ManagedMediaSource;r.disableRemotePlayback=r.disableRemotePlayback||t&&n instanceof t,kv(r),function(e,t){const r=self.document.createElement("source");r.type="video/mp4",r.src=t,e.appendChild(r)}(r,e),r.load()}catch(t){r.src=e}else r.src=e}r.addEventListener("emptied",this._onMediaEmptied)}}assignMediaSource(e){var t,r;this.log(`${(null==(t=this.transferData)?void 0:t.mediaSource)===e?"transferred":"created"} media source: ${null==(r=e.constructor)?void 0:r.name}`),e.addEventListener("sourceopen",this._onMediaSourceOpen),e.addEventListener("sourceended",this._onMediaSourceEnded),e.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(e.addEventListener("startstreaming",this._onStartStreaming),e.addEventListener("endstreaming",this._onEndStreaming))}attachTransferred(){const e=this.media,t=this.transferData;if(!t||!e)return;const r=this.tracks,i=t.tracks,n=i?Object.keys(i):null,s=n?n.length:0,a=()=>{Promise.resolve().then(()=>{this.media&&this.mediaSourceOpenOrEnded&&this._onMediaSourceOpen()})};if(i&&n&&s){if(!this.tracksReady)return this.hls.config.startFragPrefetch=!0,void this.log("attachTransferred: waiting for SourceBuffer track info");if(this.log(`attachTransferred: (bufferCodecEventsTotal ${this.bufferCodecEventsTotal})\nrequired tracks: ${cf(r,(e,t)=>"initSegment"===e?void 0:t)};\ntransfer tracks: ${cf(i,(e,t)=>"initSegment"===e?void 0:t)}}`),!Mu(i,r)){t.mediaSource=null,t.tracks=void 0;const n=e.currentTime,s=this.details,a=Math.max(n,(null==s?void 0:s.fragments[0].start)||0);return a-n>1?void this.log(`attachTransferred: waiting for playback to reach new tracks start time ${n} -> ${a}`):(this.warn(`attachTransferred: resetting MediaSource for incompatible tracks ("${Object.keys(i)}"->"${Object.keys(r)}") start time: ${a} currentTime: ${n}`),this.onMediaDetaching(fu.MEDIA_DETACHING,{}),this.onMediaAttaching(fu.MEDIA_ATTACHING,t),void(e.currentTime=a))}this.transferData=void 0,n.forEach(e=>{const t=e,r=i[t];if(r){const e=r.buffer;if(e){const i=this.fragmentTracker,n=r.id;if(i.hasFragments(n)||i.hasParts(n)){const r=lp.getBuffered(e);i.detectEvictedFragments(t,r,n,null,!0)}const s=Iv(t),a=[t,e];this.sourceBuffers[s]=a,e.updating&&this.operationQueue&&this.operationQueue.prependBlocker(t),this.trackSourceBuffer(t,r)}}}),a(),this.bufferCreated()}else this.log("attachTransferred: MediaSource w/o SourceBuffers"),a()}get mediaSourceOpenOrEnded(){var e;const t=null==(e=this.mediaSource)?void 0:e.readyState;return"open"===t||"ended"===t}onMediaDetaching(e,t){const r=!!t.transferMedia;this.transferData=this.overrides=void 0;const{media:i,mediaSource:n,_objectUrl:s}=this;if(n){if(this.log("media source "+(r?"transferring":"detaching")),r)this.sourceBuffers.forEach(([e])=>{e&&this.removeBuffer(e)}),this.resetQueue();else{if(this.mediaSourceOpenOrEnded){const e="open"===n.readyState;try{const t=n.sourceBuffers;for(let r=t.length;r--;)e&&t[r].abort(),n.removeSourceBuffer(t[r]);e&&n.endOfStream()}catch(e){this.warn(`onMediaDetaching: ${e.message} while calling endOfStream`)}}this.sourceBufferCount&&this.onBufferReset()}n.removeEventListener("sourceopen",this._onMediaSourceOpen),n.removeEventListener("sourceended",this._onMediaSourceEnded),n.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(n.removeEventListener("startstreaming",this._onStartStreaming),n.removeEventListener("endstreaming",this._onEndStreaming)),this.mediaSource=null,this._objectUrl=null}i&&(i.removeEventListener("emptied",this._onMediaEmptied),r||(s&&self.URL.revokeObjectURL(s),this.mediaSrc===s?(i.removeAttribute("src"),this.appendSource&&kv(i),i.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null),this.hls.trigger(fu.MEDIA_DETACHED,t)}onBufferReset(){this.sourceBuffers.forEach(([e])=>{e&&this.resetBuffer(e)}),this.initTracks()}resetBuffer(e){var t;const r=null==(t=this.tracks[e])?void 0:t.buffer;if(this.removeBuffer(e),r)try{var i;null!=(i=this.mediaSource)&&i.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(r)}catch(t){this.warn(`onBufferReset ${e}`,t)}delete this.tracks[e]}removeBuffer(e){this.removeBufferListeners(e),this.sourceBuffers[Iv(e)]=[null,null];const t=this.tracks[e];t&&(t.buffer=void 0)}resetQueue(){this.operationQueue&&this.operationQueue.destroy(),this.operationQueue=new Sv(this.tracks)}onBufferCodecs(e,t){var r;const i=this.tracks,n=Object.keys(t);this.log(`BUFFER_CODECS: "${n}" (current SB count ${this.sourceBufferCount})`);const s="audiovideo"in t&&(i.audio||i.video)||i.audiovideo&&("audio"in t||"video"in t),a=!s&&this.sourceBufferCount&&this.media&&n.some(e=>!i[e]);s||a?this.warn(`Unsupported transition between "${Object.keys(i)}" and "${n}" SourceBuffers`):(n.forEach(e=>{var r,n;const s=t[e],{id:a,codec:o,levelCodec:l,container:c,metadata:d,supplemental:u}=s;let h=i[e];const f=null==(r=this.transferData)||null==(r=r.tracks)?void 0:r[e],p=null!=f&&f.buffer?f:h,m=(null==p?void 0:p.pendingCodec)||(null==p?void 0:p.codec),g=null==p?void 0:p.levelCodec;h||(h=i[e]={buffer:void 0,listeners:[],codec:o,supplemental:u,container:c,levelCodec:l,metadata:d,id:a});const v=Uh(m,g),y=null==v?void 0:v.replace(Tv,"$1");let b=Uh(o,l);const E=null==(n=b)?void 0:n.replace(Tv,"$1");b&&v&&y!==E&&("audio"===e.slice(0,5)&&(b=Bh(b,this.appendSource)),this.log(`switching codec ${m} to ${b}`),b!==(h.pendingCodec||h.codec)&&(h.pendingCodec=b),h.container=c,this.appendChangeType(e,c,b))}),(this.tracksReady||this.sourceBufferCount)&&(t.tracks=this.sourceBufferTracks),this.sourceBufferCount||(this.bufferCodecEventsTotal>1&&!this.tracks.video&&!t.video&&"main"===(null==(r=t.audio)?void 0:r.id)&&(this.log("Main audio-only"),this.bufferCodecEventsTotal=1),this.mediaSourceOpenOrEnded&&this.checkPendingTracks()))}get sourceBufferTracks(){return Object.keys(this.tracks).reduce((e,t)=>{const r=this.tracks[t];return e[t]={id:r.id,container:r.container,codec:r.codec,levelCodec:r.levelCodec},e},{})}appendChangeType(e,t,r){const i=`${t};codecs=${r}`,n={label:`change-type=${i}`,execute:()=>{const n=this.tracks[e];if(n){const s=n.buffer;null!=s&&s.changeType&&(this.log(`changing ${e} sourceBuffer type to ${i}`),s.changeType(i),n.codec=r,n.container=t)}this.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:t=>{this.warn(`Failed to change ${e} SourceBuffer type`,t)}};this.append(n,e,this.isPending(this.tracks[e]))}blockAudio(e){var t;const r=e.start,i=r+.05*e.duration;if(!0===(null==(t=this.fragmentTracker.getAppendedFrag(r,yu))?void 0:t.gap))return;const n={label:"block-audio",execute:()=>{var e;const t=this.tracks.video;(this.lastVideoAppendEnd>i||null!=t&&t.buffer&&lp.isBuffered(t.buffer,i)||!0===(null==(e=this.fragmentTracker.getAppendedFrag(i,yu))?void 0:e.gap))&&(this.blockedAudioAppend=null,this.shiftAndExecuteNext("audio"))},onStart:()=>{},onComplete:()=>{},onError:e=>{this.warn("Error executing block-audio operation",e)}};this.blockedAudioAppend={op:n,frag:e},this.append(n,"audio",!0)}unblockAudio(){const{blockedAudioAppend:e,operationQueue:t}=this;e&&t&&(this.blockedAudioAppend=null,t.unblockAudio(e.op))}onBufferAppending(e,t){const{tracks:r}=this,{data:i,type:n,parent:s,frag:a,part:o,chunkMeta:l,offset:c}=t,d=l.buffering[n],{sn:u,cc:h}=a,f=self.performance.now();d.start=f;const p=a.stats.buffering,m=o?o.stats.buffering:null;0===p.start&&(p.start=f),m&&0===m.start&&(m.start=f);const g=r.audio;let v=!1;"audio"===n&&"audio/mpeg"===(null==g?void 0:g.container)&&(v=!this.lastMpegAudioChunk||1===l.id||this.lastMpegAudioChunk.sn!==l.sn,this.lastMpegAudioChunk=l);const y=r.video,b=null==y?void 0:y.buffer;if(b&&"initSegment"!==u){const e=o||a,t=this.blockedAudioAppend;if("audio"!==n||"main"===s||this.blockedAudioAppend||y.ending||y.ended){if("video"===n){const r=e.end;if(t){const e=t.frag.start;(r>e||r<this.lastVideoAppendEnd||lp.isBuffered(b,e))&&this.unblockAudio()}this.lastVideoAppendEnd=r}}else{const t=e.start+.05*e.duration,r=b.buffered,i=this.currentOp("video");r.length||i?!i&&!lp.isBuffered(b,t)&&this.lastVideoAppendEnd<t&&this.blockAudio(e):this.blockAudio(e)}}const E=(o||a).start,w={label:`append-${n}`,execute:()=>{var e;d.executeStart=self.performance.now();const t=null==(e=this.tracks[n])?void 0:e.buffer;t&&(v?this.updateTimestampOffset(t,E,.1,n,u,h):void 0!==c&&lu(c)&&this.updateTimestampOffset(t,c,1e-6,n,u,h)),this.appendExecutor(i,n)},onStart:()=>{},onComplete:()=>{const e=self.performance.now();d.executeEnd=d.end=e,0===p.first&&(p.first=e),m&&0===m.first&&(m.first=e);const t={};this.sourceBuffers.forEach(([e,r])=>{e&&(t[e]=lp.getBuffered(r))}),this.appendErrors[n]=0,"audio"===n||"video"===n?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger(fu.BUFFER_APPENDED,{type:n,frag:a,part:o,chunkMeta:l,parent:a.type,timeRanges:t})},onError:e=>{var t;const r={type:uu.MEDIA_ERROR,parent:a.type,details:hu.BUFFER_APPEND_ERROR,sourceBufferName:n,frag:a,part:o,chunkMeta:l,error:e,err:e,fatal:!1},i=null==(t=this.media)?void 0:t.error;if(e.code===DOMException.QUOTA_EXCEEDED_ERR||"QuotaExceededError"==e.name||"quota"in e)r.details=hu.BUFFER_FULL_ERROR;else if(e.code===DOMException.INVALID_STATE_ERR&&this.mediaSourceOpenOrEnded&&!i)r.errorAction=Bf(!0);else if(e.name===xv&&0===this.sourceBufferCount)r.errorAction=Bf(!0);else{const e=++this.appendErrors[n];this.warn(`Failed ${e}/${this.hls.config.appendErrorMaxRetry} times to append segment in "${n}" sourceBuffer (${i||"no media error"})`),(e>=this.hls.config.appendErrorMaxRetry||i)&&(r.fatal=!0)}this.hls.trigger(fu.ERROR,r)}};this.log(`queuing "${n}" append sn: ${u}${o?" p: "+o.index:""} of ${a.type===yu?"level":"track"} ${a.level} cc: ${h}`),this.append(w,n,this.isPending(this.tracks[n]))}getFlushOp(e,t,r){return this.log(`queuing "${e}" remove ${t}-${r}`),{label:"remove",execute:()=>{this.removeExecutor(e,t,r)},onStart:()=>{},onComplete:()=>{this.hls.trigger(fu.BUFFER_FLUSHED,{type:e})},onError:i=>{this.warn(`Failed to remove ${t}-${r} from "${e}" SourceBuffer`,i)}}}onBufferFlushing(e,t){const{type:r,startOffset:i,endOffset:n}=t;r?this.append(this.getFlushOp(r,i,n),r):this.sourceBuffers.forEach(([e])=>{e&&this.append(this.getFlushOp(e,i,n),e)})}onFragParsed(e,t){const{frag:r,part:i}=t,n=[],s=i?i.elementaryStreams:r.elementaryStreams;s[Qu]?n.push("audiovideo"):(s[qu]&&n.push("audio"),s[Xu]&&n.push("video"));0===n.length&&this.warn(`Fragments must have at least one ElementaryStreamType set. type: ${r.type} level: ${r.level} sn: ${r.sn}`),this.blockBuffers(()=>{const e=self.performance.now();r.stats.buffering.end=e,i&&(i.stats.buffering.end=e);const t=i?i.stats:r.stats;this.hls.trigger(fu.FRAG_BUFFERED,{frag:r,part:i,stats:t,id:r.type})},n).catch(e=>{this.warn(`Fragment buffered callback ${e}`),this.stepOperationQueue(this.sourceBufferTypes)})}onFragChanged(e,t){this.trimBuffers()}get bufferedToEnd(){return this.sourceBufferCount>0&&!this.sourceBuffers.some(([e])=>{if(e){const t=this.tracks[e];if(t)return!t.ended||t.ending}return!1})}onBufferEos(e,t){var r;this.sourceBuffers.forEach(([e])=>{if(e){const r=this.tracks[e];t.type&&t.type!==e||(r.ending=!0,r.ended||(r.ended=!0,this.log(`${e} buffer reached EOS`)))}});const i=!1!==(null==(r=this.overrides)?void 0:r.endOfStream);this.sourceBufferCount>0&&!this.sourceBuffers.some(([e])=>{var t;return e&&!(null!=(t=this.tracks[e])&&t.ended)})?i?(this.log("Queueing EOS"),this.blockUntilOpen(()=>{this.tracksEnded();const{mediaSource:e}=this;e&&"open"===e.readyState?(this.log("Calling mediaSource.endOfStream()"),e.endOfStream(),this.hls.trigger(fu.BUFFERED_TO_END,void 0)):e&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${e.readyState}`)})):(this.tracksEnded(),this.hls.trigger(fu.BUFFERED_TO_END,void 0)):"video"===t.type&&this.unblockAudio()}tracksEnded(){this.sourceBuffers.forEach(([e])=>{if(null!==e){const t=this.tracks[e];t&&(t.ending=!1)}})}onLevelUpdated(e,{details:t}){t.fragments.length&&(this.details=t,this.updateDuration())}updateDuration(){this.blockUntilOpen(()=>{const e=this.getDurationAndRange();e&&this.updateMediaSource(e)})}onError(e,t){if(t.details===hu.BUFFER_APPEND_ERROR&&t.frag){var r;const e=null==(r=t.errorAction)?void 0:r.nextAutoLevel;lu(e)&&e!==t.frag.level&&this.resetAppendErrors()}}resetAppendErrors(){this.appendErrors={audio:0,video:0,audiovideo:0}}trimBuffers(){const{hls:e,details:t,media:r}=this;if(!r||null===t)return;if(!this.sourceBufferCount)return;const i=e.config,n=r.currentTime,s=t.levelTargetDuration,a=t.live&&null!==i.liveBackBufferLength?i.liveBackBufferLength:i.backBufferLength;if(lu(a)&&a>=0){const e=Math.max(a,s),t=Math.floor(n/s)*s-e;this.flushBackBuffer(n,s,t)}const o=i.frontBufferFlushThreshold;if(lu(o)&&o>0){const e=Math.max(i.maxBufferLength,o),t=Math.max(e,s),r=Math.floor(n/s)*s+t;this.flushFrontBuffer(n,s,r)}}flushBackBuffer(e,t,r){this.sourceBuffers.forEach(([e,t])=>{if(t){const n=lp.getBuffered(t);if(n.length>0&&r>n.start(0)){var i;this.hls.trigger(fu.BACK_BUFFER_REACHED,{bufferEnd:r});const t=this.tracks[e];if(null!=(i=this.details)&&i.live)this.hls.trigger(fu.LIVE_BACK_BUFFER_REACHED,{bufferEnd:r});else if(null!=t&&t.ended)return void this.log(`Cannot flush ${e} back buffer while SourceBuffer is in ended state`);this.hls.trigger(fu.BUFFER_FLUSHING,{startOffset:0,endOffset:r,type:e})}}})}flushFrontBuffer(e,t,r){this.sourceBuffers.forEach(([t,i])=>{if(i){const n=lp.getBuffered(i),s=n.length;if(s<2)return;const a=n.start(s-1),o=n.end(s-1);if(r>a||e>=a&&e<=o)return;this.hls.trigger(fu.BUFFER_FLUSHING,{startOffset:a,endOffset:1/0,type:t})}})}getDurationAndRange(){var e;const{details:t,mediaSource:r}=this;if(!t||!this.media||"open"!==(null==r?void 0:r.readyState))return null;const i=t.edge;if(t.live&&this.hls.config.liveDurationInfinity){if(t.fragments.length&&r.setLiveSeekableRange){const e=Math.max(0,t.fragmentStart);return{duration:1/0,start:e,end:Math.max(e,i)}}return{duration:1/0}}const n=null==(e=this.overrides)?void 0:e.duration;if(n)return lu(n)?{duration:n}:null;const s=this.media.duration;return i>(lu(r.duration)?r.duration:0)&&i>s||!lu(s)?{duration:i}:null}updateMediaSource({duration:e,start:t,end:r}){const i=this.mediaSource;this.media&&i&&"open"===i.readyState&&(i.duration!==e&&(lu(e)&&this.log(`Updating MediaSource duration to ${e.toFixed(3)}`),i.duration=e),void 0!==t&&void 0!==r&&(this.log(`MediaSource duration is set to ${i.duration}. Setting seekable range to ${t}-${r}.`),i.setLiveSeekableRange(t,r)))}get tracksReady(){const e=this.pendingTrackCount;return e>0&&(e>=this.bufferCodecEventsTotal||this.isPending(this.tracks.audiovideo))}checkPendingTracks(){const{bufferCodecEventsTotal:e,pendingTrackCount:t,tracks:r}=this;if(this.log(`checkPendingTracks (pending: ${t} codec events expected: ${e}) ${cf(r)}`),this.tracksReady){var i;const e=null==(i=this.transferData)?void 0:i.tracks;e&&Object.keys(e).length?this.attachTransferred():this.createSourceBuffers()}}bufferCreated(){if(this.sourceBufferCount){const e={};this.sourceBuffers.forEach(([t,r])=>{if(t){const i=this.tracks[t];e[t]={buffer:r,container:i.container,codec:i.codec,supplemental:i.supplemental,levelCodec:i.levelCodec,id:i.id,metadata:i.metadata}}}),this.hls.trigger(fu.BUFFER_CREATED,{tracks:e}),this.log(`SourceBuffers created. Running queue: ${this.operationQueue}`),this.sourceBuffers.forEach(([e])=>{this.executeNext(e)})}else{const e=new Error("could not create source buffer for media codec(s)");this.hls.trigger(fu.ERROR,{type:uu.MEDIA_ERROR,details:hu.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:e,reason:e.message})}}createSourceBuffers(){const{tracks:e,sourceBuffers:t,mediaSource:r}=this;if(!r)throw new Error("createSourceBuffers called when mediaSource was null");for(const n in e){const s=n,a=e[s];if(this.isPending(a)){const e=this.getTrackCodec(a,s),n=`${a.container};codecs=${e}`;a.codec=e,this.log(`creating sourceBuffer(${n})${this.currentOp(s)?" Queued":""} ${cf(a)}`);try{const e=r.addSourceBuffer(n),i=Iv(s),o=[s,e];t[i]=o,a.buffer=e}catch(e){var i;return this.error(`error while trying to add sourceBuffer: ${e.message}`),this.shiftAndExecuteNext(s),null==(i=this.operationQueue)||i.removeBlockers(),delete this.tracks[s],void this.hls.trigger(fu.ERROR,{type:uu.MEDIA_ERROR,details:hu.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:e,sourceBufferName:s,mimeType:n,parent:a.id})}this.trackSourceBuffer(s,a)}}this.bufferCreated()}getTrackCodec(e,t){const r=e.supplemental;let i=e.codec;r&&("video"===t||"audiovideo"===t)&&Dh(r,"video")&&(i=function(e,t){const r=[];if(e){const t=e.split(",");for(let e=0;e<t.length;e++)Ch(t[e],"video")||r.push(t[e])}return t&&r.push(t),r.join(",")}(i,r));const n=Uh(i,e.levelCodec);return n?"audio"===t.slice(0,5)?Bh(n,this.appendSource):n:""}trackSourceBuffer(e,t){const r=t.buffer;if(!r)return;const i=this.getTrackCodec(t,e);this.tracks[e]={buffer:r,codec:i,container:t.container,levelCodec:t.levelCodec,supplemental:t.supplemental,metadata:t.metadata,id:t.id,listeners:[]},this.removeBufferListeners(e),this.addBufferListener(e,"updatestart",this.onSBUpdateStart),this.addBufferListener(e,"updateend",this.onSBUpdateEnd),this.addBufferListener(e,"error",this.onSBUpdateError),this.appendSource&&this.addBufferListener(e,"bufferedchange",(e,t)=>{const r=t.removedRanges;null!=r&&r.length&&this.hls.trigger(fu.BUFFER_FLUSHED,{type:e})})}get mediaSrc(){var e,t;const r=(null==(e=this.media)||null==(t=e.querySelector)?void 0:t.call(e,"source"))||this.media;return null==r?void 0:r.src}onSBUpdateStart(e){const t=this.currentOp(e);t&&t.onStart()}onSBUpdateEnd(e){var t;if("closed"===(null==(t=this.mediaSource)?void 0:t.readyState))return void this.resetBuffer(e);const r=this.currentOp(e);r&&(r.onComplete(),this.shiftAndExecuteNext(e))}onSBUpdateError(e,t){var r;const i=new Error(`${e} SourceBuffer error. MediaSource readyState: ${null==(r=this.mediaSource)?void 0:r.readyState}`);this.error(`${i}`,t),this.hls.trigger(fu.ERROR,{type:uu.MEDIA_ERROR,details:hu.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:i,fatal:!1});const n=this.currentOp(e);n&&n.onError(i)}updateTimestampOffset(e,t,r,i,n,s){const a=t-e.timestampOffset;Math.abs(a)>=r&&(this.log(`Updating ${i} SourceBuffer timestampOffset to ${t} (sn: ${n} cc: ${s})`),e.timestampOffset=t)}removeExecutor(e,t,r){const{media:i,mediaSource:n}=this,s=this.tracks[e],a=null==s?void 0:s.buffer;if(!i||!n||!a)return this.warn(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`),void this.shiftAndExecuteNext(e);const o=lu(i.duration)?i.duration:1/0,l=lu(n.duration)?n.duration:1/0,c=Math.max(0,t),d=Math.min(r,o,l);d>c&&(!s.ending||s.ended)?(s.ended=!1,this.log(`Removing [${c},${d}] from the ${e} SourceBuffer`),a.remove(c,d)):this.shiftAndExecuteNext(e)}appendExecutor(e,t){const r=this.tracks[t],i=null==r?void 0:r.buffer;if(!i)throw new Av(`Attempting to append to the ${t} SourceBuffer, but it does not exist`);r.ending=!1,r.ended=!1,i.appendBuffer(e)}blockUntilOpen(e){if(this.isUpdating()||this.isQueued())this.blockBuffers(e).catch(e=>{this.warn(`SourceBuffer blocked callback ${e}`),this.stepOperationQueue(this.sourceBufferTypes)});else try{e()}catch(e){this.warn(`Callback run without blocking ${this.operationQueue} ${e}`)}}isUpdating(){return this.sourceBuffers.some(([e,t])=>e&&t.updating)}isQueued(){return this.sourceBuffers.some(([e])=>e&&!!this.currentOp(e))}isPending(e){return!!e&&!e.buffer}blockBuffers(e,t=this.sourceBufferTypes){if(!t.length)return this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);const{operationQueue:r}=this,i=t.map(e=>this.appendBlocker(e));return t.length>1&&!!this.blockedAudioAppend&&this.unblockAudio(),Promise.all(i).then(t=>{r===this.operationQueue&&(e(),this.stepOperationQueue(this.sourceBufferTypes))})}stepOperationQueue(e){e.forEach(e=>{var t;const r=null==(t=this.tracks[e])?void 0:t.buffer;r&&!r.updating&&this.shiftAndExecuteNext(e)})}append(e,t,r){this.operationQueue&&this.operationQueue.append(e,t,r)}appendBlocker(e){if(this.operationQueue)return this.operationQueue.appendBlocker(e)}currentOp(e){return this.operationQueue?this.operationQueue.current(e):null}executeNext(e){e&&this.operationQueue&&this.operationQueue.executeNext(e)}shiftAndExecuteNext(e){this.operationQueue&&this.operationQueue.shiftAndExecuteNext(e)}get pendingTrackCount(){return Object.keys(this.tracks).reduce((e,t)=>e+(this.isPending(this.tracks[t])?1:0),0)}get sourceBufferCount(){return this.sourceBuffers.reduce((e,[t])=>e+(t?1:0),0)}get sourceBufferTypes(){return this.sourceBuffers.map(([e])=>e).filter(e=>!!e)}addBufferListener(e,t,r){const i=this.tracks[e];if(!i)return;const n=i.buffer;if(!n)return;const s=r.bind(this,e);i.listeners.push({event:t,listener:s}),n.addEventListener(t,s)}removeBufferListeners(e){const t=this.tracks[e];if(!t)return;const r=t.buffer;r&&(t.listeners.forEach(e=>{r.removeEventListener(e.event,e.listener)}),t.listeners.length=0)}},capLevelController:Lv,errorController:class extends Iu{constructor(e){super("error-controller",e.logger),this.hls=void 0,this.playlistError=0,this.hls=e,this.registerListeners()}registerListeners(){const e=this.hls;e.on(fu.ERROR,this.onError,this),e.on(fu.MANIFEST_LOADING,this.onManifestLoading,this),e.on(fu.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const e=this.hls;e&&(e.off(fu.ERROR,this.onError,this),e.off(fu.ERROR,this.onErrorOut,this),e.off(fu.MANIFEST_LOADING,this.onManifestLoading,this),e.off(fu.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null}startLoad(e){}stopLoad(){this.playlistError=0}getVariantLevelIndex(e){return(null==e?void 0:e.type)===yu?e.level:this.getVariantIndex()}getVariantIndex(){var e;const t=this.hls,r=t.currentLevel;return null!=(e=t.loadLevelObj)&&e.details||-1===r?t.loadLevel:r}variantHasKey(e,t){if(e){var r;if(null!=(r=e.details)&&r.hasKey(t))return!0;const i=e.audioGroups;if(i){return this.hls.allAudioTracks.filter(e=>i.indexOf(e.groupId)>=0).some(e=>{var r;return null==(r=e.details)?void 0:r.hasKey(t)})}}return!1}onManifestLoading(){this.playlistError=0}onLevelUpdated(){this.playlistError=0}onError(e,t){var r;if(t.fatal)return;const i=this.hls,n=t.context;switch(t.details){case hu.FRAG_LOAD_ERROR:case hu.FRAG_LOAD_TIMEOUT:case hu.KEY_LOAD_ERROR:case hu.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case hu.FRAG_PARSING_ERROR:if(null!=(r=t.frag)&&r.gap)return void(t.errorAction=Bf());case hu.FRAG_GAP:case hu.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=Df);case hu.LEVEL_EMPTY_ERROR:case hu.LEVEL_PARSING_ERROR:{var s;const e=t.parent===yu?t.level:i.loadLevel;t.details===hu.LEVEL_EMPTY_ERROR&&null!=(s=t.context)&&null!=(s=s.levelDetails)&&s.live?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,e):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,e))}return;case hu.LEVEL_LOAD_ERROR:case hu.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==n?void 0:n.level)&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.level)));case hu.AUDIO_TRACK_LOAD_ERROR:case hu.AUDIO_TRACK_LOAD_TIMEOUT:case hu.SUBTITLE_LOAD_ERROR:case hu.SUBTITLE_TRACK_LOAD_TIMEOUT:if(n){const e=i.loadLevelObj;if(e&&(n.type===gu&&e.hasAudioGroup(n.groupId)||n.type===vu&&e.hasSubtitleGroup(n.groupId)))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,i.loadLevel),t.errorAction.action=Df,void(t.errorAction.flags=Nf)}return;case hu.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:return void(t.errorAction={action:Df,flags:Ff});case hu.KEY_SYSTEM_SESSION_UPDATE_FAILED:case hu.KEY_SYSTEM_STATUS_INTERNAL_ERROR:case hu.KEY_SYSTEM_NO_SESSION:return void(t.errorAction={action:Df,flags:$f});case hu.BUFFER_ADD_CODEC_ERROR:case hu.REMUX_ALLOC_ERROR:case hu.BUFFER_APPEND_ERROR:var a;if(!t.errorAction)t.errorAction=this.getLevelSwitchAction(t,null!=(a=t.level)?a:i.loadLevel);return;case hu.INTERNAL_EXCEPTION:case hu.BUFFER_APPENDING_ERROR:case hu.BUFFER_FULL_ERROR:case hu.LEVEL_SWITCH_ERROR:case hu.BUFFER_STALLED_ERROR:case hu.BUFFER_SEEK_OVER_HOLE:case hu.BUFFER_NUDGE_ON_STALL:return void(t.errorAction=Bf())}t.type===uu.KEY_SYSTEM_ERROR&&(t.levelRetry=!1,t.errorAction=Bf())}getPlaylistRetryOrSwitchAction(e,t){const r=kf(this.hls.config.playlistLoadPolicy,e),i=this.playlistError++;if(Rf(r,i,Tf(e),e.response))return{action:Of,flags:Mf,retryConfig:r,retryCount:i};const n=this.getLevelSwitchAction(e,t);return r&&(n.retryConfig=r,n.retryCount=i),n}getFragRetryOrSwitchAction(e){const t=this.hls,r=this.getVariantLevelIndex(e.frag),i=t.levels[r],{fragLoadPolicy:n,keyLoadPolicy:s}=t.config,a=kf(xf(e)?s:n,e),o=t.levels.reduce((e,t)=>e+t.fragmentError,0);if(i&&(e.details!==hu.FRAG_GAP&&i.fragmentError++,!Af(e))){if(Rf(a,o,Tf(e),e.response))return{action:Of,flags:Mf,retryConfig:a,retryCount:o}}const l=this.getLevelSwitchAction(e,r);return a&&(l.retryConfig=a,l.retryCount=o),l}getLevelSwitchAction(e,t){const r=this.hls;null==t&&(t=r.loadLevel);const i=this.hls.levels[t];if(i){var n,s;const t=e.details;i.loadError++,t===hu.BUFFER_APPEND_ERROR&&i.fragmentError++;let l=-1;const{levels:c,loadLevel:d,minAutoLevel:u,maxAutoLevel:h}=r;r.autoLevelEnabled||r.config.preserveManualLevelOnError||(r.loadLevel=-1);const f=null==(n=e.frag)?void 0:n.type,p=(f===bu&&t===hu.FRAG_PARSING_ERROR||"audio"===e.sourceBufferName&&(t===hu.BUFFER_ADD_CODEC_ERROR||t===hu.BUFFER_APPEND_ERROR))&&c.some(({audioCodec:e})=>i.audioCodec!==e),m="video"===e.sourceBufferName&&(t===hu.BUFFER_ADD_CODEC_ERROR||t===hu.BUFFER_APPEND_ERROR)&&c.some(({codecSet:e,audioCodec:t})=>i.codecSet!==e&&i.audioCodec===t),{type:g,groupId:v}=null!=(s=e.context)?s:{};for(let r=c.length;r--;){const n=(r+d)%c.length;if(n!==d&&n>=u&&n<=h&&0===c[n].loadError){var a,o;const r=c[n];if(t===hu.FRAG_GAP&&f===yu&&e.frag){const t=c[n].details;if(t){const r=bf(e.frag,t.fragments,e.frag.start);if(null!=r&&r.gap)continue}}else{if(g===gu&&r.hasAudioGroup(v)||g===vu&&r.hasSubtitleGroup(v))continue;if(f===bu&&null!=(a=i.audioGroups)&&a.some(e=>r.hasAudioGroup(e))||f===Eu&&null!=(o=i.subtitleGroups)&&o.some(e=>r.hasSubtitleGroup(e))||p&&i.audioCodec===r.audioCodec||m&&i.codecSet===r.codecSet||!p&&i.codecSet!==r.codecSet)continue}l=n;break}}if(l>-1&&r.loadLevel!==l)return e.levelRetry=!0,this.playlistError=0,{action:Df,flags:Mf,nextAutoLevel:l}}return{action:Df,flags:Nf}}onErrorOut(e,t){var r;switch(null==(r=t.errorAction)?void 0:r.action){case Cf:break;case Df:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===hu.FRAG_GAP?/MediaSource readyState: ended/.test(t.error.message)&&(this.warn(`MediaSource ended after "${t.sourceBufferName}" sourceBuffer append error. Attempting to recover from media error.`),this.hls.recoverMediaError()):t.fatal=!0}t.fatal&&this.hls.stopLoad()}sendAlternateToPenaltyBox(e){const t=this.hls,r=e.errorAction;if(!r)return;const{flags:i}=r,n=r.nextAutoLevel;switch(i){case Mf:this.switchLevel(e,n);break;case Ff:{const i=this.getVariantLevelIndex(e.frag),n=t.levels[i],s=null==n?void 0:n.attrs["HDCP-LEVEL"];if(r.hdcpLevel=s,"NONE"===s)this.warn("HDCP policy resticted output with HDCP-LEVEL=NONE");else if(s){t.maxHdcpLevel=Zh[Zh.indexOf(s)-1],r.resolved=!0,this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}}case $f:{const t=e.decryptdata;if(t){const i=this.hls.levels,n=i.length;for(let r=n;r--;){var s,a;if(this.variantHasKey(i[r],t))this.log(`Banned key found in level ${r} (${i[r].bitrate}bps) or audio group "${null==(s=i[r].audioGroups)?void 0:s.join(",")}" (${null==(a=e.frag)?void 0:a.type} fragment) ${Fu(t.keyId||[])}`),i[r].fragmentError++,i[r].loadError++,this.log(`Removing level ${r} with key error (${e.error})`),this.hls.removeLevel(r)}const o=e.frag;if(this.hls.levels.length<n)r.resolved=!0;else if(o&&o.type!==yu){const e=o.decryptdata;e&&!t.matches(e)&&(r.resolved=!0)}}break}}r.resolved||this.switchLevel(e,n)}switchLevel(e,t){if(void 0!==t&&e.errorAction&&(this.warn(`switching to level ${t} after ${e.details}`),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel,e.details===hu.BUFFER_ADD_CODEC_ERROR&&e.mimeType&&"audiovideo"!==e.sourceBufferName)){const t=Hh(e.mimeType),r=this.hls.levels;for(let i=r.length;i--;)r[i][`${e.sourceBufferName}Codec`]===t&&(this.log(`Removing level ${i} for ${e.details} ("${t}" not supported)`),this.hls.removeLevel(i))}}},fpsController:class{constructor(e){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=e,this.registerListeners()}setStreamController(e){this.streamController=e}registerListeners(){this.hls.on(fu.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(fu.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListeners(){this.hls.off(fu.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(fu.MEDIA_DETACHING,this.onMediaDetaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){const r=this.hls.config;if(r.capLevelOnFPSDrop){const e=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=e,e&&"function"==typeof e.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}}onMediaDetaching(){this.media=null}checkFPS(e,t,r){const i=performance.now();if(t){if(this.lastTime){const e=i-this.lastTime,n=r-this.lastDroppedFrames,s=t-this.lastDecodedFrames,a=1e3*n/e,o=this.hls;if(o.trigger(fu.FPS_DROP,{currentDropped:n,currentDecoded:s,totalDroppedFrames:r}),a>0&&n>o.config.fpsDroppedMonitoringThreshold*s){let e=o.currentLevel;o.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+e),e>0&&(-1===o.autoLevelCapping||o.autoLevelCapping>=e)&&(e-=1,o.trigger(fu.FPS_DROP_LEVEL_CAPPING,{level:e,droppedLevel:o.currentLevel}),o.autoLevelCapping=e,this.streamController.nextLevelSwitch())}}this.lastTime=i,this.lastDroppedFrames=r,this.lastDecodedFrames=t}}checkFPSInterval(){const e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){const t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}},stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:$p,requireKeySystemAccessOnStart:!1,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableEmsgKLVMetadata:!1,enableID3MetadataCues:!0,enableInterstitialPlayback:!0,interstitialAppendInPlace:!0,interstitialLiveLookAhead:10,useMediaCapabilities:!0,preserveManualLevelOnError:!1,certLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null}},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},interstitialAssetListLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:3e4,timeoutRetry:{maxNumRetry:0,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:0,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},{cueHandler:Vb,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:class extends Um{constructor(e,t,r){super(e,t,r,"subtitle-stream-controller",Eu),this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this.registerListeners()}onHandlerDestroying(){this.unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null}registerListeners(){super.registerListeners();const{hls:e}=this;e.on(fu.LEVEL_LOADED,this.onLevelLoaded,this),e.on(fu.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(fu.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(fu.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(fu.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(fu.BUFFER_FLUSHING,this.onBufferFlushing,this)}unregisterListeners(){super.unregisterListeners();const{hls:e}=this;e.off(fu.LEVEL_LOADED,this.onLevelLoaded,this),e.off(fu.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(fu.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(fu.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(fu.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(fu.BUFFER_FLUSHING,this.onBufferFlushing,this)}startLoad(e,t){this.stopLoad(),this.state=Rm,this.setInterval(500),this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}onManifestLoading(){super.onManifestLoading(),this.mainDetails=null}onMediaDetaching(e,t){this.tracksBuffered=[],super.onMediaDetaching(e,t)}onLevelLoaded(e,t){this.mainDetails=t.details}onSubtitleFragProcessed(e,t){const{frag:r,success:i}=t;if(this.fragContextChanged(r)||(Ju(r)&&(this.fragPrevious=r),this.state=Rm),!i)return;const n=this.tracksBuffered[this.currentTrackId];if(!n)return;let s;const a=r.start;for(let e=0;e<n.length;e++)if(a>=n[e].start&&a<=n[e].end){s=n[e];break}const o=r.start+r.duration;s?s.end=o:(s={start:a,end:o},n.push(s)),this.fragmentTracker.fragBuffered(r),this.fragBufferedComplete(r,null),this.media&&this.tick()}onBufferFlushing(e,t){const{startOffset:r,endOffset:i}=t;if(0===r&&i!==Number.POSITIVE_INFINITY){const e=i-1;if(e<=0)return;t.endOffsetSubtitles=Math.max(0,e),this.tracksBuffered.forEach(t=>{for(let r=0;r<t.length;)if(t[r].end<=e)t.shift();else{if(!(t[r].start<e))break;t[r].start=e,r++}}),this.fragmentTracker.removeFragmentsInRange(r,e,Eu)}}onError(e,t){const r=t.frag;(null==r?void 0:r.type)===Eu&&(t.details===hu.FRAG_GAP&&this.fragmentTracker.fragBuffered(r,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==Lm&&(this.state=Rm))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){this.levels&&bv(this.levels,t)?this.levels=t.map(e=>new af(e)):(this.tracksBuffered=[],this.levels=t.map(e=>{const t=new af(e);return this.tracksBuffered[t.id]=[],t}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,Eu),this.fragPrevious=null,this.mediaBuffer=null)}onSubtitleTrackSwitch(e,t){var r;if(this.currentTrackId=t.id,null==(r=this.levels)||!r.length||-1===this.currentTrackId)return void this.clearInterval();const i=this.levels[this.currentTrackId];null!=i&&i.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,i&&this.state!==Lm&&this.setInterval(500)}onSubtitleTrackLoaded(e,t){var r;const{currentTrackId:i,levels:n}=this,{details:s,id:a}=t;if(!n)return void this.warn(`Subtitle tracks were reset while loading level ${a}`);const o=n[a];if(a>=n.length||!o)return;this.log(`Subtitle track ${a} loaded [${s.startSN},${s.endSN}]${s.lastPartSn?`[part-${s.lastPartSn}-${s.lastPartIndex}]`:""},duration:${s.totalduration}`),this.mediaBuffer=this.mediaBufferTimeRanges;let l=0;if(s.live||null!=(r=o.details)&&r.live){if(s.deltaUpdateFailed)return;const e=this.mainDetails;if(!e)return void(this.startFragRequested=!1);const t=e.fragments[0];var c;if(o.details)l=this.alignPlaylists(s,o.details,null==(c=this.levelLastLoaded)?void 0:c.details),0===l&&t&&(l=t.start,hm(s,l));else s.hasProgramDateTime&&e.hasProgramDateTime?(xm(s,e),l=s.fragmentStart):t&&(l=t.start,hm(s,l));e&&!this.startFragRequested&&this.setStartPosition(e,l)}if(o.details=s,this.levelLastLoaded=o,a===i&&(this.hls.trigger(fu.SUBTITLE_TRACK_UPDATED,{details:s,id:a,groupId:t.groupId}),this.tick(),s.live&&!this.fragCurrent&&this.media&&this.state===Rm)){bf(null,s.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),o.details=void 0)}}_handleFragmentLoadComplete(e){const{frag:t,payload:r}=e,i=t.decryptdata,n=this.hls;if(!this.fragContextChanged(t)&&r&&r.byteLength>0&&null!=i&&i.key&&i.iv&&Tp(i.method)){const e=performance.now();this.decrypter.decrypt(new Uint8Array(r),i.key.buffer,i.iv.buffer,xp(i.method)).catch(e=>{throw n.trigger(fu.ERROR,{type:uu.MEDIA_ERROR,details:hu.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:t}),e}).then(r=>{const i=performance.now();n.trigger(fu.FRAG_DECRYPTED,{frag:t,payload:r,stats:{tstart:e,tdecrypt:i}})}).catch(e=>{this.warn(`${e.name}: ${e.message}`),this.state=Rm})}}doTick(){if(this.media){if(this.state===Rm){const{currentTrackId:e,levels:t}=this,r=null==t?void 0:t[e];if(!r||!t.length||!r.details)return;if(this.waitForLive(r))return;const{config:i}=this,n=this.getLoadPosition(),s=lp.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],n,i.maxBufferHole),{end:a,len:o}=s,l=r.details;if(o>this.hls.maxBufferLength+l.levelTargetDuration)return;const c=l.fragments,d=c.length,u=l.edge;let h=null;const f=this.fragPrevious;if(a<u){const e=i.maxFragLookUpTolerance,t=a>u-e?0:e;h=bf(f,c,Math.max(c[0].start,a),t),!h&&f&&f.start<c[0].start&&(h=c[0])}else h=c[d-1];if(h=this.filterReplacedPrimary(h,r.details),!h)return;const p=c[h.sn-l.startSN-1];if(p&&p.cc===h.cc&&this.fragmentTracker.getState(p)===Uf&&(h=p),this.fragmentTracker.getState(h)===Uf){const e=this.mapToInitFragWhenRequired(h);e&&this.loadFragment(e,r,a)}}}else this.state=Rm}loadFragment(e,t,r){Ju(e)?super.loadFragment(e,t,r):this._loadInitSegment(e,t)}get mediaBufferTimeRanges(){return new qy(this.tracksBuffered[this.currentTrackId]||[])}},subtitleTrackController:class extends yv{constructor(e){super(e,"subtitle-track-controller"),this.media=null,this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.onTextTracksChanged=()=>{if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let e=null;const t=_y(this.media.textTracks);for(let r=0;r<t.length;r++)if("hidden"===t[r].mode)e=t[r];else if("showing"===t[r].mode){e=t[r];break}const r=this.findTrackForTextTrack(e);this.subtitleTrack!==r&&this.setSubtitleTrack(r)},this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,this.onTextTracksChanged=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes()}registerListeners(){const{hls:e}=this;e.on(fu.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(fu.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(fu.MANIFEST_LOADING,this.onManifestLoading,this),e.on(fu.MANIFEST_PARSED,this.onManifestParsed,this),e.on(fu.LEVEL_LOADING,this.onLevelLoading,this),e.on(fu.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(fu.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(fu.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(fu.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(fu.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(fu.MANIFEST_LOADING,this.onManifestLoading,this),e.off(fu.MANIFEST_PARSED,this.onManifestParsed,this),e.off(fu.LEVEL_LOADING,this.onLevelLoading,this),e.off(fu.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(fu.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(fu.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))}pollTrackChange(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.onTextTracksChanged,e)}onMediaDetaching(e,t){const r=this.media;if(!r)return;const i=!!t.transferMedia;if(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||r.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),this.subtitleTrack=-1,this.media=null,i)return;_y(r.textTracks).forEach(e=>{Cy(e)})}onManifestLoading(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.subtitleTracks}onSubtitleTrackLoaded(e,t){const{id:r,groupId:i,details:n}=t,s=this.tracksInGroup[r];if(!s||s.groupId!==i)return void this.warn(`Subtitle track with id:${r} and group:${i} not found in active group ${null==s?void 0:s.groupId}`);const a=s.details;s.details=t.details,this.log(`Subtitle track ${r} "${s.name}" lang:${s.lang} group:${i} loaded [${n.startSN}-${n.endSN}]`),r===this.trackId&&this.playlistLoaded(r,t,a)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(!t)return;const r=t.subtitleGroups||null,i=this.groupIds;let n=this.currentTrack;if(!r||(null==i?void 0:i.length)!==(null==r?void 0:r.length)||null!=r&&r.some(e=>-1===(null==i?void 0:i.indexOf(e)))){this.groupIds=r,this.trackId=-1,this.currentTrack=null;const e=this.tracks.filter(e=>!r||-1!==r.indexOf(e.groupId));if(e.length)this.selectDefaultTrack&&!e.some(e=>e.default)&&(this.selectDefaultTrack=!1),e.forEach((e,t)=>{e.id=t});else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=e;const t=this.hls.config.subtitlePreference;if(!n&&t){this.selectDefaultTrack=!1;const r=ff(t,e);if(r>-1)n=e[r];else{const e=ff(t,this.tracks);n=this.tracks[e]}}let i=this.findTrackId(n);-1===i&&n&&(i=this.findTrackId(null));const s={subtitleTracks:e};this.log(`Updating subtitle tracks, ${e.length} track(s) found in "${null==r?void 0:r.join(",")}" group-id`),this.hls.trigger(fu.SUBTITLE_TRACKS_UPDATED,s),-1!==i&&-1===this.trackId&&this.setSubtitleTrack(i)}}findTrackId(e){const t=this.tracksInGroup,r=this.selectDefaultTrack;for(let i=0;i<t.length;i++){const n=t[i];if((!r||n.default)&&(r||e)&&(!e||pf(n,e)))return i}if(e){for(let r=0;r<t.length;r++){const i=t[r];if(Ev(e.attrs,i.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return r}for(let r=0;r<t.length;r++){const i=t[r];if(Ev(e.attrs,i.attrs,["LANGUAGE"]))return r}}return-1}findTrackForTextTrack(e){if(e){const t=this.tracksInGroup;for(let r=0;r<t.length;r++){if(wv(t[r],e))return r}}return-1}onError(e,t){!t.fatal&&t.context&&(t.context.type!==vu||t.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(t.context.groupId)||this.checkRetry(t))}get allSubtitleTracks(){return this.tracks}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(e){this.selectDefaultTrack=!1,this.setSubtitleTrack(e)}setSubtitleOption(e){if(this.hls.config.subtitlePreference=e,e){if(-1===e.id)return this.setSubtitleTrack(-1),null;const t=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,t.length){const r=this.currentTrack;if(r&&pf(e,r))return r;const i=ff(e,this.tracksInGroup);if(i>-1){const e=this.tracksInGroup[i];return this.setSubtitleTrack(i),e}if(r)return null;{const r=ff(e,t);if(r>-1)return t[r]}}}return null}loadPlaylist(e){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentTrack)&&this.scheduleLoading(this.currentTrack,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);const r=e.id,i=e.groupId,n=this.getUrlWithDirectives(e.url,t),s=e.details,a=null==s?void 0:s.age;this.log(`Loading subtitle ${r} "${e.name}" lang:${e.lang} group:${i}${void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:""}${a&&s.live?" age "+a.toFixed(1)+(s.type&&" "+s.type||""):""} ${n}`),this.hls.trigger(fu.SUBTITLE_TRACK_LOADING,{url:n,id:r,groupId:i,deliveryDirectives:t||null,track:e})}toggleTrackModes(){const{media:e}=this;if(!e)return;const t=_y(e.textTracks),r=this.currentTrack;let i;if(r&&(i=t.filter(e=>wv(r,e))[0],i||this.warn(`Unable to find subtitle TextTrack with name "${r.name}" and language "${r.lang}"`)),[].slice.call(t).forEach(e=>{"disabled"!==e.mode&&e!==i&&(e.mode="disabled")}),i){const e=this.subtitleDisplay?"showing":"hidden";i.mode!==e&&(i.mode=e)}}setSubtitleTrack(e){const t=this.tracksInGroup;if(!this.media)return void(this.queuedDefaultTrack=e);if(e<-1||e>=t.length||!lu(e))return void this.warn(`Invalid subtitle track id: ${e}`);this.selectDefaultTrack=!1;const r=this.currentTrack,i=t[e]||null;if(this.trackId=e,this.currentTrack=i,this.toggleTrackModes(),!i)return void this.hls.trigger(fu.SUBTITLE_TRACK_SWITCH,{id:e});const n=!!i.details&&!i.details.live;if(e===this.trackId&&i===r&&n)return;this.log(`Switching to subtitle-track ${e}`+(i?` "${i.name}" lang:${i.lang} group:${i.groupId}`:""));const{id:s,groupId:a="",name:o,type:l,url:c}=i;this.hls.trigger(fu.SUBTITLE_TRACK_SWITCH,{id:s,groupId:a,name:o,type:l,url:c});const d=this.switchParams(i.url,null==r?void 0:r.details,i.details);this.loadPlaylist(d)}},timelineController:class{constructor(e){this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},e.on(fu.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(fu.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(fu.MANIFEST_LOADING,this.onManifestLoading,this),e.on(fu.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(fu.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(fu.FRAG_LOADING,this.onFragLoading,this),e.on(fu.FRAG_LOADED,this.onFragLoaded,this),e.on(fu.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(fu.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(fu.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(fu.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(fu.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:e}=this;e.off(fu.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(fu.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(fu.MANIFEST_LOADING,this.onManifestLoading,this),e.off(fu.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(fu.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(fu.FRAG_LOADING,this.onFragLoading,this),e.off(fu.FRAG_LOADED,this.onFragLoaded,this),e.off(fu.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(fu.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(fu.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(fu.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(fu.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.media=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){const e=new Ub(this,"textTrack1"),t=new Ub(this,"textTrack2"),r=new Ub(this,"textTrack3"),i=new Ub(this,"textTrack4");this.cea608Parser1=new hb(1,e,t),this.cea608Parser2=new hb(3,r,i)}addCues(e,t,r,i,n){let s=!1;for(let e=n.length;e--;){const i=n[e],a=jb(i[0],i[1],t,r);if(a>=0&&(i[0]=Math.min(i[0],t),i[1]=Math.max(i[1],r),s=!0,a/(r-t)>.5))return}if(s||n.push([t,r]),this.config.renderTextTracksNatively){const n=this.captionsTracks[e];this.Cues.newCue(n,t,r,i)}else{const n=this.Cues.newCue(null,t,r,i);this.hls.trigger(fu.CUES_PARSED,{type:"captions",cues:n,track:e})}}onInitPtsFound(e,{frag:t,id:r,initPTS:i,timescale:n,trackId:s}){const{unparsedVttFrags:a}=this;r===yu&&(this.initPTS[t.cc]={baseTime:i,timescale:n,trackId:s}),a.length&&(this.unparsedVttFrags=[],a.forEach(e=>{this.initPTS[e.frag.cc]?this.onFragLoaded(fu.FRAG_LOADED,e):this.hls.trigger(fu.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e.frag,error:new Error("Subtitle discontinuity domain does not match main")})}))}getExistingTrack(e,t){const{media:r}=this;if(r)for(let i=0;i<r.textTracks.length;i++){const n=r.textTracks[i];if(Gb(n,{name:e,lang:t,characteristics:"transcribes-spoken-dialog,describes-music-and-sound"}))return n}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(this.captionsTracks[e])return;const{captionsProperties:t,captionsTracks:r,media:i}=this,{label:n,languageCode:s}=t[e],a=this.getExistingTrack(n,s);if(a)r[e]=a,Cy(r[e]),Ry(r[e],i);else{const t=this.createTextTrack("captions",n,s);t&&(t[e]=!0,r[e]=t)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;const t=this.captionsProperties[e];if(!t)return;const r={_id:e,label:t.label,kind:"captions",default:!!t.media&&!!t.media.default,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=r,this.hls.trigger(fu.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[r]})}createTextTrack(e,t,r){const i=this.media;if(i)return i.addTextTrack(e,t,r)}onMediaAttaching(e,t){this.media=t.media,t.mediaSource||this._cleanTracks()}onMediaDetaching(e,t){const r=!!t.transferMedia;if(this.media=null,r)return;const{captionsTracks:i}=this;Object.keys(i).forEach(e=>{Cy(i[e]),delete i[e]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}_cleanTracks(){const{media:e}=this;if(!e)return;const t=e.textTracks;if(t)for(let e=0;e<t.length;e++)Cy(t[e])}onSubtitleTracksUpdated(e,t){const r=t.subtitleTracks||[],i=r.some(e=>e.textCodec===Rb);if(this.config.enableWebVTT||i&&this.config.enableIMSC1){if(bv(this.tracks,r))return void(this.tracks=r);if(this.textTracks=[],this.tracks=r,this.config.renderTextTracksNatively){const e=this.media,t=e?_y(e.textTracks):null;if(this.tracks.forEach((e,r)=>{let i;if(t){let r=null;for(let i=0;i<t.length;i++)if(t[i]&&Gb(t[i],e)){r=t[i],t[i]=null;break}r&&(i=r)}if(i)Cy(i);else{const t=zb(e);i=this.createTextTrack(t,e.name,e.lang),i&&(i.mode="disabled")}i&&this.textTracks.push(i)}),null!=t&&t.length){const e=t.filter(e=>null!==e).map(e=>e.label);e.length&&this.hls.logger.warn(`Media element contains unused subtitle tracks: ${e.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`)}}else if(this.tracks.length){const e=this.tracks.map(e=>({label:e.name,kind:e.type.toLowerCase(),default:e.default,subtitleTrack:e}));this.hls.trigger(fu.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:e})}}}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(e=>{const t=/(?:CC|SERVICE)([1-4])/.exec(e.instreamId);if(!t)return;const r=`textTrack${t[1]}`,i=this.captionsProperties[r];i&&(i.label=e.name,e.lang&&(i.languageCode=e.lang),i.media=e)})}closedCaptionsForLevel(e){const t=this.hls.levels[e.level];return null==t?void 0:t.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){if(this.enabled&&t.frag.type===yu){var r,i;const{cea608Parser1:e,cea608Parser2:n,lastSn:s}=this,{cc:a,sn:o}=t.frag,l=null!=(r=null==(i=t.part)?void 0:i.index)?r:-1;e&&n&&(o!==s+1||o===s&&l!==this.lastPartIndex+1||a!==this.lastCc)&&(e.reset(),n.reset()),this.lastCc=a,this.lastSn=o,this.lastPartIndex=l}}onFragLoaded(e,t){const{frag:r,payload:i}=t;if(r.type===Eu)if(i.byteLength){const e=r.decryptdata,n="stats"in t;if(null==e||!e.encrypted||n){const e=this.tracks[r.level],n=this.vttCCs;n[r.cc]||(n[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),e&&e.textCodec===Rb?this._parseIMSC1(r,i):this._parseVTTs(t)}}else this.hls.trigger(fu.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){const r=this.hls;_b(t,this.initPTS[e.cc],t=>{this._appendCues(t,e.level),r.trigger(fu.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},t=>{r.logger.log(`Failed to parse IMSC1: ${t}`),r.trigger(fu.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:t})})}_parseVTTs(e){var t;const{frag:r,payload:i}=e,{initPTS:n,unparsedVttFrags:s}=this,a=n.length-1;if(!n[r.cc]&&-1===a)return void s.push(e);const o=this.hls;Lb(null!=(t=r.initSegment)&&t.data?wh(r.initSegment.data,new Uint8Array(i)).buffer:i,this.initPTS[r.cc],this.vttCCs,r.cc,r.start,e=>{this._appendCues(e,r.level),o.trigger(fu.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:r})},t=>{const n="Missing initPTS for VTT MPEGTS"===t.message;n?s.push(e):this._fallbackToIMSC1(r,i),o.logger.log(`Failed to parse VTT cue: ${t}`),n&&a>r.cc||o.trigger(fu.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:t})})}_fallbackToIMSC1(e,t){const r=this.tracks[e.level];r.textCodec||_b(t,this.initPTS[e.cc],()=>{r.textCodec=Rb,this._parseIMSC1(e,t)},()=>{r.textCodec="wvtt"})}_appendCues(e,t){const r=this.hls;if(this.config.renderTextTracksNatively){const r=this.textTracks[t];if(!r||"disabled"===r.mode)return;e.forEach(e=>Py(r,e))}else{const i=this.tracks[t];if(!i)return;const n=i.default?"default":"subtitles"+t;r.trigger(fu.CUES_PARSED,{type:"subtitles",cues:e,track:n})}}onFragDecrypted(e,t){const{frag:r}=t;r.type===Eu&&this.onFragLoaded(fu.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){if(!this.enabled||!this.config.enableCEA708Captions)return;const{frag:r,samples:i}=t;if(r.type!==yu||"NONE"!==this.closedCaptionsForLevel(r))for(let e=0;e<i.length;e++){const t=i[e].bytes;if(t){this.cea608Parser1||this.initCea608Parsers();const r=this.extractCea608Data(t);this.cea608Parser1.addData(i[e].pts,r[0]),this.cea608Parser2.addData(i[e].pts,r[1])}}}onBufferFlushing(e,{startOffset:t,endOffset:r,endOffsetSubtitles:i,type:n}){const{media:s}=this;if(s&&!(s.currentTime<r)){if(!n||"video"===n){const{captionsTracks:e}=this;Object.keys(e).forEach(i=>Dy(e[i],t,r))}if(this.config.renderTextTracksNatively&&0===t&&void 0!==i){const{textTracks:e}=this;Object.keys(e).forEach(r=>Dy(e[r],t,i))}}}extractCea608Data(e){const t=[[],[]],r=31&e[0];let i=2;for(let n=0;n<r;n++){const r=e[i++],n=127&e[i++],s=127&e[i++];if(0===n&&0===s)continue;if(!!(4&r)){const e=3&r;0!==e&&1!==e||(t[e].push(n),t[e].push(s))}}return t}},audioStreamController:class extends Um{constructor(e,t,r){super(e,t,r,"audio-stream-controller",bu),this.mainAnchor=null,this.mainFragLoading=null,this.audioOnly=!1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.flushing=!1,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this.registerListeners()}onHandlerDestroying(){this.unregisterListeners(),super.onHandlerDestroying(),this.resetItem()}resetItem(){this.mainDetails=this.mainAnchor=this.mainFragLoading=this.bufferedTrack=this.switchingTrack=this.waitingData=this.cachedTrackLoadedData=null}registerListeners(){super.registerListeners();const{hls:e}=this;e.on(fu.LEVEL_LOADED,this.onLevelLoaded,this),e.on(fu.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(fu.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(fu.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(fu.BUFFER_RESET,this.onBufferReset,this),e.on(fu.BUFFER_CREATED,this.onBufferCreated,this),e.on(fu.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(fu.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(fu.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(fu.FRAG_LOADING,this.onFragLoading,this),e.on(fu.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){const{hls:e}=this;e&&(super.unregisterListeners(),e.off(fu.LEVEL_LOADED,this.onLevelLoaded,this),e.off(fu.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(fu.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(fu.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(fu.BUFFER_RESET,this.onBufferReset,this),e.off(fu.BUFFER_CREATED,this.onBufferCreated,this),e.off(fu.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(fu.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(fu.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(fu.FRAG_LOADING,this.onFragLoading,this),e.off(fu.FRAG_BUFFERED,this.onFragBuffered,this))}onInitPtsFound(e,{frag:t,id:r,initPTS:i,timescale:n,trackId:s}){if(r===yu){const e=t.cc,r=this.fragCurrent;if(this.initPTS[e]={baseTime:i,timescale:n,trackId:s},this.log(`InitPTS for cc: ${e} found from main: ${i/n} (${i}/${n}) trackId: ${s}`),this.mainAnchor=t,this.state===$m){const r=this.waitingData;(!r&&!this.loadingParts||r&&r.frag.cc!==e)&&this.syncWithAnchor(t,null==r?void 0:r.frag)}else!this.hls.hasEnoughToStart&&r&&r.cc!==e?(r.abortRequests(),this.syncWithAnchor(t,r)):this.state===Rm&&this.tick()}}getLoadPosition(){return!this.startFragRequested&&this.nextLoadPosition>=0?this.nextLoadPosition:super.getLoadPosition()}syncWithAnchor(e,t){var r;const i=(null==(r=this.mainFragLoading)?void 0:r.frag)||null;if(t&&(null==i?void 0:i.cc)===t.cc)return;const n=(i||e).cc,s=Sf(this.getLevelDetails(),n,this.getLoadPosition());s&&(this.log(`Syncing with main frag at ${s.start} cc ${s.cc}`),this.startFragRequested=!1,this.nextLoadPosition=s.start,this.resetLoadingState(),this.state===Rm&&this.doTickIdle())}startLoad(e,t){if(!this.levels)return this.startPosition=e,void(this.state=Lm);const r=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),r>0&&-1===e?(this.log(`Override startPosition with lastCurrentTime @${r.toFixed(3)}`),e=r,this.state=Rm):this.state=_m,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}doTick(){switch(this.state){case Rm:this.doTickIdle();break;case _m:{const{levels:e,trackId:t}=this,r=null==e?void 0:e[t],i=null==r?void 0:r.details;if(i&&!this.waitForLive(r)){if(this.waitForCdnTuneIn(i))break;this.state=$m}break}case Dm:this.checkRetryDate();break;case $m:{const e=this.waitingData;if(e){const{frag:t,part:r,cache:i,complete:n}=e,s=this.mainAnchor;if(void 0!==this.initPTS[t.cc]){this.waitingData=null,this.state=Cm;const e={frag:t,part:r,payload:i.flush().buffer,networkDetails:null};this._handleFragmentLoadProgress(e),n&&super._handleFragmentLoadComplete(e)}else s&&s.cc!==e.frag.cc&&this.syncWithAnchor(s,e.frag)}else this.state=Rm}}this.onTickEnd()}resetLoadingState(){const e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null),super.resetLoadingState()}onTickEnd(){const{media:e}=this;null!=e&&e.readyState&&(this.lastCurrentTime=e.currentTime)}doTickIdle(){var e;const{hls:t,levels:r,media:i,trackId:n}=this,s=t.config;if(!this.buffering||!i&&!this.primaryPrefetch&&(this.startFragRequested||!s.startFragPrefetch)||null==r||!r[n])return;const a=r[n],o=a.details;if(!o||this.waitForLive(a)||this.waitForCdnTuneIn(o))return this.state=_m,void(this.startFragRequested=!1);const l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,qu,bu));const c=this.getFwdBufferInfo(l,bu);if(null===c)return;if(!this.switchingTrack&&this._streamEnded(c,o))return t.trigger(fu.BUFFER_EOS,{type:"audio"}),void(this.state=Nm);const d=c.len,u=t.maxBufferLength,h=o.fragments,f=h[0].start,p=this.getLoadPosition(),m=this.flushing?p:c.end;if(this.switchingTrack&&i){const e=p;o.PTSKnown&&e<f&&(c.end>f||c.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),i.currentTime=f+.05)}if(d>=u&&!this.switchingTrack&&m<h[h.length-1].start)return;let g=this.getNextFragment(m,o);if(g&&this.isLoopLoading(g,m)&&(g=this.getNextFragmentLoopLoading(g,o,c,yu,u)),!g)return void(this.bufferFlushed=!0);let v=(null==(e=this.mainFragLoading)?void 0:e.frag)||null;if(!this.audioOnly&&this.startFragRequested&&v&&Ju(g)&&!g.endList&&(!o.live||!this.loadingParts&&m<this.hls.liveSyncPosition)&&(this.fragmentTracker.getState(v)===jf&&(this.mainFragLoading=v=null),v&&Ju(v))){if(g.start>v.end){const e=this.fragmentTracker.getFragAtPos(m,yu);e&&e.end>v.end&&(v=e,this.mainFragLoading={frag:e,targetBufferTime:null})}if(g.start>v.end)return}this.loadFragment(g,a,m)}onMediaDetaching(e,t){this.bufferFlushed=this.flushing=!1,super.onMediaDetaching(e,t)}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(e=>new af(e))}onAudioTrackSwitching(e,t){const r=!!t.url;this.trackId=t.id;const{fragCurrent:i}=this;i&&(i.abortRequests(),this.removeUnbufferedFrags(i.start)),this.resetLoadingState(),r?(this.switchingTrack=t,this.flushAudioIfNeeded(t),this.state!==Lm&&(this.setInterval(100),this.state=Rm,this.tick())):(this.resetTransmuxer(),this.switchingTrack=null,this.bufferedTrack=t,this.clearInterval())}onManifestLoading(){super.onManifestLoading(),this.bufferFlushed=this.flushing=this.audioOnly=!1,this.resetItem(),this.trackId=-1}onLevelLoaded(e,t){this.mainDetails=t.details;const r=this.cachedTrackLoadedData;r&&(this.cachedTrackLoadedData=null,this.onAudioTrackLoaded(fu.AUDIO_TRACK_LOADED,r))}onAudioTrackLoaded(e,t){var r;const{levels:i}=this,{details:n,id:s,groupId:a,track:o}=t;if(!i)return void this.warn(`Audio tracks reset while loading track ${s} "${o.name}" of "${a}"`);const l=this.mainDetails;if(!l||n.endCC>l.endCC||l.expired)return this.cachedTrackLoadedData=t,void(this.state!==Lm&&(this.state=_m));this.cachedTrackLoadedData=null,this.log(`Audio track ${s} "${o.name}" of "${a}" loaded [${n.startSN},${n.endSN}]${n.lastPartSn?`[part-${n.lastPartSn}-${n.lastPartIndex}]`:""},duration:${n.totalduration}`);const c=i[s];let d=0;if(n.live||null!=(r=c.details)&&r.live){if(this.checkLiveUpdate(n),n.deltaUpdateFailed)return;var u;if(c.details)d=this.alignPlaylists(n,c.details,null==(u=this.levelLastLoaded)?void 0:u.details);n.alignedSliding||(Tm(n,l),n.alignedSliding||xm(n,l),d=n.fragmentStart)}c.details=n,this.levelLastLoaded=c,this.startFragRequested||this.setStartPosition(l,d),this.hls.trigger(fu.AUDIO_TRACK_UPDATED,{details:n,id:s,groupId:t.groupId}),this.state!==_m||this.waitForCdnTuneIn(n)||(this.state=Rm),this.tick()}_handleFragmentLoadProgress(e){var t;const r=e.frag,{part:i,payload:n}=e,{config:s,trackId:a,levels:o}=this;if(!o)return void this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);const l=o[a];if(!l)return void this.warn("Audio track is undefined on fragment load progress");const c=l.details;if(!c)return this.warn("Audio track details undefined on fragment load progress"),void this.removeUnbufferedFrags(r.start);const d=s.defaultAudioCodec||l.audioCodec||"mp4a.40.2";let u=this.transmuxer;u||(u=this.transmuxer=new vv(this.hls,bu,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const h=this.initPTS[r.cc],f=null==(t=r.initSegment)?void 0:t.data;if(void 0!==h){const e=!1,t=i?i.index:-1,s=-1!==t,a=new ap(r.level,r.sn,r.stats.chunkCount,n.byteLength,t,s);u.push(n,f,d,"",r,i,c.totalduration,e,a,h)}else{this.log(`Unknown video PTS for cc ${r.cc}, waiting for video PTS before demuxing audio frag ${r.sn} of [${c.startSN} ,${c.endSN}],track ${a}`);const{cache:e}=this.waitingData=this.waitingData||{frag:r,part:i,cache:new Gm,complete:!1};e.push(new Uint8Array(n)),this.state!==Lm&&(this.state=$m)}}_handleFragmentLoadComplete(e){this.waitingData?this.waitingData.complete=!0:super._handleFragmentLoadComplete(e)}onBufferReset(){this.mediaBuffer=null}onBufferCreated(e,t){this.bufferFlushed=this.flushing=!1;const r=t.tracks.audio;r&&(this.mediaBuffer=r.buffer||null)}onFragLoading(e,t){!this.audioOnly&&t.frag.type===yu&&Ju(t.frag)&&(this.mainFragLoading=t,this.state===Rm&&this.tick())}onFragBuffered(e,t){const{frag:r,part:i}=t;if(r.type===bu)if(this.fragContextChanged(r))this.warn(`Fragment ${r.sn}${i?" p: "+i.index:""} of level ${r.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);else{if(Ju(r)){this.fragPrevious=r;const e=this.switchingTrack;e&&(this.bufferedTrack=e,this.switchingTrack=null,this.hls.trigger(fu.AUDIO_TRACK_SWITCHED,ku({},e)))}this.fragBufferedComplete(r,i),this.media&&this.tick()}else this.audioOnly||r.type!==yu||r.elementaryStreams.video||r.elementaryStreams.audiovideo||(this.audioOnly=!0,this.mainFragLoading=null)}onError(e,t){var r;if(t.fatal)this.state=Fm;else switch(t.details){case hu.FRAG_GAP:case hu.FRAG_PARSING_ERROR:case hu.FRAG_DECRYPT_ERROR:case hu.FRAG_LOAD_ERROR:case hu.FRAG_LOAD_TIMEOUT:case hu.KEY_LOAD_ERROR:case hu.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(bu,t);break;case hu.AUDIO_TRACK_LOAD_ERROR:case hu.AUDIO_TRACK_LOAD_TIMEOUT:case hu.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==_m||(null==(r=t.context)?void 0:r.type)!==gu||(this.state=Rm);break;case hu.BUFFER_ADD_CODEC_ERROR:case hu.BUFFER_APPEND_ERROR:if("audio"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)||this.resetLoadingState();break;case hu.BUFFER_FULL_ERROR:if("audio"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case hu.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}onBufferFlushing(e,{type:t}){t!==Xu&&(this.flushing=!0)}onBufferFlushed(e,{type:t}){if(t!==Xu){this.flushing=!1,this.bufferFlushed=!0,this.state===Nm&&(this.state=Rm);const e=this.mediaBuffer||this.media;e&&(this.afterBufferFlushed(e,t,bu),this.tick())}}_handleTransmuxComplete(e){var t;const r="audio",{hls:i}=this,{remuxResult:n,chunkMeta:s}=e,a=this.getCurrentContext(s);if(!a)return void this.resetWhenMissingContext(s);const{frag:o,part:l,level:c}=a,{details:d}=c,{audio:u,text:h,id3:f,initSegment:p}=n;if(!this.fragContextChanged(o)&&d){if(this.state=Om,this.switchingTrack&&u&&this.completeAudioSwitch(this.switchingTrack),null!=p&&p.tracks){const e=o.initSegment||o;if(this.unhandledEncryptionError(p,o))return;this._bufferInitSegment(c,p.tracks,e,s),i.trigger(fu.FRAG_PARSING_INIT_SEGMENT,{frag:e,id:r,tracks:p.tracks})}if(u){const{startPTS:e,endPTS:t,startDTS:r,endDTS:i}=u;l&&(l.elementaryStreams[qu]={startPTS:e,endPTS:t,startDTS:r,endDTS:i}),o.setElementaryStreamInfo(qu,e,t,r,i),this.bufferFragmentData(u,o,l,s)}if(null!=f&&null!=(t=f.samples)&&t.length){const e=xu({id:r,frag:o,details:d},f);i.trigger(fu.FRAG_PARSING_METADATA,e)}if(h){const e=xu({id:r,frag:o,details:d},h);i.trigger(fu.FRAG_PARSING_USERDATA,e)}}else this.fragmentTracker.removeFragment(o)}_bufferInitSegment(e,t,r,i){if(this.state!==Om)return;if(t.video&&delete t.video,t.audiovideo&&delete t.audiovideo,!t.audio)return;const n=t.audio;n.id=bu;const s=e.audioCodec;this.log(`Init audio buffer, container:${n.container}, codecs[level/parsed]=[${s}/${n.codec}]`),s&&1===s.split(",").length&&(n.levelCodec=s),this.hls.trigger(fu.BUFFER_CODECS,t);const a=n.initSegment;if(null!=a&&a.byteLength){const e={type:"audio",frag:r,part:null,chunkMeta:i,parent:r.type,data:a};this.hls.trigger(fu.BUFFER_APPENDING,e)}this.tickImmediate()}loadFragment(e,t,r){const i=this.fragmentTracker.getState(e);var n;if(this.switchingTrack||i===Uf||i===Gf)if(Ju(e))if(null!=(n=t.details)&&n.live&&!this.initPTS[e.cc]){this.log(`Waiting for video PTS in continuity counter ${e.cc} of live stream before loading audio fragment ${e.sn} of level ${this.trackId}`),this.state=$m;const r=this.mainDetails;r&&r.fragmentStart!==t.details.fragmentStart&&xm(t.details,r)}else super.loadFragment(e,t,r);else this._loadInitSegment(e,t);else this.clearTrackerIfNeeded(e)}flushAudioIfNeeded(e){if(this.media&&this.bufferedTrack){const{name:t,lang:r,assocLang:i,characteristics:n,audioCodec:s,channels:a}=this.bufferedTrack;pf({name:t,lang:r,assocLang:i,characteristics:n,audioCodec:s,channels:a},e,mf)||(vf(e.url,this.hls)?(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null):this.bufferedTrack=e)}}completeAudioSwitch(e){const{hls:t}=this;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(fu.AUDIO_TRACK_SWITCHED,ku({},e))}},audioTrackController:class extends yv{constructor(e){super(e,"audio-track-controller"),this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){const{hls:e}=this;e.on(fu.MANIFEST_LOADING,this.onManifestLoading,this),e.on(fu.MANIFEST_PARSED,this.onManifestParsed,this),e.on(fu.LEVEL_LOADING,this.onLevelLoading,this),e.on(fu.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(fu.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(fu.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(fu.MANIFEST_LOADING,this.onManifestLoading,this),e.off(fu.MANIFEST_PARSED,this.onManifestParsed,this),e.off(fu.LEVEL_LOADING,this.onLevelLoading,this),e.off(fu.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(fu.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(fu.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.tracksInGroup=[],this.groupIds=null,this.currentTrack=null,this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.audioTracks||[]}onAudioTrackLoaded(e,t){const{id:r,groupId:i,details:n}=t,s=this.tracksInGroup[r];if(!s||s.groupId!==i)return void this.warn(`Audio track with id:${r} and group:${i} not found in active group ${null==s?void 0:s.groupId}`);const a=s.details;s.details=t.details,this.log(`Audio track ${r} "${s.name}" lang:${s.lang} group:${i} loaded [${n.startSN}-${n.endSN}]`),r===this.trackId&&this.playlistLoaded(r,t,a)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(!t)return;const r=t.audioGroups||null,i=this.groupIds;let n=this.currentTrack;if(!r||(null==i?void 0:i.length)!==(null==r?void 0:r.length)||null!=r&&r.some(e=>-1===(null==i?void 0:i.indexOf(e)))){this.groupIds=r,this.trackId=-1,this.currentTrack=null;const e=this.tracks.filter(e=>!r||-1!==r.indexOf(e.groupId));if(e.length)this.selectDefaultTrack&&!e.some(e=>e.default)&&(this.selectDefaultTrack=!1),e.forEach((e,t)=>{e.id=t});else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=e;const t=this.hls.config.audioPreference;if(!n&&t){const r=ff(t,e,mf);if(r>-1)n=e[r];else{const e=ff(t,this.tracks);n=this.tracks[e]}}let i=this.findTrackId(n);-1===i&&n&&(i=this.findTrackId(null));const a={audioTracks:e};this.log(`Updating audio tracks, ${e.length} track(s) found in group(s): ${null==r?void 0:r.join(",")}`),this.hls.trigger(fu.AUDIO_TRACKS_UPDATED,a);const o=this.trackId;if(-1!==i&&-1===o)this.setAudioTrack(i);else if(e.length&&-1===o){var s;const t=new Error(`No audio track selected for current audio group-ID(s): ${null==(s=this.groupIds)?void 0:s.join(",")} track count: ${e.length}`);this.warn(t.message),this.hls.trigger(fu.ERROR,{type:uu.MEDIA_ERROR,details:hu.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:t})}}}onError(e,t){!t.fatal&&t.context&&(t.context.type!==gu||t.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(t.context.groupId)||this.checkRetry(t))}get allAudioTracks(){return this.tracks}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}setAudioOption(e){const t=this.hls;if(t.config.audioPreference=e,e){const r=this.allAudioTracks;if(this.selectDefaultTrack=!1,r.length){const i=this.currentTrack;if(i&&pf(e,i,mf))return i;const n=ff(e,this.tracksInGroup,mf);if(n>-1){const e=this.tracksInGroup[n];return this.setAudioTrack(n),e}if(i){let i=t.loadLevel;-1===i&&(i=t.firstAutoLevel);const n=function(e,t,r,i,n){const s=t[i],a=t.reduce((e,t,r)=>{const i=t.uri;return(e[i]||(e[i]=[])).push(r),e},{})[s.uri];a.length>1&&(i=Math.max.apply(Math,a));const o=s.videoRange,l=s.frameRate,c=s.codecSet.substring(0,4),d=gf(t,i,t=>{if(t.videoRange!==o||t.frameRate!==l||t.codecSet.substring(0,4)!==c)return!1;const i=t.audioGroups,s=r.filter(e=>!i||-1!==i.indexOf(e.groupId));return ff(e,s,n)>-1});return d>-1?d:gf(t,i,t=>{const i=t.audioGroups,s=r.filter(e=>!i||-1!==i.indexOf(e.groupId));return ff(e,s,n)>-1})}(e,t.levels,r,i,mf);if(-1===n)return null;t.nextLoadLevel=n}if(e.channels||e.audioCodec){const t=ff(e,r);if(t>-1)return r[t]}}}return null}setAudioTrack(e){const t=this.tracksInGroup;if(e<0||e>=t.length)return void this.warn(`Invalid audio track id: ${e}`);this.selectDefaultTrack=!1;const r=this.currentTrack,i=t[e],n=i.details&&!i.details.live;if(e===this.trackId&&i===r&&n)return;if(this.log(`Switching to audio-track ${e} "${i.name}" lang:${i.lang} group:${i.groupId} channels:${i.channels}`),this.trackId=e,this.currentTrack=i,this.hls.trigger(fu.AUDIO_TRACK_SWITCHING,ku({},i)),n)return;const s=this.switchParams(i.url,null==r?void 0:r.details,i.details);this.loadPlaylist(s)}findTrackId(e){const t=this.tracksInGroup;for(let r=0;r<t.length;r++){const i=t[r];if((!this.selectDefaultTrack||i.default)&&(!e||pf(e,i,mf)))return r}if(e){const{name:r,lang:i,assocLang:n,characteristics:s,audioCodec:a,channels:o}=e;for(let e=0;e<t.length;e++){if(pf({name:r,lang:i,assocLang:n,characteristics:s,audioCodec:a,channels:o},t[e],mf))return e}for(let r=0;r<t.length;r++){const i=t[r];if(Ev(e.attrs,i.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return r}for(let r=0;r<t.length;r++){const i=t[r];if(Ev(e.attrs,i.attrs,["LANGUAGE"]))return r}}return-1}loadPlaylist(e){super.loadPlaylist();const t=this.currentTrack;this.shouldLoadPlaylist(t)&&vf(t.url,this.hls)&&this.scheduleLoading(t,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);const r=e.id,i=e.groupId,n=this.getUrlWithDirectives(e.url,t),s=e.details,a=null==s?void 0:s.age;this.log(`Loading audio-track ${r} "${e.name}" lang:${e.lang} group:${i}${void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:""}${a&&s.live?" age "+a.toFixed(1)+(s.type&&" "+s.type||""):""} ${n}`),this.hls.trigger(fu.AUDIO_TRACK_LOADING,{url:n,id:r,groupId:i,deliveryDirectives:t||null,track:e})}},emeController:xy,cmcdController:class{constructor(e){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.includeKeys=void 0,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=e=>{try{this.apply(e,{ot:Rv.MANIFEST,su:!this.initialized})}catch(e){this.hls.logger.warn("Could not generate manifest CMCD data.",e)}},this.applyFragmentData=e=>{try{const{frag:t,part:r}=e,i=this.hls.levels[t.level],n=this.getObjectType(t),s={d:1e3*(r||t).duration,ot:n};n!==Rv.VIDEO&&n!==Rv.AUDIO&&n!=Rv.MUXED||(s.br=i.bitrate/1e3,s.tb=this.getTopBandwidth(n)/1e3,s.bl=this.getBufferLength(n));const a=r?this.getNextPart(r):this.getNextFrag(t);null!=a&&a.url&&a.url!==t.url&&(s.nor=a.url),this.apply(e,s)}catch(e){this.hls.logger.warn("Could not generate segment CMCD data.",e)}},this.hls=e;const t=this.config=e.config,{cmcd:r}=t;null!=r&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=r.sessionId||e.sessionId,this.cid=r.contentId,this.useHeaders=!0===r.useHeaders,this.includeKeys=r.includeKeys,this.registerListeners())}registerListeners(){const e=this.hls;e.on(fu.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(fu.MEDIA_DETACHED,this.onMediaDetached,this),e.on(fu.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const e=this.hls;e.off(fu.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(fu.MEDIA_DETACHED,this.onMediaDetached,this),e.off(fu.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=this.media=null}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(e,t){var r,i;this.audioBuffer=null==(r=t.tracks.audio)?void 0:r.buffer,this.videoBuffer=null==(i=t.tracks.video)?void 0:i.buffer}createData(){var e;return{v:1,sf:Pv.HLS,sid:this.sid,cid:this.cid,pr:null==(e=this.media)?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){xu(t,this.createData());const r=t.ot===Rv.INIT||t.ot===Rv.VIDEO||t.ot===Rv.MUXED;this.starved&&r&&(t.bs=!0,t.su=!0,this.starved=!1),null==t.su&&(t.su=this.buffering);const{includeKeys:i}=this;i&&(t=Object.keys(t).reduce((e,r)=>(i.includes(r)&&(e[r]=t[r]),e),{}));const n={baseUrl:e.url};this.useHeaders?(e.headers||(e.headers={}),yy(e.headers,t,n)):e.url=wy(e.url,t,n)}getNextFrag(e){var t;const r=null==(t=this.hls.levels[e.level])?void 0:t.details;if(r){const t=e.sn-r.startSN;return r.fragments[t+1]}}getNextPart(e){var t;const{index:r,fragment:i}=e,n=null==(t=this.hls.levels[i.level])||null==(t=t.details)?void 0:t.partList;if(n){const{sn:e}=i;for(let t=n.length-1;t>=0;t--){const i=n[t];if(i.index===r&&i.fragment.sn===e)return n[t+1]}}}getObjectType(e){const{type:t}=e;return"subtitle"===t?Rv.TIMED_TEXT:"initSegment"===e.sn?Rv.INIT:"audio"===t?Rv.AUDIO:"main"===t?this.hls.audioTracks.length?Rv.VIDEO:Rv.MUXED:void 0}getTopBandwidth(e){let t,r=0;const i=this.hls;if(e===Rv.AUDIO)t=i.audioTracks;else{const e=i.maxAutoLevel,r=e>-1?e+1:i.levels.length;t=i.levels.slice(0,r)}return t.forEach(e=>{e.bitrate>r&&(r=e.bitrate)}),r>0?r:NaN}getBufferLength(e){const t=this.media,r=e===Rv.AUDIO?this.audioBuffer:this.videoBuffer;if(!r||!t)return NaN;return 1e3*lp.bufferInfo(r,t.currentTime,this.config.maxBufferHole).len}createPlaylistLoader(){const{pLoader:e}=this.config,t=this.applyPlaylistData,r=e||this.config.loader;return class{constructor(e){this.loader=void 0,this.loader=new r(e)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(e,r,i){t(e),this.loader.load(e,r,i)}}}createFragmentLoader(){const{fLoader:e}=this.config,t=this.applyFragmentData,r=e||this.config.loader;return class{constructor(e){this.loader=void 0,this.loader=new r(e)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(e,r,i){t(e),this.loader.load(e,r,i)}}}},contentSteeringController:class extends Iu{constructor(e){super("content-steering",e.logger),this.hls=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this._pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.registerListeners()}registerListeners(){const e=this.hls;e.on(fu.MANIFEST_LOADING,this.onManifestLoading,this),e.on(fu.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(fu.MANIFEST_PARSED,this.onManifestParsed,this),e.on(fu.ERROR,this.onError,this)}unregisterListeners(){const e=this.hls;e&&(e.off(fu.MANIFEST_LOADING,this.onManifestLoading,this),e.off(fu.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(fu.MANIFEST_PARSED,this.onManifestParsed,this),e.off(fu.ERROR,this.onError,this))}pathways(){return(this.levels||[]).reduce((e,t)=>(-1===e.indexOf(t.pathwayId)&&e.push(t.pathwayId),e),[])}get pathwayPriority(){return this._pathwayPriority}set pathwayPriority(e){this.updatePathwayPriority(e)}startLoad(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){const e=1e3*this.timeToLoad-(performance.now()-this.updated);if(e>0)return void this.scheduleRefresh(this.uri,e)}this.loadSteeringManifest(this.uri)}}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}clearTimeout(){-1!==this.reloadTimer&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(e){const t=this.levels;t&&(this.levels=t.filter(t=>t!==e))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(e,t){const{contentSteering:r}=t;null!==r&&(this.pathwayId=r.pathwayId,this.uri=r.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){const{errorAction:r}=t;if((null==r?void 0:r.action)===Df&&r.flags===Nf){const e=this.levels;let i=this._pathwayPriority,n=this.pathwayId;if(t.context){const{groupId:r,pathwayId:i,type:s}=t.context;r&&e?n=this.getPathwayForGroupId(r,s,n):i&&(n=i)}n in this.penalizedPathways||(this.penalizedPathways[n]=performance.now()),!i&&e&&(i=this.pathways()),i&&i.length>1&&(this.updatePathwayPriority(i),r.resolved=this.pathwayId!==n),t.details!==hu.BUFFER_APPEND_ERROR||t.fatal?r.resolved||this.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${n} levels: ${e?e.length:e} priorities: ${cf(i)} penalized: ${cf(this.penalizedPathways)}`):r.resolved=!0}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(0===t.length){const r=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${r}"`),t=this.getLevelsForPathway(r),this.pathwayId=r}return t.length!==e.length&&this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t}getLevelsForPathway(e){return null===this.levels?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){let t;this._pathwayPriority=e;const r=this.penalizedPathways,i=performance.now();Object.keys(r).forEach(e=>{i-r[e]>3e5&&delete r[e]});for(let i=0;i<e.length;i++){const n=e[i];if(n in r)continue;if(n===this.pathwayId)return;const s=this.hls.nextLoadLevel,a=this.hls.levels[s];if(t=this.getLevelsForPathway(n),t.length>0){this.log(`Setting Pathway to "${n}"`),this.pathwayId=n,vm(t),this.hls.trigger(fu.LEVELS_UPDATED,{levels:t});const e=this.hls.levels[s];a&&e&&this.levels&&(e.attrs["STABLE-VARIANT-ID"]!==a.attrs["STABLE-VARIANT-ID"]&&e.bitrate!==a.bitrate&&this.log(`Unstable Pathways change from bitrate ${a.bitrate} to ${e.bitrate}`),this.hls.nextLoadLevel=s);break}}}getPathwayForGroupId(e,t,r){const i=this.getLevelsForPathway(r).concat(this.levels||[]);for(let r=0;r<i.length;r++)if(t===gu&&i[r].hasAudioGroup(e)||t===vu&&i[r].hasSubtitleGroup(e))return i[r].pathwayId;return r}clonePathways(e){const t=this.levels;if(!t)return;const r={},i={};e.forEach(e=>{const{ID:n,"BASE-ID":s,"URI-REPLACEMENT":a}=e;if(t.some(e=>e.pathwayId===n))return;const o=this.getLevelsForPathway(s).map(e=>{const t=new gp(e.attrs);t["PATHWAY-ID"]=n;const s=t.AUDIO&&`${t.AUDIO}_clone_${n}`,o=t.SUBTITLES&&`${t.SUBTITLES}_clone_${n}`;s&&(r[t.AUDIO]=s,t.AUDIO=s),o&&(i[t.SUBTITLES]=o,t.SUBTITLES=o);const l=Ty(e.uri,t["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",a),c=new af({attrs:t,audioCodec:e.audioCodec,bitrate:e.bitrate,height:e.height,name:e.name,url:l,videoCodec:e.videoCodec,width:e.width});if(e.audioGroups)for(let t=1;t<e.audioGroups.length;t++)c.addGroupId("audio",`${e.audioGroups[t]}_clone_${n}`);if(e.subtitleGroups)for(let t=1;t<e.subtitleGroups.length;t++)c.addGroupId("text",`${e.subtitleGroups[t]}_clone_${n}`);return c});t.push(...o),Sy(this.audioTracks,r,a,n),Sy(this.subtitleTracks,i,a,n)})}loadSteeringManifest(e){const t=this.hls.config,r=t.loader;let i;this.loader&&this.loader.destroy(),this.loader=new r(t);try{i=new self.URL(e)}catch(t){return this.enabled=!1,void this.log(`Failed to parse Steering Manifest URI: ${e}`)}if("data:"!==i.protocol){const e=0|(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate);i.searchParams.set("_HLS_pathway",this.pathwayId),i.searchParams.set("_HLS_throughput",""+e)}const n={responseType:"json",url:i.href},s=t.steeringManifestLoadPolicy.default,a=s.errorRetry||s.timeoutRetry||{},o={loadPolicy:s,timeout:s.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},l={onSuccess:(e,t,r,n)=>{this.log(`Loaded steering manifest: "${i}"`);const s=e.data;if(1!==(null==s?void 0:s.VERSION))return void this.log(`Steering VERSION ${s.VERSION} not supported!`);this.updated=performance.now(),this.timeToLoad=s.TTL;const{"RELOAD-URI":a,"PATHWAY-CLONES":o,"PATHWAY-PRIORITY":l}=s;if(a)try{this.uri=new self.URL(a,i).href}catch(e){return this.enabled=!1,void this.log(`Failed to parse Steering Manifest RELOAD-URI: ${a}`)}this.scheduleRefresh(this.uri||r.url),o&&this.clonePathways(o);const c={steeringManifest:s,url:i.toString()};this.hls.trigger(fu.STEERING_MANIFEST_LOADED,c),l&&this.updatePathwayPriority(l)},onError:(e,t,r,i)=>{if(this.log(`Error loading steering manifest: ${e.code} ${e.text} (${t.url})`),this.stopLoad(),410===e.code)return this.enabled=!1,void this.log(`Steering manifest ${t.url} no longer available`);let n=1e3*this.timeToLoad;if(429===e.code){const e=this.loader;if("function"==typeof(null==e?void 0:e.getResponseHeader)){const t=e.getResponseHeader("Retry-After");t&&(n=1e3*parseFloat(t))}return void this.log(`Steering manifest ${t.url} rate limited`)}this.scheduleRefresh(this.uri||t.url,n)},onTimeout:(e,t,r)=>{this.log(`Timeout loading steering manifest (${t.url})`),this.scheduleRefresh(this.uri||t.url)}};this.log(`Requesting steering manifest: ${i}`),this.loader.load(n,o,l)}scheduleRefresh(e,t=1e3*this.timeToLoad){this.clearTimeout(),this.reloadTimer=self.setTimeout(()=>{var t;const r=null==(t=this.hls)?void 0:t.media;!r||r.ended?this.scheduleRefresh(e,1e3*this.timeToLoad):this.loadSteeringManifest(e)},t)}},interstitialsController:class extends Iu{constructor(e,t){super("interstitials",e.logger),this.HlsPlayerClass=void 0,this.hls=void 0,this.assetListLoader=void 0,this.mediaSelection=null,this.altSelection=null,this.media=null,this.detachedData=null,this.requiredTracks=null,this.manager=null,this.playerQueue=[],this.bufferedPos=-1,this.timelinePos=-1,this.schedule=void 0,this.playingItem=null,this.bufferingItem=null,this.waitingItem=null,this.endedItem=null,this.playingAsset=null,this.endedAsset=null,this.bufferingAsset=null,this.shouldPlay=!1,this.onPlay=()=>{this.shouldPlay=!0},this.onPause=()=>{this.shouldPlay=!1},this.onSeeking=()=>{const e=this.currentTime;if(void 0===e||this.playbackDisabled||!this.schedule)return;const t=e-this.timelinePos;if(Math.abs(t)<1/7056e5)return;const r=t<=-.01;this.timelinePos=e,this.bufferedPos=e;const i=this.playingItem;if(!i)return void this.checkBuffer();if(r){this.schedule.resetErrorsInRange(e,e-t)&&this.updateSchedule(!0)}if(this.checkBuffer(),r&&e<i.start||e>=i.end){var n;const t=this.findItemIndex(i);let s=this.schedule.findItemIndexAtTime(e);if(-1===s&&(s=t+(r?-1:1),this.log(`seeked ${r?"back ":""}to position not covered by schedule ${e} (resolving from ${t} to ${s})`)),!this.isInterstitial(i)&&null!=(n=this.media)&&n.paused&&(this.shouldPlay=!1),!r&&s>t){const e=this.schedule.findJumpRestrictedIndex(t+1,s);if(e>t)return void this.setSchedulePosition(e)}return void this.setSchedulePosition(s)}const s=this.playingAsset;if(!s){if(this.playingLastItem&&this.isInterstitial(i)){const t=i.event.assetList[0];t&&(this.endedItem=this.playingItem,this.playingItem=null,this.setScheduleToAssetAtTime(e,t))}return}const a=s.timelineStart,o=s.duration||0;var l;(r&&e<a||e>=a+o)&&(null!=(l=i.event)&&l.appendInPlace&&(this.clearAssetPlayers(i.event,i),this.flushFrontBuffer(e)),this.setScheduleToAssetAtTime(e,s))},this.onTimeupdate=()=>{const e=this.currentTime;if(void 0===e||this.playbackDisabled)return;if(!(e>this.timelinePos))return;this.timelinePos=e,e>this.bufferedPos&&this.checkBuffer();const t=this.playingItem;if(!t||this.playingLastItem)return;if(e>=t.end){this.timelinePos=t.end;const e=this.findItemIndex(t);this.setSchedulePosition(e+1)}const r=this.playingAsset;if(!r)return;e>=r.timelineStart+(r.duration||0)&&this.setScheduleToAssetAtTime(e,r)},this.onScheduleUpdate=(e,t)=>{const r=this.schedule;if(!r)return;const i=this.playingItem,n=r.events||[],s=r.items||[],a=r.durations,o=e.map(e=>e.identifier),l=!(!n.length&&!o.length);(l||t)&&this.log(`INTERSTITIALS_UPDATED (${n.length}): ${n}\nSchedule: ${s.map(e=>Vy(e))} pos: ${this.timelinePos}`),o.length&&this.log(`Removed events ${o}`);let c=null,d=null;i&&(c=this.updateItem(i,this.timelinePos),this.itemsMatch(i,c)?this.playingItem=c:this.waitingItem=this.endedItem=null),this.waitingItem=this.updateItem(this.waitingItem),this.endedItem=this.updateItem(this.endedItem);const u=this.bufferingItem;if(u&&(d=this.updateItem(u,this.bufferedPos),this.itemsMatch(u,d)?this.bufferingItem=d:u.event&&(this.bufferingItem=this.playingItem,this.clearInterstitial(u.event,null))),e.forEach(e=>{e.assetList.forEach(e=>{this.clearAssetPlayer(e.identifier,null)})}),this.playerQueue.forEach(e=>{if(e.interstitial.appendInPlace){const t=e.assetItem.timelineStart,r=e.timelineOffset-t;if(r)try{e.timelineOffset=t}catch(i){Math.abs(r)>My&&this.warn(`${i} ("${e.assetId}" ${e.timelineOffset}->${t})`)}}}),l||t){if(this.hls.trigger(fu.INTERSTITIALS_UPDATED,{events:n.slice(0),schedule:s.slice(0),durations:a,removedIds:o}),this.isInterstitial(i)&&o.includes(i.event.identifier))return this.warn(`Interstitial "${i.event.identifier}" removed while playing`),void this.primaryFallback(i.event);i&&this.trimInPlace(c,i),u&&d!==c&&this.trimInPlace(d,u),this.checkBuffer()}},this.hls=e,this.HlsPlayerClass=t,this.assetListLoader=new Wy(e),this.schedule=new Hy(this.onScheduleUpdate,e.logger),this.registerListeners()}registerListeners(){const e=this.hls;e&&(e.on(fu.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(fu.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(fu.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(fu.MANIFEST_LOADING,this.onManifestLoading,this),e.on(fu.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(fu.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(fu.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.on(fu.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(fu.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.on(fu.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.on(fu.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.on(fu.BUFFER_APPENDED,this.onBufferAppended,this),e.on(fu.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(fu.BUFFERED_TO_END,this.onBufferedToEnd,this),e.on(fu.MEDIA_ENDED,this.onMediaEnded,this),e.on(fu.ERROR,this.onError,this),e.on(fu.DESTROYING,this.onDestroying,this))}unregisterListeners(){const e=this.hls;e&&(e.off(fu.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(fu.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(fu.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(fu.MANIFEST_LOADING,this.onManifestLoading,this),e.off(fu.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(fu.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(fu.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.off(fu.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(fu.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.off(fu.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.off(fu.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.off(fu.BUFFER_CODECS,this.onBufferCodecs,this),e.off(fu.BUFFER_APPENDED,this.onBufferAppended,this),e.off(fu.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(fu.BUFFERED_TO_END,this.onBufferedToEnd,this),e.off(fu.MEDIA_ENDED,this.onMediaEnded,this),e.off(fu.ERROR,this.onError,this),e.off(fu.DESTROYING,this.onDestroying,this))}startLoad(){this.resumeBuffering()}stopLoad(){this.pauseBuffering()}resumeBuffering(){var e;null==(e=this.getBufferingPlayer())||e.resumeBuffering()}pauseBuffering(){var e;null==(e=this.getBufferingPlayer())||e.pauseBuffering()}destroy(){this.unregisterListeners(),this.stopLoad(),this.assetListLoader&&this.assetListLoader.destroy(),this.emptyPlayerQueue(),this.clearScheduleState(),this.schedule&&this.schedule.destroy(),this.media=this.detachedData=this.mediaSelection=this.requiredTracks=this.altSelection=this.schedule=this.manager=null,this.hls=this.HlsPlayerClass=this.log=null,this.assetListLoader=null,this.onPlay=this.onPause=this.onSeeking=this.onTimeupdate=null,this.onScheduleUpdate=null}onDestroying(){const e=this.primaryMedia||this.media;e&&this.removeMediaListeners(e)}removeMediaListeners(e){km(e,"play",this.onPlay),km(e,"pause",this.onPause),km(e,"seeking",this.onSeeking),km(e,"timeupdate",this.onTimeupdate)}onMediaAttaching(e,t){const r=this.media=t.media;Am(r,"seeking",this.onSeeking),Am(r,"timeupdate",this.onTimeupdate),Am(r,"play",this.onPlay),Am(r,"pause",this.onPause)}onMediaAttached(e,t){const r=this.effectivePlayingItem,i=this.detachedData;if(this.detachedData=null,null===r)this.checkStart();else if(!i){this.clearScheduleState();const e=this.findItemIndex(r);this.setSchedulePosition(e)}}clearScheduleState(){this.log("clear schedule state"),this.playingItem=this.bufferingItem=this.waitingItem=this.endedItem=this.playingAsset=this.endedAsset=this.bufferingAsset=null}onMediaDetaching(e,t){const r=!!t.transferMedia,i=this.media;if(this.media=null,!r&&(i&&this.removeMediaListeners(i),this.detachedData)){const e=this.getBufferingPlayer();e&&(this.log(`Removing schedule state for detachedData and ${e}`),this.playingAsset=this.endedAsset=this.bufferingAsset=this.bufferingItem=this.waitingItem=this.detachedData=null,e.detachMedia()),this.shouldPlay=!1}}get interstitialsManager(){if(!this.hls)return null;if(this.manager)return this.manager;const e=this,t=()=>e.bufferingItem||e.waitingItem,r=t=>t?e.getAssetPlayer(t.identifier):t,i=(t,i,s,a,o)=>{if(t){let l=t[i].start;const c=t.event;if(c){if("playout"===i||c.timelineOccupancy!==Ny.Point){const e=r(s);(null==e?void 0:e.interstitial)===c&&(l+=e.assetItem.startOffset+e[o])}}else{l+=("bufferedPos"===a?n():e[a])-t.start}return l}return 0},n=()=>{const t=e.bufferedPos;return t===Number.MAX_VALUE?s("primary"):Math.max(t,0)},s=t=>{var r,i;return null!=(r=e.primaryDetails)&&r.live?e.primaryDetails.edge:(null==(i=e.schedule)?void 0:i.durations[t])||0},a=(t,n)=>{var s,a;const o=e.effectivePlayingItem;if(null!=o&&null!=(s=o.event)&&s.restrictions.skip||!e.schedule)return;e.log(`seek to ${t} "${n}"`);const l=e.effectivePlayingItem,c=e.schedule.findItemIndexAtTime(t,n),d=null==(a=e.schedule.items)?void 0:a[c],u=e.getBufferingPlayer(),h=null==u?void 0:u.interstitial,f=null==h?void 0:h.appendInPlace,p=l&&e.itemsMatch(l,d);if(l&&(f||p)){const s=r(e.playingAsset),a=(null==s?void 0:s.media)||e.primaryMedia;if(a){const r="primary"===n?a.currentTime:i(l,n,e.playingAsset,"timelinePos","currentTime"),o=t-r,c=(f?r:a.currentTime)+o;if(c>=0&&(!s||f||c<=s.duration))return void(a.currentTime=c)}}if(d){let r=t;if("primary"!==n){const e=t-d[n].start;r=d.start+e}const i=!e.isInterstitial(d);if(e.isInterstitial(l)&&!l.event.appendInPlace||!i&&!d.event.appendInPlace){if(l){const s=e.findItemIndex(l);if(c>s){const t=e.schedule.findJumpRestrictedIndex(s+1,c);if(t>s)return void e.setSchedulePosition(t)}let a=0;if(i)e.timelinePos=r,e.checkBuffer();else{const e=d.event.assetList,r=t-(d[n]||d).start;for(let t=e.length;t--;){const i=e[t];if(i.duration&&r>=i.startOffset&&r<i.startOffset+i.duration){a=t;break}}}e.setSchedulePosition(c,a)}}else{const t=e.media||(f?null==u?void 0:u.media:null);t&&(t.currentTime=r)}}},o=()=>{const r=e.effectivePlayingItem;if(e.isInterstitial(r))return r;const i=t();return e.isInterstitial(i)?i:null},l={get bufferedEnd(){const r=t(),n=e.bufferingItem;var s;return n&&n===r&&(i(n,"playout",e.bufferingAsset,"bufferedPos","bufferedEnd")-n.playout.start||(null==(s=e.bufferingAsset)?void 0:s.startOffset))||0},get currentTime(){const t=o(),r=e.effectivePlayingItem;return r&&r===t?i(r,"playout",e.effectivePlayingAsset,"timelinePos","currentTime")-r.playout.start:0},set currentTime(t){const r=o(),i=e.effectivePlayingItem;i&&i===r&&a(t+i.playout.start,"playout")},get duration(){const e=o();return e?e.playout.end-e.playout.start:0},get assetPlayers(){var t;const r=null==(t=o())?void 0:t.event.assetList;return r?r.map(t=>e.getAssetPlayer(t.identifier)):[]},get playingIndex(){var t;const r=null==(t=o())?void 0:t.event;return r&&e.effectivePlayingAsset?r.findAssetIndex(e.effectivePlayingAsset):-1},get scheduleItem(){return o()}};return this.manager={get events(){var t;return(null==(t=e.schedule)||null==(t=t.events)?void 0:t.slice(0))||[]},get schedule(){var t;return(null==(t=e.schedule)||null==(t=t.items)?void 0:t.slice(0))||[]},get interstitialPlayer(){return o()?l:null},get playerQueue(){return e.playerQueue.slice(0)},get bufferingAsset(){return e.bufferingAsset},get bufferingItem(){return t()},get bufferingIndex(){const r=t();return e.findItemIndex(r)},get playingAsset(){return e.effectivePlayingAsset},get playingItem(){return e.effectivePlayingItem},get playingIndex(){const t=e.effectivePlayingItem;return e.findItemIndex(t)},primary:{get bufferedEnd(){return n()},get currentTime(){const t=e.timelinePos;return t>0?t:0},set currentTime(e){a(e,"primary")},get duration(){return s("primary")},get seekableStart(){var t;return(null==(t=e.primaryDetails)?void 0:t.fragmentStart)||0}},integrated:{get bufferedEnd(){return i(t(),"integrated",e.bufferingAsset,"bufferedPos","bufferedEnd")},get currentTime(){return i(e.effectivePlayingItem,"integrated",e.effectivePlayingAsset,"timelinePos","currentTime")},set currentTime(e){a(e,"integrated")},get duration(){return s("integrated")},get seekableStart(){var t;return((t,r)=>{var i;if(0!==t&&"primary"!==r&&null!=(i=e.schedule)&&i.length){var n;const i=e.schedule.findItemIndexAtTime(t),s=null==(n=e.schedule.items)?void 0:n[i];if(s)return t+(s[r].start-s.start)}return t})((null==(t=e.primaryDetails)?void 0:t.fragmentStart)||0,"integrated")}},skip:()=>{const t=e.effectivePlayingItem,r=null==t?void 0:t.event;if(r&&!r.restrictions.skip){const i=e.findItemIndex(t);if(r.appendInPlace){const e=t.playout.start+t.event.duration;a(e+.001,"playout")}else e.advanceAfterAssetEnded(r,i,1/0)}}}}get effectivePlayingItem(){return this.waitingItem||this.playingItem||this.endedItem}get effectivePlayingAsset(){return this.playingAsset||this.endedAsset}get playingLastItem(){var e;const t=this.playingItem,r=null==(e=this.schedule)?void 0:e.items;return!!(this.playbackStarted&&t&&r)&&this.findItemIndex(t)===r.length-1}get playbackStarted(){return null!==this.effectivePlayingItem}get currentTime(){var e,t;if(null===this.mediaSelection)return;const r=this.waitingItem||this.playingItem;if(this.isInterstitial(r)&&!r.event.appendInPlace)return;let i=this.media;!i&&null!=(e=this.bufferingItem)&&null!=(e=e.event)&&e.appendInPlace&&(i=this.primaryMedia);const n=null==(t=i)?void 0:t.currentTime;return void 0!==n&&lu(n)?n:void 0}get primaryMedia(){var e;return this.media||(null==(e=this.detachedData)?void 0:e.media)||null}isInterstitial(e){return!(null==e||!e.event)}retreiveMediaSource(e,t){const r=this.getAssetPlayer(e);r&&this.transferMediaFromPlayer(r,t)}transferMediaFromPlayer(e,t){const r=e.interstitial.appendInPlace,i=e.media;if(r&&i===this.primaryMedia){if(this.bufferingAsset=null,(!t||this.isInterstitial(t)&&!t.event.appendInPlace)&&t&&i)return void(this.detachedData={media:i});const r=e.transferMedia();this.log(`transfer MediaSource from ${e} ${cf(r)}`),this.detachedData=r}else t&&i&&(this.shouldPlay||(this.shouldPlay=!i.paused))}transferMediaTo(e,t){var r,i;if(e.media===t)return;let n=null;const s=this.hls,a=e!==s,o=a&&e.interstitial.appendInPlace,l=null==(r=this.detachedData)?void 0:r.mediaSource;let c;if(s.media)o&&(n=s.transferMedia(),this.detachedData=n),c="Primary";else if(l){const e=this.getBufferingPlayer();e?(n=e.transferMedia(),c=`${e}`):c="detached MediaSource"}else c="detached media";if(!n)if(l)n=this.detachedData,this.log(`using detachedData: MediaSource ${cf(n)}`);else if(!this.detachedData||s.media===t){const e=this.playerQueue;e.length>1&&e.forEach(e=>{if(a&&e.interstitial.appendInPlace!==o){const t=e.interstitial;this.clearInterstitial(e.interstitial,null),t.appendInPlace=!1,t.appendInPlace&&this.warn(`Could not change append strategy for queued assets ${t}`)}}),this.hls.detachMedia(),this.detachedData={media:t}}const d=n&&"mediaSource"in n&&"closed"!==(null==(i=n.mediaSource)?void 0:i.readyState),u=d&&n?n:t;this.log(`${d?"transfering MediaSource":"attaching media"} to ${a?e:"Primary"} from ${c} (media.currentTime: ${t.currentTime})`);const h=this.schedule;if(u===n&&h){const t=a&&e.assetId===h.assetIdAtEnd;u.overrides={duration:h.duration,endOfStream:!a||t,cueRemoval:!a}}e.attachMedia(u)}onInterstitialCueEnter(){this.onTimeupdate()}checkStart(){const e=this.schedule,t=null==e?void 0:e.events;if(!t||this.playbackDisabled||!this.media)return;-1===this.bufferedPos&&(this.bufferedPos=0);const r=this.timelinePos,i=this.effectivePlayingItem;if(-1===r){const r=this.hls.startPosition;if(this.log(Ky("checkStart",r)),this.timelinePos=r,t.length&&t[0].cue.pre){const r=e.findEventIndex(t[0].identifier);this.setSchedulePosition(r)}else if(r>=0||!this.primaryLive){const t=this.timelinePos=r>0?r:0,i=e.findItemIndexAtTime(t);this.setSchedulePosition(i)}}else if(i&&!this.playingItem){const t=e.findItemIndex(i);this.setSchedulePosition(t)}}advanceAssetBuffering(e,t){const r=e.event,i=r.findAssetIndex(t),n=zy(r,i);if(r.isAssetPastPlayoutLimit(n)){if(this.schedule){var s;const t=null==(s=this.schedule.items)?void 0:s[this.findItemIndex(e)+1];t&&this.bufferedToItem(t)}}else this.bufferedToEvent(e,n)}advanceAfterAssetEnded(e,t,r){const i=zy(e,r);if(e.isAssetPastPlayoutLimit(i)){if(this.schedule){const r=this.schedule.items;if(r){const i=t+1;if(i>=r.length)return void this.setSchedulePosition(-1);const n=e.resumeTime;this.timelinePos<n&&(this.log(Ky("advanceAfterAssetEnded",n)),this.timelinePos=n,e.appendInPlace&&this.advanceInPlace(n),this.checkBuffer(this.bufferedPos<n)),this.setSchedulePosition(i)}}}else{if(e.appendInPlace){const t=e.assetList[i];t&&this.advanceInPlace(t.timelineStart)}this.setSchedulePosition(t,i)}}setScheduleToAssetAtTime(e,t){const r=this.schedule;if(!r)return;const i=t.parentIdentifier,n=r.getEvent(i);if(n){const t=r.findEventIndex(i),s=r.findAssetIndex(n,e);this.advanceAfterAssetEnded(n,t,s-1)}}setSchedulePosition(e,t){var r;const i=null==(r=this.schedule)?void 0:r.items;if(!i||this.playbackDisabled)return;const n=e>=0?i[e]:null;this.log(`setSchedulePosition ${e}, ${t} (${n?Vy(n):n}) pos: ${this.timelinePos}`);const s=this.waitingItem||this.playingItem,a=this.playingLastItem;if(this.isInterstitial(s)){const r=s.event,c=this.playingAsset,d=null==c?void 0:c.identifier,u=d?this.getAssetPlayer(d):null;if(u&&d&&(!this.eventItemsMatch(s,n)||void 0!==t&&d!==r.assetList[t].identifier)){var o;const t=r.findAssetIndex(c);if(this.log(`INTERSTITIAL_ASSET_ENDED ${t+1}/${r.assetList.length} ${Gy(c)}`),this.endedAsset=c,this.playingAsset=null,this.hls.trigger(fu.INTERSTITIAL_ASSET_ENDED,{asset:c,assetListIndex:t,event:r,schedule:i.slice(0),scheduleIndex:e,player:u}),s!==this.playingItem)return void(this.itemsMatch(s,this.playingItem)&&!this.playingAsset&&this.advanceAfterAssetEnded(r,this.findItemIndex(this.playingItem),t));this.retreiveMediaSource(d,n),!u.media||null!=(o=this.detachedData)&&o.mediaSource||u.detachMedia()}if(!this.eventItemsMatch(s,n)&&(this.endedItem=s,this.playingItem=null,this.log(`INTERSTITIAL_ENDED ${r} ${Vy(s)}`),r.hasPlayed=!0,this.hls.trigger(fu.INTERSTITIAL_ENDED,{event:r,schedule:i.slice(0),scheduleIndex:e}),r.cue.once)){var l;this.updateSchedule();const e=null==(l=this.schedule)?void 0:l.items;if(n&&e){const r=this.findItemIndex(n);this.advanceSchedule(r,e,t,s,a)}return}}this.advanceSchedule(e,i,t,s,a)}advanceSchedule(e,t,r,i,n){const s=this.schedule;if(!s)return;const a=t[e]||null,o=this.primaryMedia,l=this.playerQueue;if(l.length&&l.forEach(t=>{const r=t.interstitial,i=s.findEventIndex(r.identifier);(i<e||i>e+1)&&this.clearInterstitial(r,a)}),this.isInterstitial(a)){this.timelinePos=Math.min(Math.max(this.timelinePos,a.start),a.end);const n=a.event;if(void 0===r){const t=zy(n,(r=s.findAssetIndex(n,this.timelinePos))-1);if(n.isAssetPastPlayoutLimit(t)||n.appendInPlace&&this.timelinePos===a.end)return void this.advanceAfterAssetEnded(n,e,r);r=t}const l=this.waitingItem;this.assetsBuffered(a,o)||this.setBufferingItem(a);let c=this.preloadAssets(n,r);if(this.eventItemsMatch(a,l||i)||(this.waitingItem=a,this.log(`INTERSTITIAL_STARTED ${Vy(a)} ${n.appendInPlace?"append in place":""}`),this.hls.trigger(fu.INTERSTITIAL_STARTED,{event:n,schedule:t.slice(0),scheduleIndex:e})),!n.assetListLoaded)return void this.log(`Waiting for ASSET-LIST to complete loading ${n}`);if(n.assetListLoader&&(n.assetListLoader.destroy(),n.assetListLoader=void 0),!o)return void this.log(`Waiting for attachMedia to start Interstitial ${n}`);this.waitingItem=this.endedItem=null,this.playingItem=a;const d=n.assetList[r];if(!d)return void this.advanceAfterAssetEnded(n,e,r||0);if(c||(c=this.getAssetPlayer(d.identifier)),null===c||c.destroyed){const e=n.assetList.length;this.warn(`asset ${r+1}/${e} player destroyed ${n}`),c=this.createAssetPlayer(n,d,r),c.loadSource()}if(!this.eventItemsMatch(a,this.bufferingItem)&&n.appendInPlace&&this.isAssetBuffered(d))return;this.startAssetPlayer(c,r,t,e,o),this.shouldPlay&&Yy(c.media)}else a?(this.resumePrimary(a,e,i),this.shouldPlay&&Yy(this.hls.media)):n&&this.isInterstitial(i)&&(this.endedItem=null,this.playingItem=i,i.event.appendInPlace||this.attachPrimary(s.durations.primary,null))}get playbackDisabled(){return!1===this.hls.config.enableInterstitialPlayback}get primaryDetails(){var e;return null==(e=this.mediaSelection)?void 0:e.main.details}get primaryLive(){var e;return!(null==(e=this.primaryDetails)||!e.live)}resumePrimary(e,t,r){var i,n;if(this.playingItem=e,this.playingAsset=this.endedAsset=null,this.waitingItem=this.endedItem=null,this.bufferedToItem(e),this.log(`resuming ${Vy(e)}`),null==(i=this.detachedData)||!i.mediaSource){let r=this.timelinePos;(r<e.start||r>=e.end)&&(r=this.getPrimaryResumption(e,t),this.log(Ky("resumePrimary",r)),this.timelinePos=r),this.attachPrimary(r,e)}if(!r)return;const s=null==(n=this.schedule)?void 0:n.items;s&&(this.log(`INTERSTITIALS_PRIMARY_RESUMED ${Vy(e)}`),this.hls.trigger(fu.INTERSTITIALS_PRIMARY_RESUMED,{schedule:s.slice(0),scheduleIndex:t}),this.checkBuffer())}getPrimaryResumption(e,t){const r=e.start;if(this.primaryLive){const e=this.primaryDetails;if(0===t)return this.hls.startPosition;if(e&&(r<e.fragmentStart||r>e.edge))return this.hls.liveSyncPosition||-1}return r}isAssetBuffered(e){const t=this.getAssetPlayer(e.identifier);if(null!=t&&t.hls)return t.hls.bufferedToEnd;return lp.bufferInfo(this.primaryMedia,this.timelinePos,0).end+1>=e.timelineStart+(e.duration||0)}attachPrimary(e,t,r){t?this.setBufferingItem(t):this.bufferingItem=this.playingItem,this.bufferingAsset=null;const i=this.primaryMedia;if(!i)return;const n=this.hls;n.media?this.checkBuffer():(this.transferMediaTo(n,i),r&&this.startLoadingPrimaryAt(e,r)),r||(this.log(Ky("attachPrimary",e)),this.timelinePos=e,this.startLoadingPrimaryAt(e,r))}startLoadingPrimaryAt(e,t){var r;const i=this.hls;!i.loadingEnabled||!i.media||Math.abs(((null==(r=i.mainForwardBufferInfo)?void 0:r.start)||i.media.currentTime)-e)>.5?i.startLoad(e,t):i.bufferingEnabled||i.resumeBuffering()}onManifestLoading(){var e;this.stopLoad(),null==(e=this.schedule)||e.reset(),this.emptyPlayerQueue(),this.clearScheduleState(),this.shouldPlay=!1,this.bufferedPos=this.timelinePos=-1,this.mediaSelection=this.altSelection=this.manager=this.requiredTracks=null,this.hls.off(fu.BUFFER_CODECS,this.onBufferCodecs,this),this.hls.on(fu.BUFFER_CODECS,this.onBufferCodecs,this)}onLevelUpdated(e,t){if(-1===t.level||!this.schedule)return;const r=this.hls.levels[t.level];if(!r.details)return;const i=ku(ku({},this.mediaSelection||this.altSelection),{},{main:r});this.mediaSelection=i,this.schedule.parseInterstitialDateRanges(i,this.hls.config.interstitialAppendInPlace),!this.effectivePlayingItem&&this.schedule.items&&this.checkStart()}onAudioTrackUpdated(e,t){const r=this.hls.audioTracks[t.id],i=this.mediaSelection;if(!i)return void(this.altSelection=ku(ku({},this.altSelection),{},{audio:r}));const n=ku(ku({},i),{},{audio:r});this.mediaSelection=n}onSubtitleTrackUpdated(e,t){const r=this.hls.subtitleTracks[t.id],i=this.mediaSelection;if(!i)return void(this.altSelection=ku(ku({},this.altSelection),{},{subtitles:r}));const n=ku(ku({},i),{},{subtitles:r});this.mediaSelection=n}onAudioTrackSwitching(e,t){const r=hf(t);this.playerQueue.forEach(({hls:e})=>e&&(e.setAudioOption(t)||e.setAudioOption(r)))}onSubtitleTrackSwitch(e,t){const r=hf(t);this.playerQueue.forEach(({hls:e})=>e&&(e.setSubtitleOption(t)||-1!==t.id&&e.setSubtitleOption(r)))}onBufferCodecs(e,t){const r=t.tracks;r&&(this.requiredTracks=r)}onBufferAppended(e,t){this.checkBuffer()}onBufferFlushed(e,t){const r=this.playingItem;if(r&&!this.itemsMatch(r,this.bufferingItem)&&!this.isInterstitial(r)){const e=this.timelinePos;this.bufferedPos=e,this.checkBuffer()}}onBufferedToEnd(e){if(!this.schedule)return;const t=this.schedule.events;if(this.bufferedPos<Number.MAX_VALUE&&t){for(let e=0;e<t.length;e++){const i=t[e];if(i.cue.post){var r;const e=this.schedule.findEventIndex(i.identifier),t=null==(r=this.schedule.items)?void 0:r[e];this.isInterstitial(t)&&this.eventItemsMatch(t,this.bufferingItem)&&this.bufferedToItem(t,0);break}}this.bufferedPos=Number.MAX_VALUE}}onMediaEnded(e){const t=this.playingItem;if(!this.playingLastItem&&t){const e=this.findItemIndex(t);this.setSchedulePosition(e+1)}else this.shouldPlay=!1}updateItem(e,t){var r;const i=null==(r=this.schedule)?void 0:r.items;if(e&&i){return i[this.findItemIndex(e,t)]||null}return null}trimInPlace(e,t){if(this.isInterstitial(e)&&e.event.appendInPlace&&t.end-e.end>.25){e.event.assetList.forEach((t,r)=>{e.event.isAssetPastPlayoutLimit(r)&&this.clearAssetPlayer(t.identifier,null)});const r=e.end+.25,i=lp.bufferInfo(this.primaryMedia,r,0);if(i.end>r||(i.nextStart||0)>r){this.log(`trim buffered interstitial ${Vy(e)} (was ${Vy(t)})`);const i=!0;this.attachPrimary(r,null,i),this.flushFrontBuffer(r)}}}itemsMatch(e,t){return!!t&&(e===t||e.event&&t.event&&this.eventItemsMatch(e,t)||!e.event&&!t.event&&this.findItemIndex(e)===this.findItemIndex(t))}eventItemsMatch(e,t){var r;return!!t&&(e===t||e.event.identifier===(null==(r=t.event)?void 0:r.identifier))}findItemIndex(e,t){return e&&this.schedule?this.schedule.findItemIndex(e,t):-1}updateSchedule(e=!1){var t;const r=this.mediaSelection;r&&(null==(t=this.schedule)||t.updateSchedule(r,[],e))}checkBuffer(e){var t;const r=null==(t=this.schedule)?void 0:t.items;if(!r)return;const i=lp.bufferInfo(this.primaryMedia,this.timelinePos,0);e&&(this.bufferedPos=this.timelinePos),e||(e=i.len<1),this.updateBufferedPos(i.end,r,e)}updateBufferedPos(e,t,r){const i=this.schedule,n=this.bufferingItem;if(this.bufferedPos>e||!i)return;if(1===t.length&&this.itemsMatch(t[0],n))return void(this.bufferedPos=e);const s=this.playingItem,a=this.findItemIndex(s);let o=i.findItemIndexAtTime(e);if(this.bufferedPos<e){var l;const r=this.findItemIndex(n),i=Math.min(r+1,t.length-1),s=t[i];if((-1===o&&n&&e>=n.end||null!=(l=s.event)&&l.appendInPlace&&e+.01>=s.start)&&(o=i),this.isInterstitial(n)){const e=n.event;if(i-a>1&&!1===e.appendInPlace)return;if(0===e.assetList.length&&e.assetListLoader)return}if(this.bufferedPos=e,o>r&&o>a)this.bufferedToItem(s);else{const t=this.primaryDetails;this.primaryLive&&t&&e>t.edge-t.targetduration&&s.start<t.edge+this.hls.config.interstitialLiveLookAhead&&this.isInterstitial(s)&&this.preloadAssets(s.event,0)}}else r&&s&&!this.itemsMatch(s,n)&&(o===a?this.bufferedToItem(s):o===a+1&&this.bufferedToItem(t[o]))}assetsBuffered(e,t){return 0!==e.event.assetList.length&&!e.event.assetList.some(e=>{const r=this.getAssetPlayer(e.identifier);return!(null!=r&&r.bufferedInPlaceToEnd(t))})}setBufferingItem(e){const t=this.bufferingItem,r=this.schedule;if(!this.itemsMatch(e,t)&&r){const{items:i,events:n}=r;if(!i||!n)return t;const s=this.isInterstitial(e),a=this.getBufferingPlayer();this.bufferingItem=e,this.bufferedPos=Math.max(e.start,Math.min(e.end,this.timelinePos));const o=a?a.remaining:t?t.end-this.timelinePos:0;if(this.log(`INTERSTITIALS_BUFFERED_TO_BOUNDARY ${Vy(e)}`+(t?` (${o.toFixed(2)} remaining)`:"")),!this.playbackDisabled)if(s){const t=r.findAssetIndex(e.event,this.bufferedPos);e.event.assetList.forEach((e,r)=>{const i=this.getAssetPlayer(e.identifier);i&&(r===t&&i.loadSource(),i.resumeBuffering())})}else this.hls.resumeBuffering(),this.playerQueue.forEach(e=>e.pauseBuffering());this.hls.trigger(fu.INTERSTITIALS_BUFFERED_TO_BOUNDARY,{events:n.slice(0),schedule:i.slice(0),bufferingIndex:this.findItemIndex(e),playingIndex:this.findItemIndex(this.playingItem)})}else this.bufferingItem!==e&&(this.bufferingItem=e);return t}bufferedToItem(e,t=0){const r=this.setBufferingItem(e);if(!this.playbackDisabled)if(this.isInterstitial(e))this.bufferedToEvent(e,t);else if(null!==r){this.bufferingAsset=null;const t=this.detachedData;if(t)if(t.mediaSource){const t=!0;this.attachPrimary(e.start,e,t)}else this.preloadPrimary(e);else this.preloadPrimary(e)}}preloadPrimary(e){const t=this.findItemIndex(e),r=this.getPrimaryResumption(e,t);this.startLoadingPrimaryAt(r)}bufferedToEvent(e,t){const r=e.event,i=0===r.assetList.length&&!r.assetListLoader,n=r.cue.once;if(i||!n){const e=this.preloadAssets(r,t);if(null!=e&&e.interstitial.appendInPlace){const t=this.primaryMedia;t&&this.bufferAssetPlayer(e,t)}}}preloadAssets(e,t){const r=e.assetUrl,i=e.assetList.length,n=0===i&&!e.assetListLoader,s=e.cue.once;if(n){const n=e.timelineStart;if(e.appendInPlace){var a;const t=this.playingItem;this.isInterstitial(t)||(null==t||null==(a=t.nextEvent)?void 0:a.identifier)!==e.identifier||this.flushFrontBuffer(n+.25)}let s,o=0;if(!this.playingItem&&this.primaryLive&&(o=this.hls.startPosition,-1===o&&(o=this.hls.liveSyncPosition||0)),o&&!e.cue.pre&&!e.cue.post){const e=o-n;e>0&&(s=Math.round(1e3*e)/1e3)}if(this.log(`Load interstitial asset ${t+1}/${r?1:i} ${e}${s?` live-start: ${o} start-offset: ${s}`:""}`),r)return this.createAsset(e,0,0,n,e.duration,r);const l=this.assetListLoader.loadAssetList(e,s);l&&(e.assetListLoader=l)}else if(!s&&i){for(let r=t;r<i;r++){const t=e.assetList[r],i=this.getAssetPlayerQueueIndex(t.identifier);-1!==i&&!this.playerQueue[i].destroyed||t.error||this.createAssetPlayer(e,t,r)}const r=e.assetList[t];if(r){const e=this.getAssetPlayer(r.identifier);return e&&e.loadSource(),e}}return null}flushFrontBuffer(e){const t=this.requiredTracks;if(!t)return;this.log(`Removing front buffer starting at ${e}`);Object.keys(t).forEach(t=>{this.hls.trigger(fu.BUFFER_FLUSHING,{startOffset:e,endOffset:1/0,type:t})})}getAssetPlayerQueueIndex(e){const t=this.playerQueue;for(let r=0;r<t.length;r++)if(e===t[r].assetId)return r;return-1}getAssetPlayer(e){const t=this.getAssetPlayerQueueIndex(e);return this.playerQueue[t]||null}getBufferingPlayer(){const{playerQueue:e,primaryMedia:t}=this;if(t)for(let r=0;r<e.length;r++)if(e[r].media===t)return e[r];return null}createAsset(e,t,r,i,n,s){const a={parentIdentifier:e.identifier,identifier:Fy(e,s,t),duration:n,startOffset:r,timelineStart:i,uri:s};return this.createAssetPlayer(e,a,t)}createAssetPlayer(e,t,r){const i=this.hls,n=i.userConfig;let s=n.videoPreference;const a=i.loadLevelObj||i.levels[i.currentLevel];(s||a)&&(s=xu({},s),a.videoCodec&&(s.videoCodec=a.videoCodec),a.videoRange&&(s.allowedVideoRanges=[a.videoRange]));const o=i.audioTracks[i.audioTrack],l=i.subtitleTracks[i.subtitleTrack];let c=0;if(this.primaryLive||e.appendInPlace){const e=this.timelinePos-t.timelineStart;if(e>1){const r=t.duration;r&&e<r&&(c=e)}}const d=t.identifier,u=ku(ku({},n),{},{maxMaxBufferLength:Math.min(180,i.config.maxMaxBufferLength),autoStartLoad:!0,startFragPrefetch:!0,primarySessionId:i.sessionId,assetPlayerId:d,abrEwmaDefaultEstimate:i.bandwidthEstimate,interstitialsController:void 0,startPosition:c,liveDurationInfinity:!1,testBandwidth:!1,videoPreference:s,audioPreference:o||n.audioPreference,subtitlePreference:l||n.subtitlePreference});e.appendInPlace&&(e.appendInPlaceStarted=!0,t.timelineStart&&(u.timelineOffset=t.timelineStart));const h=u.cmcd;null!=h&&h.sessionId&&h.contentId&&(u.cmcd=xu({},h,{contentId:Oy(t.uri)})),this.getAssetPlayer(d)&&this.warn(`Duplicate date range identifier ${e} and asset ${d}`);const f=new jy(this.HlsPlayerClass,u,e,t);this.playerQueue.push(f),e.assetList[r]=t;let p=!0;const m=i=>{if(i.live){var n;const t=new Error(`Interstitials MUST be VOD assets ${e}`),i={fatal:!0,type:uu.OTHER_ERROR,details:hu.INTERSTITIAL_ASSET_ITEM_ERROR,error:t},s=(null==(n=this.schedule)?void 0:n.findEventIndex(e.identifier))||-1;return void this.handleAssetItemError(i,e,s,r,t.message)}const s=i.edge-i.fragmentStart,a=t.duration;(p||null===a||s>a)&&(p=!1,this.log(`Interstitial asset "${d}" duration change ${a} > ${s}`),t.duration=s,this.updateSchedule())};f.on(fu.LEVEL_UPDATED,(e,{details:t})=>m(t)),f.on(fu.LEVEL_PTS_UPDATED,(e,{details:t})=>m(t)),f.on(fu.EVENT_CUE_ENTER,()=>this.onInterstitialCueEnter());const g=(e,t)=>{const r=this.getAssetPlayer(d);if(r&&t.tracks){r.off(fu.BUFFER_CODECS,g),r.tracks=t.tracks;const e=this.primaryMedia;this.bufferingAsset===r.assetItem&&e&&!r.media&&this.bufferAssetPlayer(r,e)}};f.on(fu.BUFFER_CODECS,g);f.on(fu.BUFFERED_TO_END,()=>{var r;const i=this.getAssetPlayer(d);if(this.log(`buffered to end of asset ${i}`),!i||!this.schedule)return;const n=this.schedule.findEventIndex(e.identifier),s=null==(r=this.schedule.items)?void 0:r[n];this.isInterstitial(s)&&this.advanceAssetBuffering(s,t)});const v=t=>()=>{if(!this.getAssetPlayer(d)||!this.schedule)return;this.shouldPlay=!0;const r=this.schedule.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,r,t)};return f.once(fu.MEDIA_ENDED,v(r)),f.once(fu.PLAYOUT_LIMIT_REACHED,v(1/0)),f.on(fu.ERROR,(t,i)=>{if(!this.schedule)return;const n=this.getAssetPlayer(d);if(i.details===hu.BUFFER_STALLED_ERROR)return null!=n&&n.appendInPlace?void this.handleInPlaceStall(e):(this.onTimeupdate(),void this.checkBuffer(!0));this.handleAssetItemError(i,e,this.schedule.findEventIndex(e.identifier),r,`Asset player error ${i.error} ${e}`)}),f.on(fu.DESTROYING,()=>{if(!this.getAssetPlayer(d)||!this.schedule)return;const t=new Error(`Asset player destroyed unexpectedly ${d}`),i={fatal:!0,type:uu.OTHER_ERROR,details:hu.INTERSTITIAL_ASSET_ITEM_ERROR,error:t};this.handleAssetItemError(i,e,this.schedule.findEventIndex(e.identifier),r,t.message)}),this.log(`INTERSTITIAL_ASSET_PLAYER_CREATED ${Gy(t)}`),this.hls.trigger(fu.INTERSTITIAL_ASSET_PLAYER_CREATED,{asset:t,assetListIndex:r,event:e,player:f}),f}clearInterstitial(e,t){this.clearAssetPlayers(e,t),e.reset()}clearAssetPlayers(e,t){e.assetList.forEach(e=>{this.clearAssetPlayer(e.identifier,t)})}resetAssetPlayer(e){const t=this.getAssetPlayerQueueIndex(e);if(-1!==t){this.log(`reset asset player "${e}" after error`);const r=this.playerQueue[t];this.transferMediaFromPlayer(r,null),r.resetDetails()}}clearAssetPlayer(e,t){const r=this.getAssetPlayerQueueIndex(e);if(-1!==r){const e=this.playerQueue[r];this.log(`clear ${e} toSegment: ${t?Vy(t):t}`),this.transferMediaFromPlayer(e,t),this.playerQueue.splice(r,1),e.destroy()}}emptyPlayerQueue(){let e;for(;e=this.playerQueue.pop();)e.destroy();this.playerQueue=[]}startAssetPlayer(e,t,r,i,n){const{interstitial:s,assetItem:a,assetId:o}=e,l=s.assetList.length,c=this.playingAsset;this.endedAsset=null,this.playingAsset=a,c&&c.identifier===o||(c&&(this.clearAssetPlayer(c.identifier,r[i]),delete c.error),this.log(`INTERSTITIAL_ASSET_STARTED ${t+1}/${l} ${Gy(a)}`),this.hls.trigger(fu.INTERSTITIAL_ASSET_STARTED,{asset:a,assetListIndex:t,event:s,schedule:r.slice(0),scheduleIndex:i,player:e})),this.bufferAssetPlayer(e,n)}bufferAssetPlayer(e,t){var r,i;if(!this.schedule)return;const{interstitial:n,assetItem:s}=e,a=this.schedule.findEventIndex(n.identifier),o=null==(r=this.schedule.items)?void 0:r[a];if(!o)return;e.loadSource(),this.setBufferingItem(o),this.bufferingAsset=s;const l=this.getBufferingPlayer();if(l===e)return;const c=n.appendInPlace;if(c&&!1===(null==l?void 0:l.interstitial.appendInPlace))return;const d=(null==l?void 0:l.tracks)||(null==(i=this.detachedData)?void 0:i.tracks)||this.requiredTracks;if(c&&s!==this.playingAsset){if(!e.tracks)return void this.log(`Waiting for track info before buffering ${e}`);if(d&&!Mu(d,e.tracks)){const t=new Error(`Asset ${Gy(s)} SourceBuffer tracks ('${Object.keys(e.tracks)}') are not compatible with primary content tracks ('${Object.keys(d)}')`),r={fatal:!0,type:uu.OTHER_ERROR,details:hu.INTERSTITIAL_ASSET_ITEM_ERROR,error:t},i=n.findAssetIndex(s);return void this.handleAssetItemError(r,n,a,i,t.message)}}this.transferMediaTo(e,t)}handleInPlaceStall(e){const t=this.schedule,r=this.primaryMedia;if(!t||!r)return;const i=r.currentTime,n=t.findAssetIndex(e,i),s=e.assetList[n];if(s){const a=this.getAssetPlayer(s.identifier);if(a){const o=a.currentTime||i-s.timelineStart,l=a.duration-o;if(this.warn(`Stalled at ${o} of ${o+l} in ${a} ${e} (media.currentTime: ${i})`),o&&(l/r.playbackRate<.5||a.bufferedInPlaceToEnd(r))&&a.hls){const r=t.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,r,n)}}}}advanceInPlace(e){const t=this.primaryMedia;t&&t.currentTime<e&&(t.currentTime=e)}handleAssetItemError(e,t,r,i,n){if(e.details===hu.BUFFER_STALLED_ERROR)return;const s=t.assetList[i]||null;if(this.warn(`INTERSTITIAL_ASSET_ERROR ${s?Gy(s):s} ${e.error}`),!this.schedule)return;const a=(null==s?void 0:s.identifier)||"",o=this.getAssetPlayerQueueIndex(a),l=this.playerQueue[o]||null,c=this.schedule.items,d=xu({},e,{fatal:!1,errorAction:Bf(!0),asset:s,assetListIndex:i,event:t,schedule:c,scheduleIndex:r,player:l});if(this.hls.trigger(fu.INTERSTITIAL_ASSET_ERROR,d),!e.fatal)return;const u=this.playingAsset,h=this.bufferingAsset,f=new Error(n);if(s&&(this.clearAssetPlayer(a,null),s.error=f),t.assetList.some(e=>!e.error))for(let e=i;e<t.assetList.length;e++)this.resetAssetPlayer(t.assetList[e].identifier);else t.error=f;this.updateSchedule(!0),t.error?this.primaryFallback(t):u&&u.identifier===a?this.advanceAfterAssetEnded(t,r,i):h&&h.identifier===a&&this.isInterstitial(this.bufferingItem)&&this.advanceAssetBuffering(this.bufferingItem,h)}primaryFallback(e){const t=e.timelineStart,r=this.effectivePlayingItem;let i=this.timelinePos;if(r){this.log(`Fallback to primary from event "${e.identifier}" start: ${t} pos: ${i} playing: ${Vy(r)} error: ${e.error}`),-1===i&&(i=this.hls.startPosition);const n=this.updateItem(r,i);this.itemsMatch(r,n)&&this.clearInterstitial(e,null),e.appendInPlace&&(this.attachPrimary(t,null),this.flushFrontBuffer(t))}else if(-1===i)return void this.checkStart();if(!this.schedule)return;const n=this.schedule.findItemIndexAtTime(i);this.setSchedulePosition(n)}onAssetListLoaded(e,t){var r,i;const n=t.event,s=n.identifier,a=t.assetListResponse.ASSETS;if(null==(r=this.schedule)||!r.hasEvent(s))return;const o=n.timelineStart,l=n.duration;let c=0;a.forEach((e,t)=>{const r=parseFloat(e.DURATION);this.createAsset(n,t,c,o+c,r,e.URI),c+=r}),n.duration=c,this.log(`Loaded asset-list with duration: ${c} (was: ${l}) ${n}`);const d=this.waitingItem,u=(null==d?void 0:d.event.identifier)===s;this.updateSchedule();const h=null==(i=this.bufferingItem)?void 0:i.event;if(u){var f;const e=this.schedule.findEventIndex(s),t=null==(f=this.schedule.items)?void 0:f[e];if(t){if(!this.playingItem&&this.timelinePos>t.end){if(this.schedule.findItemIndexAtTime(this.timelinePos)!==e)return n.error=new Error(`Interstitial ${a.length?"no longer within playback range":"asset-list is empty"} ${this.timelinePos} ${n}`),this.log(n.error.message),this.updateSchedule(!0),void this.primaryFallback(n)}this.setBufferingItem(t)}this.setSchedulePosition(e)}else if((null==h?void 0:h.identifier)===s){const e=n.assetList[0];if(e){const t=this.getAssetPlayer(e.identifier);if(h.appendInPlace){const e=this.primaryMedia;t&&e&&this.bufferAssetPlayer(t,e)}else t&&t.loadSource()}}}onError(e,t){if(this.schedule)switch(t.details){case hu.ASSET_LIST_PARSING_ERROR:case hu.ASSET_LIST_LOAD_ERROR:case hu.ASSET_LIST_LOAD_TIMEOUT:{const e=t.interstitial;e&&(this.updateSchedule(!0),this.primaryFallback(e));break}case hu.BUFFER_STALLED_ERROR:{const e=this.endedItem||this.waitingItem||this.playingItem;if(this.isInterstitial(e)&&e.event.appendInPlace)return void this.handleInPlaceStall(e.event);this.log(`Primary player stall @${this.timelinePos} bufferedPos: ${this.bufferedPos}`),this.onTimeupdate(),this.checkBuffer(!0);break}}}}});function Jb(e){return e&&"object"==typeof e?Array.isArray(e)?e.map(Jb):Object.keys(e).reduce((t,r)=>(t[r]=Jb(e[r]),t),{}):e}function eE(e,t){const r=e.loader;if(r!==Yb&&r!==Qb)t.log("[config]: Custom loader detected, cannot enable progressive streaming"),e.progressive=!1;else{(function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(e){}return!1})()&&(e.loader=Yb,e.progressive=!0,e.enableSoftwareAES=!0,t.log("[config]: Progressive streaming enabled, using FetchLoader"))}}class tE extends sp{constructor(e,t){super("gap-controller",e.logger),this.hls=void 0,this.fragmentTracker=void 0,this.media=null,this.mediaSource=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.buffered={},this.lastCurrentTime=0,this.ended=0,this.waiting=0,this.onMediaPlaying=()=>{this.ended=0,this.waiting=0},this.onMediaWaiting=()=>{var e;null!=(e=this.media)&&e.seeking||(this.waiting=self.performance.now(),this.tick())},this.onMediaEnded=()=>{var e;this.hls&&(this.ended=(null==(e=this.media)?void 0:e.currentTime)||1,this.hls.trigger(fu.MEDIA_ENDED,{stalled:!1}))},this.hls=e,this.fragmentTracker=t,this.registerListeners()}registerListeners(){const{hls:e}=this;e&&(e.on(fu.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(fu.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(fu.BUFFER_APPENDED,this.onBufferAppended,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off(fu.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(fu.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(fu.BUFFER_APPENDED,this.onBufferAppended,this))}destroy(){super.destroy(),this.unregisterListeners(),this.media=this.hls=this.fragmentTracker=null,this.mediaSource=void 0}onMediaAttached(e,t){this.setInterval(100),this.mediaSource=t.mediaSource;const r=this.media=t.media;Am(r,"playing",this.onMediaPlaying),Am(r,"waiting",this.onMediaWaiting),Am(r,"ended",this.onMediaEnded)}onMediaDetaching(e,t){this.clearInterval();const{media:r}=this;r&&(km(r,"playing",this.onMediaPlaying),km(r,"waiting",this.onMediaWaiting),km(r,"ended",this.onMediaEnded),this.media=null),this.mediaSource=void 0}onBufferAppended(e,t){this.buffered=t.timeRanges}get hasBuffered(){return Object.keys(this.buffered).length>0}tick(){var e;if(null==(e=this.media)||!e.readyState||!this.hasBuffered)return;const t=this.media.currentTime;this.poll(t,this.lastCurrentTime),this.lastCurrentTime=t}poll(e,t){var r,i;const n=null==(r=this.hls)?void 0:r.config;if(!n)return;const s=this.media;if(!s)return;const{seeking:a}=s,o=this.seeking&&!a,l=!this.seeking&&a,c=s.paused&&!a||s.ended||0===s.playbackRate;if(this.seeking=a,e!==t)return t&&(this.ended=0),this.moved=!0,a||(this.nudgeRetry=0,n.nudgeOnVideoHole&&!c&&e>t&&this.nudgeOnVideoHole(e,t)),void(0===this.waiting&&this.stallResolved(e));if(l||o)return void(o&&this.stallResolved(e));if(c)return this.nudgeRetry=0,this.stallResolved(e),void(!this.ended&&s.ended&&this.hls&&(this.ended=e||1,this.hls.trigger(fu.MEDIA_ENDED,{stalled:!1})));if(!lp.getBuffered(s).length)return void(this.nudgeRetry=0);const d=lp.bufferInfo(s,e,0),u=d.nextStart||0,h=this.fragmentTracker;if(a&&h&&this.hls){const t=rE(this.hls.inFlightFragments,e),r=d.len>2,i=!u||t||u-e>2&&!h.getPartialFragment(e);if(r||i)return;this.moved=!1}const f=null==(i=this.hls)?void 0:i.latestLevelDetails;if(!this.moved&&null!==this.stalled&&h){if(!(d.len>0)&&!u)return;const t=Math.max(u,d.start||0)-e,r=!(null==f||!f.live)?2*f.targetduration:2,i=nE(e,h);if(t>0&&(t<=r||i))return void(s.paused||this._trySkipBufferHole(i))}const p=n.detectStallWithCurrentTimeMs,m=self.performance.now(),g=this.waiting;let v=this.stalled;if(null===v){if(!(g>0&&m-g<p))return void(this.stalled=m);v=this.stalled=g}const y=m-v;if(!a&&(y>=p||g)&&this.hls){var b;if("ended"===(null==(b=this.mediaSource)?void 0:b.readyState)&&(null==f||!f.live)&&Math.abs(e-((null==f?void 0:f.edge)||0))<1){if(this.ended)return;return this.ended=e||1,void this.hls.trigger(fu.MEDIA_ENDED,{stalled:!0})}if(this._reportStall(d),!this.media||!this.hls)return}const E=lp.bufferInfo(s,e,n.maxBufferHole);this._tryFixBufferStall(E,y,e)}stallResolved(e){const t=this.stalled;if(t&&this.hls&&(this.stalled=null,this.stallReported)){const r=self.performance.now()-t;this.log(`playback not stuck anymore @${e}, after ${Math.round(r)}ms`),this.stallReported=!1,this.waiting=0,this.hls.trigger(fu.STALL_RESOLVED,{})}}nudgeOnVideoHole(e,t){var r;const i=this.buffered.video;if(this.hls&&this.media&&this.fragmentTracker&&null!=(r=this.buffered.audio)&&r.length&&i&&i.length>1&&e>i.end(0)){const r=lp.bufferedInfo(lp.timeRangesToArray(this.buffered.audio),e,0);if(r.len>1&&t>=r.start){const r=lp.timeRangesToArray(i),n=lp.bufferedInfo(r,t,0).bufferedIndex;if(n>-1&&n<r.length-1){const t=lp.bufferedInfo(r,e,0).bufferedIndex,i=r[n].end,s=r[n+1].start;if((-1===t||t>n)&&s-i<1&&e-i<2){const r=new Error(`nudging playhead to flush pipeline after video hole. currentTime: ${e} hole: ${i} -> ${s} buffered index: ${t}`);this.warn(r.message),this.media.currentTime+=1e-6;let n=nE(e,this.fragmentTracker);n&&"fragment"in n?n=n.fragment:n||(n=void 0);const a=lp.bufferInfo(this.media,e,0);this.hls.trigger(fu.ERROR,{type:uu.MEDIA_ERROR,details:hu.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:r,reason:r.message,frag:n,buffer:a.len,bufferInfo:a})}}}}}_tryFixBufferStall(e,t,r){var i,n;const{fragmentTracker:s,media:a}=this,o=null==(i=this.hls)?void 0:i.config;if(!a||!s||!o)return;const l=null==(n=this.hls)?void 0:n.latestLevelDetails,c=nE(r,s);if(c||null!=l&&l.live&&r<l.fragmentStart){if(this._trySkipBufferHole(c)||!this.media)return}const d=e.buffered,u=this.adjacentTraversal(e,r);(d&&d.length>1&&e.len>o.maxBufferHole||e.nextStart&&(e.nextStart-r<o.maxBufferHole||u))&&(t>1e3*o.highBufferWatchdogPeriod||this.waiting)&&(this.warn("Trying to nudge playhead over buffer-hole"),this._tryNudgeBuffer(e))}adjacentTraversal(e,t){const r=this.fragmentTracker,i=e.nextStart;if(r&&i){const e=r.getFragAtPos(t,yu),n=r.getFragAtPos(i,yu);if(e&&n)return n.sn-e.sn<2}return!1}_reportStall(e){const{hls:t,media:r,stallReported:i,stalled:n}=this;if(!i&&null!==n&&r&&t){this.stallReported=!0;const i=new Error(`Playback stalling at @${r.currentTime} due to low buffer (${cf(e)})`);this.warn(i.message),t.trigger(fu.ERROR,{type:uu.MEDIA_ERROR,details:hu.BUFFER_STALLED_ERROR,fatal:!1,error:i,buffer:e.len,bufferInfo:e,stalled:{start:n}})}}_trySkipBufferHole(e){var t;const{fragmentTracker:r,media:i}=this,n=null==(t=this.hls)?void 0:t.config;if(!i||!r||!n)return 0;const s=i.currentTime,a=lp.bufferInfo(i,s,0),o=s<a.start?a.start:a.nextStart;if(o&&this.hls){const t=a.len<=n.maxBufferHole,c=a.len>0&&a.len<1&&i.readyState<3,d=o-s;if(d>0&&(t||c)){if(d>n.maxBufferHole){let t=!1;if(0===s){const e=r.getAppendedFrag(0,yu);e&&o<e.end&&(t=!0)}if(!t&&e){var l;if(null==(l=this.hls.loadLevelObj)||!l.details)return 0;if(rE(this.hls.inFlightFragments,o))return 0;let t=!1,i=e.end;for(;i<o;){const e=nE(i,r);if(!e){t=!0;break}i+=e.duration}if(t)return 0}}const t=Math.max(o+.05,s+.1);if(this.warn(`skipping hole, adjusting currentTime from ${s} to ${t}`),this.moved=!0,i.currentTime=t,null==e||!e.gap){const r=new Error(`fragment loaded with buffer holes, seeking from ${s} to ${t}`),i={type:uu.MEDIA_ERROR,details:hu.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:r,reason:r.message,buffer:a.len,bufferInfo:a};e&&("fragment"in e?i.part=e:i.frag=e),this.hls.trigger(fu.ERROR,i)}return t}}return 0}_tryNudgeBuffer(e){const{hls:t,media:r,nudgeRetry:i}=this,n=null==t?void 0:t.config;if(!r||!n)return 0;const s=r.currentTime;if(this.nudgeRetry++,i<n.nudgeMaxRetry){const a=s+(i+1)*n.nudgeOffset,o=new Error(`Nudging 'currentTime' from ${s} to ${a}`);this.warn(o.message),r.currentTime=a,t.trigger(fu.ERROR,{type:uu.MEDIA_ERROR,details:hu.BUFFER_NUDGE_ON_STALL,error:o,fatal:!1,buffer:e.len,bufferInfo:e})}else{const r=new Error(`Playhead still not moving while enough data buffered @${s} after ${n.nudgeMaxRetry} nudges`);this.error(r.message),t.trigger(fu.ERROR,{type:uu.MEDIA_ERROR,details:hu.BUFFER_STALLED_ERROR,error:r,fatal:!0,buffer:e.len,bufferInfo:e})}}}function rE(e,t){const r=iE(e.main);if(r&&r.start<=t)return r;const i=iE(e.audio);return i&&i.start<=t?i:null}function iE(e){if(!e)return null;switch(e.state){case Rm:case Lm:case Nm:case Fm:return null}return e.frag}function nE(e,t){return t.getAppendedFrag(e,yu)||t.getPartialFragment(e)}function sE(){if("undefined"!=typeof self)return self.VTTCue||self.TextTrackCue}function aE(e,t,r,i,n){let s=new e(t,r,"");try{s.value=i,n&&(s.type=n)}catch(a){s=new e(t,r,cf(n?ku({type:n},i):i))}return s}const oE=(()=>{const e=sE();try{e&&new e(0,Number.POSITIVE_INFINITY,"")}catch(e){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();class lE{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=!0,this.assetCue=void 0,this.onEventCueEnter=()=>{this.hls&&this.hls.trigger(fu.EVENT_CUE_ENTER,{})},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=this.onEventCueEnter=null}_registerListeners(){const{hls:e}=this;e&&(e.on(fu.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(fu.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(fu.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(fu.MANIFEST_LOADING,this.onManifestLoading,this),e.on(fu.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(fu.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(fu.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(fu.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}_unregisterListeners(){const{hls:e}=this;e&&(e.off(fu.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(fu.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(fu.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(fu.MANIFEST_LOADING,this.onManifestLoading,this),e.off(fu.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(fu.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(fu.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(fu.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}onMediaAttaching(e,t){var r;this.media=t.media,!1===(null==(r=t.overrides)?void 0:r.cueRemoval)&&(this.removeCues=!1)}onMediaAttached(){var e;const t=null==(e=this.hls)?void 0:e.latestLevelDetails;t&&this.updateDateRangeCues(t)}onMediaDetaching(e,t){this.media=null;!!t.transferMedia||(this.id3Track&&(this.removeCues&&Cy(this.id3Track,this.onEventCueEnter),this.id3Track=null),this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){const t=this.getID3Track(e.textTracks);return t.mode="hidden",t}getID3Track(e){if(this.media){for(let t=0;t<e.length;t++){const r=e[t];if("metadata"===r.kind&&"id3"===r.label)return Ry(r,this.media),r}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media||!this.hls)return;const{enableEmsgMetadataCues:r,enableID3MetadataCues:i}=this.hls.config;if(!r&&!i)return;const{samples:n}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));const s=sE();if(s)for(let e=0;e<n.length;e++){const t=n[e].type;if(t===gg.emsg&&!r||!i)continue;const a=hg(n[e].data),o=n[e].pts;let l=o+n[e].duration;l>oE&&(l=oE);l-o<=0&&(l=o+.25);for(let e=0;e<a.length;e++){const r=a[e];if(!fg(r)){this.updateId3CueEnds(o,t);const e=aE(s,o,l,r,t);e&&this.id3Track.addCue(e)}}}}updateId3CueEnds(e,t){var r;const i=null==(r=this.id3Track)?void 0:r.cues;if(i)for(let r=i.length;r--;){const n=i[r];n.type===t&&n.startTime<e&&n.endTime===oE&&(n.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:r,type:i}){const{id3Track:n,hls:s}=this;if(!s)return;const{config:{enableEmsgMetadataCues:a,enableID3MetadataCues:o}}=s;if(n&&(a||o)){let e;e="audio"===i?e=>e.type===gg.audioId3&&o:"video"===i?e=>e.type===gg.emsg&&a:e=>e.type===gg.audioId3&&o||e.type===gg.emsg&&a,Dy(n,t,r,e)}}onLevelUpdated(e,{details:t}){this.updateDateRangeCues(t,!0)}onLevelPtsUpdated(e,t){Math.abs(t.drift)>.01&&this.updateDateRangeCues(t.details)}updateDateRangeCues(e,t){if(!this.hls||!this.media)return;const{assetPlayerId:r,timelineOffset:i,enableDateRangeMetadataCues:n,interstitialsController:s}=this.hls.config;if(!n)return;const a=sE();if(r&&i&&!s){const{fragmentStart:t,fragmentEnd:i}=e;let n=this.assetCue;n?(n.startTime=t,n.endTime=i):a&&(n=this.assetCue=aE(a,t,i,{assetPlayerId:this.hls.config.assetPlayerId},"hlsjs.interstitial.asset"),n&&(n.id=r,this.id3Track||(this.id3Track=this.createTrack(this.media)),this.id3Track.addCue(n),n.addEventListener("enter",this.onEventCueEnter)))}if(!e.hasProgramDateTime)return;const{id3Track:o}=this,{dateRanges:l}=e,c=Object.keys(l);let d=this.dateRangeCuesAppended;var u;if(o&&t)if(null!=(u=o.cues)&&u.length){const e=Object.keys(d).filter(e=>!c.includes(e));for(let t=e.length;t--;){var h;const r=e[t],i=null==(h=d[r])?void 0:h.cues;delete d[r],i&&Object.keys(i).forEach(e=>{const t=i[e];if(t){t.removeEventListener("enter",this.onEventCueEnter);try{o.removeCue(t)}catch(e){}}})}}else d=this.dateRangeCuesAppended={};const f=e.fragments[e.fragments.length-1];if(0!==c.length&&lu(null==f?void 0:f.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(let e=0;e<c.length;e++){const t=c[e],r=l[t],i=r.startTime,n=d[t],o=(null==n?void 0:n.cues)||{};let u=(null==n?void 0:n.durationKnown)||!1,h=oE;const{duration:f,endDate:p}=r;if(p&&null!==f)h=i+f,u=!0;else if(r.endOnNext&&!u){const e=c.reduce((e,t)=>{if(t!==r.id){const i=l[t];if(i.class===r.class&&i.startDate>r.startDate&&(!e||r.startDate<e.startDate))return i}return e},null);e&&(h=e.startTime,u=!0)}const m=Object.keys(r.attr);for(let e=0;e<m.length;e++){const l=m[e];if(!vp(l))continue;const c=o[l];if(c)!u||null!=n&&n.durationKnown?Math.abs(c.startTime-i)>.01&&(c.startTime=i,c.endTime=h):c.endTime=h;else if(a){let e=r.attr[l];yp(l)&&(e=$u(e));const n=aE(a,i,h,{key:l,data:e},gg.dateRange);n&&(n.id=t,this.id3Track.addCue(n),o[l]=n,s&&("X-ASSET-LIST"!==l&&"X-ASSET-URL"!==l||n.addEventListener("enter",this.onEventCueEnter)))}}d[t]={cues:o,dateRange:r,durationKnown:u}}}}}class cE{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.currentTime=0,this.stallCount=0,this._latency=null,this._targetLatencyUpdated=!1,this.onTimeupdate=()=>{const{media:e}=this,t=this.levelDetails;if(!e||!t)return;this.currentTime=e.currentTime;const r=this.computeLatency();if(null===r)return;this._latency=r;const{lowLatencyMode:i,maxLiveSyncPlaybackRate:n}=this.config;if(!i||1===n||!t.live)return;const s=this.targetLatency;if(null===s)return;const a=r-s;if(a<Math.min(this.maxLatency,s+t.targetduration)&&a>.05&&this.forwardBufferLength>1){const t=Math.min(2,Math.max(1,n)),r=Math.round(2/(1+Math.exp(-.75*a-this.edgeStalled))*20)/20,i=Math.min(t,Math.max(1,r));this.changeMediaPlaybackRate(e,i)}else 1!==e.playbackRate&&0!==e.playbackRate&&this.changeMediaPlaybackRate(e,1)},this.hls=e,this.config=e.config,this.registerListeners()}get levelDetails(){var e;return(null==(e=this.hls)?void 0:e.latestLevelDetails)||null}get latency(){return this._latency||0}get maxLatency(){const{config:e}=this;if(void 0!==e.liveMaxLatencyDuration)return e.liveMaxLatencyDuration;const t=this.levelDetails;return t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){const e=this.levelDetails;if(null===e||null===this.hls)return null;const{holdBack:t,partHoldBack:r,targetduration:i}=e,{liveSyncDuration:n,liveSyncDurationCount:s,lowLatencyMode:a}=this.config,o=this.hls.userConfig;let l=a&&r||t;(this._targetLatencyUpdated||o.liveSyncDuration||o.liveSyncDurationCount||0===l)&&(l=void 0!==n?n:s*i);const c=i;return l+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,c)}set targetLatency(e){this.stallCount=0,this.config.liveSyncDuration=e,this._targetLatencyUpdated=!0}get liveSyncPosition(){const e=this.estimateLiveEdge(),t=this.targetLatency;if(null===e||null===t)return null;const r=this.levelDetails;if(null===r)return null;const i=r.edge,n=e-t-this.edgeStalled,s=i-r.totalduration,a=i-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(s,n),a)}get drift(){const e=this.levelDetails;return null===e?1:e.drift}get edgeStalled(){const e=this.levelDetails;if(null===e)return 0;const t=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.max(e.age-t,0)}get forwardBufferLength(){const{media:e}=this,t=this.levelDetails;if(!e||!t)return 0;const r=e.buffered.length;return(r?e.buffered.end(r-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null}registerListeners(){const{hls:e}=this;e&&(e.on(fu.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(fu.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(fu.MANIFEST_LOADING,this.onManifestLoading,this),e.on(fu.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(fu.ERROR,this.onError,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off(fu.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(fu.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(fu.MANIFEST_LOADING,this.onManifestLoading,this),e.off(fu.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(fu.ERROR,this.onError,this))}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.onTimeupdate)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.onTimeupdate),this.media=null)}onManifestLoading(){this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:t}){t.advanced&&this.onTimeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.onTimeupdate)}onError(e,t){var r;t.details===hu.BUFFER_STALLED_ERROR&&(this.stallCount++,this.hls&&null!=(r=this.levelDetails)&&r.live&&this.hls.logger.warn("[latency-controller]: Stall detected, adjusting target latency"))}changeMediaPlaybackRate(e,t){var r,i;e.playbackRate!==t&&(null==(r=this.hls)||r.logger.debug(`[latency-controller]: latency=${this.latency.toFixed(3)}, targetLatency=${null==(i=this.targetLatency)?void 0:i.toFixed(3)}, forwardBufferLength=${this.forwardBufferLength.toFixed(3)}: adjusting playback rate from ${e.playbackRate} to ${t}`),e.playbackRate=t)}estimateLiveEdge(){const e=this.levelDetails;return null===e?null:e.edge+e.age}computeLatency(){const e=this.estimateLiveEdge();return null===e?null:e-this.currentTime}}class dE extends yv{constructor(e,t){super(e,"level-controller"),this._levels=[],this._firstLevel=-1,this._maxAutoLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=t,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(fu.MANIFEST_LOADING,this.onManifestLoading,this),e.on(fu.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(fu.LEVEL_LOADED,this.onLevelLoaded,this),e.on(fu.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(fu.FRAG_BUFFERED,this.onFragBuffered,this),e.on(fu.ERROR,this.onError,this)}_unregisterListeners(){const{hls:e}=this;e.off(fu.MANIFEST_LOADING,this.onManifestLoading,this),e.off(fu.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(fu.LEVEL_LOADED,this.onLevelLoaded,this),e.off(fu.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(fu.FRAG_BUFFERED,this.onFragBuffered,this),e.off(fu.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}stopLoad(){this._levels.forEach(e=>{e.loadError=0,e.fragmentError=0}),super.stopLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1}onManifestLoading(e,t){this.resetLevels()}onManifestLoaded(e,t){const r=this.hls.config.preferManagedMediaSource,i=[],n={},s={};let a=!1,o=!1,l=!1;t.levels.forEach(e=>{const t=e.attrs;let{audioCodec:c,videoCodec:d}=e;c&&(e.audioCodec=c=Bh(c,r)||void 0),d&&(d=e.videoCodec=function(e){const t=e.split(",");for(let e=0;e<t.length;e++){const r=t[e].split(".");r.length>2&&"avc1"===r[0]&&(t[e]=`avc1.${parseInt(r[1]).toString(16)}${("000"+parseInt(r[2]).toString(16)).slice(-4)}`)}return t.join(",")}(d));const{width:u,height:h,unknownCodecs:f}=e,p=(null==f?void 0:f.length)||0;if(a||(a=!(!u||!h)),o||(o=!!d),l||(l=!!c),p||c&&!this.isAudioSupported(c)||d&&!this.isVideoSupported(d))return void this.log(`Some or all CODECS not supported "${t.CODECS}"`);const{CODECS:m,"FRAME-RATE":g,"HDCP-LEVEL":v,"PATHWAY-ID":y,RESOLUTION:b,"VIDEO-RANGE":E}=t,w=`${`${y||"."}-`}${e.bitrate}-${b}-${g}-${m}-${E}-${v}`;if(n[w])if(n[w].uri===e.url||e.attrs["PATHWAY-ID"])n[w].addGroupId("audio",t.AUDIO),n[w].addGroupId("text",t.SUBTITLES);else{const t=s[w]+=1;e.attrs["PATHWAY-ID"]=new Array(t+1).join(".");const r=this.createLevel(e);n[w]=r,i.push(r)}else{const t=this.createLevel(e);n[w]=t,s[w]=1,i.push(t)}}),this.filterAndSortMediaOptions(i,t,a,o,l)}createLevel(e){const t=new af(e),r=e.supplemental;if(null!=r&&r.videoCodec&&!this.isVideoSupported(r.videoCodec)){const e=new Error(`SUPPLEMENTAL-CODECS not supported "${r.videoCodec}"`);this.log(e.message),t.supportedResult=Yh(e,[])}return t}isAudioSupported(e){return Dh(e,"audio",this.hls.config.preferManagedMediaSource)}isVideoSupported(e){return Dh(e,"video",this.hls.config.preferManagedMediaSource)}filterAndSortMediaOptions(e,t,r,i,n){var s;let a=[],o=[],l=e;const c=(null==(s=t.stats)?void 0:s.parsing)||{};if((r||i)&&n&&(l=l.filter(({videoCodec:e,videoRange:t,width:r,height:i})=>{return(!!e||!(!r||!i))&&(!!(n=t)&&Jh.indexOf(n)>-1);var n})),0===l.length)return Promise.resolve().then(()=>{if(this.hls){let e="no level with compatible codecs found in manifest",r=e;t.levels.length&&(r=`one or more CODECS in variant not supported: ${cf(t.levels.map(e=>e.attrs.CODECS).filter((e,t,r)=>r.indexOf(e)===t))}`,this.warn(r),e+=` (${r})`);const i=new Error(e);this.hls.trigger(fu.ERROR,{type:uu.MEDIA_ERROR,details:hu.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:i,reason:r})}}),void(c.end=performance.now());t.audioTracks&&(a=t.audioTracks.filter(e=>!e.audioCodec||this.isAudioSupported(e.audioCodec)),uE(a)),t.subtitles&&(o=t.subtitles,uE(o));const d=l.slice(0);l.sort((e,t)=>{if(e.attrs["HDCP-LEVEL"]!==t.attrs["HDCP-LEVEL"])return(e.attrs["HDCP-LEVEL"]||"")>(t.attrs["HDCP-LEVEL"]||"")?1:-1;if(r&&e.height!==t.height)return e.height-t.height;if(e.frameRate!==t.frameRate)return e.frameRate-t.frameRate;if(e.videoRange!==t.videoRange)return Jh.indexOf(e.videoRange)-Jh.indexOf(t.videoRange);if(e.videoCodec!==t.videoCodec){const r=Mh(e.videoCodec),i=Mh(t.videoCodec);if(r!==i)return i-r}if(e.uri===t.uri&&e.codecSet!==t.codecSet){const r=Nh(e.codecSet),i=Nh(t.codecSet);if(r!==i)return i-r}return e.averageBitrate!==t.averageBitrate?e.averageBitrate-t.averageBitrate:0});let u=d[0];if(this.steering&&(l=this.steering.filterParsedLevels(l),l.length!==d.length))for(let e=0;e<d.length;e++)if(d[e].pathwayId===l[0].pathwayId){u=d[e];break}this._levels=l;for(let e=0;e<l.length;e++)if(l[e]===u){var h;this._firstLevel=e;const t=u.bitrate,r=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${l.length} level(s) found, first bitrate: ${t}`),void 0===(null==(h=this.hls.userConfig)?void 0:h.abrEwmaDefaultEstimate)){const e=Math.min(t,this.hls.config.abrEwmaDefaultEstimateMax);e>r&&r===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=e)}break}const f=n&&!i,p=this.hls.config,m=!(!p.audioStreamController||!p.audioTrackController),g={levels:l,audioTracks:a,subtitleTracks:o,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:n,video:i,altAudio:m&&!f&&a.some(e=>!!e.url)};c.end=performance.now(),this.hls.trigger(fu.MANIFEST_PARSED,g)}get levels(){return 0===this._levels.length?null:this._levels}get loadLevelObj(){return this.currentLevel}get level(){return this.currentLevelIndex}set level(e){const t=this._levels;if(0===t.length)return;if(e<0||e>=t.length){const r=new Error("invalid level idx"),i=e<0;if(this.hls.trigger(fu.ERROR,{type:uu.OTHER_ERROR,details:hu.LEVEL_SWITCH_ERROR,level:e,fatal:i,error:r,reason:r.message}),i)return;e=Math.min(e,t.length-1)}const r=this.currentLevelIndex,i=this.currentLevel,n=i?i.attrs["PATHWAY-ID"]:void 0,s=t[e],a=s.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=s,r===e&&i&&n===a)return;this.log(`Switching to level ${e} (${s.height?s.height+"p ":""}${s.videoRange?s.videoRange+" ":""}${s.codecSet?s.codecSet+" ":""}@${s.bitrate})${a?" with Pathway "+a:""} from level ${r}${n?" with Pathway "+n:""}`);const o={level:e,attrs:s.attrs,details:s.details,bitrate:s.bitrate,averageBitrate:s.averageBitrate,maxBitrate:s.maxBitrate,realBitrate:s.realBitrate,width:s.width,height:s.height,codecSet:s.codecSet,audioCodec:s.audioCodec,videoCodec:s.videoCodec,audioGroups:s.audioGroups,subtitleGroups:s.subtitleGroups,loaded:s.loaded,loadError:s.loadError,fragmentError:s.fragmentError,name:s.name,id:s.id,uri:s.uri,url:s.url,urlId:0,audioGroupIds:s.audioGroupIds,textGroupIds:s.textGroupIds};this.hls.trigger(fu.LEVEL_SWITCHING,o);const l=s.details;if(!l||l.live){const e=this.switchParams(s.uri,null==i?void 0:i.details,l);this.loadPlaylist(e)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e}get startLevel(){if(void 0===this._startLevel){const e=this.hls.config.startLevel;return void 0!==e?e:this.hls.firstAutoLevel}return this._startLevel}set startLevel(e){this._startLevel=e}get pathways(){return this.steering?this.steering.pathways():[]}get pathwayPriority(){return this.steering?this.steering.pathwayPriority:null}set pathwayPriority(e){if(this.steering){const t=this.steering.pathways(),r=e.filter(e=>-1!==t.indexOf(e));if(e.length<1)return void this.warn(`pathwayPriority ${e} should contain at least one pathway from list: ${t}`);this.steering.pathwayPriority=r}}onError(e,t){!t.fatal&&t.context&&t.context.type===mu&&t.context.level===this.level&&this.checkRetry(t)}onFragBuffered(e,{frag:t}){if(void 0!==t&&t.type===yu){const e=t.elementaryStreams;if(!Object.keys(e).some(t=>!!e[t]))return;const r=this._levels[t.level];null!=r&&r.loadError&&(this.log(`Resetting level error count of ${r.loadError} on frag buffered`),r.loadError=0)}}onLevelLoaded(e,t){var r;const{level:i,details:n}=t,s=t.levelInfo;var a;if(!s)return this.warn(`Invalid level index ${i}`),void(null!=(a=t.deliveryDirectives)&&a.skip&&(n.deltaUpdateFailed=!0));if(s===this.currentLevel||t.withoutMultiVariant){0===s.fragmentError&&(s.loadError=0);let e=s.details;e===t.details&&e.advanced&&(e=void 0),this.playlistLoaded(i,t,e)}else null!=(r=t.deliveryDirectives)&&r.skip&&(n.deltaUpdateFailed=!0)}loadPlaylist(e){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLoading(this.currentLevel,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);const r=this.getUrlWithDirectives(e.uri,t),i=this.currentLevelIndex,n=e.attrs["PATHWAY-ID"],s=e.details,a=null==s?void 0:s.age;this.log(`Loading level index ${i}${void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:""}${n?" Pathway "+n:""}${a&&s.live?" age "+a.toFixed(1)+(s.type&&" "+s.type||""):""} ${r}`),this.hls.trigger(fu.LEVEL_LOADING,{url:r,level:i,levelInfo:e,pathwayId:e.attrs["PATHWAY-ID"],id:0,deliveryDirectives:t||null})}get nextLoadLevel(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}removeLevel(e){var t;if(1===this._levels.length)return;const r=this._levels.filter((t,r)=>r!==e||(this.steering&&this.steering.removeLevel(t),t===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,t.details&&t.details.fragments.forEach(e=>e.level=-1)),!1));vm(r),this._levels=r,this.currentLevelIndex>-1&&null!=(t=this.currentLevel)&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.manualLevelIndex>-1&&(this.manualLevelIndex=this.currentLevelIndex);const i=r.length-1;this._firstLevel=Math.min(this._firstLevel,i),this._startLevel&&(this._startLevel=Math.min(this._startLevel,i)),this.hls.trigger(fu.LEVELS_UPDATED,{levels:r})}onLevelsUpdated(e,{levels:t}){this._levels=t}checkMaxAutoUpdated(){const{autoLevelCapping:e,maxAutoLevel:t,maxHdcpLevel:r}=this.hls;this._maxAutoLevel!==t&&(this._maxAutoLevel=t,this.hls.trigger(fu.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:r}))}}function uE(e){const t={};e.forEach(e=>{const r=e.groupId||"";e.id=t[r]=t[r]||0,t[r]++})}function hE(){return self.SourceBuffer||self.WebKitSourceBuffer}function fE(){if(!Ou())return!1;const e=hE();return!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove}class pE extends Um{constructor(e,t,r){super(e,t,r,"stream-controller",yu),this.audioCodecSwap=!1,this.level=-1,this._forceStartLoad=!1,this._hasEnoughToStart=!1,this.altAudio=0,this.audioOnly=!1,this.fragPlaying=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this.onMediaPlaying=()=>{this.tick()},this.onMediaSeeked=()=>{const e=this.media,t=e?e.currentTime:null;if(null===t||!lu(t))return;if(this.log(`Media seeked to ${t.toFixed(3)}`),!this.getBufferedFrag(t))return;const r=this.getFwdBufferInfoAtPos(e,t,yu,0);null!==r&&0!==r.len?this.tick():this.warn(`Main forward buffer length at ${t} on "seeked" event ${r?r.len:"empty"})`)},this.registerListeners()}registerListeners(){super.registerListeners();const{hls:e}=this;e.on(fu.MANIFEST_PARSED,this.onManifestParsed,this),e.on(fu.LEVEL_LOADING,this.onLevelLoading,this),e.on(fu.LEVEL_LOADED,this.onLevelLoaded,this),e.on(fu.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(fu.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(fu.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(fu.BUFFER_CREATED,this.onBufferCreated,this),e.on(fu.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(fu.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(fu.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){super.unregisterListeners();const{hls:e}=this;e.off(fu.MANIFEST_PARSED,this.onManifestParsed,this),e.off(fu.LEVEL_LOADED,this.onLevelLoaded,this),e.off(fu.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(fu.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(fu.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(fu.BUFFER_CREATED,this.onBufferCreated,this),e.off(fu.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(fu.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(fu.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),super.onHandlerDestroying()}startLoad(e,t){if(this.levels){const{lastCurrentTime:r,hls:i}=this;if(this.stopLoad(),this.setInterval(100),this.level=-1,!this.startFragRequested){let e=i.startLevel;-1===e&&(i.config.testBandwidth&&this.levels.length>1?(e=0,this.bitrateTest=!0):e=i.firstAutoLevel),i.nextLoadLevel=e,this.level=i.loadLevel,this._hasEnoughToStart=!!t}r>0&&-1===e&&!t&&(this.log(`Override startPosition with lastCurrentTime @${r.toFixed(3)}`),e=r),this.state=Rm,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}else this._forceStartLoad=!0,this.state=Lm}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case Bm:{const{levels:e,level:t}=this,r=null==e?void 0:e[t],i=null==r?void 0:r.details;if(i&&(!i.live||this.levelLastLoaded===r&&!this.waitForLive(r))){if(this.waitForCdnTuneIn(i))break;this.state=Rm;break}if(this.hls.nextLoadLevel!==this.level){this.state=Rm;break}break}case Dm:this.checkRetryDate()}this.state===Rm&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){var e;super.onTickEnd(),null!=(e=this.media)&&e.readyState&&!1===this.media.seeking&&(this.lastCurrentTime=this.media.currentTime),this.checkFragmentChanged()}doTickIdle(){const{hls:e,levelLastLoaded:t,levels:r,media:i}=this;if(null===t||!i&&!this.primaryPrefetch&&(this.startFragRequested||!e.config.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;const n=this.buffering?e.nextLoadLevel:e.loadLevel;if(null==r||!r[n])return;const s=r[n],a=this.getMainFwdBufferInfo();if(null===a)return;const o=this.getLevelDetails();if(o&&this._streamEnded(a,o)){const e={};return 2===this.altAudio&&(e.type="video"),this.hls.trigger(fu.BUFFER_EOS,e),void(this.state=Nm)}if(!this.buffering)return;e.loadLevel!==n&&-1===e.manualLevel&&this.log(`Adapting to level ${n} from level ${this.level}`),this.level=e.nextLoadLevel=n;const l=s.details;if(!l||this.state===Bm||this.waitForLive(s))return this.level=n,this.state=Bm,void(this.startFragRequested=!1);const c=a.len,d=this.getMaxBufferLength(s.maxBitrate);if(c>=d)return;this.backtrackFragment&&this.backtrackFragment.start>a.end&&(this.backtrackFragment=null);const u=this.backtrackFragment?this.backtrackFragment.start:a.end;let h=this.getNextFragment(u,l);if(this.couldBacktrack&&!this.fragPrevious&&h&&Ju(h)&&this.fragmentTracker.getState(h)!==jf){var f;const e=(null!=(f=this.backtrackFragment)?f:h).sn-l.startSN,t=l.fragments[e-1];t&&h.cc===t.cc&&(h=t,this.fragmentTracker.removeFragment(t))}else this.backtrackFragment&&a.len&&(this.backtrackFragment=null);if(h&&this.isLoopLoading(h,u)){if(!h.gap){const e=this.audioOnly&&!this.altAudio?qu:Xu,t=(e===Xu?this.videoBuffer:this.mediaBuffer)||this.media;t&&this.afterBufferFlushed(t,e,yu)}h=this.getNextFragmentLoopLoading(h,l,a,yu,d)}h&&(!h.initSegment||h.initSegment.data||this.bitrateTest||(h=h.initSegment),this.loadFragment(h,s,u))}loadFragment(e,t,r){const i=this.fragmentTracker.getState(e);i===Uf||i===Gf?Ju(e)?this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):super.loadFragment(e,t,r):this._loadInitSegment(e,t):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,yu)}followingBufferedFrag(e){return e?this.getBufferedFrag(e.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){const{levels:e,media:t}=this;if(null!=t&&t.readyState){let r;const i=this.getAppendedFrag(t.currentTime);i&&i.start>1&&this.flushMainBuffer(0,i.start-1);const n=this.getLevelDetails();if(null!=n&&n.live){const e=this.getMainFwdBufferInfo();if(!e||e.len<2*n.targetduration)return}if(!t.paused&&e){const t=e[this.hls.nextLoadLevel],i=this.fragLastKbps;r=i&&this.fragCurrent?this.fragCurrent.duration*t.maxBitrate/(1e3*i)+1:0}else r=0;const s=this.getBufferedFrag(t.currentTime+r);if(s){const e=this.followingBufferedFrag(s);if(e){this.abortCurrentFrag();const t=e.maxStartPTS?e.maxStartPTS:e.start,r=e.duration,i=Math.max(s.end,t+Math.min(Math.max(r-this.config.maxFragLookUpTolerance,r*(this.couldBacktrack?.5:.125)),r*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(i,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){const e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case Pm:case Cm:case Dm:case Om:case Mm:this.state=Rm}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,2===this.altAudio?"video":null)}onMediaAttached(e,t){super.onMediaAttached(e,t);const r=t.media;Am(r,"playing",this.onMediaPlaying),Am(r,"seeked",this.onMediaSeeked)}onMediaDetaching(e,t){const{media:r}=this;r&&(km(r,"playing",this.onMediaPlaying),km(r,"seeked",this.onMediaSeeked)),this.videoBuffer=null,this.fragPlaying=null,super.onMediaDetaching(e,t);!!t.transferMedia||(this._hasEnoughToStart=!1)}onManifestLoading(){super.onManifestLoading(),this.log("Trigger BUFFER_RESET"),this.hls.trigger(fu.BUFFER_RESET,void 0),this.couldBacktrack=!1,this.fragLastKbps=0,this.fragPlaying=this.backtrackFragment=null,this.altAudio=0,this.audioOnly=!1}onManifestParsed(e,t){let r=!1,i=!1;for(let e=0;e<t.levels.length;e++){const n=t.levels[e].audioCodec;n&&(r=r||-1!==n.indexOf("mp4a.40.2"),i=i||-1!==n.indexOf("mp4a.40.5"))}this.audioCodecSwitch=r&&i&&!function(){var e;const t=hE();return"function"==typeof(null==t||null==(e=t.prototype)?void 0:e.changeType)}(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1}onLevelLoading(e,t){const{levels:r}=this;if(!r||this.state!==Rm)return;const i=t.levelInfo;(!i.details||i.details.live&&(this.levelLastLoaded!==i||i.details.expired)||this.waitForCdnTuneIn(i.details))&&(this.state=Bm)}onLevelLoaded(e,t){var r;const{levels:i,startFragRequested:n}=this,s=t.level,a=t.details,o=a.totalduration;if(!i)return void this.warn(`Levels were reset while loading level ${s}`);this.log(`Level ${s} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""}, cc [${a.startCC}, ${a.endCC}] duration:${o}`);const l=t.levelInfo,c=this.fragCurrent;!c||this.state!==Cm&&this.state!==Dm||c.level!==t.level&&c.loader&&this.abortCurrentFrag();let d=0;if(a.live||null!=(r=l.details)&&r.live){var u;if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;d=this.alignPlaylists(a,l.details,null==(u=this.levelLastLoaded)?void 0:u.details)}if(l.details=a,this.levelLastLoaded=l,n||this.setStartPosition(a,d),this.hls.trigger(fu.LEVEL_UPDATED,{details:a,level:s}),this.state===Bm){if(this.waitForCdnTuneIn(a))return;this.state=Rm}n&&a.live&&this.synchronizeToLiveEdge(a),this.tick()}synchronizeToLiveEdge(e){const{config:t,media:r}=this;if(!r)return;const i=this.hls.liveSyncPosition,n=this.getLoadPosition(),s=e.fragmentStart,a=e.edge,o=n>=s-t.maxFragLookUpTolerance&&n<=a;if(null!==i&&r.duration>i&&(n<i||!o)){const s=void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;if((!o&&r.readyState<4||n<a-s)&&(this._hasEnoughToStart||(this.nextLoadPosition=i),r.readyState))if(this.warn(`Playback: ${n.toFixed(3)} is located too far from the end of live sliding playlist: ${a}, reset currentTime to : ${i.toFixed(3)}`),"buffered"===this.config.liveSyncMode){var l;const e=lp.bufferInfo(r,i,0);if(null==(l=e.buffered)||!l.length)return void(r.currentTime=i);if(e.start<=n)return void(r.currentTime=i);const{nextStart:t}=lp.bufferedInfo(e.buffered,n,0);t&&(r.currentTime=t)}else r.currentTime=i}}_handleFragmentLoadProgress(e){var t;const r=e.frag,{part:i,payload:n}=e,{levels:s}=this;if(!s)return void this.warn(`Levels were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);const a=s[r.level];if(!a)return void this.warn(`Level ${r.level} not found on progress`);const o=a.details;if(!o)return this.warn(`Dropping fragment ${r.sn} of level ${r.level} after level details were reset`),void this.fragmentTracker.removeFragment(r);const l=a.videoCodec,c=o.PTSKnown||!o.live,d=null==(t=r.initSegment)?void 0:t.data,u=this._getAudioCodec(a),h=this.transmuxer=this.transmuxer||new vv(this.hls,yu,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),f=i?i.index:-1,p=-1!==f,m=new ap(r.level,r.sn,r.stats.chunkCount,n.byteLength,f,p),g=this.initPTS[r.cc];h.push(n,d,u,l,r,i,o.totalduration,c,m,g)}onAudioTrackSwitching(e,t){const r=this.hls,i=0!==this.altAudio;if(vf(t.url,r))this.altAudio=1;else{if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;const e=this.fragCurrent;e&&(this.log("Switching to main audio track, cancel main fragment load"),e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();if(i)return this.altAudio=0,this.fragmentTracker.removeAllFragments(),r.once(fu.BUFFER_FLUSHED,()=>{this.hls&&this.hls.trigger(fu.AUDIO_TRACK_SWITCHED,t)}),void r.trigger(fu.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});r.trigger(fu.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){const r=vf(t.url,this.hls);if(r){const e=this.videoBuffer;e&&this.mediaBuffer!==e&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=e)}this.altAudio=r?2:0,this.tick()}onBufferCreated(e,t){const r=t.tracks;let i,n,s=!1;for(const e in r){const t=r[e];if("main"===t.id){if(n=e,i=t,"video"===e){const t=r[e];t&&(this.videoBuffer=t.buffer)}}else s=!0}s&&i?(this.log(`Alternate track found, use ${n}.buffered to schedule main fragment loading`),this.mediaBuffer=i.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){const{frag:r,part:i}=t,n=r.type===yu;if(n){if(this.fragContextChanged(r))return this.warn(`Fragment ${r.sn}${i?" p: "+i.index:""} of level ${r.level} finished buffering, but was aborted. state: ${this.state}`),void(this.state===Mm&&(this.state=Rm));const e=i?i.stats:r.stats;this.fragLastKbps=Math.round(8*e.total/(e.buffering.end-e.loading.first)),Ju(r)&&(this.fragPrevious=r),this.fragBufferedComplete(r,i)}const s=this.media;s&&(!this._hasEnoughToStart&&lp.getBuffered(s).length&&(this._hasEnoughToStart=!0,this.seekToStartPos()),n&&this.tick())}get hasEnoughToStart(){return this._hasEnoughToStart}onError(e,t){var r;if(t.fatal)this.state=Fm;else switch(t.details){case hu.FRAG_GAP:case hu.FRAG_PARSING_ERROR:case hu.FRAG_DECRYPT_ERROR:case hu.FRAG_LOAD_ERROR:case hu.FRAG_LOAD_TIMEOUT:case hu.KEY_LOAD_ERROR:case hu.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(yu,t);break;case hu.LEVEL_LOAD_ERROR:case hu.LEVEL_LOAD_TIMEOUT:case hu.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==Bm||(null==(r=t.context)?void 0:r.type)!==mu||(this.state=Rm);break;case hu.BUFFER_ADD_CODEC_ERROR:case hu.BUFFER_APPEND_ERROR:if("main"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)&&this.resetLoadingState();break;case hu.BUFFER_FULL_ERROR:if("main"!==t.parent)return;if(this.reduceLengthAndFlushBuffer(t)){!this.config.interstitialsController&&this.config.assetPlayerId?this._hasEnoughToStart=!0:this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}break;case hu.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}onFragLoadEmergencyAborted(){this.state=Rm,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==qu||!this.altAudio){const e=(t===Xu?this.videoBuffer:this.mediaBuffer)||this.media;e&&(this.afterBufferFlushed(e,t,yu),this.tick())}}onLevelsUpdated(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level,-1===this.level&&this.resetWhenMissingContext(this.fragCurrent)),this.levels=t.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){const{media:e}=this;if(!e)return;const t=e.currentTime;let r=this.startPosition;if(r>=0&&t<r){if(e.seeking)return void this.log(`could not seek to ${r}, already seeking at ${t}`);const i=this.timelineOffset;i&&r&&(r+=i);const n=this.getLevelDetails(),s=lp.getBuffered(e),a=s.length?s.start(0):0,o=a-r,l=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);(this.config.startOnSegmentBoundary||o>0&&(o<l||this.loadingParts&&o<2*((null==n?void 0:n.partTarget)||0)))&&(this.log(`adjusting start position by ${o} to match buffer start`),r+=o,this.startPosition=r),t<r&&(this.log(`seek to target start position ${r} from current time ${t} buffer start ${a}`),e.currentTime=r)}}_getAudioCodec(e){let t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t=-1!==t.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),t}_loadBitrateTestFrag(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then(e=>{const{hls:r}=this,i=null==e?void 0:e.frag;if(!i||this.fragContextChanged(i))return;t.fragmentError=0,this.state=Rm,this.startFragRequested=!1,this.bitrateTest=!1;const n=i.stats;n.parsing.start=n.parsing.end=n.buffering.start=n.buffering.end=self.performance.now(),r.trigger(fu.FRAG_LOADED,e),i.bitrateTest=!1}).catch(t=>{this.state!==Lm&&this.state!==Fm&&(this.warn(t),this.resetFragmentLoading(e))})}_handleTransmuxComplete(e){const t=this.playlistType,{hls:r}=this,{remuxResult:i,chunkMeta:n}=e,s=this.getCurrentContext(n);if(!s)return void this.resetWhenMissingContext(n);const{frag:a,part:o,level:l}=s,{video:c,text:d,id3:u,initSegment:h}=i,{details:f}=l,p=this.altAudio?void 0:i.audio;if(this.fragContextChanged(a))this.fragmentTracker.removeFragment(a);else{if(this.state=Om,h){const e=h.tracks;if(e){const i=a.initSegment||a;if(this.unhandledEncryptionError(h,a))return;this._bufferInitSegment(l,e,i,n),r.trigger(fu.FRAG_PARSING_INIT_SEGMENT,{frag:i,id:t,tracks:e})}const i=h.initPTS,s=h.timescale,o=this.initPTS[a.cc];if(lu(i)&&(!o||o.baseTime!==i||o.timescale!==s)){const e=h.trackId;this.initPTS[a.cc]={baseTime:i,timescale:s,trackId:e},r.trigger(fu.INIT_PTS_FOUND,{frag:a,id:t,initPTS:i,timescale:s,trackId:e})}}if(c&&f){p&&"audiovideo"===c.type&&this.logMuxedErr(a);const e=f.fragments[a.sn-1-f.startSN],t=a.sn===f.startSN,r=!e||a.cc>e.cc;if(!1!==i.independent){const{startPTS:e,endPTS:i,startDTS:s,endDTS:l}=c;if(o)o.elementaryStreams[c.type]={startPTS:e,endPTS:i,startDTS:s,endDTS:l};else if(c.firstKeyFrame&&c.independent&&1===n.id&&!r&&(this.couldBacktrack=!0),c.dropped&&c.independent){const n=this.getMainFwdBufferInfo(),s=(n?n.end:this.getLoadPosition())+this.config.maxBufferHole,o=c.firstKeyFramePTS?c.firstKeyFramePTS:e;if(!t&&s<o-this.config.maxBufferHole&&!r)return void this.backtrack(a);r&&(a.gap=!0),a.setElementaryStreamInfo(c.type,a.start,i,a.start,l,!0)}else t&&e-(f.appliedTimelineOffset||0)>2&&(a.gap=!0);a.setElementaryStreamInfo(c.type,e,i,s,l),this.backtrackFragment&&(this.backtrackFragment=a),this.bufferFragmentData(c,a,o,n,t||r)}else{if(!t&&!r)return void this.backtrack(a);a.gap=!0}}if(p){const{startPTS:e,endPTS:t,startDTS:r,endDTS:i}=p;o&&(o.elementaryStreams[qu]={startPTS:e,endPTS:t,startDTS:r,endDTS:i}),a.setElementaryStreamInfo(qu,e,t,r,i),this.bufferFragmentData(p,a,o,n)}if(f&&null!=u&&u.samples.length){const e={id:t,frag:a,details:f,samples:u.samples};r.trigger(fu.FRAG_PARSING_METADATA,e)}if(f&&d){const e={id:t,frag:a,details:f,samples:d.samples};r.trigger(fu.FRAG_PARSING_USERDATA,e)}}}logMuxedErr(e){this.warn(`${Ju(e)?"Media":"Init"} segment with muxed audiovideo where only video expected: ${e.url}`)}_bufferInitSegment(e,t,r,i){if(this.state!==Om)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&(delete t.audio,t.audiovideo&&this.logMuxedErr(r));const{audio:n,video:s,audiovideo:a}=t;if(n){const r=e.audioCodec;let i=Uh(n.codec,r);"mp4a"===i&&(i="mp4a.40.5");const s=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){i&&(i=-1!==i.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5");const e=n.metadata;e&&"channelCount"in e&&1!==(e.channelCount||1)&&-1===s.indexOf("firefox")&&(i="mp4a.40.5")}i&&-1!==i.indexOf("mp4a.40.5")&&-1!==s.indexOf("android")&&"audio/mpeg"!==n.container&&(i="mp4a.40.2",this.log(`Android: force audio codec to ${i}`)),r&&r!==i&&this.log(`Swapping manifest audio codec "${r}" for "${i}"`),n.levelCodec=i,n.id=yu,this.log(`Init audio buffer, container:${n.container}, codecs[selected/level/parsed]=[${i||""}/${r||""}/${n.codec}]`),delete t.audiovideo}if(s){s.levelCodec=e.videoCodec,s.id=yu;const r=s.codec;if(4===(null==r?void 0:r.length))switch(r){case"hvc1":case"hev1":s.codec="hvc1.1.6.L120.90";break;case"av01":s.codec="av01.0.04M.08";break;case"avc1":s.codec="avc1.42e01e"}this.log(`Init video buffer, container:${s.container}, codecs[level/parsed]=[${e.videoCodec||""}/${r}]${s.codec!==r?" parsed-corrected="+s.codec:""}${s.supplemental?" supplemental="+s.supplemental:""}`),delete t.audiovideo}a&&(this.log(`Init audiovideo buffer, container:${a.container}, codecs[level/parsed]=[${e.codecs}/${a.codec}]`),delete t.video,delete t.audio);const o=Object.keys(t);if(o.length){if(this.hls.trigger(fu.BUFFER_CODECS,t),!this.hls)return;o.forEach(e=>{const n=t[e].initSegment;null!=n&&n.byteLength&&this.hls.trigger(fu.BUFFER_APPENDING,{type:e,data:n,frag:r,part:null,chunkMeta:i,parent:r.type})})}this.tickImmediate()}getMainFwdBufferInfo(){const e=this.mediaBuffer&&2===this.altAudio?this.mediaBuffer:this.media;return this.getFwdBufferInfo(e,yu)}get maxBufferLength(){const{levels:e,level:t}=this,r=null==e?void 0:e[t];return r?this.getMaxBufferLength(r.maxBitrate):this.config.maxBufferLength}backtrack(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=Rm}checkFragmentChanged(){const e=this.media;let t=null;if(e&&e.readyState>1&&!1===e.seeking){const r=e.currentTime;if(lp.isBuffered(e,r)?t=this.getAppendedFrag(r):lp.isBuffered(e,r+.1)&&(t=this.getAppendedFrag(r+.1)),t){this.backtrackFragment=null;const e=this.fragPlaying,r=t.level;e&&t.sn===e.sn&&e.level===r||(this.fragPlaying=t,this.hls.trigger(fu.FRAG_CHANGED,{frag:t}),e&&e.level===r||this.hls.trigger(fu.LEVEL_SWITCHED,{level:r}))}}}get nextLevel(){const e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){var e;if(this.fragPlaying)return this.fragPlaying;const t=(null==(e=this.media)?void 0:e.currentTime)||this.lastCurrentTime;return lu(t)?this.getAppendedFrag(t):null}get currentProgramDateTime(){var e;const t=(null==(e=this.media)?void 0:e.currentTime)||this.lastCurrentTime;if(lu(t)){const e=this.getLevelDetails(),r=this.currentFrag||(e?bf(null,e.fragments,t):null);if(r){const e=r.programDateTime;if(null!==e){const i=e+1e3*(t-r.start);return new Date(i)}}}return null}get currentLevel(){const e=this.currentFrag;return e?e.level:-1}get nextBufferedFrag(){const e=this.currentFrag;return e?this.followingBufferedFrag(e):null}get forceStartLoad(){return this._forceStartLoad}}class mE extends Iu{constructor(e,t){super("key-loader",t),this.config=void 0,this.keyIdToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(const r in this.keyIdToKeyInfo){const i=this.keyIdToKeyInfo[r].loader;if(i){var t;if(e&&e!==(null==(t=i.context)?void 0:t.frag.type))return;i.abort()}}}detach(){for(const e in this.keyIdToKeyInfo){const t=this.keyIdToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyIdToKeyInfo[e]}}destroy(){this.detach();for(const e in this.keyIdToKeyInfo){const t=this.keyIdToKeyInfo[e].loader;t&&t.destroy()}this.keyIdToKeyInfo={}}createKeyLoadError(e,t=hu.KEY_LOAD_ERROR,r,i,n){return new np({type:uu.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:n,error:r,networkDetails:i})}loadClear(e,t,r){if(this.emeController&&this.config.emeEnabled&&!this.emeController.getSelectedKeySystemFormats().length){if(t.length)for(let i=0,n=t.length;i<n;i++){const s=t[i];if(e.cc<=s.cc&&(!Ju(e)||!Ju(s)||e.sn<s.sn)||!r&&i==n-1)return this.emeController.selectKeySystemFormat(s).then(e=>{if(!this.emeController)return;s.setKeyFormat(e);const t=Mp(e);return t?this.emeController.getKeySystemAccess([t]):void 0})}if(this.config.requireKeySystemAccessOnStart){const e=Fp(this.config);if(e.length)return this.emeController.getKeySystemAccess(e)}}return null}load(e){return!e.decryptdata&&e.encrypted&&this.emeController&&this.config.emeEnabled?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}loadInternal(e,t){var r,i;t&&e.setKeyFormat(t);const n=e.decryptdata;if(!n){const r=new Error(t?`Expected frag.decryptdata to be defined after setting format ${t}`:`Missing decryption data on fragment in onKeyLoading (emeEnabled with controller: ${this.emeController&&this.config.emeEnabled})`);return Promise.reject(this.createKeyLoadError(e,hu.KEY_LOAD_ERROR,r))}const s=n.uri;if(!s)return Promise.reject(this.createKeyLoadError(e,hu.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${s}"`)));const a=gE(n);let o=this.keyIdToKeyInfo[a];if(null!=(r=o)&&r.decryptdata.key)return n.key=o.decryptdata.key,Promise.resolve({frag:e,keyInfo:o});if(this.emeController&&null!=(i=o)&&i.keyLoadPromise){switch(this.emeController.getKeyStatus(o.decryptdata)){case"usable":case"usable-in-future":return o.keyLoadPromise.then(t=>{const{keyInfo:r}=t;return n.key=r.decryptdata.key,{frag:e,keyInfo:r}})}}switch(this.log(`${this.keyIdToKeyInfo[a]?"Rel":"L"}oading${n.keyId?" keyId: "+Fu(n.keyId):""} URI: ${n.uri} from ${e.type} ${e.level}`),o=this.keyIdToKeyInfo[a]={decryptdata:n,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},n.method){case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===n.keyFormat?this.loadKeyHTTP(o,e):this.loadKeyEME(o,e);case"AES-128":case"AES-256":case"AES-256-CTR":return this.loadKeyHTTP(o,e);default:return Promise.reject(this.createKeyLoadError(e,hu.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${n.method}"`)))}}loadKeyEME(e,t){const r={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var i;if(!e.decryptdata.keyId&&null!=(i=t.initSegment)&&i.data){const r=function(e){const t=[];return bh(e,e=>t.push(e.subarray(8,24))),t}(t.initSegment.data);if(r.length){let t=r[0];t.some(e=>0!==e)?(this.log(`Using keyId found in init segment ${Fu(t)}`),Gp.setKeyIdForUri(e.decryptdata.uri,t)):(t=Gp.addKeyIdForUri(e.decryptdata.uri),this.log(`Generating keyId to patch media ${Fu(t)}`)),e.decryptdata.keyId=t}}if(!e.decryptdata.keyId&&!Ju(t))return Promise.resolve(r);const n=this.emeController.loadKey(r);return(e.keyLoadPromise=n.then(t=>(e.mediaKeySessionContext=t,r))).catch(r=>{throw e.keyLoadPromise=null,"data"in r&&(r.data.frag=t),r})}return Promise.resolve(r)}loadKeyHTTP(e,t){const r=this.config,i=new(0,r.loader)(r);return t.keyLoader=e.loader=i,e.keyLoadPromise=new Promise((n,s)=>{const a={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},o=r.keyLoadPolicy.default,l={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(e,t,r,i)=>{const{frag:a,keyInfo:o}=r,l=gE(o.decryptdata);if(!a.decryptdata||o!==this.keyIdToKeyInfo[l])return s(this.createKeyLoadError(a,hu.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),i));o.decryptdata.key=a.decryptdata.key=new Uint8Array(e.data),a.keyLoader=null,o.loader=null,n({frag:a,keyInfo:o})},onError:(e,r,i,n)=>{this.resetLoader(r),s(this.createKeyLoadError(t,hu.KEY_LOAD_ERROR,new Error(`HTTP Error ${e.code} loading key ${e.text}`),i,ku({url:a.url,data:void 0},e)))},onTimeout:(e,r,i)=>{this.resetLoader(r),s(this.createKeyLoadError(t,hu.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),i))},onAbort:(e,r,i)=>{this.resetLoader(r),s(this.createKeyLoadError(t,hu.INTERNAL_ABORTED,new Error("key loading aborted"),i))}};i.load(a,l,c)})}resetLoader(e){const{frag:t,keyInfo:r,url:i}=e,n=r.loader;t.keyLoader===n&&(t.keyLoader=null,r.loader=null);const s=gE(r.decryptdata)||i;delete this.keyIdToKeyInfo[s],n&&n.destroy()}}function gE(e){if(e.keyFormat!==Dp){const t=e.keyId;if(t)return Fu(t)}return e.uri}function vE(e){const{type:t}=e;switch(t){case gu:return bu;case vu:return Eu;default:return yu}}function yE(e,t){let r=e.url;return void 0!==r&&0!==r.indexOf("data:")||(r=t.url),r}class bE{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:e}=this;e.on(fu.MANIFEST_LOADING,this.onManifestLoading,this),e.on(fu.LEVEL_LOADING,this.onLevelLoading,this),e.on(fu.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(fu.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.on(fu.LEVELS_UPDATED,this.onLevelsUpdated,this)}unregisterListeners(){const{hls:e}=this;e.off(fu.MANIFEST_LOADING,this.onManifestLoading,this),e.off(fu.LEVEL_LOADING,this.onLevelLoading,this),e.off(fu.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(fu.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.off(fu.LEVELS_UPDATED,this.onLevelsUpdated,this)}createInternalLoader(e){const t=this.hls.config,r=t.pLoader,i=t.loader,n=new(r||i)(t);return this.loaders[e.type]=n,n}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e]}destroyInternalLoaders(){for(const e in this.loaders){const t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,t){const{url:r}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:pu,url:r,deliveryDirectives:null,levelOrTrack:null})}onLevelLoading(e,t){const{id:r,level:i,pathwayId:n,url:s,deliveryDirectives:a,levelInfo:o}=t;this.load({id:r,level:i,pathwayId:n,responseType:"text",type:mu,url:s,deliveryDirectives:a,levelOrTrack:o})}onAudioTrackLoading(e,t){const{id:r,groupId:i,url:n,deliveryDirectives:s,track:a}=t;this.load({id:r,groupId:i,level:null,responseType:"text",type:gu,url:n,deliveryDirectives:s,levelOrTrack:a})}onSubtitleTrackLoading(e,t){const{id:r,groupId:i,url:n,deliveryDirectives:s,track:a}=t;this.load({id:r,groupId:i,level:null,responseType:"text",type:vu,url:n,deliveryDirectives:s,levelOrTrack:a})}onLevelsUpdated(e,t){const r=this.loaders[mu];if(r){const e=r.context;e&&!t.levels.some(t=>t===e.levelOrTrack)&&(r.abort(),delete this.loaders[mu])}}load(e){var t;const r=this.hls.config;let i,n=this.getInternalLoader(e);if(n){const t=this.hls.logger,r=n.context;if(r&&r.levelOrTrack===e.levelOrTrack&&(r.url===e.url||r.deliveryDirectives&&!e.deliveryDirectives))return void(r.url===e.url?t.log(`[playlist-loader]: ignore ${e.url} ongoing request`):t.log(`[playlist-loader]: ignore ${e.url} in favor of ${r.url}`));t.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),n.abort()}if(i=e.type===pu?r.manifestLoadPolicy.default:xu({},r.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),n=this.createInternalLoader(e),lu(null==(t=e.deliveryDirectives)?void 0:t.part)){let t;if(e.type===mu&&null!==e.level?t=this.hls.levels[e.level].details:e.type===gu&&null!==e.id?t=this.hls.audioTracks[e.id].details:e.type===vu&&null!==e.id&&(t=this.hls.subtitleTracks[e.id].details),t){const e=t.partTarget,r=t.targetduration;if(e&&r){const t=1e3*Math.max(3*e,.8*r);i=xu({},i,{maxTimeToFirstByteMs:Math.min(t,i.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(t,i.maxTimeToFirstByteMs)})}}}const s=i.errorRetry||i.timeoutRetry||{},a={loadPolicy:i,timeout:i.maxLoadTimeMs,maxRetry:s.maxNumRetry||0,retryDelay:s.retryDelayMs||0,maxRetryDelay:s.maxRetryDelayMs||0},o={onSuccess:(e,t,r,i)=>{const n=this.getInternalLoader(r);this.resetInternalLoader(r.type);const s=e.data;t.parsing.start=performance.now(),qp.isMediaPlaylist(s)||r.type!==pu?this.handleTrackOrLevelPlaylist(e,t,r,i||null,n):this.handleMasterPlaylist(e,t,r,i)},onError:(e,t,r,i)=>{this.handleNetworkError(t,r,!1,e,i)},onTimeout:(e,t,r)=>{this.handleNetworkError(t,r,!0,void 0,e)}};n.load(e,a,o)}checkAutostartLoad(){if(!this.hls)return;const{config:{autoStartLoad:e,startPosition:t},forceStartLoad:r}=this.hls;(e||r)&&(this.hls.logger.log(`${e?"auto":"force"} startLoad with configured startPosition ${t}`),this.hls.startLoad(t))}handleMasterPlaylist(e,t,r,i){const n=this.hls,s=e.data,a=yE(e,r),o=qp.parseMasterPlaylist(s,a);if(o.playlistParsingError)return t.parsing.end=performance.now(),void this.handleManifestParsingError(e,r,o.playlistParsingError,i,t);const{contentSteering:l,levels:c,sessionData:d,sessionKeys:u,startTimeOffset:h,variableList:f}=o;this.variableList=f,c.forEach(e=>{const{unknownCodecs:t}=e;if(t){const{preferManagedMediaSource:r}=this.hls.config;let{audioCodec:i,videoCodec:n}=e;for(let s=t.length;s--;){const a=t[s];Dh(a,"audio",r)?(e.audioCodec=i=i?`${i},${a}`:a,Ph.audio[i.substring(0,4)]=2,t.splice(s,1)):Dh(a,"video",r)&&(e.videoCodec=n=n?`${n},${a}`:a,Ph.video[n.substring(0,4)]=2,t.splice(s,1))}}});const{AUDIO:p=[],SUBTITLES:m,"CLOSED-CAPTIONS":g}=qp.parseMasterPlaylistMedia(s,a,o);if(p.length){p.some(e=>!e.url)||!c[0].audioCodec||c[0].attrs.AUDIO||(this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),p.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new gp({}),bitrate:0,url:""}))}n.trigger(fu.MANIFEST_LOADED,{levels:c,audioTracks:p,subtitles:m,captions:g,contentSteering:l,url:a,stats:t,networkDetails:i,sessionData:d,sessionKeys:u,startTimeOffset:h,variableList:f})}handleTrackOrLevelPlaylist(e,t,r,i,n){const s=this.hls,{id:a,level:o,type:l}=r,c=yE(e,r),d=lu(o)?o:lu(a)?a:0,u=vE(r),h=qp.parseLevelPlaylist(e.data,c,d,u,0,this.variableList);if(l===pu){const e={attrs:new gp({}),bitrate:0,details:h,name:"",url:c};h.requestScheduled=t.loading.start+fm(h,0),s.trigger(fu.MANIFEST_LOADED,{levels:[e],audioTracks:[],url:c,stats:t,networkDetails:i,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),r.levelDetails=h,this.handlePlaylistLoaded(h,e,t,r,i,n)}handleManifestParsingError(e,t,r,i,n){this.hls.trigger(fu.ERROR,{type:uu.NETWORK_ERROR,details:hu.MANIFEST_PARSING_ERROR,fatal:t.type===pu,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:i,stats:n})}handleNetworkError(e,t,r=!1,i,n){let s=`A network ${r?"timeout":"error"+(i?" (status "+i.code+")":"")} occurred while loading ${e.type}`;e.type===mu?s+=`: ${e.level} id: ${e.id}`:e.type!==gu&&e.type!==vu||(s+=` id: ${e.id} group-id: "${e.groupId}"`);const a=new Error(s);this.hls.logger.warn(`[playlist-loader]: ${s}`);let o=hu.UNKNOWN,l=!1;const c=this.getInternalLoader(e);switch(e.type){case pu:o=r?hu.MANIFEST_LOAD_TIMEOUT:hu.MANIFEST_LOAD_ERROR,l=!0;break;case mu:o=r?hu.LEVEL_LOAD_TIMEOUT:hu.LEVEL_LOAD_ERROR,l=!1;break;case gu:o=r?hu.AUDIO_TRACK_LOAD_TIMEOUT:hu.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case vu:o=r?hu.SUBTITLE_TRACK_LOAD_TIMEOUT:hu.SUBTITLE_LOAD_ERROR,l=!1}c&&this.resetInternalLoader(e.type);const d={type:uu.NETWORK_ERROR,details:o,fatal:l,url:e.url,loader:c,context:e,error:a,networkDetails:t,stats:n};if(i){const r=(null==t?void 0:t.url)||e.url;d.response=ku({url:r,data:void 0},i)}this.hls.trigger(fu.ERROR,d)}handlePlaylistLoaded(e,t,r,i,n,s){const a=this.hls,{type:o,level:l,levelOrTrack:c,id:d,groupId:u,deliveryDirectives:h}=i,f=yE(t,i),p=vE(i);let m="number"==typeof i.level&&p===yu?l:void 0;const g=e.playlistParsingError;if(g){if(this.hls.logger.warn(`${g} ${e.url}`),!a.config.ignorePlaylistParsingErrors)return void a.trigger(fu.ERROR,{type:uu.NETWORK_ERROR,details:hu.LEVEL_PARSING_ERROR,fatal:!1,url:f,error:g,reason:g.message,response:t,context:i,level:m,parent:p,networkDetails:n,stats:r});e.playlistParsingError=null}if(!e.fragments.length){const s=e.playlistParsingError=new Error("No Segments found in Playlist");return void a.trigger(fu.ERROR,{type:uu.NETWORK_ERROR,details:hu.LEVEL_EMPTY_ERROR,fatal:!1,url:f,error:s,reason:s.message,response:t,context:i,level:m,parent:p,networkDetails:n,stats:r})}switch(e.live&&s&&(s.getCacheAge&&(e.ageHeader=s.getCacheAge()||0),s.getCacheAge&&!isNaN(e.ageHeader)||(e.ageHeader=0)),o){case pu:case mu:if(m)if(c){if(c!==a.levels[m]){const e=a.levels.indexOf(c);e>-1&&(m=e)}}else m=0;a.trigger(fu.LEVEL_LOADED,{details:e,levelInfo:c||a.levels[0],level:m||0,id:d||0,stats:r,networkDetails:n,deliveryDirectives:h,withoutMultiVariant:o===pu});break;case gu:a.trigger(fu.AUDIO_TRACK_LOADED,{details:e,track:c,id:d||0,groupId:u||"",stats:r,networkDetails:n,deliveryDirectives:h});break;case vu:a.trigger(fu.SUBTITLE_TRACK_LOADED,{details:e,track:c,id:d||0,groupId:u||"",stats:r,networkDetails:n,deliveryDirectives:h})}}}class EE{static get version(){return Ym}static isMSESupported(){return fE()}static isSupported(){return function(){if(!fE())return!1;const e=Ou();return"function"==typeof(null==e?void 0:e.isTypeSupported)&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(t=>e.isTypeSupported(Oh(t,"video")))||["mp4a.40.2","fLaC"].some(t=>e.isTypeSupported(Oh(t,"audio"))))}()}static getMediaSource(){return Ou()}static get Events(){return fu}static get MetadataSchema(){return gg}static get ErrorTypes(){return uu}static get ErrorDetails(){return hu}static get DefaultConfig(){return EE.defaultConfig?EE.defaultConfig:Zb}static set DefaultConfig(e){EE.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.logger=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new Wm,this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioStreamController=void 0,this.subtititleStreamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.interstitialsController=void 0,this.gapController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this._url=null,this._sessionId=void 0,this.triggeringException=void 0,this.started=!1;const t=this.logger=function(e,t,r){const i=Pu();if("object"==typeof console&&!0===e||"object"==typeof e){const n=["debug","log","info","warn","error"];n.forEach(t=>{i[t]=Cu(t,e,r)});try{i.log(`Debug logs enabled for "${t}" in hls.js version 1.6.15`)}catch(e){return Pu()}n.forEach(t=>{Du[t]=Cu(t,e)})}else xu(Du,i);return i}(e.debug||!1,"Hls instance",e.assetPlayerId),r=this.config=function(e,t,r){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==t.liveMaxLatencyDurationCount&&(void 0===t.liveSyncDurationCount||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==t.liveMaxLatencyDuration&&(void 0===t.liveSyncDuration||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const i=Jb(e),n=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach(e=>{const s=`${"level"===e?"playlist":e}LoadPolicy`,a=void 0===t[s],o=[];n.forEach(r=>{const n=`${e}Loading${r}`,l=t[n];if(void 0!==l&&a){o.push(n);const e=i[s].default;switch(t[s]={default:e},r){case"TimeOut":e.maxLoadTimeMs=l,e.maxTimeToFirstByteMs=l;break;case"MaxRetry":e.errorRetry.maxNumRetry=l,e.timeoutRetry.maxNumRetry=l;break;case"RetryDelay":e.errorRetry.retryDelayMs=l,e.timeoutRetry.retryDelayMs=l;break;case"MaxRetryTimeout":e.errorRetry.maxRetryDelayMs=l,e.timeoutRetry.maxRetryDelayMs=l}}}),o.length&&r.warn(`hls.js config: "${o.join('", "')}" setting(s) are deprecated, use "${s}": ${cf(t[s])}`)}),ku(ku({},i),t)}(EE.DefaultConfig,e,t);this.userConfig=e,r.progressive&&eE(r,t);const{abrController:i,bufferController:n,capLevelController:s,errorController:a,fpsController:o}=r,l=new a(this),c=this.abrController=new i(this),d=new Hf(this),u=r.interstitialsController,h=u?this.interstitialsController=new u(this,EE):null,f=this.bufferController=new n(this,d),p=this.capLevelController=new s(this),m=new o(this),g=new bE(this),v=r.contentSteeringController,y=v?new v(this):null,b=this.levelController=new dE(this,y),E=new lE(this),w=new mE(this.config,this.logger),S=this.streamController=new pE(this,d,w),T=this.gapController=new tE(this,d);p.setStreamController(S),m.setStreamController(S);const x=[g,b,S];h&&x.splice(1,0,h),y&&x.splice(1,0,y),this.networkControllers=x;const A=[c,f,T,p,m,E,d];this.audioTrackController=this.createController(r.audioTrackController,x);const k=r.audioStreamController;k&&x.push(this.audioStreamController=new k(this,d,w)),this.subtitleTrackController=this.createController(r.subtitleTrackController,x);const I=r.subtitleStreamController;I&&x.push(this.subtititleStreamController=new I(this,d,w)),this.createController(r.timelineController,A),w.emeController=this.emeController=this.createController(r.emeController,A),this.cmcdController=this.createController(r.cmcdController,A),this.latencyController=this.createController(cE,A),this.coreComponents=A,x.push(l);const L=l.onErrorOut;"function"==typeof L&&this.on(fu.ERROR,L,l),this.on(fu.MANIFEST_LOADED,g.onManifestLoaded,g)}createController(e,t){if(e){const r=new e(this);return t&&t.push(r),r}return null}on(e,t,r=this){this._emitter.on(e,t,r)}once(e,t,r=this){this._emitter.once(e,t,r)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,r=this,i){this._emitter.off(e,t,r,i)}listeners(e){return this._emitter.listeners(e)}emit(e,t,r){return this._emitter.emit(e,t,r)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(t){if(this.logger.error("An internal error happened while handling event "+e+'. Error message: "'+t.message+'". Here is a stacktrace:',t),!this.triggeringException){this.triggeringException=!0;const r=e===fu.ERROR;this.trigger(fu.ERROR,{type:uu.OTHER_ERROR,details:hu.INTERNAL_EXCEPTION,fatal:r,event:e,error:t}),this.triggeringException=!1}}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){this.logger.log("destroy"),this.trigger(fu.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this._url=null,this.networkControllers.forEach(e=>e.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(e=>e.destroy()),this.coreComponents.length=0;const e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){if(!e||"media"in e&&!e.media){const t=new Error(`attachMedia failed: invalid argument (${e})`);return void this.trigger(fu.ERROR,{type:uu.OTHER_ERROR,details:hu.ATTACH_MEDIA_ERROR,fatal:!0,error:t})}this.logger.log("attachMedia"),this._media&&(this.logger.warn("media must be detached before attaching"),this.detachMedia());const t="media"in e,r=t?e.media:e,i=t?e:{media:r};this._media=r,this.trigger(fu.MEDIA_ATTACHING,i)}detachMedia(){this.logger.log("detachMedia"),this.trigger(fu.MEDIA_DETACHING,{}),this._media=null}transferMedia(){this._media=null;const e=this.bufferController.transferMedia();return this.trigger(fu.MEDIA_DETACHING,{transferMedia:e}),e}loadSource(e){this.stopLoad();const t=this.media,r=this._url,i=this._url=Yu.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log(`loadSource:${i}`),t&&r&&(r!==i||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(fu.MANIFEST_LOADING,{url:e})}get url(){return this._url}get hasEnoughToStart(){return this.streamController.hasEnoughToStart}get startPosition(){return this.streamController.startPositionValue}startLoad(e=-1,t){this.logger.log(`startLoad(${e+(t?", <skip seek to start>":"")})`),this.started=!0,this.resumeBuffering();for(let r=0;r<this.networkControllers.length&&(this.networkControllers[r].startLoad(e,t),this.started&&this.networkControllers);r++);}stopLoad(){this.logger.log("stopLoad"),this.started=!1;for(let e=0;e<this.networkControllers.length&&(this.networkControllers[e].stopLoad(),!this.started&&this.networkControllers);e++);}get loadingEnabled(){return this.started}get bufferingEnabled(){return this.streamController.bufferingEnabled}resumeBuffering(){this.bufferingEnabled||(this.logger.log("resume buffering"),this.networkControllers.forEach(e=>{e.resumeBuffering&&e.resumeBuffering()}))}pauseBuffering(){this.bufferingEnabled&&(this.logger.log("pause buffering"),this.networkControllers.forEach(e=>{e.pauseBuffering&&e.pauseBuffering()}))}get inFlightFragments(){const e={[yu]:this.streamController.inFlightFrag};return this.audioStreamController&&(e[bu]=this.audioStreamController.inFlightFrag),this.subtititleStreamController&&(e[Eu]=this.subtititleStreamController.inFlightFrag),e}swapAudioCodec(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){this.logger.log("recoverMediaError");const e=this._media,t=null==e?void 0:e.currentTime;this.detachMedia(),e&&(this.attachMedia(e),t&&this.startLoad(t))}removeLevel(e){this.levelController.removeLevel(e)}get sessionId(){let e=this._sessionId;return e||(e=this._sessionId=function(){try{return crypto.randomUUID()}catch(e){try{const e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch(e){let t=(new Date).getTime();const r="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const r=(t+16*Math.random())%16|0;return t=Math.floor(t/16),("x"==e?r:3&r|8).toString(16)});return r}}}()),e}get levels(){const e=this.levelController.levels;return e||[]}get latestLevelDetails(){return this.streamController.getLevelDetails()||null}get loadLevelObj(){return this.levelController.loadLevelObj}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){this.logger.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){this.logger.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){this.logger.log(`set loadLevel:${e}`),this.levelController.manualLevel=e}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(e){this.levelController.nextLoadLevel=e}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(e){this.logger.log(`set firstLevel:${e}`),this.levelController.firstLevel=e}get startLevel(){const e=this.levelController.startLevel;return-1===e&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e}set startLevel(e){this.logger.log(`set startLevel:${e}`),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){const t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimate():NaN}set bandwidthEstimate(e){this.abrController.resetEstimator(e)}get abrEwmaDefaultEstimate(){const{bwEstimator:e}=this.abrController;return e?e.defaultEstimate:NaN}get ttfbEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(this.logger.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){(function(e){return Zh.indexOf(e)>-1})(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}get autoLevelEnabled(){return-1===this.levelController.manualLevel}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){const{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;const r=e.length;for(let i=0;i<r;i++)if(e[i].maxBitrate>=t)return i;return 0}get maxAutoLevel(){const{levels:e,autoLevelCapping:t,maxHdcpLevel:r}=this;let i;if(i=-1===t&&null!=e&&e.length?e.length-1:t,r)for(let t=i;t--;){const i=e[t].attrs["HDCP-LEVEL"];if(i&&i<=r)return t}return i}get firstAutoLevel(){return this.abrController.firstAutoLevel}get nextAutoLevel(){return this.abrController.nextAutoLevel}set nextAutoLevel(e){this.abrController.nextAutoLevel=e}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get maxBufferLength(){return this.streamController.maxBufferLength}setAudioOption(e){var t;return(null==(t=this.audioTrackController)?void 0:t.setAudioOption(e))||null}setSubtitleOption(e){var t;return(null==(t=this.subtitleTrackController)?void 0:t.setSubtitleOption(e))||null}get allAudioTracks(){const e=this.audioTrackController;return e?e.allAudioTracks:[]}get audioTracks(){const e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){const e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){const t=this.audioTrackController;t&&(t.audioTrack=e)}get allSubtitleTracks(){const e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}get subtitleTracks(){const e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){const e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){const t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}get subtitleDisplay(){const e=this.subtitleTrackController;return!!e&&e.subtitleDisplay}set subtitleDisplay(e){const t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}set targetLatency(e){this.latencyController.targetLatency=e}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}get pathways(){return this.levelController.pathways}get pathwayPriority(){return this.levelController.pathwayPriority}set pathwayPriority(e){this.levelController.pathwayPriority=e}get bufferedToEnd(){var e;return!(null==(e=this.bufferController)||!e.bufferedToEnd)}get interstitialsManager(){var e;return(null==(e=this.interstitialsController)?void 0:e.interstitialsManager)||null}getMediaDecodingInfo(e,t=this.allAudioTracks){return qh(e,uf(t),navigator.mediaCapabilities)}}EE.defaultConfig=void 0;const wE=({file:e,startTime:a,poster:o,autoplay:l=!0,active:c=!0,visible:d=!0,muted:h=!0})=>{const f=r(null),{isReady:p,prewarm:m,setLowestResolution:g,startBufferBasedUpshift:v}=(({file:e,videoRef:t,autoplay:a=!0,startTime:o,enabled:l=!0,onReady:c,onError:d})=>{const h=r(null),f=r(null),p=r(0),m=r(0),g=r(!1),v=r(!1),[y,b]=s("idle"),[E,w]=s(0),[S,T]=s(!1),[A,k]=s([]),[I,L]=s("auto"),R=()=>{null!=f.current&&(clearTimeout(f.current),f.current=null)},P=(e=1e3)=>{if(null!=f.current)return;const t=p.current;if(t>=5)return b("error"),R(),void(null==d||d(new Error("Max retry reached")));const r=Math.min(15e3,e*Math.pow(2,Math.min(t,4)));b("loading"),console.log(`[HLS] schedule retry #${t+1} in ${r}ms`),f.current=window.setTimeout(()=>{f.current=null,p.current+=1,console.log(`[HLS] retryCount => ${p.current}`),w(e=>e+1)},r)};i(()=>{p.current=0,m.current=0,v.current=!1,T(!1),w(0),b(e?"loading":"idle"),R()},[e]);const C=n(()=>x(void 0,void 0,void 0,function*(){if(e)try{yield fetch(e,{method:"HEAD",mode:"cors",credentials:"omit"})}catch(e){}}),[e]);i(()=>{var r;const i=t.current;if(!i||!e||!l)return void(e&&!l&&(v.current=!1,T(!1),b("idle")));let n=()=>{};try{null===(r=h.current)||void 0===r||r.destroy()}catch(e){}if(h.current=null,v.current=!1,T(!1),b("loading"),EE.isSupported()){g.current=!1;const t=new EE({lowLatencyMode:!1,backBufferLength:0,maxBufferLength:2,maxMaxBufferLength:4,maxBufferSize:2e6,maxBufferHole:.5,startFragPrefetch:!0,capLevelToPlayerSize:!0});h.current=t;const r=()=>{const e=(t.levels||[]).map((e,t)=>{const r=e.height,i=e.width,n=e.bitrate,s=e.name;return{id:t,height:r,width:i,bitrate:n,name:s,label:s||(r?`${r}p`:`Level ${t}`)}});k(e);const r=t.currentLevel;L(null==r||r<0?"auto":r)},s=()=>{v.current||(v.current=!0,T(!0),b("ready"),p.current=0,R(),null==c||c(),a&&i.play().catch(()=>{}))};t.on(EE.Events.MANIFEST_PARSED,()=>{r(),a||_()}),t.on(EE.Events.FRAG_BUFFERED,s),t.on(EE.Events.BUFFER_APPENDED,s),t.on(EE.Events.LEVEL_SWITCHED,(e,t)=>{const r=null==t?void 0:t.level;L(null==r||r<0?"auto":r)}),t.on(EE.Events.ERROR,(e,r)=>{var i,n,s,a,o;const l=500===(null!==(a=null!==(n=null===(i=null==r?void 0:r.response)||void 0===i?void 0:i.code)&&void 0!==n?n:null===(s=null==r?void 0:r.response)||void 0===s?void 0:s.status)&&void 0!==a?a:null===(o=null==r?void 0:r.response)||void 0===o?void 0:o.statusCode);if(r.type!==EE.ErrorTypes.NETWORK_ERROR||r.fatal){if(r.fatal){if(r.type===EE.ErrorTypes.MEDIA_ERROR){if(m.current+=1,m.current<=2){try{t.recoverMediaError()}catch(e){}return void b("loading")}try{t.destroy()}catch(e){}return h.current=null,v.current=!1,T(!1),void P()}if(l){console.warn("[HLS] fatal 500 response - no retry");try{t.destroy()}catch(e){}return h.current=null,v.current=!1,T(!1),R(),b("error"),void(null==d||d(new Error("HTTP 500")))}try{t.destroy()}catch(e){}return h.current=null,v.current=!1,T(!1),void P()}}else{if(l){console.warn("[HLS] 500 response detected - no retry"),b("error");try{t.destroy()}catch(e){}return h.current=null,R(),void(null==d||d(new Error("HTTP 500")))}try{if(p.current>=5){b("error");try{t.destroy()}catch(e){}return h.current=null,void(null==d||d(new Error("Max retry reached")))}p.current+=1,console.log(`[HLS] non-fatal network retry => ${p.current}`),t.startLoad()}catch(e){}}}),t.attachMedia(i),t.loadSource(e),n=()=>{try{t.destroy()}catch(e){}h.current=null}}else if(i.canPlayType("application/vnd.apple.mpegURL")){g.current=!0,i.src!==e&&(i.src=e);const t=()=>{v.current||(v.current=!0,T(!0),b("ready"),p.current=0,R(),null==c||c(),a&&i.play().catch(()=>{}))},r=()=>{if(v.current=!1,T(!1),p.current>=5)return b("error"),void(null==d||d(new Error("Max retry reached")));P()};i.addEventListener("loadedmetadata",t),i.addEventListener("error",r),a&&i.play().catch(()=>{}),n=()=>{i.removeEventListener("loadedmetadata",t),i.removeEventListener("error",r)}}else b("error"),null==d||d(new Error("HLS not supported"));return()=>{n(),R()}},[e,E,a,c,d,t,l]),i(()=>{if(!S)return;if(null==o||o<=0)return;const e=t.current;if(e)try{Math.abs(e.currentTime-o)>.5&&(e.currentTime=o)}catch(e){}},[S,o,t]),i(()=>{const e=t.current;if(!e)return;const r=()=>b("ready"),i=()=>b("ready"),n=()=>{"error"!==y&&b("loading")},s=()=>b("loading"),a=()=>{b("error"),null==d||d()};return e.addEventListener("playing",r),e.addEventListener("canplay",i),e.addEventListener("waiting",n),e.addEventListener("stalled",s),e.addEventListener("error",a),()=>{e.removeEventListener("playing",r),e.removeEventListener("canplay",i),e.removeEventListener("waiting",n),e.removeEventListener("stalled",s),e.removeEventListener("error",a)}},[y,d,t]);const D=n(()=>{const e=h.current;e&&!g.current&&(console.log("Set auto resolution"),e.nextLevel=-1,L("auto"))},[]),_=n(()=>{var e,t;const r=h.current;if(!r)return;const i=r.levels||[];if(i.length){let n=0;for(let r=1;r<i.length;r++)(null!==(e=i[r].height)&&void 0!==e?e:99999)<(null!==(t=i[n].height)&&void 0!==t?t:99999)&&(n=r);r.currentLevel=n}},[]),O=n((e=2)=>{const r=h.current,i=t.current;if(!r||!i||g.current)return()=>{};let n=!1;const s=()=>{if(!n)if(r.autoLevelEnabled)n=!0;else try{i.buffered.length>0&&i.buffered.end(0)-i.currentTime>=e&&(r.nextLevel=-1,L("auto"),n=!0)}catch(e){}};return r.on(EE.Events.FRAG_BUFFERED,s),()=>{r.off(EE.Events.FRAG_BUFFERED,s)}},[t]);return{playbackStatus:y,isReady:S,qualities:A,currentLevel:I,isAutoQuality:u(()=>"auto"===I,[I]),canSetResolution:!g.current&&EE.isSupported(),setResolution:e=>{const t=h.current;if(!t||g.current)return;if("string"==typeof e&&"auto"===e.toLowerCase())return t.currentLevel=-1,void L("auto");const r="number"==typeof e?e:parseInt(e,10);if(!Number.isFinite(r)){const r=A.find(t=>t.label.toLowerCase()===String(e).toLowerCase());return void(r&&(t.currentLevel=r.id,L(r.id)))}const i=[...A].filter(e=>e.height).sort((e,t)=>(t.height||0)-(e.height||0)),n=i.find(e=>(e.height||0)<=r)||i[i.length-1];n&&(t.currentLevel=n.id,L(n.id))},setAutoResolution:D,prewarm:C,setLowestResolution:_,startBufferBasedUpshift:O}})({file:e,videoRef:f,autoplay:l,startTime:a,enabled:l||c});return i(()=>{m()},[m]),t.useEffect(()=>{var e,t;const r=f.current;if(r)if(c)null===(e=r.play)||void 0===e||e.call(r).catch(()=>{});else try{null===(t=r.pause)||void 0===t||t.call(r)}catch(e){}},[c,p]),i(()=>{if(!c)return;g();return v(2)},[c,g,v]),t.createElement("video",{ref:f,playsInline:!0,autoPlay:l,muted:h,poster:Dt(o||""),preload:"metadata",className:"w-full h-full object-cover object-center bg-black",style:{opacity:d&&p?1:0,transition:"opacity 200ms ease-in-out"}})},SE=({view:e})=>t.createElement("div",{className:"absolute",style:{top:8,left:8,borderRadius:"4px",color:"white",overflow:"hidden",fontSize:11}},t.createElement("span",{style:{backgroundColor:"rgba(62,213,69,0.71)",color:"white",padding:4,paddingLeft:9,paddingRight:9,display:"inline-block",lineHeight:1}},"다시보기"),t.createElement("span",{style:{backgroundColor:"rgba(58,58,58,0.52)",color:"white",padding:4,paddingLeft:9,paddingRight:9,display:"inline-block",lineHeight:1}},e," 시청")),TE=({content:e,aspectRatio:r="9/16",cursor:i="default",borderRadius:n,playback:s="hover"})=>{var a,o,l,c,d;const u=t.useRef(null),[h,f]=t.useState(!1),p=t.useRef(null),[m,g]=t.useState(!1),[v,y]=t.useState(!0),[b,E]=t.useState(!1),{boxSize:w}=au(r,u),S=e.thumbPath||(null===(o=null===(a=null==e?void 0:e.designInfo)||void 0===a?void 0:a.thumbPath)||void 0===o?void 0:o.preview),T=3===e.status,{API_BASE_URL:x,PLAYER_BASE_URL:A}=gt(),k=`${x}/hls/${null===(l=e.replay)||void 0===l?void 0:l.objectId}`;t.useEffect(()=>{const e=u.current;if(!e)return;const t=new IntersectionObserver(e=>{const t=e[0];E(t.isIntersecting&&t.intersectionRatio>=.5)},{root:null,threshold:[0,.5,1]});return t.observe(e),()=>t.disconnect()},[s]),t.useEffect(()=>{var e;if("undefined"!=typeof window&&window.matchMedia)try{const t=window.matchMedia("(pointer: fine)"),r=()=>y(t.matches);return r(),null===(e=t.addEventListener)||void 0===e||e.call(t,"change",r),()=>{var e;return null===(e=t.removeEventListener)||void 0===e?void 0:e.call(t,"change",r)}}catch(e){}},[s]);const I=()=>{null!=p.current&&(clearTimeout(p.current),p.current=null)},L=()=>{g(!0),I(),f(!1)};t.useEffect(()=>{const e=()=>g(!1);return window.addEventListener("mouseup",e),window.addEventListener("touchend",e),window.addEventListener("pointerup",e),()=>{window.removeEventListener("mouseup",e),window.removeEventListener("touchend",e),window.removeEventListener("pointerup",e)}},[s]);const R="hover"===s&&v,P=Boolean(k&&("autoplay"===s&&b||R&&h));return t.createElement("div",{className:"w-full h-full flex flex-col items-center justify-center",ref:u,onMouseEnter:()=>{"hover"===s&&v&&(m||(I(),p.current=window.setTimeout(()=>{f(!0)},150)))},onMouseLeave:()=>{I(),f(!1)},onMouseDown:L,onTouchStart:L},t.createElement("div",{className:"relative rounded overflow-hidden",style:{width:w.width?`${w.width}px`:"100%",height:w.height?`${w.height}px`:"100%",borderRadius:`${null!=n?n:10}px`,backgroundRepeat:"no-repeat",backgroundPosition:"center",backgroundSize:"cover",aspectRatio:w.height?void 0:r,backgroundImage:S?`url(${Dt(S)})`:void 0,backgroundColor:S?void 0:"black"}},T?t.createElement("iframe",{src:`${A}/live/${e.eventId}`,className:"w-full h-full"}):t.createElement(t.Fragment,null,t.createElement("div",{className:"absolute inset-0 w-full h-full object-cover",style:{pointerEvents:"none"}},t.createElement(wE,{file:k,poster:S,autoplay:"autoplay"===s,active:"autoplay"===s&&b||R&&h,visible:P,muted:!0})),!P&&t.createElement(nu,null),t.createElement(SE,{view:null!==(d=null===(c=e.statistics)||void 0===c?void 0:c.pageView)&&void 0!==d?d:0}))))},xE=e=>{var r,i,n,s;const{content:a,title:o,aspectRatio:l="9/16",card:c,titleFontSize:d}=e,h=null!==(r=null==c?void 0:c.layout)&&void 0!==r?r:"slider",f=null!==(i=null==c?void 0:c.sliderPerView)&&void 0!==i?i:3,p=null!==(n=null==c?void 0:c.gridColumns)&&void 0!==n?n:3,m=null!==(s=null==c?void 0:c.gap)&&void 0!==s?s:12,g=null==c?void 0:c.width,v=g?"auto":f,y=u(()=>({fontSize:d?`${d}px`:void 0,fontWeight:600}),[d]),{PLAYER_BASE_URL:b}=gt();return a&&0!==a.length?t.createElement("div",{className:"flex flex-col w-full",style:{gap:m}},t.createElement("p",{className:"truncate",style:Object.assign(Object.assign({},y),{userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none",cursor:"default"})},o||("past"===e.liveType?"지난 라이브":"예정된 라이브")),"slider"===h?t.createElement("div",null,t.createElement(Pa,{key:`${v}-${null!=g?g:""}-${m}`,slidesPerView:v,spaceBetween:m},a.map(r=>{var i,n;return t.createElement(Ca,{key:r.eventId,style:g?{width:`${g}px`}:void 0},t.createElement("a",{href:`${b}/live/${r.eventId}`,target:"_blank",rel:"noopener noreferrer",className:"flex flex-col",style:{gap:6,textDecoration:"none",cursor:"pointer"}},"past"===e.liveType&&r.eventStatus!==iu.READY?t.createElement(TE,{content:r,aspectRatio:l,cursor:"pointer",borderRadius:null==c?void 0:c.borderRadius,playback:e.playback}):t.createElement(ou,{content:r,aspectRatio:l,cursor:"pointer",borderRadius:null==c?void 0:c.borderRadius}),t.createElement("p",{className:"truncate",style:{color:null!==(n=null===(i=e.theme)||void 0===i?void 0:i.textColor)&&void 0!==n?n:"black",fontSize:14,userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"}},r.eventName)))}))):t.createElement("div",{style:{overflowY:"auto"}},t.createElement("div",{style:{display:"grid",gridTemplateColumns:g?`repeat(auto-fill, ${g}px)`:`repeat(${p}, minmax(0, 1fr))`,gap:m}},a.map(r=>{var i,n;return t.createElement("a",{key:r.eventId,href:`${b}/live/${r.eventId}`,target:"_blank",rel:"noopener noreferrer",className:"flex flex-col",style:{gap:6,textDecoration:"none",cursor:"pointer"}},"past"===e.liveType&&r.eventStatus!==iu.READY?t.createElement(TE,{content:r,aspectRatio:l,cursor:"pointer",borderRadius:null==c?void 0:c.borderRadius,playback:e.playback}):t.createElement(ou,{content:r,aspectRatio:l,cursor:"pointer",borderRadius:null==c?void 0:c.borderRadius}),t.createElement("p",{className:"truncate",style:{color:null!==(n=null===(i=e.theme)||void 0===i?void 0:i.textColor)&&void 0!==n?n:"black",fontSize:14,userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"}},r.eventName))})))):null},AE=({content:e})=>{const r=t.useMemo(()=>qe(e.start).tz("Asia/Seoul").format("M월 D일 A HH:mm"),[e.start]),i=e.eventStatus!==iu.READY;return t.createElement("div",{className:"flex-1 flex flex-col gap-5 items-center justify-center"},t.createElement("p",{style:{fontWeight:"bold",fontSize:"24px"}},e.eventName),!i&&t.createElement("p",null,r),t.createElement("button",{onClick:()=>{window.open(`https://player.midibus.im/live/${e.eventId}`,"_blank")},className:"rounded bg-black text-white cursor-pointer",style:{width:"70%",padding:"10px"}},"라이브 입장하기"))},kE=e=>{var r,i;const{content:n,aspectRatio:s="9/16",videoAlign:a}=e,o=null===(r=e.card)||void 0===r?void 0:r.borderRadius,l=null===(i=e.card)||void 0===i?void 0:i.width,{PLAYER_BASE_URL:c}=gt();return t.createElement("div",{className:"flex w-full h-full items-center justify-center"},"only"===a?t.createElement("a",{className:"w-full h-full",href:`${c}/live/${n.eventId}`,target:"_blank",rel:"noopener noreferrer",style:l?{width:`${l}px`}:void 0},t.createElement(ou,{content:n,aspectRatio:s,borderRadius:o,cursor:"pointer"})):"left"===a?t.createElement(t.Fragment,null,t.createElement("div",{className:"flex-1"},t.createElement("a",{href:`${c}/live/${n.eventId}`,target:"_blank",rel:"noopener noreferrer",style:l?{width:`${l}px`}:void 0},t.createElement(ou,{content:n,aspectRatio:s,borderRadius:o,cursor:"pointer"}))),t.createElement(AE,{content:n})):t.createElement(t.Fragment,null,t.createElement(AE,{content:n}),t.createElement("div",{className:"flex-1"},t.createElement("a",{href:`${c}/live/${n.eventId}`,target:"_blank",rel:"noopener noreferrer",style:l?{width:`${l}px`}:void 0},t.createElement(ou,{content:n,aspectRatio:s,borderRadius:o,cursor:"pointer"})))))},IE=e=>{var r;const{theme:i,titleFontSize:n,title:s}=e;return t.createElement("div",{className:"w-full h-full flex flex-col",style:{color:null!==(r=null==i?void 0:i.textColor)&&void 0!==r?r:"#252525"}},t.createElement("p",{style:Object.assign(Object.assign({},n&&{fontSize:n}),{fontWeight:"bold",color:null==i?void 0:i.textColor,paddingTop:"10px",paddingBottom:"10px",marginBottom:"30px"})},s||("past"===e.liveType?"지난 라이브":"예정된 라이브")),t.createElement("div",{className:"self-center text-center h-full flex flex-col items-center justify-center",style:{minHeight:"200px"}},t.createElement("p",{style:{fontSize:"20px",marginBottom:"10px"}},"past"===e.liveType?"지난 라이브가 없어요.":"예정된 라이브가 없어요."),t.createElement("span",{style:{fontWeight:"lighter"}},"past"===e.liveType?"다른 콘텐츠도 확인해 보세요.":"곧 혜택 가득한 라이브로 찾아올게요!")))};function LE(t){var{className:r}=t,i=T(t,["className"]);return e.createElement("div",Object.assign({className:St("animate-pulse rounded-md bg-gray-200",r)},i))}const RE=e=>{var r,i,n,s,a,o,l,c,d;const{card:u,aspectRatio:h="9/16",widgetType:f,layout:p,theme:m}=e,g=null!==(r=null==u?void 0:u.layout)&&void 0!==r?r:"slider",v=null!==(i=null==u?void 0:u.sliderPerView)&&void 0!==i?i:3,y=null!==(n=null==u?void 0:u.gridColumns)&&void 0!==n?n:3,b=null!==(s=null==u?void 0:u.gap)&&void 0!==s?s:12,E=null!==(a=null==u?void 0:u.borderRadius)&&void 0!==a?a:8,w=null!==(o=null==p?void 0:p.paddingTop)&&void 0!==o?o:0,S=null!==(l=null==p?void 0:p.paddingBottom)&&void 0!==l?l:0,T=null!==(c=null==p?void 0:p.paddingLeft)&&void 0!==c?c:0,x=null!==(d=null==p?void 0:p.paddingRight)&&void 0!==d?d:0,A="ONE"===f&&"past"!==e.liveType,k=A?1:(null==u?void 0:u.visibleCount)||6,I=A?1:"slider"===g?v:k;return t.createElement("div",{className:"w-full flex flex-col",style:{gap:b,paddingTop:w,paddingBottom:S,paddingLeft:T,paddingRight:x,backgroundColor:null==m?void 0:m.backgroundColor}},t.createElement(LE,{className:"h-5 w-36"}),t.createElement("div",{style:A||"scroll"!==g?{display:"flex",gap:b,overflow:"hidden"}:{display:"grid",gridTemplateColumns:`repeat(${y}, minmax(0, 1fr))`,gap:b}},Array.from({length:I}).map((e,r)=>t.createElement("div",{key:r,className:"flex flex-col flex-shrink-0",style:{flex:A||"slider"!==g?void 0:`0 0 calc((100% - ${b*(v-1)}px) / ${v})`,gap:6}},t.createElement(LE,{style:{aspectRatio:h,borderRadius:E,width:"100%"}}),t.createElement(LE,{className:"h-3.5 w-4/5"})))))},PE=e=>{var r,i,n,s;const{widgetType:a,theme:o,layout:l}=e,c=ru(e=>e.liveWidget),d=null!==(r=null==l?void 0:l.paddingTop)&&void 0!==r?r:0,u=null!==(i=null==l?void 0:l.paddingBottom)&&void 0!==i?i:0,h=null!==(n=null==l?void 0:l.paddingLeft)&&void 0!==n?n:0,f=null!==(s=null==l?void 0:l.paddingRight)&&void 0!==s?s:0;return null===c?t.createElement(RE,Object.assign({},e)):0===c.length?t.createElement(IE,Object.assign({},e)):t.createElement("div",{className:"w-full h-full",style:{backgroundColor:null==o?void 0:o.backgroundColor,color:null==o?void 0:o.textColor,paddingTop:d,paddingBottom:u,paddingLeft:h,paddingRight:f}},"ONE"===a&&"past"!==e.liveType?t.createElement(kE,Object.assign({content:c[0]},e)):t.createElement(xE,Object.assign({content:c},e)))},CE=e=>{const r=ru(e=>e.liveWidget),n=ru(e=>e.setLiveWidget),{userId:s,card:a,includeRepresentative:o=!1,liveType:l}=e;return i(()=>{if(!s)return;if(r&&(null==a?void 0:a.visibleCount)&&r.length>Number(a.visibleCount))return void n(r.slice(0,null==a?void 0:a.visibleCount));const t=new AbortController;return x(void 0,void 0,void 0,function*(){const r=yield Yt(s,"past"===l?"FINISHED":"UPCOMING",(null==a?void 0:a.visibleCount)||6,o,e.sorting);if(!r||t.signal.aborted)return;n(r);const i=yield Promise.allSettled(r.map(e=>x(void 0,void 0,void 0,function*(){const t=yield((e,t)=>x(void 0,void 0,void 0,function*(){const{STATISTICS_BASE_URL:r}=gt(),i=`${r}/replay/${e}/${t}/summary`,n=yield fetch(i);if(404!==n.status){if(!n.ok){const e=yield n.text().catch(()=>"");return console.error(`[ReplayStatistics] ${n.status} ${n.statusText} ${e}`),{pageView:0,like:0}}return n.json()}}))(s,e.eventId);return Object.assign(Object.assign({},e),{statistics:t})})));t.signal.aborted||n(i.map((e,t)=>"fulfilled"===e.status?e.value:r[t]))}),()=>t.abort()},[s,null==a?void 0:a.visibleCount,l,e.sorting,o]),t.createElement(qr.div,{className:"w-full h-full"},t.createElement(Fo,null),t.createElement(PE,Object.assign({},e)))},DE=e=>t.createElement(tu,null,t.createElement(CE,Object.assign({},e)));var _E={exports:{}},OE={};function ME(e){var t,r,i="";if("string"==typeof e||"number"==typeof e)i+=e;else if("object"==typeof e)if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(r=ME(e[t]))&&(i&&(i+=" "),i+=r);else for(t in e)e[t]&&(i&&(i+=" "),i+=t);return i}function NE(){for(var e,t,r=0,i="";r<arguments.length;)(e=arguments[r++])&&(t=ME(e))&&(i&&(i+=" "),i+=t);return i}var FE,$E=He(Object.freeze({__proto__:null,clsx:NE,default:NE})),BE={},UE={};function zE(){if(FE)return UE;return FE=1,Object.defineProperty(UE,"__esModule",{value:!0}),UE.dontSetMe=function(e,t,r){if(e[t])return new Error("Invalid prop ".concat(t," passed to ").concat(r," - do not set this, set it on the child."))},UE.findInArray=function(e,t){for(let r=0,i=e.length;r<i;r++)if(t.apply(t,[e[r],r,e]))return e[r]},UE.int=function(e){return parseInt(e,10)},UE.isFunction=function(e){return"function"==typeof e||"[object Function]"===Object.prototype.toString.call(e)},UE.isNum=function(e){return"number"==typeof e&&!isNaN(e)},UE}var GE,jE,HE={};function VE(){if(jE)return BE;jE=1,Object.defineProperty(BE,"__esModule",{value:!0}),BE.addClassName=a,BE.addEvent=function(e,t,r,i){if(!e)return;const n={capture:!0,...i};e.addEventListener?e.addEventListener(t,r,n):e.attachEvent?e.attachEvent("on"+t,r):e["on"+t]=r},BE.addUserSelectStyles=function(e){if(!e)return;let t=e.getElementById("react-draggable-style-el");t||(t=e.createElement("style"),t.type="text/css",t.id="react-draggable-style-el",t.innerHTML=".react-draggable-transparent-selection *::-moz-selection {all: inherit;}\n",t.innerHTML+=".react-draggable-transparent-selection *::selection {all: inherit;}\n",e.getElementsByTagName("head")[0].appendChild(t));e.body&&a(e.body,"react-draggable-transparent-selection")},BE.createCSSTransform=function(e,r){const i=s(e,r,"px");return{[(0,t.browserPrefixToKey)("transform",t.default)]:i}},BE.createSVGTransform=function(e,t){return s(e,t,"")},BE.getTouch=function(t,r){return t.targetTouches&&(0,e.findInArray)(t.targetTouches,e=>r===e.identifier)||t.changedTouches&&(0,e.findInArray)(t.changedTouches,e=>r===e.identifier)},BE.getTouchIdentifier=function(e){if(e.targetTouches&&e.targetTouches[0])return e.targetTouches[0].identifier;if(e.changedTouches&&e.changedTouches[0])return e.changedTouches[0].identifier},BE.getTranslation=s,BE.innerHeight=function(t){let r=t.clientHeight;const i=t.ownerDocument.defaultView.getComputedStyle(t);return r-=(0,e.int)(i.paddingTop),r-=(0,e.int)(i.paddingBottom),r},BE.innerWidth=function(t){let r=t.clientWidth;const i=t.ownerDocument.defaultView.getComputedStyle(t);return r-=(0,e.int)(i.paddingLeft),r-=(0,e.int)(i.paddingRight),r},BE.matchesSelector=n,BE.matchesSelectorAndParentsTo=function(e,t,r){let i=e;do{if(n(i,t))return!0;if(i===r)return!1;i=i.parentNode}while(i);return!1},BE.offsetXYFromParent=function(e,t,r){const i=t===t.ownerDocument.body?{left:0,top:0}:t.getBoundingClientRect(),n=(e.clientX+t.scrollLeft-i.left)/r,s=(e.clientY+t.scrollTop-i.top)/r;return{x:n,y:s}},BE.outerHeight=function(t){let r=t.clientHeight;const i=t.ownerDocument.defaultView.getComputedStyle(t);return r+=(0,e.int)(i.borderTopWidth),r+=(0,e.int)(i.borderBottomWidth),r},BE.outerWidth=function(t){let r=t.clientWidth;const i=t.ownerDocument.defaultView.getComputedStyle(t);return r+=(0,e.int)(i.borderLeftWidth),r+=(0,e.int)(i.borderRightWidth),r},BE.removeClassName=o,BE.removeEvent=function(e,t,r,i){if(!e)return;const n={capture:!0,...i};e.removeEventListener?e.removeEventListener(t,r,n):e.detachEvent?e.detachEvent("on"+t,r):e["on"+t]=null},BE.removeUserSelectStyles=function(e){if(!e)return;try{if(e.body&&o(e.body,"react-draggable-transparent-selection"),e.selection)e.selection.empty();else{const t=(e.defaultView||window).getSelection();t&&"Caret"!==t.type&&t.removeAllRanges()}}catch(e){}};var e=zE(),t=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var i=r(t);if(i&&i.has(e))return i.get(e);var n={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if("default"!==a&&Object.prototype.hasOwnProperty.call(e,a)){var o=s?Object.getOwnPropertyDescriptor(e,a):null;o&&(o.get||o.set)?Object.defineProperty(n,a,o):n[a]=e[a]}n.default=e,i&&i.set(e,n);return n}(function(){if(GE)return HE;GE=1,Object.defineProperty(HE,"__esModule",{value:!0}),HE.browserPrefixToKey=r,HE.browserPrefixToStyle=function(e,t){return t?"-".concat(t.toLowerCase(),"-").concat(e):e},HE.default=void 0,HE.getPrefix=t;const e=["Moz","Webkit","O","ms"];function t(){var t;let i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"transform";if("undefined"==typeof window)return"";const n=null===(t=window.document)||void 0===t||null===(t=t.documentElement)||void 0===t?void 0:t.style;if(!n)return"";if(i in n)return"";for(let t=0;t<e.length;t++)if(r(i,e[t])in n)return e[t];return""}function r(e,t){return t?"".concat(t).concat(function(e){let t="",r=!0;for(let i=0;i<e.length;i++)r?(t+=e[i].toUpperCase(),r=!1):"-"===e[i]?r=!0:t+=e[i];return t}(e)):e}return HE.default=t(),HE}());function r(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return(r=function(e){return e?i:t})(e)}let i="";function n(t,r){return i||(i=(0,e.findInArray)(["matches","webkitMatchesSelector","mozMatchesSelector","msMatchesSelector","oMatchesSelector"],function(r){return(0,e.isFunction)(t[r])})),!!(0,e.isFunction)(t[i])&&t[i](r)}function s(e,t,r){let{x:i,y:n}=e,s="translate(".concat(i).concat(r,",").concat(n).concat(r,")");if(t){const e="".concat("string"==typeof t.x?t.x:t.x+r),i="".concat("string"==typeof t.y?t.y:t.y+r);s="translate(".concat(e,", ").concat(i,")")+s}return s}function a(e,t){e.classList?e.classList.add(t):e.className.match(new RegExp("(?:^|\\s)".concat(t,"(?!\\S)")))||(e.className+=" ".concat(t))}function o(e,t){e.classList?e.classList.remove(t):e.className=e.className.replace(new RegExp("(?:^|\\s)".concat(t,"(?!\\S)"),"g"),"")}return BE}var WE,YE={};function KE(){if(WE)return YE;WE=1,Object.defineProperty(YE,"__esModule",{value:!0}),YE.canDragX=function(e){return"both"===e.props.axis||"x"===e.props.axis},YE.canDragY=function(e){return"both"===e.props.axis||"y"===e.props.axis},YE.createCoreData=function(t,i,n){const s=!(0,e.isNum)(t.lastX),a=r(t);return s?{node:a,deltaX:0,deltaY:0,lastX:i,lastY:n,x:i,y:n}:{node:a,deltaX:i-t.lastX,deltaY:n-t.lastY,lastX:t.lastX,lastY:t.lastY,x:i,y:n}},YE.createDraggableData=function(e,t){const r=e.props.scale;return{node:t.node,x:e.state.x+t.deltaX/r,y:e.state.y+t.deltaY/r,deltaX:t.deltaX/r,deltaY:t.deltaY/r,lastX:e.state.x,lastY:e.state.y}},YE.getBoundPosition=function(i,n,s){if(!i.props.bounds)return[n,s];let{bounds:a}=i.props;a="string"==typeof a?a:function(e){return{left:e.left,top:e.top,right:e.right,bottom:e.bottom}}(a);const o=r(i);if("string"==typeof a){const{ownerDocument:r}=o,i=r.defaultView;let n;if(n="parent"===a?o.parentNode:r.querySelector(a),!(n instanceof i.HTMLElement))throw new Error('Bounds selector "'+a+'" could not find an element.');const s=n,l=i.getComputedStyle(o),c=i.getComputedStyle(s);a={left:-o.offsetLeft+(0,e.int)(c.paddingLeft)+(0,e.int)(l.marginLeft),top:-o.offsetTop+(0,e.int)(c.paddingTop)+(0,e.int)(l.marginTop),right:(0,t.innerWidth)(s)-(0,t.outerWidth)(o)-o.offsetLeft+(0,e.int)(c.paddingRight)-(0,e.int)(l.marginRight),bottom:(0,t.innerHeight)(s)-(0,t.outerHeight)(o)-o.offsetTop+(0,e.int)(c.paddingBottom)-(0,e.int)(l.marginBottom)}}(0,e.isNum)(a.right)&&(n=Math.min(n,a.right));(0,e.isNum)(a.bottom)&&(s=Math.min(s,a.bottom));(0,e.isNum)(a.left)&&(n=Math.max(n,a.left));(0,e.isNum)(a.top)&&(s=Math.max(s,a.top));return[n,s]},YE.getControlPosition=function(e,i,n){const s="number"==typeof i?(0,t.getTouch)(e,i):null;if("number"==typeof i&&!s)return null;const a=r(n),o=n.props.offsetParent||a.offsetParent||a.ownerDocument.body;return(0,t.offsetXYFromParent)(s||e,o,n.props.scale)},YE.snapToGrid=function(e,t,r){const i=Math.round(t/e[0])*e[0],n=Math.round(r/e[1])*e[1];return[i,n]};var e=zE(),t=VE();function r(e){const t=e.findDOMNode();if(!t)throw new Error("<DraggableCore>: Unmounted during event!");return t}return YE}var qE,XE,QE,ZE,JE={},ew={};function tw(){if(qE)return ew;return qE=1,Object.defineProperty(ew,"__esModule",{value:!0}),ew.default=function(){},ew}function rw(){if(XE)return JE;XE=1,Object.defineProperty(JE,"__esModule",{value:!0}),JE.default=void 0;var e=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=c(t);if(r&&r.has(e))return r.get(e);var i={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in e)if("default"!==s&&Object.prototype.hasOwnProperty.call(e,s)){var a=n?Object.getOwnPropertyDescriptor(e,s):null;a&&(a.get||a.set)?Object.defineProperty(i,s,a):i[s]=e[s]}i.default=e,r&&r.set(e,i);return i}(t),r=l(Mr()),i=l(m),n=VE(),s=KE(),a=zE(),o=l(tw());function l(e){return e&&e.__esModule?e:{default:e}}function c(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(c=function(e){return e?r:t})(e)}function d(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const u={start:"touchstart",move:"touchmove",stop:"touchend"},h={start:"mousedown",move:"mousemove",stop:"mouseup"};let f=h,p=class extends e.Component{constructor(){super(...arguments),d(this,"dragging",!1),d(this,"lastX",NaN),d(this,"lastY",NaN),d(this,"touchIdentifier",null),d(this,"mounted",!1),d(this,"handleDragStart",e=>{if(this.props.onMouseDown(e),!this.props.allowAnyClick&&"number"==typeof e.button&&0!==e.button)return!1;const t=this.findDOMNode();if(!t||!t.ownerDocument||!t.ownerDocument.body)throw new Error("<DraggableCore> not mounted on DragStart!");const{ownerDocument:r}=t;if(this.props.disabled||!(e.target instanceof r.defaultView.Node)||this.props.handle&&!(0,n.matchesSelectorAndParentsTo)(e.target,this.props.handle,t)||this.props.cancel&&(0,n.matchesSelectorAndParentsTo)(e.target,this.props.cancel,t))return;"touchstart"===e.type&&e.preventDefault();const i=(0,n.getTouchIdentifier)(e);this.touchIdentifier=i;const a=(0,s.getControlPosition)(e,i,this);if(null==a)return;const{x:l,y:c}=a,d=(0,s.createCoreData)(this,l,c);(0,o.default)("DraggableCore: handleDragStart: %j",d),(0,o.default)("calling",this.props.onStart);!1!==this.props.onStart(e,d)&&!1!==this.mounted&&(this.props.enableUserSelectHack&&(0,n.addUserSelectStyles)(r),this.dragging=!0,this.lastX=l,this.lastY=c,(0,n.addEvent)(r,f.move,this.handleDrag),(0,n.addEvent)(r,f.stop,this.handleDragStop))}),d(this,"handleDrag",e=>{const t=(0,s.getControlPosition)(e,this.touchIdentifier,this);if(null==t)return;let{x:r,y:i}=t;if(Array.isArray(this.props.grid)){let e=r-this.lastX,t=i-this.lastY;if([e,t]=(0,s.snapToGrid)(this.props.grid,e,t),!e&&!t)return;r=this.lastX+e,i=this.lastY+t}const n=(0,s.createCoreData)(this,r,i);(0,o.default)("DraggableCore: handleDrag: %j",n);if(!1!==this.props.onDrag(e,n)&&!1!==this.mounted)this.lastX=r,this.lastY=i;else try{this.handleDragStop(new MouseEvent("mouseup"))}catch(e){const t=document.createEvent("MouseEvents");t.initMouseEvent("mouseup",!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),this.handleDragStop(t)}}),d(this,"handleDragStop",e=>{if(!this.dragging)return;const t=(0,s.getControlPosition)(e,this.touchIdentifier,this);if(null==t)return;let{x:r,y:i}=t;if(Array.isArray(this.props.grid)){let e=r-this.lastX||0,t=i-this.lastY||0;[e,t]=(0,s.snapToGrid)(this.props.grid,e,t),r=this.lastX+e,i=this.lastY+t}const a=(0,s.createCoreData)(this,r,i);if(!1===this.props.onStop(e,a)||!1===this.mounted)return!1;const l=this.findDOMNode();l&&this.props.enableUserSelectHack&&(0,n.removeUserSelectStyles)(l.ownerDocument),(0,o.default)("DraggableCore: handleDragStop: %j",a),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,l&&((0,o.default)("DraggableCore: Removing handlers"),(0,n.removeEvent)(l.ownerDocument,f.move,this.handleDrag),(0,n.removeEvent)(l.ownerDocument,f.stop,this.handleDragStop))}),d(this,"onMouseDown",e=>(f=h,this.handleDragStart(e))),d(this,"onMouseUp",e=>(f=h,this.handleDragStop(e))),d(this,"onTouchStart",e=>(f=u,this.handleDragStart(e))),d(this,"onTouchEnd",e=>(f=u,this.handleDragStop(e)))}componentDidMount(){this.mounted=!0;const e=this.findDOMNode();e&&(0,n.addEvent)(e,u.start,this.onTouchStart,{passive:!1})}componentWillUnmount(){this.mounted=!1;const e=this.findDOMNode();if(e){const{ownerDocument:t}=e;(0,n.removeEvent)(t,h.move,this.handleDrag),(0,n.removeEvent)(t,u.move,this.handleDrag),(0,n.removeEvent)(t,h.stop,this.handleDragStop),(0,n.removeEvent)(t,u.stop,this.handleDragStop),(0,n.removeEvent)(e,u.start,this.onTouchStart,{passive:!1}),this.props.enableUserSelectHack&&(0,n.removeUserSelectStyles)(t)}}findDOMNode(){var e,t;return null!==(e=this.props)&&void 0!==e&&e.nodeRef?null===(t=this.props)||void 0===t||null===(t=t.nodeRef)||void 0===t?void 0:t.current:i.default.findDOMNode(this)}render(){return e.cloneElement(e.Children.only(this.props.children),{onMouseDown:this.onMouseDown,onMouseUp:this.onMouseUp,onTouchEnd:this.onTouchEnd})}};return JE.default=p,d(p,"displayName","DraggableCore"),d(p,"propTypes",{allowAnyClick:r.default.bool,children:r.default.node.isRequired,disabled:r.default.bool,enableUserSelectHack:r.default.bool,offsetParent:function(e,t){if(e[t]&&1!==e[t].nodeType)throw new Error("Draggable's offsetParent must be a DOM Node.")},grid:r.default.arrayOf(r.default.number),handle:r.default.string,cancel:r.default.string,nodeRef:r.default.object,onStart:r.default.func,onDrag:r.default.func,onStop:r.default.func,onMouseDown:r.default.func,scale:r.default.number,className:a.dontSetMe,style:a.dontSetMe,transform:a.dontSetMe}),d(p,"defaultProps",{allowAnyClick:!1,disabled:!1,enableUserSelectHack:!0,onStart:function(){},onDrag:function(){},onStop:function(){},onMouseDown:function(){},scale:1}),JE}function iw(){return QE||(QE=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"DraggableCore",{enumerable:!0,get:function(){return c.default}}),e.default=void 0;var r=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=h(t);if(r&&r.has(e))return r.get(e);var i={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in e)if("default"!==s&&Object.prototype.hasOwnProperty.call(e,s)){var a=n?Object.getOwnPropertyDescriptor(e,s):null;a&&(a.get||a.set)?Object.defineProperty(i,s,a):i[s]=e[s]}i.default=e,r&&r.set(e,i);return i}(t),i=u(Mr()),n=u(m),s=u($E),a=VE(),o=KE(),l=zE(),c=u(rw()),d=u(tw());function u(e){return e&&e.__esModule?e:{default:e}}function h(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(h=function(e){return e?r:t})(e)}function f(){return f=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},f.apply(this,arguments)}function p(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class g extends r.Component{static getDerivedStateFromProps(e,t){let{position:r}=e,{prevPropsPosition:i}=t;return!r||i&&r.x===i.x&&r.y===i.y?null:((0,d.default)("Draggable: getDerivedStateFromProps %j",{position:r,prevPropsPosition:i}),{x:r.x,y:r.y,prevPropsPosition:{...r}})}constructor(e){super(e),p(this,"onDragStart",(e,t)=>{(0,d.default)("Draggable: onDragStart: %j",t);if(!1===this.props.onStart(e,(0,o.createDraggableData)(this,t)))return!1;this.setState({dragging:!0,dragged:!0})}),p(this,"onDrag",(e,t)=>{if(!this.state.dragging)return!1;(0,d.default)("Draggable: onDrag: %j",t);const r=(0,o.createDraggableData)(this,t),i={x:r.x,y:r.y,slackX:0,slackY:0};if(this.props.bounds){const{x:e,y:t}=i;i.x+=this.state.slackX,i.y+=this.state.slackY;const[n,s]=(0,o.getBoundPosition)(this,i.x,i.y);i.x=n,i.y=s,i.slackX=this.state.slackX+(e-i.x),i.slackY=this.state.slackY+(t-i.y),r.x=i.x,r.y=i.y,r.deltaX=i.x-this.state.x,r.deltaY=i.y-this.state.y}if(!1===this.props.onDrag(e,r))return!1;this.setState(i)}),p(this,"onDragStop",(e,t)=>{if(!this.state.dragging)return!1;if(!1===this.props.onStop(e,(0,o.createDraggableData)(this,t)))return!1;(0,d.default)("Draggable: onDragStop: %j",t);const r={dragging:!1,slackX:0,slackY:0};if(Boolean(this.props.position)){const{x:e,y:t}=this.props.position;r.x=e,r.y=t}this.setState(r)}),this.state={dragging:!1,dragged:!1,x:e.position?e.position.x:e.defaultPosition.x,y:e.position?e.position.y:e.defaultPosition.y,prevPropsPosition:{...e.position},slackX:0,slackY:0,isElementSVG:!1},!e.position||e.onDrag||e.onStop||console.warn("A `position` was applied to this <Draggable>, without drag handlers. This will make this component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the `position` of this element.")}componentDidMount(){void 0!==window.SVGElement&&this.findDOMNode()instanceof window.SVGElement&&this.setState({isElementSVG:!0})}componentWillUnmount(){this.setState({dragging:!1})}findDOMNode(){var e,t;return null!==(e=null===(t=this.props)||void 0===t||null===(t=t.nodeRef)||void 0===t?void 0:t.current)&&void 0!==e?e:n.default.findDOMNode(this)}render(){const{axis:e,bounds:t,children:i,defaultPosition:n,defaultClassName:l,defaultClassNameDragging:d,defaultClassNameDragged:u,position:h,positionOffset:p,scale:m,...g}=this.props;let v={},y=null;const b=!Boolean(h)||this.state.dragging,E=h||n,w={x:(0,o.canDragX)(this)&&b?this.state.x:E.x,y:(0,o.canDragY)(this)&&b?this.state.y:E.y};this.state.isElementSVG?y=(0,a.createSVGTransform)(w,p):v=(0,a.createCSSTransform)(w,p);const S=(0,s.default)(i.props.className||"",l,{[d]:this.state.dragging,[u]:this.state.dragged});return r.createElement(c.default,f({},g,{onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop}),r.cloneElement(r.Children.only(i),{className:S,style:{...i.props.style,...v},transform:y}))}}e.default=g,p(g,"displayName","Draggable"),p(g,"propTypes",{...c.default.propTypes,axis:i.default.oneOf(["both","x","y","none"]),bounds:i.default.oneOfType([i.default.shape({left:i.default.number,right:i.default.number,top:i.default.number,bottom:i.default.number}),i.default.string,i.default.oneOf([!1])]),defaultClassName:i.default.string,defaultClassNameDragging:i.default.string,defaultClassNameDragged:i.default.string,defaultPosition:i.default.shape({x:i.default.number,y:i.default.number}),positionOffset:i.default.shape({x:i.default.oneOfType([i.default.number,i.default.string]),y:i.default.oneOfType([i.default.number,i.default.string])}),position:i.default.shape({x:i.default.number,y:i.default.number}),className:l.dontSetMe,style:l.dontSetMe,transform:l.dontSetMe}),p(g,"defaultProps",{...c.default.defaultProps,axis:"both",bounds:!1,defaultClassName:"react-draggable",defaultClassNameDragging:"react-draggable-dragging",defaultClassNameDragged:"react-draggable-dragged",defaultPosition:{x:0,y:0},scale:1})}(OE)),OE}var nw=function(){if(ZE)return _E.exports;ZE=1;const{default:e,DraggableCore:t}=iw();return _E.exports=e,_E.exports.default=e,_E.exports.DraggableCore=t,_E.exports}(),sw=je(nw),aw=function(){return aw=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},aw.apply(this,arguments)},ow={width:"100%",height:"10px",top:"0px",left:"0px",cursor:"row-resize"},lw={width:"10px",height:"100%",top:"0px",left:"0px",cursor:"col-resize"},cw={width:"20px",height:"20px",position:"absolute",zIndex:1},dw={top:aw(aw({},ow),{top:"-5px"}),right:aw(aw({},lw),{left:void 0,right:"-5px"}),bottom:aw(aw({},ow),{top:void 0,bottom:"-5px"}),left:aw(aw({},lw),{left:"-5px"}),topRight:aw(aw({},cw),{right:"-10px",top:"-10px",cursor:"ne-resize"}),bottomRight:aw(aw({},cw),{right:"-10px",bottom:"-10px",cursor:"se-resize"}),bottomLeft:aw(aw({},cw),{left:"-10px",bottom:"-10px",cursor:"sw-resize"}),topLeft:aw(aw({},cw),{left:"-10px",top:"-10px",cursor:"nw-resize"})},uw=h(function(e){var t=e.onResizeStart,r=e.direction,i=e.children,s=e.replaceStyles,a=e.className,o=n(function(e){t(e,r)},[t,r]),l=n(function(e){t(e,r)},[t,r]),c=u(function(){return aw(aw({position:"absolute",userSelect:"none"},dw[r]),null!=s?s:{})},[s,r]);return b("div",{className:a||void 0,style:c,onMouseDown:o,onTouchStart:l,children:i})}),hw=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function i(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}}(),fw=function(){return fw=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},fw.apply(this,arguments)},pw={width:"auto",height:"auto"},mw=function(e,t,r){return Math.max(Math.min(e,r),t)},gw=function(e,t,r){var i=Math.round(e/t);return i*t+r*(i-1)},vw=function(e,t){return new RegExp(e,"i").test(t)},yw=function(e){return Boolean(e.touches&&e.touches.length)},bw=function(e,t,r){void 0===r&&(r=0);var i=t.reduce(function(r,i,n){return Math.abs(i-e)<Math.abs(t[r]-e)?n:r},0),n=Math.abs(t[i]-e);return 0===r||n<r?t[i]:e},Ew=function(e){return"auto"===(e=e.toString())||e.endsWith("px")||e.endsWith("%")||e.endsWith("vh")||e.endsWith("vw")||e.endsWith("vmax")||e.endsWith("vmin")?e:"".concat(e,"px")},ww=function(e,t,r,i){if(e&&"string"==typeof e){if(e.endsWith("px"))return Number(e.replace("px",""));if(e.endsWith("%"))return t*(Number(e.replace("%",""))/100);if(e.endsWith("vw"))return r*(Number(e.replace("vw",""))/100);if(e.endsWith("vh"))return i*(Number(e.replace("vh",""))/100)}return e},Sw=["as","ref","style","className","grid","gridGap","snap","bounds","boundsByDirection","size","defaultSize","minWidth","minHeight","maxWidth","maxHeight","lockAspectRatio","lockAspectRatioExtraWidth","lockAspectRatioExtraHeight","enable","handleStyles","handleClasses","handleWrapperStyle","handleWrapperClass","children","onResizeStart","onResize","onResizeStop","handleComponent","scale","resizeRatio","snapGap"],Tw="__resizable_base__",xw=function(e){function t(t){var r,i,n,s,a=e.call(this,t)||this;return a.ratio=1,a.resizable=null,a.parentLeft=0,a.parentTop=0,a.resizableLeft=0,a.resizableRight=0,a.resizableTop=0,a.resizableBottom=0,a.targetLeft=0,a.targetTop=0,a.delta={width:0,height:0},a.appendBase=function(){if(!a.resizable||!a.window)return null;var e=a.parentNode;if(!e)return null;var t=a.window.document.createElement("div");return t.style.width="100%",t.style.height="100%",t.style.position="absolute",t.style.transform="scale(0, 0)",t.style.left="0",t.style.flex="0 0 100%",t.classList?t.classList.add(Tw):t.className+=Tw,e.appendChild(t),t},a.removeBase=function(e){var t=a.parentNode;t&&t.removeChild(e)},a.state={isResizing:!1,width:null!==(i=null===(r=a.propsSize)||void 0===r?void 0:r.width)&&void 0!==i?i:"auto",height:null!==(s=null===(n=a.propsSize)||void 0===n?void 0:n.height)&&void 0!==s?s:"auto",direction:"right",original:{x:0,y:0,width:0,height:0},backgroundStyle:{height:"100%",width:"100%",backgroundColor:"rgba(0,0,0,0)",cursor:"auto",opacity:0,position:"fixed",zIndex:9999,top:"0",left:"0",bottom:"0",right:"0"},flexBasis:void 0},a.onResizeStart=a.onResizeStart.bind(a),a.onMouseMove=a.onMouseMove.bind(a),a.onMouseUp=a.onMouseUp.bind(a),a}return hw(t,e),Object.defineProperty(t.prototype,"parentNode",{get:function(){return this.resizable?this.resizable.parentNode:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"window",{get:function(){return this.resizable&&this.resizable.ownerDocument?this.resizable.ownerDocument.defaultView:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"propsSize",{get:function(){return this.props.size||this.props.defaultSize||pw},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"size",{get:function(){var e=0,t=0;if(this.resizable&&this.window){var r=this.resizable.offsetWidth,i=this.resizable.offsetHeight,n=this.resizable.style.position;"relative"!==n&&(this.resizable.style.position="relative"),e="auto"!==this.resizable.style.width?this.resizable.offsetWidth:r,t="auto"!==this.resizable.style.height?this.resizable.offsetHeight:i,this.resizable.style.position=n}return{width:e,height:t}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sizeStyle",{get:function(){var e=this,t=this.props.size,r=function(t){var r;if(void 0===e.state[t]||"auto"===e.state[t])return"auto";if(e.propsSize&&e.propsSize[t]&&(null===(r=e.propsSize[t])||void 0===r?void 0:r.toString().endsWith("%"))){if(e.state[t].toString().endsWith("%"))return e.state[t].toString();var i=e.getParentSize(),n=Number(e.state[t].toString().replace("px",""))/i[t]*100;return"".concat(n,"%")}return Ew(e.state[t])};return{width:t&&void 0!==t.width&&!this.state.isResizing?Ew(t.width):r("width"),height:t&&void 0!==t.height&&!this.state.isResizing?Ew(t.height):r("height")}},enumerable:!1,configurable:!0}),t.prototype.getParentSize=function(){if(!this.parentNode)return this.window?{width:this.window.innerWidth,height:this.window.innerHeight}:{width:0,height:0};var e=this.appendBase();if(!e)return{width:0,height:0};var t=!1,r=this.parentNode.style.flexWrap;"wrap"!==r&&(t=!0,this.parentNode.style.flexWrap="wrap"),e.style.position="relative",e.style.minWidth="100%",e.style.minHeight="100%";var i={width:e.offsetWidth,height:e.offsetHeight};return t&&(this.parentNode.style.flexWrap=r),this.removeBase(e),i},t.prototype.bindEvents=function(){this.window&&(this.window.addEventListener("mouseup",this.onMouseUp),this.window.addEventListener("mousemove",this.onMouseMove),this.window.addEventListener("mouseleave",this.onMouseUp),this.window.addEventListener("touchmove",this.onMouseMove,{capture:!0,passive:!1}),this.window.addEventListener("touchend",this.onMouseUp))},t.prototype.unbindEvents=function(){this.window&&(this.window.removeEventListener("mouseup",this.onMouseUp),this.window.removeEventListener("mousemove",this.onMouseMove),this.window.removeEventListener("mouseleave",this.onMouseUp),this.window.removeEventListener("touchmove",this.onMouseMove,!0),this.window.removeEventListener("touchend",this.onMouseUp))},t.prototype.componentDidMount=function(){if(this.resizable&&this.window){var e=this.window.getComputedStyle(this.resizable);this.setState({width:this.state.width||this.size.width,height:this.state.height||this.size.height,flexBasis:"auto"!==e.flexBasis?e.flexBasis:void 0})}},t.prototype.componentWillUnmount=function(){this.window&&this.unbindEvents()},t.prototype.createSizeForCssProperty=function(e,t){var r=this.propsSize&&this.propsSize[t];return"auto"!==this.state[t]||this.state.original[t]!==e||void 0!==r&&"auto"!==r?e:"auto"},t.prototype.calculateNewMaxFromBoundary=function(e,t){var r,i,n=this.props.boundsByDirection,s=this.state.direction,a=n&&vw("left",s),o=n&&vw("top",s);if("parent"===this.props.bounds){var l=this.parentNode;l&&(r=a?this.resizableRight-this.parentLeft:l.offsetWidth+(this.parentLeft-this.resizableLeft),i=o?this.resizableBottom-this.parentTop:l.offsetHeight+(this.parentTop-this.resizableTop))}else"window"===this.props.bounds?this.window&&(r=a?this.resizableRight:this.window.innerWidth-this.resizableLeft,i=o?this.resizableBottom:this.window.innerHeight-this.resizableTop):this.props.bounds&&(r=a?this.resizableRight-this.targetLeft:this.props.bounds.offsetWidth+(this.targetLeft-this.resizableLeft),i=o?this.resizableBottom-this.targetTop:this.props.bounds.offsetHeight+(this.targetTop-this.resizableTop));return r&&Number.isFinite(r)&&(e=e&&e<r?e:r),i&&Number.isFinite(i)&&(t=t&&t<i?t:i),{maxWidth:e,maxHeight:t}},t.prototype.calculateNewSizeFromDirection=function(e,t){var r,i=this.props.scale||1,n=(r=this.props.resizeRatio||1,Array.isArray(r)?r:[r,r]),s=n[0],a=n[1],o=this.state,l=o.direction,c=o.original,d=this.props,u=d.lockAspectRatio,h=d.lockAspectRatioExtraHeight,f=d.lockAspectRatioExtraWidth,p=c.width,m=c.height,g=h||0,v=f||0;return vw("right",l)&&(p=c.width+(e-c.x)*s/i,u&&(m=(p-v)/this.ratio+g)),vw("left",l)&&(p=c.width-(e-c.x)*s/i,u&&(m=(p-v)/this.ratio+g)),vw("bottom",l)&&(m=c.height+(t-c.y)*a/i,u&&(p=(m-g)*this.ratio+v)),vw("top",l)&&(m=c.height-(t-c.y)*a/i,u&&(p=(m-g)*this.ratio+v)),{newWidth:p,newHeight:m}},t.prototype.calculateNewSizeFromAspectRatio=function(e,t,r,i){var n=this.props,s=n.lockAspectRatio,a=n.lockAspectRatioExtraHeight,o=n.lockAspectRatioExtraWidth,l=void 0===i.width?10:i.width,c=void 0===r.width||r.width<0?e:r.width,d=void 0===i.height?10:i.height,u=void 0===r.height||r.height<0?t:r.height,h=a||0,f=o||0;if(s){var p=(d-h)*this.ratio+f,m=(u-h)*this.ratio+f,g=(l-f)/this.ratio+h,v=(c-f)/this.ratio+h,y=Math.max(l,p),b=Math.min(c,m),E=Math.max(d,g),w=Math.min(u,v);e=mw(e,y,b),t=mw(t,E,w)}else e=mw(e,l,c),t=mw(t,d,u);return{newWidth:e,newHeight:t}},t.prototype.setBoundingClientRect=function(){var e=1/(this.props.scale||1);if("parent"===this.props.bounds){var t=this.parentNode;if(t){var r=t.getBoundingClientRect();this.parentLeft=r.left*e,this.parentTop=r.top*e}}if(this.props.bounds&&"string"!=typeof this.props.bounds){var i=this.props.bounds.getBoundingClientRect();this.targetLeft=i.left*e,this.targetTop=i.top*e}if(this.resizable){var n=this.resizable.getBoundingClientRect(),s=n.left,a=n.top,o=n.right,l=n.bottom;this.resizableLeft=s*e,this.resizableRight=o*e,this.resizableTop=a*e,this.resizableBottom=l*e}},t.prototype.onResizeStart=function(e,t){if(this.resizable&&this.window){var r,i=0,n=0;if(e.nativeEvent&&function(e){return Boolean((e.clientX||0===e.clientX)&&(e.clientY||0===e.clientY))}(e.nativeEvent)?(i=e.nativeEvent.clientX,n=e.nativeEvent.clientY):e.nativeEvent&&yw(e.nativeEvent)&&(i=e.nativeEvent.touches[0].clientX,n=e.nativeEvent.touches[0].clientY),this.props.onResizeStart)if(this.resizable)if(!1===this.props.onResizeStart(e,t,this.resizable))return;this.props.size&&(void 0!==this.props.size.height&&this.props.size.height!==this.state.height&&this.setState({height:this.props.size.height}),void 0!==this.props.size.width&&this.props.size.width!==this.state.width&&this.setState({width:this.props.size.width})),this.ratio="number"==typeof this.props.lockAspectRatio?this.props.lockAspectRatio:this.size.width/this.size.height;var s=this.window.getComputedStyle(this.resizable);if("auto"!==s.flexBasis){var a=this.parentNode;if(a){var o=this.window.getComputedStyle(a).flexDirection;this.flexDir=o.startsWith("row")?"row":"column",r=s.flexBasis}}this.setBoundingClientRect(),this.bindEvents();var l={original:{x:i,y:n,width:this.size.width,height:this.size.height},isResizing:!0,backgroundStyle:fw(fw({},this.state.backgroundStyle),{cursor:this.window.getComputedStyle(e.target).cursor||"auto"}),direction:t,flexBasis:r};this.setState(l)}},t.prototype.onMouseMove=function(e){var t=this;if(this.state.isResizing&&this.resizable&&this.window){if(this.window.TouchEvent&&yw(e))try{e.preventDefault(),e.stopPropagation()}catch(e){}var r=this.props,i=r.maxWidth,n=r.maxHeight,s=r.minWidth,a=r.minHeight,o=yw(e)?e.touches[0].clientX:e.clientX,l=yw(e)?e.touches[0].clientY:e.clientY,c=this.state,d=c.direction,u=c.original,h=c.width,f=c.height,p=this.getParentSize(),m=function(e,t,r,i,n,s,a){return i=ww(i,e.width,t,r),n=ww(n,e.height,t,r),s=ww(s,e.width,t,r),a=ww(a,e.height,t,r),{maxWidth:void 0===i?void 0:Number(i),maxHeight:void 0===n?void 0:Number(n),minWidth:void 0===s?void 0:Number(s),minHeight:void 0===a?void 0:Number(a)}}(p,this.window.innerWidth,this.window.innerHeight,i,n,s,a);i=m.maxWidth,n=m.maxHeight,s=m.minWidth,a=m.minHeight;var g=this.calculateNewSizeFromDirection(o,l),y=g.newHeight,b=g.newWidth,E=this.calculateNewMaxFromBoundary(i,n);this.props.snap&&this.props.snap.x&&(b=bw(b,this.props.snap.x,this.props.snapGap)),this.props.snap&&this.props.snap.y&&(y=bw(y,this.props.snap.y,this.props.snapGap));var w=this.calculateNewSizeFromAspectRatio(b,y,{width:E.maxWidth,height:E.maxHeight},{width:s,height:a});if(b=w.newWidth,y=w.newHeight,this.props.grid){var S=gw(b,this.props.grid[0],this.props.gridGap?this.props.gridGap[0]:0),T=gw(y,this.props.grid[1],this.props.gridGap?this.props.gridGap[1]:0),x=this.props.snapGap||0;b=0===x||Math.abs(S-b)<=x?S:b,y=0===x||Math.abs(T-y)<=x?T:y}var A={width:b-u.width,height:y-u.height};if(this.delta=A,h&&"string"==typeof h)if(h.endsWith("%")){var k=b/p.width*100;b="".concat(k,"%")}else if(h.endsWith("vw")){var I=b/this.window.innerWidth*100;b="".concat(I,"vw")}else if(h.endsWith("vh")){var L=b/this.window.innerHeight*100;b="".concat(L,"vh")}if(f&&"string"==typeof f)if(f.endsWith("%")){k=y/p.height*100;y="".concat(k,"%")}else if(f.endsWith("vw")){I=y/this.window.innerWidth*100;y="".concat(I,"vw")}else if(f.endsWith("vh")){L=y/this.window.innerHeight*100;y="".concat(L,"vh")}var R={width:this.createSizeForCssProperty(b,"width"),height:this.createSizeForCssProperty(y,"height")};"row"===this.flexDir?R.flexBasis=R.width:"column"===this.flexDir&&(R.flexBasis=R.height);var P=this.state.width!==R.width,C=this.state.height!==R.height,D=this.state.flexBasis!==R.flexBasis,_=P||C||D;_&&v(function(){t.setState(R)}),this.props.onResize&&_&&this.props.onResize(e,d,this.resizable,A)}},t.prototype.onMouseUp=function(e){var t,r,i=this.state,n=i.isResizing,s=i.direction;i.original,n&&this.resizable&&(this.props.onResizeStop&&this.props.onResizeStop(e,s,this.resizable,this.delta),this.props.size&&this.setState({width:null!==(t=this.props.size.width)&&void 0!==t?t:"auto",height:null!==(r=this.props.size.height)&&void 0!==r?r:"auto"}),this.unbindEvents(),this.setState({isResizing:!1,backgroundStyle:fw(fw({},this.state.backgroundStyle),{cursor:"auto"})}))},t.prototype.updateSize=function(e){var t,r;this.setState({width:null!==(t=e.width)&&void 0!==t?t:"auto",height:null!==(r=e.height)&&void 0!==r?r:"auto"})},t.prototype.renderResizer=function(){var e=this,t=this.props,r=t.enable,i=t.handleStyles,n=t.handleClasses,s=t.handleWrapperStyle,a=t.handleWrapperClass,o=t.handleComponent;if(!r)return null;var l=Object.keys(r).map(function(t){return!1!==r[t]?b(uw,{direction:t,onResizeStart:e.onResizeStart,replaceStyles:i&&i[t],className:n&&n[t],children:o&&o[t]?o[t]:null},t):null});return b("div",{className:a,style:s,children:l})},t.prototype.render=function(){var e=this,t=Object.keys(this.props).reduce(function(t,r){return-1!==Sw.indexOf(r)||(t[r]=e.props[r]),t},{}),r=fw(fw(fw({position:"relative",userSelect:this.state.isResizing?"none":"auto"},this.props.style),this.sizeStyle),{maxWidth:this.props.maxWidth,maxHeight:this.props.maxHeight,minWidth:this.props.minWidth,minHeight:this.props.minHeight,boxSizing:"border-box",flexShrink:0});this.state.flexBasis&&(r.flexBasis=this.state.flexBasis);var i=this.props.as||"div";return w(i,fw({style:r,className:this.props.className},t,{ref:function(t){t&&(e.resizable=t)},children:[this.state.isResizing&&b("div",{style:this.state.backgroundStyle}),this.props.children,this.renderResizer()]}))},t.defaultProps={as:"div",onResizeStart:function(){},onResize:function(){},onResizeStop:function(){},enable:{top:!0,right:!0,bottom:!0,left:!0,topRight:!0,bottomRight:!0,bottomLeft:!0,topLeft:!0},style:{},grid:[1,1],gridGap:[0,0],lockAspectRatio:!1,lockAspectRatioExtraWidth:0,lockAspectRatioExtraHeight:0,scale:1,resizeRatio:1,snapGap:0},t}(f),Aw=function(e,t){return Aw=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},Aw(e,t)};var kw=function(){return kw=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},kw.apply(this,arguments)};var Iw={width:"auto",height:"auto",display:"inline-block",position:"absolute",top:0,left:0},Lw=function(e){function t(t){var r=e.call(this,t)||this;return r.resizingPosition={x:0,y:0},r.offsetFromParent={left:0,top:0},r.resizableElement={current:null},r.originalPosition={x:0,y:0},r.state={resizing:!1,bounds:{top:0,right:0,bottom:0,left:0},maxWidth:t.maxWidth,maxHeight:t.maxHeight},r.onResizeStart=r.onResizeStart.bind(r),r.onResize=r.onResize.bind(r),r.onResizeStop=r.onResizeStop.bind(r),r.onDragStart=r.onDragStart.bind(r),r.onDrag=r.onDrag.bind(r),r.onDragStop=r.onDragStop.bind(r),r.getMaxSizesFromProps=r.getMaxSizesFromProps.bind(r),r}return function(e,t){function r(){this.constructor=e}Aw(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}(t,e),t.prototype.componentDidMount=function(){this.updateOffsetFromParent();var e=this.offsetFromParent,t=e.left,r=e.top,i=this.getDraggablePosition(),n=i.x,s=i.y;this.draggable.setState({x:n-t,y:s-r}),this.forceUpdate()},t.prototype.getDraggablePosition=function(){var e=this.draggable.state;return{x:e.x,y:e.y}},t.prototype.getParent=function(){return this.resizable&&this.resizable.parentNode},t.prototype.getParentSize=function(){return this.resizable.getParentSize()},t.prototype.getMaxSizesFromProps=function(){return{maxWidth:void 0===this.props.maxWidth?Number.MAX_SAFE_INTEGER:this.props.maxWidth,maxHeight:void 0===this.props.maxHeight?Number.MAX_SAFE_INTEGER:this.props.maxHeight}},t.prototype.getSelfElement=function(){return this.resizable&&this.resizable.resizable},t.prototype.getOffsetHeight=function(e){var t=this.props.scale;switch(this.props.bounds){case"window":return window.innerHeight/t;case"body":return document.body.offsetHeight/t;default:return e.offsetHeight}},t.prototype.getOffsetWidth=function(e){var t=this.props.scale;switch(this.props.bounds){case"window":return window.innerWidth/t;case"body":return document.body.offsetWidth/t;default:return e.offsetWidth}},t.prototype.onDragStart=function(e,t){this.props.onDragStart&&this.props.onDragStart(e,t);var r=this.getDraggablePosition();if(this.originalPosition=r,this.props.bounds){var i,n=this.getParent(),s=this.props.scale;if("parent"===this.props.bounds)i=n;else{if("body"===this.props.bounds){var a=n.getBoundingClientRect(),o=a.left,l=a.top,c=document.body.getBoundingClientRect(),d=-(o-n.offsetLeft*s-c.left)/s,u=-(l-n.offsetTop*s-c.top)/s,h=(document.body.offsetWidth-this.resizable.size.width*s)/s+d,f=(document.body.offsetHeight-this.resizable.size.height*s)/s+u;return this.setState({bounds:{top:u,right:h,bottom:f,left:d}})}if("window"===this.props.bounds){if(!this.resizable)return;var p=n.getBoundingClientRect(),m=p.left,g=p.top,v=-(m-n.offsetLeft*s)/s,y=-(g-n.offsetTop*s)/s;h=(window.innerWidth-this.resizable.size.width*s)/s+v,f=(window.innerHeight-this.resizable.size.height*s)/s+y;return this.setState({bounds:{top:y,right:h,bottom:f,left:v}})}"string"==typeof this.props.bounds?i=document.querySelector(this.props.bounds):this.props.bounds instanceof HTMLElement&&(i=this.props.bounds)}if(i instanceof HTMLElement&&n instanceof HTMLElement){var b=i.getBoundingClientRect(),E=b.left,w=b.top,S=n.getBoundingClientRect(),T=(E-S.left)/s,x=w-S.top;if(this.resizable){this.updateOffsetFromParent();var A=this.offsetFromParent;this.setState({bounds:{top:x-A.top,right:T+(i.offsetWidth-this.resizable.size.width)-A.left/s,bottom:x+(i.offsetHeight-this.resizable.size.height)-A.top,left:T-A.left/s}})}}}},t.prototype.onDrag=function(e,t){if(this.props.onDrag){var r=this.offsetFromParent,i=r.left,n=r.top;return this.props.dragAxis&&"both"!==this.props.dragAxis?"x"===this.props.dragAxis?this.props.onDrag(e,kw(kw({},t),{x:t.x+i,y:this.originalPosition.y+n,deltaY:0})):"y"===this.props.dragAxis?this.props.onDrag(e,kw(kw({},t),{x:this.originalPosition.x+i,y:t.y+n,deltaX:0})):void 0:this.props.onDrag(e,kw(kw({},t),{x:t.x+i,y:t.y+n}))}},t.prototype.onDragStop=function(e,t){if(this.props.onDragStop){var r=this.offsetFromParent,i=r.left,n=r.top;return this.props.dragAxis&&"both"!==this.props.dragAxis?"x"===this.props.dragAxis?this.props.onDragStop(e,kw(kw({},t),{x:t.x+i,y:this.originalPosition.y+n,deltaY:0})):"y"===this.props.dragAxis?this.props.onDragStop(e,kw(kw({},t),{x:this.originalPosition.x+i,y:t.y+n,deltaX:0})):void 0:this.props.onDragStop(e,kw(kw({},t),{x:t.x+i,y:t.y+n}))}},t.prototype.onResizeStart=function(e,t,r){e.stopPropagation(),this.setState({resizing:!0});var i=this.props.scale,n=this.offsetFromParent,s=this.getDraggablePosition();if(this.resizingPosition={x:s.x+n.left,y:s.y+n.top},this.originalPosition=s,this.props.bounds){var a=this.getParent(),o=void 0;"parent"===this.props.bounds?o=a:"body"===this.props.bounds?o=document.body:"window"===this.props.bounds?o=window:"string"==typeof this.props.bounds?o=document.querySelector(this.props.bounds):this.props.bounds instanceof HTMLElement&&(o=this.props.bounds);var l=this.getSelfElement();if(l instanceof Element&&(o instanceof HTMLElement||o===window)&&a instanceof HTMLElement){var c=this.getMaxSizesFromProps(),d=c.maxWidth,u=c.maxHeight,h=this.getParentSize();if(d&&"string"==typeof d)if(d.endsWith("%")){var f=Number(d.replace("%",""))/100;d=h.width*f}else d.endsWith("px")&&(d=Number(d.replace("px","")));if(u&&"string"==typeof u)if(u.endsWith("%")){f=Number(u.replace("%",""))/100;u=h.height*f}else u.endsWith("px")&&(u=Number(u.replace("px","")));var p=l.getBoundingClientRect(),m=p.left,g=p.top,v="window"===this.props.bounds?{left:0,top:0}:o.getBoundingClientRect(),y=v.left,b=v.top,E=this.getOffsetWidth(o),w=this.getOffsetHeight(o),S=t.toLowerCase().endsWith("left"),T=t.toLowerCase().endsWith("right"),x=t.startsWith("top"),A=t.startsWith("bottom");if((S||x)&&this.resizable){var k=(m-y)/i+this.resizable.size.width;this.setState({maxWidth:k>Number(d)?d:k})}if(T||this.props.lockAspectRatio&&!S&&!x){k=E+(y-m)/i;this.setState({maxWidth:k>Number(d)?d:k})}if((x||S)&&this.resizable){k=(g-b)/i+this.resizable.size.height;this.setState({maxHeight:k>Number(u)?u:k})}if(A||this.props.lockAspectRatio&&!x&&!S){k=w+(b-g)/i;this.setState({maxHeight:k>Number(u)?u:k})}}}else this.setState({maxWidth:this.props.maxWidth,maxHeight:this.props.maxHeight});this.props.onResizeStart&&this.props.onResizeStart(e,t,r)},t.prototype.onResize=function(e,t,r,i){var n=this,s={x:this.originalPosition.x,y:this.originalPosition.y},a=-i.width,o=-i.height;["top","left","topLeft","bottomLeft","topRight"].includes(t)&&("bottomLeft"===t?s.x+=a:("topRight"===t||(s.x+=a),s.y+=o));var l=this.draggable.state;s.x===l.x&&s.y===l.y||v(function(){n.draggable.setState(s)}),this.updateOffsetFromParent();var c=this.offsetFromParent,d=this.getDraggablePosition().x+c.left,u=this.getDraggablePosition().y+c.top;this.resizingPosition={x:d,y:u},this.props.onResize&&this.props.onResize(e,t,r,i,{x:d,y:u})},t.prototype.onResizeStop=function(e,t,r,i){this.setState({resizing:!1});var n=this.getMaxSizesFromProps(),s=n.maxWidth,a=n.maxHeight;this.setState({maxWidth:s,maxHeight:a}),this.props.onResizeStop&&this.props.onResizeStop(e,t,r,i,this.resizingPosition)},t.prototype.updateSize=function(e){this.resizable&&this.resizable.updateSize({width:e.width,height:e.height})},t.prototype.updatePosition=function(e){this.draggable.setState(e)},t.prototype.updateOffsetFromParent=function(){var e=this.props.scale,t=this.getParent(),r=this.getSelfElement();if(!t||null===r)return{top:0,left:0};var i=t.getBoundingClientRect(),n=i.left,s=i.top,a=r.getBoundingClientRect(),o=this.getDraggablePosition(),l=t.scrollLeft,c=t.scrollTop;this.offsetFromParent={left:a.left-n+l-o.x*e,top:a.top-s+c-o.y*e}},t.prototype.render=function(){var e=this,t=this.props,r=t.disableDragging,i=t.style,n=t.dragHandleClassName,s=t.position,a=t.onMouseDown,o=t.onMouseUp,l=t.dragAxis,d=t.dragGrid,u=t.bounds,h=t.enableUserSelectHack,f=t.cancel,p=t.children;t.onResizeStart,t.onResize,t.onResizeStop,t.onDragStart,t.onDrag,t.onDragStop;var m=t.resizeHandleStyles,g=t.resizeHandleClasses,v=t.resizeHandleComponent,y=t.enableResizing,b=t.resizeGrid,E=t.resizeHandleWrapperClass,w=t.resizeHandleWrapperStyle,S=t.scale,T=t.allowAnyClick,x=t.dragPositionOffset,A=function(e,t){var r={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(r[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(i=Object.getOwnPropertySymbols(e);n<i.length;n++)t.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(e,i[n])&&(r[i[n]]=e[i[n]])}return r}(t,["disableDragging","style","dragHandleClassName","position","onMouseDown","onMouseUp","dragAxis","dragGrid","bounds","enableUserSelectHack","cancel","children","onResizeStart","onResize","onResizeStop","onDragStart","onDrag","onDragStop","resizeHandleStyles","resizeHandleClasses","resizeHandleComponent","enableResizing","resizeGrid","resizeHandleWrapperClass","resizeHandleWrapperStyle","scale","allowAnyClick","dragPositionOffset"]),k=this.props.default?kw({},this.props.default):void 0;delete A.default;var I,L=r||n?{cursor:"auto"}:{cursor:"move"},R=kw(kw(kw({},Iw),L),i),P=this.offsetFromParent,C=P.left,D=P.top;s&&(I={x:s.x-C,y:s.y-D});var _,O=this.state.resizing?void 0:I,M=this.state.resizing?"both":l;return c(sw,{ref:function(t){t&&(e.draggable=t)},handle:n?".".concat(n):void 0,defaultPosition:k,onMouseDown:a,onMouseUp:o,onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop,axis:M,disabled:r,grid:d,bounds:u?this.state.bounds:void 0,position:O,enableUserSelectHack:h,cancel:f,scale:S,allowAnyClick:T,nodeRef:this.resizableElement,positionOffset:x},c(xw,kw({},A,{ref:function(t){t&&(e.resizable=t,e.resizableElement.current=t.resizable)},defaultSize:k,size:this.props.size,enable:"boolean"==typeof y?(_=y,{bottom:_,bottomLeft:_,bottomRight:_,left:_,right:_,top:_,topLeft:_,topRight:_}):y,onResizeStart:this.onResizeStart,onResize:this.onResize,onResizeStop:this.onResizeStop,style:R,minWidth:this.props.minWidth,minHeight:this.props.minHeight,maxWidth:this.state.resizing?this.state.maxWidth:this.props.maxWidth,maxHeight:this.state.resizing?this.state.maxHeight:this.props.maxHeight,grid:b,handleWrapperClass:E,handleWrapperStyle:w,lockAspectRatio:this.props.lockAspectRatio,lockAspectRatioExtraWidth:this.props.lockAspectRatioExtraWidth,lockAspectRatioExtraHeight:this.props.lockAspectRatioExtraHeight,handleStyles:m,handleClasses:g,handleComponent:v,scale:this.props.scale}),p))},t.defaultProps={maxWidth:Number.MAX_SAFE_INTEGER,maxHeight:Number.MAX_SAFE_INTEGER,scale:1,onResizeStart:function(){},onResize:function(){},onResizeStop:function(){},onDragStart:function(){},onDrag:function(){},onDragStop:function(){}},t}(f);const Rw=({eventId:e})=>{const[r,i]=s(!1),{PLAYER_BASE_URL:n}=gt();if(r)return null;const{w:a,h:o,left:l,top:c}=(()=>{const e=window.visualViewport;return e?{w:e.width,h:e.height,left:e.offsetLeft,top:e.offsetTop}:{w:window.innerWidth,h:window.innerHeight,left:0,top:0}})();return t.createElement(Lw,{minWidth:240,lockAspectRatio:9/17.05,style:{zIndex:99999},default:{width:240,height:455,x:l+a-240-50,y:c+o-427-28-50},bounds:"window",dragHandleClassName:"live-floating-drag-handle"},t.createElement("div",{className:"flex flex-col w-full h-full",style:{borderRadius:8,overflow:"hidden",boxShadow:"0 4px 24px rgba(0,0,0,0.4)"}},t.createElement("div",{className:"live-floating-drag-handle flex items-center justify-between",style:{height:28,minHeight:28,background:"#111",cursor:"grab",padding:"0 8px",userSelect:"none"}},t.createElement(oi,{size:16,color:"#888"}),t.createElement("button",{className:"cursor-pointer",style:{color:"#ccc",lineHeight:0},onClick:()=>i(!0),"aria-label":"Close"},t.createElement(gi,{size:16}))),t.createElement("iframe",{src:`${n}/live/${e}`,style:{flex:1,border:0,display:"block",minHeight:0},allow:"autoplay; fullscreen; picture-in-picture",allowFullScreen:!0,scrolling:"no",referrerPolicy:"no-referrer-when-downgrade"})))},Pw=({eventId:e})=>e?t.createElement(qr.div,{style:{position:"fixed",inset:0,pointerEvents:"none",zIndex:99999}},t.createElement(Fo,null),t.createElement("div",{style:{pointerEvents:"auto"}},t.createElement(Rw,{eventId:e}))):null;export{jd as CollectionShowcase,Jd as FloatingCollectionPlayer,Xd as FloatingPlayer,Pw as LiveFloatingPlayer,DE as LiveWidget,jo as PreviewPlayer,Go as ShoppingPlayer,or as ViewPlayer,Dd as WidgetPlayer,mt as configure};
|