@kinxcdn/commerce-player 1.6.7-alpha.4 → 1.6.7-alpha.6

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/esm/index.js CHANGED
@@ -31,10 +31,10 @@ var xr={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24
31
31
  *
32
32
  * This source code is licensed under the ISC license.
33
33
  * See the LICENSE file in the root directory of this source tree.
34
- */const Ar=s(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:i,className:n="",children:s,iconNode:a,...o},d)=>l("svg",{ref:d,...xr,width:t,height:t,stroke:e,strokeWidth:i?24*Number(r)/Number(t):r,className:Sr("lucide",n),...!s&&!Tr(o)&&{"aria-hidden":"true"},...o},[...a.map(([e,t])=>l(e,t)),...Array.isArray(s)?s:[s]])),kr=(e,t)=>{const r=s(({className:r,...i},n)=>{return l(Ar,{ref:n,iconNode:t,className:Sr(`lucide-${s=wr(e),s.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,`lucide-${e}`,r),...i});var s});return r.displayName=wr(e),r},Lr=kr("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]),Ir=kr("chevron-left",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]),Rr=kr("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),Pr=kr("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]),Cr=kr("grip-horizontal",[["circle",{cx:"12",cy:"9",r:"1",key:"124mty"}],["circle",{cx:"19",cy:"9",r:"1",key:"1ruzo2"}],["circle",{cx:"5",cy:"9",r:"1",key:"1a8b28"}],["circle",{cx:"12",cy:"15",r:"1",key:"1e56xg"}],["circle",{cx:"19",cy:"15",r:"1",key:"1a92ep"}],["circle",{cx:"5",cy:"15",r:"1",key:"5r1jwy"}]]),Dr=kr("heart",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}]]),_r=kr("pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]]),Or=kr("play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]),Mr=kr("share-2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]),Nr=kr("volume-2",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]]),Fr=kr("volume-x",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]]),$r=kr("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Br=()=>t.createElement("div",{className:"text-white rounded max-w-fit bg-[rgba(0,0,0,.3)] flex overflow-hidden items-center text-[12px] h-6 mt-2"},t.createElement("div",{className:"bg-[#0ab060] h-full flex gap-1 items-center"},t.createElement(Or,{size:18}),t.createElement("span",{className:"pr-1"},"조회수")),t.createElement("div",{className:"p-1"},"123 시청")),Ur=({width:e,height:r})=>t.createElement("div",{className:"w-full h-full flex items-center justify-center"},t.createElement("img",{src:"public/images/noImage.svg",alt:"no image",width:e||50,height:r||50})),zr=({product:e,onError:r})=>t.createElement("img",{src:Rt(e.thumbPath),alt:e.productName,className:"h-full w-full rounded object-cover",onError:r}),Gr=({product:e})=>{const[r,i]=a(!1);return t.createElement("div",{className:"flex gap-3 text-sm cursor-pointer h-[100px] items-center"},t.createElement("div",{className:"h-full overflow-hidden rounded border aspect-square"},e.thumbPath&&!r?t.createElement(zr,{product:e,onError:()=>i(!0)}):t.createElement(Ur,null)),t.createElement("div",{className:"justify-center flex flex-col"},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:"max-w-52 break-keep line-clamp-2"},e.productName),t.createElement("div",null,t.createElement("span",{className:"font-semibold text-red-500"},e.discount,"%"," "),t.createElement("span",{className:"font-semibold"},xt(e.sellingPrice),"원"))))},jr=()=>t.createElement("div",{className:"flex flex-col gap-2 overflow-y-auto max-h-[150px] px-2"},t.createElement("p",{className:"font-medium text-gray-400 text-sm"},"영상과 무관하거나 욕설, 비방 등의 댓글은 관리자에 의해 삭제될 수 있습니다."),t.createElement("div",null,t.createElement("div",{className:"flex justify-between"},t.createElement("div",null,t.createElement("p",{className:"font-semibold"},"유저 ID"),t.createElement("p",null,"댓글 내용"),t.createElement("span",{className:"text-gray-500"},"2024.01.01"))))),Hr=()=>t.createElement("div",{className:"inline-block absolute pointer-events-none top-0 z-10 animate-float"},t.createElement(Dr,{className:"fill-red-500 text-transparent"})),Vr=({rounded:e})=>{const[r,i]=a(234),[n,s]=a([]),o=()=>x(void 0,void 0,void 0,function*(){(()=>{const e=Date.now();s(t=>[...t,e]),setTimeout(()=>{s(t=>t.filter(t=>t!==e))},2e3)})(),i(e=>e+1)});return e?t.createElement("div",{className:"w-14 h-14 bg-white rounded-full flex justify-center"},t.createElement("div",{className:"flex justify-center flex-col items-center relative"},t.createElement("div",{onClick:o,style:{border:"none"},className:"z-[5] cursor-pointer"},t.createElement(Dr,{className:"text-xl fill-black"})),n.map(e=>t.createElement(Hr,{key:e})),t.createElement("span",{className:"break-keep text-xs"},xt(r)))):t.createElement("div",{className:"flex justify-center flex-col items-center relative"},t.createElement("div",{onClick:o,className:"z-[5] cursor-pointer"},t.createElement(Dr,{className:"text-xl fill-white"})),n.map(e=>t.createElement(Hr,{key:e})),t.createElement("span",{className:"break-keep text-xs"},xt(r)))},Wr=({rounded:e})=>e?t.createElement("div",{className:"w-14 h-14 bg-white rounded-full flex justify-center "},t.createElement("button",{className:"cursor-pointer"},t.createElement(Mr,{size:28}))):t.createElement("button",{className:"cursor-pointer"},t.createElement(Mr,{size:28})),Yr=({rounded:e,mute:r,handleMute:i,iconSize:n})=>e?t.createElement("div",{className:"w-12 h-12 bg-white rounded-full flex justify-center items-center "},t.createElement("button",Object.assign({className:"cursor-pointer"},i&&{onClick:i}),r?t.createElement(Nr,{size:28}):t.createElement(Fr,{size:28}))):t.createElement("button",Object.assign({className:"cursor-pointer"},i&&{onClick:i}),r?t.createElement(Nr,{size:n||28}):t.createElement(Fr,{size:n||28}));
34
+ */const Ar=s(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:i,className:n="",children:s,iconNode:a,...o},d)=>l("svg",{ref:d,...xr,width:t,height:t,stroke:e,strokeWidth:i?24*Number(r)/Number(t):r,className:Sr("lucide",n),...!s&&!Tr(o)&&{"aria-hidden":"true"},...o},[...a.map(([e,t])=>l(e,t)),...Array.isArray(s)?s:[s]])),kr=(e,t)=>{const r=s(({className:r,...i},n)=>{return l(Ar,{ref:n,iconNode:t,className:Sr(`lucide-${s=wr(e),s.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,`lucide-${e}`,r),...i});var s});return r.displayName=wr(e),r},Lr=kr("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]),Ir=kr("chevron-left",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]),Rr=kr("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),Pr=kr("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]),Cr=kr("chevrons-up-down",[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]),Dr=kr("grip-horizontal",[["circle",{cx:"12",cy:"9",r:"1",key:"124mty"}],["circle",{cx:"19",cy:"9",r:"1",key:"1ruzo2"}],["circle",{cx:"5",cy:"9",r:"1",key:"1a8b28"}],["circle",{cx:"12",cy:"15",r:"1",key:"1e56xg"}],["circle",{cx:"19",cy:"15",r:"1",key:"1a92ep"}],["circle",{cx:"5",cy:"15",r:"1",key:"5r1jwy"}]]),_r=kr("heart",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}]]),Or=kr("pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]]),Mr=kr("play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]),Nr=kr("share-2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]),Fr=kr("volume-2",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]]),$r=kr("volume-x",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]]),Br=kr("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Ur=()=>t.createElement("div",{className:"text-white rounded max-w-fit bg-[rgba(0,0,0,.3)] flex overflow-hidden items-center text-[12px] h-6 mt-2"},t.createElement("div",{className:"bg-[#0ab060] h-full flex gap-1 items-center"},t.createElement(Mr,{size:18}),t.createElement("span",{className:"pr-1"},"조회수")),t.createElement("div",{className:"p-1"},"123 시청")),zr=({width:e,height:r})=>t.createElement("div",{className:"w-full h-full flex items-center justify-center"},t.createElement("img",{src:"public/images/noImage.svg",alt:"no image",width:e||50,height:r||50})),Gr=({product:e,onError:r})=>t.createElement("img",{src:Rt(e.thumbPath),alt:e.productName,className:"h-full w-full rounded object-cover",onError:r}),jr=({product:e})=>{const[r,i]=a(!1);return t.createElement("div",{className:"flex gap-3 text-sm cursor-pointer h-[100px] items-center"},t.createElement("div",{className:"h-full overflow-hidden rounded border aspect-square"},e.thumbPath&&!r?t.createElement(Gr,{product:e,onError:()=>i(!0)}):t.createElement(zr,null)),t.createElement("div",{className:"justify-center flex flex-col"},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:"max-w-52 break-keep line-clamp-2"},e.productName),t.createElement("div",null,t.createElement("span",{className:"font-semibold text-red-500"},e.discount,"%"," "),t.createElement("span",{className:"font-semibold"},xt(e.sellingPrice),"원"))))},Hr=()=>t.createElement("div",{className:"flex flex-col gap-2 overflow-y-auto max-h-[150px] px-2"},t.createElement("p",{className:"font-medium text-gray-400 text-sm"},"영상과 무관하거나 욕설, 비방 등의 댓글은 관리자에 의해 삭제될 수 있습니다."),t.createElement("div",null,t.createElement("div",{className:"flex justify-between"},t.createElement("div",null,t.createElement("p",{className:"font-semibold"},"유저 ID"),t.createElement("p",null,"댓글 내용"),t.createElement("span",{className:"text-gray-500"},"2024.01.01"))))),Vr=()=>t.createElement("div",{className:"inline-block absolute pointer-events-none top-0 z-10 animate-float"},t.createElement(_r,{className:"fill-red-500 text-transparent"})),Wr=({rounded:e})=>{const[r,i]=a(234),[n,s]=a([]),o=()=>x(void 0,void 0,void 0,function*(){(()=>{const e=Date.now();s(t=>[...t,e]),setTimeout(()=>{s(t=>t.filter(t=>t!==e))},2e3)})(),i(e=>e+1)});return e?t.createElement("div",{className:"w-14 h-14 bg-white rounded-full flex justify-center"},t.createElement("div",{className:"flex justify-center flex-col items-center relative"},t.createElement("div",{onClick:o,style:{border:"none"},className:"z-[5] cursor-pointer"},t.createElement(_r,{className:"text-xl fill-black"})),n.map(e=>t.createElement(Vr,{key:e})),t.createElement("span",{className:"break-keep text-xs"},xt(r)))):t.createElement("div",{className:"flex justify-center flex-col items-center relative"},t.createElement("div",{onClick:o,className:"z-[5] cursor-pointer"},t.createElement(_r,{className:"text-xl fill-white"})),n.map(e=>t.createElement(Vr,{key:e})),t.createElement("span",{className:"break-keep text-xs"},xt(r)))},Yr=({rounded:e})=>e?t.createElement("div",{className:"w-14 h-14 bg-white rounded-full flex justify-center "},t.createElement("button",{className:"cursor-pointer"},t.createElement(Nr,{size:28}))):t.createElement("button",{className:"cursor-pointer"},t.createElement(Nr,{size:28})),Kr=({rounded:e,mute:r,handleMute:i,iconSize:n})=>e?t.createElement("div",{className:"w-12 h-12 bg-white rounded-full flex justify-center items-center "},t.createElement("button",Object.assign({className:"cursor-pointer"},i&&{onClick:i}),r?t.createElement(Fr,{size:28}):t.createElement($r,{size:28}))):t.createElement("button",Object.assign({className:"cursor-pointer"},i&&{onClick:i}),r?t.createElement(Fr,{size:n||28}):t.createElement($r,{size:n||28}));
35
35
  /**
36
36
  * @license lucide-react v0.503.0 - ISC
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 Kr(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,d=e.useMemo(()=>o,Object.values(o));return b(l.Provider,{value:d,children:n})};return o.displayName=r+"Provider",[o,function(i,o){const l=o?.[t]?.[a]||s,d=e.useContext(l);if(d)return d;if(void 0!==n)return n;throw new Error(`\`${i}\` must be used within \`${r}\``)}]},qr(n,...r)]}function qr(...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 Xr(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function Qr(...e){return t=>{let r=!1;const i=e.map(e=>{const i=Xr(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():Xr(e[t],null)}}}}function Zr(...t){return e.useCallback(Qr(...t),t)}var Jr=e.forwardRef((t,r)=>{const{children:i,...n}=t,s=e.Children.toArray(i),a=s.find(ri);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(ei,{...n,ref:r,children:e.isValidElement(t)?e.cloneElement(t,void 0,i):null})}return b(ei,{...n,ref:r,children:i})});Jr.displayName="Slot";var ei=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?Qr(r,t):t),e.cloneElement(i,s)}return e.Children.count(i)>1?e.Children.only(null):null});ei.displayName="SlotClone";var ti=({children:e})=>b(E,{children:e});function ri(t){return e.isValidElement(t)&&t.type===ti}function ii(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=ii(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():ii(e[t],null)}}}}function si(e,t,{checkForDefaultPrevented:r=!0}={}){return function(i){if(e?.(i),!1===r||!i.defaultPrevented)return t?.(i)}}function ai(t){const r=e.useRef(t);return e.useEffect(()=>{r.current=t}),e.useMemo(()=>(...e)=>r.current?.(...e),[])}function oi({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=ai(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=ai(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 li=e.forwardRef((t,r)=>{const{children:i,...n}=t,s=e.Children.toArray(i),a=s.find(ui);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})});li.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?ni(r,t):t),e.cloneElement(i,s)}return e.Children.count(i)>1?e.Children.only(null):null});di.displayName="SlotClone";var ci=({children:e})=>b(E,{children:e});function ui(t){return e.isValidElement(t)&&t.type===ci}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?li:r;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),b(s,{...n,ref:t})});return i.displayName=`Primitive.${r}`,{...t,[r]:i}},{}),fi=Boolean(globalThis?.document)?e.useLayoutEffect:()=>{};function pi(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function mi(...e){return t=>{let r=!1;const i=e.map(e=>{const i=pi(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():pi(e[t],null)}}}}function gi(...t){return e.useCallback(mi(...t),t)}var vi=e.forwardRef((t,r)=>{const{children:i,...n}=t,s=e.Children.toArray(i),a=s.find(Ei);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(yi,{...n,ref:r,children:e.isValidElement(t)?e.cloneElement(t,void 0,i):null})}return b(yi,{...n,ref:r,children:i})});vi.displayName="Slot";var yi=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?mi(r,t):t),e.cloneElement(i,s)}return e.Children.count(i)>1?e.Children.only(null):null});yi.displayName="SlotClone";var bi=({children:e})=>b(E,{children:e});function Ei(t){return e.isValidElement(t)&&t.type===bi}var wi=["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?vi:r;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),b(s,{...n,ref:t})});return i.displayName=`Primitive.${r}`,{...t,[r]:i}},{});var Si=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,d]=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=Ti(n.current);a.current="mounted"===l?e:"none"},[l]),fi(()=>{const e=n.current,r=s.current;if(r!==t){const i=a.current,n=Ti(e);if(t)d("MOUNT");else if("none"===n||"none"===e?.display)d("UNMOUNT");else{d(r&&i!==n?"ANIMATION_OUT":"UNMOUNT")}s.current=t}},[t,d]),fi(()=>{if(r){let e;const t=r.ownerDocument.defaultView??window,i=i=>{const a=Ti(n.current).includes(i.animationName);if(i.target===r&&a&&(d("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=Ti(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)}}d("ANIMATION_END")},[r,d]),{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=gi(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 Ti(e){return e?.animationName||"none"}Si.displayName="Presence";var xi=Boolean(globalThis?.document)?e.useLayoutEffect:()=>{},Ai=e["useId".toString()]||(()=>{}),ki=0;function Li(t){const[r,i]=e.useState(Ai());return xi(()=>{i(e=>e??String(ki++))},[t]),r?`radix-${r}`:""}var Ii="Collapsible",[Ri,Pi]=Kr(Ii),[Ci,Di]=Ri(Ii),_i=e.forwardRef((t,r)=>{const{__scopeCollapsible:i,open:n,defaultOpen:s,disabled:a,onOpenChange:o,...l}=t,[d=!1,c]=oi({prop:n,defaultProp:s,onChange:o});return b(Ci,{scope:i,disabled:a,contentId:Li(),open:d,onOpenToggle:e.useCallback(()=>c(e=>!e),[c]),children:b(wi.div,{"data-state":Bi(d),"data-disabled":a?"":void 0,...l,ref:r})})});_i.displayName=Ii;var Oi="CollapsibleTrigger",Mi=e.forwardRef((e,t)=>{const{__scopeCollapsible:r,...i}=e,n=Di(Oi,r);return b(wi.button,{type:"button","aria-controls":n.contentId,"aria-expanded":n.open||!1,"data-state":Bi(n.open),"data-disabled":n.disabled?"":void 0,disabled:n.disabled,...i,ref:t,onClick:si(e.onClick,n.onOpenToggle)})});Mi.displayName=Oi;var Ni="CollapsibleContent",Fi=e.forwardRef((e,t)=>{const{forceMount:r,...i}=e,n=Di(Ni,e.__scopeCollapsible);return b(Si,{present:r||n.open,children:({present:e})=>b($i,{...i,ref:t,present:e})})});Fi.displayName=Ni;var $i=e.forwardRef((t,r)=>{const{__scopeCollapsible:i,present:n,children:s,...a}=t,o=Di(Ni,i),[l,d]=e.useState(n),c=e.useRef(null),u=gi(r,c),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)},[]),fi(()=>{const e=c.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),d(n)}},[o.open,n]),b(wi.div,{"data-state":Bi(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 Bi(e){return e?"open":"closed"}var Ui=_i,zi=Mi,Gi=Fi,ji=e.createContext(void 0);var Hi="Accordion",Vi=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[Wi,Yi,Ki]=function(e){const r=e+"CollectionProvider",[i,n]=Kr(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",d=t.forwardRef((e,t)=>{const{scope:r,children:i}=e,n=Zr(t,a(l,r).collectionRef);return b(Jr,{ref:n,children:i})});d.displayName=l;const c=e+"CollectionItemSlot",u="data-radix-collection-item",h=t.forwardRef((e,r)=>{const{scope:i,children:n,...s}=e,o=t.useRef(null),l=Zr(r,o),d=a(c,i);return t.useEffect(()=>(d.itemMap.set(o,{ref:o,...s}),()=>{d.itemMap.delete(o)})),b(Jr,{[u]:"",ref:l,children:n})});return h.displayName=c,[{Provider:o,Slot:d,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]}(Hi),[qi,Xi]=Kr(Hi,[Ki,Pi]),Qi=Pi(),Zi=t.forwardRef((e,t)=>{const{type:r,...i}=e,n=i,s=i;return b(Wi.Provider,{scope:e.__scopeAccordion,children:"multiple"===r?b(sn,{...s,ref:t}):b(nn,{...n,ref:t})})});Zi.displayName=Hi;var[Ji,en]=qi(Hi),[tn,rn]=qi(Hi,{collapsible:!1}),nn=t.forwardRef((e,r)=>{const{value:i,defaultValue:n,onValueChange:s=()=>{},collapsible:a=!1,...o}=e,[l,d]=oi({prop:i,defaultProp:n,onChange:s});return b(Ji,{scope:e.__scopeAccordion,value:l?[l]:[],onItemOpen:d,onItemClose:t.useCallback(()=>a&&d(""),[a,d]),children:b(tn,{scope:e.__scopeAccordion,collapsible:a,children:b(ln,{...o,ref:r})})})}),sn=t.forwardRef((e,r)=>{const{value:i,defaultValue:n,onValueChange:s=()=>{},...a}=e,[o=[],l]=oi({prop:i,defaultProp:n,onChange:s}),d=t.useCallback(e=>l((t=[])=>[...t,e]),[l]),c=t.useCallback(e=>l((t=[])=>t.filter(t=>t!==e)),[l]);return b(Ji,{scope:e.__scopeAccordion,value:o,onItemOpen:d,onItemClose:c,children:b(tn,{scope:e.__scopeAccordion,collapsible:!0,children:b(ln,{...a,ref:r})})})}),[an,on]=qi(Hi),ln=t.forwardRef((r,i)=>{const{__scopeAccordion:n,disabled:s,dir:a,orientation:o="vertical",...l}=r,d=function(...t){return e.useCallback(ni(...t),t)}(t.useRef(null),i),c=Yi(n),u="ltr"===function(t){const r=e.useContext(ji);return t||r||"ltr"}(a),h=si(r.onKeyDown,e=>{if(!Vi.includes(e.key))return;const t=e.target,r=c().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)},d=()=>{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():d());break;case"ArrowDown":"vertical"===o&&l();break;case"ArrowLeft":"horizontal"===o&&(u?d():l());break;case"ArrowUp":"vertical"===o&&d()}const h=s%n;r[h].ref.current?.focus()});return b(an,{scope:n,disabled:s,direction:a,orientation:o,children:b(Wi.Slot,{scope:n,children:b(hi.div,{...l,"data-orientation":o,ref:d,onKeyDown:s?void 0:h})})})}),dn="AccordionItem",[cn,un]=qi(dn),hn=t.forwardRef((e,t)=>{const{__scopeAccordion:r,value:i,...n}=e,s=on(dn,r),a=en(dn,r),o=Qi(r),l=Li(),d=i&&a.value.includes(i)||!1,c=s.disabled||e.disabled;return b(cn,{scope:r,open:d,disabled:c,triggerId:l,children:b(Ui,{"data-orientation":s.orientation,"data-state":bn(d),...o,...n,ref:t,disabled:c,open:d,onOpenChange:e=>{e?a.onItemOpen(i):a.onItemClose(i)}})})});hn.displayName=dn;var fn="AccordionHeader",pn=t.forwardRef((e,t)=>{const{__scopeAccordion:r,...i}=e,n=on(Hi,r),s=un(fn,r);return b(hi.h3,{"data-orientation":n.orientation,"data-state":bn(s.open),"data-disabled":s.disabled?"":void 0,...i,ref:t})});pn.displayName=fn;var mn="AccordionTrigger",gn=t.forwardRef((e,t)=>{const{__scopeAccordion:r,...i}=e,n=on(Hi,r),s=un(mn,r),a=rn(mn,r),o=Qi(r);return b(Wi.ItemSlot,{scope:r,children:b(zi,{"aria-disabled":s.open&&!a.collapsible||void 0,"data-orientation":n.orientation,id:s.triggerId,...o,...i,ref:t})})});gn.displayName=mn;var vn="AccordionContent",yn=t.forwardRef((e,t)=>{const{__scopeAccordion:r,...i}=e,n=on(Hi,r),s=un(vn,r),a=Qi(r);return b(Gi,{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 bn(e){return e?"open":"closed"}yn.displayName=vn;var En=Zi,wn=hn,Sn=pn,Tn=gn,xn=yn;function An(t){var r=T(t,[]);return e.createElement(En,Object.assign({"data-slot":"accordion"},r))}function kn(t){var{className:r}=t,i=T(t,["className"]);return e.createElement(wn,Object.assign({"data-slot":"accordion-item",className:wt("border-b last:border-b-0",r)},i))}function Ln(t){var{className:r,children:i}=t,n=T(t,["className","children"]);return e.createElement(Sn,{className:"flex"},e.createElement(Tn,Object.assign({"data-slot":"accordion-trigger",className:wt("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(Lr,{className:"text-muted-foreground pointer-events-none size-4 shrink-0 translate-y-0.5 transition-transform duration-200"})))}function In(t){var{className:r,children:i}=t,n=T(t,["className","children"]);return e.createElement(xn,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:wt("pt-0 pb-4",r)},i))}const Rn=({title:e,content:r})=>t.createElement(An,{style:{borderRadius:"0.625rem"},type:"single",collapsible:!0,className:"bg-white px-4",defaultValue:"item"},t.createElement(kn,{value:"item"},t.createElement(Ln,{className:""},e),t.createElement(In,{className:"text-gray-700"},r))),Pn=({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($r,null)))),Cn=e=>{const{playerSettings:r,shortform:{description:i,productsInfo:n,logo:s,brand:a,title:o},player:l}=e;return t.createElement("div",{className:"w-full h-full bg-[#f4f4f4] overflow-scroll"},t.createElement(Pn,{logo:s}),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"},a?t.createElement("div",{className:"items-center flex gap-3"},a.thumbPath&&t.createElement("div",{className:"w-16 h-16 bg-white rounded-full border "},t.createElement("img",{src:a.thumbPath,alt:a.brandName,width:100,height:100,className:"object-contain w-full h-full rounded-full"})),t.createElement("div",null,t.createElement("p",null,a.brandName),t.createElement("p",{className:"text-lg font-semibold"},o))):t.createElement("p",{className:"text-xl font-semibold"},o),t.createElement(Br,null)),t.createElement("div",{className:"w-full pb-10 flex gap-4 justify-center"},t.createElement("div",{className:"flex gap-3"},l),t.createElement("div",{className:"flex flex-col gap-4 justify-end"},t.createElement(Vr,{rounded:!0}),t.createElement(Wr,{rounded:!0}),t.createElement(Yr,{rounded:!0})))),t.createElement("div",{className:"flex flex-col gap-4 max-w-[40%]"},i&&t.createElement(Rn,{title:"숏클립 안내",content:t.createElement("p",{className:"font-medium"},i)}),t.createElement(Rn,{title:"상품 목록",content:t.createElement(t.Fragment,null,t.createElement("div",{className:"max-h-[300px] overflow-y-auto font-medium"},n.map((e,r)=>t.createElement(t.Fragment,null,t.createElement(Gr,{product:e}),r!==n.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==n?void 0:n.length)},"상품 전체 보기"))}),r.comment&&t.createElement(Rn,{title:"댓글",content:t.createElement(jr,null)}))))};function Dn(e){return null!==e&&"object"==typeof e&&"constructor"in e&&e.constructor===Object}function _n(e,t){void 0===e&&(e={}),void 0===t&&(t={}),Object.keys(t).forEach(r=>{void 0===e[r]?e[r]=t[r]:Dn(t[r])&&Dn(e[r])&&Object.keys(t[r]).length>0&&_n(e[r],t[r])})}const On={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 Mn(){const e="undefined"!=typeof document?document:{};return _n(e,On),e}const Nn={document:On,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 Fn(){const e="undefined"!=typeof window?window:{};return _n(e,Nn),e}function $n(e,t){return void 0===t&&(t=0),setTimeout(e,t)}function Bn(){return Date.now()}function Un(e,t){void 0===t&&(t="x");const r=Fn();let i,n,s;const a=function(e){const t=Fn();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 zn(e){return"object"==typeof e&&null!==e&&e.constructor&&"Object"===Object.prototype.toString.call(e).slice(8,-1)}function Gn(e){return"undefined"!=typeof window&&void 0!==window.HTMLElement?e instanceof HTMLElement:e&&(1===e.nodeType||11===e.nodeType)}function jn(){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&&!Gn(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&&(zn(e[n])&&zn(i[n])?i[n].__swiper__?e[n]=i[n]:jn(e[n],i[n]):!zn(e[n])&&zn(i[n])?(e[n]={},i[n].__swiper__?e[n]=i[n]:jn(e[n],i[n])):e[n]=i[n])}}}return e}function Hn(e,t,r){e.style.setProperty(t,r)}function Vn(e){let{swiper:t,targetPosition:r,side:i}=e;const n=Fn(),s=-t.translate;let a,o=null;const l=t.params.speed;t.wrapperEl.style.scrollSnapType="none",n.cancelAnimationFrame(t.cssModeFrameID);const d=r>s?"next":"prev",c=(e,t)=>"next"===d&&e>=t||"prev"===d&&e<=t,u=()=>{a=(new Date).getTime(),null===o&&(o=a);const e=Math.max(Math.min((a-o)/l,1),0),d=.5-Math.cos(e*Math.PI)/2;let h=s+d*(r-s);if(c(h,r)&&(h=r),t.wrapperEl.scrollTo({[i]:h}),c(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 Wn(e){return e.querySelector(".swiper-slide-transform")||e.shadowRoot&&e.shadowRoot.querySelector(".swiper-slide-transform")||e}function Yn(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 Kn(e){try{return void console.warn(e)}catch(e){}}function qn(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 Xn(e,t){return Fn().getComputedStyle(e,null).getPropertyValue(t)}function Qn(e){let t,r=e;if(r){for(t=0;null!==(r=r.previousSibling);)1===r.nodeType&&(t+=1);return t}}function Zn(e,t,r){const i=Fn();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 Jn(e){return(Array.isArray(e)?e:[e]).filter(e=>!!e)}let es,ts,rs;function is(){return es||(es=function(){const e=Fn(),t=Mn();return{smoothScroll:t.documentElement&&t.documentElement.style&&"scrollBehavior"in t.documentElement.style,touch:!!("ontouchstart"in e||e.DocumentTouch&&t instanceof e.DocumentTouch)}}()),es}function ns(e){return void 0===e&&(e={}),ts||(ts=function(e){let{userAgent:t}=void 0===e?{}:e;const r=is(),i=Fn(),n=i.navigator.platform,s=t||i.navigator.userAgent,a={ios:!1,android:!1},o=i.screen.width,l=i.screen.height,d=s.match(/(Android);?[\s\/]+([\d.]+)?/);let c=s.match(/(iPad).*OS\s([\d_]+)/);const u=s.match(/(iPod)(.*OS\s([\d_]+))?/),h=!c&&s.match(/(iPhone\sOS|iOS)\s([\d_]+)/),f="Win32"===n;let p="MacIntel"===n;return!c&&p&&r.touch&&["1024x1366","1366x1024","834x1194","1194x834","834x1112","1112x834","768x1024","1024x768","820x1180","1180x820","810x1080","1080x810"].indexOf(`${o}x${l}`)>=0&&(c=s.match(/(Version)\/([\d.]+)/),c||(c=[0,1,"13_0_0"]),p=!1),d&&!f&&(a.os="android",a.android=!0),(c||h||u)&&(a.os="ios",a.ios=!0),a}(e)),ts}function ss(){return rs||(rs=function(){const e=Fn(),t=ns();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}}()),rs}var as={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 os=(e,t,r)=>{t&&!e.classList.contains(r)?e.classList.add(r):!t&&e.classList.contains(r)&&e.classList.remove(r)};const ls=(e,t,r)=>{t&&!e.classList.contains(r)?e.classList.add(r):!t&&e.classList.contains(r)&&e.classList.remove(r)};const ds=(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()}},cs=(e,t)=>{if(!e.slides[t])return;const r=e.slides[t].querySelector('[loading="lazy"]');r&&r.removeAttribute("loading")},us=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)&&cs(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)&&cs(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)&&cs(e,i)};var hs={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(Xn(i,"padding-left")||0,10)-parseInt(Xn(i,"padding-right")||0,10),r=r-parseInt(Xn(i,"padding-top")||0,10)-parseInt(Xn(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,d=l?e.virtual.slides.length:e.slides.length,c=Yn(n,`.${e.params.slideClass}, swiper-slide`),u=l?e.virtual.slides.length:c.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,c.forEach(e=>{a?e.style.marginLeft="":e.style.marginRight="",e.style.marginBottom="",e.style.marginTop=""}),r.centeredSlides&&r.cssMode&&(Hn(i,"--swiper-centered-offset-before",""),Hn(i,"--swiper-centered-offset-after",""));const T=r.grid&&r.grid.rows>1&&e.grid;let x;T?e.grid.initSlides(c):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,c[i]&&(n=c[i]),T&&e.grid.updateSlide(i,n,c),!c[i]||"none"!==Xn(n,"display")){if("auto"===r.slidesPerView){A&&(c[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()?Zn(n,"width"):Zn(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)),c[i]&&(c[i].style[e.getDirectionLabel("width")]=`${x}px`);c[i]&&(c[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");c.filter((e,t)=>!(r.cssMode&&!r.loop)||t!==c.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:c,snapGrid:h,slidesGrid:f,slidesSizesGrid:p}),r.centeredSlides&&r.cssMode&&!r.centeredSlidesBounds){Hn(i,"--swiper-centered-offset-before",-h[0]+"px"),Hn(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!==d&&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 d=l.swiperSlideOffset;r.cssMode&&r.centeredSlides&&(d-=i[0].swiperSlideOffset);const c=(a+(r.centeredSlides?t.minTranslate():0)-d)/(l.swiperSlideSize+o),u=(a-s[0]+(r.centeredSlides?t.minTranslate():0)-d)/(l.swiperSlideSize+o),h=-(a-d),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)),os(l,m,r.slideVisibleClass),os(l,p,r.slideFullyVisibleClass),l.progress=n?-c:c,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,d=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&&!d&&t.emit("reachEnd toEdge"),(l&&!s||d&&!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=>Yn(i,`.${r.slideClass}${e}, swiper-slide${e}`)[0];let l,d,c;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],c=t.filter(e=>e.column===n+1)[0],d=t.filter(e=>e.column===n-1)[0]):l=t[n];l&&(a||(c=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&&!c&&(c=t[0]),d=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===!d&&(d=t[t.length-1]))),t.forEach(e=>{ls(e,e===l,r.slideActiveClass),ls(e,e===c,r.slideNextClass),ls(e,e===d,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,d=e;const c=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===d&&(d=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,d);l=e+Math.floor((d-e)/n.slidesPerGroup)}if(l>=i.length&&(l=i.length-1),d===s&&!t.params.loop)return void(l!==o&&(t.snapIndex=l,t.emit("snapIndexChange")));if(d===s&&t.params.loop&&t.virtual&&t.params.virtual.enabled)return void(t.realIndex=c(d));const u=t.grid&&n.grid&&n.grid.rows>1;let h;if(t.virtual&&n.virtual.enabled&&n.loop)h=c(d);else if(u){const e=t.slides.filter(e=>e.column===d)[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[d]){const e=t.slides[d].getAttribute("data-swiper-slide-index");h=e?parseInt(e,10):d}else h=d;Object.assign(t,{previousSnapIndex:o,snapIndex:l,previousRealIndex:a,realIndex:h,previousIndex:s,activeIndex:d}),t.initialized&&us(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 fs={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=Un(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,d=0;r.isHorizontal()?l=i?-e:e:d=e,n.roundLengths&&(l=Math.floor(l),d=Math.floor(d)),r.previousTranslate=r.translate,r.translate=r.isHorizontal()?l:d,n.cssMode?s[r.isHorizontal()?"scrollLeft":"scrollTop"]=r.isHorizontal()?-l:-d:n.virtualTranslate||(r.isHorizontal()?l-=r.cssOverflowAdjustment():d-=r.cssOverflowAdjustment(),s.style.transform=`translate3d(${l}px, ${d}px, 0px)`);const c=r.maxTranslate()-r.minTranslate();o=0===c?0:(e-r.minTranslate())/c,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(),d=s.maxTranslate();let c;if(c=i&&e>l?l:i&&e<d?d:e,s.updateProgress(c),a.cssMode){const e=s.isHorizontal();if(0===t)o[e?"scrollLeft":"scrollTop"]=-c;else{if(!s.support.smoothScroll)return Vn({swiper:s,targetPosition:-c,side:e?"left":"top"}),!0;o.scrollTo({[e?"left":"top"]:-c,behavior:"smooth"})}return!0}return 0===t?(s.setTransition(0),s.setTranslate(c),r&&(s.emit("beforeTransitionStart",t,n),s.emit("transitionEnd"))):(s.setTransition(t),s.setTranslate(c),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 ps(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 ms={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(),ps({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),ps({swiper:r,runCallbacks:e,direction:t,step:"End"}))}};var gs={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:d,previousIndex:c,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<d.length;e+=1){const t=-Math.floor(100*v),r=Math.floor(100*d[e]),i=Math.floor(100*d[e+1]);void 0!==d[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!==(c||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 Vn({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,d=i.virtual&&s.virtual.enabled;if(s.loop){if(a&&!d&&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:d}=i;if(!l||i.destroyed)return i;void 0===e&&(e=i.params.speed);const c=i.virtual&&n.virtual.enabled;if(n.loop){if(d&&!c&&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(Yn(r,`${a}[data-swiper-slide-index="${n}"]`)[0]),$n(()=>{e.slideTo(s)})):e.slideTo(s):s>e.slides.length-i?(e.loopFix(),s=e.getSlideIndex(Yn(r,`${a}[data-swiper-slide-index="${n}"]`)[0]),$n(()=>{e.slideTo(s)})):e.slideTo(s)}else e.slideTo(s)}};var vs={loopCreate:function(e){const t=this,{params:r,slidesEl:i}=t;if(!r.loop||t.virtual&&t.params.virtual.enabled)return;const n=()=>{Yn(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,d=e=>{for(let i=0;i<e;i+=1){const e=t.isElement?qn("swiper-slide",[r.slideBlankClass]):qn("div",[r.slideClass,r.slideBlankClass]);t.slidesEl.append(e)}};if(o){if(r.loopAddBlankSlides){d(a-t.slides.length%a),t.recalcSlides(),t.updateSlides()}else Kn("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){d(r.grid.rows-t.slides.length%r.grid.rows),t.recalcSlides(),t.updateSlides()}else Kn("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:d,allowSlidePrev:c,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=c,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;d.length<m+v?Kn("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&&Kn("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(d.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(d.length/f.grid.rows):d.length,L=(y?d[s].column:s)+(p&&void 0===n?-m/2+.5:0);if(L<v){x=Math.max(v-L,g);for(let e=0;e<v-L;e+=1){const t=e-Math.floor(e/k)*k;if(y){const e=k-t-1;for(let t=d.length-1;t>=0;t-=1)d[t].column===e&&b.push(t)}else b.push(k-t-1)}}else if(L+m>k-v){A=Math.max(L-(k-2*v),g);for(let e=0;e<A;e+=1){const t=e-Math.floor(e/k)*k;y?d.forEach((e,r)=>{e.column===t&&E.push(r)}):E.push(t)}}if(l.__preventObserver__=!0,requestAnimationFrame(()=>{l.__preventObserver__=!1}),T&&b.forEach(e=>{d[e].swiperLoopMoveDOM=!0,h.prepend(d[e]),d[e].swiperLoopMoveDOM=!1}),S&&E.forEach(e=>{d[e].swiperLoopMoveDOM=!0,h.append(d[e]),d[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=c,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 ys(e,t,r){const i=Fn(),{params:n}=e,s=n.edgeSwipeDetection,a=n.edgeSwipeThreshold;return!s||!(r<=a||r>=i.innerWidth-a)||"prevent"===s&&(t.preventDefault(),!0)}function bs(e){const t=this,r=Mn();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 ys(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 d=!!s.noSwipingClass&&""!==s.noSwipingClass,c=i.composedPath?i.composedPath():i.path;d&&i.target&&i.target.shadowRoot&&c&&(l=c[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===Mn()||r===Fn())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(!ys(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=Bn(),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 Es(e){const t=Mn(),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,d=e;if(d.originalEvent&&(d=d.originalEvent),"pointermove"===d.type){if(null!==i.touchId)return;if(d.pointerId!==i.pointerId)return}if("touchmove"===d.type){if(l=[...d.changedTouches].filter(e=>e.identifier===i.touchId)[0],!l||l.identifier!==i.touchId)return}else l=d;if(!i.isTouched)return void(i.startMoving&&i.isScrolling&&r.emit("touchMoveOpposite",d));const c=l.pageX,u=l.pageY;if(d.preventedByNestedSwiper)return s.startX=c,void(s.startY=u);if(!r.allowTouchMove)return d.target.matches(i.focusableElements)||(r.allowClick=!1),void(i.isTouched&&(Object.assign(s,{startX:c,startY:u,currentX:c,currentY:u}),i.touchStartTime=Bn()));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(c<s.startX&&r.translate<=r.maxTranslate()||c>s.startX&&r.translate>=r.minTranslate())return;if(t.activeElement&&t.activeElement.matches(i.focusableElements)&&t.activeElement!==d.target&&"mouse"!==d.pointerType&&t.activeElement.blur(),t.activeElement&&d.target===t.activeElement&&d.target.matches(i.focusableElements))return i.isMoved=!0,void(r.allowClick=!1);i.allowTouchCallbacks&&r.emit("touchMove",d),s.previousX=s.currentX,s.previousY=s.currentY,s.currentX=c,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",d),void 0===i.startMoving&&(s.currentX===s.startX&&s.currentY===s.startY||(i.startMoving=!0)),i.isScrolling||"touchmove"===d.type&&i.preventTouchMoveFromPointerMove)return void(i.isTouched=!1);if(!i.startMoving)return;r.allowClick=!1,!n.cssMode&&d.cancelable&&d.preventDefault(),n.touchMoveStopPropagation&&!n.nested&&d.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",d)}if((new Date).getTime(),i.isMoved&&i.allowThresholdMove&&g!==r.touchesDirection&&v&&y&&Math.abs(p)>=1)return Object.assign(s,{startX:c,startY:u,currentX:c,currentY:u,startTranslate:i.currentTranslate}),i.loopSwapReset=!0,void(i.startTranslate=i.currentTranslate);r.emit("sliderMove",d),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&&(d.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 ws(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:d}=t;if(!d)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 c=Bn(),u=c-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&&c-r.lastClickTime<300&&t.emit("doubleTap doubleClick",n)}if(r.lastClickTime=Bn(),$n(()=>{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 Ss(){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 Ts(e){const t=this;t.enabled&&(t.allowClick||(t.params.preventClicks&&e.preventDefault(),t.params.preventClicksPropagation&&t.animating&&(e.stopPropagation(),e.stopImmediatePropagation())))}function xs(){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 As(e){const t=this;ds(t,e.target),t.params.cssMode||"auto"!==t.params.slidesPerView&&!t.params.autoHeight||t.update()}function ks(){const e=this;e.documentTouchHandlerProceeded||(e.documentTouchHandlerProceeded=!0,e.params.touchReleaseOnEdges&&(e.el.style.touchAction="auto"))}const Ls=(e,t)=>{const r=Mn(),{params:i,el:n,wrapperEl:s,device:a}=e,o=!!i.nested,l="on"===t?"addEventListener":"removeEventListener",d=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[d](a.ios||a.android?"resize orientationchange observerUpdate":"resize observerUpdate",Ss,!0):e[d]("observerUpdate",Ss,!0),n[l]("load",e.onLoad,{capture:!0}))};const Is=(e,t)=>e.grid&&t.grid&&t.grid.rows>1;var Rs={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=Is(e,i),d=Is(e,o),c=e.params.grabCursor,u=o.grabCursor,h=i.enabled;l&&!d?(n.classList.remove(`${i.containerModifierClass}grid`,`${i.containerModifierClass}grid-column`),e.emitContainerClasses()):!l&&d&&(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()),c&&!u?e.unsetGrabCursor():!c&&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(),jn(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=Fn(),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 Ps={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 Cs(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}),jn(t,r)):jn(t,r)):jn(t,r)}}const Ds={eventsEmitter:as,update:hs,translate:fs,transition:ms,slide:gs,loop:vs,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=bs.bind(e),e.onTouchMove=Es.bind(e),e.onTouchEnd=ws.bind(e),e.onDocumentTouchStart=ks.bind(e),t.cssMode&&(e.onScroll=xs.bind(e)),e.onClick=Ts.bind(e),e.onLoad=As.bind(e),Ls(e,"on")},detachEvents:function(){Ls(this,"off")}},breakpoints:Rs,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())}}},_s={};let Os=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=jn({},r),t&&!r.el&&(r.el=t);const a=Mn();if(r.el&&"string"==typeof r.el&&a.querySelectorAll(r.el).length>1){const t=[];return a.querySelectorAll(r.el).forEach(i=>{const n=jn({},r,{el:i});t.push(new e(n))}),t}const o=this;o.__swiper__=!0,o.support=is(),o.device=ns({userAgent:r.userAgent}),o.browser=ss(),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:Cs(r,l),on:o.on.bind(o),once:o.once.bind(o),off:o.off.bind(o),emit:o.emit.bind(o)})});const d=jn({},Ps,l);return o.params=jn({},d,_s,r),o.originalParams=jn({},o.params),o.passedParams=jn({},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=Qn(Yn(t,`.${r.slideClass}, swiper-slide`)[0]);return Qn(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=Yn(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&&ds(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 Yn(r,i())[0]})();return!n&&t.params.createElements&&(n=qn("div",t.params.wrapperClass),r.append(n),Yn(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"===Xn(r,"direction"),rtlTranslate:"horizontal"===t.params.direction&&("rtl"===r.dir.toLowerCase()||"rtl"===Xn(r,"direction")),wrongRTL:"-webkit-box"===Xn(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?ds(t,e):e.addEventListener("load",e=>{ds(t,e.target)})}),us(t),t.initialized=!0,us(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){jn(_s,e)}static get extendedDefaults(){return _s}static get defaults(){return Ps}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(Ds).forEach(e=>{Object.keys(Ds[e]).forEach(t=>{Os.prototype[t]=Ds[e][t]})}),Os.use([function(e){let{swiper:t,on:r,emit:i}=e;const n=Fn();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=Fn(),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 Ms=["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 Ns(e){return"object"==typeof e&&null!==e&&e.constructor&&"Object"===Object.prototype.toString.call(e).slice(8,-1)&&!e.__swiper__}function Fs(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]:Ns(t[r])&&Ns(e[r])&&Object.keys(t[r]).length>0?t[r].__swiper__?e[r]=t[r]:Fs(e[r],t[r]):e[r]=t[r]})}function $s(e){return void 0===e&&(e={}),e.navigation&&void 0===e.navigation.nextEl&&void 0===e.navigation.prevEl}function Bs(e){return void 0===e&&(e={}),e.pagination&&void 0===e.pagination.el}function Us(e){return void 0===e&&(e={}),e.scrollbar&&void 0===e.scrollbar.el}function zs(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 Gs(e){return void 0===e&&(e=""),e?e.includes("swiper-wrapper")?e:`swiper-wrapper ${e}`:"swiper-wrapper"}function js(){return js=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},js.apply(this,arguments)}function Hs(e){return e.type&&e.type.displayName&&e.type.displayName.includes("SwiperSlide")}function Vs(e){const r=[];return t.Children.toArray(e).forEach(e=>{Hs(e)?r.push(e):e.props&&e.props.children&&Vs(e.props.children).forEach(e=>r.push(e))}),r}function Ws(e){const r=[],i={"container-start":[],"container-end":[],"wrapper-start":[],"wrapper-end":[]};return t.Children.toArray(e).forEach(e=>{if(Hs(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=Vs(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 Ys(e,t){return"undefined"==typeof window?i(e,t):o(e,t)}const Ks=n(null),qs=n(null),Xs=s(function(e,n){let{className:s,tag:o="div",wrapperTag:l="div",children:d,onSwiper:c,...u}=void 0===e?{}:e,h=!1;const[f,p]=a("swiper"),[m,g]=a(null),[v,y]=a(!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),L=r(null),{params:I,passedParams:R,rest:P,events:C}=function(e,t){void 0===e&&(e={}),void 0===t&&(t=!0);const r={on:{}},i={},n={};Fs(r,Ps),r._emitClasses=!0,r.init=!1;const s={},a=Ms.map(e=>e.replace(/_/,"")),o=Object.assign({},e);return Object.keys(o).forEach(o=>{void 0!==e[o]&&(a.indexOf(o)>=0?Ns(e[o])?(r[o]={},n[o]={},Fs(r[o],e[o]),Fs(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:_}=Ws(d),O=()=>{y(!v)};Object.assign(I.on,{_containerClasses(e,t){p(t)}});const M=()=>{Object.assign(I.on,C),h=!0;const e={...I};if(delete e.wrapperClass,w.current=new Os(e),w.current.virtual&&w.current.params.virtual.enabled){w.current.virtual.slides=D;const e={cache:!1,slides:D,renderExternal:g,renderExternalUpdate:!1};Fs(w.current.params.virtual,e),Fs(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)}),Ys(()=>{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;$s(t)&&i&&n&&(o.params.navigation.nextEl=i,o.originalParams.navigation.nextEl=i,o.params.navigation.prevEl=n,o.originalParams.navigation.prevEl=n),Bs(t)&&s&&(o.params.pagination.el=s,o.originalParams.pagination.el=s),Us(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:L.current,swiper:w.current},I),c&&!w.current.destroyed&&c(w.current),()=>{w.current&&!w.current.destroyed&&w.current.destroy(!0,!1)}},[]),Ys(()=>{!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 Ms.filter(e=>"_"===e[0]).map(e=>e.replace(/_/,"")).forEach(r=>{if(r in e&&r in t)if(Ns(e[r])&&Ns(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 d=n.filter(e=>"children"!==e&&"direction"!==e&&"wrapperClass"!==e),{params:c,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&&c.thumbs&&(!c.thumbs.swiper||c.thumbs.swiper.destroyed)&&(g=!0),n.includes("controller")&&i.controller&&i.controller.control&&c.controller&&!c.controller.control&&(v=!0),n.includes("pagination")&&i.pagination&&(i.pagination.el||l)&&(c.pagination||!1===c.pagination)&&u&&!u.el&&(y=!0),n.includes("scrollbar")&&i.scrollbar&&(i.scrollbar.el||o)&&(c.scrollbar||!1===c.scrollbar)&&f&&!f.el&&(b=!0),n.includes("navigation")&&i.navigation&&(i.navigation.prevEl||a)&&(i.navigation.nextEl||s)&&(c.navigation||!1===c.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()),c[e].prevEl=void 0,c[e].nextEl=void 0,t[e].prevEl=void 0,t[e].nextEl=void 0):(t.isElement&&t[e].el.remove(),c[e].el=void 0,t[e].el=void 0))};n.includes("loop")&&t.isElement&&(c.loop&&!i.loop?w=!0:!c.loop&&i.loop?S=!0:T=!0),d.forEach(e=>{if(Ns(c[e])&&Ns(i[e]))Object.assign(c[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?c[e]=i[e]:!1===t&&x(e)}}),d.includes("controller")&&!v&&t.controller&&t.controller.control&&c.controller&&c.controller.control&&(t.controller.control=c.controller.control),n.includes("children")&&r&&p&&c.virtual.enabled?(p.slides=r,p.update(!0)):n.includes("virtual")&&p&&c.virtual.enabled&&(r&&(p.slides=r),p.update(!0)),n.includes("children")&&r&&c.loop&&(T=!0),g&&m.init()&&m.update(!0);v&&(t.controller.control=c.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&&(c.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&&(c.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&&(c.navigation.nextEl=s),a&&(c.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:L.current,paginationEl:k.current}),()=>{C&&w.current&&Object.keys(C).forEach(e=>{w.current.off(e,C[e])})}}),Ys(()=>{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,js({ref:E,className:zs(`${f}${s?` ${s}`:""}`)},P),t.createElement(qs.Provider,{value:w.current},_["container-start"],t.createElement(l,{className:Gs(I.wrapperClass)},_["wrapper-start"],I.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,d=e.params.loop?2*r.length:r.length,c=[];for(let e=l;e<d;e+=1)e>=a&&e<=o&&c.push(r[n(e)]);return c.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"]),$s(I)&&t.createElement(t.Fragment,null,t.createElement("div",{ref:A,className:"swiper-button-prev"}),t.createElement("div",{ref:x,className:"swiper-button-next"})),Us(I)&&t.createElement("div",{ref:L,className:"swiper-scrollbar"}),Bs(I)&&t.createElement("div",{ref:k,className:"swiper-pagination"}),_["container-end"]))});Xs.displayName="Swiper";const Qs=s(function(e,i){let{tag:n="div",children:s,className:o="",swiper:l,zoom:d,lazy:c,virtualIndex:u,swiperSlideIndex:h,...f}=void 0===e?{}:e;const p=r(null),[m,g]=a("swiper-slide"),[v,y]=a(!1);function b(e,t,r){t===p.current&&g(r)}Ys(()=>{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")}}),Ys(()=>{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 s?s(E):s;return t.createElement(n,js({ref:p,className:zs(`${m}${o?` ${o}`:""}`),"data-swiper-slide-index":u,onLoad:()=>{y(!0)}},f),d&&t.createElement(Ks.Provider,{value:E},t.createElement("div",{className:"swiper-zoom-container","data-swiper-zoom":"number"==typeof d?d:void 0},w(),c&&!v&&t.createElement("div",{className:"swiper-lazy-preloader"}))),!d&&t.createElement(Ks.Provider,{value:E},w(),c&&!v&&t.createElement("div",{className:"swiper-lazy-preloader"})))});function Zs(e){let{swiper:t,extendParams:r,on:i,emit:n}=e;const s=Fn();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=Bn();const d=[];function c(){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&&Bn()-l<t.params.mousewheel.thresholdTime)&&(e.delta>=6&&Bn()-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 c=l&&l.contains(r.target);if(!t.mouseEntered&&!c&&!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:Bn(),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 c=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(),(!c&&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,d.length>=15&&d.shift();const r=d.length?d[d.length-1]:void 0,i=d[0];if(d.push(e),r&&(e.delta>r.delta||e.direction!==r.direction))d.splice(0);else if(d.length>=15&&e.time-i.time<500&&i.delta-e.delta>=1&&e.delta<=6){const r=u>0?.8:.2;o=e,d.splice(0),a=$n(()=>{!t.destroyed&&t.params&&t.slideToClosest(t.params.speed,!0,void 0,r)},0)}a||(a=$n(()=>{if(t.destroyed||!t.params)return;o=e,d.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:Bn(),delta:Math.abs(u),direction:Math.sign(u),raw:e};d.length>=2&&d.shift();const i=d.length?d[d.length-1]:void 0;if(d.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",c),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 Js(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=Jn(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 d(e){e.preventDefault(),(!t.isEnd||t.params.loop||t.params.rewind)&&(t.slideNext(),n("navigationNext"))}function c(){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=Yn(e.el,`.${i[n]}`)[0];s||(s=qn("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=Jn(r),i=Jn(i);const n=(r,i)=>{r&&r.addEventListener("click","next"===i?d: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=Jn(e),r=Jn(r);const i=(e,r)=>{e.removeEventListener("click","next"===r?d: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():(c(),o())}),i("toEdge fromEdge lock unlock",()=>{o()}),i("destroy",()=>{u()}),i("enable disable",()=>{let{nextEl:e,prevEl:r}=t.navigation;e=Jn(e),r=Jn(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=Jn(i),s=Jn(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(" ")),c(),o()},disable:h,update:o,init:c,destroy:u})}function ea(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,d,c,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?d=!0:d&&(v=l,d=!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,d=()=>{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(()=>{d()},n)):requestAnimationFrame(()=>{d()}),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=Mn();"hidden"===e.visibilityState&&(p=!0,x(!0)),"visible"===e.visibilityState&&A()},L=e=>{"mouse"===e.pointerType&&(p=!0,m=!0,i.animating||i.autoplay.paused||x(!0))},I=e=>{"mouse"===e.pointerType&&(m=!1,i.autoplay.paused&&A())};s("init",()=>{i.params.autoplay.enabled&&(i.params.autoplay.pauseOnMouseEnter&&(i.el.addEventListener("pointerenter",L),i.el.addEventListener("pointerleave",I)),Mn().addEventListener("visibilitychange",k),S())}),s("destroy",()=>{i.el&&"string"!=typeof i.el&&(i.el.removeEventListener("pointerenter",L),i.el.removeEventListener("pointerleave",I)),Mn().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():(c=!0,u=!1,p=!1,h=setTimeout(()=>{p=!0,u=!0,x(!0)},200)))}),s("touchEnd",()=>{if(!i.destroyed&&i.autoplay.running&&c){if(clearTimeout(h),clearTimeout(t),i.params.autoplay.disableOnInteraction)return u=!1,void(c=!1);u&&i.params.cssMode&&A(),u=!1,c=!1}}),s("slideChange",()=>{!i.destroyed&&i.autoplay.running&&(f=!0)}),Object.assign(i.autoplay,{start:S,stop:T,pause:x,resume:A})}function ta(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,d=l(),{rows:c,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*c)),i=e-c*o*r,s=0===r?o:Math.min(Math.ceil((h-r*c*o)/c),o);m=Math.floor(i/s),p=i-m*s+r*o,f=p+m*t/c,n.style.order=f}else"column"===u?(p=Math.floor(e/c),m=e-p*c,(p>i||p===i&&m===c-1)&&(m+=1,m>=c&&(m=0,p+=1))):(m=Math.floor(e/r),p=e-m*r);n.row=m,n.column=p,n.style.height=`calc((100% - ${(c-1)*d}px) / ${c})`,n.style[s.getDirectionLabel("margin-top")]=0!==m?d&&`${d}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 ra(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 ia(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 na(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 d=[];for(let t=o-1;t>=e;t-=1){const e=r.slides[t];e.remove(),d.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<d.length;e+=1)s.append(d[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 sa(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 aa(){const e=this,t=[];for(let r=0;r<e.slides.length;r+=1)t.push(r);e.removeSlide(t)}function oa(e){let{swiper:t}=e;Object.assign(t,{appendSlide:ra.bind(t),prependSlide:ia.bind(t),addSlide:na.bind(t),removeSlide:sa.bind(t),removeAllSlides:aa.bind(t)})}function la(e,t){const r=Wn(t);return r!==t&&(r.style.backfaceVisibility="hidden",r.style["-webkit-backface-visibility"]="hidden"),r}function da(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 ca(e,t,r){const i=`swiper-slide-shadow swiper-slide-shadow-${e}`,n=Wn(t);let s=n.querySelector(`.${i.split(" ").join(".")}`);return s||(s=qn("div",i.split(" ")),n.append(s)),s}function ua(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:d}=e;let c;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(!d||!d().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||(c=!0),requestAnimationFrame(()=>{c&&r.slides&&r.slides.length&&(n(),c=!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 d=e[l],c=d.progress,u=Math.min(Math.max(c,-4),4);let h=d.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=d.querySelector(".swiper-slide-shadow");e||(e=ca("cards",d)),e&&(e.style.opacity=Math.min(Math.max((Math.abs(u)-.5)/.5,0),1))}d.style.zIndex=-Math.abs(Math.round(c))+e.length;la(0,d).style.transform=T}},setTransition:e=>{const r=t.slides.map(e=>Wn(e));r.forEach(t=>{t.style.transitionDuration=`${e}ms`,t.querySelectorAll(".swiper-slide-shadow").forEach(t=>{t.style.transitionDuration=`${e}ms`})}),da({swiper:t,duration:e,transformElements:r})},perspective:()=>!0,overwriteParams:()=>({watchSlidesProgress:!0,virtualTranslate:!t.params.cssMode})})}Qs.displayName="SwiperSlide";const ha=({product:e})=>{const[r,i]=a(!1);return t.createElement("a",{href:e.linkPath,target:"_blank"},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&&!r?t.createElement(zr,{product:e,onError:()=>i(!0)}):t.createElement(Ur,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"},xt(e.sellingPrice),"원")))))},fa=({products:e})=>{const i=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=i.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(Ir,{size:32,strokeWidth:1})),t.createElement("div",{className:"w-full px-10"},t.createElement(Xs,{modules:[Js],onSwiper:e=>{i.current=e},slidesPerView:1,breakpoints:{480:{slidesPerView:2},768:{slidesPerView:3}},navigation:{prevEl:".slide__prev",nextEl:".slide__next"},spaceBetween:0},e.map(e=>t.createElement(Qs,{key:e.productId},t.createElement("div",{className:"h-full px-3 md:px-4 lg:px-5"},t.createElement(ha,{product:e})))))),e.length>3&&t.createElement("button",{"aria-label":"next",onClick:()=>{var e;null===(e=i.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(Rr,{size:32,strokeWidth:1})))},pa=e=>{const{player:r,shortform:i}=e;return t.createElement("div",{className:"flex h-full w-full gap-5 bg-white"},t.createElement("div",{className:"h-full aspect-[9/16] shrink-0"},r),t.createElement("div",{className:"flex h-full w-full min-w-0 max-w-[800px] items-center overflow-hidden text-sm"},t.createElement(fa,{products:i.productsInfo})))},ma=({products:e})=>{const n=r(null),s=r(null),[o,l]=a(4);return i(()=>{const e=s.current;if(!e)return;const t=()=>{const t=e.clientHeight;if(!t)return;const r=Math.max(1,Math.floor((t+12)/112));l(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 items-center flex-col h-full"},e.length>o&&t.createElement(Pr,{size:50,strokeWidth:1,className:"cursor-pointer slide__prev text-zinc-500"}),t.createElement("div",{ref:s,className:"max-w-full h-[80%] w-full"},t.createElement(Xs,{modules:[Zs,Js],mousewheel:!0,onSwiper:e=>{n.current=e},spaceBetween:12,className:"max-w-full h-full",slidesPerView:o,direction:"vertical",navigation:{prevEl:".slide__prev",nextEl:".slide__next"}},e.map(e=>t.createElement(Qs,{key:e.productId},t.createElement("div",{className:"h-full items-center flex"},t.createElement(Gr,{product:e})))))),e.length>o&&t.createElement(Lr,{size:50,strokeWidth:1,className:"cursor-pointer slide__next text-zinc-500"}))},ga=e=>{const{playerSettings:r,shortform:{productsInfo:i},player:n}=e;return t.createElement("div",{className:"flex h-full w-full gap-5"},t.createElement("div",{className:" h-full "},n),t.createElement("div",{className:"max-w-[800px] overflow-hidden"},t.createElement(ma,{products:i})))},va=({products:e})=>{const i=r(null),n=e.length>6;return t.createElement("div",{className:"relative flex h-full w-full max-w-[830px] items-center text-sm"},n&&t.createElement("button",{"aria-label":"prev",onClick:()=>{var e;null===(e=i.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(Ir,{size:50,strokeWidth:1})),t.createElement("div",{className:"w-full px-14"},t.createElement(Xs,{onSwiper:e=>{i.current=e},slidesPerView:3,spaceBetween:20,modules:[ta],grid:{rows:2,fill:"row"}},e.map(e=>t.createElement(Qs,{key:e.productId},t.createElement(ha,{product:e}))))),n&&t.createElement("button",{"aria-label":"next",onClick:()=>{var e;null===(e=i.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(Rr,{size:50,strokeWidth:1})))},ya=e=>{const{player:r,shortform:{productsInfo:i}}=e;return t.createElement("div",{className:"flex gap-4 w-full h-full min-w-[768px]"},t.createElement("div",{className:"flex-1 w-full"},t.createElement("div",{className:"h-full aspect-[9/16]"},r)),t.createElement("div",{className:"flex-[2] w-full h-full overflow-hidden"},t.createElement(va,{products:i})))},ba="cursor-pointer text-zinc-500",Ea=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(Pr,{size:44,strokeWidth:1,className:ba,onClick:()=>{var e;null===(e=a.current)||void 0===e||e.swiper.slidePrev()}}),t.createElement(Lr,{size:44,strokeWidth:1,className:ba,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(Xs,{modules:[Zs,oa],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(Qs,{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(L,{file:Tt(n.media.objectId)})),t.createElement("img",{src:Rt(e.thumbPath),alt:e.title,className:"rounded-xl w-full h-full bg-black "+(e.media.width>e.media.height?"object-contain":"object-cover")})))))))};var wa;!function(e){e.latest="",e.views="pageView",e.likes="like"}(wa||(wa={}));let Sa=0;const Ta=e=>x(void 0,void 0,void 0,function*(){const{PLAYER_BACK_BASE_URL:t}=gt(),{contentId:r,uuid:i,type:n,userId:s}=e;try{if(3===Sa)return;const e=`${t}/statistics/play`,a=Object.assign({contentId:r,uuid:i,type:n,date:At(),userId:+s,playtime:0,isLive:!1},"shorts"===n&&{isFinished:!1,playedOver5Sec:!1});yield fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})}catch(e){console.error(`Error in statisticsApi.join - contentId: ${r}`),Pt(e),Sa++}}),xa=e=>{const{PLAYER_BACK_BASE_URL:t}=gt(),{contentId:r,uuid:i,type:n,isFinished:s,playtime:a,userId:o}=e,l=Object.assign({contentId:r,uuid:i,playtime:a,type:n,date:At(),userId:+o,isLive:!1},"shorts"===n&&{isFinished:s,playedOver5Sec:Number(a)>5});fetch(`${t}/statistics/play`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l),keepalive:!0})},Aa=e=>x(void 0,void 0,void 0,function*(){const{PLAYER_BACK_BASE_URL:t}=gt(),{contentProductId:r}=e;try{yield fetch(`${t}/statistics/products/${r}/clicks`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Object.assign({date:At()},e))})}catch(e){console.error(`Error in statisticsApi.productClick - contentProductId: ${r}`),Pt(e)}}),ka=e=>x(void 0,void 0,void 0,function*(){const{STATISTICS_BASE_URL:t}=gt();try{return(yield(yield fetch(`${t}/${e}/likes`)).json()).result||0}catch(t){return console.error(`Error in statisticsApi.getLike - contentId: ${e}`),Pt(t),0}}),La=e=>x(void 0,void 0,void 0,function*(){const{PLAYER_BACK_BASE_URL:t}=gt();try{yield fetch(`${t}/statistics/like`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({contentId:e,isLive:!1,isFirst:!1})})}catch(t){console.error(`Error in statisticsApi.getLike - contentId: ${e}`),Pt(t)}}),Ia=e=>x(void 0,[e],void 0,function*({collectionId:e,nextKey:t,size:r=5}){const{PLAYER_BACK_BASE_URL:i}=gt();try{const n=new URLSearchParams;-1!==r&&n.set("size",String(r)),t&&n.set("nextKey",t);const s=yield fetch(`${i}/commerce/collection/${e}?${n.toString()}`);return s.ok?yield s.json():null}catch(e){return Pt(e),null}}),Ra=(e,...t)=>x(void 0,[e,...t],void 0,function*(e,t=!1){const{API_BASE_URL:r,PLAYER_BACK_BASE_URL:i}=gt();if(t)try{const t=(yield(yield fetch(`${r}/shorts/player/${e}`)).json()).result;if(!t.media)return null;t.file=`${r}/direct/${t.media.objectId}`;const{player:{viewPlayer:{width:i,height:n}}}=t;return Object.assign(Object.assign(Object.assign(Object.assign({layout:t.player.layout},t.player.shoppingPlayer),{aspectRatio:Ct(i,n)}),t),{uuid:kt()})}catch(e){return Pt(e),null}try{const t=yield fetch(`${i}/commerce/short-form/${e}`),r=yield t.json();return r.shortsId?r:null}catch(e){return Pt(e),null}}),Pa=(e,t,r,i,n)=>x(void 0,void 0,void 0,function*(){const{API_BASE_URL:s}=gt();try{const a=yield fetch(`${s}/live/${e}/list?size=${r||6}&status=${t}&includeMainLive=${i}${n&&wa[n]?`&sortBy=${wa[n]}`:""}`);if(!a.ok)return console.error("Error in getLiveWidgetContents "),null;const o=(yield a.json()).result;if(o.content){const{mainLive:e,content:t}=o;return[...e?[e]:[],...t]}return o}catch(e){return console.error("Error in getLiveWidgetContents: ",e),null}}),Ca=e=>{let t;const r=new Set,i=(e,i)=>{const n="function"==typeof e?e(t):e;if(!Object.is(n,t)){const e=t;t=(null!=i?i:"object"!=typeof n||null===n)?n:Object.assign({},t,n),r.forEach(r=>r(t,e))}},n=()=>t,s={setState:i,getState:n,getInitialState:()=>a,subscribe:e=>(r.add(e),()=>r.delete(e))},a=t=e(i,n,s);return s},Da=e=>e?Ca(e):Ca,_a=e=>e;function Oa(e,r=_a){const i=t.useSyncExternalStore(e.subscribe,t.useCallback(()=>r(e.getState()),[e,r]),t.useCallback(()=>r(e.getInitialState()),[e,r]));return t.useDebugValue(i),i}const Ma=e=>{const t=Da(e),r=e=>Oa(t,e);return Object.assign(r,t),r},Na=e=>e?Ma(e):Ma,Fa=Na(e=>({priceText:"",isPreview:!1,memberOnly:!1,isMemberLoggedIn:!1,setPriceText:t=>e({priceText:t}),setIsPreview:t=>e({isPreview:t}),setMemberOnly:t=>e({memberOnly:t}),setIsMemberLoggedIn:t=>e({isMemberLoggedIn:t})})),$a=()=>t.createElement("div",{className:"inline-block absolute pointer-events-none top-0 z-10 animate-float w-[24px] h-[24px]"},t.createElement(Dr,{className:"fill-red-500 text-transparent w-[24px] h-[24px]"})),Ba=({shortsId:e})=>{const{isPreview:r}=Fa(),[n,s]=a(r?123:0),[o,l]=a([]);i(()=>{r||x(void 0,void 0,void 0,function*(){try{const t=yield ka(e);s(t)}catch(e){return console.error(`Error in statistics getLikeInLive: ${e.toString()}`),0}})},[r,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();l(t=>[...t,e]),setTimeout(()=>{l(t=>t.filter(t=>t!==e))},2e3)})(),s(e=>e+1),r||(yield x(void 0,void 0,void 0,function*(){yield La(e)}))}),className:"z-[5] cursor-pointer"},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"}))),o.map(e=>t.createElement($a,{key:e})),t.createElement("span",{className:"break-keep text-[10px]"},xt(n)))};var Ua,za,Ga={},ja={exports:{}},Ha=ja.exports;function Va(){return Ua||(Ua=1,e=ja,t=ja.exports,function(r,i){var n="function",s="undefined",a="object",o="string",l="major",d="model",c="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",L="Firefox",I="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,d,c,u=0;u<t.length&&!d;){var h=t[u],f=t[u+1];for(r=s=0;r<h.length&&!d&&h[r];)if(d=h[r++].exec(e))for(o=0;o<f.length;o++)c=d[++s],typeof(l=f[o])===a&&l.length>0?2===l.length?typeof l[1]==n?this[l[0]]=l[1].call(this,c):this[l[0]]=l[1]:3===l.length?typeof l[1]!==n||l[1].exec&&l[1].test?this[l[0]]=c?c.replace(l[1],l[2]):i:this[l[0]]=c?l[1].call(this,c,l[2]):i:4===l.length&&(this[l[0]]=c?l[3].call(this,c.replace(l[1],l[2])):i):this[l]=c||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,[c,"Chrome"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[f,[c,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[c,f],[/opios[\/ ]+([\w\.]+)/i],[f,[c,_+" Mini"]],[/\bop(?:rg)?x\/([\w\.]+)/i],[f,[c,_+" GX"]],[/\bopr\/([\w\.]+)/i],[f,[c,_]],[/\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[\/ ]?([\w\.]+)/i],[f,[c,"Baidu"]],[/\b(?:mxbrowser|mxios|myie2)\/?([-\w\.]*)\b/i],[f,[c,"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],[c,f],[/quark(?:pc)?\/([-\w\.]+)/i],[f,[c,"Quark"]],[/\bddg\/([\w\.]+)/i],[f,[c,"DuckDuckGo"]],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[f,[c,"UC"+A]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i,/micromessenger\/([\w\.]+)/i],[f,[c,"WeChat"]],[/konqueror\/([\w\.]+)/i],[f,[c,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[f,[c,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[f,[c,"Yandex"]],[/slbrowser\/([\w\.]+)/i],[f,[c,"Smart Lenovo "+A]],[/(avast|avg)\/([\w\.]+)/i],[[c,/(.+)/,"$1 Secure "+A],f],[/\bfocus\/([\w\.]+)/i],[f,[c,L+" Focus"]],[/\bopt\/([\w\.]+)/i],[f,[c,_+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[f,[c,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[f,[c,"Dolphin"]],[/coast\/([\w\.]+)/i],[f,[c,_+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[f,[c,"MIUI"+G]],[/fxios\/([\w\.-]+)/i],[f,[c,L]],[/\bqihoobrowser\/?([\w\.]*)/i],[f,[c,"360"]],[/\b(qq)\/([\w\.]+)/i],[[c,/(.+)/,"$1Browser"],f],[/(oculus|sailfish|huawei|vivo|pico)browser\/([\w\.]+)/i],[[c,/(.+)/,"$1"+G],f],[/samsungbrowser\/([\w\.]+)/i],[f,[c,O+" Internet"]],[/metasr[\/ ]?([\d\.]+)/i],[f,[c,"Sogou Explorer"]],[/(sogou)mo\w+\/([\d\.]+)/i],[[c,"Sogou Mobile"],f],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|2345(?=browser|chrome|explorer))\w*[\/ ]?v?([\w\.]+)/i],[c,f],[/(lbbrowser|rekonq)/i,/\[(linkedin)app\]/i],[c],[/ome\/([\w\.]+) \w* ?(iron) saf/i,/ome\/([\w\.]+).+qihu (360)[es]e/i],[f,c],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[c,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],[c,f],[/\bgsa\/([\w\.]+) .*safari\//i],[f,[c,"GSA"]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[f,[c,"TikTok"]],[/headlesschrome(?:\/([\w\.]+)| )/i],[f,[c,k+" Headless"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[c,k+" WebView"],f],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[f,[c,"Android "+A]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[c,f],[/version\/([\w\.\,]+) .*mobile\/\w+ (safari)/i],[f,[c,"Mobile Safari"]],[/version\/([\w(\.|\,)]+) .*(mobile ?safari|safari)/i],[f,c],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[c,[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],[c,f],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[c,"Netscape"],f],[/(wolvic|librewolf)\/([\w\.]+)/i],[c,f],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[f,[c,L+" 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],[c,[f,/_/g,"."]],[/(cobalt)\/([\w\.]+)/i],[c,[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],[d,[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],[d,[h,O],[u,g]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i],[d,[h,S],[u,g]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[d,[h,S],[u,v]],[/(macintosh);/i],[d,[h,S]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[d,[h,M],[u,g]],[/(?:honor)([-\w ]+)[;\)]/i],[d,[h,"Honor"],[u,g]],[/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i],[d,[h,R],[u,v]],[/(?:huawei)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[d,[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],[[d,/_/g," "],[h,F],[u,g]],[/oid[^\)]+; (2\d{4}(283|rpbf)[cgl])( bui|\))/i,/\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i],[[d,/_/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],[d,[h,"OPPO"],[u,g]],[/\b(opd2\d{3}a?) bui/i],[d,[h,"OPPO"],[u,v]],[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[d,[h,"Vivo"],[u,g]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i],[d,[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],[d,[h,D],[u,g]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[d,[h,D],[u,v]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[d,[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],[d,[h,P],[u,g]],[/(ideatab[-\w ]+)/i,/lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i],[d,[h,"Lenovo"],[u,v]],[/(?:maemo|nokia).*(n900|lumia \d+)/i,/nokia[-_ ]?([-\w\.]*)/i],[[d,/_/g," "],[h,"Nokia"],[u,g]],[/(pixel c)\b/i],[d,[h,I],[u,v]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[d,[h,I],[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],[d,[h,N],[u,g]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[d,"Xperia Tablet"],[h,N],[u,v]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[d,[h,"OnePlus"],[u,g]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo(?!bc)\w\w)( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[d,[h,w],[u,v]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[d,/(.+)/g,"Fire Phone $1"],[h,w],[u,g]],[/(playbook);[-\w\),; ]+(rim)/i],[d,h,[u,v]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[d,[h,x],[u,g]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[d,[h,T],[u,v]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[d,[h,T],[u,g]],[/(nexus 9)/i],[d,[h,"HTC"],[u,v]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[h,[d,/_/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],[d,[h,"TCL"],[u,v]],[/(itel) ((\w+))/i],[[h,V],d,[u,K,{tablet:["p10001l","w7001"],"*":"mobile"}]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[d,[h,"Acer"],[u,v]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[d,[h,"Meizu"],[u,g]],[/; ((?:power )?armor(?:[\w ]{0,8}))(?: bui|\))/i],[d,[h,"Ulefone"],[u,g]],[/; (energy ?\w+)(?: bui|\))/i,/; energizer ([\w ]+)(?: bui|\))/i],[d,[h,"Energizer"],[u,g]],[/; cat (b35);/i,/; (b15q?|s22 flip|s48c|s62 pro)(?: bui|\))/i],[d,[h,"Cat"],[u,g]],[/((?:new )?andromax[\w- ]+)(?: bui|\))/i],[d,[h,"Smartfren"],[u,g]],[/droid.+; (a(?:015|06[35]|142p?))/i],[d,[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,d,[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,d,[u,v]],[/(surface duo)/i],[d,[h,C],[u,v]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[d,[h,"Fairphone"],[u,g]],[/(u304aa)/i],[d,[h,"AT&T"],[u,g]],[/\bsie-(\w*)/i],[d,[h,"Siemens"],[u,g]],[/\b(rct\w+) b/i],[d,[h,"RCA"],[u,v]],[/\b(venue[\d ]{2,7}) b/i],[d,[h,"Dell"],[u,v]],[/\b(q(?:mv|ta)\w+) b/i],[d,[h,"Verizon"],[u,v]],[/\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i],[d,[h,"Barnes & Noble"],[u,v]],[/\b(tm\d{3}\w+) b/i],[d,[h,"NuVision"],[u,v]],[/\b(k88) b/i],[d,[h,"ZTE"],[u,v]],[/\b(nx\d{3}j) b/i],[d,[h,"ZTE"],[u,g]],[/\b(gen\d{3}) b.+49h/i],[d,[h,"Swiss"],[u,g]],[/\b(zur\d{3}) b/i],[d,[h,"Swiss"],[u,v]],[/\b((zeki)?tb.*\b) b/i],[d,[h,"Zeki"],[u,v]],[/\b([yr]\d{2}) b/i,/\b(dragon[- ]+touch |dt)(\w{5}) b/i],[[h,"Dragon Touch"],d,[u,v]],[/\b(ns-?\w{0,9}) b/i],[d,[h,"Insignia"],[u,v]],[/\b((nxa|next)-?\w{0,9}) b/i],[d,[h,"NextBook"],[u,v]],[/\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i],[[h,"Voice"],d,[u,g]],[/\b(lvtel\-)?(v1[12]) b/i],[[h,"LvTel"],d,[u,g]],[/\b(ph-1) /i],[d,[h,"Essential"],[u,g]],[/\b(v(100md|700na|7011|917g).*\b) b/i],[d,[h,"Envizen"],[u,v]],[/\b(trio[-\w\. ]+) b/i],[d,[h,"MachSpeed"],[u,v]],[/\btu_(1491) b/i],[d,[h,"Rotor"],[u,v]],[/(shield[\w ]+) b/i],[d,[h,"Nvidia"],[u,v]],[/(sprint) (\w+)/i],[h,d,[u,g]],[/(kin\.[onetw]{3})/i],[[d,/\./g," "],[h,C],[u,g]],[/droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[d,[h,$],[u,v]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[d,[h,$],[u,g]],[/smart-tv.+(samsung)/i],[h,[u,y]],[/hbbtv.+maple;(\d+)/i],[[d,/^/,"SmartTV"],[h,O],[u,y]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[h,P],[u,y]],[/(apple) ?tv/i],[h,[d,S+" TV"],[u,y]],[/crkey/i],[[d,k+"cast"],[h,I],[u,y]],[/droid.+aft(\w+)( bui|\))/i],[d,[h,w],[u,y]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[d,[h,M],[u,y]],[/(bravia[\w ]+)( bui|\))/i],[d,[h,N],[u,y]],[/(mitv-\w{5}) bui/i],[d,[h,F],[u,y]],[/Hbbtv.*(technisat) (.*);/i],[h,d,[u,y]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[h,W],[d,W],[u,y]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[u,y]],[/(ouya)/i,/(nintendo) ([wids3utch]+)/i],[h,d,[u,m]],[/droid.+; (shield) bui/i],[d,[h,"Nvidia"],[u,m]],[/(playstation [345portablevi]+)/i],[d,[h,N],[u,m]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[d,[h,C],[u,m]],[/\b(sm-[lr]\d\d[05][fnuw]?s?)\b/i],[d,[h,O],[u,b]],[/((pebble))app/i],[h,d,[u,b]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[d,[h,S],[u,b]],[/droid.+; (glass) \d/i],[d,[h,I],[u,b]],[/droid.+; (wt63?0{2,3})\)/i],[d,[h,$],[u,b]],[/droid.+; (glass) \d/i],[d,[h,I],[u,b]],[/(pico) (4|neo3(?: link|pro)?)/i],[h,d,[u,b]],[/; (quest( \d| pro)?)/i],[d,[h,B],[u,b]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[h,[u,E]],[/(aeobc)\b/i],[d,[h,w],[u,E]],[/droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew).+? mobile safari/i],[d,[u,g]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i],[d,[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],[d,[h,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[f,[c,"EdgeHTML"]],[/(arkweb)\/([\w\.]+)/i],[c,f],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[f,[c,"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],[c,f],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[f,c]],os:[[/microsoft (windows) (vista|xp)/i],[c,f],[/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i],[c,[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],[c,"Windows"]],[/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i,/(?:ios;fbsv\/|iphone.+ios[\/ ])([\d\.]+)/i,/cfnetwork\/.+darwin/i],[[f,/_/g,"."],[c,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[c,z],[f,/_/g,"."]],[/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i],[f,c],[/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish|openharmony)[-\/ ]?([\w\.]*)/i,/(blackberry)\w*\/([\w\.]*)/i,/(tizen|kaios)[\/ ]([\w\.]+)/i,/\((series40);/i],[c,f],[/\(bb(10);/i],[f,[c,x]],[/(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i],[f,[c,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[f,[c,L+" OS"]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[f,[c,"webOS"]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[f,[c,"watchOS"]],[/crkey\/([\d\.]+)/i],[f,[c,k+"cast"]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[c,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],[c,f],[/(sunos) ?([\w\.\d]*)/i],[[c,"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],[c,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[c]=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[c]="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[d]=i,e[u]=i,Y.call(e,y,E.device),w&&!e[u]&&b&&b.mobile&&(e[u]=g),w&&"Macintosh"==e[d]&&m&&typeof m.standalone!==s&&m.maxTouchPoints&&m.maxTouchPoints>2&&(e[d]="iPad",e[u]=v),e},this.getEngine=function(){var e={};return e[c]=i,e[f]=i,Y.call(e,y,E.engine),e},this.getOS=function(){var e={};return e[c]=i,e[f]=i,Y.call(e,y,E.os),w&&!e[c]&&b&&b.platform&&"Unknown"!=b.platform&&(e[c]=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([c,f,l]),Q.CPU=j([p]),Q.DEVICE=j([d,h,u,m,g,y,v,b,E]),Q.ENGINE=Q.OS=j([c,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:Ha)),ja.exports;var e,t}var Wa=function(){if(za)return Ga;za=1,Object.defineProperty(Ga,"__esModule",{value:!0});var e,r=t,i=(e=r)&&"object"==typeof e&&"default"in e?e.default:e,n=Va(),s=new n,a=s.getBrowser(),o=s.getCPU(),l=s.getDevice(),d=s.getEngine(),c=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:d,os:c,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",L="tablet",I="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===L},G=function(e){var t=e.type;return t===k||t===L},j=function(e){return e.type===I},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},de=function(e){var t=e.name;return t===_.Safari||t===_.MobileSafari},ce=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 Le(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:ce(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:de(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 Ie=j(l),Re=W(l),Pe=V(l),Ce=Y(l),De=ce(a)||Te(),_e=ae(a),Oe=G(l)||Te(),Me=U(l),Ne=z(l)||Te(),Fe=H(l),$e=H(l),Be=Q(c),Ue=ee(c),ze=te(c)||Te(),Ge=ne(a),je=se(a),He=de(a),Ve=ue(a),We=he(a),Ye=re(c),Ke=ie(c),qe=me(a),Xe=ge(a),Qe=ve(a),Ze=K(l),Je=q(l),et=ye(d),tt=be(d),rt=ke(u),it=oe(a)||we(u),nt=le(a),st=X(l),at=Se(),ot=Te(),lt=xe(),dt=Ae(),ct=Ee(),ut=we(u),ht=oe(a)&&!we(u),ft=Z(c),pt=J(c),mt=fe(a),gt=pe(a);function vt(e){var t=e||window.navigator.userAgent;return f(t)}return Ga.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},Ga.BrowserTypes=_,Ga.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},Ga.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},Ga.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},Ga.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},Ga.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},Ga.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},Ga.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},Ga.OsTypes=O,Ga.SmartTVView=function(e){var t=e.renderWithFragment,n=e.children,s=S(e,["renderWithFragment","children"]);return Ie?t?i.createElement(r.Fragment,null,n):i.createElement("div",s,n):null},Ga.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},Ga.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},Ga.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},Ga.browserName=Qe,Ga.browserVersion=Xe,Ga.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 L:return{isTablet:!0};case I: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,d=o.isMobile,c=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):d||c?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},Ga.deviceType=st,Ga.engineName=et,Ga.engineVersion=tt,Ga.fullBrowserVersion=qe,Ga.getSelectorsByUserAgent=function(e){if(e&&"string"==typeof e){var t=f(e);return Le({device:t.device,browser:t.browser,os:t.os,engine:t.engine,ua:t.ua})}console.error("No valid user agent string was provided")},Ga.getUA=rt,Ga.isAndroid=Be,Ga.isBrowser=Fe,Ga.isChrome=Ge,Ga.isChromium=_e,Ga.isConsole=Re,Ga.isDesktop=$e,Ga.isEdge=it,Ga.isEdgeChromium=ut,Ga.isElectron=ct,Ga.isEmbedded=Ce,Ga.isFirefox=je,Ga.isIE=We,Ga.isIOS=ze,Ga.isIOS13=at,Ga.isIPad13=ot,Ga.isIPhone13=lt,Ga.isIPod13=dt,Ga.isLegacyEdge=ht,Ga.isMIUI=mt,Ga.isMacOs=pt,Ga.isMobile=Oe,Ga.isMobileOnly=Me,Ga.isMobileSafari=De,Ga.isOpera=Ve,Ga.isSafari=He,Ga.isSamsungBrowser=gt,Ga.isSmartTV=Ie,Ga.isTablet=Ne,Ga.isWearable=Pe,Ga.isWinPhone=Ue,Ga.isWindows=ft,Ga.isYandex=nt,Ga.mobileModel=Je,Ga.mobileVendor=Ze,Ga.osName=Ke,Ga.osVersion=Ye,Ga.parseUserAgent=f,Ga.setUserAgent=function(e){return h(e)},Ga.useDeviceData=vt,Ga.useDeviceSelectors=function(e){var t=vt(e||window.navigator.userAgent);return[Le(t),t]},Ga.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},Ga.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)},Ga}();function Ya({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 Ka=({shortForm:e,shareUrl:r})=>{const i=null!=r?r:window.location.href,[n,s]=a(!1);return t.createElement(t.Fragment,null,t.createElement("button",{onClick:()=>x(void 0,void 0,void 0,function*(){try{s(!0),Wa.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"},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(Ya,{message:"공유 링크 복사 완료",setVisible:s,visible:n})))},qa=({product:e,hideMoreBtn:r,contentId:i})=>{const{isPreview:n,priceText:s,memberOnly:o,isMemberLoggedIn:l}=Fa(),d=o&&!l,[c,u]=a(!1);return t.createElement("div",{style:{height:"80px"},className:"flex gap-2 items-center w-full",onClick:()=>x(void 0,void 0,void 0,function*(){r&&(window.open(e.linkPath,"_blank"),n||(yield Aa({contentProductId:e.eventProductId,contentId:i,productId:e.productId})))})},e.thumbPath&&!c?t.createElement(zr,{product:e,onError:()=>u(!0)}):t.createElement(Ur,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:"text-gray-800 text-ellipsis line-clamp-1 ",style:{fontSize:"12px"}},e.productName),t.createElement("div",{className:"text-red-500 break-keep",style:{fontSize:"12px"}},d?t.createElement("span",{className:"font-semibold break-keep"},"판매가 회원 공개"):t.createElement(t.Fragment,null,s?s+" ":"할인가 ",t.createElement("span",{className:"font-semibold break-keep"},xt(e.sellingPrice),"원")))))};function Xa(e,t,{checkForDefaultPrevented:r=!0}={}){return function(i){if(e?.(i),!1===r||!i.defaultPrevented)return t?.(i)}}function Qa(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function Za(...e){return t=>{let r=!1;const i=e.map(e=>{const i=Qa(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():Qa(e[t],null)}}}}function Ja(...t){return e.useCallback(Za(...t),t)}function eo(...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 to=globalThis?.document?e.useLayoutEffect:()=>{},ro=e[" useId ".trim().toString()]||(()=>{}),io=0;function no(t){const[r,i]=e.useState(ro());return to(()=>{t||i(e=>e??String(io++))},[t]),t||(r?`radix-${r}`:"")}var so=e[" useInsertionEffect ".trim().toString()]||to;function ao({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 so(()=>{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,d=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 c=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[d,c]}function oo(t){const r=lo(t),i=e.forwardRef((t,i)=>{const{children:n,...s}=t,a=e.Children.toArray(n),o=a.find(uo);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 lo(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?Za(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 co=Symbol("radix.slottable");function uo(t){return e.isValidElement(t)&&"function"==typeof t.type&&"__radixId"in t.type&&t.type.__radixId===co}var ho=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((t,r)=>{const i=oo(`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 fo(t){const r=e.useRef(t);return e.useEffect(()=>{r.current=t}),e.useMemo(()=>(...e)=>r.current?.(...e),[])}function po(t,r=globalThis?.document){const i=fo(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])}var mo,go="dismissableLayer.update",vo="dismissableLayer.pointerDownOutside",yo="dismissableLayer.focusOutside",bo=e.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Eo=e.forwardRef((t,r)=>{const{disableOutsidePointerEvents:i=!1,onEscapeKeyDown:n,onPointerDownOutside:s,onFocusOutside:a,onInteractOutside:o,onDismiss:l,...d}=t,c=e.useContext(bo),[u,h]=e.useState(null),f=u?.ownerDocument??globalThis?.document,[,p]=e.useState({}),m=Ja(r,e=>h(e)),g=Array.from(c.layers),[v]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),y=g.indexOf(v),E=u?g.indexOf(u):-1,w=c.layersWithOutsidePointerEventsDisabled.size>0,S=E>=y,T=function(t,r=globalThis?.document){const i=fo(t),n=e.useRef(!1),s=e.useRef(()=>{});return e.useEffect(()=>{const e=e=>{if(e.target&&!n.current){let t=function(){So(vo,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=[...c.branches].some(e=>e.contains(t));S&&!r&&(s?.(e),o?.(e),e.defaultPrevented||l?.())},f),x=function(t,r=globalThis?.document){const i=fo(t),n=e.useRef(!1);return e.useEffect(()=>{const e=e=>{if(e.target&&!n.current){So(yo,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;[...c.branches].some(e=>e.contains(t))||(a?.(e),o?.(e),e.defaultPrevented||l?.())},f);return po(e=>{E===c.layers.size-1&&(n?.(e),!e.defaultPrevented&&l&&(e.preventDefault(),l()))},f),e.useEffect(()=>{if(u)return i&&(0===c.layersWithOutsidePointerEventsDisabled.size&&(mo=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(u)),c.layers.add(u),wo(),()=>{i&&1===c.layersWithOutsidePointerEventsDisabled.size&&(f.body.style.pointerEvents=mo)}},[u,f,i,c]),e.useEffect(()=>()=>{u&&(c.layers.delete(u),c.layersWithOutsidePointerEventsDisabled.delete(u),wo())},[u,c]),e.useEffect(()=>{const e=()=>p({});return document.addEventListener(go,e),()=>document.removeEventListener(go,e)},[]),b(ho.div,{...d,ref:m,style:{pointerEvents:w?S?"auto":"none":void 0,...t.style},onFocusCapture:Xa(t.onFocusCapture,x.onFocusCapture),onBlurCapture:Xa(t.onBlurCapture,x.onBlurCapture),onPointerDownCapture:Xa(t.onPointerDownCapture,T.onPointerDownCapture)})});Eo.displayName="DismissableLayer";function wo(){const e=new CustomEvent(go);document.dispatchEvent(e)}function So(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(bo),n=e.useRef(null),s=Ja(r,n);return e.useEffect(()=>{const e=n.current;if(e)return i.branches.add(e),()=>{i.branches.delete(e)}},[i.branches]),b(ho.div,{...t,ref:s})}).displayName="DismissableLayerBranch";var To="focusScope.autoFocusOnMount",xo="focusScope.autoFocusOnUnmount",Ao={bubbles:!1,cancelable:!0},ko=e.forwardRef((t,r)=>{const{loop:i=!1,trapped:n=!1,onMountAutoFocus:s,onUnmountAutoFocus:a,...o}=t,[l,d]=e.useState(null),c=fo(s),u=fo(a),h=e.useRef(null),f=Ja(r,e=>d(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:Po(h.current,{select:!0})},t=function(e){if(p.paused||!l)return;const t=e.relatedTarget;null!==t&&(l.contains(t)||Po(h.current,{select:!0}))},r=function(e){if(document.activeElement===document.body)for(const t of e)t.removedNodes.length>0&&Po(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){Co.add(p);const t=document.activeElement;if(!l.contains(t)){const r=new CustomEvent(To,Ao);l.addEventListener(To,c),l.dispatchEvent(r),r.defaultPrevented||(!function(e,{select:t=!1}={}){const r=document.activeElement;for(const i of e)if(Po(i,{select:t}),document.activeElement!==r)return}((e=Lo(l),e.filter(e=>"A"!==e.tagName)),{select:!0}),document.activeElement===t&&Po(l))}return()=>{l.removeEventListener(To,c),setTimeout(()=>{const e=new CustomEvent(xo,Ao);l.addEventListener(xo,u),l.dispatchEvent(e),e.defaultPrevented||Po(t??document.body,{select:!0}),l.removeEventListener(xo,u),Co.remove(p)},0)}}var e},[l,c,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=Lo(e),r=Io(t,e),i=Io(t.reverse(),e);return[r,i]}(t);n&&s?e.shiftKey||r!==s?e.shiftKey&&r===n&&(e.preventDefault(),i&&Po(s,{select:!0})):(e.preventDefault(),i&&Po(n,{select:!0})):r===t&&e.preventDefault()}},[i,n,p.paused]);return b(ho.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});function Lo(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 Io(e,t){for(const r of e)if(!Ro(r,{upTo:t}))return r}function Ro(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 Po(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()}}ko.displayName="FocusScope";var Co=function(){let e=[];return{add(t){const r=e[0];t!==r&&r?.pause(),e=Do(e,t),e.unshift(t)},remove(t){e=Do(e,t),e[0]?.resume()}}}();function Do(e,t){const r=[...e],i=r.indexOf(t);return-1!==i&&r.splice(i,1),r}var _o=e.forwardRef((t,r)=>{const{container:i,...n}=t,[s,a]=e.useState(!1);to(()=>a(!0),[]);const o=i||s&&globalThis?.document?.body;return o?m.createPortal(b(ho.div,{...n,ref:r}),o):null});_o.displayName="Portal";var Oo=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,d]=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=Mo(n.current);a.current="mounted"===l?e:"none"},[l]),to(()=>{const e=n.current,r=s.current;if(r!==t){const i=a.current,n=Mo(e);if(t)d("MOUNT");else if("none"===n||"none"===e?.display)d("UNMOUNT");else{d(r&&i!==n?"ANIMATION_OUT":"UNMOUNT")}s.current=t}},[t,d]),to(()=>{if(r){let e;const t=r.ownerDocument.defaultView??window,i=i=>{const a=Mo(n.current).includes(i.animationName);if(i.target===r&&a&&(d("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=Mo(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)}}d("ANIMATION_END")},[r,d]),{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=Ja(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 Mo(e){return e?.animationName||"none"}Oo.displayName="Presence";var No=0;function Fo(){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 $o="right-scroll-bar-position",Bo="width-before-scroll-bar";function Uo(e,t){return"function"==typeof e?e(t):e&&(e.current=t),e}var zo="undefined"!=typeof window?e.useLayoutEffect:e.useEffect,Go=new WeakMap;function jo(e,t){var r,i,n,s=(r=null,i=function(t){return e.forEach(function(e){return Uo(e,t)})},(n=a(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 zo(function(){var t=Go.get(s);if(t){var r=new Set(t),i=new Set(e),n=s.current;r.forEach(function(e){i.has(e)||Uo(e,null)}),i.forEach(function(e){r.has(e)||Uo(e,n)})}Go.set(s,e)},[e]),s}function Ho(e){return e}var Vo=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))};Vo.isSideCarExport=!0;var Wo=function(e){void 0===e&&(e={});var t=function(e,t){void 0===t&&(t=Ho);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}(),Yo=function(){},Ko=e.forwardRef(function(t,r){var i=e.useRef(null),n=e.useState({onScrollCapture:Yo,onWheelCapture:Yo,onTouchMoveCapture:Yo}),s=n[0],a=n[1],o=t.forwardProps,l=t.children,d=t.className,c=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=jo([i,r]),k=S(S({},w),s);return e.createElement(e.Fragment,null,u&&e.createElement(x,{sideCar:Wo,removeScrollBar:c,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:d,ref:A}),l))});Ko.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Ko.classNames={fullWidth:Bo,zeroRight:$o};function qo(){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 Xo=function(){var e=0,t=null;return{add:function(r){var i,n;0==e&&(t=qo())&&(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)}}},Qo=function(){var t,r=(t=Xo(),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}},Zo={left:0,top:0,right:0,gap:0},Jo=function(e){return parseInt(e||"",10)||0},el=function(e){if(void 0===e&&(e="margin"),"undefined"==typeof window)return Zo;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[Jo(r),Jo(i),Jo(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])}},tl=Qo(),rl="data-scroll-locked",il=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(rl,"] {\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($o," {\n right: ").concat(o,"px ").concat(i,";\n }\n \n .").concat(Bo," {\n margin-right: ").concat(o,"px ").concat(i,";\n }\n \n .").concat($o," .").concat($o," {\n right: 0 ").concat(i,";\n }\n \n .").concat(Bo," .").concat(Bo," {\n margin-right: 0 ").concat(i,";\n }\n \n body[").concat(rl,"] {\n ").concat("--removed-body-scroll-bar-size",": ").concat(o,"px;\n }\n")},nl=function(){var e=parseInt(document.body.getAttribute(rl)||"0",10);return isFinite(e)?e:0},sl=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(rl,(nl()+1).toString()),function(){var e=nl()-1;e<=0?document.body.removeAttribute(rl):document.body.setAttribute(rl,e.toString())}},[]);var a=e.useMemo(function(){return el(s)},[s]);return e.createElement(tl,{styles:il(a,!r,s,i?"":"!important")})},al=!1;if("undefined"!=typeof window)try{var ol=Object.defineProperty({},"passive",{get:function(){return al=!0,!0}});window.addEventListener("test",ol,ol),window.removeEventListener("test",ol,ol)}catch(e){al=!1}var ll=!!al&&{passive:!1},dl=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])},cl=function(e,t){var r=t.ownerDocument,i=t;do{if("undefined"!=typeof ShadowRoot&&i instanceof ShadowRoot&&(i=i.host),ul(e,i)){var n=hl(e,i);if(n[1]>n[2])return!0}i=i.parentNode}while(i&&i!==r.body);return!1},ul=function(e,t){return"v"===e?function(e){return dl(e,"overflowY")}(t):function(e){return dl(e,"overflowX")}(t)},hl=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},fl=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},pl=function(e){return[e.deltaX,e.deltaY]},ml=function(e){return e&&"current"in e?e.current:e},gl=function(e){return"\n .block-interactivity-".concat(e," {pointer-events: none;}\n .allow-interactivity-").concat(e," {pointer-events: all;}\n")},vl=0,yl=[];function bl(e){for(var t=null;null!==e;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var El,wl=(El=function(t){var r=e.useRef([]),i=e.useRef([0,0]),n=e.useRef(),s=e.useState(vl++)[0],a=e.useState(Qo)[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(ml),!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=fl(e),a=i.current,l="deltaX"in e?e.deltaX:a[0]-s[0],d="deltaY"in e?e.deltaY:a[1]-s[1],c=e.target,u=Math.abs(l)>Math.abs(d)?"h":"v";if("touches"in e&&"h"===u&&"range"===c.type)return!1;var h=cl(u,c);if(!h)return!0;if(h?r=u:(r="v"===u?"h":"v",h=cl(u,c)),!h)return!1;if(!n.current&&"changedTouches"in e&&(l||d)&&(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),d=!1,c=a>0,u=0,h=0;do{if(!o)break;var f=hl(e,o),p=f[0],m=f[1]-f[2]-s*p;(p||m)&&ul(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 c&&(Math.abs(u)<1||!n)?d=!0:c||!(Math.abs(h)<1)&&n||(d=!0),d}(f,t,e,"h"===f?l:d,!0)},[]),d=e.useCallback(function(e){var t=e;if(yl.length&&yl[yl.length-1]===a){var i="deltaY"in t?pl(t):fl(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(ml).filter(Boolean).filter(function(e){return e.contains(t.target)});(s.length>0?l(t,s[0]):!o.current.noIsolation)&&t.cancelable&&t.preventDefault()}}},[]),c=e.useCallback(function(e,t,i,n){var s={name:e,delta:t,target:i,should:n,shadowParent:bl(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=fl(e),n.current=void 0},[]),h=e.useCallback(function(e){c(e.type,pl(e),e.target,l(e,t.lockRef.current))},[]),f=e.useCallback(function(e){c(e.type,fl(e),e.target,l(e,t.lockRef.current))},[]);e.useEffect(function(){return yl.push(a),t.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:f}),document.addEventListener("wheel",d,ll),document.addEventListener("touchmove",d,ll),document.addEventListener("touchstart",u,ll),function(){yl=yl.filter(function(e){return e!==a}),document.removeEventListener("wheel",d,ll),document.removeEventListener("touchmove",d,ll),document.removeEventListener("touchstart",u,ll)}},[]);var p=t.removeScrollBar,m=t.inert;return e.createElement(e.Fragment,null,m?e.createElement(a,{styles:gl(s)}):null,p?e.createElement(sl,{noRelative:t.noRelative,gapMode:t.gapMode}):null)},Wo.useMedium(El),Vo),Sl=e.forwardRef(function(t,r){return e.createElement(Ko,S({},t,{ref:r,sideCar:wl}))});Sl.classNames=Ko.classNames;var Tl=new WeakMap,xl=new WeakMap,Al={},kl=0,Ll=function(e){return e&&(e.host||Ll(e.parentNode))},Il=function(e,t,r,i){var n=function(e,t){return t.map(function(t){if(e.contains(t))return t;var r=Ll(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]);Al[r]||(Al[r]=new WeakMap);var s=Al[r],a=[],o=new Set,l=new Set(n),d=function(e){e&&!o.has(e)&&(o.add(e),d(e.parentNode))};n.forEach(d);var c=function(e){e&&!l.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(o.has(e))c(e);else try{var t=e.getAttribute(i),n=null!==t&&"false"!==t,l=(Tl.get(e)||0)+1,d=(s.get(e)||0)+1;Tl.set(e,l),s.set(e,d),a.push(e),1===l&&n&&xl.set(e,!0),1===d&&e.setAttribute(r,"true"),n||e.setAttribute(i,"true")}catch(t){console.error("aria-hidden: cannot operate on ",e,t)}})};return c(t),o.clear(),kl++,function(){a.forEach(function(e){var t=Tl.get(e)-1,n=s.get(e)-1;Tl.set(e,t),s.set(e,n),t||(xl.has(e)||e.removeAttribute(i),xl.delete(e)),n||e.removeAttribute(r)}),--kl||(Tl=new WeakMap,Tl=new WeakMap,xl=new WeakMap,Al={})}},Rl=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"))),Il(i,n,r,"aria-hidden")):function(){return null}},Pl="Dialog",[Cl,Dl]=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,d=e.useMemo(()=>o,Object.values(o));return b(l.Provider,{value:d,children:n})};return o.displayName=r+"Provider",[o,function(i,o){const l=o?.[t]?.[a]||s,d=e.useContext(l);if(d)return d;if(void 0!==n)return n;throw new Error(`\`${i}\` must be used within \`${r}\``)}]},eo(n,...r)]}(Pl),[_l,Ol]=Cl(Pl),Ml=t=>{const{__scopeDialog:r,children:i,open:n,defaultOpen:s,onOpenChange:a,modal:o=!0}=t,l=e.useRef(null),d=e.useRef(null),[c,u]=ao({prop:n,defaultProp:s??!1,onChange:a,caller:Pl});return b(_l,{scope:r,triggerRef:l,contentRef:d,contentId:no(),titleId:no(),descriptionId:no(),open:c,onOpenChange:u,onOpenToggle:e.useCallback(()=>u(e=>!e),[u]),modal:o,children:i})};Ml.displayName=Pl;var Nl="DialogTrigger",Fl=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=Ol(Nl,r),s=Ja(t,n.triggerRef);return b(ho.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":id(n.open),...i,ref:s,onClick:Xa(e.onClick,n.onOpenToggle)})});Fl.displayName=Nl;var $l="DialogPortal",[Bl,Ul]=Cl($l,{forceMount:void 0}),zl=t=>{const{__scopeDialog:r,forceMount:i,children:n,container:s}=t,a=Ol($l,r);return b(Bl,{scope:r,forceMount:i,children:e.Children.map(n,e=>b(Oo,{present:i||a.open,children:b(_o,{asChild:!0,container:s,children:e})}))})};zl.displayName=$l;var Gl="DialogOverlay",jl=e.forwardRef((e,t)=>{const r=Ul(Gl,e.__scopeDialog),{forceMount:i=r.forceMount,...n}=e,s=Ol(Gl,e.__scopeDialog);return s.modal?b(Oo,{present:i||s.open,children:b(Vl,{...n,ref:t})}):null});jl.displayName=Gl;var Hl=oo("DialogOverlay.RemoveScroll"),Vl=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=Ol(Gl,r);return b(Sl,{as:Hl,allowPinchZoom:!0,shards:[n.contentRef],children:b(ho.div,{"data-state":id(n.open),...i,ref:t,style:{pointerEvents:"auto",...i.style}})})}),Wl="DialogContent",Yl=e.forwardRef((e,t)=>{const r=Ul(Wl,e.__scopeDialog),{forceMount:i=r.forceMount,...n}=e,s=Ol(Wl,e.__scopeDialog);return b(Oo,{present:i||s.open,children:s.modal?b(Kl,{...n,ref:t}):b(ql,{...n,ref:t})})});Yl.displayName=Wl;var Kl=e.forwardRef((t,r)=>{const i=Ol(Wl,t.__scopeDialog),n=e.useRef(null),s=Ja(r,i.contentRef,n);return e.useEffect(()=>{const e=n.current;if(e)return Rl(e)},[]),b(Xl,{...t,ref:s,trapFocus:i.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Xa(t.onCloseAutoFocus,e=>{e.preventDefault(),i.triggerRef.current?.focus()}),onPointerDownOutside:Xa(t.onPointerDownOutside,e=>{const t=e.detail.originalEvent,r=0===t.button&&!0===t.ctrlKey;(2===t.button||r)&&e.preventDefault()}),onFocusOutside:Xa(t.onFocusOutside,e=>e.preventDefault())})}),ql=e.forwardRef((t,r)=>{const i=Ol(Wl,t.__scopeDialog),n=e.useRef(!1),s=e.useRef(!1);return b(Xl,{...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()}})}),Xl=e.forwardRef((t,r)=>{const{__scopeDialog:i,trapFocus:n,onOpenAutoFocus:s,onCloseAutoFocus:a,...o}=t,l=Ol(Wl,i),d=e.useRef(null),c=Ja(r,d);return e.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Fo()),document.body.insertAdjacentElement("beforeend",e[1]??Fo()),No++,()=>{1===No&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),No--}},[]),w(E,{children:[b(ko,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:s,onUnmountAutoFocus:a,children:b(Eo,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":id(l.open),...o,ref:c,onDismiss:()=>l.onOpenChange(!1)})}),w(E,{children:[b(od,{titleId:l.titleId}),b(ld,{contentRef:d,descriptionId:l.descriptionId})]})]})}),Ql="DialogTitle",Zl=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=Ol(Ql,r);return b(ho.h2,{id:n.titleId,...i,ref:t})});Zl.displayName=Ql;var Jl="DialogDescription",ed=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=Ol(Jl,r);return b(ho.p,{id:n.descriptionId,...i,ref:t})});ed.displayName=Jl;var td="DialogClose",rd=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=Ol(td,r);return b(ho.button,{type:"button",...i,ref:t,onClick:Xa(e.onClick,()=>n.onOpenChange(!1))})});function id(e){return e?"open":"closed"}rd.displayName=td;var nd="DialogTitleWarning",[sd,ad]=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}\``)}]}(nd,{contentName:Wl,titleName:Ql,docsSlug:"dialog"}),od=({titleId:t})=>{const r=ad(nd),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},ld=({contentRef:t,descriptionId:r})=>{const i=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${ad("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},dd=Ml,cd=Fl,ud=zl,hd=jl,fd=Yl,pd=Zl,md=ed,gd=rd;const vd=t.createContext({drawerRef:{current:null},overlayRef:{current:null},onPress:()=>{},onRelease:()=>{},onDrag:()=>{},onNestedDrag:()=>{},onNestedOpenChange:()=>{},onNestedRelease:()=>{},openProp:void 0,dismissible:!1,isOpen:!1,isDragging:!1,keyboardIsOpen:{current:!1},snapPointsOffset:null,snapPoints:null,handleOnly:!1,modal:!1,shouldFade:!1,activeSnapPoint:null,onOpenChange:()=>{},setActiveSnapPoint:()=>{},closeDrawer:()=>{},direction:"bottom",shouldAnimate:{current:!0},shouldScaleBackground:!1,setBackgroundColorOnScale:!0,noBodyStyles:!1,container:null,autoFocus:!1}),yd=()=>{const e=t.useContext(vd);if(!e)throw new Error("useDrawerContext must be used within a Drawer.Root");return e};function bd(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function Ed(){return Sd(/^iPad/)||Sd(/^Mac/)&&navigator.maxTouchPoints>1}function wd(){return Sd(/^iPhone/)||Ed()}function Sd(e){return"undefined"!=typeof window&&null!=window.navigator?e.test(window.navigator.platform):void 0}!function(e){if("undefined"==typeof document)return;let t=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}("[data-vaul-drawer]{touch-action:none;will-change:transform;transition:transform .5s cubic-bezier(.32, .72, 0, 1);animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=open]{animation-name:slideFromBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=closed]{animation-name:slideToBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=open]{animation-name:slideFromTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=closed]{animation-name:slideToTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=open]{animation-name:slideFromLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=closed]{animation-name:slideToLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=open]{animation-name:slideFromRight}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=closed]{animation-name:slideToRight}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,var(--initial-transform,100%),0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(var(--initial-transform,100%),0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-overlay][data-vaul-snap-points=false]{animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-overlay][data-vaul-snap-points=false][data-state=open]{animation-name:fadeIn}[data-vaul-overlay][data-state=closed]{animation-name:fadeOut}[data-vaul-animate=false]{animation:none!important}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:0;transition:opacity .5s cubic-bezier(.32, .72, 0, 1)}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:1}[data-vaul-drawer]:not([data-vaul-custom-container=true])::after{content:'';position:absolute;background:inherit;background-color:inherit}[data-vaul-drawer][data-vaul-drawer-direction=top]::after{top:initial;bottom:100%;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=bottom]::after{top:100%;bottom:initial;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=left]::after{left:initial;right:100%;top:0;bottom:0;width:200%}[data-vaul-drawer][data-vaul-drawer-direction=right]::after{left:100%;right:initial;top:0;bottom:0;width:200%}[data-vaul-overlay][data-vaul-snap-points=true]:not([data-vaul-snap-points-overlay=true]):not(\n[data-state=closed]\n){opacity:0}[data-vaul-overlay][data-vaul-snap-points-overlay=true]{opacity:1}[data-vaul-handle]{display:block;position:relative;opacity:.7;background:#e2e2e4;margin-left:auto;margin-right:auto;height:5px;width:32px;border-radius:1rem;touch-action:pan-y}[data-vaul-handle]:active,[data-vaul-handle]:hover{opacity:1}[data-vaul-handle-hitarea]{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:max(100%,2.75rem);height:max(100%,2.75rem);touch-action:inherit}@media (hover:hover) and (pointer:fine){[data-vaul-drawer]{user-select:none}}@media (pointer:fine){[data-vaul-handle-hitarea]:{width:100%;height:100%}}@keyframes fadeIn{from{opacity:0}to{opacity:1}}@keyframes fadeOut{to{opacity:0}}@keyframes slideFromBottom{from{transform:translate3d(0,var(--initial-transform,100%),0)}to{transform:translate3d(0,0,0)}}@keyframes slideToBottom{to{transform:translate3d(0,var(--initial-transform,100%),0)}}@keyframes slideFromTop{from{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}to{transform:translate3d(0,0,0)}}@keyframes slideToTop{to{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}}@keyframes slideFromLeft{from{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToLeft{to{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}}@keyframes slideFromRight{from{transform:translate3d(var(--initial-transform,100%),0,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToRight{to{transform:translate3d(var(--initial-transform,100%),0,0)}}");const Td="undefined"!=typeof window?o:i;function xd(...e){return(...t)=>{for(let r of e)"function"==typeof r&&r(...t)}}const Ad="undefined"!=typeof document&&window.visualViewport;function kd(e){let t=window.getComputedStyle(e);return/(auto|scroll)/.test(t.overflow+t.overflowX+t.overflowY)}function Ld(e){for(kd(e)&&(e=e.parentElement);e&&!kd(e);)e=e.parentElement;return e||document.scrollingElement||document.documentElement}const Id=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);let Rd,Pd=0;function Cd(e={}){let{isDisabled:t}=e;Td(()=>{if(!t)return Pd++,1===Pd&&wd()&&(Rd=function(){let e,t=0,r=r=>{e=Ld(r.target),e===document.documentElement&&e===document.body||(t=r.changedTouches[0].pageY)},i=r=>{if(!e||e===document.documentElement||e===document.body)return void r.preventDefault();let i=r.changedTouches[0].pageY,n=e.scrollTop,s=e.scrollHeight-e.clientHeight;0!==s&&((n<=0&&i>t||n>=s&&i<t)&&r.preventDefault(),t=i)},n=e=>{let t=e.target;Od(t)&&t!==document.activeElement&&(e.preventDefault(),t.style.transform="translateY(-2000px)",t.focus(),requestAnimationFrame(()=>{t.style.transform=""}))},s=e=>{let t=e.target;Od(t)&&(t.style.transform="translateY(-2000px)",requestAnimationFrame(()=>{t.style.transform="",Ad&&(Ad.height<window.innerHeight?requestAnimationFrame(()=>{_d(t)}):Ad.addEventListener("resize",()=>_d(t),{once:!0}))}))},a=()=>{window.scrollTo(0,0)},o=window.pageXOffset,l=window.pageYOffset,d=xd(function(e,t,r){let i=e.style[t];return e.style[t]=r,()=>{e.style[t]=i}}(document.documentElement,"paddingRight",window.innerWidth-document.documentElement.clientWidth+"px"));window.scrollTo(0,0);let c=xd(Dd(document,"touchstart",r,{passive:!1,capture:!0}),Dd(document,"touchmove",i,{passive:!1,capture:!0}),Dd(document,"touchend",n,{passive:!1,capture:!0}),Dd(document,"focus",s,!0),Dd(window,"scroll",a));return()=>{d(),c(),window.scrollTo(o,l)}}()),()=>{Pd--,0===Pd&&(null==Rd||Rd())}},[t])}function Dd(e,t,r,i){return e.addEventListener(t,r,i),()=>{e.removeEventListener(t,r,i)}}function _d(e){let t=document.scrollingElement||document.documentElement;for(;e&&e!==t;){let t=Ld(e);if(t!==document.documentElement&&t!==document.body&&t!==e){let r=t.getBoundingClientRect().top,i=e.getBoundingClientRect().top;e.getBoundingClientRect().bottom>t.getBoundingClientRect().bottom+24&&(t.scrollTop+=i-r)}e=t.parentElement}}function Od(e){return e instanceof HTMLInputElement&&!Id.has(e.type)||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable}function Md(...t){return e.useCallback(function(...e){return t=>e.forEach(e=>function(e,t){"function"==typeof e?e(t):null!=e&&(e.current=t)}(e,t))}(...t),t)}const Nd=new WeakMap;function Fd(e,t,r=!1){if(!(e&&e instanceof HTMLElement))return;let i={};Object.entries(t).forEach(([t,r])=>{t.startsWith("--")?e.style.setProperty(t,r):(i[t]=e.style[t],e.style[t]=r)}),r||Nd.set(e,i)}const $d=e=>{switch(e){case"top":case"bottom":return!0;case"left":case"right":return!1;default:return e}};function Bd(e,t){if(!e)return null;const r=window.getComputedStyle(e),i=r.transform||r.webkitTransform||r.mozTransform;let n=i.match(/^matrix3d\((.+)\)$/);return n?parseFloat(n[1].split(", ")[$d(t)?13:12]):(n=i.match(/^matrix\((.+)\)$/),n?parseFloat(n[1].split(", ")[$d(t)?5:4]):null)}function Ud(e,t){if(!e)return()=>{};const r=e.style.cssText;return Object.assign(e.style,t),()=>{e.style.cssText=r}}const zd={DURATION:.5,EASE:[.32,.72,0,1]},Gd=16,jd="vaul-dragging";function Hd(e){const r=t.useRef(e);return t.useEffect(()=>{r.current=e}),t.useMemo(()=>(...e)=>null==r.current?void 0:r.current.call(r,...e),[])}function Vd({prop:e,defaultProp:r,onChange:i=()=>{}}){const[n,s]=function({defaultProp:e,onChange:r}){const i=t.useState(e),[n]=i,s=t.useRef(n),a=Hd(r);return t.useEffect(()=>{s.current!==n&&(a(n),s.current=n)},[n,s,a]),i}({defaultProp:r,onChange:i}),a=void 0!==e,o=a?e:n,l=Hd(i),d=t.useCallback(t=>{if(a){const r="function"==typeof t?t(e):t;r!==e&&l(r)}else s(t)},[a,e,s,l]);return[o,d]}let Wd=null;function Yd({open:e,onOpenChange:r,children:i,onDrag:n,onRelease:s,snapPoints:a,shouldScaleBackground:o=!1,setBackgroundColorOnScale:l=!0,closeThreshold:d=.25,scrollLockTimeout:c=100,dismissible:u=!0,handleOnly:h=!1,fadeFromIndex:f=a&&a.length-1,activeSnapPoint:p,setActiveSnapPoint:m,fixed:g,modal:v=!0,onClose:y,nested:b,noBodyStyles:E=!1,direction:w="bottom",defaultOpen:S=!1,disablePreventScroll:T=!0,snapToSequentialPoint:x=!1,preventScrollRestoration:A=!1,repositionInputs:k=!0,onAnimationEnd:L,container:I,autoFocus:R=!1}){var P,C;const[D=!1,_]=Vd({defaultProp:S,prop:e,onChange:e=>{null==r||r(e),e||b||ce(),setTimeout(()=>{null==L||L(e)},1e3*zd.DURATION),e&&!v&&"undefined"!=typeof window&&window.requestAnimationFrame(()=>{document.body.style.pointerEvents="auto"}),e||(document.body.style.pointerEvents="auto")}}),[O,M]=t.useState(!1),[N,F]=t.useState(!1),[$,B]=t.useState(!1),U=t.useRef(null),z=t.useRef(null),G=t.useRef(null),j=t.useRef(null),H=t.useRef(null),V=t.useRef(!1),W=t.useRef(null),Y=t.useRef(0),K=t.useRef(!1),q=t.useRef(!S),X=t.useRef(0),Q=t.useRef(null),Z=t.useRef((null==(P=Q.current)?void 0:P.getBoundingClientRect().height)||0),J=t.useRef((null==(C=Q.current)?void 0:C.getBoundingClientRect().width)||0),ee=t.useRef(0),te=t.useCallback(e=>{a&&e===ae.length-1&&(z.current=new Date)},[]),{activeSnapPoint:re,activeSnapPointIndex:ie,setActiveSnapPoint:ne,onRelease:se,snapPointsOffset:ae,onDrag:oe,shouldFade:le,getPercentageDragged:de}=function({activeSnapPointProp:e,setActiveSnapPointProp:r,snapPoints:i,drawerRef:n,overlayRef:s,fadeFromIndex:a,onSnapPointChange:o,direction:l="bottom",container:d,snapToSequentialPoint:c}){const[u,h]=Vd({prop:e,defaultProp:null==i?void 0:i[0],onChange:r}),[f,p]=t.useState("undefined"!=typeof window?{innerWidth:window.innerWidth,innerHeight:window.innerHeight}:void 0);t.useEffect(()=>{function e(){p({innerWidth:window.innerWidth,innerHeight:window.innerHeight})}return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const m=t.useMemo(()=>u===(null==i?void 0:i[i.length-1])||null,[i,u]),g=t.useMemo(()=>{var e;return null!=(e=null==i?void 0:i.findIndex(e=>e===u))?e:null},[i,u]),v=i&&i.length>0&&(a||0===a)&&!Number.isNaN(a)&&i[a]===u||!i,y=t.useMemo(()=>{const e=d?{width:d.getBoundingClientRect().width,height:d.getBoundingClientRect().height}:"undefined"!=typeof window?{width:window.innerWidth,height:window.innerHeight}:{width:0,height:0};var t;return null!=(t=null==i?void 0:i.map(t=>{const r="string"==typeof t;let i=0;if(r&&(i=parseInt(t,10)),$d(l)){const n=r?i:f?t*e.height:0;return f?"bottom"===l?e.height-n:-e.height+n:n}const n=r?i:f?t*e.width:0;return f?"right"===l?e.width-n:-e.width+n:n}))?t:[]},[i,f,d]),b=t.useMemo(()=>null!==g?null==y?void 0:y[g]:null,[y,g]),E=t.useCallback(e=>{var t;const r=null!=(t=null==y?void 0:y.findIndex(t=>t===e))?t:null;o(r),Fd(n.current,{transition:`transform ${zd.DURATION}s cubic-bezier(${zd.EASE.join(",")})`,transform:$d(l)?`translate3d(0, ${e}px, 0)`:`translate3d(${e}px, 0, 0)`}),y&&r!==y.length-1&&void 0!==a&&r!==a&&r<a?Fd(s.current,{transition:`opacity ${zd.DURATION}s cubic-bezier(${zd.EASE.join(",")})`,opacity:"0"}):Fd(s.current,{transition:`opacity ${zd.DURATION}s cubic-bezier(${zd.EASE.join(",")})`,opacity:"1"}),h(null==i?void 0:i[Math.max(r,0)])},[n.current,i,y,a,s,h]);return t.useEffect(()=>{if(u||e){var t;const r=null!=(t=null==i?void 0:i.findIndex(t=>t===e||t===u))?t:-1;y&&-1!==r&&"number"==typeof y[r]&&E(y[r])}},[u,e,i,y,E]),{isLastSnapPoint:m,activeSnapPoint:u,shouldFade:v,getPercentageDragged:function(e,t){if(!i||"number"!=typeof g||!y||void 0===a)return null;const r=g===a-1;if(g>=a&&t)return 0;if(r&&!t)return 1;if(!v&&!r)return null;const n=r?g+1:g-1,s=r?y[n]-y[n-1]:y[n+1]-y[n],o=e/Math.abs(s);return r?1-o:o},setActiveSnapPoint:h,activeSnapPointIndex:g,onRelease:function({draggedDistance:e,closeDrawer:t,velocity:r,dismissible:n}){if(void 0===a)return;const o="bottom"===l||"right"===l?(null!=b?b:0)-e:(null!=b?b:0)+e,d=0===g,u=e>0;if(g===a-1&&Fd(s.current,{transition:`opacity ${zd.DURATION}s cubic-bezier(${zd.EASE.join(",")})`}),!c&&r>2&&!u)return void(n?t():E(y[0]));if(!c&&r>2&&u&&y&&i)return void E(y[i.length-1]);const h=null==y?void 0:y.reduce((e,t)=>"number"!=typeof e||"number"!=typeof t?e:Math.abs(t-o)<Math.abs(e-o)?t:e),f=$d(l)?window.innerHeight:window.innerWidth;if(r>.4&&Math.abs(e)<.4*f){const e=u?1:-1;if(e>0&&m&&i)return void E(y[i.length-1]);if(d&&e<0&&n&&t(),null===g)return;return void E(y[g+e])}E(h)},onDrag:function({draggedDistance:e}){if(null===b)return;const t="bottom"===l||"right"===l?b-e:b+e;("bottom"===l||"right"===l)&&t<y[y.length-1]||("top"===l||"left"===l)&&t>y[y.length-1]||Fd(n.current,{transform:$d(l)?`translate3d(0, ${t}px, 0)`:`translate3d(${t}px, 0, 0)`})},snapPointsOffset:y}}({snapPoints:a,activeSnapPointProp:p,setActiveSnapPointProp:m,drawerRef:Q,fadeFromIndex:f,overlayRef:U,onSnapPointChange:te,direction:w,container:I,snapToSequentialPoint:x});Cd({isDisabled:!D||N||!v||$||!O||!k||!T});const{restorePositionSetting:ce}=function({isOpen:e,modal:r,nested:i,hasBeenOpened:n,preventScrollRestoration:s,noBodyStyles:a}){const[o,l]=t.useState(()=>"undefined"!=typeof window?window.location.href:""),d=t.useRef(0),c=t.useCallback(()=>{if(bd()&&null===Wd&&e&&!a){Wd={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left,height:document.body.style.height,right:"unset"};const{scrollX:e,innerHeight:t}=window;document.body.style.setProperty("position","fixed","important"),Object.assign(document.body.style,{top:-d.current+"px",left:-e+"px",right:"0px",height:"auto"}),window.setTimeout(()=>window.requestAnimationFrame(()=>{const e=t-window.innerHeight;e&&d.current>=t&&(document.body.style.top=-(d.current+e)+"px")}),300)}},[e]),u=t.useCallback(()=>{if(bd()&&null!==Wd&&!a){const e=-parseInt(document.body.style.top,10),t=-parseInt(document.body.style.left,10);Object.assign(document.body.style,Wd),window.requestAnimationFrame(()=>{s&&o!==window.location.href?l(window.location.href):window.scrollTo(t,e)}),Wd=null}},[o]);return t.useEffect(()=>{function e(){d.current=window.scrollY}return e(),window.addEventListener("scroll",e),()=>{window.removeEventListener("scroll",e)}},[]),t.useEffect(()=>{if(r)return()=>{"undefined"!=typeof document&&(document.querySelector("[data-vaul-drawer]")||u())}},[r,u]),t.useEffect(()=>{!i&&n&&(e?(!window.matchMedia("(display-mode: standalone)").matches&&c(),r||window.setTimeout(()=>{u()},500)):u())},[e,n,o,r,i,c,u]),{restorePositionSetting:u}}({isOpen:D,modal:v,nested:null!=b&&b,hasBeenOpened:O,preventScrollRestoration:A,noBodyStyles:E});function ue(){return(window.innerWidth-26)/window.innerWidth}function he(e,t){var r;let i=e;const n=null==(r=window.getSelection())?void 0:r.toString(),s=Q.current?Bd(Q.current,w):null,a=new Date;if("SELECT"===i.tagName)return!1;if(i.hasAttribute("data-vaul-no-drag")||i.closest("[data-vaul-no-drag]"))return!1;if("right"===w||"left"===w)return!0;if(z.current&&a.getTime()-z.current.getTime()<500)return!1;if(null!==s&&("bottom"===w?s>0:s<0))return!0;if(n&&n.length>0)return!1;if(H.current&&a.getTime()-H.current.getTime()<c&&0===s)return H.current=a,!1;if(t)return H.current=a,!1;for(;i;){if(i.scrollHeight>i.clientHeight){if(0!==i.scrollTop)return H.current=new Date,!1;if("dialog"===i.getAttribute("role"))return!0}i=i.parentNode}return!0}function fe(e){!function(){if(!N||!Q.current)return;Q.current.classList.remove(jd),V.current=!1,F(!1),j.current=new Date}(),null==y||y(),e||_(!1),setTimeout(()=>{a&&ne(a[0])},1e3*zd.DURATION)}function pe(){if(!Q.current)return;const e=document.querySelector("[data-vaul-drawer-wrapper]"),t=Bd(Q.current,w);Fd(Q.current,{transform:"translate3d(0, 0, 0)",transition:`transform ${zd.DURATION}s cubic-bezier(${zd.EASE.join(",")})`}),Fd(U.current,{transition:`opacity ${zd.DURATION}s cubic-bezier(${zd.EASE.join(",")})`,opacity:"1"}),o&&t&&t>0&&D&&Fd(e,{borderRadius:"8px",overflow:"hidden",...$d(w)?{transform:`scale(${ue()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`,transformOrigin:"top"}:{transform:`scale(${ue()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`,transformOrigin:"left"},transitionProperty:"transform, border-radius",transitionDuration:`${zd.DURATION}s`,transitionTimingFunction:`cubic-bezier(${zd.EASE.join(",")})`},!0)}return t.useEffect(()=>{window.requestAnimationFrame(()=>{q.current=!0})},[]),t.useEffect(()=>{var e;function t(){if(!Q.current||!k)return;if(Od(document.activeElement)||K.current){var e;const t=(null==(e=window.visualViewport)?void 0:e.height)||0,r=window.innerHeight;let i=r-t;const n=Q.current.getBoundingClientRect().height||0,s=n>.8*r;ee.current||(ee.current=n);const o=Q.current.getBoundingClientRect().top;if(Math.abs(X.current-i)>60&&(K.current=!K.current),a&&a.length>0&&ae&&ie){i+=ae[ie]||0}if(X.current=i,n>t||K.current){const e=Q.current.getBoundingClientRect().height;let r=e;e>t&&(r=t-(s?o:26)),Q.current.style.height=g?e-Math.max(i,0)+"px":`${Math.max(r,t-o)}px`}else(function(){const e=navigator.userAgent;return"undefined"!=typeof window&&(/Firefox/.test(e)&&/Mobile/.test(e)||/FxiOS/.test(e))})()||(Q.current.style.height=`${ee.current}px`);a&&a.length>0&&!K.current?Q.current.style.bottom="0px":Q.current.style.bottom=`${Math.max(i,0)}px`}}return null==(e=window.visualViewport)||e.addEventListener("resize",t),()=>{var e;return null==(e=window.visualViewport)?void 0:e.removeEventListener("resize",t)}},[ie,a,ae]),t.useEffect(()=>(D&&(Fd(document.documentElement,{scrollBehavior:"auto"}),z.current=new Date),()=>{!function(e,t){if(!(e&&e instanceof HTMLElement))return;let r=Nd.get(e);r&&(e.style[t]=r[t])}(document.documentElement,"scrollBehavior")}),[D]),t.useEffect(()=>{v||window.requestAnimationFrame(()=>{document.body.style.pointerEvents="auto"})},[v]),t.createElement(dd,{defaultOpen:S,onOpenChange:e=>{(u||e)&&(e?M(!0):fe(!0),_(e))},open:D},t.createElement(vd.Provider,{value:{activeSnapPoint:re,snapPoints:a,setActiveSnapPoint:ne,drawerRef:Q,overlayRef:U,onOpenChange:r,onPress:function(e){var t,r;(u||a)&&(Q.current&&!Q.current.contains(e.target)||(Z.current=(null==(t=Q.current)?void 0:t.getBoundingClientRect().height)||0,J.current=(null==(r=Q.current)?void 0:r.getBoundingClientRect().width)||0,F(!0),G.current=new Date,wd()&&window.addEventListener("touchend",()=>V.current=!1,{once:!0}),e.target.setPointerCapture(e.pointerId),Y.current=$d(w)?e.pageY:e.pageX))},onRelease:function(e){if(!N||!Q.current)return;Q.current.classList.remove(jd),V.current=!1,F(!1),j.current=new Date;const t=Bd(Q.current,w);if(!e||!he(e.target,!1)||!t||Number.isNaN(t))return;if(null===G.current)return;const r=j.current.getTime()-G.current.getTime(),i=Y.current-($d(w)?e.pageY:e.pageX),n=Math.abs(i)/r;if(n>.05&&(B(!0),setTimeout(()=>{B(!1)},200)),a){return se({draggedDistance:i*("bottom"===w||"right"===w?1:-1),closeDrawer:fe,velocity:n,dismissible:u}),void(null==s||s(e,!0))}if("bottom"===w||"right"===w?i>0:i<0)return pe(),void(null==s||s(e,!0));if(n>.4)return fe(),void(null==s||s(e,!1));var o;const l=Math.min(null!=(o=Q.current.getBoundingClientRect().height)?o:0,window.innerHeight);var c;const h=Math.min(null!=(c=Q.current.getBoundingClientRect().width)?c:0,window.innerWidth),f="left"===w||"right"===w;if(Math.abs(t)>=(f?h:l)*d)return fe(),void(null==s||s(e,!1));null==s||s(e,!0),pe()},onDrag:function(e){if(Q.current&&N){const t="bottom"===w||"right"===w?1:-1,r=(Y.current-($d(w)?e.pageY:e.pageX))*t,i=r>0,s=a&&!u&&!i;if(s&&0===ie)return;const l=Math.abs(r),d=document.querySelector("[data-vaul-drawer-wrapper]");let c=l/("bottom"===w||"top"===w?Z.current:J.current);const h=de(l,i);if(null!==h&&(c=h),s&&c>=1)return;if(!V.current&&!he(e.target,i))return;if(Q.current.classList.add(jd),V.current=!0,Fd(Q.current,{transition:"none"}),Fd(U.current,{transition:"none"}),a&&oe({draggedDistance:r}),i&&!a){const e=function(e){return 8*(Math.log(e+1)-2)}(r),i=Math.min(-1*e,0)*t;return void Fd(Q.current,{transform:$d(w)?`translate3d(0, ${i}px, 0)`:`translate3d(${i}px, 0, 0)`})}const p=1-c;if((le||f&&ie===f-1)&&(null==n||n(e,c),Fd(U.current,{opacity:`${p}`,transition:"none"},!0)),d&&U.current&&o){const e=Math.min(ue()+c*(1-ue()),1),t=8-8*c,r=Math.max(0,14-14*c);Fd(d,{borderRadius:`${t}px`,transform:$d(w)?`scale(${e}) translate3d(0, ${r}px, 0)`:`scale(${e}) translate3d(${r}px, 0, 0)`,transition:"none"},!0)}if(!a){const e=l*t;Fd(Q.current,{transform:$d(w)?`translate3d(0, ${e}px, 0)`:`translate3d(${e}px, 0, 0)`})}}},dismissible:u,shouldAnimate:q,handleOnly:h,isOpen:D,isDragging:N,shouldFade:le,closeDrawer:fe,onNestedDrag:function(e,t){if(t<0)return;const r=(window.innerWidth-Gd)/window.innerWidth,i=r+t*(1-r),n=t*Gd-16;Fd(Q.current,{transform:$d(w)?`scale(${i}) translate3d(0, ${n}px, 0)`:`scale(${i}) translate3d(${n}px, 0, 0)`,transition:"none"})},onNestedOpenChange:function(e){const t=e?(window.innerWidth-Gd)/window.innerWidth:1,r=e?-16:0;W.current&&window.clearTimeout(W.current),Fd(Q.current,{transition:`transform ${zd.DURATION}s cubic-bezier(${zd.EASE.join(",")})`,transform:$d(w)?`scale(${t}) translate3d(0, ${r}px, 0)`:`scale(${t}) translate3d(${r}px, 0, 0)`}),!e&&Q.current&&(W.current=setTimeout(()=>{const e=Bd(Q.current,w);Fd(Q.current,{transition:"none",transform:$d(w)?`translate3d(0, ${e}px, 0)`:`translate3d(${e}px, 0, 0)`})},500))},onNestedRelease:function(e,t){const r=$d(w)?window.innerHeight:window.innerWidth,i=t?(r-Gd)/r:1,n=t?-16:0;t&&Fd(Q.current,{transition:`transform ${zd.DURATION}s cubic-bezier(${zd.EASE.join(",")})`,transform:$d(w)?`scale(${i}) translate3d(0, ${n}px, 0)`:`scale(${i}) translate3d(${n}px, 0, 0)`})},keyboardIsOpen:K,modal:v,snapPointsOffset:ae,activeSnapPointIndex:ie,direction:w,shouldScaleBackground:o,setBackgroundColorOnScale:l,noBodyStyles:E,container:I,autoFocus:R}},i))}const Kd=t.forwardRef(function({...e},r){const{overlayRef:i,snapPoints:n,onRelease:s,shouldFade:a,isOpen:o,modal:l,shouldAnimate:d}=yd(),c=Md(r,i),u=n&&n.length>0;if(!l)return null;const h=t.useCallback(e=>s(e),[s]);return t.createElement(hd,{onMouseUp:h,ref:c,"data-vaul-overlay":"","data-vaul-snap-points":o&&u?"true":"false","data-vaul-snap-points-overlay":o&&a?"true":"false","data-vaul-animate":(null==d?void 0:d.current)?"true":"false",...e})});Kd.displayName="Drawer.Overlay";const qd=t.forwardRef(function({onPointerDownOutside:e,style:r,onOpenAutoFocus:i,...n},s){const{drawerRef:a,onPress:o,onRelease:l,onDrag:d,keyboardIsOpen:u,snapPointsOffset:h,activeSnapPointIndex:f,modal:p,isOpen:m,direction:g,snapPoints:v,container:y,handleOnly:b,shouldAnimate:E,autoFocus:w}=yd(),[S,T]=t.useState(!1),x=Md(s,a),A=t.useRef(null),k=t.useRef(null),L=t.useRef(!1),I=v&&v.length>0;!function(){const{direction:e,isOpen:r,shouldScaleBackground:i,setBackgroundColorOnScale:n,noBodyStyles:s}=yd(),a=t.useRef(null),o=c(()=>document.body.style.backgroundColor,[]);function l(){return(window.innerWidth-26)/window.innerWidth}t.useEffect(()=>{if(r&&i){a.current&&clearTimeout(a.current);const t=document.querySelector("[data-vaul-drawer-wrapper]")||document.querySelector("[vaul-drawer-wrapper]");if(!t)return;n&&!s&&Ud(document.body,{background:"black"}),Ud(t,{transformOrigin:$d(e)?"top":"left",transitionProperty:"transform, border-radius",transitionDuration:`${zd.DURATION}s`,transitionTimingFunction:`cubic-bezier(${zd.EASE.join(",")})`});const r=Ud(t,{borderRadius:"8px",overflow:"hidden",...$d(e)?{transform:`scale(${l()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`}:{transform:`scale(${l()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`}});return()=>{r(),a.current=window.setTimeout(()=>{o?document.body.style.background=o:document.body.style.removeProperty("background")},1e3*zd.DURATION)}}},[r,i,o])}();function R(e){A.current=null,L.current=!1,l(e)}return t.useEffect(()=>{I&&window.requestAnimationFrame(()=>{T(!0)})},[]),t.createElement(fd,{"data-vaul-drawer-direction":g,"data-vaul-drawer":"","data-vaul-delayed-snap-points":S?"true":"false","data-vaul-snap-points":m&&I?"true":"false","data-vaul-custom-container":y?"true":"false","data-vaul-animate":(null==E?void 0:E.current)?"true":"false",...n,ref:x,style:h&&h.length>0?{"--snap-point-height":`${h[null!=f?f:0]}px`,...r}:r,onPointerDown:e=>{b||(null==n.onPointerDown||n.onPointerDown.call(n,e),A.current={x:e.pageX,y:e.pageY},o(e))},onOpenAutoFocus:e=>{null==i||i(e),w||e.preventDefault()},onPointerDownOutside:t=>{null==e||e(t),p&&!t.defaultPrevented?u.current&&(u.current=!1):t.preventDefault()},onFocusOutside:e=>{p||e.preventDefault()},onPointerMove:e=>{if(k.current=e,b)return;if(null==n.onPointerMove||n.onPointerMove.call(n,e),!A.current)return;const t=e.pageY-A.current.y,r=e.pageX-A.current.x,i="touch"===e.pointerType?10:2,s=((e,t,r=0)=>{if(L.current)return!0;const i=Math.abs(e.y),n=Math.abs(e.x),s=n>i,a=["bottom","right"].includes(t)?1:-1;if("left"===t||"right"===t){if(!(e.x*a<0)&&n>=0&&n<=r)return s}else if(!(e.y*a<0)&&i>=0&&i<=r)return!s;return L.current=!0,!0})({x:r,y:t},g,i);s?d(e):(Math.abs(r)>i||Math.abs(t)>i)&&(A.current=null)},onPointerUp:e=>{null==n.onPointerUp||n.onPointerUp.call(n,e),A.current=null,L.current=!1,l(e)},onPointerOut:e=>{null==n.onPointerOut||n.onPointerOut.call(n,e),R(k.current)},onContextMenu:e=>{null==n.onContextMenu||n.onContextMenu.call(n,e),k.current&&R(k.current)}})});qd.displayName="Drawer.Content";const Xd=t.forwardRef(function({preventCycle:e=!1,children:r,...i},n){const{closeDrawer:s,isDragging:a,snapPoints:o,activeSnapPoint:l,setActiveSnapPoint:d,dismissible:c,handleOnly:u,isOpen:h,onPress:f,onDrag:p}=yd(),m=t.useRef(null),g=t.useRef(!1);function v(){m.current&&window.clearTimeout(m.current),g.current=!1}return t.createElement("div",{onClick:function(){g.current?v():window.setTimeout(()=>{!function(){if(a||e||g.current)return void v();if(v(),!o||0===o.length)return void(c||s());if(l===o[o.length-1]&&c)return void s();const t=o.findIndex(e=>e===l);if(-1===t)return;const r=o[t+1];d(r)}()},120)},onPointerCancel:v,onPointerDown:e=>{u&&f(e),m.current=window.setTimeout(()=>{g.current=!0},250)},onPointerMove:e=>{u&&p(e)},ref:n,"data-vaul-drawer-visible":h?"true":"false","data-vaul-handle":"","aria-hidden":"true",...i},t.createElement("span",{"data-vaul-handle-hitarea":"","aria-hidden":"true"},r))});Xd.displayName="Drawer.Handle";const Qd={Root:Yd,NestedRoot:function({onDrag:e,onOpenChange:r,open:i,...n}){const{onNestedDrag:s,onNestedOpenChange:a,onNestedRelease:o}=yd();if(!s)throw new Error("Drawer.NestedRoot must be placed in another drawer");return t.createElement(Yd,{nested:!0,open:i,onClose:()=>{a(!1)},onDrag:(t,r)=>{s(t,r),null==e||e(t,r)},onOpenChange:e=>{e&&a(e),null==r||r(e)},onRelease:o,...n})},Content:qd,Overlay:Kd,Trigger:cd,Portal:function(e){const r=yd(),{container:i=r.container,...n}=e;return t.createElement(ud,{container:i,...n})},Handle:Xd,Close:gd,Title:pd,Description:md};function Zd(t){var r=T(t,[]);return e.createElement(Qd.Root,Object.assign({"data-slot":"drawer"},r))}function Jd(t){var r=T(t,[]);return e.createElement(Qd.Trigger,Object.assign({"data-slot":"drawer-trigger"},r))}function ec(t){var r=T(t,[]);return e.createElement(Qd.Portal,Object.assign({"data-slot":"drawer-portal"},r))}function tc(t){var{className:r}=t,i=T(t,["className"]);return e.createElement(Qd.Overlay,Object.assign({"data-slot":"drawer-overlay",className:wt("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-[999999] bg-black/50",r)},i))}function rc(t){var{className:r,children:i,container:n}=t,s=T(t,["className","children","container"]);return e.createElement(ec,{"data-slot":"drawer-portal",container:null!=n?n:void 0},e.createElement(tc,null),e.createElement(Qd.Content,Object.assign({"data-slot":"drawer-content",className:wt("group/drawer-content bg-background fixed z-[999999] flex h-auto flex-col","data-[vaul-drawer-direction=top]:inset-x-0 data-[vaul-drawer-direction=top]:top-0 data-[vaul-drawer-direction=top]:mb-24 data-[vaul-drawer-direction=top]:max-h-[80vh] data-[vaul-drawer-direction=top]:rounded-b-lg data-[vaul-drawer-direction=top]:border-b","data-[vaul-drawer-direction=bottom]:inset-x-0 data-[vaul-drawer-direction=bottom]:bottom-0 data-[vaul-drawer-direction=bottom]:mt-24 data-[vaul-drawer-direction=bottom]:max-h-[80vh] data-[vaul-drawer-direction=bottom]:rounded-t-lg data-[vaul-drawer-direction=bottom]:border-t","data-[vaul-drawer-direction=right]:inset-y-0 data-[vaul-drawer-direction=right]:right-0 data-[vaul-drawer-direction=right]:w-3/4 data-[vaul-drawer-direction=right]:border-l data-[vaul-drawer-direction=right]:sm:max-w-sm","data-[vaul-drawer-direction=left]:inset-y-0 data-[vaul-drawer-direction=left]:left-0 data-[vaul-drawer-direction=left]:w-3/4 data-[vaul-drawer-direction=left]:border-r data-[vaul-drawer-direction=left]:sm:max-w-sm",r)},s),e.createElement("div",{className:"bg-muted mx-auto mt-4 hidden h-2 w-[100px] shrink-0 rounded-full group-data-[vaul-drawer-direction=bottom]/drawer-content:block"}),i))}function ic(t){var{className:r}=t,i=T(t,["className"]);return e.createElement("div",Object.assign({"data-slot":"drawer-header",className:wt("flex flex-col gap-1.5 p-4",r)},i))}function nc(t){var{className:r}=t,i=T(t,["className"]);return e.createElement(Qd.Title,Object.assign({"data-slot":"drawer-title",className:wt("text-foreground font-semibold",r)},i))}const sc=t.createContext(null),ac=({children:e,products:r,contentId:i})=>{const{isPreview:n}=Fa(),s=t.useContext(sc);return t.createElement(Zd,{direction:"right",fadeFromIndex:0,snapPoints:[1]},t.createElement(Jd,{className:"w-full"},e),t.createElement(rc,{container:s},t.createElement(ic,null,t.createElement(nc,null,"상품 목록")),t.createElement("div",{className:"overflow-y-scroll grid-cols-2 grid items-baseline justify-items-center scrollbar-hide"},r.map(e=>e.linkPath?t.createElement("a",{key:e.productId,className:"p-2 text-gray-800 w-full h-full flex flex-col items-center justify-center no-underline",href:e.linkPath,target:"_blank",onClick:()=>x(void 0,void 0,void 0,function*(){n||(yield Aa({contentId:i,contentProductId:e.eventProductId,productId:e.productId}))})},t.createElement(oc,{product:e})):t.createElement(oc,{key:e.productId,product:e})))))},oc=({product:e})=>{const r=Fa(e=>e.memberOnly&&!e.isMemberLoggedIn);return t.createElement("div",{className:"text-gray-800 w-32"},t.createElement("div",{className:"w-full aspect-square mb-2 border border-[#f4f3f6] rounded "},t.createElement("img",{src:e.thumbPath,alt:e.productName,className:"w-full h-full"})),e.brand&&t.createElement("p",{className:"text-xs text-gray-400 mb-1"},e.brand.brandName),t.createElement("p",{className:"w-full text-[12px] md:text-[15px] mb-1"},e.productName),t.createElement("div",{className:"w-full "},r?t.createElement("span",{className:"font-semibold text-red-500"},"판매가 회원 공개"):t.createElement("div",{className:"flex"},t.createElement("span",{className:"text-sm text-red-500 mr-2 font-semibold"},e.discount,"%"),t.createElement("span",{className:"font-semibold"},St(e.sellingPrice),"원"))))},lc=({products:e,useDrawer:r,contentId:i})=>{const n=c(()=>(e=>{if(e.length>=3)return e;const t=[...e];for(;t.length<3;)t.push(...e);return t})(e),[e]),s=1===(null==e?void 0:e.length);return(null==e?void 0:e.length)?t.createElement("div",{className:"w-full",style:{height:"80px"}},s?t.createElement("div",{className:"bg-white overflow-hidden rounded-xl w-full",style:{borderRadius:"10px",height:"80px"}},r?t.createElement(ac,{products:e,contentId:i},t.createElement(qa,{product:e[0],productsLength:e.length,contentId:i})):t.createElement(qa,{product:e[0],productsLength:e.length,hideMoreBtn:!0,contentId:i})):t.createElement(Xs,{nested:!0,modules:[ua,ea],slidesPerView:1.1,effect:"cards",autoplay:!0,loop:!0,grabCursor:!0,cardsEffect:{rotate:!1},className:"w-full",style:{height:"80px"}},n.map((n,s)=>t.createElement(Qs,{key:s+n.productId,className:"bg-white overflow-hidden rounded-xl",style:{borderRadius:"10px",height:"80px"}},r?t.createElement(ac,{products:e,contentId:i},t.createElement(qa,{product:n,productsLength:e.length,contentId:i})):t.createElement(qa,{product:n,productsLength:e.length,hideMoreBtn:!0,contentId:i}))))):null},dc="https://mbus-asset.s3.ap-northeast-2.amazonaws.com/mcom-player",cc=({shortForm:e,useDrawer:r,isPopup:i,hideProductCarousel:n,shareUrl:s,handleClose:o})=>{const[l,d]=a(!Boolean(i)),[c,u]=a(!0),h=()=>{d(e=>!e)},f=()=>{u(e=>!e)},{logo:p,productsInfo:m,thumbPath:g,title:v,media:y,brand:b,shortsId:E}=e,w=i?"mb-1 max-h-10 max-w-20 object-contain":"mb-1 max-h-10 max-w-28 object-contain",S=e=>{e.stopPropagation()},T=i?t.createElement("div",{className:"justify-self-end flex gap-2"},t.createElement("button",{className:"cursor-pointer text-white",onClick:f},t.createElement("div",{className:"glass-panel flex h-10 w-10 items-center justify-center rounded-full"},c?t.createElement(_r,{size:24}):t.createElement(Or,{size:24}))),t.createElement("button",{className:"cursor-pointer text-white",onClick:h},t.createElement("div",{className:"glass-panel flex h-10 w-10 items-center justify-center rounded-full"},t.createElement("img",{src:`${dc}/${l?"sound_off":"sound"}.png`,alt:l?"muted":"volume",width:24,height:24,className:"block h-6 w-6 object-contain"}))),o?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"},t.createElement($r,{size:24}))):null):t.createElement("div",{className:"flex flex-col gap-3 items-end"},t.createElement("button",{type:"button",className:"text-white",onClick:e=>{S(e),h()},"aria-label":l?"음소거 해제":"음소거"},t.createElement("div",{className:"glass-panel flex h-10 w-10 items-center justify-center rounded-full"},t.createElement("img",{src:`${dc}/${l?"sound_off":"sound"}.png`,alt:l?"muted":"volume",width:24,height:24,className:"block h-6 w-6 object-contain"}))),o?t.createElement("button",{type:"button",className:"text-white",onClick:e=>{S(e),o()},"aria-label":"닫기"},t.createElement("div",{className:"glass-panel flex h-10 w-10 items-center justify-center rounded-full"},t.createElement($r,{size:24}))):null);return t.createElement("div",{className:"h-full w-full text-sm overflow-hidden text-white relative",onClick:i?void 0:f},t.createElement("div",{className:"pointer-events-none absolute inset-0 z-[1] flex h-full w-full flex-col justify-between bg-gradient-to-b from-black/40 via-transparent to-black/40 p-4"},t.createElement("div",{className:"flex gap-2 justify-between pointer-events-auto",onClick:S},t.createElement("div",null,(null==p?void 0:p.thumbPath)?t.createElement("img",{className:w,src:p.thumbPath,alt:p.logoName,width:100,height:100}):null),T),t.createElement("div",{className:"h-full w-full"}),t.createElement("div",{className:"mb-6 pointer-events-auto",onClick:S},t.createElement("div",{className:"flex justify-between items-end mb-3 gap-3"},t.createElement("div",{className:"w-full"},b&&t.createElement("div",{className:"items-center flex gap-3 mb-2"},t.createElement("div",{className:"w-14 h-14 bg-white rounded-full border overflow-hidden shrink-0"},t.createElement("img",{src:b.thumbPath,alt:b.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==b?void 0:b.brandName)),t.createElement("p",{className:"text-start text-base line-clamp-2"},v)),t.createElement("div",{className:"flex flex-col gap-4 items-center"},t.createElement(Ba,{shortsId:E}),t.createElement("div",{className:"flex items-center justify-center"},t.createElement(Ka,{shortForm:e,shareUrl:s})))),!n&&(null==m?void 0:m.length)>0&&t.createElement(lc,{products:m,useDrawer:r,contentId:e.shortsId}))),t.createElement(L,{file:Tt(null==y?void 0:y.objectId),thumbnail:`${Rt(g)}`,mute:l,isVertical:(null==y?void 0:y.height)>(null==y?void 0:y.width),play:c}))},uc="cursor-pointer text-zinc-500",hc=e=>{const{collection:i,shortform:n,setShortform:s}=e,a=r(null);return t.createElement("div",{className:"mx-10 flex h-full gap-4"},t.createElement("div",{className:"self-center flex gap-4 flex-col"},t.createElement(Pr,{size:44,strokeWidth:1,className:uc,onClick:()=>{var e;null===(e=a.current)||void 0===e||e.swiper.slidePrev()}}),t.createElement(Lr,{size:44,strokeWidth:1,className:uc,onClick:()=>{var e;null===(e=a.current)||void 0===e||e.swiper.slideNext()}})),t.createElement("div",{className:"h-full aspect-[9/16]"},t.createElement(Xs,{modules:[Zs,oa],mousewheel:!0,direction:"vertical",slidesPerView:1,ref:a,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(Qs,{key:e.shortsId},t.createElement("div",{className:"flex justify-center gap-3 h-full w-full"},n.shortsId===e.shortsId&&t.createElement("div",{className:"h-full absolute z-[999] w-full bg-white"},t.createElement(cc,{shortForm:n,hideProductCarousel:!0})),t.createElement("div",{className:"h-full aspect-[9/16]"},t.createElement("img",{src:Rt(e.thumbPath),alt:e.title,className:"w-full h-full bg-black "+(e.media.width>e.media.height?"object-contain":"object-cover")}))))))))},fc=({collection:e,playerSettings:r})=>{const[i,n]=a(e.contents[0]);return t.createElement("div",{className:"w-full h-full aspect-[9/16]"},t.createElement(Xs,{modules:[Zs,oa],loop:!0,mousewheel:!0,direction:"vertical",touchEventsTarget:"container",slidesPerView:1,onSlideChangeTransitionEnd:t=>{const r=e.contents[t.realIndex];n(Object.assign({},r))},className:"h-full"},e.contents.map(e=>t.createElement(Qs,{key:e.shortsId,className:"rounded-xl overflow-hidden"},i.shortsId===e.shortsId&&t.createElement("div",{className:"h-full rounded-xl absolute z-[999] w-full"},t.createElement(cc,{shortForm:i})),t.createElement("img",{src:Rt(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 pc='/*! 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-sm:24rem;--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)}.top-0{top:calc(var(--spacing)*0)}.top-1\\/2{top:50%}.top-4{top:calc(var(--spacing)*4)}.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)}.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-\\[999\\]{z-index:999}.z-\\[999999\\]{z-index:999999}.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-10{margin-inline:calc(var(--spacing)*10)}.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)}.mt-auto{margin-top:auto}.mr-2{margin-right:calc(var(--spacing)*2)}.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-2{height:calc(var(--spacing)*2)}.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-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-auto{height:auto}.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%}.\\!w-auto{width:auto!important}.w-4{width:calc(var(--spacing)*4)}.w-4\\/5{width:80%}.w-6{width:calc(var(--spacing)*6)}.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-32{width:calc(var(--spacing)*32)}.w-36{width:calc(var(--spacing)*36)}.w-\\[24px\\]{width:24px}.w-\\[100px\\]{width:100px}.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-\\[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-baseline{align-items:baseline}.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}.justify-items-center{justify-items:center}.gap-1{gap:calc(var(--spacing)*1)}.gap-1\\.5{gap:calc(var(--spacing)*1.5)}.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-y-auto{overflow-y:auto}.overflow-y-scroll{overflow-y:scroll}.rounded{border-radius:.25rem}.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-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}.border-\\[\\#f4f3f6\\]{border-color:#f4f3f6}.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-background{background-color:var(--background)}.bg-black{background-color:var(--color-black)}.bg-black\\/50{background-color:color-mix(in oklab,var(--color-black) 50%,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-muted{background-color:var(--muted)}.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}.p-0{padding:calc(var(--spacing)*0)}.p-1{padding:calc(var(--spacing)*1)}.p-2{padding:calc(var(--spacing)*2)}.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-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-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-\\[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-foreground{color:var(--foreground)}.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}.no-underline{text-decoration-line:none}.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}.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}.group-data-\\[vaul-drawer-direction\\=bottom\\]\\/drawer-content\\:block{&:is(:where(.group\\/drawer-content)[data-vaul-drawer-direction=bottom] *){display:block}}.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\\=closed\\]\\:animate-out{&[data-state=closed]{--tw-exit-opacity:initial;--tw-exit-scale:initial;--tw-exit-rotate:initial;--tw-exit-translate-x:initial;--tw-exit-translate-y:initial;animation-duration:.15s;animation-name:exit}}.data-\\[state\\=closed\\]\\:fade-out-0{&[data-state=closed]{--tw-exit-opacity:0}}.data-\\[state\\=open\\]\\:animate-in{&[data-state=open]{--tw-enter-opacity:initial;--tw-enter-scale:initial;--tw-enter-rotate:initial;--tw-enter-translate-x:initial;--tw-enter-translate-y:initial;animation-duration:.15s;animation-name:enter}}.data-\\[state\\=open\\]\\:fade-in-0{&[data-state=open]{--tw-enter-opacity:0}}.data-\\[vaul-drawer-direction\\=bottom\\]\\:inset-x-0{&[data-vaul-drawer-direction=bottom]{inset-inline:calc(var(--spacing)*0)}}.data-\\[vaul-drawer-direction\\=bottom\\]\\:bottom-0{&[data-vaul-drawer-direction=bottom]{bottom:calc(var(--spacing)*0)}}.data-\\[vaul-drawer-direction\\=bottom\\]\\:mt-24{&[data-vaul-drawer-direction=bottom]{margin-top:calc(var(--spacing)*24)}}.data-\\[vaul-drawer-direction\\=bottom\\]\\:max-h-\\[80vh\\]{&[data-vaul-drawer-direction=bottom]{max-height:80vh}}.data-\\[vaul-drawer-direction\\=bottom\\]\\:rounded-t-lg{&[data-vaul-drawer-direction=bottom]{border-top-left-radius:var(--radius);border-top-right-radius:var(--radius)}}.data-\\[vaul-drawer-direction\\=bottom\\]\\:border-t{&[data-vaul-drawer-direction=bottom]{border-top-style:var(--tw-border-style);border-top-width:1px}}.data-\\[vaul-drawer-direction\\=left\\]\\:inset-y-0{&[data-vaul-drawer-direction=left]{inset-block:calc(var(--spacing)*0)}}.data-\\[vaul-drawer-direction\\=left\\]\\:left-0{&[data-vaul-drawer-direction=left]{left:calc(var(--spacing)*0)}}.data-\\[vaul-drawer-direction\\=left\\]\\:w-3\\/4{&[data-vaul-drawer-direction=left]{width:75%}}.data-\\[vaul-drawer-direction\\=left\\]\\:border-r{&[data-vaul-drawer-direction=left]{border-right-style:var(--tw-border-style);border-right-width:1px}}.data-\\[vaul-drawer-direction\\=right\\]\\:inset-y-0{&[data-vaul-drawer-direction=right]{inset-block:calc(var(--spacing)*0)}}.data-\\[vaul-drawer-direction\\=right\\]\\:right-0{&[data-vaul-drawer-direction=right]{right:calc(var(--spacing)*0)}}.data-\\[vaul-drawer-direction\\=right\\]\\:w-3\\/4{&[data-vaul-drawer-direction=right]{width:75%}}.data-\\[vaul-drawer-direction\\=right\\]\\:border-l{&[data-vaul-drawer-direction=right]{border-left-style:var(--tw-border-style);border-left-width:1px}}.data-\\[vaul-drawer-direction\\=top\\]\\:inset-x-0{&[data-vaul-drawer-direction=top]{inset-inline:calc(var(--spacing)*0)}}.data-\\[vaul-drawer-direction\\=top\\]\\:top-0{&[data-vaul-drawer-direction=top]{top:calc(var(--spacing)*0)}}.data-\\[vaul-drawer-direction\\=top\\]\\:mb-24{&[data-vaul-drawer-direction=top]{margin-bottom:calc(var(--spacing)*24)}}.data-\\[vaul-drawer-direction\\=top\\]\\:max-h-\\[80vh\\]{&[data-vaul-drawer-direction=top]{max-height:80vh}}.data-\\[vaul-drawer-direction\\=top\\]\\:rounded-b-lg{&[data-vaul-drawer-direction=top]{border-bottom-left-radius:var(--radius);border-bottom-right-radius:var(--radius)}}.data-\\[vaul-drawer-direction\\=top\\]\\:border-b{&[data-vaul-drawer-direction=top]{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}}.data-\\[vaul-drawer-direction\\=left\\]\\:sm\\:max-w-sm,.sm\\:flex-row,.sm\\:justify-end,.sm\\:mx-0{&[data-vaul-drawer-direction=left]{@media (width >= 40rem){max-width:var(--container-sm)}}}.data-\\[vaul-drawer-direction\\=right\\]\\:sm\\:max-w-sm{&[data-vaul-drawer-direction=right]{@media (width >= 40rem){max-width:var(--container-sm)}}}.\\[\\&\\[data-state\\=open\\]\\>svg\\]\\:rotate-180,.lg\\:px-5,.md\\:block,.md\\:hidden,.md\\:px-4,.md\\:text-\\[15px\\]{&[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);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)}.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-dialog-container{max-height:70vh;max-width:min(82vw,500px);overflow-y:auto;width:100%}.border{border:1px solid oklch(.922 0 0)}@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-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)}}',mc=pc.trim().length>0,gc="undefined"!=typeof window&&"adoptedStyleSheets"in Document.prototype&&"undefined"!=typeof CSSStyleSheet&&"replaceSync"in CSSStyleSheet.prototype;let vc=null;function yc(e){return vc||(vc=new CSSStyleSheet,vc.replaceSync(e)),vc}function bc(){return mc?pc: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 Ec=({extra:e})=>{const r=bc()+(e?"\n"+e:"");return t.createElement("style",null,r)};const wc=Na(e=>({open:!1,setOpen:t=>e({open:t})}));function Sc(){const[e,n]=t.useState(null),s=r(null),{open:a,setOpen:o}=wc();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=bc();if(gc)e.adoptedStyleSheets=[yc(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 Tc=e=>{const{isMobile:r}=e,n=Fa(e=>e.setIsPreview),[s,o]=a("collection"in e?e.collection.contents[0]:null);if(i(()=>{var t;const r=Fa.getState().isPreview;return n(null===(t=e.isPreview)||void 0===t||t),()=>{n(r)}},[e.isPreview,n]),r){if("shortform"in e)return t.createElement(cc,{shortForm:e.shortform});if(e.collection)return t.createElement(fc,{collection:e.collection,playerSettings:e.collection.player.shoppingPlayer})}if("shortform"in e){const{layout:r}=e.shortform.player,i=e.shortform.player.shoppingPlayer;switch(r){case br.PLATFORM:return t.createElement(Cn,{shortform:e.shortform,playerSettings:i,player:t.createElement("div",{className:"aspect-[9/16] h-full rounded-xl border overflow-hidden"},t.createElement(cc,{shortForm:e.shortform,hideProductCarousel:!0}))});case br.HORIZONTAL:return t.createElement(t.Fragment,null,t.createElement("div",{className:"md:hidden h-full w-full"},t.createElement(cc,{shortForm:e.shortform})),t.createElement("div",{className:"hidden md:block h-full w-full"},t.createElement(pa,{shortform:e.shortform,playerSettings:i,player:t.createElement(cc,{shortForm:e.shortform,hideProductCarousel:!0})})));case br.VERTICAL:return t.createElement(ga,{shortform:e.shortform,playerSettings:i,player:t.createElement("div",{className:"aspect-[9/16] h-full"},t.createElement(cc,{shortForm:e.shortform,hideProductCarousel:!0}))});case br.GRID:return t.createElement(ya,{shortform:e.shortform,playerSettings:i,player:t.createElement(cc,{shortForm:e.shortform,hideProductCarousel:!0})})}}else{if(!e.collection||!s)return null;{const{layout:r}=e.collection.player,i=e.collection.player.shoppingPlayer;switch(r){case br.PLATFORM:return t.createElement(Cn,{shortform:s,playerSettings:i,player:t.createElement("div",{className:"w-full flex items-center justify-center gap-4",style:{height:"calc(-220px + 100vh)"}},t.createElement(Ea,{collection:e.collection,playerSettings:i,shortform:s,setShortform:o}))});case br.HORIZONTAL:return t.createElement(pa,{shortform:s,playerSettings:Object.assign({},i),player:t.createElement("div",{className:"h-full aspect-[9/16]"},t.createElement(hc,{collection:e.collection,playerSettings:i,shortform:s,setShortform:o}))});case br.VERTICAL:return t.createElement(ga,{playerSettings:Object.assign({},i),shortform:s,player:t.createElement(hc,{collection:e.collection,playerSettings:i,shortform:s,setShortform:o})});case br.GRID:return t.createElement(ya,{shortform:s,playerSettings:Object.assign({},i),player:t.createElement(hc,{collection:e.collection,playerSettings:i,shortform:s,setShortform:o})})}}}},xc=e=>{const{container:r}=Sc();return r?t.createElement(Er.div,null,t.createElement(Ec,null),t.createElement(sc.Provider,{value:r},t.createElement(Tc,Object.assign({},e)))):null},Ac=e=>{const{container:r}=Sc();return r?t.createElement(Er.div,null,t.createElement(Ec,null),t.createElement(sc.Provider,{value:r},t.createElement(cc,Object.assign({},e)))):null},kc=e=>(document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}),Lc=()=>document.visibilityState,Ic=()=>{throw Error("useVisibilityChange is a client-only hook")};function Rc(){return"visible"===e.useSyncExternalStore(kc,Lc,Ic)}var Pc=(e,t,n=!0)=>{const s=r(e),a=r(null),o=()=>{a.current&&(clearInterval(a.current),a.current=null)},l=u(()=>{a.current||(a.current=setInterval(()=>s.current(),t))},[t]);return i(()=>{s.current=e},[e]),i(()=>(n&&l(),()=>o()),[l,n]),{clear:o,run:l}};const Cc=()=>{const[e,t]=a(0);Pc(()=>{t(e=>e+1)},1e3);return{playtime:e,resetPlaytime:()=>t(0)}},Dc=t.createContext(null),_c=({children:e})=>{const r=t.useRef(null);return r.current||(r.current=Da(e=>({collection:null,setCollection:t=>e({collection:t}),nextKey:"",setNextKey:t=>e({nextKey:t}),isFetching:!1,setIsFetching:t=>e({isFetching:t})}))),t.createElement(Dc.Provider,{value:r.current},e)},Oc=()=>(e=>{const r=t.useContext(Dc);if(!r)throw new Error("Missing CollectionProvider");return Oa(r,e)})(e=>e),Mc=(e,t)=>{const{collection:r,setCollection:n,isFetching:s,setIsFetching:a,nextKey:o,setNextKey:l}=Oc(),{isPreview:d}=Fa(),c=(null==e?void 0:e.media)?e.media.duration.split(":").reduce((e,t,r)=>e+ +t*60**(2-r),0):0;const{resetPlaytime:u,playtime:h}=Cc(),{playtime:f,resetPlaytime:p}=Cc(),m=Rc(),g=()=>{if(!r)return;const{colId:t,uuid:i,userId:n}=r,s=Ge,a=Math.floor((new Date).getTime()/1e3);localStorage.setItem(s,a.toString()),d||(xa({contentId:t,uuid:i,type:Et.COLLECTION,userId:n,playtime:f}),e&&xa({contentId:e.shortsId,uuid:e.uuid,type:Et.SHORTS,userId:n,playtime:h,isFinished:h>=c}),p(),u())};i(()=>{m||g()},[m]);return{onSlideChange:i=>x(void 0,void 0,void 0,function*(){if(e&&r&&(yield(e=>x(void 0,void 0,void 0,function*(){var t,i;if(!r)return;const{contents:d,count:c}=r;if((null!=c?c:Number.MAX_SAFE_INTEGER)>d.length&&e>=d.length-5&&!s){a(!0);try{const e=yield Ia({collectionId:r.colId,nextKey:o});if(!e||!(null===(t=e.contents)||void 0===t?void 0:t.length))return;l((null===(i=e.contents.at(-1))||void 0===i?void 0:i.shortsId)||"");const s=new Set(r.contents.map(e=>e.shortsId)),a=e.contents.filter(e=>!s.has(e.shortsId));if(!a.length)return;const d=r.contents.concat(a);n(Object.assign(Object.assign({},r),{contents:d}))}catch(e){console.error(e)}finally{a(!1)}}}))(i),!d)){const{shortsId:n,uuid:s,userId:a}=e;xa({contentId:n,uuid:s,type:Et.SHORTS,playtime:h,isFinished:h>=c,userId:a}),u();const o=kt(),l=r.contents[i];t(Object.assign(Object.assign({},l),{uuid:o})),yield Ta({contentId:l.shortsId,uuid:o,type:Et.SHORTS,userId:l.userId,isFirstPlay:!Lt(l.shortsId)})}}),onCollectionClose:g}};function Nc(){const[e,t]=a({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 Fc=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(${Rt(e.thumbPath)})`}},t.createElement(cc,{handleClose:i,shortForm:e,useDrawer:!1,isPopup:!0,shareUrl:r})))),$c=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}`})`}})),Bc=({shortform:e,shareUrl:r,handleClose:i})=>{const{isActive:n}=d(Ks),s=d(qs),a=Nc().width<430||Wa.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(Ir,{size:28})),t.createElement(Fc,{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(Rr,{size:28}))):t.createElement($c,{shortform:e})))},{PLAYER_BACK_BASE_URL:Uc}=gt(),zc=({collection:e,initialShortsId:i,onSlideChange:n,onClosePlayer:s})=>{var a;const o=c(()=>Math.max(e.contents.findIndex(e=>e.shortsId===i),0),[e.contents,i]),l=e.contents.length,d=Math.max(l,10),u=null!==(a=Nc().width)&&void 0!==a?a:0,h=u<430||Wa.isMobile,f=h?1:u>=1200?4:u>=900?3:2,p=c(()=>(e=>{const t=[...e];for(;t.length<d;)t.push(...e);return t})(e.contents),[e.contents]),m=r(null);return t.createElement("div",{style:{minHeight:100,minWidth:300},className:"w-full"},t.createElement(Xs,{style:{minHeight:100,overflow:"visible"},initialSlide:o,ref:m,lazyPreloadPrevNext:2,className:"w-full",spaceBetween:h?8:u>=1200?24:u>=900?25:16,slidesPerView:f,grabCursor:!0,centeredSlides:1!==f,onSlideChangeTransitionEnd:t=>{const r=t.realIndex%l;null==n||n(r);const i=e.contents[(r+1)%l];var s;s=Tt(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:!0,slideToClickedSlide:!0},p.map((r,i)=>t.createElement(Qs,{key:i},t.createElement(Bc,{handleClose:s,shortform:r,shareUrl:`${Uc}/collection/${e.colId}?start=${r.shortsId}&layout=5`})))))},Gc=({shortform:e,onThumbnailClick:n,onCardView:s,iconSize:a,exposeTitle:o,borderLine:l})=>{const d=c(()=>It(l),[l]),u=r(null);i(()=>{const t=u.current;if(!t)return;const r=new IntersectionObserver(([t])=>{t.isIntersecting&&(s(e.shortsId),r.disconnect())},{threshold:.5});return r.observe(t),()=>r.disconnect()},[e.shortsId,s]);const h=d?{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",{ref:u,className:"flex flex-col w-full gap-2",onClick:()=>n(e.shortsId)},t.createElement("div",{className:"rounded-full overflow-hidden cursor-pointer",style:Object.assign({width:a,height:a,padding:4},h)},t.createElement("img",{src:Rt(e.thumbPath),alt:"thumbnail",className:"w-full h-full object-cover block rounded-full"})),o&&t.createElement("span",{style:{width:a},className:"text-black overflow-hidden text-[12px] whitespace-nowrap text-center text-clip cursor-default"},e.title))},jc=({product:e,productLength:r,hideMoreBadge:i=!1,contentId:n,lineClamp:s,showMoreBtn:a=!1,openProductPopup:o})=>{const{isPreview:l}=Fa();return t.createElement(t.Fragment,null,t.createElement("div",{className:"product-banner border mbus-border",onClick:()=>x(void 0,void 0,void 0,function*(){i&&(window.open(e.linkPath,"_blank"),l||(yield Aa({contentProductId:e.eventProductId,contentId:n,productId:e.productId})))})},t.createElement("span",{className:"product-banner__clip","aria-hidden":!0},t.createElement("span",{className:"product-banner__sheen"})),t.createElement("div",{className:"relative",style:{width:"40%",minWidth:"40%"}},t.createElement("img",{style:{borderRadius:"0.625rem"},className:"aspect-square rounded-lg object-cover w-full",src:Rt(e.thumbPath),alt:e.productName}),!i&&t.createElement("p",{className:"absolute text-white rounded-lg",style:{backgroundColor:"#797979",top:-10,right:-10,padding:"2px 4px",fontSize:"10px",borderRadius:"0.625rem"}},"+",r)),t.createElement("div",{style:{position:"relative",zIndex:2,minWidth:0,flex:1,paddingRight:24}},t.createElement("p",{style:{display:"-webkit-box",WebkitLineClamp:s||2,WebkitBoxOrient:"vertical",overflow:"hidden",wordBreak:"break-word",fontWeight:600,color:"#494949"}},e.productName)),t.createElement("span",{className:"product-banner__arrow","aria-hidden":!0},"›")),a&&r>1&&t.createElement("div",{onClick:o,className:" flex items-center justify-center border mbus-border cursor-pointer",style:{borderRadius:"0.625rem",padding:"10px",backgroundColor:"#f5f5f5",fontWeight:600}},"+ 더보기 (",r,")"))},Hc=({products:e,iconSize:r,contentId:i,setSelectedProducts:n,showMoreBtn:s,hideMoreBadge:a})=>{const{setOpen:o}=wc(),l=()=>{n({productsInfo:e,shortsId:i}),o(!0)};return t.createElement(t.Fragment,null,t.createElement("div",{onClick:()=>x(void 0,void 0,void 0,function*(){1===e.length||s||l()}),className:"flex flex-col gap-2 mt-4 text-gray-800",style:{maxWidth:r||"100%",fontSize:13}},t.createElement(jc,{showMoreBtn:s,lineClamp:2,product:e[0],contentId:i,productLength:e.length,hideMoreBadge:null!=a?a:1===e.length,openProductPopup:l})))},Vc=({product:e,maxWidth:r="100%",height:i,cardWidth:n})=>{const s=Fa(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:Rt(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}},St(e.sellingPrice),"원"),t.createElement("span",{style:{color:"#9ca3af",textDecoration:"line-through"}},St(e.price),"원")):t.createElement("span",{style:{color:"#dc2626",fontWeight:600}},St(e.sellingPrice),"원"):t.createElement("span",{style:{color:"#dc2626",fontWeight:600}},St(e.price),"원")})())))},Wc=({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"})),Yc=({shortform:e,onThumbnailClick:n,onCardView:s,iconSize:o,exposeTitle:l,rounded:d,borderLine:u,titlePosition:h,exposeProductBanner:f,setSelectedProducts:p,iconRatio:m,hoverPlay:g,exposeProductBadge:v})=>{var y;const b=c(()=>It(u),[u]),[E,w]=a(!1),{API_BASE_URL:S}=gt(),T=r(null);return i(()=>{const t=T.current;if(!t)return;const r=new IntersectionObserver(([t])=>{t.isIntersecting&&(s(e.shortsId),r.disconnect())},{threshold:.5});return r.observe(t),()=>r.disconnect()},[e.shortsId,s]),t.createElement("div",{className:"relative"},t.createElement("div",{ref:T,onMouseEnter:()=>{w(!0),s(e.shortsId)},onMouseLeave:()=>w(!1),onClick:()=>n(e.shortsId),style:Object.assign({width:o,aspectRatio:m},d&&{borderRadius:"10px"}),className:`cursor-pointer p-[3px] ${d&&"rounded-xl"} ${b&&"bg-insta"} relative overflow-hidden`},E&&g&&t.createElement(Wc,{playUrl:`${S}/direct/${e.media.objectId}`,poster:Rt(e.thumbPath)}),t.createElement("img",{style:Object.assign({},d&&{borderRadius:"10px"}),src:Rt(e.thumbPath),alt:"thumbnail",className:`w-full h-full object-cover ${d&&"rounded-xl"}`}),v&&(null===(y=e.productsInfo)||void 0===y?void 0:y.length)>0&&!(g&&E)&&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(Vc,{product:e.productsInfo[0],maxWidth:"100%",height:"100%",cardWidth:o})))),l&&!(g&&E&&h===Be.INNER)&&t.createElement("p",{style:Object.assign({width:o,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},h===Be.INNER&&v?{bottom:"22%"}:{}),className:`my-2 ${h===Be.INNER?"absolute bottom-0 left-0 text-white px-2 z-10":""} text-[12px] cursor-default truncate`},e.title),f&&t.createElement(Hc,{setSelectedProducts:p,products:e.productsInfo,iconSize:o,contentId:e.shortsId}))},Kc=e=>{const{iconShape:r,collection:i}=e;return r===Ne.MANY?t.createElement(qc,Object.assign({},e)):t.createElement(Xc,Object.assign({},e,{shortform:i.contents[0]}))},qc=e=>{const{collection:r}=e,{thumbnailAutoPlay:i}=e,{setCollection:n,nextKey:s,setNextKey:a,isFetching:o,setIsFetching:l}=Oc();return t.createElement(Xs,{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 Ia({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?[ea]:[],autoplay:!!i&&{delay:3e3,disableOnInteraction:!1,pauseOnMouseEnter:!0},loop:i||void 0},null==r?void 0:r.contents.map(r=>t.createElement(Qs,{key:r.shortsId,className:"!w-auto"},t.createElement(Xc,Object.assign({},e,{shortform:r})))))},Xc=e=>{const{iconForm:r}=e;return r===Me.INSTA?t.createElement(Gc,Object.assign({},e)):t.createElement(Yc,Object.assign({},e))};function Qc(e,t,{checkForDefaultPrevented:r=!0}={}){return function(i){if(e?.(i),!1===r||!i.defaultPrevented)return t?.(i)}}function Zc(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function Jc(...e){return t=>{let r=!1;const i=e.map(e=>{const i=Zc(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():Zc(e[t],null)}}}}function eu(...t){return e.useCallback(Jc(...t),t)}function tu(...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 ru=globalThis?.document?e.useLayoutEffect:()=>{},iu=e[" useId ".trim().toString()]||(()=>{}),nu=0;function su(t){const[r,i]=e.useState(iu());return ru(()=>{t||i(e=>e??String(nu++))},[t]),t||(r?`radix-${r}`:"")}var au=e[" useInsertionEffect ".trim().toString()]||ru;function ou({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 au(()=>{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,d=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 c=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[d,c]}function lu(e,t,{checkForDefaultPrevented:r=!0}={}){return function(i){if(e?.(i),!1===r||!i.defaultPrevented)return t?.(i)}}function du(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function cu(...e){return t=>{let r=!1;const i=e.map(e=>{const i=du(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():du(e[t],null)}}}}function uu(...t){return e.useCallback(cu(...t),t)}function hu(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?cu(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 fu=Symbol("radix.slottable");function pu(t){return e.isValidElement(t)&&"function"==typeof t.type&&"__radixId"in t.type&&t.type.__radixId===fu}var mu=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((t,r)=>{const i=function(t){const r=hu(t),i=e.forwardRef((t,i)=>{const{children:n,...s}=t,a=e.Children.toArray(n),o=a.find(pu);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}(`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}},{});var gu,vu="dismissableLayer.update",yu="dismissableLayer.pointerDownOutside",bu="dismissableLayer.focusOutside",Eu=e.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),wu=e.forwardRef((t,r)=>{const{disableOutsidePointerEvents:i=!1,onEscapeKeyDown:n,onPointerDownOutside:s,onFocusOutside:a,onInteractOutside:o,onDismiss:l,...d}=t,c=e.useContext(Eu),[u,h]=e.useState(null),f=u?.ownerDocument??globalThis?.document,[,p]=e.useState({}),m=uu(r,e=>h(e)),g=Array.from(c.layers),[v]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),y=g.indexOf(v),E=u?g.indexOf(u):-1,w=c.layersWithOutsidePointerEventsDisabled.size>0,S=E>=y,T=function(t,r=globalThis?.document){const i=fo(t),n=e.useRef(!1),s=e.useRef(()=>{});return e.useEffect(()=>{const e=e=>{if(e.target&&!n.current){let t=function(){Tu(yu,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=[...c.branches].some(e=>e.contains(t));S&&!r&&(s?.(e),o?.(e),e.defaultPrevented||l?.())},f),x=function(t,r=globalThis?.document){const i=fo(t),n=e.useRef(!1);return e.useEffect(()=>{const e=e=>{if(e.target&&!n.current){Tu(bu,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;[...c.branches].some(e=>e.contains(t))||(a?.(e),o?.(e),e.defaultPrevented||l?.())},f);return po(e=>{E===c.layers.size-1&&(n?.(e),!e.defaultPrevented&&l&&(e.preventDefault(),l()))},f),e.useEffect(()=>{if(u)return i&&(0===c.layersWithOutsidePointerEventsDisabled.size&&(gu=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(u)),c.layers.add(u),Su(),()=>{i&&1===c.layersWithOutsidePointerEventsDisabled.size&&(f.body.style.pointerEvents=gu)}},[u,f,i,c]),e.useEffect(()=>()=>{u&&(c.layers.delete(u),c.layersWithOutsidePointerEventsDisabled.delete(u),Su())},[u,c]),e.useEffect(()=>{const e=()=>p({});return document.addEventListener(vu,e),()=>document.removeEventListener(vu,e)},[]),b(mu.div,{...d,ref:m,style:{pointerEvents:w?S?"auto":"none":void 0,...t.style},onFocusCapture:lu(t.onFocusCapture,x.onFocusCapture),onBlurCapture:lu(t.onBlurCapture,x.onBlurCapture),onPointerDownCapture:lu(t.onPointerDownCapture,T.onPointerDownCapture)})});wu.displayName="DismissableLayer";function Su(){const e=new CustomEvent(vu);document.dispatchEvent(e)}function Tu(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(Eu),n=e.useRef(null),s=uu(r,n);return e.useEffect(()=>{const e=n.current;if(e)return i.branches.add(e),()=>{i.branches.delete(e)}},[i.branches]),b(mu.div,{...t,ref:s})}).displayName="DismissableLayerBranch";var xu=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,d]=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=Au(n.current);a.current="mounted"===l?e:"none"},[l]),ru(()=>{const e=n.current,r=s.current;if(r!==t){const i=a.current,n=Au(e);if(t)d("MOUNT");else if("none"===n||"none"===e?.display)d("UNMOUNT");else{d(r&&i!==n?"ANIMATION_OUT":"UNMOUNT")}s.current=t}},[t,d]),ru(()=>{if(r){let e;const t=r.ownerDocument.defaultView??window,i=i=>{const a=Au(n.current).includes(i.animationName);if(i.target===r&&a&&(d("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=Au(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)}}d("ANIMATION_END")},[r,d]),{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=eu(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 Au(e){return e?.animationName||"none"}function ku(t){const r=Lu(t),i=e.forwardRef((t,i)=>{const{children:n,...s}=t,a=e.Children.toArray(n),o=a.find(Ru);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 Lu(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?Jc(r,t):t),e.cloneElement(i,s)}return e.Children.count(i)>1?e.Children.only(null):null});return r.displayName=`${t}.SlotClone`,r}xu.displayName="Presence";var Iu=Symbol("radix.slottable");function Ru(t){return e.isValidElement(t)&&"function"==typeof t.type&&"__radixId"in t.type&&t.type.__radixId===Iu}var Pu=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((t,r)=>{const i=ku(`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}},{}),Cu=0;function Du(){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 _u="Dialog",[Ou,Mu]=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,d=e.useMemo(()=>o,Object.values(o));return b(l.Provider,{value:d,children:n})};return o.displayName=r+"Provider",[o,function(i,o){const l=o?.[t]?.[a]||s,d=e.useContext(l);if(d)return d;if(void 0!==n)return n;throw new Error(`\`${i}\` must be used within \`${r}\``)}]},tu(n,...r)]}(_u),[Nu,Fu]=Ou(_u),$u=t=>{const{__scopeDialog:r,children:i,open:n,defaultOpen:s,onOpenChange:a,modal:o=!0}=t,l=e.useRef(null),d=e.useRef(null),[c,u]=ou({prop:n,defaultProp:s??!1,onChange:a,caller:_u});return b(Nu,{scope:r,triggerRef:l,contentRef:d,contentId:su(),titleId:su(),descriptionId:su(),open:c,onOpenChange:u,onOpenToggle:e.useCallback(()=>u(e=>!e),[u]),modal:o,children:i})};$u.displayName=_u;var Bu="DialogTrigger";e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=Fu(Bu,r),s=eu(t,n.triggerRef);return b(Pu.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":sh(n.open),...i,ref:s,onClick:Qc(e.onClick,n.onOpenToggle)})}).displayName=Bu;var Uu="DialogPortal",[zu,Gu]=Ou(Uu,{forceMount:void 0}),ju=t=>{const{__scopeDialog:r,forceMount:i,children:n,container:s}=t,a=Fu(Uu,r);return b(zu,{scope:r,forceMount:i,children:e.Children.map(n,e=>b(xu,{present:i||a.open,children:b(_o,{asChild:!0,container:s,children:e})}))})};ju.displayName=Uu;var Hu="DialogOverlay",Vu=e.forwardRef((e,t)=>{const r=Gu(Hu,e.__scopeDialog),{forceMount:i=r.forceMount,...n}=e,s=Fu(Hu,e.__scopeDialog);return s.modal?b(xu,{present:i||s.open,children:b(Yu,{...n,ref:t})}):null});Vu.displayName=Hu;var Wu=ku("DialogOverlay.RemoveScroll"),Yu=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=Fu(Hu,r);return b(Sl,{as:Wu,allowPinchZoom:!0,shards:[n.contentRef],children:b(Pu.div,{"data-state":sh(n.open),...i,ref:t,style:{pointerEvents:"auto",...i.style}})})}),Ku="DialogContent",qu=e.forwardRef((e,t)=>{const r=Gu(Ku,e.__scopeDialog),{forceMount:i=r.forceMount,...n}=e,s=Fu(Ku,e.__scopeDialog);return b(xu,{present:i||s.open,children:s.modal?b(Xu,{...n,ref:t}):b(Qu,{...n,ref:t})})});qu.displayName=Ku;var Xu=e.forwardRef((t,r)=>{const i=Fu(Ku,t.__scopeDialog),n=e.useRef(null),s=eu(r,i.contentRef,n);return e.useEffect(()=>{const e=n.current;if(e)return Rl(e)},[]),b(Zu,{...t,ref:s,trapFocus:i.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Qc(t.onCloseAutoFocus,e=>{e.preventDefault(),i.triggerRef.current?.focus()}),onPointerDownOutside:Qc(t.onPointerDownOutside,e=>{const t=e.detail.originalEvent,r=0===t.button&&!0===t.ctrlKey;(2===t.button||r)&&e.preventDefault()}),onFocusOutside:Qc(t.onFocusOutside,e=>e.preventDefault())})}),Qu=e.forwardRef((t,r)=>{const i=Fu(Ku,t.__scopeDialog),n=e.useRef(!1),s=e.useRef(!1);return b(Zu,{...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()}})}),Zu=e.forwardRef((t,r)=>{const{__scopeDialog:i,trapFocus:n,onOpenAutoFocus:s,onCloseAutoFocus:a,...o}=t,l=Fu(Ku,i),d=e.useRef(null),c=eu(r,d);return e.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Du()),document.body.insertAdjacentElement("beforeend",e[1]??Du()),Cu++,()=>{1===Cu&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),Cu--}},[]),w(E,{children:[b(ko,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:s,onUnmountAutoFocus:a,children:b(wu,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":sh(l.open),...o,ref:c,onDismiss:()=>l.onOpenChange(!1)})}),w(E,{children:[b(dh,{titleId:l.titleId}),b(ch,{contentRef:d,descriptionId:l.descriptionId})]})]})}),Ju="DialogTitle",eh=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=Fu(Ju,r);return b(Pu.h2,{id:n.titleId,...i,ref:t})});eh.displayName=Ju;var th="DialogDescription",rh=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=Fu(th,r);return b(Pu.p,{id:n.descriptionId,...i,ref:t})});rh.displayName=th;var ih="DialogClose",nh=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=Fu(ih,r);return b(Pu.button,{type:"button",...i,ref:t,onClick:Qc(e.onClick,()=>n.onOpenChange(!1))})});function sh(e){return e?"open":"closed"}nh.displayName=ih;var ah="DialogTitleWarning",[oh,lh]=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}\``)}]}(ah,{contentName:Ku,titleName:Ju,docsSlug:"dialog"}),dh=({titleId:t})=>{const r=lh(ah),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},ch=({contentRef:t,descriptionId:r})=>{const i=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${lh("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},uh=$u,hh=ju,fh=Vu,ph=qu,mh=eh,gh=nh;function vh(t){return e.createElement(uh,Object.assign({"data-slot":"dialog"},t))}function yh(t){var r=T(t,[]);return e.createElement(hh,Object.assign({"data-slot":"dialog-portal"},r))}function bh(t){var{className:r}=t,i=T(t,["className"]);return e.createElement(fh,Object.assign({"data-slot":"dialog-overlay",className:wt("fixed inset-0 z-50 bg-black/50",r)},i))}function Eh(t){var{className:r,children:i,showCloseButton:n=!0,container:s}=t,a=T(t,["className","children","showCloseButton","container"]);return e.createElement(yh,{"data-slot":"dialog-portal",container:s},e.createElement(bh,null),e.createElement(ph,Object.assign({"data-slot":"dialog-content",style:{left:"50%",top:"50%",transform:"translate(-50%, -50%)",outline:"none"},className:wt("fixed","z-50 grid w-full max-w-lg sm:mx-0 gap-4 p-6",r)},a),i,n&&e.createElement(gh,{"data-slot":"dialog-close",style:{right:"calc(var(--spacing) * 4)",top:"calc(var(--spacing) * 4)",outline:"none"},className:wt("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($r,{className:"h-4 w-4 pointer-events-none shrink-0",style:{height:"calc(var(--spacing) * 4)",width:"calc(var(--spacing) * 4)"}}))))}function wh(t){var{className:r}=t,i=T(t,["className"]);return e.createElement("div",Object.assign({"data-slot":"dialog-header",className:wt("flex flex-col gap-2 text-left",r)},i))}function Sh(t){var{className:r}=t,i=T(t,["className"]);return e.createElement(mh,Object.assign({"data-slot":"dialog-title",className:wt("text-lg leading-none font-semibold",r)},i))}function Th({title:e,children:r,contentClassName:i,hideCloseButton:n=!1,portalContainer:s,description:a}){const{open:o,setOpen:l}=wc();return t.createElement(vh,{open:o,onOpenChange:l},t.createElement(Eh,{container:s,className:i,showCloseButton:!n},e&&t.createElement(wh,null,t.createElement(Sh,{style:{color:"#494949"}},e||""),t.createElement(rh,{style:{color:"#5e5e5e",fontSize:"12.5px"}},a||"")),r))}const xh=({products:e,contentId:r})=>{const i=Nc().width<430||Wa.isMobile;return t.createElement("div",{onWheel:e=>e.stopPropagation(),onTouchMove:e=>e.stopPropagation(),className:"grid gap-2 "+(i?"grid-cols-1":"grid-cols-2"),style:{fontSize:13}},e.map(i=>t.createElement(jc,{key:i.productId,product:i,hideMoreBadge:!0,productLength:e.length,contentId:r})))},Ah=({widgetPlayerOption:e,setCollectionUuid:n,portalContainer:s})=>{const{PLAYER_BASE_URL:o}=gt(),{player:l}=e,[d,c]=a(null),{collection:h}=Oc(),{isPreview:f}=Fa(),{onSlideChange:p,onCollectionClose:m}=Mc(d,c),g=r(new Set),v=r(null),y=u(e=>{f||h&&(g.current.has(e)||(g.current.add(e),Ta({contentId:e,uuid:kt(),type:Et.SHORTS,userId:h.userId,isFirstPlay:!Lt(e)}).catch(e=>console.error("Error joining shorts PV:",e))))},[f,h]);i(()=>{if(f)return;if(!h)return;if(v.current===h.colId)return;v.current=h.colId;const e=kt();n(e),Ta({contentId:h.colId,uuid:e,type:Et.COLLECTION,userId:h.userId,isFirstPlay:!Lt(h.colId)}).catch(e=>console.error("Error joining collection PV:",e))},[f,null==h?void 0:h.colId]);const{setOpen:b,open:E}=wc();i(()=>{E||(d&&(m(),c(null)),w&&S(null))},[E]);const[w,S]=a();return t.createElement(t.Fragment,null,h&&t.createElement(Kc,Object.assign({collection:h},e,{onThumbnailClick:e=>x(void 0,void 0,void 0,function*(){if(l===$e.POPUP){const t=kt();if(c(Object.assign(Object.assign({},h.contents.find(t=>t.shortsId===e)),{uuid:t})),b(!0),f)return;try{yield Ta({contentId:e,uuid:t,type:Et.SHORTS,userId:h.userId,isFirstPlay:!Lt(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}})(l),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(`${o}/collection/${h.colId}?${n.toString()}`)}}),onCardView:y,setSelectedProducts:S})),w&&t.createElement(Th,{portalContainer:s,title:"상품 목록",contentClassName:"bg-white rounded p-4 product-dialog-container",description:"상품 정보를 확인해 보세요"},t.createElement(xh,{products:w.productsInfo,contentId:w.shortsId})),h&&d&&t.createElement(Th,{portalContainer:s,hideCloseButton:!0,contentClassName:"w-full max-w-none p-0 mx-0"},t.createElement(zc,{collection:h,initialShortsId:d.shortsId,onClosePlayer:()=>x(void 0,void 0,void 0,function*(){m(),b(!1)}),onSlideChange:p})))};const kh=e=>{const{collectionId:r,isPreview:n,priceText:s,memberOnly:a,container:o}=e,{setIsPreview:l,setPriceText:d,setMemberOnly:c,setIsMemberLoggedIn:u}=Fa(),{setCollection:h,setNextKey:f,collection:p}=Oc();i(()=>{s&&d(s);const e=Boolean(n);e&&l(e),a&&(c(!0),u(Boolean(window.MEMBER_UID)))},[]),i(()=>{x(void 0,void 0,void 0,function*(){var e;const t=yield Ia({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,d,c,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!==(d=e.exposeProductBanner)&&void 0!==d&&d,exposeProductBadge:null!==(c=e.exposeProductBadge)&&void 0!==c&&c,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}=Oc(),d=t.useRef(null),[c,u]=t.useState(0);return t.useEffect(()=>{if(!d.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(d.current),()=>e.disconnect()},[]),t.useEffect(()=>{var e;if(!i||!i.contents)return;const t=Math.max(1,r+12),d=Math.ceil((c||0)/t)+4,u=null!==(e=i.count)&&void 0!==e?e:Number.MAX_SAFE_INTEGER,h=Math.min(u,d);if(i.contents.length>=h||o)return;let f=!1;return(()=>{x(this,void 0,void 0,function*(){var e,t,r,o,d;try{l(!0);let c=i,u=s||(null===(e=c.contents.at(-1))||void 0===e?void 0:e.shortsId)||void 0;const p=new Set(c.contents.map(e=>e.shortsId));for(;!f&&c.contents.length<h;){const e=Math.max(6,h-c.contents.length),i=yield Ia({collectionId:c.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)),c=Object.assign(Object.assign({},c),{contents:[...c.contents,...s]}),n(c),a(u||""),c.contents.length>=(null!==(d=c.count)&&void 0!==d?d: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,c,r,o,s,n,l,a]),{containerRef:d}}({collectionId:r,iconSize:m.iconSize});return t.createElement(Er.div,null,t.createElement(Ec,null),t.createElement("div",{ref:g},t.createElement(Ah,{widgetPlayerOption:m,setCollectionUuid:e=>{h(Object.assign(Object.assign({},p),{uuid:e}))},portalContainer:o})))},Lh=e=>{const{container:r}=Sc();return r?t.createElement(_c,null,t.createElement(kh,Object.assign({},e,{container:r}))):null},Ih=({portalContainer:e,aspectRatio:r})=>{var n;const{collection:s,setNextKey:o}=Oc(),[l,d]=a(),{setOpen:c,open:u}=wc();i(()=>{u||l&&d(null)},[u]);const h=(null!==(n=Nc().width)&&void 0!==n?n:0)<430||Wa.isMobile;return t.createElement(t.Fragment,null,t.createElement("div",{className:"grid gap-4",style:{gridTemplateColumns:`repeat(${h?2:5}, 1fr)`}},null==s?void 0:s.contents.map(e=>t.createElement("div",null,t.createElement("div",{className:"overflow-hidden",style:{borderRadius:"0.625rem",aspectRatio:null!=r?r:"9/16"}},t.createElement("video",{loop:!0,className:"w-full h-full object-cover",muted:!0,autoPlay:!0,playsInline:!0,src:Tt(e.media.objectId),poster:Rt(e.thumbPath)})),t.createElement(Hc,{hideMoreBadge:!0,showMoreBtn:!0,products:e.productsInfo,contentId:e.shortsId,setSelectedProducts:d})))),l&&t.createElement(Th,{portalContainer:e,title:"상품 목록",contentClassName:"bg-white rounded p-4 product-dialog-container",description:"연결된 전체 상품 정보를 확인해 보세요"},t.createElement(xh,{products:l.productsInfo,contentId:l.shortsId})))},Rh=({collectionId:e,aspectRatio:r,container:n,isPreview:s})=>{const{setCollection:a,setNextKey:o}=Oc();return i(()=>{x(void 0,void 0,void 0,function*(){var t;const r=yield Ia({collectionId:e,size:-1});if(!r)return;const{contents:i,count:n}=r;(null==i?void 0:i.length)&&o(null===(t=i.at(-1))||void 0===t?void 0:t.shortsId),a(Object.assign(Object.assign({},r),{count:n}))})},[e]),t.createElement(Er.div,null,t.createElement(Ec,null),t.createElement(Ih,{portalContainer:n,aspectRatio:r}))},Ph=e=>{const{container:r}=Sc();return r?t.createElement(_c,null,t.createElement(Rh,Object.assign({},e,{container:r}))):null},Ch=Na(e=>({shortform:null,setShortform:t=>e({shortform:t})}));var Dh={exports:{}},_h={};function Oh(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=Oh(e[t]))&&(i&&(i+=" "),i+=r);else for(t in e)e[t]&&(i&&(i+=" "),i+=t);return i}function Mh(){for(var e,t,r=0,i="";r<arguments.length;)(e=arguments[r++])&&(t=Oh(e))&&(i&&(i+=" "),i+=t);return i}var Nh,Fh=He(Object.freeze({__proto__:null,clsx:Mh,default:Mh})),$h={},Bh={};function Uh(){if(Nh)return Bh;return Nh=1,Object.defineProperty(Bh,"__esModule",{value:!0}),Bh.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."))},Bh.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]},Bh.int=function(e){return parseInt(e,10)},Bh.isFunction=function(e){return"function"==typeof e||"[object Function]"===Object.prototype.toString.call(e)},Bh.isNum=function(e){return"number"==typeof e&&!isNaN(e)},Bh}var zh,Gh,jh={};function Hh(){if(Gh)return $h;Gh=1,Object.defineProperty($h,"__esModule",{value:!0}),$h.addClassName=a,$h.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},$h.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")},$h.createCSSTransform=function(e,r){const i=s(e,r,"px");return{[(0,t.browserPrefixToKey)("transform",t.default)]:i}},$h.createSVGTransform=function(e,t){return s(e,t,"")},$h.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)},$h.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},$h.getTranslation=s,$h.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},$h.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},$h.matchesSelector=n,$h.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},$h.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}},$h.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},$h.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},$h.removeClassName=o,$h.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},$h.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=Uh(),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(zh)return jh;zh=1,Object.defineProperty(jh,"__esModule",{value:!0}),jh.browserPrefixToKey=r,jh.browserPrefixToStyle=function(e,t){return t?"-".concat(t.toLowerCase(),"-").concat(e):e},jh.default=void 0,jh.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 jh.default=t(),jh}());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 $h}var Vh,Wh={};function Yh(){if(Vh)return Wh;Vh=1,Object.defineProperty(Wh,"__esModule",{value:!0}),Wh.canDragX=function(e){return"both"===e.props.axis||"x"===e.props.axis},Wh.canDragY=function(e){return"both"===e.props.axis||"y"===e.props.axis},Wh.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}},Wh.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}},Wh.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),d=i.getComputedStyle(s);a={left:-o.offsetLeft+(0,e.int)(d.paddingLeft)+(0,e.int)(l.marginLeft),top:-o.offsetTop+(0,e.int)(d.paddingTop)+(0,e.int)(l.marginTop),right:(0,t.innerWidth)(s)-(0,t.outerWidth)(o)-o.offsetLeft+(0,e.int)(d.paddingRight)-(0,e.int)(l.marginRight),bottom:(0,t.innerHeight)(s)-(0,t.outerHeight)(o)-o.offsetTop+(0,e.int)(d.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]},Wh.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)},Wh.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=Uh(),t=Hh();function r(e){const t=e.findDOMNode();if(!t)throw new Error("<DraggableCore>: Unmounted during event!");return t}return Wh}var Kh,qh,Xh,Qh,Zh={},Jh={};function ef(){if(Kh)return Jh;return Kh=1,Object.defineProperty(Jh,"__esModule",{value:!0}),Jh.default=function(){},Jh}function tf(){if(qh)return Zh;qh=1,Object.defineProperty(Zh,"__esModule",{value:!0}),Zh.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=d(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(ar()),i=l(m),n=Hh(),s=Yh(),a=Uh(),o=l(ef());function l(e){return e&&e.__esModule?e:{default:e}}function d(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(d=function(e){return e?r:t})(e)}function c(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),c(this,"dragging",!1),c(this,"lastX",NaN),c(this,"lastY",NaN),c(this,"touchIdentifier",null),c(this,"mounted",!1),c(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:d}=a,c=(0,s.createCoreData)(this,l,d);(0,o.default)("DraggableCore: handleDragStart: %j",c),(0,o.default)("calling",this.props.onStart);!1!==this.props.onStart(e,c)&&!1!==this.mounted&&(this.props.enableUserSelectHack&&(0,n.addUserSelectStyles)(r),this.dragging=!0,this.lastX=l,this.lastY=d,(0,n.addEvent)(r,f.move,this.handleDrag),(0,n.addEvent)(r,f.stop,this.handleDragStop))}),c(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)}}),c(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))}),c(this,"onMouseDown",e=>(f=h,this.handleDragStart(e))),c(this,"onMouseUp",e=>(f=h,this.handleDragStop(e))),c(this,"onTouchStart",e=>(f=u,this.handleDragStart(e))),c(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 Zh.default=p,c(p,"displayName","DraggableCore"),c(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}),c(p,"defaultProps",{allowAnyClick:!1,disabled:!1,enableUserSelectHack:!0,onStart:function(){},onDrag:function(){},onStop:function(){},onMouseDown:function(){},scale:1}),Zh}function rf(){return Xh||(Xh=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"DraggableCore",{enumerable:!0,get:function(){return d.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(ar()),n=u(m),s=u(Fh),a=Hh(),o=Yh(),l=Uh(),d=u(tf()),c=u(ef());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,c.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,c.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,c.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,c.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:c,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,{[c]:this.state.dragging,[u]:this.state.dragged});return r.createElement(d.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",{...d.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",{...d.default.defaultProps,axis:"both",bounds:!1,defaultClassName:"react-draggable",defaultClassNameDragging:"react-draggable-dragging",defaultClassNameDragged:"react-draggable-dragged",defaultPosition:{x:0,y:0},scale:1})}(_h)),_h}var nf=function(){if(Qh)return Dh.exports;Qh=1;const{default:e,DraggableCore:t}=rf();return Dh.exports=e,Dh.exports.default=e,Dh.exports.DraggableCore=t,Dh.exports}(),sf=je(nf),af=function(){return af=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},af.apply(this,arguments)},of={width:"100%",height:"10px",top:"0px",left:"0px",cursor:"row-resize"},lf={width:"10px",height:"100%",top:"0px",left:"0px",cursor:"col-resize"},df={width:"20px",height:"20px",position:"absolute",zIndex:1},cf={top:af(af({},of),{top:"-5px"}),right:af(af({},lf),{left:void 0,right:"-5px"}),bottom:af(af({},of),{top:void 0,bottom:"-5px"}),left:af(af({},lf),{left:"-5px"}),topRight:af(af({},df),{right:"-10px",top:"-10px",cursor:"ne-resize"}),bottomRight:af(af({},df),{right:"-10px",bottom:"-10px",cursor:"se-resize"}),bottomLeft:af(af({},df),{left:"-10px",bottom:"-10px",cursor:"sw-resize"}),topLeft:af(af({},df),{left:"-10px",top:"-10px",cursor:"nw-resize"})},uf=h(function(e){var t=e.onResizeStart,r=e.direction,i=e.children,n=e.replaceStyles,s=e.className,a=u(function(e){t(e,r)},[t,r]),o=u(function(e){t(e,r)},[t,r]),l=c(function(){return af(af({position:"absolute",userSelect:"none"},cf[r]),null!=n?n:{})},[n,r]);return b("div",{className:s||void 0,style:l,onMouseDown:a,onTouchStart:o,children:i})}),hf=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)}}(),ff=function(){return ff=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},ff.apply(this,arguments)},pf={width:"auto",height:"auto"},mf=function(e,t,r){return Math.max(Math.min(e,r),t)},gf=function(e,t,r){var i=Math.round(e/t);return i*t+r*(i-1)},vf=function(e,t){return new RegExp(e,"i").test(t)},yf=function(e){return Boolean(e.touches&&e.touches.length)},bf=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},Ef=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")},wf=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},Sf=["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"],Tf="__resizable_base__",xf=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(Tf):t.className+=Tf,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 hf(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||pf},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 Ef(e.state[t])};return{width:t&&void 0!==t.width&&!this.state.isResizing?Ef(t.width):r("width"),height:t&&void 0!==t.height&&!this.state.isResizing?Ef(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&&vf("left",s),o=n&&vf("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,d=o.original,c=this.props,u=c.lockAspectRatio,h=c.lockAspectRatioExtraHeight,f=c.lockAspectRatioExtraWidth,p=d.width,m=d.height,g=h||0,v=f||0;return vf("right",l)&&(p=d.width+(e-d.x)*s/i,u&&(m=(p-v)/this.ratio+g)),vf("left",l)&&(p=d.width-(e-d.x)*s/i,u&&(m=(p-v)/this.ratio+g)),vf("bottom",l)&&(m=d.height+(t-d.y)*a/i,u&&(p=(m-g)*this.ratio+v)),vf("top",l)&&(m=d.height-(t-d.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,d=void 0===r.width||r.width<0?e:r.width,c=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=(c-h)*this.ratio+f,m=(u-h)*this.ratio+f,g=(l-f)/this.ratio+h,v=(d-f)/this.ratio+h,y=Math.max(l,p),b=Math.min(d,m),E=Math.max(c,g),w=Math.min(u,v);e=mf(e,y,b),t=mf(t,E,w)}else e=mf(e,l,d),t=mf(t,c,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&&yf(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:ff(ff({},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&&yf(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=yf(e)?e.touches[0].clientX:e.clientX,l=yf(e)?e.touches[0].clientY:e.clientY,d=this.state,c=d.direction,u=d.original,h=d.width,f=d.height,p=this.getParentSize(),m=function(e,t,r,i,n,s,a){return i=wf(i,e.width,t,r),n=wf(n,e.height,t,r),s=wf(s,e.width,t,r),a=wf(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=bf(b,this.props.snap.x,this.props.snapGap)),this.props.snap&&this.props.snap.y&&(y=bf(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=gf(b,this.props.grid[0],this.props.gridGap?this.props.gridGap[0]:0),T=gf(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 L=b/this.window.innerWidth*100;b="".concat(L,"vw")}else if(h.endsWith("vh")){var I=b/this.window.innerHeight*100;b="".concat(I,"vh")}if(f&&"string"==typeof f)if(f.endsWith("%")){k=y/p.height*100;y="".concat(k,"%")}else if(f.endsWith("vw")){L=y/this.window.innerWidth*100;y="".concat(L,"vw")}else if(f.endsWith("vh")){I=y/this.window.innerHeight*100;y="".concat(I,"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,c,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:ff(ff({},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(uf,{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!==Sf.indexOf(r)||(t[r]=e.props[r]),t},{}),r=ff(ff(ff({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,ff({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),Af=function(e,t){return Af=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])},Af(e,t)};var kf=function(){return kf=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},kf.apply(this,arguments)};var Lf={width:"auto",height:"auto",display:"inline-block",position:"absolute",top:0,left:0},If=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}Af(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,d=document.body.getBoundingClientRect(),c=-(o-n.offsetLeft*s-d.left)/s,u=-(l-n.offsetTop*s-d.top)/s,h=(document.body.offsetWidth-this.resizable.size.width*s)/s+c,f=(document.body.offsetHeight-this.resizable.size.height*s)/s+u;return this.setState({bounds:{top:u,right:h,bottom:f,left:c}})}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,kf(kf({},t),{x:t.x+i,y:this.originalPosition.y+n,deltaY:0})):"y"===this.props.dragAxis?this.props.onDrag(e,kf(kf({},t),{x:this.originalPosition.x+i,y:t.y+n,deltaX:0})):void 0:this.props.onDrag(e,kf(kf({},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,kf(kf({},t),{x:t.x+i,y:this.originalPosition.y+n,deltaY:0})):"y"===this.props.dragAxis?this.props.onDragStop(e,kf(kf({},t),{x:this.originalPosition.x+i,y:t.y+n,deltaX:0})):void 0:this.props.onDragStop(e,kf(kf({},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 d=this.getMaxSizesFromProps(),c=d.maxWidth,u=d.maxHeight,h=this.getParentSize();if(c&&"string"==typeof c)if(c.endsWith("%")){var f=Number(c.replace("%",""))/100;c=h.width*f}else c.endsWith("px")&&(c=Number(c.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(c)?c:k})}if(T||this.props.lockAspectRatio&&!S&&!x){k=E+(y-m)/i;this.setState({maxWidth:k>Number(c)?c: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 d=this.offsetFromParent,c=this.getDraggablePosition().x+d.left,u=this.getDraggablePosition().y+d.top;this.resizingPosition={x:c,y:u},this.props.onResize&&this.props.onResize(e,t,r,i,{x:c,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,d=t.scrollTop;this.offsetFromParent={left:a.left-n+l-o.x*e,top:a.top-s+d-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,d=t.dragAxis,c=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?kf({},this.props.default):void 0;delete A.default;var L,I=r||n?{cursor:"auto"}:{cursor:"move"},R=kf(kf(kf({},Lf),I),i),P=this.offsetFromParent,C=P.left,D=P.top;s&&(L={x:s.x-C,y:s.y-D});var _,O=this.state.resizing?void 0:L,M=this.state.resizing?"both":d;return l(sf,{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:c,bounds:u?this.state.bounds:void 0,position:O,enableUserSelectHack:h,cancel:f,scale:S,allowAnyClick:T,nodeRef:this.resizableElement,positionOffset:x},l(xf,kf({},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 Rf=({shortform:e,setClose:r})=>{const[n,s]=t.useState(!0),[o,l]=a(!0),[d,c]=a(!1),u=t.useRef(null),h=()=>{u.current&&(window.clearTimeout(u.current),u.current=null)},f=(e=1500)=>{h(),u.current=window.setTimeout(()=>c(!1),e)};return i(()=>()=>h(),[]),t.createElement("div",{className:"relative w-full h-full",onClick:()=>{c(!0),f(2e3)},onMouseLeave:()=>f(800),onMouseEnter:()=>d&&f(1500)},t.createElement("div",{className:"absolute inset-0 bg-black",style:{zIndex:1,opacity:d?.4:0,transition:"opacity 300ms ease",pointerEvents:d?"auto":"none"}}),t.createElement("div",{className:"absolute inset-0",style:{zIndex:2,opacity:d?1:0,transition:"opacity 300ms ease",pointerEvents:d?"auto":"none"}},t.createElement("div",{className:"absolute text-white flex gap-2",style:{zIndex:3,top:8,right:8}},t.createElement("button",{className:"cursor-pointer",onClick:e=>{e.stopPropagation(),s(e=>!e)},"aria-label":n?"Unmute":"Mute"},n?t.createElement(Fr,{size:20}):t.createElement(Nr,{size:20})),t.createElement("button",{className:"cursor-pointer",onClick:e=>{null==e||e.stopPropagation(),r()},"aria-label":"Close"},t.createElement($r,{size:20}))),t.createElement("div",{className:"absolute inset-0 flex items-center justify-center",style:{pointerEvents:"none"}},t.createElement("button",{onClick:e=>{null==e||e.stopPropagation(),l(e=>!e)},"aria-label":o?"Pause":"Play",className:"cursor-pointer text-white p-2 ",style:{pointerEvents:"auto"}},o?t.createElement(_r,{size:28}):t.createElement(Or,{size:28})))),t.createElement(Dt,{shortform:e,mute:n,play:o}))},Pf=({shortsId:e,type:r})=>{const{shortform:n}=Ch(),[s,o]=a(!1),{playtime:l}=Cc(),d=()=>{if(!n)return;o(!0);const{shortsId:e,uuid:t,userId:r}=n;xa({contentId:e,uuid:t,type:Et.SHORTS,playtime:l,userId:r})};(({shorform:e,playtime:t})=>{i(()=>{if(!e)return;const{shortsId:t,shortsUuid:r,userId:i}=e;Ta({contentId:t,uuid:r,type:Et.SHORTS,userId:i,isFirstPlay:!Lt(t)})},[]);const r=Rc();i(()=>{if(!e||r)return;const{shortsId:i,uuid:n,userId:s}=e;xa({contentId:i,uuid:n,type:Et.SHORTS,playtime:t,userId:s})},[r])})({shorform:n,playtime:l});const{w:c,h:u,left:h,top:f}=(()=>{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 n&&!s&&t.createElement(If,{minWidth:240,lockAspectRatio:9/16,style:{zIndex:99999},default:{width:240,height:427,x:h+c-240-50,y:f+u-427-50},bounds:"window"},"shopping"===r&&n.productsInfo.length>0?t.createElement(cc,{shortForm:n,handleClose:d}):t.createElement(Rf,{shortform:n,setClose:d}))},Cf=({shortsId:e,type:r,isPreview:n})=>{const{setShortform:s,shortform:a}=Ch();return i(()=>{if(!e)return;e&&x(void 0,void 0,void 0,function*(){const t=yield Ra(e,n);t&&s(Object.assign(Object.assign({},t),{uuid:kt()}))})},[e]),a?t.createElement(Er.div,{style:{position:"fixed",inset:0,pointerEvents:"none",zIndex:99999}},t.createElement(Ec,null),t.createElement("div",{style:{pointerEvents:"auto"}},t.createElement(Pf,{shortsId:e,type:r}))):null},Df=t.createContext(null),_f=({children:e})=>{const r=t.useRef(null);return r.current||(r.current=Da(e=>({liveWidget:null,setLiveWidget:t=>e({liveWidget:t}),nextKey:"",setNextKey:t=>e({nextKey:t}),isFetching:!1,setIsFetching:t=>e({isFetching:t})}))),t.createElement(Df.Provider,{value:r.current},e)};function Of(e){const r=t.useContext(Df);if(!r)throw new Error("Missing LiveWidgetProvider");return Oa(r,e)}var Mf;!function(e){e[e.READY=1]="READY",e[e.STREAMING=2]="STREAMING",e[e.PAUSED=3]="PAUSED"}(Mf||(Mf={}));const Nf=({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"}})},Ff=({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"})},$f=(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],d=l/o;let c,u;i>0&&s>0?(c=i,u=Math.round(c*d),u>s&&(u=s,c=Math.round(u/d)),n({width:c,height:u})):n({});const h="number"==typeof c?c: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}},Bf=({content:e,aspectRatio:r="9/16",cursor:i="default",borderRadius:n})=>{var s,o;const{leftTime:l}=(e=>{const{start:t}=e,r=qe().tz("Asia/Seoul").unix(),[i,n]=a(t-r>0?t-r:0);return Pc(()=>{n(i<=0?0:e=>e-1)},1e3),{leftTime:i}})(e),d=null===(o=null===(s=null==e?void 0:e.designInfo)||void 0===s?void 0:s.thumbPath)||void 0===o?void 0:o.preview,c=t.useRef(null),{boxSize:u,fontSize:h}=$f(r,c),{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:c},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:d?`url(${Rt(d)})`:void 0,backgroundColor:d?void 0:"black"}},1===e.openStatus?t.createElement(t.Fragment,null,t.createElement(Ff,{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(Nf,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(Nf,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`}},"곧 라이브가 시작됩니다!")))))},Uf=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},zf=Number.isSafeInteger||function(e){return"number"==typeof e&&Math.abs(e)<=Gf},Gf=Number.MAX_SAFE_INTEGER||9007199254740991;let jf=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}({}),Hf=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}({}),Vf=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 Wf="manifest",Yf="level",Kf="audioTrack",qf="subtitleTrack",Xf="main",Qf="audio",Zf="subtitle";class Jf{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 ep{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 Jf(e),this.fast_=new Jf(t),this.defaultTTFB_=i,this.ttfb_=new Jf(e)}update(e,t){const{slow_:r,fast_:i,ttfb_:n}=this;r.halfLife!==e&&(this.slow_=new Jf(e,r.getEstimate(),r.getTotalWeight())),i.halfLife!==t&&(this.fast_=new Jf(t,i.getEstimate(),i.getTotalWeight())),n.halfLife!==e&&(this.ttfb_=new Jf(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 tp(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 rp(){return rp=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},rp.apply(null,arguments)}function ip(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 np(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ip(Object(r),!0).forEach(function(t){tp(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ip(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}class sp{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=ap,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 ap=function(){},op={trace:ap,debug:ap,log:ap,warn:ap,info:ap,error:ap};function lp(){return rp({},op)}function dp(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}] >`):ap}(e,r)}const cp=lp();const up=cp;function hp(e=!0){if("undefined"==typeof self)return;return(e||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function fp(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 pp(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 mp(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 gp(e){return Uint8Array.from(e.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}function vp(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var yp,bp={exports:{}};var Ep,wp,Sp,Tp,xp,Ap=yp?bp.exports:(yp=1,Ep=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,wp=/^(?=([^\/?#]*))\1([^]*)$/,Sp=/(?:\/|^)\.(?=\/)/g,Tp=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,bp.exports=xp={buildAbsoluteURL:function(e,t,r){if(r=r||{},e=e.trim(),!(t=t.trim())){if(!r.alwaysNormalize)return e;var i=xp.parseURL(e);if(!i)throw new Error("Error trying to parse base URL.");return i.path=xp.normalizePath(i.path),xp.buildURLFromParts(i)}var n=xp.parseURL(t);if(!n)throw new Error("Error trying to parse relative URL.");if(n.scheme)return r.alwaysNormalize?(n.path=xp.normalizePath(n.path),xp.buildURLFromParts(n)):t;var s=xp.parseURL(e);if(!s)throw new Error("Error trying to parse base URL.");if(!s.netLoc&&s.path&&"/"!==s.path[0]){var a=wp.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,d=l.substring(0,l.lastIndexOf("/")+1)+n.path;o.path=xp.normalizePath(d)}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?xp.normalizePath(n.path):n.path),xp.buildURLFromParts(o)},parseURL:function(e){var t=Ep.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(Sp,"");e.length!==(e=e.replace(Tp,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}});class kp{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 Lp="audio",Ip="video",Rp="audiovideo";class Pp{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=Op(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={[Lp]:null,[Ip]:null,[Rp]: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 kp),this._stats}set stats(e){this._stats=e}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Ap.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}clearElementaryStreamInfo(){const{elementaryStreams:e}=this;e[Lp]=null,e[Ip]=null,e[Rp]=null}}function Cp(e){return"initSegment"!==e.sn}class Dp extends Pp{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(Uf(e)&&Uf(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=Uf(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){Uf(e)?this._programDateTime=e:this._programDateTime=this.rawProgramDateTime=null}get ref(){return Cp(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 _p extends Pp{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 Op(e,t){const r=Object.getPrototypeOf(e);if(r){const e=Object.getOwnPropertyDescriptor(r,t);return e||Op(r,t)}}const Mp=Math.pow(2,32)-1,Np=[].push,Fp={video:1,audio:2,id3:3,text:4};function $p(e){return String.fromCharCode.apply(null,e)}function Bp(e,t){const r=e[t]<<8|e[t+1];return r<0?65536+r:r}function Up(e,t){const r=Gp(e,t);return r<0?4294967296+r:r}function zp(e,t){let r=Up(e,t);return r*=Math.pow(2,32),r+=Up(e,t+4),r}function Gp(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function jp(e,t){const r=[];if(!t.length)return r;const i=e.byteLength;for(let n=0;n<i;){const s=Up(e,n),a=s>1?n+s:i;if($p(e.subarray(n+4,n+8))===t[0])if(1===t.length)r.push(e.subarray(n+8,a));else{const i=jp(e.subarray(n+8,a),t.slice(1));i.length&&Np.apply(r,i)}n=a}return r}function Hp(e){const t=[],r=e[0];let i=8;const n=Up(e,i);i+=4;let s=0,a=0;0===r?(s=Up(e,i),a=Up(e,i+4),i+=8):(s=zp(e,i),a=zp(e,i+8),i+=16),i+=2;let o=e.length+a;const l=Bp(e,i);i+=2;for(let r=0;r<l;r++){let r=i;const s=Up(e,r);r+=4;const a=2147483647&s;if(1===(2147483648&s)>>>31)return up.warn("SIDX has hierarchical references (not supported)"),null;const l=Up(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 Vp(e){const t=[],r=jp(e,["moov","trak"]);for(let e=0;e<r.length;e++){const i=r[e],n=jp(i,["tkhd"])[0];if(n){let e=n[0];const r=Up(n,0===e?12:20),s=jp(i,["mdia","mdhd"])[0];if(s){e=s[0];const n=Up(s,0===e?12:20),a=jp(i,["mdia","hdlr"])[0];if(a){const e=$p(a.subarray(8,12)),s={soun:Lp,vide:Ip}[e],o=Wp(jp(i,["mdia","minf","stbl","stsd"])[0]);s?(t[r]={timescale:n,type:s,stsd:o},t[s]=np({timescale:n,id:r},o)):t[r]={timescale:n,type:e,stsd:o}}}}}return jp(e,["moov","mvex","trex"]).forEach(e=>{const r=Up(e,4),i=t[r];i&&(i.default={duration:Up(e,12),flags:Up(e,20)})}),t}function Wp(e){const t=e.subarray(8),r=t.subarray(86),i=$p(t.subarray(4,8));let n,s=i;const a="enca"===i||"encv"===i;if(a){const e=jp(t,[i])[0];jp(e.subarray("enca"===i?28:78),["sinf"]).forEach(e=>{const t=jp(e,["schm"])[0];if(t){const r=$p(t.subarray(4,8));if("cbcs"===r||"cenc"===r){const t=jp(e,["frma"])[0];t&&(s=$p(t))}}})}const o=s;switch(s){case"avc1":case"avc2":case"avc3":case"avc4":{const e=jp(r,["avcC"])[0];e&&e.length>3&&(s+="."+qp(e[1])+qp(e[2])+qp(e[3]),n=Yp("avc1"===o?"dva1":"dvav",r));break}case"mp4a":{const e=jp(t,[i])[0],r=jp(e.subarray(28),["esds"])[0];if(r&&r.length>7){let e=4;if(3!==r[e++])break;e=Kp(r,e),e+=2;const t=r[e++];if(128&t&&(e+=2),64&t&&(e+=r[e++]),4!==r[e++])break;e=Kp(r,e);const i=r[e++];if(64!==i)break;if(s+="."+qp(i),e+=12,5!==r[e++])break;e=Kp(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=jp(r,["hvcC"])[0];if(e&&e.length>12){const t=e[1],r=["","A","B","C"][t>>6],i=31&t,n=Up(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 d="";for(let e=l.length;e--;){const t=l[e];if(t||d){d="."+t.toString(16).toUpperCase()+d}}s+=d}n=Yp("hev1"==o?"dvhe":"dvh1",r);break}case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":s=Yp(s,r)||s;break;case"vp09":{const e=jp(r,["vpcC"])[0];if(e&&e.length>6){const t=e[4],r=e[5],i=e[6]>>4&15;s+="."+Xp(t)+"."+Xp(r)+"."+Xp(i)}break}case"av01":{const e=jp(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,d=2===t&&o?l?12:10:o?10:8,c=(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+"."+Xp(i)+a+"."+Xp(d)+"."+c+"."+u+h+f+"."+Xp(p)+"."+Xp(m)+"."+Xp(g)+"."+v,n=Yp("dav1",r)}break}}return{codec:s,encrypted:a,supplemental:n}}function Yp(e,t){const r=jp(t,["dvvC"]),i=r.length?r[0]:jp(t,["dvcC"])[0];if(i){const t=i[2]>>1&127,r=i[2]<<5&32|i[3]>>3&31;return e+"."+Xp(t)+"."+Xp(r)}}function Kp(e,t){const r=t+5;for(;128&e[t++]&&t<r;);return t}function qp(e){return("0"+e.toString(16).toUpperCase()).slice(-2)}function Xp(e){return(e<10?"0":"")+e}function Qp(e,t){jp(e,["moov","trak"]).forEach(e=>{const r=jp(e,["mdia","minf","stbl","stsd"])[0];if(!r)return;const i=r.subarray(8);let n=jp(i,["enca"]);const s=n.length>0;s||(n=jp(i,["encv"])),n.forEach(e=>{jp(s?e.subarray(28):e.subarray(78),["sinf"]).forEach(e=>{const r=Zp(e);r&&t(r,s)})})})}function Zp(e){const t=jp(e,["schm"])[0];if(t){const r=$p(t.subarray(4,8));if("cbcs"===r||"cenc"===r){const t=jp(e,["schi","tenc"])[0];if(t)return t}}}function Jp(e,t){const r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}function em(e,t){const r=[],i=t.samples,n=t.timescale,s=t.id;let a=!1;return jp(i,["moof"]).map(o=>{const l=o.byteOffset-8;jp(o,["traf"]).map(o=>{const d=jp(o,["tfdt"]).map(e=>{const t=e[0];let r=Up(e,4);return 1===t&&(r*=Math.pow(2,32),r+=Up(e,8)),r/n})[0];return void 0!==d&&(e=d),jp(o,["tfhd"]).map(d=>{const c=Up(d,4),u=16777215&Up(d,0);let h=0;const f=!!(16&u);let p=0;const m=!!(32&u);let g=8;c===s&&(!!(1&u)&&(g+=8),!!(2&u)&&(g+=4),!!(8&u)&&(h=Up(d,g),g+=4),f&&(p=Up(d,g),g+=4),m&&(g+=4),"video"===t.type&&(a=tm(t.codec)),jp(o,["trun"]).map(s=>{const o=s[0],d=16777215&Up(s,0),c=!!(1&d);let u=0;const f=!!(4&d),m=!!(256&d);let g=0;const v=!!(512&d);let y=0;const b=!!(1024&d),E=!!(2048&d);let w=0;const S=Up(s,4);let T=8;c&&(u=Up(s,T),T+=4),f&&(T+=4);let x=u+l;for(let l=0;l<S;l++){if(m?(g=Up(s,T),T+=4):g=h,v?(y=Up(s,T),T+=4):y=p,b&&(T+=4),E&&(w=0===o?Up(s,T):Gp(s,T),T+=4),t.type===Ip){let t=0;for(;t<y;){const s=Up(i,x);if(x+=4,rm(a,i[x])){im(i.subarray(x,x+s),a?2:1,e+w/n,r)}x+=s,t+=s+4}}e+=g/n}}))})})}),r}function tm(e){if(!e)return!1;const t=e.substring(0,4);return"hvc1"===t||"hev1"===t||"dvh1"===t||"dvhe"===t}function rm(e,t){if(e){const e=t>>1&63;return 39===e||40===e}return 6===(31&t)}function im(e,t,r,i){const n=nm(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){up.error(`Malformed SEI payload. ${o} is too small, only ${e} bytes left to parse.`);break}if(4===a){if(181===n[t++]){const e=Bp(n,t);if(t+=2,49===e){const e=Up(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,d=new Uint8Array(l);if(o){d[0]=s;for(let e=1;e<l;e++)d[e]=n[t++]}i.push({type:e,payloadType:a,pts:r,bytes:d})}}}}}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:pp(l),userDataBytes:l})}}}function nm(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 sm(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 am(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=mp(new Uint8Array(s,r+12,16));let o=null,l=null,d=0;if(0===n)d=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));d=32+16*n}if(!d)return{offset:r,size:t};const c=e.getUint32(d);return t-32<c?{offset:r,size:t}:(l=new Uint8Array(s,r+d+4,c),{version:n,systemId:a,kids:o,data:l,offset:r,size:t})}const om=()=>/\(Windows.+Firefox\//i.test(navigator.userAgent),lm={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 dm(e,t){const r=lm[t];return!!r&&!!r[e.slice(0,4)]}function cm(e,t,r=!0){return!e.split(",").some(e=>!um(e,t,r))}function um(e,t,r=!0){var i;const n=hp(r);return null!=(i=null==n?void 0:n.isTypeSupported(hm(e,t)))&&i}function hm(e,t){return`${t}/mp4;codecs=${e}`}function fm(e){if(e){const t=e.substring(0,4);return lm.video[t]}return 2}function pm(e){const t=om();return e.split(",").reduce((e,r)=>{const i=t&&tm(r)?9:lm.video[r];return i?(2*i+e)/(e?3:2):(lm.audio[r]+e)/(e?2:1)},0)}const mm={};const gm=/flac|opus|mp4a\.40\.34/i;function vm(e,t=!0){return e.replace(gm,e=>function(e,t=!0){if(mm[e])return mm[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(um(r[n],"audio",t))return mm[e]=r[n],r[n];if("mp3"===r[n]&&null!=(i=hp(t))&&i.isTypeSupported("audio/mpeg"))return""}return e}(e.toLowerCase(),t))}function ym(e,t){if(e&&(e.length>4||-1!==["ac-3","ec-3","alac","fLaC","Opus"].indexOf(e))&&(bm(e,"audio")||bm(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 bm(e,t){return dm(e,t)&&um(e,t)}function Em(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 wm(e){const t=hp(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 Sm(e){return e.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}const Tm={supported:!1,smooth:!1,powerEfficient:!1},xm={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]};function Am(e,t){return{supported:!1,configurations:t,decodingInfoResults:[Tm],error:e}}function km(e,t,r,i,n,s){const a=e.videoCodec,o=e.audioCodec?e.audioGroups:null,l=null==s?void 0:s.audioCodec,d=null==s?void 0:s.channels,c=d?parseInt(d):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=>tm(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&&Uf(c)&&Object.keys(u).some(e=>parseInt(e)>c)}function Lm(e,t,r,i={}){const n=e.videoCodec;if(!n&&!e.audioCodec||!r)return Promise.resolve(xm);const s=[],a=function(e){var t;const r=null==(t=e.videoCodec)?void 0:t.split(","),i=Rm(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:hm(Em(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=Rm(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:hm(t,"audio"),bitrate:r?Im(t,s):s};i&&(n.channels=""+i),e.push(n)})}return e},e):e},[]);return[]}(e,t,o>0),d=l.length;for(let e=o||1*d||1;e--;){const t={type:"media-source"};if(o&&(t.video=a[e%o]),d){t.audio=l[e%d];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=>tm(e))&&om())return Promise.resolve(Am(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+=`${Sm(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?"_":""}${Sm(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 Im(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 Rm(e){return 1e3*Math.ceil(Math.max(.9*e.bitrate,e.averageBitrate)/1e3)||1}const Pm=["NONE","TYPE-0","TYPE-1",null];const Cm=["SDR","PQ","HLG"];var Dm="",_m="YES",Om="v2";function Mm(e){const{canSkipUntil:t,canSkipDateRanges:r,age:i}=e;return t&&i<t/2?r?Om:_m:Dm}class Nm{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 Fm{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 $m(this._audioGroups,e)}hasSubtitleGroup(e){return $m(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 $m(e,t){return!(!t||!e)&&-1!==e.indexOf(t)}function Bm(e,t){let r=!1,i=[];if(e&&(r="SDR"!==e,i=[e]),t){i=t.allowedVideoRanges||Cm.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 Um=(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 zm(e,t){up.log(`[abr] start candidates with "${e}" ignored because ${t}`)}function Gm(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 jm(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 Hm(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(Vm(e,t[i],r))return i}return-1}function Vm(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 Wm(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 Ym(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 Km(e,t){var r;return!!e&&e!==(null==(r=t.loadLevelObj)?void 0:r.uri)}const qm=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 Xm(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===Qm(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=qm(t,Qm.bind(null,r,i));return!a||a===e&&s?s:a}function Qm(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 Zm(e,t,r){const i=1e3*Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return(r.endProgramDateTime||0)-i>e}function Jm(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)),qm(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 eg(e){switch(e.details){case Hf.FRAG_LOAD_TIMEOUT:case Hf.KEY_LOAD_TIMEOUT:case Hf.LEVEL_LOAD_TIMEOUT:case Hf.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function tg(e){return e.details.startsWith("key")}function rg(e){return tg(e)&&!!e.frag&&!e.frag.decryptdata}function ig(e,t){const r=eg(t);return e.default[(r?"timeout":"error")+"Retry"]}function ng(e,t){const r="linear"===e.backoff?1:Math.pow(2,t);return Math.min(r*e.retryDelayMs,e.maxRetryDelayMs)}function sg(e){return np(np({},e),{errorRetry:null,timeoutRetry:null})}function ag(e,t,r,i){if(!e)return!1;const n=null==i?void 0:i.code,s=t<e.maxNumRetry&&(function(e){return og(e)||!!e&&(e<400||e>499)}(n)||!!r);return e.shouldRetry?e.shouldRetry(e,t,r,i,s):s}function og(e){return 0===e&&!1===navigator.onLine}var lg=0,dg=2,cg=3,ug=5,hg=0,fg=1,pg=2,mg=4;function gg(e){const t={action:lg,flags:hg};return e&&(t.resolved=!0),t}var vg="NOT_LOADED",yg="APPENDING",bg="PARTIAL",Eg="OK";class wg{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(Vf.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Vf.BUFFER_APPENDED,this.onBufferAppended,this),e.on(Vf.FRAG_BUFFERED,this.onFragBuffered,this),e.on(Vf.FRAG_LOADED,this.onFragLoaded,this))}_unregisterListeners(){const{hls:e}=this;e&&(e.off(Vf.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Vf.BUFFER_APPENDED,this.onBufferAppended,this),e.off(Vf.FRAG_BUFFERED,this.onFragBuffered,this),e.off(Vf.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=Tg(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),Sg(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]=xg(r,t=>t.fragment.sn>=e))}fragBuffered(e,t){const r=Tg(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 d=o[l];d&&Sg(d)&&(r=d.body.start-a,i=d.body.end+a,e>=r&&e<=i&&(t=Math.min(e-r,i-e),s<=t&&(n=d.body,s=t)))}),n}isEndListAppended(e){const t=this.endListFragments[e];return void 0!==t&&(t.buffered||Sg(t))}getState(e){const t=Tg(e),r=this.fragments[t];return r?r.buffered?Sg(r)?bg:Eg:yg:vg}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=Tg(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=Tg(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=Tg(e);e.clearElementaryStreamInfo();const r=this.activePartLists[e.type];if(r){const t=e.sn;this.activePartLists[e.type]=xg(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 Sg(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 Tg(e){return`${e.type}_${e.level}_${e.sn}`}function xg(e,t){return e.filter(e=>{const r=t(e);return r||e.clearElementaryStreamInfo(),r})}var Ag=0,kg=1;class Lg{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 Ag:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e);case kg: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 Ig{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],d=o[1],c=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,d[r]=v<<16|v>>>16,c[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),d=this.invKeySchedule=new Uint32Array(s),c=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=c[y>>>24]<<24|c[y>>>16&255]<<16|c[y>>>8&255]<<8|c[255&y],y^=u[a/n|0]<<24):n>6&&a%n===4&&(y=c[y>>>24]<<24|c[y>>>16&255]<<16|c[y>>>8&255]<<8|c[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],d[o]=o<4||a<=4?y:f[c[y>>>24]]^p[c[y>>>16&255]]^m[c[y>>>8&255]]^g[c[255&y]],d[o]=d[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],d=a[2],c=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,L,I,R,P,C;const D=this.networkToHostOrderSwap;for(;t<g.length;){for(k=D(g[t]),L=D(g[t+1]),I=D(g[t+2]),R=D(g[t+3]),S=k^n[0],T=R^n[1],x=I^n[2],A=L^n[3],P=4,C=1;C<i;C++)y=o[S>>>24]^l[T>>16&255]^d[x>>8&255]^c[255&A]^n[P],b=o[T>>>24]^l[x>>16&255]^d[A>>8&255]^c[255&S]^n[P+1],E=o[x>>>24]^l[A>>16&255]^d[S>>8&255]^c[255&T]^n[P+2],w=o[A>>>24]^l[S>>16&255]^d[T>>8&255]^c[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=L,p=I,m=R,t+=4}return v.buffer}}class Rg{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 Ag:return"AES-CBC";case kg: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 Pg{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!==Ag||16!==t.byteLength)return up.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),a&&(e=Jp(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 Ig),l.expandKey(t);const d=s;return this.currentResult=l.decrypt(o.buffer,0,r),this.currentIV=o.slice(-16).buffer,d||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 Rg(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 Lg(this.subtle,new Uint8Array(r),i).decrypt(e.buffer,t)}).catch(n=>(up.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&&(up.log(`[decrypter]: ${e}`),this.logEnabled=!1)}}const Cg=Math.pow(2,17);class Dg{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 Mg({type:jf.NETWORK_ERROR,details:Hf.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(Og(e));e.gap=!1}const l=this.loader=n?new n(i):new s(i),d=_g(e);e.loader=l;const c=sg(i.fragLoadPolicy.default),u={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===e.sn?1/0:Cg};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 Mg({type:jf.NETWORK_ERROR,details:Hf.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:np({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 Mg({type:jf.NETWORK_ERROR,details:Hf.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:i,stats:t}))},onTimeout:(t,r,i)=>{this.resetLoader(e,l),o(new Mg({type:jf.NETWORK_ERROR,details:Hf.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(d,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(Og(e,t));const l=this.loader=n?new n(i):new s(i),d=_g(e,t);e.loader=l;const c=sg(i.fragLoadPolicy.default),u={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:Cg};t.stats=l.stats,l.load(d,u,{onSuccess:(i,n,s,o)=>{this.resetLoader(e,l),this.updateStatsFromPart(e,t);const d={frag:e,part:t,payload:i.data,networkDetails:o};r(d),a(d)},onError:(r,i,n,s)=>{this.resetLoader(e,l),o(new Mg({type:jf.NETWORK_ERROR,details:Hf.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:np({url:d.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 Mg({type:jf.NETWORK_ERROR,details:Hf.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 Mg({type:jf.NETWORK_ERROR,details:Hf.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 _g(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(Uf(n)&&Uf(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 Og(e,t){const r=new Error(`GAP ${e.gap?"tag":"attribute"} found`),i={type:jf.MEDIA_ERROR,details:Hf.FRAG_GAP,fatal:!1,frag:e,error:r,networkDetails:null};return t&&(i.part=t),(t||e).stats.aborted=!0,new Mg(i)}class Mg extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class Ng extends sp{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 Fg{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 $g={length:0,start:()=>0,end:()=>0};class Bg{static isBuffered(e,t){if(e){const r=Bg.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=Bg.getBuffered(e);return Bg.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=Bg.bufferedRanges(e);if(i.length)return Bg.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 d=n[e].start,c=n[e].end;if(-1===i&&t>=d&&t<=c&&(i=e),t+r>=d&&t<c)o=d,l=c,a=l-t;else if(t+r<d){s=d;break}}return{len:a,start:o||0,end:l||0,nextStart:s,buffered:e,bufferedIndex:i}}static getBuffered(e){try{return e.buffered||$g}catch(e){return up.log("failed to get media.buffered",e),$g}}}const Ug=/\{\$([a-zA-Z0-9-_]+)\}/g;function zg(e){return Ug.test(e)}function Gg(e,t){if(null!==e.variableList||e.hasVariableRefs){const r=e.variableList;return t.replace(Ug,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 jg(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 Hg(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 Vg=/^(\d+)x(\d+)$/,Wg=/(.+?)=(".*?"|.*?)(?:,|$)/g;class Yg{constructor(e,t){"string"==typeof e&&(e=Yg.parseAttrList(e,t)),rp(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=Vg.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(Wg.lastIndex=0;null!==(r=Wg.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=Gg(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":up.warn(`${e}: attribute ${n} is missing quotes`)}i[n]=s}return i}}function Kg(e){return"ID"!==e&&"CLASS"!==e&&"CUE"!==e&&"START-DATE"!==e&&"DURATION"!==e&&"END-DATE"!==e&&"END-ON-NEXT"!==e}function qg(e){return"SCTE35-OUT"===e||"SCTE35-IN"===e||"SCTE35-CMD"===e}class Xg{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]){up.warn(`DATERANGE tag attribute: "${t}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=t;break}e=rp(new Yg({}),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"]);Uf(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?(up.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(Uf(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&&Uf(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 Qg{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&&Uf(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 Zg(e,t){return e.length===t.length&&!e.some((e,r)=>e!==t[r])}function Jg(e,t){return!e&&!t||!(!e||!t)&&Zg(e,t)}function ev(e){return"AES-128"===e||"AES-256"===e||"AES-256-CTR"===e}function tv(e){switch(e){case"AES-128":case"AES-256":return Ag;case"AES-256-CTR":return kg;default:throw new Error(`invalid full segment method ${e}`)}}function rv(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0))}function iv(e){return Uint8Array.from(unescape(encodeURIComponent(e)),e=>e.charCodeAt(0))}function nv(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 sv(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=rv(n)):r=function(e){const t=iv(e).subarray(0,16),r=new Uint8Array(16);return r.set(t,16-t.length),r}(n)}}return r}const av="undefined"!=typeof self?self:void 0;var ov={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},lv="org.w3.clearkey",dv="com.apple.streamingkeydelivery",cv="com.microsoft.playready",uv="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function hv(e){switch(e){case dv:return ov.FAIRPLAY;case cv:return ov.PLAYREADY;case uv:return ov.WIDEVINE;case lv:return ov.CLEARKEY}}function fv(e){switch(e){case ov.FAIRPLAY:return dv;case ov.PLAYREADY:return cv;case ov.WIDEVINE:return uv;case ov.CLEARKEY:return lv}}function pv(e){const{drmSystems:t,widevineLicenseUrl:r}=e,i=t?[ov.FAIRPLAY,ov.WIDEVINE,ov.PLAYREADY,ov.CLEARKEY].filter(e=>!!t[e]):[];return!i[ov.WIDEVINE]&&r&&i.push(ov.WIDEVINE),i}const mv=null!=av&&null!=(gv=av.navigator)&&gv.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;var gv;function vv(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=rv(e).subarray(0,16);return nv(t),t}}return null}let yv={};class bv{static clearKeyUriToKeyIdMap(){yv={}}static setKeyIdForUri(e,t){yv[e]=t}static addKeyIdForUri(e){const t=Object.keys(yv).length%Number.MAX_SAFE_INTEGER,r=new Uint8Array(16);return new DataView(r.buffer,12,4).setUint32(0,t),yv[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&&!ev(e),null!=s&&s.startsWith("0x")&&(this.keyId=new Uint8Array(gp(s)))}matches(e){return e.uri===this.uri&&e.method===this.method&&e.encrypted===this.encrypted&&e.keyFormat===this.keyFormat&&Zg(e.keyFormatVersions,this.keyFormatVersions)&&Jg(e.iv,this.iv)&&Jg(e.keyId,this.keyId)}isSupported(){if(this.method){if(ev(this.method)||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method;switch(this.keyFormat){case dv:case uv:case cv:case lv: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(ev(this.method)){let t=this.iv;t||("number"!=typeof e&&(up.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 bv(this.method,this.uri,"identity",this.keyFormatVersions,t)}if(this.keyId){const e=yv[this.uri];if(e&&!Zg(this.keyId,e)&&bv.setKeyIdForUri(this.uri,this.keyId),this.pssh)return this}const r=sv(this.uri);if(r)switch(this.keyFormat){case uv: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=am(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=Ev(t));break;case cv:{const e=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=sm(e,0,r),this.keyId=vv(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[uv];if(t)return t.keyId;return null}(t),e||(e=Ev(t),e||(e=yv[this.uri])),e&&(this.keyId=e,bv.setKeyIdForUri(this.uri,e))}return this}}function Ev(e){const t=null==e?void 0:e[cv];if(t){const e=sv(t.uri);if(e)return vv(e)}return null}const wv=/#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,Sv=/#EXT-X-MEDIA:(.*)/g,Tv=/^#EXT(?:INF|-X-TARGETDURATION):/m,xv=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),Av=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 kv{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 Ap.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return Tv.test(e)}static parseMasterPlaylist(e,t){const r={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:zg(e)},i=[];if(wv.lastIndex=0,!e.startsWith("#EXTM3U"))return r.playlistParsingError=new Error("no EXTM3U delimiter"),r;let n;for(;null!=(n=wv.exec(e));)if(n[1]){var s;const e=new Yg(n[1],r),a=Gg(r,n[2]),o={attrs:e,bitrate:e.decimalInteger("BANDWIDTH")||e.decimalInteger("AVERAGE-BANDWIDTH"),name:e.NAME,url:kv.resolve(a,t)},l=e.decimalResolution("RESOLUTION");l&&(o.width=l.width,o.height=l.height),Cv(e.CODECS,o);const d=e["SUPPLEMENTAL-CODECS"];d&&(o.supplemental={},Cv(d,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 Yg(i,r),t=e["DATA-ID"];t&&(null===r.sessionData&&(r.sessionData={}),r.sessionData[t]=e);break}case"SESSION-KEY":{const e=Rv(i,t,r);e.encrypted&&e.isSupported()?(null===r.sessionKeys&&(r.sessionKeys=[]),r.sessionKeys.push(e)):up.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${i}"`);break}case"DEFINE":jg(r,new Yg(i,r),t);break;case"CONTENT-STEERING":{const e=new Yg(i,r);r.contentSteering={uri:kv.resolve(e["SERVER-URI"],t),pathwayId:e["PATHWAY-ID"]||"."};break}case"START":r.startTimeOffset=Pv(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(Sv.lastIndex=0;null!==(i=Sv.exec(e));){const e=new Yg(i[1],r),s=e.TYPE;if(s){const r=a[s],i=n[s]||[];n[s]=i;const l=e.LANGUAGE,d=e["ASSOC-LANGUAGE"],c=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?kv.resolve(e.URI,t):""};if(d&&(f.assocLang=d),c&&(f.channels=c),u&&(f.characteristics=u),h&&(f.instreamId=h),null!=r&&r.length){const e=kv.findGroup(r,f.groupId)||r[0];Dv(f,e,"audioCodec"),Dv(f,e,"textCodec")}i.push(f)}}return n}static parseLevelPlaylist(e,t,r,i,n,s){var a;const o={url:t},l=new Qg(t),d=l.fragments,c=[];let u,h,f,p,m=null,g=0,v=0,y=0,b=0,E=0,w=null,S=new Dp(i,o),T=-1,x=!1,A=null;if(xv.lastIndex=0,l.m3u8=e,l.hasVariableRefs=zg(e),"#EXTM3U"!==(null==(a=xv.exec(e))?void 0:a[0]))return l.playlistParsingError=new Error("Missing format identifier #EXTM3U"),l;for(;null!==(u=xv.exec(e));){x&&(x=!1,S=new Dp(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(Uf(S.duration)){S.playlistOffset=y,S.setStart(y),f&&Mv(S,f,l),S.sn=g,S.level=r,S.cc=b,d.push(S);const e=(" "+u[3]).slice(1);S.relurl=Gg(l,e),_v(S,w,c),w=S,y+=S.duration,g++,v=0,x=!0}}else{if(u=u[0].match(Av),!u){up.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=d.length);break;case"PLAYLIST-TYPE":l.type&&Nv(l,e,u),l.type=n.toUpperCase();break;case"MEDIA-SEQUENCE":0!==l.startSN?Nv(l,e,u):d.length>0&&Fv(l,e,u),g=l.startSN=parseInt(n);break;case"SKIP":{l.skippedSegments&&Nv(l,e,u);const t=new Yg(n,l),r=t.decimalInteger("SKIPPED-SEGMENTS");if(Uf(r)){l.skippedSegments+=r;for(let e=r;e--;)d.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&&Nv(l,e,u),l.targetduration=Math.max(parseInt(n),1);break;case"VERSION":null!==l.version&&Nv(l,e,u),l.version=parseInt(n);break;case"INDEPENDENT-SEGMENTS":break;case"ENDLIST":l.live||Nv(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),Uf(E)?S.bitrate=E:E=0;break;case"DATERANGE":{const e=new Yg(n,l),t=new Xg(e,l.dateRanges[e.ID],l.dateRangeTagCount);l.dateRangeTagCount++,t.isValid||l.skippedSegments?l.dateRanges[t.id]=t:up.warn(`Ignoring invalid DATERANGE tag: "${n}"`),S.tagList.push(["EXT-X-DATERANGE",n]);break}case"DEFINE":{const e=new Yg(n,l);"IMPORT"in e?Hg(l,e,s):jg(l,e,t)}break;case"DISCONTINUITY-SEQUENCE":0!==l.startCC?Nv(l,e,u):d.length>0&&Fv(l,e,u),l.startCC=b=parseInt(n);break;case"KEY":{const e=Rv(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=rp({},f)),f[e.keyFormat]=e)}else up.warn(`[Keys] Ignoring unsupported EXT-X-KEY tag: "${n}"`);break}case"START":l.startTimeOffset=Pv(n);break;case"MAP":{const e=new Yg(n,l);if(S.duration){const t=new Dp(i,o);Ov(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;Ov(S,e,r,f),m=S,x=!0}m.cc=b;break}case"SERVER-CONTROL":p&&Nv(l,e,u),p=new Yg(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&&Nv(l,e,u);const t=new Yg(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 Yg(n,l),s=new _p(i,S,o,r,t);e.push(s),S.duration+=s.duration;break}case"PRELOAD-HINT":{const e=new Yg(n,l);l.preloadHint=e;break}case"RENDITION-REPORT":{const e=new Yg(n,l);l.renditionReports=l.renditionReports||[],l.renditionReports.push(e);break}default:up.warn(`line parsed but not handled: ${u}`)}}}w&&!w.relurl?(d.pop(),y-=w.duration,l.partList&&(l.fragmentHint=w)):l.partList&&(_v(S,w,c),S.cc=b,l.fragmentHint=S,f&&Mv(S,f,l)),l.targetduration||(l.playlistParsingError=new Error("Missing Target Duration"));const k=d.length,L=d[0],I=d[k-1];if(y+=l.skippedSegments*l.targetduration,y>0&&k&&I){l.averagetargetduration=y/k;const e=I.sn;l.endSN="initSegment"!==e?e:0,l.live||(I.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}}(d,T),L&&c.unshift(L))}return l.fragmentHint&&(y+=l.fragmentHint.duration),l.totalduration=y,c.length&&l.dateRangeTagCount&&L&&Lv(c,l),l.endCC=b,l}}function Lv(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]],d=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=Iv(t,d,e,i,n);if(-1!==r){l.tagAnchor=t.fragments[r].ref;break}}}}function Iv(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 Rv(e,t,r){var i,n;const s=new Yg(e,r),a=null!=(i=s.METHOD)?i:"",o=s.URI,l=s.hexadecimalInteger("IV"),d=s.KEYFORMATVERSIONS,c=null!=(n=s.KEYFORMAT)?n:"identity";o&&s.IV&&!l&&up.error(`Invalid IV: ${s.IV}`);const u=o?kv.resolve(o,t):"",h=(d||"1").split("/").map(Number).filter(Number.isFinite);return new bv(a,u,c,h,l,s.KEYID)}function Pv(e){const t=new Yg(e).decimalFloatingPoint("TIME-OFFSET");return Uf(t)?t:null}function Cv(e,t){let r=(e||"").split(/[ ,]+/).filter(e=>e);["video","audio","text"].forEach(e=>{const i=r.filter(t=>dm(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 Dv(e,t,r){const i=t[r];i&&(e[r]=i)}function _v(e,t,r){e.rawProgramDateTime?r.push(e):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime)}function Ov(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 Mv(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 Nv(e,t,r){e.playlistParsingError=new Error(`#EXT-X-${t} must not appear more than once (${r[0]})`)}function Fv(e,t,r){e.playlistParsingError=new Error(`#EXT-X-${t} must appear before the first Media Segment (${r[0]})`)}function $v(e,t){const r=t.startPTS;if(Uf(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 Bv(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 d=t.startPTS,c=t.endPTS;if(Uf(d)){const u=Math.abs(d-r);e&&u>e.totalduration?a.warn(`media timestamps and playlist times differ by ${u}s for level ${t.level} ${e.url}`):Uf(t.deltaPTS)?t.deltaPTS=Math.max(u,t.deltaPTS):t.deltaPTS=u,o=Math.max(r,d),r=Math.min(r,d),n=void 0!==t.startDTS?Math.min(n,t.startDTS):n,l=Math.min(i,c),i=Math.max(i,c),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--)$v(m[f],m[f-1]);for(f=p;f<m.length-1;f++)$v(m[f],m[f+1]);return e.fragmentHint&&$v(m[m.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,u}function Uv(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 d=n;d<=s;d++){const n=l[a+d];let s=o[d];if(i&&!s&&n&&(s=t.fragments[d]=n),n&&s){r(n,s,d,o);const i=n.relurl,a=s.relurl;if(i&&qv(i,a))return void(t.playlistParsingError=zv(`media sequence mismatch ${s.sn}:`,e,t,n,s));if(n.cc!==s.cc)return void(t.playlistParsingError=zv(`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}Uf(e.startPTS)&&Uf(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=rp({},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 Xg(i[e].attr,t);n.isValid?(s[e]=n,t||(n.tagOrder+=a)):r.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${Um(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&&_v(o[e],o[e-1],i);Lv(i,t)}t.endCC=a[a.length-1].cc}if(!t.startCC){var l;const r=Vv(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?Bv(t,s,s.startPTS,s.endPTS,s.startDTS,s.endDTS,r):Gv(e,t),a.length&&(t.totalduration=t.edge-a[0].start),t.driftStartTime=e.driftStartTime,t.driftStart=e.driftStart;const d=t.advancedDateTime;if(t.advanced&&d){const e=t.edge;t.driftStart||(t.driftStartTime=d,t.driftStart=e),t.driftEndTime=d,t.driftEnd=e}else t.driftEndTime=e.driftEndTime,t.driftEnd=e.driftEnd,t.advancedDateTime=e.advancedDateTime;-1===t.requestScheduled&&(t.requestScheduled=e.requestScheduled)}function zv(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 Gv(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}jv(t,a)}function jv(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 Hv(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 Vv(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 Wv(e,t,r){return e?Yv(e.partList,t,r):null}function Yv(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 Kv(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 qv(e,t){return!(e===t||!t)&&Xv(e)!==Xv(t)}function Xv(e){return e.replace(/\?[^?]*$/,"")}function Qv(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 Zv(e,t){const r=e.start+t;e.startPTS=r,e.setStart(r),e.endPTS=r+e.duration}function Jv(e,t){const r=t.fragments;for(let t=0,i=r.length;t<i;t++)Zv(r[t],e);t.fragmentHint&&Zv(t.fragmentHint,e),t.alignedSliding=!0}function ey(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=Qv(t.fragments,r),n=Qv(e.fragments,r);if(!i||!n)return;up.log(`Aligning playlist at start of dicontinuity sequence ${r}`);Jv(i.start-n.start,e)}function ty(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=Qv(i,a),s=Qv(r,a)),n&&s||(n=i[Math.floor(i.length/2)],s=Qv(r,n.cc)||r[Math.floor(r.length/2)]);const o=n.programDateTime,l=s.programDateTime;if(!o||!l)return;Jv((l-o)/1e3-(s.start-n.start),e)}function ry(e,t,r){iy(e,t,r),e.addEventListener(t,r)}function iy(e,t,r){e.removeEventListener(t,r)}const ny=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},sy="STOPPED",ay="IDLE",oy="KEY_LOADING",ly="FRAG_LOADING",dy="FRAG_LOADING_WAITING_RETRY",cy="WAITING_TRACK",uy="PARSING",hy="PARSED",fy="ENDED",py="ERROR",my="WAITING_INIT_PTS",gy="WAITING_LEVEL";class vy extends Ng{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=sy,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=Bg.bufferInfo(i||r,s,e.maxBufferHole),o=!a.len;if(this.log(`Media seeking to ${Uf(s)?s.toFixed(3):s}, state: ${n}, ${o?"out of":"in"} buffer`),this.state===fy)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===ay&&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 Dg(e.config),this.keyLoader=r,this.fragmentTracker=t,this.config=e.config,this.decrypter=new Pg(e.config)}registerListeners(){const{hls:e}=this;e.on(Vf.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Vf.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Vf.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Vf.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(Vf.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(Vf.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Vf.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Vf.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Vf.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(Vf.ERROR,this.onError,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){if(this.state===sy)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=sy}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=Bg.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 Bg.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;ry(r,"seeking",this.onMediaSeeking),ry(r,"ended",this.onMediaEnded);const i=this.config;this.levels&&i.autoStartLoad&&this.state===sy&&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),iy(i,"seeking",this.onMediaSeeking),iy(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=sy,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===ly||!this.fragCurrent&&t===uy)&&(this.fragmentTracker.removeFragment(r),this.state=ay):("payload"in e&&(this.log(`Loaded ${r.type} sn: ${r.sn} of ${this.playlistLabel()} ${r.level}`),this.hls.trigger(Vf.FRAG_LOADED,e)),this._handleFragmentLoadComplete(e))}).catch(t=>{this.state!==sy&&this.state!==py&&(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)===yg){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)===bg&&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(Vf.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&&ev(n.method)){const s=self.performance.now();return this.decrypter.decrypt(new Uint8Array(i),n.key.buffer,n.iv.buffer,tv(n.method)).catch(e=>{throw t.trigger(Vf.ERROR,{type:jf.MEDIA_ERROR,details:Hf.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:r}),e}).then(i=>{const n=self.performance.now();return t.trigger(Vf.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!==sy&&this.state!==py&&(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!==sy&&(this.state=ay),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(Vf.ERROR,{type:jf.KEY_SYSTEM_ERROR,details:Hf.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?ny(Bg.getBuffered(r)):"(detached)"})`),Cp(e)){var i;if(e.type!==Zf){const t=e.elementaryStreams;if(!Object.keys(t).some(e=>!!t[e]))return void(this.state=ay)}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=ay}_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 Fg(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=oy,this.fragCurrent=e,a=this.keyLoader.load(e).then(e=>{if(!this.fragContextChanged(e.frag))return this.hls.trigger(Vf.KEY_LOADED,e),this.state===oy&&(this.state=ay),e}),this.hls.trigger(Vf.KEY_LOADING,{frag:e}),null===this.fragCurrent)return this.log("context changed in KEY_LOADING"),Promise.resolve(null);const o=this.fragPrevious;if(Cp(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&&Cp(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 d;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=ly,d=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(Vf.FRAG_LOADING,{frag:e,part:l,targetBufferTime:r}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):d}if(!e.url||this.loadedEndOfParts(n,r))return Promise.resolve(null)}}var l;if(Cp(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))}`),Uf(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=ly;const d=this.config.progressive&&e.type!==Zf;let c;return c=d&&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,d?i:void 0),a]).then(([e])=>(!d&&i&&i(e),e)).catch(e=>this.handleFragLoadError(e)),this.hls.trigger(Vf.FRAG_LOADING,{frag:e,targetBufferTime:r}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):c}doFragPartsLoad(e,t,r,i){return new Promise((n,s)=>{var a;const o=[],l=null==(a=r.details)?void 0:a.partList,d=t=>{this.fragmentLoader.loadPart(e,t,i).then(i=>{o[t.index]=i;const s=i.part;this.hls.trigger(Vf.FRAG_LOADED,i);const a=Wv(r.details,e.sn,t.index+1)||Yv(l,e.sn,t.index+1);if(!a)return n({frag:e,part:s,partsLoaded:o});d(a)}).catch(s)};d(t)})}handleFragLoadError(e){if("data"in e){const t=e.data;t.frag&&t.details===Hf.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):t.frag&&t.type===jf.KEY_SYSTEM_ERROR?(t.frag.abortRequests(),this.resetStartWhenNotLoaded(),this.resetFragmentLoading(t.frag)):this.hls.trigger(Vf.ERROR,t)}else this.hls.trigger(Vf.ERROR,{type:jf.OTHER_ERROR,details:Hf.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){const t=this.getCurrentContext(e);if(!t||this.state!==uy)return void(this.fragCurrent||this.state===sy||this.state===py||(this.state=ay));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===Zf)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?Wv(o,n,s):null,d=l?l.fragment:Vv(o,n,r);return d?(r&&r!==d&&(d.stats=r.stats),{frag:d,part:l,level:a}):null}bufferFragmentData(e,t,r,i,n){if(this.state!==uy)return;const{data1:s,data2:a}=e;let o=s;if(a&&(o=Jp(s,a)),!o.length)return;const l=this.initPTS[t.cc],d=l?-l.baseTime/l.timescale:void 0,c={type:e.type,frag:t,part:r,chunkMeta:i,offset:d,parent:t.type,data:o};if(this.hls.trigger(Vf.BUFFER_APPENDING,c),e.dropped&&e.independent&&!r){if(n)return;this.flushBufferGap(t)}}flushBufferGap(e){const t=this.media;if(!t)return;if(!Bg.isBuffered(t,t.currentTime))return void this.flushMainBuffer(0,e.start);const r=t.currentTime,i=Bg.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(!Uf(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=Bg.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 Bg.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=Xf){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 d=this.filterReplacedPrimary(o,t);if(!d&&o){const e=o.sn-t.startSN;d=this.filterReplacedPrimary(r[e+1]||null,t)}return this.mapToInitFragWhenRequired(d)}isLoopLoading(e,t){const r=this.fragmentTracker.getState(e);return(r===Eg||r===bg&&!!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(yy(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(yy(this.config)&&e.type!==Zf){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||!Uf(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(Zm(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=Jm(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,d=r.partList,c=!!(this.loadingParts&&null!=d&&d.length&&o);let u;if(c&&!this.bitrateTest&&d[d.length-1].fragment.sn===o.sn&&(s=s.concat(o),a=o.sn),e<t){var h;u=Xm(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===Eg||t===bg&&u.gap)&&(n=u),n&&u.sn===n.sn&&(!c||d[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)!==Eg?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&&Uf(n);if(s||!a&&!n){!function(e,t){e&&(ey(t,e),t.alignedSliding||ty(t,e),t.alignedSliding||t.skippedSegments||Gv(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&&Uf(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&&Cp(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===dy)||(this.state=ay)}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===Hf.FRAG_GAP;s&&this.fragmentTracker.fragBuffered(i,!0);const a=t.errorAction;if(!a)return void(this.state=py);const{action:o,flags:l,retryCount:d=0,retryConfig:c}=a,u=!!c,h=u&&o===ug,f=u&&!a.resolved&&l===fg,p=null==(r=this.hls.latestLevelDetails)?void 0:r.live;if(!h&&f&&Cp(i)&&!i.endList&&p&&!rg(t))this.resetFragmentErrors(e),this.treatAsGap(i),a.resolved=!0;else if((h||f)&&d<c.maxNumRetry){var m;const r=og(null==(m=t.response)?void 0:m.code),n=ng(c,d);if(this.resetStartWhenNotLoaded(),this.retryDate=self.performance.now()+n,this.state=dy,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 ${d+1}/${c.maxNumRetry} in ${n}ms`)}else if(c){if(this.resetFragmentErrors(e),!(d<c.maxNumRetry))return void this.warn(`${t.details} reached or exceeded max retry (${d})`);s||o===cg||(a.resolved=!0)}else this.state=o===dg?gy:py;this.tickImmediate()}checkRetryDate(){const e=self.performance.now(),t=this.retryDate,r=t===1/0;(!t||e>=t||r&&!og(0))&&(r&&this.log("Connection restored (online)"),this.resetStartWhenNotLoaded(),this.state=ay)}reduceLengthAndFlushBuffer(e){if(this.state===uy||this.state===hy){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===Qf&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==sy&&(this.state=ay)}afterBufferFlushed(e,t,r){if(!e)return;const i=Bg.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,i,r),this.state===fy&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==sy&&(this.state=ay)}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:Bv(n,e,a.startPTS,a.endPTS,a.startDTS,a.endDTS,this);return this.hls.trigger(Vf.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(Vf.ERROR,{type:jf.MEDIA_ERROR,details:Hf.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=hy,this.log(`Parsed ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)})`),this.hls.trigger(Vf.FRAG_PARSED,{frag:e,part:t})}playlistLabel(){return this.playlistType===Xf?"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 yy(e){return!!e.interstitialsController&&!1!==e.enableInterstitialPlayback}class by{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 Ey,wy={exports:{}};var Sy=(Ey||(Ey=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,d,c=this._events[o],u=arguments.length;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),u){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,i),!0;case 4:return c.fn.call(c.context,t,i,n),!0;case 5:return c.fn.call(c.context,t,i,n,s),!0;case 6:return c.fn.call(c.context,t,i,n,s,a),!0}for(d=1,l=new Array(u-1);d<u;d++)l[d-1]=arguments[d];c.fn.apply(c.context,l)}else{var h,f=c.length;for(d=0;d<f;d++)switch(c[d].once&&this.removeListener(e,c[d].fn,void 0,!0),u){case 1:c[d].fn.call(c[d].context);break;case 2:c[d].fn.call(c[d].context,t);break;case 3:c[d].fn.call(c[d].context,t,i);break;case 4:c[d].fn.call(c[d].context,t,i,n);break;default:if(!l)for(h=1,l=new Array(u-1);h<u;h++)l[h-1]=arguments[h];c[d].fn.apply(c[d].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,d=[],c=o.length;l<c;l++)(o[l].fn!==t||n&&!o[l].once||i&&o[l].context!==i)&&d.push(o[l]);d.length?this._events[s]=1===d.length?d[0]:d: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}(wy)),wy.exports),Ty=vp(Sy);const xy="1.6.15",Ay={};function ky(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 Ly(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 Iy(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 Ry(e,t){const r=t;let i=0;for(;Ly(e,t);){i+=10;i+=Iy(e,t+6),ky(e,t+10)&&(i+=10),t+=i}if(i>0)return e.subarray(r,r+i)}function Py(e,t){return 255===e[t]&&240==(246&e[t+1])}function Cy(e,t){return 1&e[t+1]?7:9}function Dy(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function _y(e,t){return t+1<e.length&&Py(e,t)}function Oy(e,t){if(_y(e,t)){const r=Cy(e,t);if(t+r>=e.length)return!1;const i=Dy(e,t);if(i<=r)return!1;const n=t+i;return n===e.length||_y(e,n)}return!1}function My(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(Vf.ERROR,Vf.ERROR,{type:jf.MEDIA_ERROR,details:Hf.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,d=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][s];let c=s;5!==a&&29!==a||(c-=3);const u=[a<<3|(14&c)>>1,(1&c)<<7|o<<3];return up.log(`manifest codec:${i}, parsed codec:${l}, channels:${o}, rate:${d} (ADTS object type:${a} sampling index:${s})`),{config:u,samplerate:d,channelCount:o,codec:l,parsedCodec:l,manifestCodec:i}}(t,r,i,n);if(!s)return;rp(e,s)}}function Ny(e){return 9216e4/e}function Fy(e,t,r,i,n){const s=i+n*Ny(e.samplerate),a=function(e,t){const r=Cy(e,t);if(t+r<=e.length){const i=Dy(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,d=Math.max(0,r+l-t.length);d?(o=new Uint8Array(l-n),o.set(t.subarray(r+n,t.length),0)):o=t.subarray(r+n,r+l);const c={unit:o,pts:s};return d||e.samples.push(c),{sample:c,length:l,missing:d}}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 $y(e,t){return Ly(e,t)&&Iy(e,t+6)+10<=e.length-t}function By(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,d=Math.floor(Math.max(0,Math.min(l,o))),c=Math.floor(Math.min(d+Math.max(r,0),o));var u;return new i(n,d,c-d)}(e,t,r,Uint8Array)}function Uy(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=pp(By(e.data,1,r)),n=e.data[2+r],s=e.data.subarray(3+r).indexOf(0);if(-1===s)return;const a=pp(By(e.data,3+r,s));let o;return o="--\x3e"===i?pp(By(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 zy(e){return"PRIV"===e.type?function(e){if(e.size<2)return;const t=pp(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=pp(e.data.subarray(t),!0);t+=r.length+1;const i=pp(e.data.subarray(t));return{key:e.type,info:r,data:i}}const t=pp(e.data);return{key:e.type,info:"",data:t}}(e):"APIC"===e.type?Uy(e):function(e){if(e.size<2)return;if("TXXX"===e.type){let t=1;const r=pp(e.data.subarray(t),!0);t+=r.length+1;const i=pp(e.data.subarray(t));return{key:e.type,info:r,data:i}}const t=pp(e.data.subarray(1));return{key:e.type,info:"",data:t}}(e)}function Gy(e){const t=String.fromCharCode(e[0],e[1],e[2],e[3]),r=Iy(e,4);return{type:t,size:r,data:e.subarray(10,10+r)}}function jy(e){let t=0;const r=[];for(;Ly(e,t);){const i=Iy(e,t+6);e[t+5]>>6&1&&(t+=10),t+=10;const n=t+i;for(;t+10<n;){const i=Gy(e.subarray(t)),n=zy(i);n&&r.push(n),t+=i.size+10}ky(e,t)&&(t+=10)}return r}function Hy(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info}function Vy(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 Wy(e){const t=jy(e);for(let e=0;e<t.length;e++){const r=t[e];if(Hy(r))return Vy(r)}}let Yy=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 Ky(e="",t=9e4){return{type:e,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}class qy{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=Jp(this.cachedData,e),this.cachedData=null);let r,i=Ry(e,0),n=i?i.length:0;const s=this._audioTrack,a=this._id3Track,o=i?Wy(i):void 0,l=e.length;for((null===this.basePTS||0===this.frameIndex&&Uf(o))&&(this.basePTS=Xy(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:Yy.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 $y(e,n)?(i=Ry(e,n),a.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:Yy.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=Jp(this.cachedData,t):this.cachedData=t}}return{audioTrack:s,videoTrack:Ky(),id3Track:a,textTrack:Ky()}}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:Ky(),id3Track:this._id3Track,textTrack:Ky()}}destroy(){this.cachedData=null,this._audioTrack=this._id3Track=void 0}}const Xy=(e,t,r)=>{if(Uf(e))return 90*e;return 9e4*t+(r?9e4*r.baseTime/r.timescale:0)};let Qy=null;const Zy=[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],Jy=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],eb=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],tb=[0,1,1,4];function rb(e,t,r,i,n){if(r+24>t.length)return;const s=ib(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 ib(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*Zy[14*(3===r?3-i:3===i?3:4)+n-1],d=Jy[3*(3===r?0:2===r?1:2)+s],c=3===o?1:2,u=eb[r][i],h=tb[i],f=8*u*h,p=Math.floor(u*l/d+a)*h;if(null===Qy){const e=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Qy=e?parseInt(e[1]):0}return!!Qy&&Qy<=87&&2===i&&l>=224e3&&0===o&&(e[t+3]=128|e[t+3]),{sampleRate:d,channelCount:c,frameLength:p,samplesPerFrame:f}}}function nb(e,t){return!(255!==e[t]||224&~e[t+1]||!(6&e[t+1]))}function sb(e,t){return t+1<e.length&&nb(e,t)}function ab(e,t){if(t+1<e.length&&nb(e,t)){const r=4,i=ib(e,t);let n=r;null!=i&&i.frameLength&&(n=i.frameLength);const s=t+n;return s===e.length||sb(e,s)}return!1}const ob=(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 lb extends qy{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=db(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=Ry(e,0);if(!t)return!1;const r=t.length;return 11===e[r]&&119===e[r+1]&&void 0!==Wy(t)&&ob(e,r)<16}}function db(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 d=t[r+6]>>5;let c=0;2===d?c+=2:(1&d&&1!==d&&(c+=2),4&d&&(c+=2));const u=(t[r+6]<<8|t[r+7])>>12-c&1,h=[2,1,2,3,3,4,4,5][d]+u,f=t[r+5]>>3,p=7&t[r+5],m=new Uint8Array([s<<6|f<<1|p>>2,(3&p)<<6|d<<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 cb=/\/emsg[-/]ID3/i;function ub(e,t){return Uf(e.presentationTime)?e.presentationTime/e.timeScale:t+e.presentationTimeDelta/e.timeScale}class hb{constructor(e,t,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new Pg(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,Ag)}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=nm(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 fb{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,d,c=0,u=-1,h=0;for(-1===n&&(u=0,h=this.getNALuType(t,0),n=0,c=1);c<i;)if(o=t[c++],n)if(1!==n)if(o)if(1===o){if(l=c-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&&c<=4-s&&r.state&&(r.data=r.data.subarray(0,r.data.byteLength-s)),l>0&&(r.data=Jp(r.data,t.subarray(0,l)),r.state=0))}c<i?(d=this.getNALuType(t,c),u=c,h=d,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=Jp(r.data,t))}return e.naluState=n,a}}class pb{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&&up.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 mb extends fb{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 d;if(t)null!=(d=a)&&d.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,im(i.data,1,r.pts,t.samples);break;case 7:{var c,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==(c=e.pixelRatio)?void 0:c[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 pb(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 pb(e);let r,i,n,s=0,a=0,o=0,l=0;const d=t.readUByte.bind(t),c=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);d();const v=d();if(c(5),f(3),d(),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=c(1);0===w&&f(1),f(1),h()&&(s=u(),a=u(),o=u(),l=u());let S=[1,1];if(h()&&h()){switch(d()){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=[d()<<8|d(),d()<<8|d()]}}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 gb extends fb{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 d;if(s=!0,o)null!=(d=a)&&d.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,im(i.data,2,r.pts,t.samples);break;case 32:s=!0,e.vps||("object"!=typeof e.params&&(e.params={}),e.params=rp(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 pb(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 pb(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(),d=t.readUByte(),c=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 L=t.readUEG(),I=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|d;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,d],general_constraint_indicator_flags:[c,u,h,f,p,m],general_level_idc:g,bit_depth:L+8,bit_depth_luma_minus8:L,bit_depth_chroma_minus8:I,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 pb(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 vb=188;class yb{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=yb.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-vb)+1,i=0;for(;i<r;){let n=!1,s=-1,a=0;for(let o=i;o<t;o+=vb){if(71!==e[o]||t-o!==vb&&71!==e[o+vb]){if(a)return-1;break}if(a++,-1===s&&(s=o,0!==s&&(r=Math.min(s+18612,e.length-vb)+1)),n||(n=0===bb(e,o)),n&&a>1&&(0===s&&a>2||o+vb>r))return s}i++}return-1}static createTrack(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:Fp[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=yb.createTrack("video"),this._videoTrack.duration=i,this._audioTrack=yb.createTrack("audio",i),this._id3Track=yb.createTrack("id3"),this._txtTrack=yb.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 d=s.pid,c=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=Jp(this.remainderData,e)).length,this.remainderData=null),y<vb&&!i)return this.remainderData=e,{audioTrack:a,videoTrack:s,id3Track:o,textTrack:l};const b=Math.max(0,yb.syncOffset(e));y-=(y-b)%vb,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+=vb)if(71===e[t]){const i=!!(64&e[t+1]),y=bb(e,t);let E;if((48&e[t+3])>>4>1){if(E=t+5+e[t+4],E===t+vb)continue}else E=t+4;switch(y){case d:i&&(c&&(n=xb(c,this.logger))&&(this.readyVideoParser(s.segmentCodec),null!==this.videoParser&&this.videoParser.parsePES(s,l,n,!1)),c={data:[],size:0}),c&&(c.data.push(e.subarray(E,t+vb)),c.size+=t+vb-E);break;case u:if(i){if(f&&(n=xb(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+vb)),f.size+=t+vb-E);break;case h:i&&(p&&(n=xb(p,this.logger))&&this.parseID3PES(o,n),p={data:[],size:0}),p&&(p.data.push(e.subarray(E,t+vb)),p.size+=t+vb-E);break;case 0:i&&(E+=e[E]+1),v=this._pmtId=Eb(e,E);break;case v:{i&&(E+=e[E]+1);const n=wb(e,E,this.typeSupported,r,this.observer,this.logger);d=n.videoPid,d>0&&(s.pid=d,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&&Sb(this.observer,new Error(`Found ${E} TS packet/s that do not start with 0x47`),void 0,this.logger),s.pesData=c,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=xb(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=xb(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=xb(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 hb(this.observer,this.config,t);return this.decrypt(i,n)}readyVideoParser(e){null===this.videoParser&&("avc"===e?this.videoParser=new mb:"hevc"===e&&(this.videoParser=new gb))}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=Jp(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&&!_y(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",Sb(this.observer,new Error(e),t,this.logger),!t)return}if(My(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=Ny(e.samplerate);a=i.sample.pts+t}}let l,d=0;for(;n<s;){if(l=Fy(e,o,n,a,d),n+=l.length,l.missing){this.aacOverFlow=l;break}for(d++;n<s-1&&!_y(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(sb(r,s)){const t=rb(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=db(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=rp({},t,{type:this._videoTrack?Yy.emsg:Yy.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(r)}}function bb(e,t){return((31&e[t+1])<<8)+e[t+2]}function Eb(e,t){return(31&e[t+10])<<8|e[t+11]}function wb(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=bb(e,t),l=(15&e[t+3])<<8|e[t+4];switch(e[t]){case 207:if(!i){Tb("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){Tb("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){Tb("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 Sb(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 Sb(e,t,r,i){i.warn(`parsing error: ${t.message}`),e.emit(Vf.ERROR,Vf.ERROR,{type:jf.MEDIA_ERROR,details:Hf.FRAG_PARSING_ERROR,fatal:!1,levelRetry:r,error:t,reason:t.message})}function Tb(e,t){t.log(`${e} with AES-128-CBC encryption found in unencrypted stream`)}function xb(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]=Jp(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 d=r[7];192&d&&(s=536870912*(14&r[9])+4194304*(255&r[10])+16384*(254&r[11])+128*(255&r[12])+(254&r[13])/2,64&d?(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 c=n+9;if(e.size<=c)return null;e.size-=c;const u=new Uint8Array(e.size);for(let e=0,t=l.length;e<t;e++){r=l[e];let t=r.byteLength;if(c){if(c>t){c-=t;continue}r=r.subarray(c),t-=c,c=0}u.set(r,o),o+=t}return i&&(i-=n+3),{data:u,pts:s,dts:a,len:i}}return null}class Ab{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 kb=Math.pow(2,32)-1;class Lb{static init(){let e;for(e in Lb.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:[]},Lb.types)Lb.types.hasOwnProperty(e)&&(Lb.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]);Lb.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]);Lb.STTS=Lb.STSC=Lb.STCO=n,Lb.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),Lb.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),Lb.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),Lb.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]);Lb.FTYP=Lb.box(Lb.types.ftyp,s,o,s,a),Lb.DINF=Lb.box(Lb.types.dinf,Lb.box(Lb.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 Lb.box(Lb.types.hdlr,Lb.HDLR_TYPES[e])}static mdat(e){return Lb.box(Lb.types.mdat,e)}static mdhd(e,t){t*=e;const r=Math.floor(t/(kb+1)),i=Math.floor(t%(kb+1));return Lb.box(Lb.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 Lb.box(Lb.types.mdia,Lb.mdhd(e.timescale||0,e.duration||0),Lb.hdlr(e.type),Lb.minf(e))}static mfhd(e){return Lb.box(Lb.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?Lb.box(Lb.types.minf,Lb.box(Lb.types.smhd,Lb.SMHD),Lb.DINF,Lb.stbl(e)):Lb.box(Lb.types.minf,Lb.box(Lb.types.vmhd,Lb.VMHD),Lb.DINF,Lb.stbl(e))}static moof(e,t,r){return Lb.box(Lb.types.moof,Lb.mfhd(e),Lb.traf(r,t))}static moov(e){let t=e.length;const r=[];for(;t--;)r[t]=Lb.trak(e[t]);return Lb.box.apply(null,[Lb.types.moov,Lb.mvhd(e[0].timescale||0,e[0].duration||0)].concat(r).concat(Lb.mvex(e)))}static mvex(e){let t=e.length;const r=[];for(;t--;)r[t]=Lb.trex(e[t]);return Lb.box.apply(null,[Lb.types.mvex,...r])}static mvhd(e,t){t*=e;const r=Math.floor(t/(kb+1)),i=Math.floor(t%(kb+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 Lb.box(Lb.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 Lb.box(Lb.types.sdtp,r)}static stbl(e){return Lb.box(Lb.types.stbl,Lb.stsd(e),Lb.box(Lb.types.stts,Lb.STTS),Lb.box(Lb.types.stsc,Lb.STSC),Lb.box(Lb.types.stsz,Lb.STSZ),Lb.box(Lb.types.stco,Lb.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=Lb.box(Lb.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,d=e.pixelRatio[0],c=e.pixelRatio[1];return Lb.box(Lb.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,Lb.box(Lb.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),Lb.box(Lb.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,255&d,c>>24,c>>16&255,c>>8&255,255&c])))}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 Lb.box(Lb.types.mp4a,Lb.audioStsd(e),Lb.box(Lb.types.esds,Lb.esds(e)))}static mp3(e){return Lb.box(Lb.types[".mp3"],Lb.audioStsd(e))}static ac3(e){return Lb.box(Lb.types["ac-3"],Lb.audioStsd(e),Lb.box(Lb.types.dac3,e.config))}static stsd(e){const{segmentCodec:t}=e;if("audio"===e.type){if("aac"===t)return Lb.box(Lb.types.stsd,Lb.STSD,Lb.mp4a(e));if("ac3"===t&&e.config)return Lb.box(Lb.types.stsd,Lb.STSD,Lb.ac3(e));if("mp3"===t&&"mp3"===e.codec)return Lb.box(Lb.types.stsd,Lb.STSD,Lb.mp3(e))}else{if(!e.pps||!e.sps)throw new Error("video track missing pps or sps");if("avc"===t)return Lb.box(Lb.types.stsd,Lb.STSD,Lb.avc1(e));if("hevc"===t&&e.vps)return Lb.box(Lb.types.stsd,Lb.STSD,Lb.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/(kb+1)),a=Math.floor(r%(kb+1));return Lb.box(Lb.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=Lb.sdtp(e),i=e.id,n=Math.floor(t/(kb+1)),s=Math.floor(t%(kb+1));return Lb.box(Lb.types.traf,Lb.box(Lb.types.tfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i])),Lb.box(Lb.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])),Lb.trun(e,r.length+16+20+8+16+8+8),r)}static trak(e){return e.duration=e.duration||4294967295,Lb.box(Lb.types.trak,Lb.tkhd(e),Lb.mdia(e))}static trex(e){const t=e.id;return Lb.box(Lb.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,d,c,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,d=o.size,c=o.flags,u=o.cts,s.set([l>>>24&255,l>>>16&255,l>>>8&255,255&l,d>>>24&255,d>>>16&255,d>>>8&255,255&d,c.isLeading<<2|c.dependsOn,c.isDependedOn<<6|c.hasRedundancy<<4|c.paddingValue<<1|c.isNonSync,61440&c.degradPrio,15&c.degradPrio,u>>>24&255,u>>>16&255,u>>>8&255,255&u],12+16*a);return Lb.box(Lb.types.trun,s)}static initSegment(e){Lb.types||Lb.init();const t=Lb.moov(e);return Jp(Lb.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=Lb.box(Lb.types.hvcC,s),l=e.width,d=e.height,c=e.pixelRatio[0],u=e.pixelRatio[1];return Lb.box(Lb.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,d>>8&255,255&d,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,Lb.box(Lb.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),Lb.box(Lb.types.pasp,new Uint8Array([c>>24,c>>16&255,c>>8&255,255&c,u>>24,u>>16&255,u>>8&255,255&u])))}}Lb.types=void 0,Lb.HDLR_TYPES=void 0,Lb.STTS=void 0,Lb.STSC=void 0,Lb.STCO=void 0,Lb.STSZ=void 0,Lb.VMHD=void 0,Lb.SMHD=void 0,Lb.STSD=void 0,Lb.FTYP=void 0,Lb.DINF=void 0;function Ib(e,t,r=1,i=!1){const n=e*t*r;return i?Math.round(n):n}function Rb(e,t=!1){return Ib(e,1e3,1/9e4,t)}function Pb(e){const{baseTime:t,timescale:r,trackId:i}=e;return`${t/r} (${t}/${r}) trackId: ${i}`}let Cb,Db=null,_b=null;function Ob(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 Mb extends sp{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===Db){const e=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Db=e?parseInt(e[1]):0}if(null===_b){const e=navigator.userAgent.match(/Safari\/(\d+)/i);_b=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?Pb(t):t} > ${e?Pb(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=Nb(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,d,c,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||(c=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=(Nb(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"),c=this.generateIS(e,t,n,s)),d=this.remuxAudio(e,p,this.isAudioContiguous,s,v||E||o===Qf?m:void 0),E){const i=d?d.endPTS-d.startPTS:0;t.inputTimeScale||(this.warn("regenerate InitSegment as video detected"),c=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=Fb(r,n,this._initPTS,this._initDTS)),i.samples.length&&(u=$b(i,n,this._initPTS))),{audio:d,video:l,initSegment:c,independent:f,text:u,id3:h}}computeInitPts(e,t,r,i){const n=Math.round(r*t);let s=Nb(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 d,c,u,h=!l||i,f="audio/mp4",p=-1;if(h&&(d=c=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):Lb.initSegment([e]),metadata:{channelCount:e.channelCount}},h&&(p=e.id,u=e.inputTimeScale,l&&u===l.timescale?h=!1:d=c=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:Lb.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=Nb(s[0].dts,e),i=this.computeInitPts(t,u,r,"video"),n=this.computeInitPts(e,u,r,"video");c=Math.min(c,i),d=Math.min(d,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} ${d/u} != initPTS: ${l.baseTime/l.timescale} (${l.baseTime}/${l.timescale}) trackId: ${l.trackId}`),this.log(`Found initPTS at playlist time: ${r} offset: ${d/u} (${d}/${u}) trackId: ${p}`),this._initPTS={baseTime:d,timescale:u,trackId:p},this._initDTS={baseTime:c,timescale:u,trackId:p}):d=u=void 0,{tracks:o,initPTS:d,timescale:u,trackId:p}}remuxVideo(e,t,r,i){const n=e.inputTimeScale,s=e.samples,a=[],o=s.length,l=this._initPTS,d=l.baseTime*n/l.timescale;let c,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=d+t*n,i=s[0].pts-Nb(s[0].dts,s[0].pts);Db&&null!==h&&Math.abs(e-i-(h+d))<15e3?r=!0:h=e-i-d}const y=h+d;for(let e=0;e<o;e++){const t=s[e];t.pts=Nb(t.pts,y),t.dts=Nb(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}),c=s[0].dts,u=s[s.length-1].dts;const b=u-c,E=b?Math.round(b/(o-1)):p||e.inputTimeScale/30;if(r){const r=c-y,i=r>E,n=r<-1;if((i||n)&&(i?this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${Rb(r,!0)} ms (${r}dts) hole between fragments detected at ${t.toFixed(3)}`):this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${Rb(-r,!0)} ms (${r}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!n||y>=s[0].pts||Db)){c=y;const e=s[0].pts-r;if(i)s[0].dts=c,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: ${Rb(e,!0)}/${Rb(c,!0)}, delta: ${Rb(r,!0)} ms`)}}c=Math.max(0,c);let w=0,S=0,T=c;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(Vf.ERROR,Vf.ERROR,{type:jf.MUX_ERROR,details:Hf.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(Lb.types.mdat,4);let L=!1,I=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,c=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,c+=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+d)-t.pts;s>e?(p=s-a,p<0?p=a:L=!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);I=Math.min(I,p),P=Math.max(P,p),R=Math.min(R,l),C=Math.max(C,l),a.push(Ob(t.key,p,c,u))}if(a.length)if(Db){if(Db<70){const e=a[0].flags;e.dependsOn=2,e.isNonSync=0}}else if(_b&&C-R<P-I&&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=c;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=L||!p?E:p;const D=u+p;this.nextVideoTs=h=D-d,this.videoSampleDuration=p,this.isVideoContiguous=!0;const _={data1:Lb.moof(e.sequenceNumber++,c,rp(e,{samples:a})),data2:A,startPTS:(m-d)/n,endPTS:(g+p-d)/n,startDTS:(c-d)/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,d=this._initPTS,c="mp3"===e.segmentCodec&&this.typeSupported.mpeg,u=[],h=void 0!==n;let f=e.samples,p=c?0:8,m=this.nextAudioTs||-1;const g=d.baseTime*s/d.timescale,v=g+t*s;if(this.isAudioContiguous=r=r||f.length&&m>0&&(i&&Math.abs(v-(m+g))<9e3||Math.abs(Nb(f[0].pts,v)-(m+g))<20*l),f.forEach(function(e){e.pts=Nb(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,d=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&&d<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=Ab.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(Vf.ERROR,Vf.ERROR,{type:jf.MUX_ERROR,details:Hf.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:w,reason:`fail allocating audio mdat ${w}`})}if(!c){new DataView(y.buffer).setUint32(0,w),y.set(Lb.types.mdat,4)}}y.set(n,p);const l=n.byteLength;p+=l,u.push(Ob(!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=c?new Uint8Array(0):Lb.moof(e.sequenceNumber++,b/a,rp({},e,{samples:u}));e.samples=[];const k=(b-g)/s,L=this.nextAudioTs/s,I={data1:A,data2:y,startPTS:k,endPTS:L,startDTS:k,endDTS:L,type:"audio",hasAudio:!0,hasVideo:!1,nb:T};return this.isAudioContiguous=!0,I}}function Nb(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 Fb(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=Nb(n.pts-r.baseTime*s/r.timescale,t*s)/s,n.dts=Nb(n.dts-i.baseTime*s/i.timescale,t*s)/s}const a=e.samples;return e.samples=[],{samples:a}}function $b(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=Nb(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 Bb(e,t,r=!1){return void 0!==(null==e?void 0:e.start)?(e.start+(r?e.duration:0))/e.timescale:t}function Ub(e,t,r){const i=e.codec;if(i&&i.length>4)return i;if(t===Lp){if("ec-3"===i||"ac-3"===i||"alac"===i)return i;if("fLaC"===i||"Opus"===i){return vm(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{Cb=self.performance.now.bind(self.performance)}catch(e){Cb=Date.now}const zb=[{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=Ky("video",1),s=this.audioTrack=Ky("audio",1),a=this.txtTrack=Ky("text",1);if(this.id3Track=Ky("id3",1),this.timeOffset=0,null==e||!e.byteLength)return;const o=Vp(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=Fp.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=Up(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=Jp(this.remainderData,e));const t=function(e){const t={valid:null,remainder:null},r=jp(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=em(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=em(e,t),{videoTrack:t,audioTrack:Ky(),id3Track:i,textTrack:Ky()}}extractID3Track(e,t){const r=this.id3Track;if(e.samples.length){const i=jp(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,d=0;if(0===t){for(;"\0"!==$p(e.subarray(d,d+1));)r+=$p(e.subarray(d,d+1)),d+=1;for(r+=$p(e.subarray(d,d+1)),d+=1;"\0"!==$p(e.subarray(d,d+1));)i+=$p(e.subarray(d,d+1)),d+=1;i+=$p(e.subarray(d,d+1)),d+=1,n=Up(e,12),s=Up(e,16),o=Up(e,20),l=Up(e,24),d=28}else if(1===t){d+=4,n=Up(e,d),d+=4;const t=Up(e,d);d+=4;const s=Up(e,d);for(d+=4,a=2**32*t+s,zf(a)||(a=Number.MAX_SAFE_INTEGER,up.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=Up(e,d),d+=4,l=Up(e,d),d+=4;"\0"!==$p(e.subarray(d,d+1));)r+=$p(e.subarray(d,d+1)),d+=1;for(r+=$p(e.subarray(d,d+1)),d+=1;"\0"!==$p(e.subarray(d,d+1));)i+=$p(e.subarray(d,d+1)),d+=1;i+=$p(e.subarray(d,d+1)),d+=1}return{schemeIdUri:r,value:i,timeScale:n,presentationTime:a,presentationTimeDelta:s,eventDuration:o,id:l,payload:e.subarray(d,e.byteLength)}}(e);if(cb.test(i.schemeIdUri)){const e=ub(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:Yy.emsg,duration:n})}else if(this.config.enableEmsgKLVMetadata&&i.schemeIdUri.startsWith("urn:misb:KLV:bin:1910.1")){const e=ub(i,t);r.samples.push({data:i.payload,len:i.payload.byteLength,dts:e,pts:e,type:Yy.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 sp{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=Vp(e);if(t)!function(e,t){if(!e||!t)return;const r=t.keyId;r&&t.isCommonEncryption&&Qp(e,(e,t)=>{const i=e.subarray(8,24);i.some(e=>0!==e)||(up.log(`[eme] Patching keyId in 'enc${t?"a":"v"}>sinf>>tenc' box: ${mp(i)} -> ${mp(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=Ub(n,Lp,this)),s&&(i=Ub(s,Ip,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:d}=this;const c={audio:void 0,video:void 0,text:i,id3:r,initSegment:void 0};Uf(d)||(d=this.lastEndTime=n||0);const u=t.samples;if(!u.length)return c;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."),c;this.emitInitSegment&&(h.tracks=this.initTracks,this.emitInitSegment=!1);const p=function(e,t,r){const i={},n=jp(e,["moof","traf"]);for(let e=0;e<n.length;e++){const s=n[e],a=jp(s,["tfhd"])[0],o=Up(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 d=i[o],c=jp(s,["tfdt"])[0];if(c){const e=c[0];let t=Up(c,4);1===e&&(t===Mp?r.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"):(t*=Mp+1,t+=Up(c,8))),Uf(t)&&(!Uf(d.start)||t<d.start)&&(d.start=t)}const u=l.default,h=Up(a,0)|(null==u?void 0:u.flags);let f=(null==u?void 0:u.duration)||0;8&h&&(f=Up(a,2&h?12:8));const p=jp(s,["trun"]);let m=d.start||0,g=0,v=f;for(let e=0;e<p.length;e++){const t=p[e],r=Up(t,4),i=d.sampleCount;d.sampleCount+=r;const n=1&t[3],s=4&t[3],a=1&t[2],o=2&t[2],l=4&t[2],c=8&t[2];let u=8,h=r;for(n&&(u+=4),s&&r&&(1&t[u+1]||void 0!==d.keyFrameIndex||(d.keyFrameIndex=i),u+=4,a?(v=Up(t,u),u+=4):v=f,o&&(u+=4),c&&(u+=4),m+=v,g+=v,h--);h--;)a?(v=Up(t,u),u+=4):v=f,o&&(u+=4),l&&(1&t[u+1]||void 0===d.keyFrameIndex&&(d.keyFrameIndex=d.sampleCount-(h+1),d.keyFrameStart=m),u+=4),c&&(u+=4),m+=v,g+=v;!g&&f&&(g+=f*r)}d.duration+=g}if(!Object.keys(i).some(e=>i[e].duration)){let t=1/0,r=0;const n=jp(e,["sidx"]);for(let e=0;e<n.length;e++){const i=Hp(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&&Uf(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=Bb(g,1/0),y=Bb(m,1/0),b=Bb(g,0,!0),E=Bb(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 L=!!f.audio,I=!!f.video;let R="";L&&(R+="audio"),I&&(R+="video");const P={data1:u,startPTS:A,startDTS:A,endPTS:k,endDTS:k,type:R,hasAudio:L,hasVideo:I,nb:1,dropped:0,encrypted:!!f.audio&&f.audio.encrypted||!!f.video&&f.video.encrypted};c.audio=L&&!I?P:void 0,c.video=I?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||(c.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 c.initSegment=h,c.id3=Fb(r,n,l,l),i.samples.length&&(c.text=$b(i,n,l)),c}}},{demux:yb,remux:Mb},{demux:class extends qy{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=Ry(e,0);let i=(null==r?void 0:r.length)||0;if(ab(e,i))return!1;for(let r=e.length;i<r;i++)if(Oy(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)&&Py(e,t)&&Dy(e,t)<=e.length-t}(e,t)}appendFrame(e,t,r){My(e,this.observer,t,r,e.manifestCodec);const i=Fy(e,t,r,this.basePTS,this.frameIndex);if(i&&0===i.missing)return i}},remux:Mb},{demux:class extends qy{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=Ry(e,0);let r=(null==t?void 0:t.length)||0;if(t&&11===e[r]&&119===e[r+1]&&void 0!==Wy(t)&&ob(e,r)<=16)return!1;for(let t=e.length;r<t;r++)if(ab(e,r))return up.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return function(e,t){return nb(e,t)&&4<=e.length-t}(e,t)}appendFrame(e,t,r){if(null!==this.basePTS)return rb(e,t,r,this.basePTS,this.frameIndex)}},remux:Mb}];zb.splice(2,0,{demux:lb,remux:Mb});class Gb{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=Cb();let s=new Uint8Array(e);const{currentTransmuxState:a,transmuxConfig:o}=this;i&&(this.currentTransmuxState=i);const{contiguous:l,discontinuity:d,trackSwitch:c,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&&ev(b.method)){const e=this.getDecrypter(),t=tv(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=Cb(),jb(r);s=new Uint8Array(i)}}const E=this.needsProbing(d,c);if(E){const e=this.configureTransmuxer(s);if(e)return this.logger.warn(`[transmuxer] ${e.message}`),this.observer.emit(Vf.ERROR,Vf.ERROR,{type:jf.MEDIA_ERROR,details:Hf.FRAG_PARSING_ERROR,fatal:!1,error:e,reason:e.message}),n.executeEnd=Cb(),jb(r)}(d||c||f||E)&&this.resetInitSegment(y,p,m,v,t),(d||f||E)&&this.resetInitialTimestamp(g),l||this.resetContiguity();const w=this.transmux(s,b,h,u,r);this.asyncResult=Hb(w);const S=this.currentTransmuxState;return S.contiguous=!0,S.discontinuity=!1,S.trackSwitch=!1,n.executeEnd=Cb(),w}flush(e){const t=e.transmuxing;t.executeStart=Cb();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=Cb();const r=[jb(e)];return this.asyncResult?Promise.resolve(r):r}const d=o.flush(a);return Hb(d)?(this.asyncResult=!0,d.then(t=>(this.flushRemux(s,t,e),s))):(this.flushRemux(s,d,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===Xf?"level":"track"} ${r.level}`);const d=this.remuxer.remux(i,n,s,a,l,o,!0,this.id);e.push({remuxResult:d,chunkMeta:r}),r.transmuxing.executeEnd=Cb()}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=zb.length;t<r;t++){var s;if(null!=(s=zb[t].demux)&&s.probe(e,this.logger)){n=zb[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,d=n.demux;o&&o instanceof l||(this.remuxer=new l(r,t,i,this.logger)),a&&a instanceof d||(this.demuxer=new d(r,t,i,this.logger),this.probe=d.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new Pg(this.config)),e}}const jb=e=>({remuxResult:{},chunkMeta:e});function Hb(e){return"then"in e&&e.then instanceof Function}class Vb{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 Wb{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 Yb=0;class Kb{constructor(e,t,r,i){this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=Yb++,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(Vf.ERROR,{type:jf.OTHER_ERROR,details:Hf.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===Vf.ERROR&&(t.parent=this.id,t.part=this.part,this.error=t.error),this.hls.trigger(e,t)};this.observer=new Ty,this.observer.on(Vf.FRAG_DECRYPTED,s),this.observer.on(Vf.ERROR,s);const a=wm(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=Ay[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 Ay[e]=i,i}(n.workerPath)):(r.log(`injecting Web Worker for "${t}"`),this.workerContext=function(){const e=Ay[xy];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 Ay[xy]=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:Um(n)})}catch(i){r.warn(`Error setting up "${t}" Web Worker, fallback to inline`,i),this.terminateWorker(),this.error=null,this.transmuxer=new Gb(this.observer,a,n,"",t,e.logger)}return}}this.transmuxer=new Gb(this.observer,a,n,"",t,e.logger)}reset(){if(this.frag=null,this.part=null,this.workerContext){const e=this.instanceNo;this.instanceNo=Yb++;const t=this.hls.config,r=wm(t.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:e,typeSupported:r,id:this.id,config:Um(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=Ay[e||xy];if(t&&1===t.clientCount--){const{worker:r,objectURL:i}=t;delete Ay[e||xy],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,d){var c,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==(c=n.initSegment)?void 0:c.url)===(null==(u=g.initSegment)?void 0:u.url)),A=new Wb(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===Xf?"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 Vb(r,i,t,a,d);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);Hb(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);Hb(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(Vf.ERROR,{type:jf.MEDIA_ERROR,details:Hf.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 qb extends sp{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&&Mm(r);return new Nm(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){Uv(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(Vf.ERROR,{type:jf.NETWORK_ERROR,details:Hf.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 d=this.hls.mainForwardBufferInfo,c=d?d.end-d.len:0,u=Hv(i,1e3*(i.edge-c));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,d=n===a;-1!==l?d?(f=a+1,p=e?0:l):(f=n,p=e?l+1:i.maxPartIndex):f=a+1;const c=i.age,u=c+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 ${c.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 ${c.toFixed(2)}s goal: ${m} skip sn ${e} to part ${p}`)}i.tuneInGoal=m}if(h=this.getDeliveryDirectives(i,t.deliveryDirectives,f,p),e||!d)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=Mm(e);return null!=t&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,i=t.part,n=Dm),new Nm(r,i,n)}checkRetry(e){const t=e.details,r=eg(e),i=e.errorAction,{action:n,retryCount:s=0,retryConfig:a}=i||{},o=!!i&&!!a&&(n===ug||!i.resolved&&n===dg);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=ng(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 Xb(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!Qb(e[r].attrs,t[r].attrs))return!1;return!0}function Qb(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 Zb(e,t){return t.label.toLowerCase()===e.name.toLowerCase()&&(!t.language||t.language.toLowerCase()===(e.lang||"").toLowerCase())}class Jb{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 eE=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,tE="HlsJsTrackRemovedError";class rE extends Error{constructor(e){super(e),this.name=tE}}function iE(e){const t=e.querySelectorAll("source");[].slice.call(t).forEach(t=>{e.removeChild(t)})}function nE(e){return"audio"===e?1:0}class sE{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(Vf.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(Vf.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(Vf.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Vf.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(Vf.BUFFER_CODECS,this.onBufferCodecs,this),e.on(Vf.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:e}=this;e.off(Vf.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(Vf.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(Vf.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Vf.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(Vf.BUFFER_CODECS,this.onBufferCodecs,this),e.off(Vf.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&&Uf(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,sE.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 aE={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"},oE={HLS:"h"};class lE{constructor(e,t){Array.isArray(e)&&(e=e.map(e=>e instanceof lE?e:new lE(e))),this.value=e,this.params=t}}function dE(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 cE(e,t,r){return dE("serialize",e,t,r)}class uE{constructor(e){this.description=e}}const hE="Bare Item";function fE(e){if(!1===ArrayBuffer.isView(e))throw cE(e,"Byte Sequence");return`:${t=e,btoa(String.fromCharCode(...t))}:`;var t}function pE(e){if(function(e){return e<-999999999999999||999999999999999<e}(e))throw cE(e,"Integer");return e.toString()}function mE(e,t){if(e<0)return-mE(-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 gE(e){const t=mE(e,3);if(Math.floor(Math.abs(t)).toString().length>12)throw cE(e,"Decimal");const r=t.toString();return r.includes(".")?r:`${r}.0`}const vE=/[\x00-\x1f\x7f]+/;function yE(e){const t=(r=e).description||r.toString().slice(7,-1);var r;if(!1===/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(t))throw cE(t,"Token");return t}function bE(e){switch(typeof e){case"number":if(!Uf(e))throw cE(e,hE);return Number.isInteger(e)?pE(e):gE(e);case"string":return function(e){if(vE.test(e))throw cE(e,"String");return`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}(e);case"symbol":return yE(e);case"boolean":return function(e){if("boolean"!=typeof e)throw cE(e,"Boolean");return e?"?1":"?0"}(e);case"object":if(e instanceof Date)return function(e){return`@${pE(e.getTime()/1e3)}`}(e);if(e instanceof Uint8Array)return fE(e);if(e instanceof uE)return yE(e);default:throw cE(e,hE)}}function EE(e){if(!1===/^[a-z*][a-z0-9\-_.*]*$/.test(e))throw cE(e,"Key");return e}function wE(e){return null==e?"":Object.entries(e).map(([e,t])=>!0===t?`;${EE(e)}`:`;${EE(e)}=${bE(t)}`).join("")}function SE(e){return e instanceof lE?`${bE(e.value)}${wE(e.params)}`:bE(e)}function TE(e,t={whitespace:!0}){if("object"!=typeof e||null==e)throw cE(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 lE==!1&&(t=new lE(t));let r=EE(e);var i;return!0===t.value?r+=wE(t.params):(r+="=",Array.isArray(t.value)?r+=`(${(i=t).value.map(SE).join(" ")})${wE(i.params)}`:r+=SE(t)),r}).join(`,${i}`)}function xE(e,t){return TE(e,t)}const AE="CMCD-Object",kE="CMCD-Request",LE="CMCD-Session",IE="CMCD-Status",RE={br:AE,ab:AE,d:AE,ot:AE,tb:AE,tpb:AE,lb:AE,tab:AE,lab:AE,url:AE,pb:kE,bl:kE,tbl:kE,dl:kE,ltc:kE,mtp:kE,nor:kE,nrr:kE,rc:kE,sn:kE,sta:kE,su:kE,ttfb:kE,ttfbb:kE,ttlb:kE,cmsdd:kE,cmsds:kE,smrt:kE,df:kE,cs:kE,ts:kE,cid:LE,pr:LE,sf:LE,sid:LE,st:LE,v:LE,msd:LE,bs:IE,bsd:IE,cdn:IE,rtp:IE,bg:IE,pt:IE,ec:IE,e:IE},PE=kE;function CE(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=RE[r]||n[r]||PE;return(null!==(i=t[s])&&void 0!==i?i:t[s]={})[r]=e[r],t},r)}const DE="event";const _E=e=>Math.round(e),OE=(e,t)=>Array.isArray(e)?e.map(e=>OE(e,t)):e instanceof lE&&"string"==typeof e.value?new lE(OE(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),ME=e=>100*_E(e/100),NE={br:_E,d:_E,bl:ME,dl:ME,mtp:ME,nor:(e,t)=>{let r=e;return t.version>=2&&(e instanceof lE&&"string"==typeof e.value?r=new lE([e]):"string"==typeof e&&(r=[e])),OE(r,t)},rtp:ME,tb:_E},FE="request",$E="response",BE=["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"],UE=["e"],zE=/^[a-zA-Z0-9-.]+-[a-zA-Z0-9-.]+$/;function GE(e){return zE.test(e)}const jE=["d","dl","nor","ot","rtp","su"];const HE=["cmsdd","cmsds","rc","smrt","ttfb","ttfbb","ttlb","url"];const VE=["bl","br","bs","cid","d","dl","mtp","nor","nrr","ot","pr","rtp","sf","sid","st","su","tb","v"];function WE(e){return VE.includes(e)||GE(e)}const YE={[$E]:function(e){return BE.includes(e)||jE.includes(e)||HE.includes(e)||GE(e)},[DE]:function(e){return BE.includes(e)||UE.includes(e)||GE(e)},[FE]:function(e){return BE.includes(e)||jE.includes(e)||GE(e)}};function KE(e,t={}){const r={};if(null==e||"object"!=typeof e)return r;const i=t.version||e.v||1,n=t.reportingMode||FE,s=1===i?WE:YE[n];let a=Object.keys(e).filter(s);const o=t.filter;"function"==typeof o&&(a=a.filter(o));const l=n===$E||n===DE;l&&!a.includes("ts")&&a.push("ts"),i>1&&!a.includes("v")&&a.push("v");const d=rp({},NE,t.formatters),c={version:i,reportingMode:n,baseUrl:t.baseUrl};return a.sort().forEach(t=>{let n=e[t];const s=d[t];if("function"==typeof s&&(n=s(n,c)),"v"===t){if(1===i)return;n=i}"pr"==t&&1===n||(l&&"ts"===t&&!Uf(n)&&(n=Date.now()),function(e){return"number"==typeof e?Uf(e):null!=e&&""!==e&&!1!==e}(n)&&(function(e){return["ot","sf","st","e","sta"].includes(e)}(t)&&"string"==typeof n&&(n=new uE(n)),r[t]=n))}),r}function qE(e,t,r){return rp(e,function(e,t={}){const r={};if(!e)return r;const i=CE(KE(e,t),null==t?void 0:t.customHeaderMap);return Object.entries(i).reduce((e,[t,r])=>{const i=xE(r,{whitespace:!1});return i&&(e[t]=i),e},r)}(t,r))}function XE(e,t={}){if(!e)return"";const r=function(e,t={}){return e?xE(KE(e,t),{whitespace:!1}):""}(e,t);return encodeURIComponent(r)}const QE=/CMCD=[^&#]+/;function ZE(e,t,r){const i=function(e,t={}){return e?`CMCD=${XE(e,t)}`:""}(t,r);if(!i)return e;if(QE.test(e))return e.replace(QE,i);const n=e.includes("?")?"&":"?";return`${e}${n}${i}`}function JE(e,t,r,i){e&&Object.keys(t).forEach(n=>{const s=e.filter(e=>e.groupId===n).map(e=>{const s=rp({},e);return s.details=void 0,s.attrs=new Yg(s.attrs),s.url=s.attrs.URI=ew(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 ew(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 tw extends sp{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=tw.CDMCleanupPromise?[tw.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=pv(this.config));const t=e.map(fv).filter(e=>!!e);this.keyFormatPromise=this.getKeyFormatPromise(t)}this.keyFormatPromise.then(n=>{const s=hv(n);if("sinf"!==t||s!==ov.FAIRPLAY)return void this.log(`Ignoring "${e.type}" event with init data type: "${t}" for selected key-system ${s}`);let a;try{const e=$p(new Uint8Array(r)),t=Zp(rv(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=mp(a),{keyIdToKeySessionPromise:l,mediaKeySessions:d}=this;let c=l[o];for(let e=0;e<d.length;e++){const i=d[e],n=i.decryptdata;if(!n.keyId)continue;const s=mp(n.keyId);if(Zg(a,n.keyId)||-1!==n.uri.replace(/-/g,"").indexOf(o)){if(c=l[s],!c)continue;if(n.pssh)break;delete l[s],n.pssh=new Uint8Array(r),n.keyId=a,c=l[o]=c.then(()=>this.generateRequestWithPreferredKeySession(i,t,r,"encrypted-event-key-match")),c.catch(e=>this.handleError(e));break}}c||this.handleError(new Error(`Key ID ${o} not encountered in playlist. Key-system sessions ${d.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(Vf.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(Vf.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(Vf.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(Vf.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.on(Vf.DESTROYING,this.onDestroying,this)}unregisterListeners(){this.hls.off(Vf.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(Vf.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(Vf.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(Vf.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.off(Vf.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===ov.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 nw?t:new nw({type:jf.KEY_SYSTEM_ERROR,details:Hf.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===mv&&"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 ov.FAIRPLAY:n=["cenc","sinf"];break;case ov.WIDEVINE:case ov.PLAYREADY:n=["cenc"];break;case ov.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: ${Um(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: ${mp(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=rw(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 ${mp(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})=>fv(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=fv(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=pv(this.config),r=e.map(hv).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=iw(e,t[r]);if(i)return i}}loadKey(e){const t=e.keyInfo.decryptdata,r=rw(t),i=this.bannedKeyIds[r];if(i||"internal-error"===this.getKeyStatus(t)){const r=sw(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 nw){const i=np({},r.data);"internal-error"===this.getKeyStatus(t)&&(i.decryptdata=t);const n=new nw(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 nw){t&&(e.data.frag=t);const r=e.data.decryptdata;this.error(`${e.message}${r?` (${mp(r.keyId||[])})`:""}`),this.hls.trigger(Vf.ERROR,e.data)}else this.error(e.message),this.hls.trigger(Vf.ERROR,{type:jf.KEY_SYSTEM_ERROR,details:Hf.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0})}getKeySystemForKeyPromise(e){const t=rw(e),r=this.keyIdToKeySessionPromise[t];if(!r){const t=hv(e.keyFormat),r=t?[t]:pv(this.config);return this.attemptKeySystemAccess(r)}return r}getKeySystemSelectionPromise(e){if(e.length||(e=pv(this.config)),0===e.length)throw new nw({type:jf.KEY_SYSTEM_ERROR,details:Hf.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${Um({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=rw(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 Ty,d=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===ov.FAIRPLAY&&this.updateKeySession(e,iv("acknowledged")).then(()=>this.removeSession(e)).catch(e=>this.handleError(e)):this.warn(`unhandled media key message type "${i}"`)},c=(e,t)=>{let r;t.keyStatus=e,e.startsWith("usable")?l.emit("resolved"):"internal-error"===e||"output-restricted"===e||"output-downscaled"===e?r=sw(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 ${Um(r)} in key-session "${e.mediaKeysSession.sessionId}"`),void this.renewKeySession(e);let i=r[a];if(i)c(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.`),c(r,e);this.log(`key status for ${a} in key-session "${e.mediaKeysSession.sessionId}" timed out after ${t}ms`),i="internal-error",c(i,e)},t)),this.log(`No status for keyId ${a} (${Um(r)}).`)}};ry(e.mediaKeysSession,"message",d),ry(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 nw({type:jf.KEY_SYSTEM_ERROR,details:Hf.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===ov.PLAYREADY&&16===n.length){const e=mp(n);t[e]=r,nv(n)}const s=mp(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},d={onSuccess:(e,t,r,i)=>{n(e.data)},onError:(t,r,n,o)=>{s(new nw({type:jf.KEY_SYSTEM_ERROR,details:Hf.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:n,response:np({url:a.url,data:void 0},t)},`"${e}" certificate request failed (${i}). Status: ${t.code} (${t.text})`))},onTimeout:(t,r,n)=>{s(new nw({type:jf.KEY_SYSTEM_ERROR,details:Hf.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,d)})):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 nw({type:jf.KEY_SYSTEM_ERROR,details:Hf.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 nw({type:jf.KEY_SYSTEM_ERROR,details:Hf.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 iv(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 nw({type:jf.KEY_SYSTEM_ERROR,details:Hf.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==ov.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,ry(r,"encrypted",this.onMediaEncrypted),ry(r,"waitingforkey",this.onWaitingForKey);const i=this.mediaResolved;i?i():this.mediaKeys=r.mediaKeys}onMediaDetached(){const e=this.media;e&&(iy(e,"encrypted",this.onMediaEncrypted),iy(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,bv.clearKeyUriToKeyIdMap();const n=i.length;tw.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(Vf.ERROR,{type:jf.OTHER_ERROR,details:Hf.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(Vf.ERROR,{type:jf.OTHER_ERROR,details:Hf.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: ${mp((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(Vf.ERROR,{type:jf.OTHER_ERROR,details:Hf.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(Vf.ERROR,{type:jf.OTHER_ERROR,details:Hf.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close session: ${e}`)})})}return Promise.resolve()}}function rw(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(null===e.keyId)throw new Error("keyId is null");return mp(e.keyId)}function iw(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}tw.CDMCleanupPromise=void 0;class nw 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 sw(e,t){const r="output-restricted"===e,i=r?Hf.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:Hf.KEY_SYSTEM_STATUS_INTERNAL_ERROR;return new nw({type:jf.KEY_SYSTEM_ERROR,details:i,fatal:!1,decryptdata:t},r?"HDCP level output restricted":`key status changed to "${e}"`)}function aw(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 ow(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){up.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){up.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${e}`)}}"disabled"===r&&(e.mode=r)}function lw(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 dw(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 cw(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 uw(e){let t=5381,r=e.length;for(;r;)t=33*t^e.charCodeAt(--r);return(t>>>0).toString()}const hw=.025;let fw=function(e){return e[e.Point=0]="Point",e[e.Range=1]="Range",e}({});function pw(e,t,r){return`${e.identifier}-${r+1}-${uw(t)}`}class mw{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 gw(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-gw(t,e)<.1}return!1}get resumptionOffset(){const e=this.resumeOffset,t=Uf(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 gw(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)<hw))}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"]?fw.Range:fw.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 gw(e,t){return e-t.start<t.duration/2&&!(Math.abs(e-(t.start+t.duration))<hw)?t.start:t.start+t.duration}function vw(e,t,r){const i=new self.URL(e,r);return"data:"!==i.protocol&&i.searchParams.set("_HLS_primary_id",t),i}function yw(e,t){for(;null!=(r=e.assetList[++t])&&r.error;)var r;return t}function bw(e){const t=e.timelineStart,r=e.duration||0;return`["${e.identifier}" ${t.toFixed(2)}-${(t+r).toFixed(2)}]`}class Ew{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(Vf.PLAYOUT_LIMIT_REACHED,{})};const n=this.hls=new e(t);this.interstitial=r,this.assetItem=i;const s=()=>{this.hasDetails=!0};n.once(Vf.LEVEL_LOADED,s),n.once(Vf.AUDIO_TRACK_LOADED,s),n.once(Vf.SUBTITLE_TRACK_LOADED,s),n.on(Vf.MEDIA_ATTACHING,(e,{media:t})=>{this.removeMediaListeners(),this.mediaAttached=t;this.interstitial.playoutLimit&&(t.addEventListener("timeupdate",this.checkPlayout),this.appendInPlace&&n.on(Vf.BUFFER_APPENDED,()=>{const e=this.bufferedEnd;this.reachedPlayout(e)&&(this._bufferedEosTime=e,n.trigger(Vf.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=vw(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=Bg.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=Bg.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: ${bw(this.assetItem)} ${null==(e=this.hls)?void 0:e.sessionId} ${this.appendInPlace?"append-in-place":""}`}}class ww extends sp{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 mw(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,d=t.cue.post,c=e[a-1]||null,u=t.appendInPlace,h=d?n:t.startOffset,f=t.duration,p=t.timelineOccupancy===fw.Range?f:0,m=t.resumptionOffset,g=(null==c?void 0:c.startTime)===h,v=h+t.cumulativeDuration;let y=u?v+f:h+m;if(l||!d&&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,d=o;o+=n;const c=s;s+=n;const u={previousEvent:e[a-1]||null,nextEvent:t,start:l,end:l+n,playout:{start:c,end:s},integrated:{start:d,end:o}};r.push(u)}else n>0&&c&&(c.cumulativeDuration+=n,r[r.length-1].end=h)}d&&(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=d||b>n?n:b}),i<n){var a;const e=i,t=o,l=n-i;o+=l;const d=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:d,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,d=a.cue.post,c=l?0:d?i:a.startTime;this.updateAssetDurations(a);if(s===c?a.cumulativeDuration=n:(n=0,s=c),!d&&a.snapOptions.in&&(a.resumeAnchor=Xm(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=Uf(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)>hw)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=Xm(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)<hw+o||Math.abs(a.end-r)<hw+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 Sw(e){return`[${e.event?'"'+e.event.identifier+'"':"primary"}: ${e.start.toFixed(2)}-${e.end.toFixed(2)}]`}class Tw{constructor(e){this.hls=void 0,this.hls=e}destroy(){this.hls=null}loadAssetList(e,t){const r=e.assetListUrl;let i;try{i=vw(r,this.hls.sessionId,e.baseUrl)}catch(t){const i=this.assignAssetListError(e,Hf.ASSET_LIST_LOAD_ERROR,t,r);return void this.hls.trigger(Vf.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},d={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,Hf.ASSET_LIST_PARSING_ERROR,new Error("Invalid interstitial asset list"),i.url,r,n);return void this.hls.trigger(Vf.ERROR,t)}e.assetListResponse=s,this.hls.trigger(Vf.ASSET_LIST_LOADED,{event:e,assetListResponse:s,networkDetails:n})},onError:(t,r,i,n)=>{const s=this.assignAssetListError(e,Hf.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(Vf.ERROR,s)},onTimeout:(t,r,i)=>{const n=this.assignAssetListError(e,Hf.ASSET_LIST_LOAD_TIMEOUT,new Error(`Timeout loading X-ASSET-LIST (${r.url})`),r.url,t,i);this.hls.trigger(Vf.ERROR,n)}};return s.load(a,l,d),this.hls.trigger(Vf.ASSET_LIST_LOADING,{event:e}),s}assignAssetListError(e,t,r,i,n,s){return e.error=r,{type:jf.NETWORK_ERROR,details:t,fatal:!1,interstitial:e,url:i,error:r,networkDetails:s,stats:n}}}function xw(e){var t;null==e||null==(t=e.play())||t.catch(()=>{})}function Aw(e,t){return`[${e}] Advancing timeline position to ${t}`}class kw{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 Lw={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},Iw=e=>String.fromCharCode(Lw[e]||e),Rw=15,Pw=100,Cw={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},Dw={17:2,18:4,21:6,22:8,23:10,19:13,20:15},_w={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},Ow={25:2,26:4,29:6,30:8,31:10,27:13,28:15},Mw=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class Nw{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){const r="function"==typeof t?t():t;up.log(`${this.time} [${e}] ${r}`)}}}const Fw=function(e){const t=[];for(let r=0;r<e.length;r++)t.push(e[r].toString(16));return t};class $w{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 Bw{constructor(){this.uchar=" ",this.penState=new $w}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 Uw{constructor(e){this.chars=[],this.pos=0,this.currPenState=new $w,this.cueStartTime=null,this.logger=void 0;for(let e=0;e<Pw;e++)this.chars.push(new Bw);this.logger=e}equals(e){for(let t=0;t<Pw;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}copy(e){for(let t=0;t<Pw;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<Pw;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>Pw&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=Pw)}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=Iw(e);this.pos>=Pw?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<Pw;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<Pw;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 zw{constructor(e){this.rows=[],this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let t=0;t<Rw;t++)this.rows.push(new Uw(e));this.logger=e}reset(){for(let e=0;e<Rw;e++)this.rows[e].clear();this.currRow=14}equals(e){let t=!0;for(let r=0;r<Rw;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t}copy(e){for(let t=0;t<Rw;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<Rw;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 = "+Um(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<Rw;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 = "+Um(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<Rw;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 Gw{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 zw(r),this.nonDisplayedMemory=new zw(r),this.lastOutputScreen=new zw(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: "+Um(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 jw{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 Nw;this.channels=[null,new Gw(e,t,i),new Gw(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,()=>"["+Fw([t[e],t[e+1]])+"] -> ("+Fw([r,i])+")");const a=this.cmdHistory;if(r>=16&&r<=31){if(Vw(r,i,a)){Hw(null,null,a),this.logger.log(3,()=>"Repeated command ("+Fw([r,i])+") is dropped");continue}Hw(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 Hw(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 "+Fw([r,i])+" orig: "+Fw([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 ("+Fw([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?Cw[e]:_w[e]:1===i?Dw[e]:Ow[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 '"+Iw(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 = "+Fw(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=Mw[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()}Hw(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 Hw(e,t,r){r.a=e,r.b=t}function Vw(e,t,r){return r.a===e&&r.b===t}var Ww=function(){if(null!=av&&av.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 d="",c=!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 d},set:function(e){d=""+e}})),Object.defineProperty(o,"pauseOnExit",n({},l,{get:function(){return c},set:function(e){c=!!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 Yw{decode(e,t){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}function Kw(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 qw{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 Xw(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 Qw=new Ww(0,0,""),Zw="middle"===Qw.align?"middle":"center";function Jw(e,t,r){const i=e;function n(){const t=Kw(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 qw;Xw(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",Zw,"end"]);break;case"position":n=t.split(","),i.percent(e,n[0]),2===n.length&&i.alt("positionAlign",n[1],["start",Zw,"end","line-left","line-right","auto"]);break;case"size":i.percent(e,t);break;case"align":i.alt(e,t,["start",Zw,"end","left","right"])}},/:/,/\s/),t.region=i.get("region",null),t.vertical=i.get("vertical","");let n=i.get("line","auto");"auto"===n&&-1===Qw.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",Zw);let s=i.get("position","auto");"auto"===s&&50===Qw.position&&(s="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=s}(e,t)}function eS(e){return e.replace(/<br(?: \/)?>/gi,"\n")}class tS{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new Yw,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=eS(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){Xw(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 Ww(0,0,""),t.state="CUE",-1===e.indexOf("--\x3e")){t.cue.id=e;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{Jw(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 rS=/\r\n|\n\r|\n|\r/g,iS=function(e,t,r=0){return e.slice(r,r+t.length)===t};function nS(e,t,r){return uw(e.toString())+uw(t.toString())+uw(r)}function sS(e,t,r,i,n,s,a){const o=new tS,l=pp(new Uint8Array(e)).trim().replace(rS,"\n").split("\n"),d=[],c=t?function(e,t=1){return Ib(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-c)/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=Nb(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=nS(e.startTime,e.endTime,m)),e.endTime>0&&d.push(e)},o.onparsingerror=function(e){u=e},o.onflush=function(){u?a(u):s(d)},l.forEach(e=>{if(m){if(iS(e,"X-TIMESTAMP-MAP=")){m=!1,e.slice(16).split(",").forEach(e=>{iS(e,"LOCAL:")?h=e.slice(6):iS(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(!(Uf(t)&&Uf(r)&&Uf(i)&&Uf(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 aS="stpp.ttml.im1t",oS=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,lS=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,dS={left:"start",center:"center",right:"end",start:"start",end:"end"};function cS(e,t,r,i){const n=jp(new Uint8Array(e),["mdat"]);if(0===n.length)return void i(new Error("Could not parse IMSC1 mdat"));const s=n.map(e=>pp(e)),a=function(e,t,r=1,i=!1){return Ib(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=hS(uS(i,"styling","style")),l=hS(uS(i,"layout","region")),d=uS(i,"body","[begin]");return[].map.call(d,e=>{const r=fS(e,a);if(!r||!e.hasAttribute("begin"))return null;const i=gS(e.getAttribute("begin"),s),n=gS(e.getAttribute("dur"),s);let d=gS(e.getAttribute("end"),s);if(null===i)throw mS(e);if(null===d){if(null===n)throw mS(e);d=i+n}const c=new Ww(i-t,d-t,r);c.id=nS(c.startTime,c.endTime,c.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=pS(t,i,s)||pS(e,i,s)||pS(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=dS[h];e&&(c.lineAlign=e),c.align=h}return rp(c,u),c}).filter(e=>null!==e)}(e,a)))}catch(e){i(e)}}function uS(e,t,r){const i=e.getElementsByTagName(t)[0];return i?[].slice.call(i.querySelectorAll(r)):[]}function hS(e){return e.reduce((e,t)=>{const r=t.getAttribute("xml:id");return r&&(e[r]=t),e},{})}function fS(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?fS(r,t):t?e+r.textContent.trim().replace(/\s+/g," "):e+r.textContent},"")}function pS(e,t,r){return e&&e.hasAttributeNS(t,r)?e.getAttributeNS(t,r):null}function mS(e){return new Error(`Could not parse ttml timestamp ${e}`)}function gS(e,t){if(!e)return null;let r=Kw(e);return null===r&&(oS.test(e)?r=function(e,t){const r=oS.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):lS.test(e)&&(r=function(e,t){const r=lS.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 vS{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 yS(e){return e.characteristics&&/transcribes-spoken-dialog/gi.test(e.characteristics)&&/describes-music-and-sound/gi.test(e.characteristics)?"captions":"subtitles"}function bS(e,t){return!!e&&e.kind===yS(t)&&Zb(t,e)}function ES(e,t,r,i){return Math.min(t,i)-Math.max(e,r)}const wS=/\s/,SS={newCue(e,t,r,i){const n=[];let s,a,o,l,d;const c=self.VTTCue||self.TextTrackCue;for(let h=0;h<i.rows.length;h++)if(s=i.rows[h],o=!0,l=0,d="",!s.isEmpty()){var u;for(let e=0;e<s.chars.length;e++)wS.test(s.chars[e].uchar)&&o?l++:(d+=s.chars[e].uchar,o=!1);s.cueStartTime=t,t===r&&(r+=1e-4),l>=16?l--:l++;const i=eS(d.trim()),f=nS(t,r,i);null!=e&&null!=(u=e.cues)&&u.getCueById(f)||(a=new c(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=>ow(e,t))),n}};const TS=/(\d+)-(\d+)\/(\d+)/;class xS{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||AS,this.controller=new self.AbortController,this.stats=new kp}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(rp({},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&&Uf(o)?o:l,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(i,e,this.response))},t.timeout);(Hb(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 kS(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=TS.exec(e);if(t)return parseInt(t[2])-parseInt(t[1])+1}(t);if(Uf(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&&Uf(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 d={url:o.url,data:r,code:o.status},c=null==(n=this.callbacks)?void 0:n.onProgress;c&&!Uf(t.highWaterMark)&&c(i,e,r,o),null==(s=this.callbacks)||s.onSuccess(d,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 by,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,d=l.length;return t.loaded+=d,d<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 AS(e,t){return new self.Request(e.url,t)}class kS extends Error{constructor(e,t,r){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=r}}const LS=/^age:\s*[\d.]+\s*$/im;class IS{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 kp,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&&Uf(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 d={url:t.responseURL,data:n,code:i};return void(null==(a=this.callbacks)||a.onSuccess(d,r,e,t))}}const d=n.loadPolicy.errorRetry;var o;if(ag(d,r.retry,!1,{url:e.url,data:void 0,code:i}))this.retry(d);else up.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(ag(e,this.stats.retry,!0))this.retry(e);else{var t;up.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=ng(e,r.retry),r.retry++,up.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&&LS.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 RS=np(np({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:IS,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:class extends sp{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,d=i?i.duration:r.duration,c=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(c<=Math.max(v,d/(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(d*(r.bitrate||x.averageBitrate)/8));let k=w?c-E:c;k<1&&w&&(k=Math.min(c,8*l.loaded/S));const L=w?1e3*l.loaded/k:0,I=v/1e3,R=L?(A-l.loaded)/L:8*A/S+I;if(R<=b)return;const P=L?8*L: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(I,P,d*e,t),O<Math.min(b,d+I))break}if(O>=R)return;if(O>10*d)return;w?this.bwEstimator.sample(c-Math.min(v,E),l.loaded):this.bwEstimator.sampleTTFB(c);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: ${Uf(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(Vf.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 ep(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){const{hls:e}=this;e.on(Vf.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Vf.FRAG_LOADING,this.onFragLoading,this),e.on(Vf.FRAG_LOADED,this.onFragLoaded,this),e.on(Vf.FRAG_BUFFERED,this.onFragBuffered,this),e.on(Vf.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(Vf.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Vf.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(Vf.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(Vf.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e&&(e.off(Vf.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Vf.FRAG_LOADING,this.onFragLoading,this),e.off(Vf.FRAG_LOADED,this.onFragLoaded,this),e.off(Vf.FRAG_BUFFERED,this.onFragBuffered,this),e.off(Vf.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(Vf.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Vf.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(Vf.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(Vf.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 Hf.BUFFER_ADD_CODEC_ERROR:case Hf.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case Hf.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;Uf(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===Xf&&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(Vf.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!==Xf||"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 d=n.abrBandWidthFactor,c=n.abrBandWidthUpFactor;if(l){const e=this.findBestLevel(o,s,i,l,0,d,c);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`),d=c=1}}const h=this.findBestLevel(o,s,i,l,u,d,c);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,d=this.lastLoadedFragLevel,c=-1===d?this.hls.firstLevel:d,{fragCurrent:u,partCurrent:h}=this,{levels:f,allAudioTracks:p,loadLevel:m,config:g}=this.hls;if(1===f.length)return 0;const v=f[c],y=!(null==(o=this.hls.latestLevelDetails)||!o.live),b=-1===m||-1===d;let E,w="SDR",S=(null==v?void 0:v.frameRate)||0;const{audioPreference:T,videoPreference:x}=g,A=this.audioTracksByGroup||(this.audioTracksByGroup=Gm(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,d=a&&2===parseInt(a);let c=!1,u=!1,h=1/0,f=1/0,p=1/0,m=1/0,g=0,v=[];const{preferHDR:y,allowedVideoRanges:b}=Bm(t,n);for(let t=s.length;t--;){const r=e[s[t]];c||(c=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=Uf(h)?h:0,f=Uf(f)?f:0;const E=Math.max(1080,h),w=Math.max(30,f);p=Uf(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 zm(i,`min bitrate of ${n.minBitrate} > current estimate of ${r}`),t;if(!n.hasDefaultAudio)return zm(i,"no renditions with default or auto-select sound found"),t;if(o&&i.indexOf(o.substring(0,4))%5!=0)return zm(i,`audio codec preference "${o}" not found`),t;if(a&&!d){if(!n.channels[a])return zm(i,`no renditions with ${a} channel sound found (channels options: ${Object.keys(n.channels)})`),t}else if((!o||d)&&c&&0===n.channels[2])return zm(i,"no renditions with stereo sound found"),t;if(n.minHeight>E)return zm(i,`min resolution of ${n.minHeight} > maximum of ${E}`),t;if(n.minFramerate>w)return zm(i,`min framerate of ${n.minFramerate} > maximum of ${w}`),t;if(!v.some(e=>n.videoRanges[e]>0))return zm(i,`no variants with VIDEO-RANGE of ${Um(v)} found`),t;if(l&&i.indexOf(l.substring(0,4))%5!=0)return zm(i,`video codec preference "${l}" not found`),t;if(n.maxScore<g)return zm(i,`max score of ${n.maxScore} < selected max of ${g}`),t}return t&&(pm(i)>=pm(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:d,preferHDR:c}=n;k=d,E=s,w=c?a[a.length-1]:a[0],S=o,e=Math.max(e,l),this.log(`picked start tier ${Um(n)}`)}else E=null==v?void 0:v.codecSet,w=null==v?void 0:v.videoRange;const L=h?h.duration:u?u.duration:0,I=this.bwEstimator.getEstimateTTFB()/1e3,R=[];for(let o=r;o>=t;o--){var P;const t=f[o],u=o>c;if(!t)continue;if(g.useMediaCapabilities&&!t.supportedResult&&!t.supportedPromise){const r=navigator.mediaCapabilities;"function"==typeof(null==r?void 0:r.decodingInfo)&&km(t,A,w,S,e,T)?(t.supportedPromise=Lm(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} ${Um(e)}`):e.supported?e.decodingInfoResults.some(e=>!1===e.smooth||!1===e.powerEfficient)&&this.log(`MediaCapabilities decodingInfo for level ${i} not smooth or powerEfficient: ${Um(e)}`):(this.warn(`Unsupported MediaCapabilities decodingInfo result for level ${i} ${Um(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=xm}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)||L;let x;x=u?a*e:s*e;const C=L&&i>=2*L&&0===n?t.averageBitrate:t.maxBitrate,D=this.getTimeToLoadFrag(I,x,C*v,void 0===p);if(x>=C&&(o===d||0===t.loadError&&0===t.fragmentError)&&(D<=I||!Uf(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:${c}->${o} adjustedbw(${Math.round(x)})-bitrate=${Math.round(x-C)} ttfb:${I.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 sp{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(Vf.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=hp(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(Vf.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(Vf.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Vf.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Vf.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Vf.BUFFER_RESET,this.onBufferReset,this),e.on(Vf.BUFFER_APPENDING,this.onBufferAppending,this),e.on(Vf.BUFFER_CODECS,this.onBufferCodecs,this),e.on(Vf.BUFFER_EOS,this.onBufferEos,this),e.on(Vf.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(Vf.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(Vf.FRAG_PARSED,this.onFragParsed,this),e.on(Vf.FRAG_CHANGED,this.onFragChanged,this),e.on(Vf.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(Vf.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(Vf.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Vf.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Vf.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Vf.BUFFER_RESET,this.onBufferReset,this),e.off(Vf.BUFFER_APPENDING,this.onBufferAppending,this),e.off(Vf.BUFFER_CODECS,this.onBufferCodecs,this),e.off(Vf.BUFFER_EOS,this.onBufferEos,this),e.off(Vf.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(Vf.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(Vf.FRAG_PARSED,this.onFragParsed,this),e.off(Vf.FRAG_CHANGED,this.onFragChanged,this),e.off(Vf.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?rp(r,i.tracks):this.sourceBuffers.forEach(e=>{const[t]=e;t&&(r[t]=rp({},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=hp(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,iE(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: ${Um(r,(e,t)=>"initSegment"===e?void 0:t)};\ntransfer tracks: ${Um(i,(e,t)=>"initSegment"===e?void 0:t)}}`),!fp(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(Vf.MEDIA_DETACHING,{}),this.onMediaAttaching(Vf.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=Bg.getBuffered(e);i.detectEvictedFragments(t,r,n,null,!0)}const s=nE(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&&iE(i),i.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null),this.hls.trigger(Vf.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[nE(e)]=[null,null];const t=this.tracks[e];t&&(t.buffer=void 0)}resetQueue(){this.operationQueue&&this.operationQueue.destroy(),this.operationQueue=new Jb(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:d,metadata:c,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:d,levelCodec:l,metadata:c,id:a});const v=ym(m,g),y=null==v?void 0:v.replace(eE,"$1");let b=ym(o,l);const E=null==(n=b)?void 0:n.replace(eE,"$1");b&&v&&y!==E&&("audio"===e.slice(0,5)&&(b=vm(b,this.appendSource)),this.log(`switching codec ${m} to ${b}`),b!==(h.pendingCodec||h.codec)&&(h.pendingCodec=b),h.container=d,this.appendChangeType(e,d,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,Xf))?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&&Bg.isBuffered(t.buffer,i)||!0===(null==(e=this.fragmentTracker.getAppendedFrag(i,Xf))?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:d}=t,c=l.buffering[n],{sn:u,cc:h}=a,f=self.performance.now();c.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||Bg.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&&!Bg.isBuffered(b,t)&&this.lastVideoAppendEnd<t&&this.blockAudio(e):this.blockAudio(e)}}const E=(o||a).start,w={label:`append-${n}`,execute:()=>{var e;c.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!==d&&Uf(d)&&this.updateTimestampOffset(t,d,1e-6,n,u,h)),this.appendExecutor(i,n)},onStart:()=>{},onComplete:()=>{const e=self.performance.now();c.executeEnd=c.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]=Bg.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(Vf.BUFFER_APPENDED,{type:n,frag:a,part:o,chunkMeta:l,parent:a.type,timeRanges:t})},onError:e=>{var t;const r={type:jf.MEDIA_ERROR,parent:a.type,details:Hf.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=Hf.BUFFER_FULL_ERROR;else if(e.code===DOMException.INVALID_STATE_ERR&&this.mediaSourceOpenOrEnded&&!i)r.errorAction=gg(!0);else if(e.name===tE&&0===this.sourceBufferCount)r.errorAction=gg(!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(Vf.ERROR,r)}};this.log(`queuing "${n}" append sn: ${u}${o?" p: "+o.index:""} of ${a.type===Xf?"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(Vf.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[Rp]?n.push("audiovideo"):(s[Lp]&&n.push("audio"),s[Ip]&&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(Vf.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(Vf.BUFFERED_TO_END,void 0)):e&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${e.readyState}`)})):(this.tracksEnded(),this.hls.trigger(Vf.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===Hf.BUFFER_APPEND_ERROR&&t.frag){var r;const e=null==(r=t.errorAction)?void 0:r.nextAutoLevel;Uf(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(Uf(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(Uf(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=Bg.getBuffered(t);if(n.length>0&&r>n.start(0)){var i;this.hls.trigger(Vf.BACK_BUFFER_REACHED,{bufferEnd:r});const t=this.tracks[e];if(null!=(i=this.details)&&i.live)this.hls.trigger(Vf.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(Vf.BUFFER_FLUSHING,{startOffset:0,endOffset:r,type:e})}}})}flushFrontBuffer(e,t,r){this.sourceBuffers.forEach(([t,i])=>{if(i){const n=Bg.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(Vf.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 Uf(n)?{duration:n}:null;const s=this.media.duration;return i>(Uf(r.duration)?r.duration:0)&&i>s||!Uf(s)?{duration:i}:null}updateMediaSource({duration:e,start:t,end:r}){const i=this.mediaSource;this.media&&i&&"open"===i.readyState&&(i.duration!==e&&(Uf(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}) ${Um(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(Vf.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(Vf.ERROR,{type:jf.MEDIA_ERROR,details:Hf.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":""} ${Um(a)}`);try{const e=r.addSourceBuffer(n),i=nE(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(Vf.ERROR,{type:jf.MEDIA_ERROR,details:Hf.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)&&cm(r,"video")&&(i=function(e,t){const r=[];if(e){const t=e.split(",");for(let e=0;e<t.length;e++)dm(t[e],"video")||r.push(t[e])}return t&&r.push(t),r.join(",")}(i,r));const n=ym(i,e.levelCodec);return n?"audio"===t.slice(0,5)?vm(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(Vf.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(Vf.ERROR,{type:jf.MEDIA_ERROR,details:Hf.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=Uf(i.duration)?i.duration:1/0,l=Uf(n.duration)?n.duration:1/0,d=Math.max(0,t),c=Math.min(r,o,l);c>d&&(!s.ending||s.ended)?(s.ended=!1,this.log(`Removing [${d},${c}] from the ${e} SourceBuffer`),a.remove(d,c)):this.shiftAndExecuteNext(e)}appendExecutor(e,t){const r=this.tracks[t],i=null==r?void 0:r.buffer;if(!i)throw new rE(`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:sE,errorController:class extends sp{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(Vf.ERROR,this.onError,this),e.on(Vf.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Vf.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const e=this.hls;e&&(e.off(Vf.ERROR,this.onError,this),e.off(Vf.ERROR,this.onErrorOut,this),e.off(Vf.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Vf.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)===Xf?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 Hf.FRAG_LOAD_ERROR:case Hf.FRAG_LOAD_TIMEOUT:case Hf.KEY_LOAD_ERROR:case Hf.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case Hf.FRAG_PARSING_ERROR:if(null!=(r=t.frag)&&r.gap)return void(t.errorAction=gg());case Hf.FRAG_GAP:case Hf.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=dg);case Hf.LEVEL_EMPTY_ERROR:case Hf.LEVEL_PARSING_ERROR:{var s;const e=t.parent===Xf?t.level:i.loadLevel;t.details===Hf.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 Hf.LEVEL_LOAD_ERROR:case Hf.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==n?void 0:n.level)&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.level)));case Hf.AUDIO_TRACK_LOAD_ERROR:case Hf.AUDIO_TRACK_LOAD_TIMEOUT:case Hf.SUBTITLE_LOAD_ERROR:case Hf.SUBTITLE_TRACK_LOAD_TIMEOUT:if(n){const e=i.loadLevelObj;if(e&&(n.type===Kf&&e.hasAudioGroup(n.groupId)||n.type===qf&&e.hasSubtitleGroup(n.groupId)))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,i.loadLevel),t.errorAction.action=dg,void(t.errorAction.flags=fg)}return;case Hf.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:return void(t.errorAction={action:dg,flags:pg});case Hf.KEY_SYSTEM_SESSION_UPDATE_FAILED:case Hf.KEY_SYSTEM_STATUS_INTERNAL_ERROR:case Hf.KEY_SYSTEM_NO_SESSION:return void(t.errorAction={action:dg,flags:mg});case Hf.BUFFER_ADD_CODEC_ERROR:case Hf.REMUX_ALLOC_ERROR:case Hf.BUFFER_APPEND_ERROR:var a;if(!t.errorAction)t.errorAction=this.getLevelSwitchAction(t,null!=(a=t.level)?a:i.loadLevel);return;case Hf.INTERNAL_EXCEPTION:case Hf.BUFFER_APPENDING_ERROR:case Hf.BUFFER_FULL_ERROR:case Hf.LEVEL_SWITCH_ERROR:case Hf.BUFFER_STALLED_ERROR:case Hf.BUFFER_SEEK_OVER_HOLE:case Hf.BUFFER_NUDGE_ON_STALL:return void(t.errorAction=gg())}t.type===jf.KEY_SYSTEM_ERROR&&(t.levelRetry=!1,t.errorAction=gg())}getPlaylistRetryOrSwitchAction(e,t){const r=ig(this.hls.config.playlistLoadPolicy,e),i=this.playlistError++;if(ag(r,i,eg(e),e.response))return{action:ug,flags:hg,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=ig(tg(e)?s:n,e),o=t.levels.reduce((e,t)=>e+t.fragmentError,0);if(i&&(e.details!==Hf.FRAG_GAP&&i.fragmentError++,!rg(e))){if(ag(a,o,eg(e),e.response))return{action:ug,flags:hg,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===Hf.BUFFER_APPEND_ERROR&&i.fragmentError++;let l=-1;const{levels:d,loadLevel:c,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===Qf&&t===Hf.FRAG_PARSING_ERROR||"audio"===e.sourceBufferName&&(t===Hf.BUFFER_ADD_CODEC_ERROR||t===Hf.BUFFER_APPEND_ERROR))&&d.some(({audioCodec:e})=>i.audioCodec!==e),m="video"===e.sourceBufferName&&(t===Hf.BUFFER_ADD_CODEC_ERROR||t===Hf.BUFFER_APPEND_ERROR)&&d.some(({codecSet:e,audioCodec:t})=>i.codecSet!==e&&i.audioCodec===t),{type:g,groupId:v}=null!=(s=e.context)?s:{};for(let r=d.length;r--;){const n=(r+c)%d.length;if(n!==c&&n>=u&&n<=h&&0===d[n].loadError){var a,o;const r=d[n];if(t===Hf.FRAG_GAP&&f===Xf&&e.frag){const t=d[n].details;if(t){const r=Xm(e.frag,t.fragments,e.frag.start);if(null!=r&&r.gap)continue}}else{if(g===Kf&&r.hasAudioGroup(v)||g===qf&&r.hasSubtitleGroup(v))continue;if(f===Qf&&null!=(a=i.audioGroups)&&a.some(e=>r.hasAudioGroup(e))||f===Zf&&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:dg,flags:hg,nextAutoLevel:l}}return{action:dg,flags:fg}}onErrorOut(e,t){var r;switch(null==(r=t.errorAction)?void 0:r.action){case lg:break;case dg:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===Hf.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 hg:this.switchLevel(e,n);break;case pg:{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=Pm[Pm.indexOf(s)-1],r.resolved=!0,this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}}case mg:{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) ${mp(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!==Xf){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===Hf.BUFFER_ADD_CODEC_ERROR&&e.mimeType&&"audiovideo"!==e.sourceBufferName)){const t=Sm(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(Vf.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(Vf.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListeners(){this.hls.off(Vf.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(Vf.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(Vf.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(Vf.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:mv,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:SS,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 vy{constructor(e,t,r){super(e,t,r,"subtitle-stream-controller",Zf),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(Vf.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Vf.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(Vf.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(Vf.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(Vf.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(Vf.BUFFER_FLUSHING,this.onBufferFlushing,this)}unregisterListeners(){super.unregisterListeners();const{hls:e}=this;e.off(Vf.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Vf.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(Vf.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(Vf.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(Vf.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(Vf.BUFFER_FLUSHING,this.onBufferFlushing,this)}startLoad(e,t){this.stopLoad(),this.state=ay,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)||(Cp(r)&&(this.fragPrevious=r),this.state=ay),!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,Zf)}}onError(e,t){const r=t.frag;(null==r?void 0:r.type)===Zf&&(t.details===Hf.FRAG_GAP&&this.fragmentTracker.fragBuffered(r,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==sy&&(this.state=ay))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){this.levels&&Xb(this.levels,t)?this.levels=t.map(e=>new Fm(e)):(this.tracksBuffered=[],this.levels=t.map(e=>{const t=new Fm(e);return this.tracksBuffered[t.id]=[],t}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,Zf),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!==sy&&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 d;if(o.details)l=this.alignPlaylists(s,o.details,null==(d=this.levelLastLoaded)?void 0:d.details),0===l&&t&&(l=t.start,jv(s,l));else s.hasProgramDateTime&&e.hasProgramDateTime?(ty(s,e),l=s.fragmentStart):t&&(l=t.start,jv(s,l));e&&!this.startFragRequested&&this.setStartPosition(e,l)}if(o.details=s,this.levelLastLoaded=o,a===i&&(this.hls.trigger(Vf.SUBTITLE_TRACK_UPDATED,{details:s,id:a,groupId:t.groupId}),this.tick(),s.live&&!this.fragCurrent&&this.media&&this.state===ay)){Xm(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&&ev(i.method)){const e=performance.now();this.decrypter.decrypt(new Uint8Array(r),i.key.buffer,i.iv.buffer,tv(i.method)).catch(e=>{throw n.trigger(Vf.ERROR,{type:jf.MEDIA_ERROR,details:Hf.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:t}),e}).then(r=>{const i=performance.now();n.trigger(Vf.FRAG_DECRYPTED,{frag:t,payload:r,stats:{tstart:e,tdecrypt:i}})}).catch(e=>{this.warn(`${e.name}: ${e.message}`),this.state=ay})}}doTick(){if(this.media){if(this.state===ay){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=Bg.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 d=l.fragments,c=d.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=Xm(f,d,Math.max(d[0].start,a),t),!h&&f&&f.start<d[0].start&&(h=d[0])}else h=d[c-1];if(h=this.filterReplacedPrimary(h,r.details),!h)return;const p=d[h.sn-l.startSN-1];if(p&&p.cc===h.cc&&this.fragmentTracker.getState(p)===vg&&(h=p),this.fragmentTracker.getState(h)===vg){const e=this.mapToInitFragWhenRequired(h);e&&this.loadFragment(e,r,a)}}}else this.state=ay}loadFragment(e,t,r){Cp(e)?super.loadFragment(e,t,r):this._loadInitSegment(e,t)}get mediaBufferTimeRanges(){return new kw(this.tracksBuffered[this.currentTrackId]||[])}},subtitleTrackController:class extends qb{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=cw(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(Vf.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Vf.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Vf.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Vf.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Vf.LEVEL_LOADING,this.onLevelLoading,this),e.on(Vf.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(Vf.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(Vf.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(Vf.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Vf.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Vf.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Vf.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Vf.LEVEL_LOADING,this.onLevelLoading,this),e.off(Vf.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(Vf.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(Vf.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;cw(r.textTracks).forEach(e=>{lw(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=Hm(t,e);if(r>-1)n=e[r];else{const e=Hm(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(Vf.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||Vm(n,e)))return i}if(e){for(let r=0;r<t.length;r++){const i=t[r];if(Qb(e.attrs,i.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return r}for(let r=0;r<t.length;r++){const i=t[r];if(Qb(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(Zb(t[r],e))return r}}return-1}onError(e,t){!t.fatal&&t.context&&(t.context.type!==qf||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&&Vm(e,r))return r;const i=Hm(e,this.tracksInGroup);if(i>-1){const e=this.tracksInGroup[i];return this.setSubtitleTrack(i),e}if(r)return null;{const r=Hm(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(Vf.SUBTITLE_TRACK_LOADING,{url:n,id:r,groupId:i,deliveryDirectives:t||null,track:e})}toggleTrackModes(){const{media:e}=this;if(!e)return;const t=cw(e.textTracks),r=this.currentTrack;let i;if(r&&(i=t.filter(e=>Zb(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||!Uf(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(Vf.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:d}=i;this.hls.trigger(Vf.SUBTITLE_TRACK_SWITCH,{id:s,groupId:a,name:o,type:l,url:d});const c=this.switchParams(i.url,null==r?void 0:r.details,i.details);this.loadPlaylist(c)}},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(Vf.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(Vf.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Vf.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Vf.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(Vf.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(Vf.FRAG_LOADING,this.onFragLoading,this),e.on(Vf.FRAG_LOADED,this.onFragLoaded,this),e.on(Vf.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(Vf.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(Vf.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(Vf.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(Vf.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:e}=this;e.off(Vf.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(Vf.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Vf.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Vf.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(Vf.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(Vf.FRAG_LOADING,this.onFragLoading,this),e.off(Vf.FRAG_LOADED,this.onFragLoaded,this),e.off(Vf.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(Vf.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(Vf.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(Vf.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(Vf.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.media=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){const e=new vS(this,"textTrack1"),t=new vS(this,"textTrack2"),r=new vS(this,"textTrack3"),i=new vS(this,"textTrack4");this.cea608Parser1=new jw(1,e,t),this.cea608Parser2=new jw(3,r,i)}addCues(e,t,r,i,n){let s=!1;for(let e=n.length;e--;){const i=n[e],a=ES(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(Vf.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===Xf&&(this.initPTS[t.cc]={baseTime:i,timescale:n,trackId:s}),a.length&&(this.unparsedVttFrags=[],a.forEach(e=>{this.initPTS[e.frag.cc]?this.onFragLoaded(Vf.FRAG_LOADED,e):this.hls.trigger(Vf.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(bS(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,lw(r[e]),aw(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(Vf.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=>{lw(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++)lw(t[e])}onSubtitleTracksUpdated(e,t){const r=t.subtitleTracks||[],i=r.some(e=>e.textCodec===aS);if(this.config.enableWebVTT||i&&this.config.enableIMSC1){if(Xb(this.tracks,r))return void(this.tracks=r);if(this.textTracks=[],this.tracks=r,this.config.renderTextTracksNatively){const e=this.media,t=e?cw(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]&&bS(t[i],e)){r=t[i],t[i]=null;break}r&&(i=r)}if(i)lw(i);else{const t=yS(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(Vf.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===Xf){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===Zf)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===aS?this._parseIMSC1(r,i):this._parseVTTs(t)}}else this.hls.trigger(Vf.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){const r=this.hls;cS(t,this.initPTS[e.cc],t=>{this._appendCues(t,e.level),r.trigger(Vf.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},t=>{r.logger.log(`Failed to parse IMSC1: ${t}`),r.trigger(Vf.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;sS(null!=(t=r.initSegment)&&t.data?Jp(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(Vf.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(Vf.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:t})})}_fallbackToIMSC1(e,t){const r=this.tracks[e.level];r.textCodec||cS(t,this.initPTS[e.cc],()=>{r.textCodec=aS,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=>ow(r,e))}else{const i=this.tracks[t];if(!i)return;const n=i.default?"default":"subtitles"+t;r.trigger(Vf.CUES_PARSED,{type:"subtitles",cues:e,track:n})}}onFragDecrypted(e,t){const{frag:r}=t;r.type===Zf&&this.onFragLoaded(Vf.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!==Xf||"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=>dw(e[i],t,r))}if(this.config.renderTextTracksNatively&&0===t&&void 0!==i){const{textTracks:e}=this;Object.keys(e).forEach(r=>dw(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 vy{constructor(e,t,r){super(e,t,r,"audio-stream-controller",Qf),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(Vf.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Vf.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(Vf.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(Vf.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(Vf.BUFFER_RESET,this.onBufferReset,this),e.on(Vf.BUFFER_CREATED,this.onBufferCreated,this),e.on(Vf.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(Vf.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(Vf.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(Vf.FRAG_LOADING,this.onFragLoading,this),e.on(Vf.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){const{hls:e}=this;e&&(super.unregisterListeners(),e.off(Vf.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Vf.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(Vf.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(Vf.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(Vf.BUFFER_RESET,this.onBufferReset,this),e.off(Vf.BUFFER_CREATED,this.onBufferCreated,this),e.off(Vf.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(Vf.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(Vf.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(Vf.FRAG_LOADING,this.onFragLoading,this),e.off(Vf.FRAG_BUFFERED,this.onFragBuffered,this))}onInitPtsFound(e,{frag:t,id:r,initPTS:i,timescale:n,trackId:s}){if(r===Xf){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===my){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===ay&&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=Jm(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===ay&&this.doTickIdle())}startLoad(e,t){if(!this.levels)return this.startPosition=e,void(this.state=sy);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=ay):this.state=cy,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}doTick(){switch(this.state){case ay:this.doTickIdle();break;case cy:{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=my}break}case dy:this.checkRetryDate();break;case my:{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=ly;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=ay}}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=cy,void(this.startFragRequested=!1);const l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,Lp,Qf));const d=this.getFwdBufferInfo(l,Qf);if(null===d)return;if(!this.switchingTrack&&this._streamEnded(d,o))return t.trigger(Vf.BUFFER_EOS,{type:"audio"}),void(this.state=fy);const c=d.len,u=t.maxBufferLength,h=o.fragments,f=h[0].start,p=this.getLoadPosition(),m=this.flushing?p:d.end;if(this.switchingTrack&&i){const e=p;o.PTSKnown&&e<f&&(d.end>f||d.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),i.currentTime=f+.05)}if(c>=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,d,Xf,u)),!g)return void(this.bufferFlushed=!0);let v=(null==(e=this.mainFragLoading)?void 0:e.frag)||null;if(!this.audioOnly&&this.startFragRequested&&v&&Cp(g)&&!g.endList&&(!o.live||!this.loadingParts&&m<this.hls.liveSyncPosition)&&(this.fragmentTracker.getState(v)===Eg&&(this.mainFragLoading=v=null),v&&Cp(v))){if(g.start>v.end){const e=this.fragmentTracker.getFragAtPos(m,Xf);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 Fm(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!==sy&&(this.setInterval(100),this.state=ay,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(Vf.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!==sy&&(this.state=cy));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 d=i[s];let c=0;if(n.live||null!=(r=d.details)&&r.live){if(this.checkLiveUpdate(n),n.deltaUpdateFailed)return;var u;if(d.details)c=this.alignPlaylists(n,d.details,null==(u=this.levelLastLoaded)?void 0:u.details);n.alignedSliding||(ey(n,l),n.alignedSliding||ty(n,l),c=n.fragmentStart)}d.details=n,this.levelLastLoaded=d,this.startFragRequested||this.setStartPosition(l,c),this.hls.trigger(Vf.AUDIO_TRACK_UPDATED,{details:n,id:s,groupId:t.groupId}),this.state!==cy||this.waitForCdnTuneIn(n)||(this.state=ay),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 d=l.details;if(!d)return this.warn("Audio track details undefined on fragment load progress"),void this.removeUnbufferedFrags(r.start);const c=s.defaultAudioCodec||l.audioCodec||"mp4a.40.2";let u=this.transmuxer;u||(u=this.transmuxer=new Kb(this.hls,Qf,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 Fg(r.level,r.sn,r.stats.chunkCount,n.byteLength,t,s);u.push(n,f,c,"",r,i,d.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 [${d.startSN} ,${d.endSN}],track ${a}`);const{cache:e}=this.waitingData=this.waitingData||{frag:r,part:i,cache:new by,complete:!1};e.push(new Uint8Array(n)),this.state!==sy&&(this.state=my)}}_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===Xf&&Cp(t.frag)&&(this.mainFragLoading=t,this.state===ay&&this.tick())}onFragBuffered(e,t){const{frag:r,part:i}=t;if(r.type===Qf)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(Cp(r)){this.fragPrevious=r;const e=this.switchingTrack;e&&(this.bufferedTrack=e,this.switchingTrack=null,this.hls.trigger(Vf.AUDIO_TRACK_SWITCHED,np({},e)))}this.fragBufferedComplete(r,i),this.media&&this.tick()}else this.audioOnly||r.type!==Xf||r.elementaryStreams.video||r.elementaryStreams.audiovideo||(this.audioOnly=!0,this.mainFragLoading=null)}onError(e,t){var r;if(t.fatal)this.state=py;else switch(t.details){case Hf.FRAG_GAP:case Hf.FRAG_PARSING_ERROR:case Hf.FRAG_DECRYPT_ERROR:case Hf.FRAG_LOAD_ERROR:case Hf.FRAG_LOAD_TIMEOUT:case Hf.KEY_LOAD_ERROR:case Hf.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Qf,t);break;case Hf.AUDIO_TRACK_LOAD_ERROR:case Hf.AUDIO_TRACK_LOAD_TIMEOUT:case Hf.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==cy||(null==(r=t.context)?void 0:r.type)!==Kf||(this.state=ay);break;case Hf.BUFFER_ADD_CODEC_ERROR:case Hf.BUFFER_APPEND_ERROR:if("audio"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)||this.resetLoadingState();break;case Hf.BUFFER_FULL_ERROR:if("audio"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case Hf.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}onBufferFlushing(e,{type:t}){t!==Ip&&(this.flushing=!0)}onBufferFlushed(e,{type:t}){if(t!==Ip){this.flushing=!1,this.bufferFlushed=!0,this.state===fy&&(this.state=ay);const e=this.mediaBuffer||this.media;e&&(this.afterBufferFlushed(e,t,Qf),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:d}=a,{details:c}=d,{audio:u,text:h,id3:f,initSegment:p}=n;if(!this.fragContextChanged(o)&&c){if(this.state=uy,this.switchingTrack&&u&&this.completeAudioSwitch(this.switchingTrack),null!=p&&p.tracks){const e=o.initSegment||o;if(this.unhandledEncryptionError(p,o))return;this._bufferInitSegment(d,p.tracks,e,s),i.trigger(Vf.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[Lp]={startPTS:e,endPTS:t,startDTS:r,endDTS:i}),o.setElementaryStreamInfo(Lp,e,t,r,i),this.bufferFragmentData(u,o,l,s)}if(null!=f&&null!=(t=f.samples)&&t.length){const e=rp({id:r,frag:o,details:c},f);i.trigger(Vf.FRAG_PARSING_METADATA,e)}if(h){const e=rp({id:r,frag:o,details:c},h);i.trigger(Vf.FRAG_PARSING_USERDATA,e)}}else this.fragmentTracker.removeFragment(o)}_bufferInitSegment(e,t,r,i){if(this.state!==uy)return;if(t.video&&delete t.video,t.audiovideo&&delete t.audiovideo,!t.audio)return;const n=t.audio;n.id=Qf;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(Vf.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(Vf.BUFFER_APPENDING,e)}this.tickImmediate()}loadFragment(e,t,r){const i=this.fragmentTracker.getState(e);var n;if(this.switchingTrack||i===vg||i===bg)if(Cp(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=my;const r=this.mainDetails;r&&r.fragmentStart!==t.details.fragmentStart&&ty(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;Vm({name:t,lang:r,assocLang:i,characteristics:n,audioCodec:s,channels:a},e,Wm)||(Km(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(Vf.AUDIO_TRACK_SWITCHED,np({},e))}},audioTrackController:class extends qb{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(Vf.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Vf.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Vf.LEVEL_LOADING,this.onLevelLoading,this),e.on(Vf.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(Vf.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(Vf.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(Vf.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Vf.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Vf.LEVEL_LOADING,this.onLevelLoading,this),e.off(Vf.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(Vf.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(Vf.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=Hm(t,e,Wm);if(r>-1)n=e[r];else{const e=Hm(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(Vf.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(Vf.ERROR,{type:jf.MEDIA_ERROR,details:Hf.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:t})}}}onError(e,t){!t.fatal&&t.context&&(t.context.type!==Kf||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&&Vm(e,i,Wm))return i;const n=Hm(e,this.tracksInGroup,Wm);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,d=s.codecSet.substring(0,4),c=Ym(t,i,t=>{if(t.videoRange!==o||t.frameRate!==l||t.codecSet.substring(0,4)!==d)return!1;const i=t.audioGroups,s=r.filter(e=>!i||-1!==i.indexOf(e.groupId));return Hm(e,s,n)>-1});return c>-1?c:Ym(t,i,t=>{const i=t.audioGroups,s=r.filter(e=>!i||-1!==i.indexOf(e.groupId));return Hm(e,s,n)>-1})}(e,t.levels,r,i,Wm);if(-1===n)return null;t.nextLoadLevel=n}if(e.channels||e.audioCodec){const t=Hm(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(Vf.AUDIO_TRACK_SWITCHING,np({},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||Vm(e,i,Wm)))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(Vm({name:r,lang:i,assocLang:n,characteristics:s,audioCodec:a,channels:o},t[e],Wm))return e}for(let r=0;r<t.length;r++){const i=t[r];if(Qb(e.attrs,i.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return r}for(let r=0;r<t.length;r++){const i=t[r];if(Qb(e.attrs,i.attrs,["LANGUAGE"]))return r}}return-1}loadPlaylist(e){super.loadPlaylist();const t=this.currentTrack;this.shouldLoadPlaylist(t)&&Km(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(Vf.AUDIO_TRACK_LOADING,{url:n,id:r,groupId:i,deliveryDirectives:t||null,track:e})}},emeController:tw,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:aE.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!==aE.VIDEO&&n!==aE.AUDIO&&n!=aE.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(Vf.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Vf.MEDIA_DETACHED,this.onMediaDetached,this),e.on(Vf.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const e=this.hls;e.off(Vf.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Vf.MEDIA_DETACHED,this.onMediaDetached,this),e.off(Vf.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:oE.HLS,sid:this.sid,cid:this.cid,pr:null==(e=this.media)?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){rp(t,this.createData());const r=t.ot===aE.INIT||t.ot===aE.VIDEO||t.ot===aE.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={}),qE(e.headers,t,n)):e.url=ZE(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?aE.TIMED_TEXT:"initSegment"===e.sn?aE.INIT:"audio"===t?aE.AUDIO:"main"===t?this.hls.audioTracks.length?aE.VIDEO:aE.MUXED:void 0}getTopBandwidth(e){let t,r=0;const i=this.hls;if(e===aE.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===aE.AUDIO?this.audioBuffer:this.videoBuffer;if(!r||!t)return NaN;return 1e3*Bg.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 sp{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(Vf.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Vf.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(Vf.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Vf.ERROR,this.onError,this)}unregisterListeners(){const e=this.hls;e&&(e.off(Vf.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Vf.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(Vf.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Vf.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)===dg&&r.flags===fg){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!==Hf.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: ${Um(i)} penalized: ${Um(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,Kv(t),this.hls.trigger(Vf.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===Kf&&i[r].hasAudioGroup(e)||t===qf&&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 Yg(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=ew(e.uri,t["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",a),d=new Fm({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++)d.addGroupId("audio",`${e.audioGroups[t]}_clone_${n}`);if(e.subtitleGroups)for(let t=1;t<e.subtitleGroups.length;t++)d.addGroupId("text",`${e.subtitleGroups[t]}_clone_${n}`);return d});t.push(...o),JE(this.audioTracks,r,a,n),JE(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 d={steeringManifest:s,url:i.toString()};this.hls.trigger(Vf.STEERING_MANIFEST_LOADED,d),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 sp{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=>Sw(e))} pos: ${this.timelinePos}`),o.length&&this.log(`Removed events ${o}`);let d=null,c=null;i&&(d=this.updateItem(i,this.timelinePos),this.itemsMatch(i,d)?this.playingItem=d:this.waitingItem=this.endedItem=null),this.waitingItem=this.updateItem(this.waitingItem),this.endedItem=this.updateItem(this.endedItem);const u=this.bufferingItem;if(u&&(c=this.updateItem(u,this.bufferedPos),this.itemsMatch(u,c)?this.bufferingItem=c: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)>hw&&this.warn(`${i} ("${e.assetId}" ${e.timelineOffset}->${t})`)}}}),l||t){if(this.hls.trigger(Vf.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(d,i),u&&c!==d&&this.trimInPlace(c,u),this.checkBuffer()}},this.hls=e,this.HlsPlayerClass=t,this.assetListLoader=new Tw(e),this.schedule=new ww(this.onScheduleUpdate,e.logger),this.registerListeners()}registerListeners(){const e=this.hls;e&&(e.on(Vf.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(Vf.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Vf.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Vf.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Vf.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(Vf.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(Vf.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.on(Vf.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(Vf.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.on(Vf.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.on(Vf.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.on(Vf.BUFFER_APPENDED,this.onBufferAppended,this),e.on(Vf.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(Vf.BUFFERED_TO_END,this.onBufferedToEnd,this),e.on(Vf.MEDIA_ENDED,this.onMediaEnded,this),e.on(Vf.ERROR,this.onError,this),e.on(Vf.DESTROYING,this.onDestroying,this))}unregisterListeners(){const e=this.hls;e&&(e.off(Vf.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(Vf.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Vf.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Vf.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Vf.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(Vf.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(Vf.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.off(Vf.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(Vf.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.off(Vf.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.off(Vf.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.off(Vf.BUFFER_CODECS,this.onBufferCodecs,this),e.off(Vf.BUFFER_APPENDED,this.onBufferAppended,this),e.off(Vf.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(Vf.BUFFERED_TO_END,this.onBufferedToEnd,this),e.off(Vf.MEDIA_ENDED,this.onMediaEnded,this),e.off(Vf.ERROR,this.onError,this),e.off(Vf.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){iy(e,"play",this.onPlay),iy(e,"pause",this.onPause),iy(e,"seeking",this.onSeeking),iy(e,"timeupdate",this.onTimeupdate)}onMediaAttaching(e,t){const r=this.media=t.media;ry(r,"seeking",this.onSeeking),ry(r,"timeupdate",this.onTimeupdate),ry(r,"play",this.onPlay),ry(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 d=t.event;if(d){if("playout"===i||d.timelineOccupancy!==fw.Point){const e=r(s);(null==e?void 0:e.interstitial)===d&&(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,d=e.schedule.findItemIndexAtTime(t,n),c=null==(a=e.schedule.items)?void 0:a[d],u=e.getBufferingPlayer(),h=null==u?void 0:u.interstitial,f=null==h?void 0:h.appendInPlace,p=l&&e.itemsMatch(l,c);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,d=(f?r:a.currentTime)+o;if(d>=0&&(!s||f||d<=s.duration))return void(a.currentTime=d)}}if(c){let r=t;if("primary"!==n){const e=t-c[n].start;r=c.start+e}const i=!e.isInterstitial(c);if(e.isInterstitial(l)&&!l.event.appendInPlace||!i&&!c.event.appendInPlace){if(l){const s=e.findItemIndex(l);if(d>s){const t=e.schedule.findJumpRestrictedIndex(s+1,d);if(t>s)return void e.setSchedulePosition(t)}let a=0;if(i)e.timelinePos=r,e.checkBuffer();else{const e=c.event.assetList,r=t-(c[n]||c).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(d,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&&Uf(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} ${Um(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 d;if(s.media)o&&(n=s.transferMedia(),this.detachedData=n),d="Primary";else if(l){const e=this.getBufferingPlayer();e?(n=e.transferMedia(),d=`${e}`):d="detached MediaSource"}else d="detached media";if(!n)if(l)n=this.detachedData,this.log(`using detachedData: MediaSource ${Um(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 c=n&&"mediaSource"in n&&"closed"!==(null==(i=n.mediaSource)?void 0:i.readyState),u=c&&n?n:t;this.log(`${c?"transfering MediaSource":"attaching media"} to ${a?e:"Primary"} from ${d} (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(Aw("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=yw(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=yw(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(Aw("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?Sw(n):n}) pos: ${this.timelinePos}`);const s=this.waitingItem||this.playingItem,a=this.playingLastItem;if(this.isInterstitial(s)){const r=s.event,d=this.playingAsset,c=null==d?void 0:d.identifier,u=c?this.getAssetPlayer(c):null;if(u&&c&&(!this.eventItemsMatch(s,n)||void 0!==t&&c!==r.assetList[t].identifier)){var o;const t=r.findAssetIndex(d);if(this.log(`INTERSTITIAL_ASSET_ENDED ${t+1}/${r.assetList.length} ${bw(d)}`),this.endedAsset=d,this.playingAsset=null,this.hls.trigger(Vf.INTERSTITIAL_ASSET_ENDED,{asset:d,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(c,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} ${Sw(s)}`),r.hasPlayed=!0,this.hls.trigger(Vf.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=yw(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 d=this.preloadAssets(n,r);if(this.eventItemsMatch(a,l||i)||(this.waitingItem=a,this.log(`INTERSTITIAL_STARTED ${Sw(a)} ${n.appendInPlace?"append in place":""}`),this.hls.trigger(Vf.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 c=n.assetList[r];if(!c)return void this.advanceAfterAssetEnded(n,e,r||0);if(d||(d=this.getAssetPlayer(c.identifier)),null===d||d.destroyed){const e=n.assetList.length;this.warn(`asset ${r+1}/${e} player destroyed ${n}`),d=this.createAssetPlayer(n,c,r),d.loadSource()}if(!this.eventItemsMatch(a,this.bufferingItem)&&n.appendInPlace&&this.isAssetBuffered(c))return;this.startAssetPlayer(d,r,t,e,o),this.shouldPlay&&xw(d.media)}else a?(this.resumePrimary(a,e,i),this.shouldPlay&&xw(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 ${Sw(e)}`),null==(i=this.detachedData)||!i.mediaSource){let r=this.timelinePos;(r<e.start||r>=e.end)&&(r=this.getPrimaryResumption(e,t),this.log(Aw("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 ${Sw(e)}`),this.hls.trigger(Vf.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 Bg.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(Aw("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(Vf.BUFFER_CODECS,this.onBufferCodecs,this),this.hls.on(Vf.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=np(np({},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=np(np({},this.altSelection),{},{audio:r}));const n=np(np({},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=np(np({},this.altSelection),{},{subtitles:r}));const n=np(np({},i),{},{subtitles:r});this.mediaSelection=n}onAudioTrackSwitching(e,t){const r=jm(t);this.playerQueue.forEach(({hls:e})=>e&&(e.setAudioOption(t)||e.setAudioOption(r)))}onSubtitleTrackSwitch(e,t){const r=jm(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=Bg.bufferInfo(this.primaryMedia,r,0);if(i.end>r||(i.nextStart||0)>r){this.log(`trim buffered interstitial ${Sw(e)} (was ${Sw(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=Bg.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 ${Sw(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(Vf.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(Vf.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:pw(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=rp({},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 d=0;if(this.primaryLive||e.appendInPlace){const e=this.timelinePos-t.timelineStart;if(e>1){const r=t.duration;r&&e<r&&(d=e)}}const c=t.identifier,u=np(np({},n),{},{maxMaxBufferLength:Math.min(180,i.config.maxMaxBufferLength),autoStartLoad:!0,startFragPrefetch:!0,primarySessionId:i.sessionId,assetPlayerId:c,abrEwmaDefaultEstimate:i.bandwidthEstimate,interstitialsController:void 0,startPosition:d,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=rp({},h,{contentId:uw(t.uri)})),this.getAssetPlayer(c)&&this.warn(`Duplicate date range identifier ${e} and asset ${c}`);const f=new Ew(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:jf.OTHER_ERROR,details:Hf.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 "${c}" duration change ${a} > ${s}`),t.duration=s,this.updateSchedule())};f.on(Vf.LEVEL_UPDATED,(e,{details:t})=>m(t)),f.on(Vf.LEVEL_PTS_UPDATED,(e,{details:t})=>m(t)),f.on(Vf.EVENT_CUE_ENTER,()=>this.onInterstitialCueEnter());const g=(e,t)=>{const r=this.getAssetPlayer(c);if(r&&t.tracks){r.off(Vf.BUFFER_CODECS,g),r.tracks=t.tracks;const e=this.primaryMedia;this.bufferingAsset===r.assetItem&&e&&!r.media&&this.bufferAssetPlayer(r,e)}};f.on(Vf.BUFFER_CODECS,g);f.on(Vf.BUFFERED_TO_END,()=>{var r;const i=this.getAssetPlayer(c);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(c)||!this.schedule)return;this.shouldPlay=!0;const r=this.schedule.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,r,t)};return f.once(Vf.MEDIA_ENDED,v(r)),f.once(Vf.PLAYOUT_LIMIT_REACHED,v(1/0)),f.on(Vf.ERROR,(t,i)=>{if(!this.schedule)return;const n=this.getAssetPlayer(c);if(i.details===Hf.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(Vf.DESTROYING,()=>{if(!this.getAssetPlayer(c)||!this.schedule)return;const t=new Error(`Asset player destroyed unexpectedly ${c}`),i={fatal:!0,type:jf.OTHER_ERROR,details:Hf.INTERSTITIAL_ASSET_ITEM_ERROR,error:t};this.handleAssetItemError(i,e,this.schedule.findEventIndex(e.identifier),r,t.message)}),this.log(`INTERSTITIAL_ASSET_PLAYER_CREATED ${bw(t)}`),this.hls.trigger(Vf.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?Sw(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,d=this.playingAsset;this.endedAsset=null,this.playingAsset=a,d&&d.identifier===o||(d&&(this.clearAssetPlayer(d.identifier,r[i]),delete d.error),this.log(`INTERSTITIAL_ASSET_STARTED ${t+1}/${l} ${bw(a)}`),this.hls.trigger(Vf.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 d=n.appendInPlace;if(d&&!1===(null==l?void 0:l.interstitial.appendInPlace))return;const c=(null==l?void 0:l.tracks)||(null==(i=this.detachedData)?void 0:i.tracks)||this.requiredTracks;if(d&&s!==this.playingAsset){if(!e.tracks)return void this.log(`Waiting for track info before buffering ${e}`);if(c&&!fp(c,e.tracks)){const t=new Error(`Asset ${bw(s)} SourceBuffer tracks ('${Object.keys(e.tracks)}') are not compatible with primary content tracks ('${Object.keys(c)}')`),r={fatal:!0,type:jf.OTHER_ERROR,details:Hf.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===Hf.BUFFER_STALLED_ERROR)return;const s=t.assetList[i]||null;if(this.warn(`INTERSTITIAL_ASSET_ERROR ${s?bw(s):s} ${e.error}`),!this.schedule)return;const a=(null==s?void 0:s.identifier)||"",o=this.getAssetPlayerQueueIndex(a),l=this.playerQueue[o]||null,d=this.schedule.items,c=rp({},e,{fatal:!1,errorAction:gg(!0),asset:s,assetListIndex:i,event:t,schedule:d,scheduleIndex:r,player:l});if(this.hls.trigger(Vf.INTERSTITIAL_ASSET_ERROR,c),!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: ${Sw(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 d=0;a.forEach((e,t)=>{const r=parseFloat(e.DURATION);this.createAsset(n,t,d,o+d,r,e.URI),d+=r}),n.duration=d,this.log(`Loaded asset-list with duration: ${d} (was: ${l}) ${n}`);const c=this.waitingItem,u=(null==c?void 0:c.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 Hf.ASSET_LIST_PARSING_ERROR:case Hf.ASSET_LIST_LOAD_ERROR:case Hf.ASSET_LIST_LOAD_TIMEOUT:{const e=t.interstitial;e&&(this.updateSchedule(!0),this.primaryFallback(e));break}case Hf.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 PS(e){return e&&"object"==typeof e?Array.isArray(e)?e.map(PS):Object.keys(e).reduce((t,r)=>(t[r]=PS(e[r]),t),{}):e}function CS(e,t){const r=e.loader;if(r!==xS&&r!==IS)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=xS,e.progressive=!0,e.enableSoftwareAES=!0,t.log("[config]: Progressive streaming enabled, using FetchLoader"))}}class DS extends Ng{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(Vf.MEDIA_ENDED,{stalled:!1}))},this.hls=e,this.fragmentTracker=t,this.registerListeners()}registerListeners(){const{hls:e}=this;e&&(e.on(Vf.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Vf.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Vf.BUFFER_APPENDED,this.onBufferAppended,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off(Vf.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Vf.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Vf.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;ry(r,"playing",this.onMediaPlaying),ry(r,"waiting",this.onMediaWaiting),ry(r,"ended",this.onMediaEnded)}onMediaDetaching(e,t){this.clearInterval();const{media:r}=this;r&&(iy(r,"playing",this.onMediaPlaying),iy(r,"waiting",this.onMediaWaiting),iy(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,d=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&&!d&&e>t&&this.nudgeOnVideoHole(e,t)),void(0===this.waiting&&this.stallResolved(e));if(l||o)return void(o&&this.stallResolved(e));if(d)return this.nudgeRetry=0,this.stallResolved(e),void(!this.ended&&s.ended&&this.hls&&(this.ended=e||1,this.hls.trigger(Vf.MEDIA_ENDED,{stalled:!1})));if(!Bg.getBuffered(s).length)return void(this.nudgeRetry=0);const c=Bg.bufferInfo(s,e,0),u=c.nextStart||0,h=this.fragmentTracker;if(a&&h&&this.hls){const t=_S(this.hls.inFlightFragments,e),r=c.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(!(c.len>0)&&!u)return;const t=Math.max(u,c.start||0)-e,r=!(null==f||!f.live)?2*f.targetduration:2,i=MS(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(Vf.MEDIA_ENDED,{stalled:!0})}if(this._reportStall(c),!this.media||!this.hls)return}const E=Bg.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(Vf.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=Bg.bufferedInfo(Bg.timeRangesToArray(this.buffered.audio),e,0);if(r.len>1&&t>=r.start){const r=Bg.timeRangesToArray(i),n=Bg.bufferedInfo(r,t,0).bufferedIndex;if(n>-1&&n<r.length-1){const t=Bg.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=MS(e,this.fragmentTracker);n&&"fragment"in n?n=n.fragment:n||(n=void 0);const a=Bg.bufferInfo(this.media,e,0);this.hls.trigger(Vf.ERROR,{type:jf.MEDIA_ERROR,details:Hf.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,d=MS(r,s);if(d||null!=l&&l.live&&r<l.fragmentStart){if(this._trySkipBufferHole(d)||!this.media)return}const c=e.buffered,u=this.adjacentTraversal(e,r);(c&&c.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,Xf),n=r.getFragAtPos(i,Xf);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 (${Um(e)})`);this.warn(i.message),t.trigger(Vf.ERROR,{type:jf.MEDIA_ERROR,details:Hf.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=Bg.bufferInfo(i,s,0),o=s<a.start?a.start:a.nextStart;if(o&&this.hls){const t=a.len<=n.maxBufferHole,d=a.len>0&&a.len<1&&i.readyState<3,c=o-s;if(c>0&&(t||d)){if(c>n.maxBufferHole){let t=!1;if(0===s){const e=r.getAppendedFrag(0,Xf);e&&o<e.end&&(t=!0)}if(!t&&e){var l;if(null==(l=this.hls.loadLevelObj)||!l.details)return 0;if(_S(this.hls.inFlightFragments,o))return 0;let t=!1,i=e.end;for(;i<o;){const e=MS(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:jf.MEDIA_ERROR,details:Hf.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(Vf.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(Vf.ERROR,{type:jf.MEDIA_ERROR,details:Hf.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(Vf.ERROR,{type:jf.MEDIA_ERROR,details:Hf.BUFFER_STALLED_ERROR,error:r,fatal:!0,buffer:e.len,bufferInfo:e})}}}function _S(e,t){const r=OS(e.main);if(r&&r.start<=t)return r;const i=OS(e.audio);return i&&i.start<=t?i:null}function OS(e){if(!e)return null;switch(e.state){case ay:case sy:case fy:case py:return null}return e.frag}function MS(e,t){return t.getAppendedFrag(e,Xf)||t.getPartialFragment(e)}function NS(){if("undefined"!=typeof self)return self.VTTCue||self.TextTrackCue}function FS(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,Um(n?np({type:n},i):i))}return s}const $S=(()=>{const e=NS();try{e&&new e(0,Number.POSITIVE_INFINITY,"")}catch(e){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();class BS{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(Vf.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(Vf.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(Vf.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Vf.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Vf.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Vf.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(Vf.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(Vf.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(Vf.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}_unregisterListeners(){const{hls:e}=this;e&&(e.off(Vf.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(Vf.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Vf.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Vf.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Vf.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(Vf.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(Vf.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(Vf.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&&lw(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 aw(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=NS();if(s)for(let e=0;e<n.length;e++){const t=n[e].type;if(t===Yy.emsg&&!r||!i)continue;const a=jy(n[e].data),o=n[e].pts;let l=o+n[e].duration;l>$S&&(l=$S);l-o<=0&&(l=o+.25);for(let e=0;e<a.length;e++){const r=a[e];if(!Hy(r)){this.updateId3CueEnds(o,t);const e=FS(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===$S&&(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===Yy.audioId3&&o:"video"===i?e=>e.type===Yy.emsg&&a:e=>e.type===Yy.audioId3&&o||e.type===Yy.emsg&&a,dw(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=NS();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=FS(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,d=Object.keys(l);let c=this.dateRangeCuesAppended;var u;if(o&&t)if(null!=(u=o.cues)&&u.length){const e=Object.keys(c).filter(e=>!d.includes(e));for(let t=e.length;t--;){var h;const r=e[t],i=null==(h=c[r])?void 0:h.cues;delete c[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 c=this.dateRangeCuesAppended={};const f=e.fragments[e.fragments.length-1];if(0!==d.length&&Uf(null==f?void 0:f.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(let e=0;e<d.length;e++){const t=d[e],r=l[t],i=r.startTime,n=c[t],o=(null==n?void 0:n.cues)||{};let u=(null==n?void 0:n.durationKnown)||!1,h=$S;const{duration:f,endDate:p}=r;if(p&&null!==f)h=i+f,u=!0;else if(r.endOnNext&&!u){const e=d.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(!Kg(l))continue;const d=o[l];if(d)!u||null!=n&&n.durationKnown?Math.abs(d.startTime-i)>.01&&(d.startTime=i,d.endTime=h):d.endTime=h;else if(a){let e=r.attr[l];qg(l)&&(e=gp(e));const n=FS(a,i,h,{key:l,data:e},Yy.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)))}}c[t]={cues:o,dateRange:r,durationKnown:u}}}}}class US{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 d=i;return l+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,d)}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(Vf.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Vf.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Vf.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Vf.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(Vf.ERROR,this.onError,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off(Vf.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Vf.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Vf.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Vf.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(Vf.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===Hf.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 zS extends qb{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(Vf.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Vf.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(Vf.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Vf.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(Vf.FRAG_BUFFERED,this.onFragBuffered,this),e.on(Vf.ERROR,this.onError,this)}_unregisterListeners(){const{hls:e}=this;e.off(Vf.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Vf.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(Vf.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Vf.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(Vf.FRAG_BUFFERED,this.onFragBuffered,this),e.off(Vf.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:d,videoCodec:c}=e;d&&(e.audioCodec=d=vm(d,r)||void 0),c&&(c=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(",")}(c));const{width:u,height:h,unknownCodecs:f}=e,p=(null==f?void 0:f.length)||0;if(a||(a=!(!u||!h)),o||(o=!!c),l||(l=!!d),p||d&&!this.isAudioSupported(d)||c&&!this.isVideoSupported(c))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 Fm(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=Am(e,[])}return t}isAudioSupported(e){return cm(e,"audio",this.hls.config.preferManagedMediaSource)}isVideoSupported(e){return cm(e,"video",this.hls.config.preferManagedMediaSource)}filterAndSortMediaOptions(e,t,r,i,n){var s;let a=[],o=[],l=e;const d=(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)&&Cm.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: ${Um(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(Vf.ERROR,{type:jf.MEDIA_ERROR,details:Hf.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:i,reason:r})}}),void(d.end=performance.now());t.audioTracks&&(a=t.audioTracks.filter(e=>!e.audioCodec||this.isAudioSupported(e.audioCodec)),GS(a)),t.subtitles&&(o=t.subtitles,GS(o));const c=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 Cm.indexOf(e.videoRange)-Cm.indexOf(t.videoRange);if(e.videoCodec!==t.videoCodec){const r=fm(e.videoCodec),i=fm(t.videoCodec);if(r!==i)return i-r}if(e.uri===t.uri&&e.codecSet!==t.codecSet){const r=pm(e.codecSet),i=pm(t.codecSet);if(r!==i)return i-r}return e.averageBitrate!==t.averageBitrate?e.averageBitrate-t.averageBitrate:0});let u=c[0];if(this.steering&&(l=this.steering.filterParsedLevels(l),l.length!==c.length))for(let e=0;e<c.length;e++)if(c[e].pathwayId===l[0].pathwayId){u=c[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)};d.end=performance.now(),this.hls.trigger(Vf.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(Vf.ERROR,{type:jf.OTHER_ERROR,details:Hf.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(Vf.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===Yf&&t.context.level===this.level&&this.checkRetry(t)}onFragBuffered(e,{frag:t}){if(void 0!==t&&t.type===Xf){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(Vf.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));Kv(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(Vf.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(Vf.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:r}))}}function GS(e){const t={};e.forEach(e=>{const r=e.groupId||"";e.id=t[r]=t[r]||0,t[r]++})}function jS(){return self.SourceBuffer||self.WebKitSourceBuffer}function HS(){if(!hp())return!1;const e=jS();return!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove}class VS extends vy{constructor(e,t,r){super(e,t,r,"stream-controller",Xf),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||!Uf(t))return;if(this.log(`Media seeked to ${t.toFixed(3)}`),!this.getBufferedFrag(t))return;const r=this.getFwdBufferInfoAtPos(e,t,Xf,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(Vf.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Vf.LEVEL_LOADING,this.onLevelLoading,this),e.on(Vf.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Vf.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(Vf.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(Vf.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(Vf.BUFFER_CREATED,this.onBufferCreated,this),e.on(Vf.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(Vf.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(Vf.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){super.unregisterListeners();const{hls:e}=this;e.off(Vf.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Vf.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Vf.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(Vf.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(Vf.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(Vf.BUFFER_CREATED,this.onBufferCreated,this),e.off(Vf.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(Vf.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(Vf.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=ay,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}else this._forceStartLoad=!0,this.state=sy}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case gy:{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=ay;break}if(this.hls.nextLoadLevel!==this.level){this.state=ay;break}break}case dy:this.checkRetryDate()}this.state===ay&&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(Vf.BUFFER_EOS,e),void(this.state=fy)}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===gy||this.waitForLive(s))return this.level=n,this.state=gy,void(this.startFragRequested=!1);const d=a.len,c=this.getMaxBufferLength(s.maxBitrate);if(d>=c)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&&Cp(h)&&this.fragmentTracker.getState(h)!==Eg){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?Lp:Ip,t=(e===Ip?this.videoBuffer:this.mediaBuffer)||this.media;t&&this.afterBufferFlushed(t,e,Xf)}h=this.getNextFragmentLoopLoading(h,l,a,Xf,c)}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===vg||i===bg?Cp(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,Xf)}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 oy:case ly:case dy:case uy:case hy:this.state=ay}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;ry(r,"playing",this.onMediaPlaying),ry(r,"seeked",this.onMediaSeeked)}onMediaDetaching(e,t){const{media:r}=this;r&&(iy(r,"playing",this.onMediaPlaying),iy(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(Vf.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=jS();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!==ay)return;const i=t.levelInfo;(!i.details||i.details.live&&(this.levelLastLoaded!==i||i.details.expired)||this.waitForCdnTuneIn(i.details))&&(this.state=gy)}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,d=this.fragCurrent;!d||this.state!==ly&&this.state!==dy||d.level!==t.level&&d.loader&&this.abortCurrentFrag();let c=0;if(a.live||null!=(r=l.details)&&r.live){var u;if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;c=this.alignPlaylists(a,l.details,null==(u=this.levelLastLoaded)?void 0:u.details)}if(l.details=a,this.levelLastLoaded=l,n||this.setStartPosition(a,c),this.hls.trigger(Vf.LEVEL_UPDATED,{details:a,level:s}),this.state===gy){if(this.waitForCdnTuneIn(a))return;this.state=ay}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=Bg.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}=Bg.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,d=o.PTSKnown||!o.live,c=null==(t=r.initSegment)?void 0:t.data,u=this._getAudioCodec(a),h=this.transmuxer=this.transmuxer||new Kb(this.hls,Xf,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),f=i?i.index:-1,p=-1!==f,m=new Fg(r.level,r.sn,r.stats.chunkCount,n.byteLength,f,p),g=this.initPTS[r.cc];h.push(n,c,u,l,r,i,o.totalduration,d,m,g)}onAudioTrackSwitching(e,t){const r=this.hls,i=0!==this.altAudio;if(Km(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(Vf.BUFFER_FLUSHED,()=>{this.hls&&this.hls.trigger(Vf.AUDIO_TRACK_SWITCHED,t)}),void r.trigger(Vf.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});r.trigger(Vf.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){const r=Km(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===Xf;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===hy&&(this.state=ay));const e=i?i.stats:r.stats;this.fragLastKbps=Math.round(8*e.total/(e.buffering.end-e.loading.first)),Cp(r)&&(this.fragPrevious=r),this.fragBufferedComplete(r,i)}const s=this.media;s&&(!this._hasEnoughToStart&&Bg.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=py;else switch(t.details){case Hf.FRAG_GAP:case Hf.FRAG_PARSING_ERROR:case Hf.FRAG_DECRYPT_ERROR:case Hf.FRAG_LOAD_ERROR:case Hf.FRAG_LOAD_TIMEOUT:case Hf.KEY_LOAD_ERROR:case Hf.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Xf,t);break;case Hf.LEVEL_LOAD_ERROR:case Hf.LEVEL_LOAD_TIMEOUT:case Hf.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==gy||(null==(r=t.context)?void 0:r.type)!==Yf||(this.state=ay);break;case Hf.BUFFER_ADD_CODEC_ERROR:case Hf.BUFFER_APPEND_ERROR:if("main"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)&&this.resetLoadingState();break;case Hf.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 Hf.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}onFragLoadEmergencyAborted(){this.state=ay,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==Lp||!this.altAudio){const e=(t===Ip?this.videoBuffer:this.mediaBuffer)||this.media;e&&(this.afterBufferFlushed(e,t,Xf),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=Bg.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=ay,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(Vf.FRAG_LOADED,e),i.bitrateTest=!1}).catch(t=>{this.state!==sy&&this.state!==py&&(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:d,text:c,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=uy,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(Vf.FRAG_PARSING_INIT_SEGMENT,{frag:i,id:t,tracks:e})}const i=h.initPTS,s=h.timescale,o=this.initPTS[a.cc];if(Uf(i)&&(!o||o.baseTime!==i||o.timescale!==s)){const e=h.trackId;this.initPTS[a.cc]={baseTime:i,timescale:s,trackId:e},r.trigger(Vf.INIT_PTS_FOUND,{frag:a,id:t,initPTS:i,timescale:s,trackId:e})}}if(d&&f){p&&"audiovideo"===d.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}=d;if(o)o.elementaryStreams[d.type]={startPTS:e,endPTS:i,startDTS:s,endDTS:l};else if(d.firstKeyFrame&&d.independent&&1===n.id&&!r&&(this.couldBacktrack=!0),d.dropped&&d.independent){const n=this.getMainFwdBufferInfo(),s=(n?n.end:this.getLoadPosition())+this.config.maxBufferHole,o=d.firstKeyFramePTS?d.firstKeyFramePTS:e;if(!t&&s<o-this.config.maxBufferHole&&!r)return void this.backtrack(a);r&&(a.gap=!0),a.setElementaryStreamInfo(d.type,a.start,i,a.start,l,!0)}else t&&e-(f.appliedTimelineOffset||0)>2&&(a.gap=!0);a.setElementaryStreamInfo(d.type,e,i,s,l),this.backtrackFragment&&(this.backtrackFragment=a),this.bufferFragmentData(d,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[Lp]={startPTS:e,endPTS:t,startDTS:r,endDTS:i}),a.setElementaryStreamInfo(Lp,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(Vf.FRAG_PARSING_METADATA,e)}if(f&&c){const e={id:t,frag:a,details:f,samples:c.samples};r.trigger(Vf.FRAG_PARSING_USERDATA,e)}}}logMuxedErr(e){this.warn(`${Cp(e)?"Media":"Init"} segment with muxed audiovideo where only video expected: ${e.url}`)}_bufferInitSegment(e,t,r,i){if(this.state!==uy)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=ym(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=Xf,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=Xf;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(Vf.BUFFER_CODECS,t),!this.hls)return;o.forEach(e=>{const n=t[e].initSegment;null!=n&&n.byteLength&&this.hls.trigger(Vf.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,Xf)}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=ay}checkFragmentChanged(){const e=this.media;let t=null;if(e&&e.readyState>1&&!1===e.seeking){const r=e.currentTime;if(Bg.isBuffered(e,r)?t=this.getAppendedFrag(r):Bg.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(Vf.FRAG_CHANGED,{frag:t}),e&&e.level===r||this.hls.trigger(Vf.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 Uf(t)?this.getAppendedFrag(t):null}get currentProgramDateTime(){var e;const t=(null==(e=this.media)?void 0:e.currentTime)||this.lastCurrentTime;if(Uf(t)){const e=this.getLevelDetails(),r=this.currentFrag||(e?Xm(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 WS extends sp{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=Hf.KEY_LOAD_ERROR,r,i,n){return new Mg({type:jf.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&&(!Cp(e)||!Cp(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=hv(e);return t?this.emeController.getKeySystemAccess([t]):void 0})}if(this.config.requireKeySystemAccessOnStart){const e=pv(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,Hf.KEY_LOAD_ERROR,r))}const s=n.uri;if(!s)return Promise.reject(this.createKeyLoadError(e,Hf.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${s}"`)));const a=YS(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: "+mp(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,Hf.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 Qp(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 ${mp(t)}`),bv.setKeyIdForUri(e.decryptdata.uri,t)):(t=bv.addKeyIdForUri(e.decryptdata.uri),this.log(`Generating keyId to patch media ${mp(t)}`)),e.decryptdata.keyId=t}}if(!e.decryptdata.keyId&&!Cp(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},d={onSuccess:(e,t,r,i)=>{const{frag:a,keyInfo:o}=r,l=YS(o.decryptdata);if(!a.decryptdata||o!==this.keyIdToKeyInfo[l])return s(this.createKeyLoadError(a,Hf.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,Hf.KEY_LOAD_ERROR,new Error(`HTTP Error ${e.code} loading key ${e.text}`),i,np({url:a.url,data:void 0},e)))},onTimeout:(e,r,i)=>{this.resetLoader(r),s(this.createKeyLoadError(t,Hf.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),i))},onAbort:(e,r,i)=>{this.resetLoader(r),s(this.createKeyLoadError(t,Hf.INTERNAL_ABORTED,new Error("key loading aborted"),i))}};i.load(a,l,d)})}resetLoader(e){const{frag:t,keyInfo:r,url:i}=e,n=r.loader;t.keyLoader===n&&(t.keyLoader=null,r.loader=null);const s=YS(r.decryptdata)||i;delete this.keyIdToKeyInfo[s],n&&n.destroy()}}function YS(e){if(e.keyFormat!==dv){const t=e.keyId;if(t)return mp(t)}return e.uri}function KS(e){const{type:t}=e;switch(t){case Kf:return Qf;case qf:return Zf;default:return Xf}}function qS(e,t){let r=e.url;return void 0!==r&&0!==r.indexOf("data:")||(r=t.url),r}class XS{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(Vf.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Vf.LEVEL_LOADING,this.onLevelLoading,this),e.on(Vf.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(Vf.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.on(Vf.LEVELS_UPDATED,this.onLevelsUpdated,this)}unregisterListeners(){const{hls:e}=this;e.off(Vf.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Vf.LEVEL_LOADING,this.onLevelLoading,this),e.off(Vf.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(Vf.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.off(Vf.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:Wf,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:Yf,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:Kf,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:qf,url:n,deliveryDirectives:s,levelOrTrack:a})}onLevelsUpdated(e,t){const r=this.loaders[Yf];if(r){const e=r.context;e&&!t.levels.some(t=>t===e.levelOrTrack)&&(r.abort(),delete this.loaders[Yf])}}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===Wf?r.manifestLoadPolicy.default:rp({},r.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),n=this.createInternalLoader(e),Uf(null==(t=e.deliveryDirectives)?void 0:t.part)){let t;if(e.type===Yf&&null!==e.level?t=this.hls.levels[e.level].details:e.type===Kf&&null!==e.id?t=this.hls.audioTracks[e.id].details:e.type===qf&&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=rp({},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(),kv.isMediaPlaylist(s)||r.type!==Wf?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=qS(e,r),o=kv.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:d,sessionData:c,sessionKeys:u,startTimeOffset:h,variableList:f}=o;this.variableList=f,d.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];cm(a,"audio",r)?(e.audioCodec=i=i?`${i},${a}`:a,lm.audio[i.substring(0,4)]=2,t.splice(s,1)):cm(a,"video",r)&&(e.videoCodec=n=n?`${n},${a}`:a,lm.video[n.substring(0,4)]=2,t.splice(s,1))}}});const{AUDIO:p=[],SUBTITLES:m,"CLOSED-CAPTIONS":g}=kv.parseMasterPlaylistMedia(s,a,o);if(p.length){p.some(e=>!e.url)||!d[0].audioCodec||d[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 Yg({}),bitrate:0,url:""}))}n.trigger(Vf.MANIFEST_LOADED,{levels:d,audioTracks:p,subtitles:m,captions:g,contentSteering:l,url:a,stats:t,networkDetails:i,sessionData:c,sessionKeys:u,startTimeOffset:h,variableList:f})}handleTrackOrLevelPlaylist(e,t,r,i,n){const s=this.hls,{id:a,level:o,type:l}=r,d=qS(e,r),c=Uf(o)?o:Uf(a)?a:0,u=KS(r),h=kv.parseLevelPlaylist(e.data,d,c,u,0,this.variableList);if(l===Wf){const e={attrs:new Yg({}),bitrate:0,details:h,name:"",url:d};h.requestScheduled=t.loading.start+Hv(h,0),s.trigger(Vf.MANIFEST_LOADED,{levels:[e],audioTracks:[],url:d,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(Vf.ERROR,{type:jf.NETWORK_ERROR,details:Hf.MANIFEST_PARSING_ERROR,fatal:t.type===Wf,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===Yf?s+=`: ${e.level} id: ${e.id}`:e.type!==Kf&&e.type!==qf||(s+=` id: ${e.id} group-id: "${e.groupId}"`);const a=new Error(s);this.hls.logger.warn(`[playlist-loader]: ${s}`);let o=Hf.UNKNOWN,l=!1;const d=this.getInternalLoader(e);switch(e.type){case Wf:o=r?Hf.MANIFEST_LOAD_TIMEOUT:Hf.MANIFEST_LOAD_ERROR,l=!0;break;case Yf:o=r?Hf.LEVEL_LOAD_TIMEOUT:Hf.LEVEL_LOAD_ERROR,l=!1;break;case Kf:o=r?Hf.AUDIO_TRACK_LOAD_TIMEOUT:Hf.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case qf:o=r?Hf.SUBTITLE_TRACK_LOAD_TIMEOUT:Hf.SUBTITLE_LOAD_ERROR,l=!1}d&&this.resetInternalLoader(e.type);const c={type:jf.NETWORK_ERROR,details:o,fatal:l,url:e.url,loader:d,context:e,error:a,networkDetails:t,stats:n};if(i){const r=(null==t?void 0:t.url)||e.url;c.response=np({url:r,data:void 0},i)}this.hls.trigger(Vf.ERROR,c)}handlePlaylistLoaded(e,t,r,i,n,s){const a=this.hls,{type:o,level:l,levelOrTrack:d,id:c,groupId:u,deliveryDirectives:h}=i,f=qS(t,i),p=KS(i);let m="number"==typeof i.level&&p===Xf?l:void 0;const g=e.playlistParsingError;if(g){if(this.hls.logger.warn(`${g} ${e.url}`),!a.config.ignorePlaylistParsingErrors)return void a.trigger(Vf.ERROR,{type:jf.NETWORK_ERROR,details:Hf.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(Vf.ERROR,{type:jf.NETWORK_ERROR,details:Hf.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 Wf:case Yf:if(m)if(d){if(d!==a.levels[m]){const e=a.levels.indexOf(d);e>-1&&(m=e)}}else m=0;a.trigger(Vf.LEVEL_LOADED,{details:e,levelInfo:d||a.levels[0],level:m||0,id:c||0,stats:r,networkDetails:n,deliveryDirectives:h,withoutMultiVariant:o===Wf});break;case Kf:a.trigger(Vf.AUDIO_TRACK_LOADED,{details:e,track:d,id:c||0,groupId:u||"",stats:r,networkDetails:n,deliveryDirectives:h});break;case qf:a.trigger(Vf.SUBTITLE_TRACK_LOADED,{details:e,track:d,id:c||0,groupId:u||"",stats:r,networkDetails:n,deliveryDirectives:h})}}}class QS{static get version(){return xy}static isMSESupported(){return HS()}static isSupported(){return function(){if(!HS())return!1;const e=hp();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(hm(t,"video")))||["mp4a.40.2","fLaC"].some(t=>e.isTypeSupported(hm(t,"audio"))))}()}static getMediaSource(){return hp()}static get Events(){return Vf}static get MetadataSchema(){return Yy}static get ErrorTypes(){return jf}static get ErrorDetails(){return Hf}static get DefaultConfig(){return QS.defaultConfig?QS.defaultConfig:RS}static set DefaultConfig(e){QS.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 Ty,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=lp();if("object"==typeof console&&!0===e||"object"==typeof e){const n=["debug","log","info","warn","error"];n.forEach(t=>{i[t]=dp(t,e,r)});try{i.log(`Debug logs enabled for "${t}" in hls.js version 1.6.15`)}catch(e){return lp()}n.forEach(t=>{cp[t]=dp(t,e)})}else rp(cp,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=PS(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}": ${Um(t[s])}`)}),np(np({},i),t)}(QS.DefaultConfig,e,t);this.userConfig=e,r.progressive&&CS(r,t);const{abrController:i,bufferController:n,capLevelController:s,errorController:a,fpsController:o}=r,l=new a(this),d=this.abrController=new i(this),c=new wg(this),u=r.interstitialsController,h=u?this.interstitialsController=new u(this,QS):null,f=this.bufferController=new n(this,c),p=this.capLevelController=new s(this),m=new o(this),g=new XS(this),v=r.contentSteeringController,y=v?new v(this):null,b=this.levelController=new zS(this,y),E=new BS(this),w=new WS(this.config,this.logger),S=this.streamController=new VS(this,c,w),T=this.gapController=new DS(this,c);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=[d,f,T,p,m,E,c];this.audioTrackController=this.createController(r.audioTrackController,x);const k=r.audioStreamController;k&&x.push(this.audioStreamController=new k(this,c,w)),this.subtitleTrackController=this.createController(r.subtitleTrackController,x);const L=r.subtitleStreamController;L&&x.push(this.subtititleStreamController=new L(this,c,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(US,A),this.coreComponents=A,x.push(l);const I=l.onErrorOut;"function"==typeof I&&this.on(Vf.ERROR,I,l),this.on(Vf.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===Vf.ERROR;this.trigger(Vf.ERROR,{type:jf.OTHER_ERROR,details:Hf.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(Vf.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(Vf.ERROR,{type:jf.OTHER_ERROR,details:Hf.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(Vf.MEDIA_ATTACHING,i)}detachMedia(){this.logger.log("detachMedia"),this.trigger(Vf.MEDIA_DETACHING,{}),this._media=null}transferMedia(){this._media=null;const e=this.bufferController.transferMedia();return this.trigger(Vf.MEDIA_DETACHING,{transferMedia:e}),e}loadSource(e){this.stopLoad();const t=this.media,r=this._url,i=this._url=Ap.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(Vf.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={[Xf]:this.streamController.inFlightFrag};return this.audioStreamController&&(e[Qf]=this.audioStreamController.inFlightFrag),this.subtititleStreamController&&(e[Zf]=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 Pm.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 Lm(e,Gm(t),navigator.mediaCapabilities)}}QS.defaultConfig=void 0;const ZS=({file:e,startTime:n,poster:s,autoplay:o=!0,active:l=!0,visible:d=!0,muted:h=!0})=>{const f=r(null),{isReady:p,prewarm:m,setLowestResolution:g,startBufferBasedUpshift:v}=(({file:e,videoRef:t,autoplay:n=!0,startTime:s,enabled:o=!0,onReady:l,onError:d})=>{const h=r(null),f=r(null),p=r(0),m=r(0),g=r(!1),v=r(!1),[y,b]=a("idle"),[E,w]=a(0),[S,T]=a(!1),[A,k]=a([]),[L,I]=a("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=u(()=>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||!o)return void(e&&!o&&(v.current=!1,T(!1),b("idle")));let s=()=>{};try{null===(r=h.current)||void 0===r||r.destroy()}catch(e){}if(h.current=null,v.current=!1,T(!1),b("loading"),QS.isSupported()){g.current=!1;const t=new QS({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;I(null==r||r<0?"auto":r)},a=()=>{v.current||(v.current=!0,T(!0),b("ready"),p.current=0,R(),null==l||l(),n&&i.play().catch(()=>{}))};t.on(QS.Events.MANIFEST_PARSED,()=>{r(),n||_()}),t.on(QS.Events.FRAG_BUFFERED,a),t.on(QS.Events.BUFFER_APPENDED,a),t.on(QS.Events.LEVEL_SWITCHED,(e,t)=>{const r=null==t?void 0:t.level;I(null==r||r<0?"auto":r)}),t.on(QS.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!==QS.ErrorTypes.NETWORK_ERROR||r.fatal){if(r.fatal){if(r.type===QS.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),s=()=>{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==l||l(),n&&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),n&&i.play().catch(()=>{}),s=()=>{i.removeEventListener("loadedmetadata",t),i.removeEventListener("error",r)}}else b("error"),null==d||d(new Error("HLS not supported"));return()=>{s(),R()}},[e,E,n,l,d,t,o]),i(()=>{if(!S)return;if(null==s||s<=0)return;const e=t.current;if(e)try{Math.abs(e.currentTime-s)>.5&&(e.currentTime=s)}catch(e){}},[S,s,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=u(()=>{const e=h.current;e&&!g.current&&(console.log("Set auto resolution"),e.nextLevel=-1,I("auto"))},[]),_=u(()=>{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=u((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,I("auto"),n=!0)}catch(e){}};return r.on(QS.Events.FRAG_BUFFERED,s),()=>{r.off(QS.Events.FRAG_BUFFERED,s)}},[t]);return{playbackStatus:y,isReady:S,qualities:A,currentLevel:L,isAutoQuality:c(()=>"auto"===L,[L]),canSetResolution:!g.current&&QS.isSupported(),setResolution:e=>{const t=h.current;if(!t||g.current)return;if("string"==typeof e&&"auto"===e.toLowerCase())return t.currentLevel=-1,void I("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,I(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,I(n.id))},setAutoResolution:D,prewarm:C,setLowestResolution:_,startBufferBasedUpshift:O}})({file:e,videoRef:f,autoplay:o,startTime:n,enabled:o||l});return i(()=>{m()},[m]),t.useEffect(()=>{var e,t;const r=f.current;if(r)if(l)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){}},[l,p]),i(()=>{if(!l)return;g();return v(2)},[l,g,v]),t.createElement("video",{ref:f,playsInline:!0,autoPlay:o,muted:h,poster:Rt(s||""),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"}})},JS=({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," 시청")),eT=({content:e,aspectRatio:r="9/16",cursor:i="default",borderRadius:n,playback:s="hover"})=>{var a,o,l,d,c;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}=$f(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 L=()=>{null!=p.current&&(clearTimeout(p.current),p.current=null)},I=()=>{g(!0),L(),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||(L(),p.current=window.setTimeout(()=>{f(!0)},150)))},onMouseLeave:()=>{L(),f(!1)},onMouseDown:I,onTouchStart:I},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(${Rt(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(ZS,{file:k,poster:S,autoplay:"autoplay"===s,active:"autoplay"===s&&b||R&&h,visible:P,muted:!0})),!P&&t.createElement(Nf,null),t.createElement(JS,{view:null!==(c=null===(d=e.statistics)||void 0===d?void 0:d.pageView)&&void 0!==c?c:0}))))},tT=e=>{var r,i,n,s;const{content:a,title:o,aspectRatio:l="9/16",card:d,titleFontSize:u}=e,h=null!==(r=null==d?void 0:d.layout)&&void 0!==r?r:"slider",f=null!==(i=null==d?void 0:d.sliderPerView)&&void 0!==i?i:3,p=null!==(n=null==d?void 0:d.gridColumns)&&void 0!==n?n:3,m=null!==(s=null==d?void 0:d.gap)&&void 0!==s?s:12,g=null==d?void 0:d.width,v=g?"auto":f,y=c(()=>({fontSize:u?`${u}px`:void 0,fontWeight:600}),[u]),{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(Xs,{key:`${v}-${null!=g?g:""}-${m}`,slidesPerView:v,spaceBetween:m},a.map(r=>{var i,n;return t.createElement(Qs,{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!==Mf.READY?t.createElement(eT,{content:r,aspectRatio:l,cursor:"pointer",borderRadius:null==d?void 0:d.borderRadius,playback:e.playback}):t.createElement(Bf,{content:r,aspectRatio:l,cursor:"pointer",borderRadius:null==d?void 0:d.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!==Mf.READY?t.createElement(eT,{content:r,aspectRatio:l,cursor:"pointer",borderRadius:null==d?void 0:d.borderRadius,playback:e.playback}):t.createElement(Bf,{content:r,aspectRatio:l,cursor:"pointer",borderRadius:null==d?void 0:d.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},rT=({content:e})=>{const r=t.useMemo(()=>qe(e.start).tz("Asia/Seoul").format("M월 D일 A HH:mm"),[e.start]),i=e.eventStatus!==Mf.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"}},"라이브 입장하기"))},iT=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:d}=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:`${d}/live/${n.eventId}`,target:"_blank",rel:"noopener noreferrer",style:l?{width:`${l}px`}:void 0},t.createElement(Bf,{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:`${d}/live/${n.eventId}`,target:"_blank",rel:"noopener noreferrer",style:l?{width:`${l}px`}:void 0},t.createElement(Bf,{content:n,aspectRatio:s,borderRadius:o,cursor:"pointer"}))),t.createElement(rT,{content:n})):t.createElement(t.Fragment,null,t.createElement(rT,{content:n}),t.createElement("div",{className:"flex-1"},t.createElement("a",{href:`${d}/live/${n.eventId}`,target:"_blank",rel:"noopener noreferrer",style:l?{width:`${l}px`}:void 0},t.createElement(Bf,{content:n,aspectRatio:s,borderRadius:o,cursor:"pointer"})))))},nT=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 sT(t){var{className:r}=t,i=T(t,["className"]);return e.createElement("div",Object.assign({className:wt("animate-pulse rounded-md bg-gray-200",r)},i))}const aT=e=>{var r,i,n,s,a,o,l,d,c;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!==(d=null==p?void 0:p.paddingLeft)&&void 0!==d?d:0,x=null!==(c=null==p?void 0:p.paddingRight)&&void 0!==c?c:0,A="ONE"===f&&"past"!==e.liveType,k=A?1:(null==u?void 0:u.visibleCount)||6,L=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(sT,{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:L}).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(sT,{style:{aspectRatio:h,borderRadius:E,width:"100%"}}),t.createElement(sT,{className:"h-3.5 w-4/5"})))))},oT=e=>{var r,i,n,s;const{widgetType:a,theme:o,layout:l}=e,d=Of(e=>e.liveWidget),c=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===d?t.createElement(aT,Object.assign({},e)):0===d.length?t.createElement(nT,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:c,paddingBottom:u,paddingLeft:h,paddingRight:f}},"ONE"===a&&"past"!==e.liveType?t.createElement(iT,Object.assign({content:d[0]},e)):t.createElement(tT,Object.assign({content:d},e)))},lT=e=>{const r=Of(e=>e.liveWidget),n=Of(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 Pa(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(Er.div,{className:"w-full h-full"},t.createElement(Ec,null),t.createElement(oT,Object.assign({},e)))},dT=e=>t.createElement(_f,null,t.createElement(lT,Object.assign({},e))),cT=({eventId:e})=>{const[r,i]=a(!1),{PLAYER_BASE_URL:n}=gt();if(r)return null;const{w:s,h:o,left:l,top:d}=(()=>{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(If,{minWidth:240,lockAspectRatio:9/17.05,style:{zIndex:99999},default:{width:240,height:455,x:l+s-240-50,y:d+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(Cr,{size:16,color:"#888"}),t.createElement("button",{className:"cursor-pointer",style:{color:"#ccc",lineHeight:0},onClick:()=>i(!0),"aria-label":"Close"},t.createElement($r,{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"})))},uT=({eventId:e})=>e?t.createElement(Er.div,{style:{position:"fixed",inset:0,pointerEvents:"none",zIndex:99999}},t.createElement(Ec,null),t.createElement("div",{style:{pointerEvents:"auto"}},t.createElement(cT,{eventId:e}))):null;export{Ph as CollectionShowcase,Cf as FloatingPlayer,uT as LiveFloatingPlayer,dT as LiveWidget,Ac as PreviewPlayer,xc as ShoppingPlayer,Dt as ViewPlayer,Lh as WidgetPlayer,mt as configure};
40
+ */function qr(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,d=e.useMemo(()=>o,Object.values(o));return b(l.Provider,{value:d,children:n})};return o.displayName=r+"Provider",[o,function(i,o){const l=o?.[t]?.[a]||s,d=e.useContext(l);if(d)return d;if(void 0!==n)return n;throw new Error(`\`${i}\` must be used within \`${r}\``)}]},Xr(n,...r)]}function Xr(...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 Qr(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function Zr(...e){return t=>{let r=!1;const i=e.map(e=>{const i=Qr(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():Qr(e[t],null)}}}}function Jr(...t){return e.useCallback(Zr(...t),t)}var ei=e.forwardRef((t,r)=>{const{children:i,...n}=t,s=e.Children.toArray(i),a=s.find(ii);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(ti,{...n,ref:r,children:e.isValidElement(t)?e.cloneElement(t,void 0,i):null})}return b(ti,{...n,ref:r,children:i})});ei.displayName="Slot";var ti=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?Zr(r,t):t),e.cloneElement(i,s)}return e.Children.count(i)>1?e.Children.only(null):null});ti.displayName="SlotClone";var ri=({children:e})=>b(E,{children:e});function ii(t){return e.isValidElement(t)&&t.type===ri}function ni(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function si(...e){return t=>{let r=!1;const i=e.map(e=>{const i=ni(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():ni(e[t],null)}}}}function ai(e,t,{checkForDefaultPrevented:r=!0}={}){return function(i){if(e?.(i),!1===r||!i.defaultPrevented)return t?.(i)}}function oi(t){const r=e.useRef(t);return e.useEffect(()=>{r.current=t}),e.useMemo(()=>(...e)=>r.current?.(...e),[])}function li({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=oi(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=oi(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 di=e.forwardRef((t,r)=>{const{children:i,...n}=t,s=e.Children.toArray(i),a=s.find(hi);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(ci,{...n,ref:r,children:e.isValidElement(t)?e.cloneElement(t,void 0,i):null})}return b(ci,{...n,ref:r,children:i})});di.displayName="Slot";var ci=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?si(r,t):t),e.cloneElement(i,s)}return e.Children.count(i)>1?e.Children.only(null):null});ci.displayName="SlotClone";var ui=({children:e})=>b(E,{children:e});function hi(t){return e.isValidElement(t)&&t.type===ui}var fi=["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?di:r;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),b(s,{...n,ref:t})});return i.displayName=`Primitive.${r}`,{...t,[r]:i}},{}),pi=Boolean(globalThis?.document)?e.useLayoutEffect:()=>{};function mi(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function gi(...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 vi(...t){return e.useCallback(gi(...t),t)}var yi=e.forwardRef((t,r)=>{const{children:i,...n}=t,s=e.Children.toArray(i),a=s.find(wi);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(bi,{...n,ref:r,children:e.isValidElement(t)?e.cloneElement(t,void 0,i):null})}return b(bi,{...n,ref:r,children:i})});yi.displayName="Slot";var bi=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?gi(r,t):t),e.cloneElement(i,s)}return e.Children.count(i)>1?e.Children.only(null):null});bi.displayName="SlotClone";var Ei=({children:e})=>b(E,{children:e});function wi(t){return e.isValidElement(t)&&t.type===Ei}var Si=["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?yi:r;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),b(s,{...n,ref:t})});return i.displayName=`Primitive.${r}`,{...t,[r]:i}},{});var Ti=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,d]=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=xi(n.current);a.current="mounted"===l?e:"none"},[l]),pi(()=>{const e=n.current,r=s.current;if(r!==t){const i=a.current,n=xi(e);if(t)d("MOUNT");else if("none"===n||"none"===e?.display)d("UNMOUNT");else{d(r&&i!==n?"ANIMATION_OUT":"UNMOUNT")}s.current=t}},[t,d]),pi(()=>{if(r){let e;const t=r.ownerDocument.defaultView??window,i=i=>{const a=xi(n.current).includes(i.animationName);if(i.target===r&&a&&(d("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=xi(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)}}d("ANIMATION_END")},[r,d]),{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=vi(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 xi(e){return e?.animationName||"none"}Ti.displayName="Presence";var Ai=Boolean(globalThis?.document)?e.useLayoutEffect:()=>{},ki=e["useId".toString()]||(()=>{}),Li=0;function Ii(t){const[r,i]=e.useState(ki());return Ai(()=>{i(e=>e??String(Li++))},[t]),r?`radix-${r}`:""}var Ri="Collapsible",[Pi,Ci]=qr(Ri),[Di,_i]=Pi(Ri),Oi=e.forwardRef((t,r)=>{const{__scopeCollapsible:i,open:n,defaultOpen:s,disabled:a,onOpenChange:o,...l}=t,[d=!1,c]=li({prop:n,defaultProp:s,onChange:o});return b(Di,{scope:i,disabled:a,contentId:Ii(),open:d,onOpenToggle:e.useCallback(()=>c(e=>!e),[c]),children:b(Si.div,{"data-state":Ui(d),"data-disabled":a?"":void 0,...l,ref:r})})});Oi.displayName=Ri;var Mi="CollapsibleTrigger",Ni=e.forwardRef((e,t)=>{const{__scopeCollapsible:r,...i}=e,n=_i(Mi,r);return b(Si.button,{type:"button","aria-controls":n.contentId,"aria-expanded":n.open||!1,"data-state":Ui(n.open),"data-disabled":n.disabled?"":void 0,disabled:n.disabled,...i,ref:t,onClick:ai(e.onClick,n.onOpenToggle)})});Ni.displayName=Mi;var Fi="CollapsibleContent",$i=e.forwardRef((e,t)=>{const{forceMount:r,...i}=e,n=_i(Fi,e.__scopeCollapsible);return b(Ti,{present:r||n.open,children:({present:e})=>b(Bi,{...i,ref:t,present:e})})});$i.displayName=Fi;var Bi=e.forwardRef((t,r)=>{const{__scopeCollapsible:i,present:n,children:s,...a}=t,o=_i(Fi,i),[l,d]=e.useState(n),c=e.useRef(null),u=vi(r,c),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)},[]),pi(()=>{const e=c.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),d(n)}},[o.open,n]),b(Si.div,{"data-state":Ui(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 Ui(e){return e?"open":"closed"}var zi=Oi,Gi=Ni,ji=$i,Hi=e.createContext(void 0);var Vi="Accordion",Wi=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[Yi,Ki,qi]=function(e){const r=e+"CollectionProvider",[i,n]=qr(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",d=t.forwardRef((e,t)=>{const{scope:r,children:i}=e,n=Jr(t,a(l,r).collectionRef);return b(ei,{ref:n,children:i})});d.displayName=l;const c=e+"CollectionItemSlot",u="data-radix-collection-item",h=t.forwardRef((e,r)=>{const{scope:i,children:n,...s}=e,o=t.useRef(null),l=Jr(r,o),d=a(c,i);return t.useEffect(()=>(d.itemMap.set(o,{ref:o,...s}),()=>{d.itemMap.delete(o)})),b(ei,{[u]:"",ref:l,children:n})});return h.displayName=c,[{Provider:o,Slot:d,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]}(Vi),[Xi,Qi]=qr(Vi,[qi,Ci]),Zi=Ci(),Ji=t.forwardRef((e,t)=>{const{type:r,...i}=e,n=i,s=i;return b(Yi.Provider,{scope:e.__scopeAccordion,children:"multiple"===r?b(an,{...s,ref:t}):b(sn,{...n,ref:t})})});Ji.displayName=Vi;var[en,tn]=Xi(Vi),[rn,nn]=Xi(Vi,{collapsible:!1}),sn=t.forwardRef((e,r)=>{const{value:i,defaultValue:n,onValueChange:s=()=>{},collapsible:a=!1,...o}=e,[l,d]=li({prop:i,defaultProp:n,onChange:s});return b(en,{scope:e.__scopeAccordion,value:l?[l]:[],onItemOpen:d,onItemClose:t.useCallback(()=>a&&d(""),[a,d]),children:b(rn,{scope:e.__scopeAccordion,collapsible:a,children:b(dn,{...o,ref:r})})})}),an=t.forwardRef((e,r)=>{const{value:i,defaultValue:n,onValueChange:s=()=>{},...a}=e,[o=[],l]=li({prop:i,defaultProp:n,onChange:s}),d=t.useCallback(e=>l((t=[])=>[...t,e]),[l]),c=t.useCallback(e=>l((t=[])=>t.filter(t=>t!==e)),[l]);return b(en,{scope:e.__scopeAccordion,value:o,onItemOpen:d,onItemClose:c,children:b(rn,{scope:e.__scopeAccordion,collapsible:!0,children:b(dn,{...a,ref:r})})})}),[on,ln]=Xi(Vi),dn=t.forwardRef((r,i)=>{const{__scopeAccordion:n,disabled:s,dir:a,orientation:o="vertical",...l}=r,d=function(...t){return e.useCallback(si(...t),t)}(t.useRef(null),i),c=Ki(n),u="ltr"===function(t){const r=e.useContext(Hi);return t||r||"ltr"}(a),h=ai(r.onKeyDown,e=>{if(!Wi.includes(e.key))return;const t=e.target,r=c().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)},d=()=>{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():d());break;case"ArrowDown":"vertical"===o&&l();break;case"ArrowLeft":"horizontal"===o&&(u?d():l());break;case"ArrowUp":"vertical"===o&&d()}const h=s%n;r[h].ref.current?.focus()});return b(on,{scope:n,disabled:s,direction:a,orientation:o,children:b(Yi.Slot,{scope:n,children:b(fi.div,{...l,"data-orientation":o,ref:d,onKeyDown:s?void 0:h})})})}),cn="AccordionItem",[un,hn]=Xi(cn),fn=t.forwardRef((e,t)=>{const{__scopeAccordion:r,value:i,...n}=e,s=ln(cn,r),a=tn(cn,r),o=Zi(r),l=Ii(),d=i&&a.value.includes(i)||!1,c=s.disabled||e.disabled;return b(un,{scope:r,open:d,disabled:c,triggerId:l,children:b(zi,{"data-orientation":s.orientation,"data-state":En(d),...o,...n,ref:t,disabled:c,open:d,onOpenChange:e=>{e?a.onItemOpen(i):a.onItemClose(i)}})})});fn.displayName=cn;var pn="AccordionHeader",mn=t.forwardRef((e,t)=>{const{__scopeAccordion:r,...i}=e,n=ln(Vi,r),s=hn(pn,r);return b(fi.h3,{"data-orientation":n.orientation,"data-state":En(s.open),"data-disabled":s.disabled?"":void 0,...i,ref:t})});mn.displayName=pn;var gn="AccordionTrigger",vn=t.forwardRef((e,t)=>{const{__scopeAccordion:r,...i}=e,n=ln(Vi,r),s=hn(gn,r),a=nn(gn,r),o=Zi(r);return b(Yi.ItemSlot,{scope:r,children:b(Gi,{"aria-disabled":s.open&&!a.collapsible||void 0,"data-orientation":n.orientation,id:s.triggerId,...o,...i,ref:t})})});vn.displayName=gn;var yn="AccordionContent",bn=t.forwardRef((e,t)=>{const{__scopeAccordion:r,...i}=e,n=ln(Vi,r),s=hn(yn,r),a=Zi(r);return b(ji,{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 En(e){return e?"open":"closed"}bn.displayName=yn;var wn=Ji,Sn=fn,Tn=mn,xn=vn,An=bn;function kn(t){var r=T(t,[]);return e.createElement(wn,Object.assign({"data-slot":"accordion"},r))}function Ln(t){var{className:r}=t,i=T(t,["className"]);return e.createElement(Sn,Object.assign({"data-slot":"accordion-item",className:wt("border-b last:border-b-0",r)},i))}function In(t){var{className:r,children:i}=t,n=T(t,["className","children"]);return e.createElement(Tn,{className:"flex"},e.createElement(xn,Object.assign({"data-slot":"accordion-trigger",className:wt("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(Lr,{className:"text-muted-foreground pointer-events-none size-4 shrink-0 translate-y-0.5 transition-transform duration-200"})))}function Rn(t){var{className:r,children:i}=t,n=T(t,["className","children"]);return e.createElement(An,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:wt("pt-0 pb-4",r)},i))}const Pn=({title:e,content:r})=>t.createElement(kn,{style:{borderRadius:"0.625rem"},type:"single",collapsible:!0,className:"bg-white px-4",defaultValue:"item"},t.createElement(Ln,{value:"item"},t.createElement(In,{className:""},e),t.createElement(Rn,{className:"text-gray-700"},r))),Cn=({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(Br,null)))),Dn=e=>{const{playerSettings:r,shortform:{description:i,productsInfo:n,logo:s,brand:a,title:o},player:l}=e;return t.createElement("div",{className:"w-full h-full bg-[#f4f4f4] overflow-scroll"},t.createElement(Cn,{logo:s}),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"},a?t.createElement("div",{className:"items-center flex gap-3"},a.thumbPath&&t.createElement("div",{className:"w-16 h-16 bg-white rounded-full border "},t.createElement("img",{src:a.thumbPath,alt:a.brandName,width:100,height:100,className:"object-contain w-full h-full rounded-full"})),t.createElement("div",null,t.createElement("p",null,a.brandName),t.createElement("p",{className:"text-lg font-semibold"},o))):t.createElement("p",{className:"text-xl font-semibold"},o),t.createElement(Ur,null)),t.createElement("div",{className:"w-full pb-10 flex gap-4 justify-center"},t.createElement("div",{className:"flex gap-3"},l),t.createElement("div",{className:"flex flex-col gap-4 justify-end"},t.createElement(Wr,{rounded:!0}),t.createElement(Yr,{rounded:!0}),t.createElement(Kr,{rounded:!0})))),t.createElement("div",{className:"flex flex-col gap-4 max-w-[40%]"},i&&t.createElement(Pn,{title:"숏클립 안내",content:t.createElement("p",{className:"font-medium"},i)}),t.createElement(Pn,{title:"상품 목록",content:t.createElement(t.Fragment,null,t.createElement("div",{className:"max-h-[300px] overflow-y-auto font-medium"},n.map((e,r)=>t.createElement(t.Fragment,null,t.createElement(jr,{product:e}),r!==n.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==n?void 0:n.length)},"상품 전체 보기"))}),r.comment&&t.createElement(Pn,{title:"댓글",content:t.createElement(Hr,null)}))))};function _n(e){return null!==e&&"object"==typeof e&&"constructor"in e&&e.constructor===Object}function On(e,t){void 0===e&&(e={}),void 0===t&&(t={}),Object.keys(t).forEach(r=>{void 0===e[r]?e[r]=t[r]:_n(t[r])&&_n(e[r])&&Object.keys(t[r]).length>0&&On(e[r],t[r])})}const Mn={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 Nn(){const e="undefined"!=typeof document?document:{};return On(e,Mn),e}const Fn={document:Mn,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 $n(){const e="undefined"!=typeof window?window:{};return On(e,Fn),e}function Bn(e,t){return void 0===t&&(t=0),setTimeout(e,t)}function Un(){return Date.now()}function zn(e,t){void 0===t&&(t="x");const r=$n();let i,n,s;const a=function(e){const t=$n();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 Gn(e){return"object"==typeof e&&null!==e&&e.constructor&&"Object"===Object.prototype.toString.call(e).slice(8,-1)}function jn(e){return"undefined"!=typeof window&&void 0!==window.HTMLElement?e instanceof HTMLElement:e&&(1===e.nodeType||11===e.nodeType)}function Hn(){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&&!jn(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&&(Gn(e[n])&&Gn(i[n])?i[n].__swiper__?e[n]=i[n]:Hn(e[n],i[n]):!Gn(e[n])&&Gn(i[n])?(e[n]={},i[n].__swiper__?e[n]=i[n]:Hn(e[n],i[n])):e[n]=i[n])}}}return e}function Vn(e,t,r){e.style.setProperty(t,r)}function Wn(e){let{swiper:t,targetPosition:r,side:i}=e;const n=$n(),s=-t.translate;let a,o=null;const l=t.params.speed;t.wrapperEl.style.scrollSnapType="none",n.cancelAnimationFrame(t.cssModeFrameID);const d=r>s?"next":"prev",c=(e,t)=>"next"===d&&e>=t||"prev"===d&&e<=t,u=()=>{a=(new Date).getTime(),null===o&&(o=a);const e=Math.max(Math.min((a-o)/l,1),0),d=.5-Math.cos(e*Math.PI)/2;let h=s+d*(r-s);if(c(h,r)&&(h=r),t.wrapperEl.scrollTo({[i]:h}),c(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 Yn(e){return e.querySelector(".swiper-slide-transform")||e.shadowRoot&&e.shadowRoot.querySelector(".swiper-slide-transform")||e}function Kn(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 qn(e){try{return void console.warn(e)}catch(e){}}function Xn(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 Qn(e,t){return $n().getComputedStyle(e,null).getPropertyValue(t)}function Zn(e){let t,r=e;if(r){for(t=0;null!==(r=r.previousSibling);)1===r.nodeType&&(t+=1);return t}}function Jn(e,t,r){const i=$n();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 es(e){return(Array.isArray(e)?e:[e]).filter(e=>!!e)}let ts,rs,is;function ns(){return ts||(ts=function(){const e=$n(),t=Nn();return{smoothScroll:t.documentElement&&t.documentElement.style&&"scrollBehavior"in t.documentElement.style,touch:!!("ontouchstart"in e||e.DocumentTouch&&t instanceof e.DocumentTouch)}}()),ts}function ss(e){return void 0===e&&(e={}),rs||(rs=function(e){let{userAgent:t}=void 0===e?{}:e;const r=ns(),i=$n(),n=i.navigator.platform,s=t||i.navigator.userAgent,a={ios:!1,android:!1},o=i.screen.width,l=i.screen.height,d=s.match(/(Android);?[\s\/]+([\d.]+)?/);let c=s.match(/(iPad).*OS\s([\d_]+)/);const u=s.match(/(iPod)(.*OS\s([\d_]+))?/),h=!c&&s.match(/(iPhone\sOS|iOS)\s([\d_]+)/),f="Win32"===n;let p="MacIntel"===n;return!c&&p&&r.touch&&["1024x1366","1366x1024","834x1194","1194x834","834x1112","1112x834","768x1024","1024x768","820x1180","1180x820","810x1080","1080x810"].indexOf(`${o}x${l}`)>=0&&(c=s.match(/(Version)\/([\d.]+)/),c||(c=[0,1,"13_0_0"]),p=!1),d&&!f&&(a.os="android",a.android=!0),(c||h||u)&&(a.os="ios",a.ios=!0),a}(e)),rs}function as(){return is||(is=function(){const e=$n(),t=ss();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}}()),is}var os={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 ls=(e,t,r)=>{t&&!e.classList.contains(r)?e.classList.add(r):!t&&e.classList.contains(r)&&e.classList.remove(r)};const ds=(e,t,r)=>{t&&!e.classList.contains(r)?e.classList.add(r):!t&&e.classList.contains(r)&&e.classList.remove(r)};const cs=(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()}},us=(e,t)=>{if(!e.slides[t])return;const r=e.slides[t].querySelector('[loading="lazy"]');r&&r.removeAttribute("loading")},hs=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)&&us(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)&&us(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)&&us(e,i)};var fs={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(Qn(i,"padding-left")||0,10)-parseInt(Qn(i,"padding-right")||0,10),r=r-parseInt(Qn(i,"padding-top")||0,10)-parseInt(Qn(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,d=l?e.virtual.slides.length:e.slides.length,c=Kn(n,`.${e.params.slideClass}, swiper-slide`),u=l?e.virtual.slides.length:c.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,c.forEach(e=>{a?e.style.marginLeft="":e.style.marginRight="",e.style.marginBottom="",e.style.marginTop=""}),r.centeredSlides&&r.cssMode&&(Vn(i,"--swiper-centered-offset-before",""),Vn(i,"--swiper-centered-offset-after",""));const T=r.grid&&r.grid.rows>1&&e.grid;let x;T?e.grid.initSlides(c):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,c[i]&&(n=c[i]),T&&e.grid.updateSlide(i,n,c),!c[i]||"none"!==Qn(n,"display")){if("auto"===r.slidesPerView){A&&(c[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()?Jn(n,"width"):Jn(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)),c[i]&&(c[i].style[e.getDirectionLabel("width")]=`${x}px`);c[i]&&(c[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");c.filter((e,t)=>!(r.cssMode&&!r.loop)||t!==c.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:c,snapGrid:h,slidesGrid:f,slidesSizesGrid:p}),r.centeredSlides&&r.cssMode&&!r.centeredSlidesBounds){Vn(i,"--swiper-centered-offset-before",-h[0]+"px"),Vn(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!==d&&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 d=l.swiperSlideOffset;r.cssMode&&r.centeredSlides&&(d-=i[0].swiperSlideOffset);const c=(a+(r.centeredSlides?t.minTranslate():0)-d)/(l.swiperSlideSize+o),u=(a-s[0]+(r.centeredSlides?t.minTranslate():0)-d)/(l.swiperSlideSize+o),h=-(a-d),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)),ls(l,m,r.slideVisibleClass),ls(l,p,r.slideFullyVisibleClass),l.progress=n?-c:c,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,d=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&&!d&&t.emit("reachEnd toEdge"),(l&&!s||d&&!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=>Kn(i,`.${r.slideClass}${e}, swiper-slide${e}`)[0];let l,d,c;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],c=t.filter(e=>e.column===n+1)[0],d=t.filter(e=>e.column===n-1)[0]):l=t[n];l&&(a||(c=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&&!c&&(c=t[0]),d=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===!d&&(d=t[t.length-1]))),t.forEach(e=>{ds(e,e===l,r.slideActiveClass),ds(e,e===c,r.slideNextClass),ds(e,e===d,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,d=e;const c=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===d&&(d=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,d);l=e+Math.floor((d-e)/n.slidesPerGroup)}if(l>=i.length&&(l=i.length-1),d===s&&!t.params.loop)return void(l!==o&&(t.snapIndex=l,t.emit("snapIndexChange")));if(d===s&&t.params.loop&&t.virtual&&t.params.virtual.enabled)return void(t.realIndex=c(d));const u=t.grid&&n.grid&&n.grid.rows>1;let h;if(t.virtual&&n.virtual.enabled&&n.loop)h=c(d);else if(u){const e=t.slides.filter(e=>e.column===d)[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[d]){const e=t.slides[d].getAttribute("data-swiper-slide-index");h=e?parseInt(e,10):d}else h=d;Object.assign(t,{previousSnapIndex:o,snapIndex:l,previousRealIndex:a,realIndex:h,previousIndex:s,activeIndex:d}),t.initialized&&hs(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 ps={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=zn(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,d=0;r.isHorizontal()?l=i?-e:e:d=e,n.roundLengths&&(l=Math.floor(l),d=Math.floor(d)),r.previousTranslate=r.translate,r.translate=r.isHorizontal()?l:d,n.cssMode?s[r.isHorizontal()?"scrollLeft":"scrollTop"]=r.isHorizontal()?-l:-d:n.virtualTranslate||(r.isHorizontal()?l-=r.cssOverflowAdjustment():d-=r.cssOverflowAdjustment(),s.style.transform=`translate3d(${l}px, ${d}px, 0px)`);const c=r.maxTranslate()-r.minTranslate();o=0===c?0:(e-r.minTranslate())/c,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(),d=s.maxTranslate();let c;if(c=i&&e>l?l:i&&e<d?d:e,s.updateProgress(c),a.cssMode){const e=s.isHorizontal();if(0===t)o[e?"scrollLeft":"scrollTop"]=-c;else{if(!s.support.smoothScroll)return Wn({swiper:s,targetPosition:-c,side:e?"left":"top"}),!0;o.scrollTo({[e?"left":"top"]:-c,behavior:"smooth"})}return!0}return 0===t?(s.setTransition(0),s.setTranslate(c),r&&(s.emit("beforeTransitionStart",t,n),s.emit("transitionEnd"))):(s.setTransition(t),s.setTranslate(c),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 ms(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 gs={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(),ms({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),ms({swiper:r,runCallbacks:e,direction:t,step:"End"}))}};var vs={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:d,previousIndex:c,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<d.length;e+=1){const t=-Math.floor(100*v),r=Math.floor(100*d[e]),i=Math.floor(100*d[e+1]);void 0!==d[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!==(c||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 Wn({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,d=i.virtual&&s.virtual.enabled;if(s.loop){if(a&&!d&&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:d}=i;if(!l||i.destroyed)return i;void 0===e&&(e=i.params.speed);const c=i.virtual&&n.virtual.enabled;if(n.loop){if(d&&!c&&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(Kn(r,`${a}[data-swiper-slide-index="${n}"]`)[0]),Bn(()=>{e.slideTo(s)})):e.slideTo(s):s>e.slides.length-i?(e.loopFix(),s=e.getSlideIndex(Kn(r,`${a}[data-swiper-slide-index="${n}"]`)[0]),Bn(()=>{e.slideTo(s)})):e.slideTo(s)}else e.slideTo(s)}};var ys={loopCreate:function(e){const t=this,{params:r,slidesEl:i}=t;if(!r.loop||t.virtual&&t.params.virtual.enabled)return;const n=()=>{Kn(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,d=e=>{for(let i=0;i<e;i+=1){const e=t.isElement?Xn("swiper-slide",[r.slideBlankClass]):Xn("div",[r.slideClass,r.slideBlankClass]);t.slidesEl.append(e)}};if(o){if(r.loopAddBlankSlides){d(a-t.slides.length%a),t.recalcSlides(),t.updateSlides()}else qn("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){d(r.grid.rows-t.slides.length%r.grid.rows),t.recalcSlides(),t.updateSlides()}else qn("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:d,allowSlidePrev:c,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=c,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;d.length<m+v?qn("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&&qn("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(d.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(d.length/f.grid.rows):d.length,L=(y?d[s].column:s)+(p&&void 0===n?-m/2+.5:0);if(L<v){x=Math.max(v-L,g);for(let e=0;e<v-L;e+=1){const t=e-Math.floor(e/k)*k;if(y){const e=k-t-1;for(let t=d.length-1;t>=0;t-=1)d[t].column===e&&b.push(t)}else b.push(k-t-1)}}else if(L+m>k-v){A=Math.max(L-(k-2*v),g);for(let e=0;e<A;e+=1){const t=e-Math.floor(e/k)*k;y?d.forEach((e,r)=>{e.column===t&&E.push(r)}):E.push(t)}}if(l.__preventObserver__=!0,requestAnimationFrame(()=>{l.__preventObserver__=!1}),T&&b.forEach(e=>{d[e].swiperLoopMoveDOM=!0,h.prepend(d[e]),d[e].swiperLoopMoveDOM=!1}),S&&E.forEach(e=>{d[e].swiperLoopMoveDOM=!0,h.append(d[e]),d[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=c,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 bs(e,t,r){const i=$n(),{params:n}=e,s=n.edgeSwipeDetection,a=n.edgeSwipeThreshold;return!s||!(r<=a||r>=i.innerWidth-a)||"prevent"===s&&(t.preventDefault(),!0)}function Es(e){const t=this,r=Nn();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 bs(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 d=!!s.noSwipingClass&&""!==s.noSwipingClass,c=i.composedPath?i.composedPath():i.path;d&&i.target&&i.target.shadowRoot&&c&&(l=c[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===Nn()||r===$n())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(!bs(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=Un(),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 ws(e){const t=Nn(),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,d=e;if(d.originalEvent&&(d=d.originalEvent),"pointermove"===d.type){if(null!==i.touchId)return;if(d.pointerId!==i.pointerId)return}if("touchmove"===d.type){if(l=[...d.changedTouches].filter(e=>e.identifier===i.touchId)[0],!l||l.identifier!==i.touchId)return}else l=d;if(!i.isTouched)return void(i.startMoving&&i.isScrolling&&r.emit("touchMoveOpposite",d));const c=l.pageX,u=l.pageY;if(d.preventedByNestedSwiper)return s.startX=c,void(s.startY=u);if(!r.allowTouchMove)return d.target.matches(i.focusableElements)||(r.allowClick=!1),void(i.isTouched&&(Object.assign(s,{startX:c,startY:u,currentX:c,currentY:u}),i.touchStartTime=Un()));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(c<s.startX&&r.translate<=r.maxTranslate()||c>s.startX&&r.translate>=r.minTranslate())return;if(t.activeElement&&t.activeElement.matches(i.focusableElements)&&t.activeElement!==d.target&&"mouse"!==d.pointerType&&t.activeElement.blur(),t.activeElement&&d.target===t.activeElement&&d.target.matches(i.focusableElements))return i.isMoved=!0,void(r.allowClick=!1);i.allowTouchCallbacks&&r.emit("touchMove",d),s.previousX=s.currentX,s.previousY=s.currentY,s.currentX=c,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",d),void 0===i.startMoving&&(s.currentX===s.startX&&s.currentY===s.startY||(i.startMoving=!0)),i.isScrolling||"touchmove"===d.type&&i.preventTouchMoveFromPointerMove)return void(i.isTouched=!1);if(!i.startMoving)return;r.allowClick=!1,!n.cssMode&&d.cancelable&&d.preventDefault(),n.touchMoveStopPropagation&&!n.nested&&d.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",d)}if((new Date).getTime(),i.isMoved&&i.allowThresholdMove&&g!==r.touchesDirection&&v&&y&&Math.abs(p)>=1)return Object.assign(s,{startX:c,startY:u,currentX:c,currentY:u,startTranslate:i.currentTranslate}),i.loopSwapReset=!0,void(i.startTranslate=i.currentTranslate);r.emit("sliderMove",d),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&&(d.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 Ss(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:d}=t;if(!d)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 c=Un(),u=c-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&&c-r.lastClickTime<300&&t.emit("doubleTap doubleClick",n)}if(r.lastClickTime=Un(),Bn(()=>{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 Ts(){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 xs(e){const t=this;t.enabled&&(t.allowClick||(t.params.preventClicks&&e.preventDefault(),t.params.preventClicksPropagation&&t.animating&&(e.stopPropagation(),e.stopImmediatePropagation())))}function As(){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 ks(e){const t=this;cs(t,e.target),t.params.cssMode||"auto"!==t.params.slidesPerView&&!t.params.autoHeight||t.update()}function Ls(){const e=this;e.documentTouchHandlerProceeded||(e.documentTouchHandlerProceeded=!0,e.params.touchReleaseOnEdges&&(e.el.style.touchAction="auto"))}const Is=(e,t)=>{const r=Nn(),{params:i,el:n,wrapperEl:s,device:a}=e,o=!!i.nested,l="on"===t?"addEventListener":"removeEventListener",d=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[d](a.ios||a.android?"resize orientationchange observerUpdate":"resize observerUpdate",Ts,!0):e[d]("observerUpdate",Ts,!0),n[l]("load",e.onLoad,{capture:!0}))};const Rs=(e,t)=>e.grid&&t.grid&&t.grid.rows>1;var Ps={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=Rs(e,i),d=Rs(e,o),c=e.params.grabCursor,u=o.grabCursor,h=i.enabled;l&&!d?(n.classList.remove(`${i.containerModifierClass}grid`,`${i.containerModifierClass}grid-column`),e.emitContainerClasses()):!l&&d&&(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()),c&&!u?e.unsetGrabCursor():!c&&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(),Hn(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=$n(),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 Cs={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 Ds(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}),Hn(t,r)):Hn(t,r)):Hn(t,r)}}const _s={eventsEmitter:os,update:fs,translate:ps,transition:gs,slide:vs,loop:ys,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=Es.bind(e),e.onTouchMove=ws.bind(e),e.onTouchEnd=Ss.bind(e),e.onDocumentTouchStart=Ls.bind(e),t.cssMode&&(e.onScroll=As.bind(e)),e.onClick=xs.bind(e),e.onLoad=ks.bind(e),Is(e,"on")},detachEvents:function(){Is(this,"off")}},breakpoints:Ps,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())}}},Os={};let Ms=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=Hn({},r),t&&!r.el&&(r.el=t);const a=Nn();if(r.el&&"string"==typeof r.el&&a.querySelectorAll(r.el).length>1){const t=[];return a.querySelectorAll(r.el).forEach(i=>{const n=Hn({},r,{el:i});t.push(new e(n))}),t}const o=this;o.__swiper__=!0,o.support=ns(),o.device=ss({userAgent:r.userAgent}),o.browser=as(),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:Ds(r,l),on:o.on.bind(o),once:o.once.bind(o),off:o.off.bind(o),emit:o.emit.bind(o)})});const d=Hn({},Cs,l);return o.params=Hn({},d,Os,r),o.originalParams=Hn({},o.params),o.passedParams=Hn({},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=Zn(Kn(t,`.${r.slideClass}, swiper-slide`)[0]);return Zn(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=Kn(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&&cs(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 Kn(r,i())[0]})();return!n&&t.params.createElements&&(n=Xn("div",t.params.wrapperClass),r.append(n),Kn(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"===Qn(r,"direction"),rtlTranslate:"horizontal"===t.params.direction&&("rtl"===r.dir.toLowerCase()||"rtl"===Qn(r,"direction")),wrongRTL:"-webkit-box"===Qn(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?cs(t,e):e.addEventListener("load",e=>{cs(t,e.target)})}),hs(t),t.initialized=!0,hs(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){Hn(Os,e)}static get extendedDefaults(){return Os}static get defaults(){return Cs}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(_s).forEach(e=>{Object.keys(_s[e]).forEach(t=>{Ms.prototype[t]=_s[e][t]})}),Ms.use([function(e){let{swiper:t,on:r,emit:i}=e;const n=$n();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=$n(),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 Ns=["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 Fs(e){return"object"==typeof e&&null!==e&&e.constructor&&"Object"===Object.prototype.toString.call(e).slice(8,-1)&&!e.__swiper__}function $s(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]:Fs(t[r])&&Fs(e[r])&&Object.keys(t[r]).length>0?t[r].__swiper__?e[r]=t[r]:$s(e[r],t[r]):e[r]=t[r]})}function Bs(e){return void 0===e&&(e={}),e.navigation&&void 0===e.navigation.nextEl&&void 0===e.navigation.prevEl}function Us(e){return void 0===e&&(e={}),e.pagination&&void 0===e.pagination.el}function zs(e){return void 0===e&&(e={}),e.scrollbar&&void 0===e.scrollbar.el}function Gs(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 js(e){return void 0===e&&(e=""),e?e.includes("swiper-wrapper")?e:`swiper-wrapper ${e}`:"swiper-wrapper"}function Hs(){return Hs=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},Hs.apply(this,arguments)}function Vs(e){return e.type&&e.type.displayName&&e.type.displayName.includes("SwiperSlide")}function Ws(e){const r=[];return t.Children.toArray(e).forEach(e=>{Vs(e)?r.push(e):e.props&&e.props.children&&Ws(e.props.children).forEach(e=>r.push(e))}),r}function Ys(e){const r=[],i={"container-start":[],"container-end":[],"wrapper-start":[],"wrapper-end":[]};return t.Children.toArray(e).forEach(e=>{if(Vs(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=Ws(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 Ks(e,t){return"undefined"==typeof window?i(e,t):o(e,t)}const qs=n(null),Xs=n(null),Qs=s(function(e,n){let{className:s,tag:o="div",wrapperTag:l="div",children:d,onSwiper:c,...u}=void 0===e?{}:e,h=!1;const[f,p]=a("swiper"),[m,g]=a(null),[v,y]=a(!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),L=r(null),{params:I,passedParams:R,rest:P,events:C}=function(e,t){void 0===e&&(e={}),void 0===t&&(t=!0);const r={on:{}},i={},n={};$s(r,Cs),r._emitClasses=!0,r.init=!1;const s={},a=Ns.map(e=>e.replace(/_/,"")),o=Object.assign({},e);return Object.keys(o).forEach(o=>{void 0!==e[o]&&(a.indexOf(o)>=0?Fs(e[o])?(r[o]={},n[o]={},$s(r[o],e[o]),$s(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:_}=Ys(d),O=()=>{y(!v)};Object.assign(I.on,{_containerClasses(e,t){p(t)}});const M=()=>{Object.assign(I.on,C),h=!0;const e={...I};if(delete e.wrapperClass,w.current=new Ms(e),w.current.virtual&&w.current.params.virtual.enabled){w.current.virtual.slides=D;const e={cache:!1,slides:D,renderExternal:g,renderExternalUpdate:!1};$s(w.current.params.virtual,e),$s(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)}),Ks(()=>{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;Bs(t)&&i&&n&&(o.params.navigation.nextEl=i,o.originalParams.navigation.nextEl=i,o.params.navigation.prevEl=n,o.originalParams.navigation.prevEl=n),Us(t)&&s&&(o.params.pagination.el=s,o.originalParams.pagination.el=s),zs(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:L.current,swiper:w.current},I),c&&!w.current.destroyed&&c(w.current),()=>{w.current&&!w.current.destroyed&&w.current.destroy(!0,!1)}},[]),Ks(()=>{!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 Ns.filter(e=>"_"===e[0]).map(e=>e.replace(/_/,"")).forEach(r=>{if(r in e&&r in t)if(Fs(e[r])&&Fs(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 d=n.filter(e=>"children"!==e&&"direction"!==e&&"wrapperClass"!==e),{params:c,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&&c.thumbs&&(!c.thumbs.swiper||c.thumbs.swiper.destroyed)&&(g=!0),n.includes("controller")&&i.controller&&i.controller.control&&c.controller&&!c.controller.control&&(v=!0),n.includes("pagination")&&i.pagination&&(i.pagination.el||l)&&(c.pagination||!1===c.pagination)&&u&&!u.el&&(y=!0),n.includes("scrollbar")&&i.scrollbar&&(i.scrollbar.el||o)&&(c.scrollbar||!1===c.scrollbar)&&f&&!f.el&&(b=!0),n.includes("navigation")&&i.navigation&&(i.navigation.prevEl||a)&&(i.navigation.nextEl||s)&&(c.navigation||!1===c.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()),c[e].prevEl=void 0,c[e].nextEl=void 0,t[e].prevEl=void 0,t[e].nextEl=void 0):(t.isElement&&t[e].el.remove(),c[e].el=void 0,t[e].el=void 0))};n.includes("loop")&&t.isElement&&(c.loop&&!i.loop?w=!0:!c.loop&&i.loop?S=!0:T=!0),d.forEach(e=>{if(Fs(c[e])&&Fs(i[e]))Object.assign(c[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?c[e]=i[e]:!1===t&&x(e)}}),d.includes("controller")&&!v&&t.controller&&t.controller.control&&c.controller&&c.controller.control&&(t.controller.control=c.controller.control),n.includes("children")&&r&&p&&c.virtual.enabled?(p.slides=r,p.update(!0)):n.includes("virtual")&&p&&c.virtual.enabled&&(r&&(p.slides=r),p.update(!0)),n.includes("children")&&r&&c.loop&&(T=!0),g&&m.init()&&m.update(!0);v&&(t.controller.control=c.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&&(c.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&&(c.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&&(c.navigation.nextEl=s),a&&(c.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:L.current,paginationEl:k.current}),()=>{C&&w.current&&Object.keys(C).forEach(e=>{w.current.off(e,C[e])})}}),Ks(()=>{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,Hs({ref:E,className:Gs(`${f}${s?` ${s}`:""}`)},P),t.createElement(Xs.Provider,{value:w.current},_["container-start"],t.createElement(l,{className:js(I.wrapperClass)},_["wrapper-start"],I.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,d=e.params.loop?2*r.length:r.length,c=[];for(let e=l;e<d;e+=1)e>=a&&e<=o&&c.push(r[n(e)]);return c.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"]),Bs(I)&&t.createElement(t.Fragment,null,t.createElement("div",{ref:A,className:"swiper-button-prev"}),t.createElement("div",{ref:x,className:"swiper-button-next"})),zs(I)&&t.createElement("div",{ref:L,className:"swiper-scrollbar"}),Us(I)&&t.createElement("div",{ref:k,className:"swiper-pagination"}),_["container-end"]))});Qs.displayName="Swiper";const Zs=s(function(e,i){let{tag:n="div",children:s,className:o="",swiper:l,zoom:d,lazy:c,virtualIndex:u,swiperSlideIndex:h,...f}=void 0===e?{}:e;const p=r(null),[m,g]=a("swiper-slide"),[v,y]=a(!1);function b(e,t,r){t===p.current&&g(r)}Ks(()=>{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")}}),Ks(()=>{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 s?s(E):s;return t.createElement(n,Hs({ref:p,className:Gs(`${m}${o?` ${o}`:""}`),"data-swiper-slide-index":u,onLoad:()=>{y(!0)}},f),d&&t.createElement(qs.Provider,{value:E},t.createElement("div",{className:"swiper-zoom-container","data-swiper-zoom":"number"==typeof d?d:void 0},w(),c&&!v&&t.createElement("div",{className:"swiper-lazy-preloader"}))),!d&&t.createElement(qs.Provider,{value:E},w(),c&&!v&&t.createElement("div",{className:"swiper-lazy-preloader"})))});function Js(e){let{swiper:t,extendParams:r,on:i,emit:n}=e;const s=$n();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=Un();const d=[];function c(){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&&Un()-l<t.params.mousewheel.thresholdTime)&&(e.delta>=6&&Un()-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 c=l&&l.contains(r.target);if(!t.mouseEntered&&!c&&!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:Un(),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 c=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(),(!c&&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,d.length>=15&&d.shift();const r=d.length?d[d.length-1]:void 0,i=d[0];if(d.push(e),r&&(e.delta>r.delta||e.direction!==r.direction))d.splice(0);else if(d.length>=15&&e.time-i.time<500&&i.delta-e.delta>=1&&e.delta<=6){const r=u>0?.8:.2;o=e,d.splice(0),a=Bn(()=>{!t.destroyed&&t.params&&t.slideToClosest(t.params.speed,!0,void 0,r)},0)}a||(a=Bn(()=>{if(t.destroyed||!t.params)return;o=e,d.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:Un(),delta:Math.abs(u),direction:Math.sign(u),raw:e};d.length>=2&&d.shift();const i=d.length?d[d.length-1]:void 0;if(d.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",c),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 ea(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=es(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 d(e){e.preventDefault(),(!t.isEnd||t.params.loop||t.params.rewind)&&(t.slideNext(),n("navigationNext"))}function c(){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=Kn(e.el,`.${i[n]}`)[0];s||(s=Xn("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=es(r),i=es(i);const n=(r,i)=>{r&&r.addEventListener("click","next"===i?d: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=es(e),r=es(r);const i=(e,r)=>{e.removeEventListener("click","next"===r?d: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():(c(),o())}),i("toEdge fromEdge lock unlock",()=>{o()}),i("destroy",()=>{u()}),i("enable disable",()=>{let{nextEl:e,prevEl:r}=t.navigation;e=es(e),r=es(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=es(i),s=es(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(" ")),c(),o()},disable:h,update:o,init:c,destroy:u})}function ta(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,d,c,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?d=!0:d&&(v=l,d=!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,d=()=>{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(()=>{d()},n)):requestAnimationFrame(()=>{d()}),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=Nn();"hidden"===e.visibilityState&&(p=!0,x(!0)),"visible"===e.visibilityState&&A()},L=e=>{"mouse"===e.pointerType&&(p=!0,m=!0,i.animating||i.autoplay.paused||x(!0))},I=e=>{"mouse"===e.pointerType&&(m=!1,i.autoplay.paused&&A())};s("init",()=>{i.params.autoplay.enabled&&(i.params.autoplay.pauseOnMouseEnter&&(i.el.addEventListener("pointerenter",L),i.el.addEventListener("pointerleave",I)),Nn().addEventListener("visibilitychange",k),S())}),s("destroy",()=>{i.el&&"string"!=typeof i.el&&(i.el.removeEventListener("pointerenter",L),i.el.removeEventListener("pointerleave",I)),Nn().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():(c=!0,u=!1,p=!1,h=setTimeout(()=>{p=!0,u=!0,x(!0)},200)))}),s("touchEnd",()=>{if(!i.destroyed&&i.autoplay.running&&c){if(clearTimeout(h),clearTimeout(t),i.params.autoplay.disableOnInteraction)return u=!1,void(c=!1);u&&i.params.cssMode&&A(),u=!1,c=!1}}),s("slideChange",()=>{!i.destroyed&&i.autoplay.running&&(f=!0)}),Object.assign(i.autoplay,{start:S,stop:T,pause:x,resume:A})}function ra(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,d=l(),{rows:c,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*c)),i=e-c*o*r,s=0===r?o:Math.min(Math.ceil((h-r*c*o)/c),o);m=Math.floor(i/s),p=i-m*s+r*o,f=p+m*t/c,n.style.order=f}else"column"===u?(p=Math.floor(e/c),m=e-p*c,(p>i||p===i&&m===c-1)&&(m+=1,m>=c&&(m=0,p+=1))):(m=Math.floor(e/r),p=e-m*r);n.row=m,n.column=p,n.style.height=`calc((100% - ${(c-1)*d}px) / ${c})`,n.style[s.getDirectionLabel("margin-top")]=0!==m?d&&`${d}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 ia(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 na(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 sa(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 d=[];for(let t=o-1;t>=e;t-=1){const e=r.slides[t];e.remove(),d.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<d.length;e+=1)s.append(d[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 aa(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 oa(){const e=this,t=[];for(let r=0;r<e.slides.length;r+=1)t.push(r);e.removeSlide(t)}function la(e){let{swiper:t}=e;Object.assign(t,{appendSlide:ia.bind(t),prependSlide:na.bind(t),addSlide:sa.bind(t),removeSlide:aa.bind(t),removeAllSlides:oa.bind(t)})}function da(e,t){const r=Yn(t);return r!==t&&(r.style.backfaceVisibility="hidden",r.style["-webkit-backface-visibility"]="hidden"),r}function ca(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 ua(e,t,r){const i=`swiper-slide-shadow swiper-slide-shadow-${e}`,n=Yn(t);let s=n.querySelector(`.${i.split(" ").join(".")}`);return s||(s=Xn("div",i.split(" ")),n.append(s)),s}function ha(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:d}=e;let c;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(!d||!d().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||(c=!0),requestAnimationFrame(()=>{c&&r.slides&&r.slides.length&&(n(),c=!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 d=e[l],c=d.progress,u=Math.min(Math.max(c,-4),4);let h=d.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=d.querySelector(".swiper-slide-shadow");e||(e=ua("cards",d)),e&&(e.style.opacity=Math.min(Math.max((Math.abs(u)-.5)/.5,0),1))}d.style.zIndex=-Math.abs(Math.round(c))+e.length;da(0,d).style.transform=T}},setTransition:e=>{const r=t.slides.map(e=>Yn(e));r.forEach(t=>{t.style.transitionDuration=`${e}ms`,t.querySelectorAll(".swiper-slide-shadow").forEach(t=>{t.style.transitionDuration=`${e}ms`})}),ca({swiper:t,duration:e,transformElements:r})},perspective:()=>!0,overwriteParams:()=>({watchSlidesProgress:!0,virtualTranslate:!t.params.cssMode})})}Zs.displayName="SwiperSlide";const fa=({product:e})=>{const[r,i]=a(!1);return t.createElement("a",{href:e.linkPath,target:"_blank"},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&&!r?t.createElement(Gr,{product:e,onError:()=>i(!0)}):t.createElement(zr,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"},xt(e.sellingPrice),"원")))))},pa=({products:e})=>{const i=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=i.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(Ir,{size:32,strokeWidth:1})),t.createElement("div",{className:"w-full px-10"},t.createElement(Qs,{modules:[ea],onSwiper:e=>{i.current=e},slidesPerView:3,navigation:{prevEl:".slide__prev",nextEl:".slide__next"},spaceBetween:0},e.map(e=>t.createElement(Zs,{key:e.productId},t.createElement("div",{className:"h-full px-3 md:px-4 lg:px-5"},t.createElement(fa,{product:e})))))),e.length>3&&t.createElement("button",{"aria-label":"next",onClick:()=>{var e;null===(e=i.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(Rr,{size:32,strokeWidth:1})))},ma=e=>{const{player:r,shortform:i}=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"},r),t.createElement("div",{className:"flex h-full w-full min-w-44 max-w-[800px] items-center overflow-hidden text-sm"},t.createElement(pa,{products:i.productsInfo})))},ga=({products:e})=>{const n=r(null),s=r(null),[o,l]=a(4);return i(()=>{const e=s.current;if(!e)return;const t=()=>{const t=e.clientHeight;if(!t)return;const r=Math.max(1,Math.floor((t+12)/112));l(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>o&&t.createElement(Pr,{size:50,strokeWidth:1,className:"slide__prev shrink-0 cursor-pointer text-zinc-500"}),t.createElement("div",{ref:s,className:"min-h-0 w-full max-w-full flex-1"},t.createElement(Qs,{modules:[Js,ea],mousewheel:!0,onSwiper:e=>{n.current=e},spaceBetween:12,className:"h-full min-h-0 w-full max-w-full",slidesPerView:o,direction:"vertical",navigation:{prevEl:".slide__prev",nextEl:".slide__next"}},e.map(e=>t.createElement(Zs,{key:e.productId},t.createElement("div",{className:"h-full items-center flex"},t.createElement(jr,{product:e})))))),e.length>o&&t.createElement(Lr,{size:50,strokeWidth:1,className:"slide__next shrink-0 cursor-pointer text-zinc-500"}))},va=e=>{const{playerSettings:r,shortform:{productsInfo:i},player:n}=e;return t.createElement("div",{className:"flex h-full w-full gap-5"},t.createElement("div",{className:" h-full "},n),t.createElement("div",{className:"max-w-[800px] overflow-hidden"},t.createElement(ga,{products:i})))},ya=({products:e})=>{const i=r(null),n=e.length>6;return t.createElement("div",{className:"relative flex h-full w-full max-w-[830px] items-center text-sm"},n&&t.createElement("button",{"aria-label":"prev",onClick:()=>{var e;null===(e=i.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(Ir,{size:50,strokeWidth:1})),t.createElement("div",{className:"w-full px-14"},t.createElement(Qs,{onSwiper:e=>{i.current=e},slidesPerView:3,spaceBetween:20,modules:[ra],grid:{rows:2,fill:"row"}},e.map(e=>t.createElement(Zs,{key:e.productId},t.createElement(fa,{product:e}))))),n&&t.createElement("button",{"aria-label":"next",onClick:()=>{var e;null===(e=i.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(Rr,{size:50,strokeWidth:1})))},ba=e=>{const{player:r,shortform:{productsInfo:i}}=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"},r),t.createElement("div",{className:"flex-[2] w-full h-full overflow-hidden"},t.createElement(ya,{products:i})))},Ea="cursor-pointer text-zinc-500",wa=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(Pr,{size:44,strokeWidth:1,className:Ea,onClick:()=>{var e;null===(e=a.current)||void 0===e||e.swiper.slidePrev()}}),t.createElement(Lr,{size:44,strokeWidth:1,className:Ea,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(Qs,{modules:[Js,la],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(Zs,{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(L,{file:Tt(n.media.objectId)})),t.createElement("img",{src:Rt(e.thumbPath),alt:e.title,className:"rounded-xl w-full h-full bg-black "+(e.media.width>e.media.height?"object-contain":"object-cover")})))))))};var Sa;!function(e){e.latest="",e.views="pageView",e.likes="like"}(Sa||(Sa={}));let Ta=0;const xa=e=>x(void 0,void 0,void 0,function*(){const{PLAYER_BACK_BASE_URL:t}=gt(),{contentId:r,uuid:i,type:n,userId:s}=e;try{if(3===Ta)return;const e=`${t}/statistics/play`,a=Object.assign({contentId:r,uuid:i,type:n,date:At(),userId:+s,playtime:0,isLive:!1},"shorts"===n&&{isFinished:!1,playedOver5Sec:!1});yield fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})}catch(e){console.error(`Error in statisticsApi.join - contentId: ${r}`),Pt(e),Ta++}}),Aa=e=>{const{PLAYER_BACK_BASE_URL:t}=gt(),{contentId:r,uuid:i,type:n,isFinished:s,playtime:a,userId:o}=e,l=Object.assign({contentId:r,uuid:i,playtime:a,type:n,date:At(),userId:+o,isLive:!1},"shorts"===n&&{isFinished:s,playedOver5Sec:Number(a)>5});fetch(`${t}/statistics/play`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l),keepalive:!0})},ka=e=>x(void 0,void 0,void 0,function*(){const{PLAYER_BACK_BASE_URL:t}=gt(),{contentProductId:r}=e;try{yield fetch(`${t}/statistics/products/${r}/clicks`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Object.assign({date:At()},e))})}catch(e){console.error(`Error in statisticsApi.productClick - contentProductId: ${r}`),Pt(e)}}),La=e=>x(void 0,void 0,void 0,function*(){const{STATISTICS_BASE_URL:t}=gt();try{return(yield(yield fetch(`${t}/${e}/likes`)).json()).result||0}catch(t){return console.error(`Error in statisticsApi.getLike - contentId: ${e}`),Pt(t),0}}),Ia=e=>x(void 0,void 0,void 0,function*(){const{PLAYER_BACK_BASE_URL:t}=gt();try{yield fetch(`${t}/statistics/like`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({contentId:e,isLive:!1,isFirst:!1})})}catch(t){console.error(`Error in statisticsApi.getLike - contentId: ${e}`),Pt(t)}}),Ra=e=>x(void 0,[e],void 0,function*({collectionId:e,nextKey:t,size:r=5}){const{PLAYER_BACK_BASE_URL:i}=gt();try{const n=new URLSearchParams;-1!==r&&n.set("size",String(r)),t&&n.set("nextKey",t);const s=yield fetch(`${i}/commerce/collection/${e}?${n.toString()}`);return s.ok?yield s.json():null}catch(e){return Pt(e),null}}),Pa=(e,...t)=>x(void 0,[e,...t],void 0,function*(e,t=!1){const{API_BASE_URL:r,PLAYER_BACK_BASE_URL:i}=gt();if(t)try{const t=(yield(yield fetch(`${r}/shorts/player/${e}`)).json()).result;if(!t.media)return null;t.file=`${r}/direct/${t.media.objectId}`;const{player:{viewPlayer:{width:i,height:n}}}=t;return Object.assign(Object.assign(Object.assign(Object.assign({layout:t.player.layout},t.player.shoppingPlayer),{aspectRatio:Ct(i,n)}),t),{uuid:kt()})}catch(e){return Pt(e),null}try{const t=yield fetch(`${i}/commerce/short-form/${e}`),r=yield t.json();return r.shortsId?r:null}catch(e){return Pt(e),null}}),Ca=(e,t,r,i,n)=>x(void 0,void 0,void 0,function*(){const{API_BASE_URL:s}=gt();try{const a=yield fetch(`${s}/live/${e}/list?size=${r||6}&status=${t}&includeMainLive=${i}${n&&Sa[n]?`&sortBy=${Sa[n]}`:""}`);if(!a.ok)return console.error("Error in getLiveWidgetContents "),null;const o=(yield a.json()).result;if(o.content){const{mainLive:e,content:t}=o;return[...e?[e]:[],...t]}return o}catch(e){return console.error("Error in getLiveWidgetContents: ",e),null}}),Da=e=>{let t;const r=new Set,i=(e,i)=>{const n="function"==typeof e?e(t):e;if(!Object.is(n,t)){const e=t;t=(null!=i?i:"object"!=typeof n||null===n)?n:Object.assign({},t,n),r.forEach(r=>r(t,e))}},n=()=>t,s={setState:i,getState:n,getInitialState:()=>a,subscribe:e=>(r.add(e),()=>r.delete(e))},a=t=e(i,n,s);return s},_a=e=>e?Da(e):Da,Oa=e=>e;function Ma(e,r=Oa){const i=t.useSyncExternalStore(e.subscribe,t.useCallback(()=>r(e.getState()),[e,r]),t.useCallback(()=>r(e.getInitialState()),[e,r]));return t.useDebugValue(i),i}const Na=e=>{const t=_a(e),r=e=>Ma(t,e);return Object.assign(r,t),r},Fa=e=>e?Na(e):Na,$a=Fa(e=>({priceText:"",isPreview:!1,memberOnly:!1,isMemberLoggedIn:!1,setPriceText:t=>e({priceText:t}),setIsPreview:t=>e({isPreview:t}),setMemberOnly:t=>e({memberOnly:t}),setIsMemberLoggedIn:t=>e({isMemberLoggedIn:t})})),Ba=()=>t.createElement("div",{className:"inline-block absolute pointer-events-none top-0 z-10 animate-float w-[24px] h-[24px]"},t.createElement(_r,{className:"fill-red-500 text-transparent w-[24px] h-[24px]"})),Ua=({shortsId:e})=>{const{isPreview:r}=$a(),[n,s]=a(r?123:0),[o,l]=a([]);i(()=>{r||x(void 0,void 0,void 0,function*(){try{const t=yield La(e);s(t)}catch(e){return console.error(`Error in statistics getLikeInLive: ${e.toString()}`),0}})},[r,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();l(t=>[...t,e]),setTimeout(()=>{l(t=>t.filter(t=>t!==e))},2e3)})(),s(e=>e+1),r||(yield x(void 0,void 0,void 0,function*(){yield Ia(e)}))}),className:"z-[5] cursor-pointer"},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"}))),o.map(e=>t.createElement(Ba,{key:e})),t.createElement("span",{className:"break-keep text-[10px]"},xt(n)))};var za,Ga,ja={},Ha={exports:{}},Va=Ha.exports;function Wa(){return za||(za=1,e=Ha,t=Ha.exports,function(r,i){var n="function",s="undefined",a="object",o="string",l="major",d="model",c="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",L="Firefox",I="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,d,c,u=0;u<t.length&&!d;){var h=t[u],f=t[u+1];for(r=s=0;r<h.length&&!d&&h[r];)if(d=h[r++].exec(e))for(o=0;o<f.length;o++)c=d[++s],typeof(l=f[o])===a&&l.length>0?2===l.length?typeof l[1]==n?this[l[0]]=l[1].call(this,c):this[l[0]]=l[1]:3===l.length?typeof l[1]!==n||l[1].exec&&l[1].test?this[l[0]]=c?c.replace(l[1],l[2]):i:this[l[0]]=c?l[1].call(this,c,l[2]):i:4===l.length&&(this[l[0]]=c?l[3].call(this,c.replace(l[1],l[2])):i):this[l]=c||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,[c,"Chrome"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[f,[c,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[c,f],[/opios[\/ ]+([\w\.]+)/i],[f,[c,_+" Mini"]],[/\bop(?:rg)?x\/([\w\.]+)/i],[f,[c,_+" GX"]],[/\bopr\/([\w\.]+)/i],[f,[c,_]],[/\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[\/ ]?([\w\.]+)/i],[f,[c,"Baidu"]],[/\b(?:mxbrowser|mxios|myie2)\/?([-\w\.]*)\b/i],[f,[c,"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],[c,f],[/quark(?:pc)?\/([-\w\.]+)/i],[f,[c,"Quark"]],[/\bddg\/([\w\.]+)/i],[f,[c,"DuckDuckGo"]],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[f,[c,"UC"+A]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i,/micromessenger\/([\w\.]+)/i],[f,[c,"WeChat"]],[/konqueror\/([\w\.]+)/i],[f,[c,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[f,[c,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[f,[c,"Yandex"]],[/slbrowser\/([\w\.]+)/i],[f,[c,"Smart Lenovo "+A]],[/(avast|avg)\/([\w\.]+)/i],[[c,/(.+)/,"$1 Secure "+A],f],[/\bfocus\/([\w\.]+)/i],[f,[c,L+" Focus"]],[/\bopt\/([\w\.]+)/i],[f,[c,_+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[f,[c,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[f,[c,"Dolphin"]],[/coast\/([\w\.]+)/i],[f,[c,_+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[f,[c,"MIUI"+G]],[/fxios\/([\w\.-]+)/i],[f,[c,L]],[/\bqihoobrowser\/?([\w\.]*)/i],[f,[c,"360"]],[/\b(qq)\/([\w\.]+)/i],[[c,/(.+)/,"$1Browser"],f],[/(oculus|sailfish|huawei|vivo|pico)browser\/([\w\.]+)/i],[[c,/(.+)/,"$1"+G],f],[/samsungbrowser\/([\w\.]+)/i],[f,[c,O+" Internet"]],[/metasr[\/ ]?([\d\.]+)/i],[f,[c,"Sogou Explorer"]],[/(sogou)mo\w+\/([\d\.]+)/i],[[c,"Sogou Mobile"],f],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|2345(?=browser|chrome|explorer))\w*[\/ ]?v?([\w\.]+)/i],[c,f],[/(lbbrowser|rekonq)/i,/\[(linkedin)app\]/i],[c],[/ome\/([\w\.]+) \w* ?(iron) saf/i,/ome\/([\w\.]+).+qihu (360)[es]e/i],[f,c],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[c,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],[c,f],[/\bgsa\/([\w\.]+) .*safari\//i],[f,[c,"GSA"]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[f,[c,"TikTok"]],[/headlesschrome(?:\/([\w\.]+)| )/i],[f,[c,k+" Headless"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[c,k+" WebView"],f],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[f,[c,"Android "+A]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[c,f],[/version\/([\w\.\,]+) .*mobile\/\w+ (safari)/i],[f,[c,"Mobile Safari"]],[/version\/([\w(\.|\,)]+) .*(mobile ?safari|safari)/i],[f,c],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[c,[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],[c,f],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[c,"Netscape"],f],[/(wolvic|librewolf)\/([\w\.]+)/i],[c,f],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[f,[c,L+" 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],[c,[f,/_/g,"."]],[/(cobalt)\/([\w\.]+)/i],[c,[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],[d,[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],[d,[h,O],[u,g]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i],[d,[h,S],[u,g]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[d,[h,S],[u,v]],[/(macintosh);/i],[d,[h,S]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[d,[h,M],[u,g]],[/(?:honor)([-\w ]+)[;\)]/i],[d,[h,"Honor"],[u,g]],[/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i],[d,[h,R],[u,v]],[/(?:huawei)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[d,[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],[[d,/_/g," "],[h,F],[u,g]],[/oid[^\)]+; (2\d{4}(283|rpbf)[cgl])( bui|\))/i,/\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i],[[d,/_/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],[d,[h,"OPPO"],[u,g]],[/\b(opd2\d{3}a?) bui/i],[d,[h,"OPPO"],[u,v]],[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[d,[h,"Vivo"],[u,g]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i],[d,[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],[d,[h,D],[u,g]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[d,[h,D],[u,v]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[d,[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],[d,[h,P],[u,g]],[/(ideatab[-\w ]+)/i,/lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i],[d,[h,"Lenovo"],[u,v]],[/(?:maemo|nokia).*(n900|lumia \d+)/i,/nokia[-_ ]?([-\w\.]*)/i],[[d,/_/g," "],[h,"Nokia"],[u,g]],[/(pixel c)\b/i],[d,[h,I],[u,v]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[d,[h,I],[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],[d,[h,N],[u,g]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[d,"Xperia Tablet"],[h,N],[u,v]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[d,[h,"OnePlus"],[u,g]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo(?!bc)\w\w)( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[d,[h,w],[u,v]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[d,/(.+)/g,"Fire Phone $1"],[h,w],[u,g]],[/(playbook);[-\w\),; ]+(rim)/i],[d,h,[u,v]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[d,[h,x],[u,g]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[d,[h,T],[u,v]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[d,[h,T],[u,g]],[/(nexus 9)/i],[d,[h,"HTC"],[u,v]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[h,[d,/_/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],[d,[h,"TCL"],[u,v]],[/(itel) ((\w+))/i],[[h,V],d,[u,K,{tablet:["p10001l","w7001"],"*":"mobile"}]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[d,[h,"Acer"],[u,v]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[d,[h,"Meizu"],[u,g]],[/; ((?:power )?armor(?:[\w ]{0,8}))(?: bui|\))/i],[d,[h,"Ulefone"],[u,g]],[/; (energy ?\w+)(?: bui|\))/i,/; energizer ([\w ]+)(?: bui|\))/i],[d,[h,"Energizer"],[u,g]],[/; cat (b35);/i,/; (b15q?|s22 flip|s48c|s62 pro)(?: bui|\))/i],[d,[h,"Cat"],[u,g]],[/((?:new )?andromax[\w- ]+)(?: bui|\))/i],[d,[h,"Smartfren"],[u,g]],[/droid.+; (a(?:015|06[35]|142p?))/i],[d,[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,d,[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,d,[u,v]],[/(surface duo)/i],[d,[h,C],[u,v]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[d,[h,"Fairphone"],[u,g]],[/(u304aa)/i],[d,[h,"AT&T"],[u,g]],[/\bsie-(\w*)/i],[d,[h,"Siemens"],[u,g]],[/\b(rct\w+) b/i],[d,[h,"RCA"],[u,v]],[/\b(venue[\d ]{2,7}) b/i],[d,[h,"Dell"],[u,v]],[/\b(q(?:mv|ta)\w+) b/i],[d,[h,"Verizon"],[u,v]],[/\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i],[d,[h,"Barnes & Noble"],[u,v]],[/\b(tm\d{3}\w+) b/i],[d,[h,"NuVision"],[u,v]],[/\b(k88) b/i],[d,[h,"ZTE"],[u,v]],[/\b(nx\d{3}j) b/i],[d,[h,"ZTE"],[u,g]],[/\b(gen\d{3}) b.+49h/i],[d,[h,"Swiss"],[u,g]],[/\b(zur\d{3}) b/i],[d,[h,"Swiss"],[u,v]],[/\b((zeki)?tb.*\b) b/i],[d,[h,"Zeki"],[u,v]],[/\b([yr]\d{2}) b/i,/\b(dragon[- ]+touch |dt)(\w{5}) b/i],[[h,"Dragon Touch"],d,[u,v]],[/\b(ns-?\w{0,9}) b/i],[d,[h,"Insignia"],[u,v]],[/\b((nxa|next)-?\w{0,9}) b/i],[d,[h,"NextBook"],[u,v]],[/\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i],[[h,"Voice"],d,[u,g]],[/\b(lvtel\-)?(v1[12]) b/i],[[h,"LvTel"],d,[u,g]],[/\b(ph-1) /i],[d,[h,"Essential"],[u,g]],[/\b(v(100md|700na|7011|917g).*\b) b/i],[d,[h,"Envizen"],[u,v]],[/\b(trio[-\w\. ]+) b/i],[d,[h,"MachSpeed"],[u,v]],[/\btu_(1491) b/i],[d,[h,"Rotor"],[u,v]],[/(shield[\w ]+) b/i],[d,[h,"Nvidia"],[u,v]],[/(sprint) (\w+)/i],[h,d,[u,g]],[/(kin\.[onetw]{3})/i],[[d,/\./g," "],[h,C],[u,g]],[/droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[d,[h,$],[u,v]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[d,[h,$],[u,g]],[/smart-tv.+(samsung)/i],[h,[u,y]],[/hbbtv.+maple;(\d+)/i],[[d,/^/,"SmartTV"],[h,O],[u,y]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[h,P],[u,y]],[/(apple) ?tv/i],[h,[d,S+" TV"],[u,y]],[/crkey/i],[[d,k+"cast"],[h,I],[u,y]],[/droid.+aft(\w+)( bui|\))/i],[d,[h,w],[u,y]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[d,[h,M],[u,y]],[/(bravia[\w ]+)( bui|\))/i],[d,[h,N],[u,y]],[/(mitv-\w{5}) bui/i],[d,[h,F],[u,y]],[/Hbbtv.*(technisat) (.*);/i],[h,d,[u,y]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[h,W],[d,W],[u,y]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[u,y]],[/(ouya)/i,/(nintendo) ([wids3utch]+)/i],[h,d,[u,m]],[/droid.+; (shield) bui/i],[d,[h,"Nvidia"],[u,m]],[/(playstation [345portablevi]+)/i],[d,[h,N],[u,m]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[d,[h,C],[u,m]],[/\b(sm-[lr]\d\d[05][fnuw]?s?)\b/i],[d,[h,O],[u,b]],[/((pebble))app/i],[h,d,[u,b]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[d,[h,S],[u,b]],[/droid.+; (glass) \d/i],[d,[h,I],[u,b]],[/droid.+; (wt63?0{2,3})\)/i],[d,[h,$],[u,b]],[/droid.+; (glass) \d/i],[d,[h,I],[u,b]],[/(pico) (4|neo3(?: link|pro)?)/i],[h,d,[u,b]],[/; (quest( \d| pro)?)/i],[d,[h,B],[u,b]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[h,[u,E]],[/(aeobc)\b/i],[d,[h,w],[u,E]],[/droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew).+? mobile safari/i],[d,[u,g]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i],[d,[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],[d,[h,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[f,[c,"EdgeHTML"]],[/(arkweb)\/([\w\.]+)/i],[c,f],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[f,[c,"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],[c,f],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[f,c]],os:[[/microsoft (windows) (vista|xp)/i],[c,f],[/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i],[c,[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],[c,"Windows"]],[/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i,/(?:ios;fbsv\/|iphone.+ios[\/ ])([\d\.]+)/i,/cfnetwork\/.+darwin/i],[[f,/_/g,"."],[c,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[c,z],[f,/_/g,"."]],[/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i],[f,c],[/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish|openharmony)[-\/ ]?([\w\.]*)/i,/(blackberry)\w*\/([\w\.]*)/i,/(tizen|kaios)[\/ ]([\w\.]+)/i,/\((series40);/i],[c,f],[/\(bb(10);/i],[f,[c,x]],[/(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i],[f,[c,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[f,[c,L+" OS"]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[f,[c,"webOS"]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[f,[c,"watchOS"]],[/crkey\/([\d\.]+)/i],[f,[c,k+"cast"]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[c,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],[c,f],[/(sunos) ?([\w\.\d]*)/i],[[c,"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],[c,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[c]=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[c]="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[d]=i,e[u]=i,Y.call(e,y,E.device),w&&!e[u]&&b&&b.mobile&&(e[u]=g),w&&"Macintosh"==e[d]&&m&&typeof m.standalone!==s&&m.maxTouchPoints&&m.maxTouchPoints>2&&(e[d]="iPad",e[u]=v),e},this.getEngine=function(){var e={};return e[c]=i,e[f]=i,Y.call(e,y,E.engine),e},this.getOS=function(){var e={};return e[c]=i,e[f]=i,Y.call(e,y,E.os),w&&!e[c]&&b&&b.platform&&"Unknown"!=b.platform&&(e[c]=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([c,f,l]),Q.CPU=j([p]),Q.DEVICE=j([d,h,u,m,g,y,v,b,E]),Q.ENGINE=Q.OS=j([c,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:Va)),Ha.exports;var e,t}var Ya=function(){if(Ga)return ja;Ga=1,Object.defineProperty(ja,"__esModule",{value:!0});var e,r=t,i=(e=r)&&"object"==typeof e&&"default"in e?e.default:e,n=Wa(),s=new n,a=s.getBrowser(),o=s.getCPU(),l=s.getDevice(),d=s.getEngine(),c=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:d,os:c,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",L="tablet",I="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===L},G=function(e){var t=e.type;return t===k||t===L},j=function(e){return e.type===I},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},de=function(e){var t=e.name;return t===_.Safari||t===_.MobileSafari},ce=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 Le(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:ce(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:de(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 Ie=j(l),Re=W(l),Pe=V(l),Ce=Y(l),De=ce(a)||Te(),_e=ae(a),Oe=G(l)||Te(),Me=U(l),Ne=z(l)||Te(),Fe=H(l),$e=H(l),Be=Q(c),Ue=ee(c),ze=te(c)||Te(),Ge=ne(a),je=se(a),He=de(a),Ve=ue(a),We=he(a),Ye=re(c),Ke=ie(c),qe=me(a),Xe=ge(a),Qe=ve(a),Ze=K(l),Je=q(l),et=ye(d),tt=be(d),rt=ke(u),it=oe(a)||we(u),nt=le(a),st=X(l),at=Se(),ot=Te(),lt=xe(),dt=Ae(),ct=Ee(),ut=we(u),ht=oe(a)&&!we(u),ft=Z(c),pt=J(c),mt=fe(a),gt=pe(a);function vt(e){var t=e||window.navigator.userAgent;return f(t)}return ja.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},ja.BrowserTypes=_,ja.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},ja.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},ja.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},ja.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},ja.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},ja.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},ja.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},ja.OsTypes=O,ja.SmartTVView=function(e){var t=e.renderWithFragment,n=e.children,s=S(e,["renderWithFragment","children"]);return Ie?t?i.createElement(r.Fragment,null,n):i.createElement("div",s,n):null},ja.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},ja.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},ja.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},ja.browserName=Qe,ja.browserVersion=Xe,ja.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 L:return{isTablet:!0};case I: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,d=o.isMobile,c=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):d||c?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},ja.deviceType=st,ja.engineName=et,ja.engineVersion=tt,ja.fullBrowserVersion=qe,ja.getSelectorsByUserAgent=function(e){if(e&&"string"==typeof e){var t=f(e);return Le({device:t.device,browser:t.browser,os:t.os,engine:t.engine,ua:t.ua})}console.error("No valid user agent string was provided")},ja.getUA=rt,ja.isAndroid=Be,ja.isBrowser=Fe,ja.isChrome=Ge,ja.isChromium=_e,ja.isConsole=Re,ja.isDesktop=$e,ja.isEdge=it,ja.isEdgeChromium=ut,ja.isElectron=ct,ja.isEmbedded=Ce,ja.isFirefox=je,ja.isIE=We,ja.isIOS=ze,ja.isIOS13=at,ja.isIPad13=ot,ja.isIPhone13=lt,ja.isIPod13=dt,ja.isLegacyEdge=ht,ja.isMIUI=mt,ja.isMacOs=pt,ja.isMobile=Oe,ja.isMobileOnly=Me,ja.isMobileSafari=De,ja.isOpera=Ve,ja.isSafari=He,ja.isSamsungBrowser=gt,ja.isSmartTV=Ie,ja.isTablet=Ne,ja.isWearable=Pe,ja.isWinPhone=Ue,ja.isWindows=ft,ja.isYandex=nt,ja.mobileModel=Je,ja.mobileVendor=Ze,ja.osName=Ke,ja.osVersion=Ye,ja.parseUserAgent=f,ja.setUserAgent=function(e){return h(e)},ja.useDeviceData=vt,ja.useDeviceSelectors=function(e){var t=vt(e||window.navigator.userAgent);return[Le(t),t]},ja.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},ja.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)},ja}();function Ka({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 qa=({shortForm:e,shareUrl:r})=>{const i=null!=r?r:window.location.href,[n,s]=a(!1);return t.createElement(t.Fragment,null,t.createElement("button",{onClick:()=>x(void 0,void 0,void 0,function*(){try{s(!0),Ya.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"},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(Ka,{message:"공유 링크 복사 완료",setVisible:s,visible:n})))},Xa=({product:e,hideMoreBtn:r,contentId:i})=>{const{isPreview:n,priceText:s,memberOnly:o,isMemberLoggedIn:l}=$a(),d=o&&!l,[c,u]=a(!1);return t.createElement("div",{style:{height:"80px"},className:"flex gap-2 items-center w-full",onClick:()=>x(void 0,void 0,void 0,function*(){r&&(window.open(e.linkPath,"_blank"),n||(yield ka({contentProductId:e.eventProductId,contentId:i,productId:e.productId})))})},t.createElement("div",{className:"w-1/3 h-full shrink-0"},e.thumbPath&&!c?t.createElement(Gr,{product:e,onError:()=>u(!0)}):t.createElement(zr,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:"text-gray-800 text-ellipsis line-clamp-1 ",style:{fontSize:"12px"}},e.productName),t.createElement("div",{className:"text-red-500 break-keep",style:{fontSize:"12px"}},d?t.createElement("span",{className:"font-semibold break-keep"},"판매가 회원 공개"):t.createElement(t.Fragment,null,s?s+" ":"할인가 ",t.createElement("span",{className:"font-semibold break-keep"},xt(e.sellingPrice),"원")))))};function Qa(e,t,{checkForDefaultPrevented:r=!0}={}){return function(i){if(e?.(i),!1===r||!i.defaultPrevented)return t?.(i)}}function Za(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function Ja(...e){return t=>{let r=!1;const i=e.map(e=>{const i=Za(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():Za(e[t],null)}}}}function eo(...t){return e.useCallback(Ja(...t),t)}function to(...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 ro=globalThis?.document?e.useLayoutEffect:()=>{},io=e[" useId ".trim().toString()]||(()=>{}),no=0;function so(t){const[r,i]=e.useState(io());return ro(()=>{t||i(e=>e??String(no++))},[t]),t||(r?`radix-${r}`:"")}var ao=e[" useInsertionEffect ".trim().toString()]||ro;function oo({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 ao(()=>{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,d=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 c=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[d,c]}function lo(t){const r=co(t),i=e.forwardRef((t,i)=>{const{children:n,...s}=t,a=e.Children.toArray(n),o=a.find(ho);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 co(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?Ja(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 uo=Symbol("radix.slottable");function ho(t){return e.isValidElement(t)&&"function"==typeof t.type&&"__radixId"in t.type&&t.type.__radixId===uo}var fo=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((t,r)=>{const i=lo(`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 po(t){const r=e.useRef(t);return e.useEffect(()=>{r.current=t}),e.useMemo(()=>(...e)=>r.current?.(...e),[])}function mo(t,r=globalThis?.document){const i=po(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])}var go,vo="dismissableLayer.update",yo="dismissableLayer.pointerDownOutside",bo="dismissableLayer.focusOutside",Eo=e.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),wo=e.forwardRef((t,r)=>{const{disableOutsidePointerEvents:i=!1,onEscapeKeyDown:n,onPointerDownOutside:s,onFocusOutside:a,onInteractOutside:o,onDismiss:l,...d}=t,c=e.useContext(Eo),[u,h]=e.useState(null),f=u?.ownerDocument??globalThis?.document,[,p]=e.useState({}),m=eo(r,e=>h(e)),g=Array.from(c.layers),[v]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),y=g.indexOf(v),E=u?g.indexOf(u):-1,w=c.layersWithOutsidePointerEventsDisabled.size>0,S=E>=y,T=function(t,r=globalThis?.document){const i=po(t),n=e.useRef(!1),s=e.useRef(()=>{});return e.useEffect(()=>{const e=e=>{if(e.target&&!n.current){let t=function(){To(yo,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=[...c.branches].some(e=>e.contains(t));S&&!r&&(s?.(e),o?.(e),e.defaultPrevented||l?.())},f),x=function(t,r=globalThis?.document){const i=po(t),n=e.useRef(!1);return e.useEffect(()=>{const e=e=>{if(e.target&&!n.current){To(bo,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;[...c.branches].some(e=>e.contains(t))||(a?.(e),o?.(e),e.defaultPrevented||l?.())},f);return mo(e=>{E===c.layers.size-1&&(n?.(e),!e.defaultPrevented&&l&&(e.preventDefault(),l()))},f),e.useEffect(()=>{if(u)return i&&(0===c.layersWithOutsidePointerEventsDisabled.size&&(go=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(u)),c.layers.add(u),So(),()=>{i&&1===c.layersWithOutsidePointerEventsDisabled.size&&(f.body.style.pointerEvents=go)}},[u,f,i,c]),e.useEffect(()=>()=>{u&&(c.layers.delete(u),c.layersWithOutsidePointerEventsDisabled.delete(u),So())},[u,c]),e.useEffect(()=>{const e=()=>p({});return document.addEventListener(vo,e),()=>document.removeEventListener(vo,e)},[]),b(fo.div,{...d,ref:m,style:{pointerEvents:w?S?"auto":"none":void 0,...t.style},onFocusCapture:Qa(t.onFocusCapture,x.onFocusCapture),onBlurCapture:Qa(t.onBlurCapture,x.onBlurCapture),onPointerDownCapture:Qa(t.onPointerDownCapture,T.onPointerDownCapture)})});wo.displayName="DismissableLayer";function So(){const e=new CustomEvent(vo);document.dispatchEvent(e)}function To(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(Eo),n=e.useRef(null),s=eo(r,n);return e.useEffect(()=>{const e=n.current;if(e)return i.branches.add(e),()=>{i.branches.delete(e)}},[i.branches]),b(fo.div,{...t,ref:s})}).displayName="DismissableLayerBranch";var xo="focusScope.autoFocusOnMount",Ao="focusScope.autoFocusOnUnmount",ko={bubbles:!1,cancelable:!0},Lo=e.forwardRef((t,r)=>{const{loop:i=!1,trapped:n=!1,onMountAutoFocus:s,onUnmountAutoFocus:a,...o}=t,[l,d]=e.useState(null),c=po(s),u=po(a),h=e.useRef(null),f=eo(r,e=>d(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:Co(h.current,{select:!0})},t=function(e){if(p.paused||!l)return;const t=e.relatedTarget;null!==t&&(l.contains(t)||Co(h.current,{select:!0}))},r=function(e){if(document.activeElement===document.body)for(const t of e)t.removedNodes.length>0&&Co(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){Do.add(p);const t=document.activeElement;if(!l.contains(t)){const r=new CustomEvent(xo,ko);l.addEventListener(xo,c),l.dispatchEvent(r),r.defaultPrevented||(!function(e,{select:t=!1}={}){const r=document.activeElement;for(const i of e)if(Co(i,{select:t}),document.activeElement!==r)return}((e=Io(l),e.filter(e=>"A"!==e.tagName)),{select:!0}),document.activeElement===t&&Co(l))}return()=>{l.removeEventListener(xo,c),setTimeout(()=>{const e=new CustomEvent(Ao,ko);l.addEventListener(Ao,u),l.dispatchEvent(e),e.defaultPrevented||Co(t??document.body,{select:!0}),l.removeEventListener(Ao,u),Do.remove(p)},0)}}var e},[l,c,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=Io(e),r=Ro(t,e),i=Ro(t.reverse(),e);return[r,i]}(t);n&&s?e.shiftKey||r!==s?e.shiftKey&&r===n&&(e.preventDefault(),i&&Co(s,{select:!0})):(e.preventDefault(),i&&Co(n,{select:!0})):r===t&&e.preventDefault()}},[i,n,p.paused]);return b(fo.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});function Io(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 Ro(e,t){for(const r of e)if(!Po(r,{upTo:t}))return r}function Po(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 Co(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()}}Lo.displayName="FocusScope";var Do=function(){let e=[];return{add(t){const r=e[0];t!==r&&r?.pause(),e=_o(e,t),e.unshift(t)},remove(t){e=_o(e,t),e[0]?.resume()}}}();function _o(e,t){const r=[...e],i=r.indexOf(t);return-1!==i&&r.splice(i,1),r}var Oo=e.forwardRef((t,r)=>{const{container:i,...n}=t,[s,a]=e.useState(!1);ro(()=>a(!0),[]);const o=i||s&&globalThis?.document?.body;return o?m.createPortal(b(fo.div,{...n,ref:r}),o):null});Oo.displayName="Portal";var Mo=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,d]=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=No(n.current);a.current="mounted"===l?e:"none"},[l]),ro(()=>{const e=n.current,r=s.current;if(r!==t){const i=a.current,n=No(e);if(t)d("MOUNT");else if("none"===n||"none"===e?.display)d("UNMOUNT");else{d(r&&i!==n?"ANIMATION_OUT":"UNMOUNT")}s.current=t}},[t,d]),ro(()=>{if(r){let e;const t=r.ownerDocument.defaultView??window,i=i=>{const a=No(n.current).includes(i.animationName);if(i.target===r&&a&&(d("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=No(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)}}d("ANIMATION_END")},[r,d]),{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=eo(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 No(e){return e?.animationName||"none"}Mo.displayName="Presence";var Fo=0;function $o(){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 Bo="right-scroll-bar-position",Uo="width-before-scroll-bar";function zo(e,t){return"function"==typeof e?e(t):e&&(e.current=t),e}var Go="undefined"!=typeof window?e.useLayoutEffect:e.useEffect,jo=new WeakMap;function Ho(e,t){var r,i,n,s=(r=null,i=function(t){return e.forEach(function(e){return zo(e,t)})},(n=a(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 Go(function(){var t=jo.get(s);if(t){var r=new Set(t),i=new Set(e),n=s.current;r.forEach(function(e){i.has(e)||zo(e,null)}),i.forEach(function(e){r.has(e)||zo(e,n)})}jo.set(s,e)},[e]),s}function Vo(e){return e}var Wo=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))};Wo.isSideCarExport=!0;var Yo=function(e){void 0===e&&(e={});var t=function(e,t){void 0===t&&(t=Vo);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}(),Ko=function(){},qo=e.forwardRef(function(t,r){var i=e.useRef(null),n=e.useState({onScrollCapture:Ko,onWheelCapture:Ko,onTouchMoveCapture:Ko}),s=n[0],a=n[1],o=t.forwardProps,l=t.children,d=t.className,c=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=Ho([i,r]),k=S(S({},w),s);return e.createElement(e.Fragment,null,u&&e.createElement(x,{sideCar:Yo,removeScrollBar:c,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:d,ref:A}),l))});qo.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},qo.classNames={fullWidth:Uo,zeroRight:Bo};function Xo(){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 Qo=function(){var e=0,t=null;return{add:function(r){var i,n;0==e&&(t=Xo())&&(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)}}},Zo=function(){var t,r=(t=Qo(),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}},Jo={left:0,top:0,right:0,gap:0},el=function(e){return parseInt(e||"",10)||0},tl=function(e){if(void 0===e&&(e="margin"),"undefined"==typeof window)return Jo;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[el(r),el(i),el(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])}},rl=Zo(),il="data-scroll-locked",nl=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(il,"] {\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(Bo," {\n right: ").concat(o,"px ").concat(i,";\n }\n \n .").concat(Uo," {\n margin-right: ").concat(o,"px ").concat(i,";\n }\n \n .").concat(Bo," .").concat(Bo," {\n right: 0 ").concat(i,";\n }\n \n .").concat(Uo," .").concat(Uo," {\n margin-right: 0 ").concat(i,";\n }\n \n body[").concat(il,"] {\n ").concat("--removed-body-scroll-bar-size",": ").concat(o,"px;\n }\n")},sl=function(){var e=parseInt(document.body.getAttribute(il)||"0",10);return isFinite(e)?e:0},al=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(il,(sl()+1).toString()),function(){var e=sl()-1;e<=0?document.body.removeAttribute(il):document.body.setAttribute(il,e.toString())}},[]);var a=e.useMemo(function(){return tl(s)},[s]);return e.createElement(rl,{styles:nl(a,!r,s,i?"":"!important")})},ol=!1;if("undefined"!=typeof window)try{var ll=Object.defineProperty({},"passive",{get:function(){return ol=!0,!0}});window.addEventListener("test",ll,ll),window.removeEventListener("test",ll,ll)}catch(e){ol=!1}var dl=!!ol&&{passive:!1},cl=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])},ul=function(e,t){var r=t.ownerDocument,i=t;do{if("undefined"!=typeof ShadowRoot&&i instanceof ShadowRoot&&(i=i.host),hl(e,i)){var n=fl(e,i);if(n[1]>n[2])return!0}i=i.parentNode}while(i&&i!==r.body);return!1},hl=function(e,t){return"v"===e?function(e){return cl(e,"overflowY")}(t):function(e){return cl(e,"overflowX")}(t)},fl=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},pl=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},ml=function(e){return[e.deltaX,e.deltaY]},gl=function(e){return e&&"current"in e?e.current:e},vl=function(e){return"\n .block-interactivity-".concat(e," {pointer-events: none;}\n .allow-interactivity-").concat(e," {pointer-events: all;}\n")},yl=0,bl=[];function El(e){for(var t=null;null!==e;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var wl,Sl=(wl=function(t){var r=e.useRef([]),i=e.useRef([0,0]),n=e.useRef(),s=e.useState(yl++)[0],a=e.useState(Zo)[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(gl),!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=pl(e),a=i.current,l="deltaX"in e?e.deltaX:a[0]-s[0],d="deltaY"in e?e.deltaY:a[1]-s[1],c=e.target,u=Math.abs(l)>Math.abs(d)?"h":"v";if("touches"in e&&"h"===u&&"range"===c.type)return!1;var h=ul(u,c);if(!h)return!0;if(h?r=u:(r="v"===u?"h":"v",h=ul(u,c)),!h)return!1;if(!n.current&&"changedTouches"in e&&(l||d)&&(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),d=!1,c=a>0,u=0,h=0;do{if(!o)break;var f=fl(e,o),p=f[0],m=f[1]-f[2]-s*p;(p||m)&&hl(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 c&&(Math.abs(u)<1||!n)?d=!0:c||!(Math.abs(h)<1)&&n||(d=!0),d}(f,t,e,"h"===f?l:d,!0)},[]),d=e.useCallback(function(e){var t=e;if(bl.length&&bl[bl.length-1]===a){var i="deltaY"in t?ml(t):pl(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(gl).filter(Boolean).filter(function(e){return e.contains(t.target)});(s.length>0?l(t,s[0]):!o.current.noIsolation)&&t.cancelable&&t.preventDefault()}}},[]),c=e.useCallback(function(e,t,i,n){var s={name:e,delta:t,target:i,should:n,shadowParent:El(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=pl(e),n.current=void 0},[]),h=e.useCallback(function(e){c(e.type,ml(e),e.target,l(e,t.lockRef.current))},[]),f=e.useCallback(function(e){c(e.type,pl(e),e.target,l(e,t.lockRef.current))},[]);e.useEffect(function(){return bl.push(a),t.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:f}),document.addEventListener("wheel",d,dl),document.addEventListener("touchmove",d,dl),document.addEventListener("touchstart",u,dl),function(){bl=bl.filter(function(e){return e!==a}),document.removeEventListener("wheel",d,dl),document.removeEventListener("touchmove",d,dl),document.removeEventListener("touchstart",u,dl)}},[]);var p=t.removeScrollBar,m=t.inert;return e.createElement(e.Fragment,null,m?e.createElement(a,{styles:vl(s)}):null,p?e.createElement(al,{noRelative:t.noRelative,gapMode:t.gapMode}):null)},Yo.useMedium(wl),Wo),Tl=e.forwardRef(function(t,r){return e.createElement(qo,S({},t,{ref:r,sideCar:Sl}))});Tl.classNames=qo.classNames;var xl=new WeakMap,Al=new WeakMap,kl={},Ll=0,Il=function(e){return e&&(e.host||Il(e.parentNode))},Rl=function(e,t,r,i){var n=function(e,t){return t.map(function(t){if(e.contains(t))return t;var r=Il(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]);kl[r]||(kl[r]=new WeakMap);var s=kl[r],a=[],o=new Set,l=new Set(n),d=function(e){e&&!o.has(e)&&(o.add(e),d(e.parentNode))};n.forEach(d);var c=function(e){e&&!l.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(o.has(e))c(e);else try{var t=e.getAttribute(i),n=null!==t&&"false"!==t,l=(xl.get(e)||0)+1,d=(s.get(e)||0)+1;xl.set(e,l),s.set(e,d),a.push(e),1===l&&n&&Al.set(e,!0),1===d&&e.setAttribute(r,"true"),n||e.setAttribute(i,"true")}catch(t){console.error("aria-hidden: cannot operate on ",e,t)}})};return c(t),o.clear(),Ll++,function(){a.forEach(function(e){var t=xl.get(e)-1,n=s.get(e)-1;xl.set(e,t),s.set(e,n),t||(Al.has(e)||e.removeAttribute(i),Al.delete(e)),n||e.removeAttribute(r)}),--Ll||(xl=new WeakMap,xl=new WeakMap,Al=new WeakMap,kl={})}},Pl=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"))),Rl(i,n,r,"aria-hidden")):function(){return null}},Cl="Dialog",[Dl,_l]=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,d=e.useMemo(()=>o,Object.values(o));return b(l.Provider,{value:d,children:n})};return o.displayName=r+"Provider",[o,function(i,o){const l=o?.[t]?.[a]||s,d=e.useContext(l);if(d)return d;if(void 0!==n)return n;throw new Error(`\`${i}\` must be used within \`${r}\``)}]},to(n,...r)]}(Cl),[Ol,Ml]=Dl(Cl),Nl=t=>{const{__scopeDialog:r,children:i,open:n,defaultOpen:s,onOpenChange:a,modal:o=!0}=t,l=e.useRef(null),d=e.useRef(null),[c,u]=oo({prop:n,defaultProp:s??!1,onChange:a,caller:Cl});return b(Ol,{scope:r,triggerRef:l,contentRef:d,contentId:so(),titleId:so(),descriptionId:so(),open:c,onOpenChange:u,onOpenToggle:e.useCallback(()=>u(e=>!e),[u]),modal:o,children:i})};Nl.displayName=Cl;var Fl="DialogTrigger",$l=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=Ml(Fl,r),s=eo(t,n.triggerRef);return b(fo.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":nd(n.open),...i,ref:s,onClick:Qa(e.onClick,n.onOpenToggle)})});$l.displayName=Fl;var Bl="DialogPortal",[Ul,zl]=Dl(Bl,{forceMount:void 0}),Gl=t=>{const{__scopeDialog:r,forceMount:i,children:n,container:s}=t,a=Ml(Bl,r);return b(Ul,{scope:r,forceMount:i,children:e.Children.map(n,e=>b(Mo,{present:i||a.open,children:b(Oo,{asChild:!0,container:s,children:e})}))})};Gl.displayName=Bl;var jl="DialogOverlay",Hl=e.forwardRef((e,t)=>{const r=zl(jl,e.__scopeDialog),{forceMount:i=r.forceMount,...n}=e,s=Ml(jl,e.__scopeDialog);return s.modal?b(Mo,{present:i||s.open,children:b(Wl,{...n,ref:t})}):null});Hl.displayName=jl;var Vl=lo("DialogOverlay.RemoveScroll"),Wl=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=Ml(jl,r);return b(Tl,{as:Vl,allowPinchZoom:!0,shards:[n.contentRef],children:b(fo.div,{"data-state":nd(n.open),...i,ref:t,style:{pointerEvents:"auto",...i.style}})})}),Yl="DialogContent",Kl=e.forwardRef((e,t)=>{const r=zl(Yl,e.__scopeDialog),{forceMount:i=r.forceMount,...n}=e,s=Ml(Yl,e.__scopeDialog);return b(Mo,{present:i||s.open,children:s.modal?b(ql,{...n,ref:t}):b(Xl,{...n,ref:t})})});Kl.displayName=Yl;var ql=e.forwardRef((t,r)=>{const i=Ml(Yl,t.__scopeDialog),n=e.useRef(null),s=eo(r,i.contentRef,n);return e.useEffect(()=>{const e=n.current;if(e)return Pl(e)},[]),b(Ql,{...t,ref:s,trapFocus:i.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Qa(t.onCloseAutoFocus,e=>{e.preventDefault(),i.triggerRef.current?.focus()}),onPointerDownOutside:Qa(t.onPointerDownOutside,e=>{const t=e.detail.originalEvent,r=0===t.button&&!0===t.ctrlKey;(2===t.button||r)&&e.preventDefault()}),onFocusOutside:Qa(t.onFocusOutside,e=>e.preventDefault())})}),Xl=e.forwardRef((t,r)=>{const i=Ml(Yl,t.__scopeDialog),n=e.useRef(!1),s=e.useRef(!1);return b(Ql,{...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()}})}),Ql=e.forwardRef((t,r)=>{const{__scopeDialog:i,trapFocus:n,onOpenAutoFocus:s,onCloseAutoFocus:a,...o}=t,l=Ml(Yl,i),d=e.useRef(null),c=eo(r,d);return e.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??$o()),document.body.insertAdjacentElement("beforeend",e[1]??$o()),Fo++,()=>{1===Fo&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),Fo--}},[]),w(E,{children:[b(Lo,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:s,onUnmountAutoFocus:a,children:b(wo,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":nd(l.open),...o,ref:c,onDismiss:()=>l.onOpenChange(!1)})}),w(E,{children:[b(ld,{titleId:l.titleId}),b(dd,{contentRef:d,descriptionId:l.descriptionId})]})]})}),Zl="DialogTitle",Jl=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=Ml(Zl,r);return b(fo.h2,{id:n.titleId,...i,ref:t})});Jl.displayName=Zl;var ed="DialogDescription",td=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=Ml(ed,r);return b(fo.p,{id:n.descriptionId,...i,ref:t})});td.displayName=ed;var rd="DialogClose",id=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=Ml(rd,r);return b(fo.button,{type:"button",...i,ref:t,onClick:Qa(e.onClick,()=>n.onOpenChange(!1))})});function nd(e){return e?"open":"closed"}id.displayName=rd;var sd="DialogTitleWarning",[ad,od]=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}\``)}]}(sd,{contentName:Yl,titleName:Zl,docsSlug:"dialog"}),ld=({titleId:t})=>{const r=od(sd),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},dd=({contentRef:t,descriptionId:r})=>{const i=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${od("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},cd=Nl,ud=$l,hd=Gl,fd=Hl,pd=Kl,md=Jl,gd=td,vd=id;const yd=t.createContext({drawerRef:{current:null},overlayRef:{current:null},onPress:()=>{},onRelease:()=>{},onDrag:()=>{},onNestedDrag:()=>{},onNestedOpenChange:()=>{},onNestedRelease:()=>{},openProp:void 0,dismissible:!1,isOpen:!1,isDragging:!1,keyboardIsOpen:{current:!1},snapPointsOffset:null,snapPoints:null,handleOnly:!1,modal:!1,shouldFade:!1,activeSnapPoint:null,onOpenChange:()=>{},setActiveSnapPoint:()=>{},closeDrawer:()=>{},direction:"bottom",shouldAnimate:{current:!0},shouldScaleBackground:!1,setBackgroundColorOnScale:!0,noBodyStyles:!1,container:null,autoFocus:!1}),bd=()=>{const e=t.useContext(yd);if(!e)throw new Error("useDrawerContext must be used within a Drawer.Root");return e};function Ed(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function wd(){return Td(/^iPad/)||Td(/^Mac/)&&navigator.maxTouchPoints>1}function Sd(){return Td(/^iPhone/)||wd()}function Td(e){return"undefined"!=typeof window&&null!=window.navigator?e.test(window.navigator.platform):void 0}!function(e){if("undefined"==typeof document)return;let t=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}("[data-vaul-drawer]{touch-action:none;will-change:transform;transition:transform .5s cubic-bezier(.32, .72, 0, 1);animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=open]{animation-name:slideFromBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=closed]{animation-name:slideToBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=open]{animation-name:slideFromTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=closed]{animation-name:slideToTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=open]{animation-name:slideFromLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=closed]{animation-name:slideToLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=open]{animation-name:slideFromRight}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=closed]{animation-name:slideToRight}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,var(--initial-transform,100%),0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(var(--initial-transform,100%),0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-overlay][data-vaul-snap-points=false]{animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-overlay][data-vaul-snap-points=false][data-state=open]{animation-name:fadeIn}[data-vaul-overlay][data-state=closed]{animation-name:fadeOut}[data-vaul-animate=false]{animation:none!important}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:0;transition:opacity .5s cubic-bezier(.32, .72, 0, 1)}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:1}[data-vaul-drawer]:not([data-vaul-custom-container=true])::after{content:'';position:absolute;background:inherit;background-color:inherit}[data-vaul-drawer][data-vaul-drawer-direction=top]::after{top:initial;bottom:100%;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=bottom]::after{top:100%;bottom:initial;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=left]::after{left:initial;right:100%;top:0;bottom:0;width:200%}[data-vaul-drawer][data-vaul-drawer-direction=right]::after{left:100%;right:initial;top:0;bottom:0;width:200%}[data-vaul-overlay][data-vaul-snap-points=true]:not([data-vaul-snap-points-overlay=true]):not(\n[data-state=closed]\n){opacity:0}[data-vaul-overlay][data-vaul-snap-points-overlay=true]{opacity:1}[data-vaul-handle]{display:block;position:relative;opacity:.7;background:#e2e2e4;margin-left:auto;margin-right:auto;height:5px;width:32px;border-radius:1rem;touch-action:pan-y}[data-vaul-handle]:active,[data-vaul-handle]:hover{opacity:1}[data-vaul-handle-hitarea]{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:max(100%,2.75rem);height:max(100%,2.75rem);touch-action:inherit}@media (hover:hover) and (pointer:fine){[data-vaul-drawer]{user-select:none}}@media (pointer:fine){[data-vaul-handle-hitarea]:{width:100%;height:100%}}@keyframes fadeIn{from{opacity:0}to{opacity:1}}@keyframes fadeOut{to{opacity:0}}@keyframes slideFromBottom{from{transform:translate3d(0,var(--initial-transform,100%),0)}to{transform:translate3d(0,0,0)}}@keyframes slideToBottom{to{transform:translate3d(0,var(--initial-transform,100%),0)}}@keyframes slideFromTop{from{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}to{transform:translate3d(0,0,0)}}@keyframes slideToTop{to{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}}@keyframes slideFromLeft{from{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToLeft{to{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}}@keyframes slideFromRight{from{transform:translate3d(var(--initial-transform,100%),0,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToRight{to{transform:translate3d(var(--initial-transform,100%),0,0)}}");const xd="undefined"!=typeof window?o:i;function Ad(...e){return(...t)=>{for(let r of e)"function"==typeof r&&r(...t)}}const kd="undefined"!=typeof document&&window.visualViewport;function Ld(e){let t=window.getComputedStyle(e);return/(auto|scroll)/.test(t.overflow+t.overflowX+t.overflowY)}function Id(e){for(Ld(e)&&(e=e.parentElement);e&&!Ld(e);)e=e.parentElement;return e||document.scrollingElement||document.documentElement}const Rd=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);let Pd,Cd=0;function Dd(e={}){let{isDisabled:t}=e;xd(()=>{if(!t)return Cd++,1===Cd&&Sd()&&(Pd=function(){let e,t=0,r=r=>{e=Id(r.target),e===document.documentElement&&e===document.body||(t=r.changedTouches[0].pageY)},i=r=>{if(!e||e===document.documentElement||e===document.body)return void r.preventDefault();let i=r.changedTouches[0].pageY,n=e.scrollTop,s=e.scrollHeight-e.clientHeight;0!==s&&((n<=0&&i>t||n>=s&&i<t)&&r.preventDefault(),t=i)},n=e=>{let t=e.target;Md(t)&&t!==document.activeElement&&(e.preventDefault(),t.style.transform="translateY(-2000px)",t.focus(),requestAnimationFrame(()=>{t.style.transform=""}))},s=e=>{let t=e.target;Md(t)&&(t.style.transform="translateY(-2000px)",requestAnimationFrame(()=>{t.style.transform="",kd&&(kd.height<window.innerHeight?requestAnimationFrame(()=>{Od(t)}):kd.addEventListener("resize",()=>Od(t),{once:!0}))}))},a=()=>{window.scrollTo(0,0)},o=window.pageXOffset,l=window.pageYOffset,d=Ad(function(e,t,r){let i=e.style[t];return e.style[t]=r,()=>{e.style[t]=i}}(document.documentElement,"paddingRight",window.innerWidth-document.documentElement.clientWidth+"px"));window.scrollTo(0,0);let c=Ad(_d(document,"touchstart",r,{passive:!1,capture:!0}),_d(document,"touchmove",i,{passive:!1,capture:!0}),_d(document,"touchend",n,{passive:!1,capture:!0}),_d(document,"focus",s,!0),_d(window,"scroll",a));return()=>{d(),c(),window.scrollTo(o,l)}}()),()=>{Cd--,0===Cd&&(null==Pd||Pd())}},[t])}function _d(e,t,r,i){return e.addEventListener(t,r,i),()=>{e.removeEventListener(t,r,i)}}function Od(e){let t=document.scrollingElement||document.documentElement;for(;e&&e!==t;){let t=Id(e);if(t!==document.documentElement&&t!==document.body&&t!==e){let r=t.getBoundingClientRect().top,i=e.getBoundingClientRect().top;e.getBoundingClientRect().bottom>t.getBoundingClientRect().bottom+24&&(t.scrollTop+=i-r)}e=t.parentElement}}function Md(e){return e instanceof HTMLInputElement&&!Rd.has(e.type)||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable}function Nd(...t){return e.useCallback(function(...e){return t=>e.forEach(e=>function(e,t){"function"==typeof e?e(t):null!=e&&(e.current=t)}(e,t))}(...t),t)}const Fd=new WeakMap;function $d(e,t,r=!1){if(!(e&&e instanceof HTMLElement))return;let i={};Object.entries(t).forEach(([t,r])=>{t.startsWith("--")?e.style.setProperty(t,r):(i[t]=e.style[t],e.style[t]=r)}),r||Fd.set(e,i)}const Bd=e=>{switch(e){case"top":case"bottom":return!0;case"left":case"right":return!1;default:return e}};function Ud(e,t){if(!e)return null;const r=window.getComputedStyle(e),i=r.transform||r.webkitTransform||r.mozTransform;let n=i.match(/^matrix3d\((.+)\)$/);return n?parseFloat(n[1].split(", ")[Bd(t)?13:12]):(n=i.match(/^matrix\((.+)\)$/),n?parseFloat(n[1].split(", ")[Bd(t)?5:4]):null)}function zd(e,t){if(!e)return()=>{};const r=e.style.cssText;return Object.assign(e.style,t),()=>{e.style.cssText=r}}const Gd={DURATION:.5,EASE:[.32,.72,0,1]},jd=16,Hd="vaul-dragging";function Vd(e){const r=t.useRef(e);return t.useEffect(()=>{r.current=e}),t.useMemo(()=>(...e)=>null==r.current?void 0:r.current.call(r,...e),[])}function Wd({prop:e,defaultProp:r,onChange:i=()=>{}}){const[n,s]=function({defaultProp:e,onChange:r}){const i=t.useState(e),[n]=i,s=t.useRef(n),a=Vd(r);return t.useEffect(()=>{s.current!==n&&(a(n),s.current=n)},[n,s,a]),i}({defaultProp:r,onChange:i}),a=void 0!==e,o=a?e:n,l=Vd(i),d=t.useCallback(t=>{if(a){const r="function"==typeof t?t(e):t;r!==e&&l(r)}else s(t)},[a,e,s,l]);return[o,d]}let Yd=null;function Kd({open:e,onOpenChange:r,children:i,onDrag:n,onRelease:s,snapPoints:a,shouldScaleBackground:o=!1,setBackgroundColorOnScale:l=!0,closeThreshold:d=.25,scrollLockTimeout:c=100,dismissible:u=!0,handleOnly:h=!1,fadeFromIndex:f=a&&a.length-1,activeSnapPoint:p,setActiveSnapPoint:m,fixed:g,modal:v=!0,onClose:y,nested:b,noBodyStyles:E=!1,direction:w="bottom",defaultOpen:S=!1,disablePreventScroll:T=!0,snapToSequentialPoint:x=!1,preventScrollRestoration:A=!1,repositionInputs:k=!0,onAnimationEnd:L,container:I,autoFocus:R=!1}){var P,C;const[D=!1,_]=Wd({defaultProp:S,prop:e,onChange:e=>{null==r||r(e),e||b||ce(),setTimeout(()=>{null==L||L(e)},1e3*Gd.DURATION),e&&!v&&"undefined"!=typeof window&&window.requestAnimationFrame(()=>{document.body.style.pointerEvents="auto"}),e||(document.body.style.pointerEvents="auto")}}),[O,M]=t.useState(!1),[N,F]=t.useState(!1),[$,B]=t.useState(!1),U=t.useRef(null),z=t.useRef(null),G=t.useRef(null),j=t.useRef(null),H=t.useRef(null),V=t.useRef(!1),W=t.useRef(null),Y=t.useRef(0),K=t.useRef(!1),q=t.useRef(!S),X=t.useRef(0),Q=t.useRef(null),Z=t.useRef((null==(P=Q.current)?void 0:P.getBoundingClientRect().height)||0),J=t.useRef((null==(C=Q.current)?void 0:C.getBoundingClientRect().width)||0),ee=t.useRef(0),te=t.useCallback(e=>{a&&e===ae.length-1&&(z.current=new Date)},[]),{activeSnapPoint:re,activeSnapPointIndex:ie,setActiveSnapPoint:ne,onRelease:se,snapPointsOffset:ae,onDrag:oe,shouldFade:le,getPercentageDragged:de}=function({activeSnapPointProp:e,setActiveSnapPointProp:r,snapPoints:i,drawerRef:n,overlayRef:s,fadeFromIndex:a,onSnapPointChange:o,direction:l="bottom",container:d,snapToSequentialPoint:c}){const[u,h]=Wd({prop:e,defaultProp:null==i?void 0:i[0],onChange:r}),[f,p]=t.useState("undefined"!=typeof window?{innerWidth:window.innerWidth,innerHeight:window.innerHeight}:void 0);t.useEffect(()=>{function e(){p({innerWidth:window.innerWidth,innerHeight:window.innerHeight})}return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const m=t.useMemo(()=>u===(null==i?void 0:i[i.length-1])||null,[i,u]),g=t.useMemo(()=>{var e;return null!=(e=null==i?void 0:i.findIndex(e=>e===u))?e:null},[i,u]),v=i&&i.length>0&&(a||0===a)&&!Number.isNaN(a)&&i[a]===u||!i,y=t.useMemo(()=>{const e=d?{width:d.getBoundingClientRect().width,height:d.getBoundingClientRect().height}:"undefined"!=typeof window?{width:window.innerWidth,height:window.innerHeight}:{width:0,height:0};var t;return null!=(t=null==i?void 0:i.map(t=>{const r="string"==typeof t;let i=0;if(r&&(i=parseInt(t,10)),Bd(l)){const n=r?i:f?t*e.height:0;return f?"bottom"===l?e.height-n:-e.height+n:n}const n=r?i:f?t*e.width:0;return f?"right"===l?e.width-n:-e.width+n:n}))?t:[]},[i,f,d]),b=t.useMemo(()=>null!==g?null==y?void 0:y[g]:null,[y,g]),E=t.useCallback(e=>{var t;const r=null!=(t=null==y?void 0:y.findIndex(t=>t===e))?t:null;o(r),$d(n.current,{transition:`transform ${Gd.DURATION}s cubic-bezier(${Gd.EASE.join(",")})`,transform:Bd(l)?`translate3d(0, ${e}px, 0)`:`translate3d(${e}px, 0, 0)`}),y&&r!==y.length-1&&void 0!==a&&r!==a&&r<a?$d(s.current,{transition:`opacity ${Gd.DURATION}s cubic-bezier(${Gd.EASE.join(",")})`,opacity:"0"}):$d(s.current,{transition:`opacity ${Gd.DURATION}s cubic-bezier(${Gd.EASE.join(",")})`,opacity:"1"}),h(null==i?void 0:i[Math.max(r,0)])},[n.current,i,y,a,s,h]);return t.useEffect(()=>{if(u||e){var t;const r=null!=(t=null==i?void 0:i.findIndex(t=>t===e||t===u))?t:-1;y&&-1!==r&&"number"==typeof y[r]&&E(y[r])}},[u,e,i,y,E]),{isLastSnapPoint:m,activeSnapPoint:u,shouldFade:v,getPercentageDragged:function(e,t){if(!i||"number"!=typeof g||!y||void 0===a)return null;const r=g===a-1;if(g>=a&&t)return 0;if(r&&!t)return 1;if(!v&&!r)return null;const n=r?g+1:g-1,s=r?y[n]-y[n-1]:y[n+1]-y[n],o=e/Math.abs(s);return r?1-o:o},setActiveSnapPoint:h,activeSnapPointIndex:g,onRelease:function({draggedDistance:e,closeDrawer:t,velocity:r,dismissible:n}){if(void 0===a)return;const o="bottom"===l||"right"===l?(null!=b?b:0)-e:(null!=b?b:0)+e,d=0===g,u=e>0;if(g===a-1&&$d(s.current,{transition:`opacity ${Gd.DURATION}s cubic-bezier(${Gd.EASE.join(",")})`}),!c&&r>2&&!u)return void(n?t():E(y[0]));if(!c&&r>2&&u&&y&&i)return void E(y[i.length-1]);const h=null==y?void 0:y.reduce((e,t)=>"number"!=typeof e||"number"!=typeof t?e:Math.abs(t-o)<Math.abs(e-o)?t:e),f=Bd(l)?window.innerHeight:window.innerWidth;if(r>.4&&Math.abs(e)<.4*f){const e=u?1:-1;if(e>0&&m&&i)return void E(y[i.length-1]);if(d&&e<0&&n&&t(),null===g)return;return void E(y[g+e])}E(h)},onDrag:function({draggedDistance:e}){if(null===b)return;const t="bottom"===l||"right"===l?b-e:b+e;("bottom"===l||"right"===l)&&t<y[y.length-1]||("top"===l||"left"===l)&&t>y[y.length-1]||$d(n.current,{transform:Bd(l)?`translate3d(0, ${t}px, 0)`:`translate3d(${t}px, 0, 0)`})},snapPointsOffset:y}}({snapPoints:a,activeSnapPointProp:p,setActiveSnapPointProp:m,drawerRef:Q,fadeFromIndex:f,overlayRef:U,onSnapPointChange:te,direction:w,container:I,snapToSequentialPoint:x});Dd({isDisabled:!D||N||!v||$||!O||!k||!T});const{restorePositionSetting:ce}=function({isOpen:e,modal:r,nested:i,hasBeenOpened:n,preventScrollRestoration:s,noBodyStyles:a}){const[o,l]=t.useState(()=>"undefined"!=typeof window?window.location.href:""),d=t.useRef(0),c=t.useCallback(()=>{if(Ed()&&null===Yd&&e&&!a){Yd={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left,height:document.body.style.height,right:"unset"};const{scrollX:e,innerHeight:t}=window;document.body.style.setProperty("position","fixed","important"),Object.assign(document.body.style,{top:-d.current+"px",left:-e+"px",right:"0px",height:"auto"}),window.setTimeout(()=>window.requestAnimationFrame(()=>{const e=t-window.innerHeight;e&&d.current>=t&&(document.body.style.top=-(d.current+e)+"px")}),300)}},[e]),u=t.useCallback(()=>{if(Ed()&&null!==Yd&&!a){const e=-parseInt(document.body.style.top,10),t=-parseInt(document.body.style.left,10);Object.assign(document.body.style,Yd),window.requestAnimationFrame(()=>{s&&o!==window.location.href?l(window.location.href):window.scrollTo(t,e)}),Yd=null}},[o]);return t.useEffect(()=>{function e(){d.current=window.scrollY}return e(),window.addEventListener("scroll",e),()=>{window.removeEventListener("scroll",e)}},[]),t.useEffect(()=>{if(r)return()=>{"undefined"!=typeof document&&(document.querySelector("[data-vaul-drawer]")||u())}},[r,u]),t.useEffect(()=>{!i&&n&&(e?(!window.matchMedia("(display-mode: standalone)").matches&&c(),r||window.setTimeout(()=>{u()},500)):u())},[e,n,o,r,i,c,u]),{restorePositionSetting:u}}({isOpen:D,modal:v,nested:null!=b&&b,hasBeenOpened:O,preventScrollRestoration:A,noBodyStyles:E});function ue(){return(window.innerWidth-26)/window.innerWidth}function he(e,t){var r;let i=e;const n=null==(r=window.getSelection())?void 0:r.toString(),s=Q.current?Ud(Q.current,w):null,a=new Date;if("SELECT"===i.tagName)return!1;if(i.hasAttribute("data-vaul-no-drag")||i.closest("[data-vaul-no-drag]"))return!1;if("right"===w||"left"===w)return!0;if(z.current&&a.getTime()-z.current.getTime()<500)return!1;if(null!==s&&("bottom"===w?s>0:s<0))return!0;if(n&&n.length>0)return!1;if(H.current&&a.getTime()-H.current.getTime()<c&&0===s)return H.current=a,!1;if(t)return H.current=a,!1;for(;i;){if(i.scrollHeight>i.clientHeight){if(0!==i.scrollTop)return H.current=new Date,!1;if("dialog"===i.getAttribute("role"))return!0}i=i.parentNode}return!0}function fe(e){!function(){if(!N||!Q.current)return;Q.current.classList.remove(Hd),V.current=!1,F(!1),j.current=new Date}(),null==y||y(),e||_(!1),setTimeout(()=>{a&&ne(a[0])},1e3*Gd.DURATION)}function pe(){if(!Q.current)return;const e=document.querySelector("[data-vaul-drawer-wrapper]"),t=Ud(Q.current,w);$d(Q.current,{transform:"translate3d(0, 0, 0)",transition:`transform ${Gd.DURATION}s cubic-bezier(${Gd.EASE.join(",")})`}),$d(U.current,{transition:`opacity ${Gd.DURATION}s cubic-bezier(${Gd.EASE.join(",")})`,opacity:"1"}),o&&t&&t>0&&D&&$d(e,{borderRadius:"8px",overflow:"hidden",...Bd(w)?{transform:`scale(${ue()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`,transformOrigin:"top"}:{transform:`scale(${ue()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`,transformOrigin:"left"},transitionProperty:"transform, border-radius",transitionDuration:`${Gd.DURATION}s`,transitionTimingFunction:`cubic-bezier(${Gd.EASE.join(",")})`},!0)}return t.useEffect(()=>{window.requestAnimationFrame(()=>{q.current=!0})},[]),t.useEffect(()=>{var e;function t(){if(!Q.current||!k)return;if(Md(document.activeElement)||K.current){var e;const t=(null==(e=window.visualViewport)?void 0:e.height)||0,r=window.innerHeight;let i=r-t;const n=Q.current.getBoundingClientRect().height||0,s=n>.8*r;ee.current||(ee.current=n);const o=Q.current.getBoundingClientRect().top;if(Math.abs(X.current-i)>60&&(K.current=!K.current),a&&a.length>0&&ae&&ie){i+=ae[ie]||0}if(X.current=i,n>t||K.current){const e=Q.current.getBoundingClientRect().height;let r=e;e>t&&(r=t-(s?o:26)),Q.current.style.height=g?e-Math.max(i,0)+"px":`${Math.max(r,t-o)}px`}else(function(){const e=navigator.userAgent;return"undefined"!=typeof window&&(/Firefox/.test(e)&&/Mobile/.test(e)||/FxiOS/.test(e))})()||(Q.current.style.height=`${ee.current}px`);a&&a.length>0&&!K.current?Q.current.style.bottom="0px":Q.current.style.bottom=`${Math.max(i,0)}px`}}return null==(e=window.visualViewport)||e.addEventListener("resize",t),()=>{var e;return null==(e=window.visualViewport)?void 0:e.removeEventListener("resize",t)}},[ie,a,ae]),t.useEffect(()=>(D&&($d(document.documentElement,{scrollBehavior:"auto"}),z.current=new Date),()=>{!function(e,t){if(!(e&&e instanceof HTMLElement))return;let r=Fd.get(e);r&&(e.style[t]=r[t])}(document.documentElement,"scrollBehavior")}),[D]),t.useEffect(()=>{v||window.requestAnimationFrame(()=>{document.body.style.pointerEvents="auto"})},[v]),t.createElement(cd,{defaultOpen:S,onOpenChange:e=>{(u||e)&&(e?M(!0):fe(!0),_(e))},open:D},t.createElement(yd.Provider,{value:{activeSnapPoint:re,snapPoints:a,setActiveSnapPoint:ne,drawerRef:Q,overlayRef:U,onOpenChange:r,onPress:function(e){var t,r;(u||a)&&(Q.current&&!Q.current.contains(e.target)||(Z.current=(null==(t=Q.current)?void 0:t.getBoundingClientRect().height)||0,J.current=(null==(r=Q.current)?void 0:r.getBoundingClientRect().width)||0,F(!0),G.current=new Date,Sd()&&window.addEventListener("touchend",()=>V.current=!1,{once:!0}),e.target.setPointerCapture(e.pointerId),Y.current=Bd(w)?e.pageY:e.pageX))},onRelease:function(e){if(!N||!Q.current)return;Q.current.classList.remove(Hd),V.current=!1,F(!1),j.current=new Date;const t=Ud(Q.current,w);if(!e||!he(e.target,!1)||!t||Number.isNaN(t))return;if(null===G.current)return;const r=j.current.getTime()-G.current.getTime(),i=Y.current-(Bd(w)?e.pageY:e.pageX),n=Math.abs(i)/r;if(n>.05&&(B(!0),setTimeout(()=>{B(!1)},200)),a){return se({draggedDistance:i*("bottom"===w||"right"===w?1:-1),closeDrawer:fe,velocity:n,dismissible:u}),void(null==s||s(e,!0))}if("bottom"===w||"right"===w?i>0:i<0)return pe(),void(null==s||s(e,!0));if(n>.4)return fe(),void(null==s||s(e,!1));var o;const l=Math.min(null!=(o=Q.current.getBoundingClientRect().height)?o:0,window.innerHeight);var c;const h=Math.min(null!=(c=Q.current.getBoundingClientRect().width)?c:0,window.innerWidth),f="left"===w||"right"===w;if(Math.abs(t)>=(f?h:l)*d)return fe(),void(null==s||s(e,!1));null==s||s(e,!0),pe()},onDrag:function(e){if(Q.current&&N){const t="bottom"===w||"right"===w?1:-1,r=(Y.current-(Bd(w)?e.pageY:e.pageX))*t,i=r>0,s=a&&!u&&!i;if(s&&0===ie)return;const l=Math.abs(r),d=document.querySelector("[data-vaul-drawer-wrapper]");let c=l/("bottom"===w||"top"===w?Z.current:J.current);const h=de(l,i);if(null!==h&&(c=h),s&&c>=1)return;if(!V.current&&!he(e.target,i))return;if(Q.current.classList.add(Hd),V.current=!0,$d(Q.current,{transition:"none"}),$d(U.current,{transition:"none"}),a&&oe({draggedDistance:r}),i&&!a){const e=function(e){return 8*(Math.log(e+1)-2)}(r),i=Math.min(-1*e,0)*t;return void $d(Q.current,{transform:Bd(w)?`translate3d(0, ${i}px, 0)`:`translate3d(${i}px, 0, 0)`})}const p=1-c;if((le||f&&ie===f-1)&&(null==n||n(e,c),$d(U.current,{opacity:`${p}`,transition:"none"},!0)),d&&U.current&&o){const e=Math.min(ue()+c*(1-ue()),1),t=8-8*c,r=Math.max(0,14-14*c);$d(d,{borderRadius:`${t}px`,transform:Bd(w)?`scale(${e}) translate3d(0, ${r}px, 0)`:`scale(${e}) translate3d(${r}px, 0, 0)`,transition:"none"},!0)}if(!a){const e=l*t;$d(Q.current,{transform:Bd(w)?`translate3d(0, ${e}px, 0)`:`translate3d(${e}px, 0, 0)`})}}},dismissible:u,shouldAnimate:q,handleOnly:h,isOpen:D,isDragging:N,shouldFade:le,closeDrawer:fe,onNestedDrag:function(e,t){if(t<0)return;const r=(window.innerWidth-jd)/window.innerWidth,i=r+t*(1-r),n=t*jd-16;$d(Q.current,{transform:Bd(w)?`scale(${i}) translate3d(0, ${n}px, 0)`:`scale(${i}) translate3d(${n}px, 0, 0)`,transition:"none"})},onNestedOpenChange:function(e){const t=e?(window.innerWidth-jd)/window.innerWidth:1,r=e?-16:0;W.current&&window.clearTimeout(W.current),$d(Q.current,{transition:`transform ${Gd.DURATION}s cubic-bezier(${Gd.EASE.join(",")})`,transform:Bd(w)?`scale(${t}) translate3d(0, ${r}px, 0)`:`scale(${t}) translate3d(${r}px, 0, 0)`}),!e&&Q.current&&(W.current=setTimeout(()=>{const e=Ud(Q.current,w);$d(Q.current,{transition:"none",transform:Bd(w)?`translate3d(0, ${e}px, 0)`:`translate3d(${e}px, 0, 0)`})},500))},onNestedRelease:function(e,t){const r=Bd(w)?window.innerHeight:window.innerWidth,i=t?(r-jd)/r:1,n=t?-16:0;t&&$d(Q.current,{transition:`transform ${Gd.DURATION}s cubic-bezier(${Gd.EASE.join(",")})`,transform:Bd(w)?`scale(${i}) translate3d(0, ${n}px, 0)`:`scale(${i}) translate3d(${n}px, 0, 0)`})},keyboardIsOpen:K,modal:v,snapPointsOffset:ae,activeSnapPointIndex:ie,direction:w,shouldScaleBackground:o,setBackgroundColorOnScale:l,noBodyStyles:E,container:I,autoFocus:R}},i))}const qd=t.forwardRef(function({...e},r){const{overlayRef:i,snapPoints:n,onRelease:s,shouldFade:a,isOpen:o,modal:l,shouldAnimate:d}=bd(),c=Nd(r,i),u=n&&n.length>0;if(!l)return null;const h=t.useCallback(e=>s(e),[s]);return t.createElement(fd,{onMouseUp:h,ref:c,"data-vaul-overlay":"","data-vaul-snap-points":o&&u?"true":"false","data-vaul-snap-points-overlay":o&&a?"true":"false","data-vaul-animate":(null==d?void 0:d.current)?"true":"false",...e})});qd.displayName="Drawer.Overlay";const Xd=t.forwardRef(function({onPointerDownOutside:e,style:r,onOpenAutoFocus:i,...n},s){const{drawerRef:a,onPress:o,onRelease:l,onDrag:d,keyboardIsOpen:u,snapPointsOffset:h,activeSnapPointIndex:f,modal:p,isOpen:m,direction:g,snapPoints:v,container:y,handleOnly:b,shouldAnimate:E,autoFocus:w}=bd(),[S,T]=t.useState(!1),x=Nd(s,a),A=t.useRef(null),k=t.useRef(null),L=t.useRef(!1),I=v&&v.length>0;!function(){const{direction:e,isOpen:r,shouldScaleBackground:i,setBackgroundColorOnScale:n,noBodyStyles:s}=bd(),a=t.useRef(null),o=c(()=>document.body.style.backgroundColor,[]);function l(){return(window.innerWidth-26)/window.innerWidth}t.useEffect(()=>{if(r&&i){a.current&&clearTimeout(a.current);const t=document.querySelector("[data-vaul-drawer-wrapper]")||document.querySelector("[vaul-drawer-wrapper]");if(!t)return;n&&!s&&zd(document.body,{background:"black"}),zd(t,{transformOrigin:Bd(e)?"top":"left",transitionProperty:"transform, border-radius",transitionDuration:`${Gd.DURATION}s`,transitionTimingFunction:`cubic-bezier(${Gd.EASE.join(",")})`});const r=zd(t,{borderRadius:"8px",overflow:"hidden",...Bd(e)?{transform:`scale(${l()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`}:{transform:`scale(${l()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`}});return()=>{r(),a.current=window.setTimeout(()=>{o?document.body.style.background=o:document.body.style.removeProperty("background")},1e3*Gd.DURATION)}}},[r,i,o])}();function R(e){A.current=null,L.current=!1,l(e)}return t.useEffect(()=>{I&&window.requestAnimationFrame(()=>{T(!0)})},[]),t.createElement(pd,{"data-vaul-drawer-direction":g,"data-vaul-drawer":"","data-vaul-delayed-snap-points":S?"true":"false","data-vaul-snap-points":m&&I?"true":"false","data-vaul-custom-container":y?"true":"false","data-vaul-animate":(null==E?void 0:E.current)?"true":"false",...n,ref:x,style:h&&h.length>0?{"--snap-point-height":`${h[null!=f?f:0]}px`,...r}:r,onPointerDown:e=>{b||(null==n.onPointerDown||n.onPointerDown.call(n,e),A.current={x:e.pageX,y:e.pageY},o(e))},onOpenAutoFocus:e=>{null==i||i(e),w||e.preventDefault()},onPointerDownOutside:t=>{null==e||e(t),p&&!t.defaultPrevented?u.current&&(u.current=!1):t.preventDefault()},onFocusOutside:e=>{p||e.preventDefault()},onPointerMove:e=>{if(k.current=e,b)return;if(null==n.onPointerMove||n.onPointerMove.call(n,e),!A.current)return;const t=e.pageY-A.current.y,r=e.pageX-A.current.x,i="touch"===e.pointerType?10:2,s=((e,t,r=0)=>{if(L.current)return!0;const i=Math.abs(e.y),n=Math.abs(e.x),s=n>i,a=["bottom","right"].includes(t)?1:-1;if("left"===t||"right"===t){if(!(e.x*a<0)&&n>=0&&n<=r)return s}else if(!(e.y*a<0)&&i>=0&&i<=r)return!s;return L.current=!0,!0})({x:r,y:t},g,i);s?d(e):(Math.abs(r)>i||Math.abs(t)>i)&&(A.current=null)},onPointerUp:e=>{null==n.onPointerUp||n.onPointerUp.call(n,e),A.current=null,L.current=!1,l(e)},onPointerOut:e=>{null==n.onPointerOut||n.onPointerOut.call(n,e),R(k.current)},onContextMenu:e=>{null==n.onContextMenu||n.onContextMenu.call(n,e),k.current&&R(k.current)}})});Xd.displayName="Drawer.Content";const Qd=t.forwardRef(function({preventCycle:e=!1,children:r,...i},n){const{closeDrawer:s,isDragging:a,snapPoints:o,activeSnapPoint:l,setActiveSnapPoint:d,dismissible:c,handleOnly:u,isOpen:h,onPress:f,onDrag:p}=bd(),m=t.useRef(null),g=t.useRef(!1);function v(){m.current&&window.clearTimeout(m.current),g.current=!1}return t.createElement("div",{onClick:function(){g.current?v():window.setTimeout(()=>{!function(){if(a||e||g.current)return void v();if(v(),!o||0===o.length)return void(c||s());if(l===o[o.length-1]&&c)return void s();const t=o.findIndex(e=>e===l);if(-1===t)return;const r=o[t+1];d(r)}()},120)},onPointerCancel:v,onPointerDown:e=>{u&&f(e),m.current=window.setTimeout(()=>{g.current=!0},250)},onPointerMove:e=>{u&&p(e)},ref:n,"data-vaul-drawer-visible":h?"true":"false","data-vaul-handle":"","aria-hidden":"true",...i},t.createElement("span",{"data-vaul-handle-hitarea":"","aria-hidden":"true"},r))});Qd.displayName="Drawer.Handle";const Zd={Root:Kd,NestedRoot:function({onDrag:e,onOpenChange:r,open:i,...n}){const{onNestedDrag:s,onNestedOpenChange:a,onNestedRelease:o}=bd();if(!s)throw new Error("Drawer.NestedRoot must be placed in another drawer");return t.createElement(Kd,{nested:!0,open:i,onClose:()=>{a(!1)},onDrag:(t,r)=>{s(t,r),null==e||e(t,r)},onOpenChange:e=>{e&&a(e),null==r||r(e)},onRelease:o,...n})},Content:Xd,Overlay:qd,Trigger:ud,Portal:function(e){const r=bd(),{container:i=r.container,...n}=e;return t.createElement(hd,{container:i,...n})},Handle:Qd,Close:vd,Title:md,Description:gd};function Jd(t){var r=T(t,[]);return e.createElement(Zd.Root,Object.assign({"data-slot":"drawer"},r))}function ec(t){var r=T(t,[]);return e.createElement(Zd.Trigger,Object.assign({"data-slot":"drawer-trigger"},r))}function tc(t){var r=T(t,[]);return e.createElement(Zd.Portal,Object.assign({"data-slot":"drawer-portal"},r))}function rc(t){var{className:r}=t,i=T(t,["className"]);return e.createElement(Zd.Overlay,Object.assign({"data-slot":"drawer-overlay",className:wt("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-[999999] bg-black/50",r)},i))}function ic(t){var{className:r,children:i,container:n}=t,s=T(t,["className","children","container"]);return e.createElement(tc,{"data-slot":"drawer-portal",container:null!=n?n:void 0},e.createElement(rc,null),e.createElement(Zd.Content,Object.assign({"data-slot":"drawer-content",className:wt("group/drawer-content bg-background fixed z-[999999] flex h-auto flex-col","data-[vaul-drawer-direction=top]:inset-x-0 data-[vaul-drawer-direction=top]:top-0 data-[vaul-drawer-direction=top]:mb-24 data-[vaul-drawer-direction=top]:max-h-[80vh] data-[vaul-drawer-direction=top]:rounded-b-lg data-[vaul-drawer-direction=top]:border-b","data-[vaul-drawer-direction=bottom]:inset-x-0 data-[vaul-drawer-direction=bottom]:bottom-0 data-[vaul-drawer-direction=bottom]:mt-24 data-[vaul-drawer-direction=bottom]:max-h-[80vh] data-[vaul-drawer-direction=bottom]:rounded-t-lg data-[vaul-drawer-direction=bottom]:border-t","data-[vaul-drawer-direction=right]:inset-y-0 data-[vaul-drawer-direction=right]:right-0 data-[vaul-drawer-direction=right]:w-3/4 data-[vaul-drawer-direction=right]:border-l data-[vaul-drawer-direction=right]:sm:max-w-sm","data-[vaul-drawer-direction=left]:inset-y-0 data-[vaul-drawer-direction=left]:left-0 data-[vaul-drawer-direction=left]:w-3/4 data-[vaul-drawer-direction=left]:border-r data-[vaul-drawer-direction=left]:sm:max-w-sm",r)},s),e.createElement("div",{className:"bg-muted mx-auto mt-4 hidden h-2 w-[100px] shrink-0 rounded-full group-data-[vaul-drawer-direction=bottom]/drawer-content:block"}),i))}function nc(t){var{className:r}=t,i=T(t,["className"]);return e.createElement("div",Object.assign({"data-slot":"drawer-header",className:wt("flex flex-col gap-1.5 p-4",r)},i))}function sc(t){var{className:r}=t,i=T(t,["className"]);return e.createElement(Zd.Title,Object.assign({"data-slot":"drawer-title",className:wt("text-foreground font-semibold",r)},i))}const ac=t.createContext(null),oc=({children:e,products:r,contentId:i})=>{const{isPreview:n}=$a(),s=t.useContext(ac);return t.createElement(Jd,{direction:"right",fadeFromIndex:0,snapPoints:[1]},t.createElement(ec,{className:"w-full"},e),t.createElement(ic,{container:s},t.createElement(nc,null,t.createElement(sc,null,"상품 목록")),t.createElement("div",{className:"overflow-y-scroll grid-cols-2 grid items-baseline justify-items-center scrollbar-hide"},r.map(e=>e.linkPath?t.createElement("a",{key:e.productId,className:"p-2 text-gray-800 w-full h-full flex flex-col items-center justify-center no-underline",href:e.linkPath,target:"_blank",onClick:()=>x(void 0,void 0,void 0,function*(){n||(yield ka({contentId:i,contentProductId:e.eventProductId,productId:e.productId}))})},t.createElement(lc,{product:e})):t.createElement(lc,{key:e.productId,product:e})))))},lc=({product:e})=>{const r=$a(e=>e.memberOnly&&!e.isMemberLoggedIn);return t.createElement("div",{className:"text-gray-800 w-32"},t.createElement("div",{className:"w-full aspect-square mb-2 border border-[#f4f3f6] rounded "},t.createElement("img",{src:e.thumbPath,alt:e.productName,className:"w-full h-full"})),e.brand&&t.createElement("p",{className:"text-xs text-gray-400 mb-1"},e.brand.brandName),t.createElement("p",{className:"w-full text-[12px] md:text-[15px] mb-1"},e.productName),t.createElement("div",{className:"w-full "},r?t.createElement("span",{className:"font-semibold text-red-500"},"판매가 회원 공개"):t.createElement("div",{className:"flex"},t.createElement("span",{className:"text-sm text-red-500 mr-2 font-semibold"},e.discount,"%"),t.createElement("span",{className:"font-semibold"},St(e.sellingPrice),"원"))))},dc=({products:e,useDrawer:r,contentId:i})=>{const n=c(()=>(e=>{if(e.length>=3)return e;const t=[...e];for(;t.length<3;)t.push(...e);return t})(e),[e]),s=1===(null==e?void 0:e.length);return(null==e?void 0:e.length)?t.createElement("div",{className:"w-full",style:{height:"80px"}},s?t.createElement("div",{className:"bg-white overflow-hidden rounded-xl w-full",style:{borderRadius:"10px",height:"80px"}},r?t.createElement(oc,{products:e,contentId:i},t.createElement(Xa,{product:e[0],productsLength:e.length,contentId:i})):t.createElement(Xa,{product:e[0],productsLength:e.length,hideMoreBtn:!0,contentId:i})):t.createElement(Qs,{nested:!0,modules:[ha,ta],slidesPerView:1.1,effect:"cards",autoplay:!0,loop:!0,grabCursor:!0,cardsEffect:{rotate:!1},className:"w-full",style:{height:"80px"}},n.map((n,s)=>t.createElement(Zs,{key:s+n.productId,className:"bg-white overflow-hidden rounded-xl",style:{borderRadius:"10px",height:"80px"}},r?t.createElement(oc,{products:e,contentId:i},t.createElement(Xa,{product:n,productsLength:e.length,contentId:i})):t.createElement(Xa,{product:n,productsLength:e.length,hideMoreBtn:!0,contentId:i}))))):null},cc="https://mbus-asset.s3.ap-northeast-2.amazonaws.com/mcom-player",uc=({shortForm:e,useDrawer:r,isPopup:i,hideProductCarousel:n,hideOverlay:s,shareUrl:o,handleClose:l})=>{const[d,c]=a(!Boolean(i)),[u,h]=a(!0),f=()=>{c(e=>!e)},p=()=>{h(e=>!e)},{logo:m,productsInfo:g,thumbPath:v,title:y,media:b,brand:E,shortsId:w}=e,S=i?"mb-1 max-h-10 max-w-20 object-contain":"mb-1 max-h-10 max-w-28 object-contain",T=e=>{e.stopPropagation()},x=i?t.createElement("div",{className:"justify-self-end flex gap-2"},t.createElement("button",{className:"cursor-pointer text-white",onClick:p},t.createElement("div",{className:"glass-panel flex h-10 w-10 items-center justify-center rounded-full"},u?t.createElement(Or,{size:24}):t.createElement(Mr,{size:24}))),t.createElement("button",{className:"cursor-pointer text-white",onClick:f},t.createElement("div",{className:"glass-panel flex h-10 w-10 items-center justify-center rounded-full"},t.createElement("img",{src:`${cc}/${d?"sound_off":"sound"}.png`,alt:d?"muted":"volume",width:24,height:24,className:"block h-6 w-6 object-contain"}))),l?t.createElement("button",{className:"cursor-pointer text-white",onClick:l},t.createElement("div",{className:"glass-panel flex h-10 w-10 items-center justify-center rounded-full"},t.createElement(Br,{size:24}))):null):t.createElement("div",{className:"flex flex-col gap-3 items-end"},t.createElement("button",{type:"button",className:"text-white",onClick:e=>{T(e),f()},"aria-label":d?"음소거 해제":"음소거"},t.createElement("div",{className:"glass-panel flex h-10 w-10 items-center justify-center rounded-full"},t.createElement("img",{src:`${cc}/${d?"sound_off":"sound"}.png`,alt:d?"muted":"volume",width:24,height:24,className:"block h-6 w-6 object-contain"}))),l?t.createElement("button",{type:"button",className:"text-white",onClick:e=>{T(e),l()},"aria-label":"닫기"},t.createElement("div",{className:"glass-panel flex h-10 w-10 items-center justify-center rounded-full"},t.createElement(Br,{size:24}))):null);return t.createElement("div",{className:"h-full w-full text-sm overflow-hidden text-white relative",onClick:i?void 0:p},t.createElement("div",{className:"pointer-events-none absolute inset-0 z-[1] flex h-full w-full flex-col justify-between bg-gradient-to-b from-black/40 via-transparent to-black/40 p-4"},t.createElement("div",{className:"flex gap-2 justify-between pointer-events-auto",onClick:T},t.createElement("div",null,!s&&(null==m?void 0:m.thumbPath)?t.createElement("img",{className:S,src:m.thumbPath,alt:m.logoName,width:100,height:100}):null),!s&&x),t.createElement("div",{className:"h-full w-full"}),t.createElement("div",{className:"mb-6 pointer-events-auto",onClick:T},!s&&t.createElement("div",{className:"flex justify-between items-end mb-3 gap-3"},t.createElement("div",{className:"w-full"},E&&t.createElement("div",{className:"items-center flex gap-3 mb-2"},t.createElement("div",{className:"w-14 h-14 bg-white rounded-full border overflow-hidden shrink-0"},t.createElement("img",{src:E.thumbPath,alt:E.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==E?void 0:E.brandName)),t.createElement("p",{className:"text-start text-base line-clamp-2"},y)),t.createElement("div",{className:"flex flex-col gap-4 items-center"},t.createElement(Ua,{shortsId:w}),t.createElement("div",{className:"flex items-center justify-center"},t.createElement(qa,{shortForm:e,shareUrl:o})))),!n&&(null==g?void 0:g.length)>0&&t.createElement(dc,{products:g,useDrawer:r,contentId:e.shortsId}))),t.createElement(L,{file:Tt(null==b?void 0:b.objectId),thumbnail:`${Rt(v)}`,mute:d,isVertical:(null==b?void 0:b.height)>(null==b?void 0:b.width),play:u}))},hc="cursor-pointer text-zinc-500",fc=e=>{const{collection:i,shortform:n,setShortform:s}=e,a=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(Pr,{size:44,strokeWidth:1,className:hc,onClick:()=>{var e;null===(e=a.current)||void 0===e||e.swiper.slidePrev()}}),t.createElement(Lr,{size:44,strokeWidth:1,className:hc,onClick:()=>{var e;null===(e=a.current)||void 0===e||e.swiper.slideNext()}})),t.createElement("div",{className:"h-full aspect-[9/16] max-w-fit relative"},t.createElement(Qs,{modules:[Js,la],mousewheel:!0,direction:"vertical",slidesPerView:1,ref:a,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(Zs,{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(uc,{shortForm:n,hideProductCarousel:!0})),t.createElement("img",{src:Rt(e.thumbPath),alt:e.title,className:"w-full h-full bg-black "+(e.media.width>e.media.height?"object-contain":"object-cover")})))))))},pc=()=>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(Cr,{size:80,strokeWidth:1.2,className:"text-white"}),t.createElement("p",{className:"text-white"},"위아래로 스와이프 해보세요"))),mc=({collection:e,playerSettings:r})=>{const[i,n]=a(e.contents[0]),[s,o]=a(!0),l=u(()=>{s&&o(!1)},[s]);return t.createElement("div",{className:"flex-1 md:flex md:justify-center w-full h-full bg-black relative",onClick:l},s&&t.createElement(pc,null),t.createElement("div",{className:"h-full w-full"},t.createElement(Qs,{modules:[Js,la],loop:!0,mousewheel:!0,direction:"vertical",touchEventsTarget:"container",slidesPerView:1,onSlideChangeTransitionEnd:t=>{const r=e.contents[t.realIndex];n(Object.assign({},r))},className:"h-full md:aspect-[9/16] md:mx-auto"},e.contents.map(e=>t.createElement(Zs,{key:e.shortsId,className:"rounded-xl overflow-hidden"},i.shortsId===e.shortsId&&t.createElement("div",{className:"w-full h-full md:flex md:justify-center absolute z-[999]"},t.createElement(uc,{shortForm:i})),t.createElement("img",{src:Rt(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 gc='/*! 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-sm:24rem;--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)}.top-0{top:calc(var(--spacing)*0)}.top-1\\/2{top:50%}.top-4{top:calc(var(--spacing)*4)}.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)}.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-\\[999\\]{z-index:999}.z-\\[999999\\]{z-index:999999}.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)}.mt-auto{margin-top:auto}.mr-2{margin-right:calc(var(--spacing)*2)}.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-2{height:calc(var(--spacing)*2)}.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-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-auto{height:auto}.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-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-32{width:calc(var(--spacing)*32)}.w-36{width:calc(var(--spacing)*36)}.w-\\[24px\\]{width:24px}.w-\\[100px\\]{width:100px}.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-baseline{align-items:baseline}.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}.justify-items-center{justify-items:center}.gap-1{gap:calc(var(--spacing)*1)}.gap-1\\.5{gap:calc(var(--spacing)*1.5)}.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-y-auto{overflow-y:auto}.overflow-y-scroll{overflow-y:scroll}.rounded{border-radius:.25rem}.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-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}.border-\\[\\#f4f3f6\\]{border-color:#f4f3f6}.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-background{background-color:var(--background)}.bg-black{background-color:var(--color-black)}.bg-black\\/50{background-color:color-mix(in oklab,var(--color-black) 50%,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-muted{background-color:var(--muted)}.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}.p-0{padding:calc(var(--spacing)*0)}.p-1{padding:calc(var(--spacing)*1)}.p-2{padding:calc(var(--spacing)*2)}.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-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-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-\\[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-foreground{color:var(--foreground)}.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}.no-underline{text-decoration-line:none}.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}.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}.group-data-\\[vaul-drawer-direction\\=bottom\\]\\/drawer-content\\:block{&:is(:where(.group\\/drawer-content)[data-vaul-drawer-direction=bottom] *){display:block}}.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\\=closed\\]\\:animate-out{&[data-state=closed]{--tw-exit-opacity:initial;--tw-exit-scale:initial;--tw-exit-rotate:initial;--tw-exit-translate-x:initial;--tw-exit-translate-y:initial;animation-duration:.15s;animation-name:exit}}.data-\\[state\\=closed\\]\\:fade-out-0{&[data-state=closed]{--tw-exit-opacity:0}}.data-\\[state\\=open\\]\\:animate-in{&[data-state=open]{--tw-enter-opacity:initial;--tw-enter-scale:initial;--tw-enter-rotate:initial;--tw-enter-translate-x:initial;--tw-enter-translate-y:initial;animation-duration:.15s;animation-name:enter}}.data-\\[state\\=open\\]\\:fade-in-0{&[data-state=open]{--tw-enter-opacity:0}}.data-\\[vaul-drawer-direction\\=bottom\\]\\:inset-x-0{&[data-vaul-drawer-direction=bottom]{inset-inline:calc(var(--spacing)*0)}}.data-\\[vaul-drawer-direction\\=bottom\\]\\:bottom-0{&[data-vaul-drawer-direction=bottom]{bottom:calc(var(--spacing)*0)}}.data-\\[vaul-drawer-direction\\=bottom\\]\\:mt-24{&[data-vaul-drawer-direction=bottom]{margin-top:calc(var(--spacing)*24)}}.data-\\[vaul-drawer-direction\\=bottom\\]\\:max-h-\\[80vh\\]{&[data-vaul-drawer-direction=bottom]{max-height:80vh}}.data-\\[vaul-drawer-direction\\=bottom\\]\\:rounded-t-lg{&[data-vaul-drawer-direction=bottom]{border-top-left-radius:var(--radius);border-top-right-radius:var(--radius)}}.data-\\[vaul-drawer-direction\\=bottom\\]\\:border-t{&[data-vaul-drawer-direction=bottom]{border-top-style:var(--tw-border-style);border-top-width:1px}}.data-\\[vaul-drawer-direction\\=left\\]\\:inset-y-0{&[data-vaul-drawer-direction=left]{inset-block:calc(var(--spacing)*0)}}.data-\\[vaul-drawer-direction\\=left\\]\\:left-0{&[data-vaul-drawer-direction=left]{left:calc(var(--spacing)*0)}}.data-\\[vaul-drawer-direction\\=left\\]\\:w-3\\/4{&[data-vaul-drawer-direction=left]{width:75%}}.data-\\[vaul-drawer-direction\\=left\\]\\:border-r{&[data-vaul-drawer-direction=left]{border-right-style:var(--tw-border-style);border-right-width:1px}}.data-\\[vaul-drawer-direction\\=right\\]\\:inset-y-0{&[data-vaul-drawer-direction=right]{inset-block:calc(var(--spacing)*0)}}.data-\\[vaul-drawer-direction\\=right\\]\\:right-0{&[data-vaul-drawer-direction=right]{right:calc(var(--spacing)*0)}}.data-\\[vaul-drawer-direction\\=right\\]\\:w-3\\/4{&[data-vaul-drawer-direction=right]{width:75%}}.data-\\[vaul-drawer-direction\\=right\\]\\:border-l{&[data-vaul-drawer-direction=right]{border-left-style:var(--tw-border-style);border-left-width:1px}}.data-\\[vaul-drawer-direction\\=top\\]\\:inset-x-0{&[data-vaul-drawer-direction=top]{inset-inline:calc(var(--spacing)*0)}}.data-\\[vaul-drawer-direction\\=top\\]\\:top-0{&[data-vaul-drawer-direction=top]{top:calc(var(--spacing)*0)}}.data-\\[vaul-drawer-direction\\=top\\]\\:mb-24{&[data-vaul-drawer-direction=top]{margin-bottom:calc(var(--spacing)*24)}}.data-\\[vaul-drawer-direction\\=top\\]\\:max-h-\\[80vh\\]{&[data-vaul-drawer-direction=top]{max-height:80vh}}.data-\\[vaul-drawer-direction\\=top\\]\\:rounded-b-lg{&[data-vaul-drawer-direction=top]{border-bottom-left-radius:var(--radius);border-bottom-right-radius:var(--radius)}}.data-\\[vaul-drawer-direction\\=top\\]\\:border-b{&[data-vaul-drawer-direction=top]{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}}.data-\\[vaul-drawer-direction\\=left\\]\\:sm\\:max-w-sm,.sm\\:flex-row,.sm\\:justify-end,.sm\\:mx-0{&[data-vaul-drawer-direction=left]{@media (width >= 40rem){max-width:var(--container-sm)}}}.data-\\[vaul-drawer-direction\\=right\\]\\:sm\\:max-w-sm{&[data-vaul-drawer-direction=right]{@media (width >= 40rem){max-width:var(--container-sm)}}}.\\[\\&\\[data-state\\=open\\]\\>svg\\]\\:rotate-180,.lg\\:px-5,.md\\:aspect-\\[9\\/16\\],.md\\:flex,.md\\:justify-center,.md\\:mx-auto,.md\\:px-4,.md\\:text-\\[15px\\]{&[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);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)}.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-dialog-container{max-height:70vh;max-width:min(82vw,500px);overflow-y:auto;width:100%}.border{border:1px solid oklch(.922 0 0)}@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-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)}}',vc=gc.trim().length>0,yc="undefined"!=typeof window&&"adoptedStyleSheets"in Document.prototype&&"undefined"!=typeof CSSStyleSheet&&"replaceSync"in CSSStyleSheet.prototype;let bc=null;function Ec(e){return bc||(bc=new CSSStyleSheet,bc.replaceSync(e)),bc}function wc(){return vc?gc: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 Sc=({extra:e})=>{const r=wc()+(e?"\n"+e:"");return t.createElement("style",null,r)};const Tc=Fa(e=>({open:!1,setOpen:t=>e({open:t})}));function xc(){const[e,n]=t.useState(null),s=r(null),{open:a,setOpen:o}=Tc();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=wc();if(yc)e.adoptedStyleSheets=[Ec(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 Ac=e=>{const{isMobile:r}=e,n=$a(e=>e.setIsPreview),[s,o]=a("collection"in e?e.collection.contents[0]:null);if(i(()=>{var t;const r=$a.getState().isPreview;return n(null===(t=e.isPreview)||void 0===t||t),()=>{n(r)}},[e.isPreview,n]),r){if("shortform"in e)return t.createElement(uc,{shortForm:e.shortform});if(e.collection)return t.createElement(mc,{collection:e.collection,playerSettings:e.collection.player.shoppingPlayer})}if("shortform"in e){const{layout:r}=e.shortform.player,i=e.shortform.player.shoppingPlayer;switch(r){case br.PLATFORM:return t.createElement(Dn,{shortform:e.shortform,playerSettings:i,player:t.createElement("div",{className:"aspect-[9/16] h-full rounded-xl border overflow-hidden"},t.createElement(uc,{shortForm:e.shortform,hideProductCarousel:!0,hideOverlay:!0}))});case br.HORIZONTAL:return t.createElement(ma,{shortform:e.shortform,playerSettings:i,player:t.createElement("div",{className:"h-full aspect-[9/16]"},t.createElement(uc,{shortForm:e.shortform,hideProductCarousel:!0}))});case br.VERTICAL:return t.createElement(va,{shortform:e.shortform,playerSettings:i,player:t.createElement("div",{className:"aspect-[9/16] h-full"},t.createElement(uc,{shortForm:e.shortform,hideProductCarousel:!0}))});case br.GRID:return t.createElement(ba,{shortform:e.shortform,playerSettings:i,player:t.createElement("div",{className:"h-full aspect-[9/16]"},t.createElement(uc,{shortForm:e.shortform,hideProductCarousel:!0}))})}}else{if(!e.collection||!s)return null;{const{layout:r}=e.collection.player,i=e.collection.player.shoppingPlayer;switch(r){case br.PLATFORM:return t.createElement(Dn,{shortform:s,playerSettings:i,player:t.createElement("div",{className:"w-full flex items-center justify-center gap-4",style:{height:"calc(-220px + 100vh)"}},t.createElement(wa,{collection:e.collection,playerSettings:i,shortform:s,setShortform:o}))});case br.HORIZONTAL:return t.createElement(ma,{shortform:s,playerSettings:Object.assign({},i),player:t.createElement(fc,{collection:e.collection,playerSettings:i,shortform:s,setShortform:o})});case br.VERTICAL:return t.createElement(va,{playerSettings:Object.assign({},i),shortform:s,player:t.createElement(fc,{collection:e.collection,playerSettings:i,shortform:s,setShortform:o})});case br.GRID:return t.createElement(ba,{shortform:s,playerSettings:Object.assign({},i),player:t.createElement(fc,{collection:e.collection,playerSettings:i,shortform:s,setShortform:o})})}}}},kc=e=>{const{container:r}=xc();return r?t.createElement(Er.div,{style:{display:"block",width:"100%",height:"100%"}},t.createElement(Sc,null),t.createElement(ac.Provider,{value:r},t.createElement(Ac,Object.assign({},e)))):null},Lc=e=>{const{container:r}=xc();return r?t.createElement(Er.div,{style:{display:"block",width:"100%",height:"100%"}},t.createElement(Sc,null),t.createElement(ac.Provider,{value:r},t.createElement(uc,Object.assign({},e)))):null},Ic=e=>(document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}),Rc=()=>document.visibilityState,Pc=()=>{throw Error("useVisibilityChange is a client-only hook")};function Cc(){return"visible"===e.useSyncExternalStore(Ic,Rc,Pc)}var Dc=(e,t,n=!0)=>{const s=r(e),a=r(null),o=()=>{a.current&&(clearInterval(a.current),a.current=null)},l=u(()=>{a.current||(a.current=setInterval(()=>s.current(),t))},[t]);return i(()=>{s.current=e},[e]),i(()=>(n&&l(),()=>o()),[l,n]),{clear:o,run:l}};const _c=()=>{const[e,t]=a(0);Dc(()=>{t(e=>e+1)},1e3);return{playtime:e,resetPlaytime:()=>t(0)}},Oc=t.createContext(null),Mc=({children:e})=>{const r=t.useRef(null);return r.current||(r.current=_a(e=>({collection:null,setCollection:t=>e({collection:t}),nextKey:"",setNextKey:t=>e({nextKey:t}),isFetching:!1,setIsFetching:t=>e({isFetching:t})}))),t.createElement(Oc.Provider,{value:r.current},e)},Nc=()=>(e=>{const r=t.useContext(Oc);if(!r)throw new Error("Missing CollectionProvider");return Ma(r,e)})(e=>e),Fc=(e,t)=>{const{collection:r,setCollection:n,isFetching:s,setIsFetching:a,nextKey:o,setNextKey:l}=Nc(),{isPreview:d}=$a(),c=(null==e?void 0:e.media)?e.media.duration.split(":").reduce((e,t,r)=>e+ +t*60**(2-r),0):0;const{resetPlaytime:u,playtime:h}=_c(),{playtime:f,resetPlaytime:p}=_c(),m=Cc(),g=()=>{if(!r)return;const{colId:t,uuid:i,userId:n}=r,s=Ge,a=Math.floor((new Date).getTime()/1e3);localStorage.setItem(s,a.toString()),d||(Aa({contentId:t,uuid:i,type:Et.COLLECTION,userId:n,playtime:f}),e&&Aa({contentId:e.shortsId,uuid:e.uuid,type:Et.SHORTS,userId:n,playtime:h,isFinished:h>=c}),p(),u())};i(()=>{m||g()},[m]);return{onSlideChange:i=>x(void 0,void 0,void 0,function*(){if(e&&r&&(yield(e=>x(void 0,void 0,void 0,function*(){var t,i;if(!r)return;const{contents:d,count:c}=r;if((null!=c?c:Number.MAX_SAFE_INTEGER)>d.length&&e>=d.length-5&&!s){a(!0);try{const e=yield Ra({collectionId:r.colId,nextKey:o});if(!e||!(null===(t=e.contents)||void 0===t?void 0:t.length))return;l((null===(i=e.contents.at(-1))||void 0===i?void 0:i.shortsId)||"");const s=new Set(r.contents.map(e=>e.shortsId)),a=e.contents.filter(e=>!s.has(e.shortsId));if(!a.length)return;const d=r.contents.concat(a);n(Object.assign(Object.assign({},r),{contents:d}))}catch(e){console.error(e)}finally{a(!1)}}}))(i),!d)){const{shortsId:n,uuid:s,userId:a}=e;Aa({contentId:n,uuid:s,type:Et.SHORTS,playtime:h,isFinished:h>=c,userId:a}),u();const o=kt(),l=r.contents[i];t(Object.assign(Object.assign({},l),{uuid:o})),yield xa({contentId:l.shortsId,uuid:o,type:Et.SHORTS,userId:l.userId,isFirstPlay:!Lt(l.shortsId)})}}),onCollectionClose:g}};function $c(){const[e,t]=a({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 Bc=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(${Rt(e.thumbPath)})`}},t.createElement(uc,{handleClose:i,shortForm:e,useDrawer:!1,isPopup:!0,shareUrl:r})))),Uc=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}`})`}})),zc=({shortform:e,shareUrl:r,handleClose:i})=>{const{isActive:n}=d(qs),s=d(Xs),a=$c().width<430||Ya.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(Ir,{size:28})),t.createElement(Bc,{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(Rr,{size:28}))):t.createElement(Uc,{shortform:e})))},{PLAYER_BACK_BASE_URL:Gc}=gt(),jc=({collection:e,initialShortsId:i,onSlideChange:n,onClosePlayer:s})=>{var a;const o=c(()=>Math.max(e.contents.findIndex(e=>e.shortsId===i),0),[e.contents,i]),l=e.contents.length,d=Math.max(l,10),u=null!==(a=$c().width)&&void 0!==a?a:0,h=u<430||Ya.isMobile,f=h?1:u>=1200?4:u>=900?3:2,p=c(()=>(e=>{const t=[...e];for(;t.length<d;)t.push(...e);return t})(e.contents),[e.contents]),m=r(null);return t.createElement("div",{style:{minHeight:100,minWidth:300},className:"w-full"},t.createElement(Qs,{style:{minHeight:100,overflow:"visible"},initialSlide:o,ref:m,lazyPreloadPrevNext:2,className:"w-full",spaceBetween:h?8:u>=1200?24:u>=900?25:16,slidesPerView:f,grabCursor:!0,centeredSlides:1!==f,onSlideChangeTransitionEnd:t=>{const r=t.realIndex%l;null==n||n(r);const i=e.contents[(r+1)%l];var s;s=Tt(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:!0,slideToClickedSlide:!0},p.map((r,i)=>t.createElement(Zs,{key:i},t.createElement(zc,{handleClose:s,shortform:r,shareUrl:`${Gc}/collection/${e.colId}?start=${r.shortsId}&layout=5`})))))},Hc=({shortform:e,onThumbnailClick:n,onCardView:s,iconSize:a,exposeTitle:o,borderLine:l})=>{const d=c(()=>It(l),[l]),u=r(null);i(()=>{const t=u.current;if(!t)return;const r=new IntersectionObserver(([t])=>{t.isIntersecting&&(s(e.shortsId),r.disconnect())},{threshold:.5});return r.observe(t),()=>r.disconnect()},[e.shortsId,s]);const h=d?{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",{ref:u,className:"flex flex-col w-full gap-2",onClick:()=>n(e.shortsId)},t.createElement("div",{className:"rounded-full overflow-hidden cursor-pointer",style:Object.assign({width:a,height:a,padding:4},h)},t.createElement("img",{src:Rt(e.thumbPath),alt:"thumbnail",className:"w-full h-full object-cover block rounded-full"})),o&&t.createElement("span",{style:{width:a},className:"text-black overflow-hidden text-[12px] whitespace-nowrap text-center text-clip cursor-default"},e.title))},Vc=({product:e,productLength:r,hideMoreBadge:i=!1,contentId:n,lineClamp:s,showMoreBtn:a=!1,openProductPopup:o})=>{const{isPreview:l}=$a();return t.createElement(t.Fragment,null,t.createElement("div",{className:"product-banner border mbus-border",onClick:()=>x(void 0,void 0,void 0,function*(){i&&(window.open(e.linkPath,"_blank"),l||(yield ka({contentProductId:e.eventProductId,contentId:n,productId:e.productId})))})},t.createElement("span",{className:"product-banner__clip","aria-hidden":!0},t.createElement("span",{className:"product-banner__sheen"})),t.createElement("div",{className:"relative",style:{width:"40%",minWidth:"40%"}},t.createElement("img",{style:{borderRadius:"0.625rem"},className:"aspect-square rounded-lg object-cover w-full",src:Rt(e.thumbPath),alt:e.productName}),!i&&t.createElement("p",{className:"absolute text-white rounded-lg",style:{backgroundColor:"#797979",top:-10,right:-10,padding:"2px 4px",fontSize:"10px",borderRadius:"0.625rem"}},"+",r)),t.createElement("div",{style:{position:"relative",zIndex:2,minWidth:0,flex:1,paddingRight:24}},t.createElement("p",{style:{display:"-webkit-box",WebkitLineClamp:s||2,WebkitBoxOrient:"vertical",overflow:"hidden",wordBreak:"break-word",fontWeight:600,color:"#494949"}},e.productName)),t.createElement("span",{className:"product-banner__arrow","aria-hidden":!0},"›")),a&&r>1&&t.createElement("div",{onClick:o,className:" flex items-center justify-center border mbus-border cursor-pointer",style:{borderRadius:"0.625rem",padding:"10px",backgroundColor:"#f5f5f5",fontWeight:600}},"+ 더보기 (",r,")"))},Wc=({products:e,iconSize:r,contentId:i,setSelectedProducts:n,showMoreBtn:s,hideMoreBadge:a})=>{const{setOpen:o}=Tc(),l=()=>{n({productsInfo:e,shortsId:i}),o(!0)};return t.createElement(t.Fragment,null,t.createElement("div",{onClick:()=>x(void 0,void 0,void 0,function*(){1===e.length||s||l()}),className:"flex flex-col gap-2 mt-4 text-gray-800",style:{maxWidth:r||"100%",fontSize:13}},t.createElement(Vc,{showMoreBtn:s,lineClamp:2,product:e[0],contentId:i,productLength:e.length,hideMoreBadge:null!=a?a:1===e.length,openProductPopup:l})))},Yc=({product:e,maxWidth:r="100%",height:i,cardWidth:n})=>{const s=$a(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:Rt(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}},St(e.sellingPrice),"원"),t.createElement("span",{style:{color:"#9ca3af",textDecoration:"line-through"}},St(e.price),"원")):t.createElement("span",{style:{color:"#dc2626",fontWeight:600}},St(e.sellingPrice),"원"):t.createElement("span",{style:{color:"#dc2626",fontWeight:600}},St(e.price),"원")})())))},Kc=({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"})),qc=({shortform:e,onThumbnailClick:n,onCardView:s,iconSize:o,exposeTitle:l,rounded:d,borderLine:u,titlePosition:h,exposeProductBanner:f,setSelectedProducts:p,iconRatio:m,hoverPlay:g,exposeProductBadge:v})=>{var y;const b=c(()=>It(u),[u]),[E,w]=a(!1),{API_BASE_URL:S}=gt(),T=r(null);return i(()=>{const t=T.current;if(!t)return;const r=new IntersectionObserver(([t])=>{t.isIntersecting&&(s(e.shortsId),r.disconnect())},{threshold:.5});return r.observe(t),()=>r.disconnect()},[e.shortsId,s]),t.createElement("div",{className:"relative"},t.createElement("div",{ref:T,onMouseEnter:()=>{w(!0),s(e.shortsId)},onMouseLeave:()=>w(!1),onClick:()=>n(e.shortsId),style:Object.assign({width:o,aspectRatio:m},d&&{borderRadius:"10px"}),className:`cursor-pointer p-[3px] ${d&&"rounded-xl"} ${b&&"bg-insta"} relative overflow-hidden`},E&&g&&t.createElement(Kc,{playUrl:`${S}/direct/${e.media.objectId}`,poster:Rt(e.thumbPath)}),t.createElement("img",{style:Object.assign({},d&&{borderRadius:"10px"}),src:Rt(e.thumbPath),alt:"thumbnail",className:`w-full h-full object-cover ${d&&"rounded-xl"}`}),v&&(null===(y=e.productsInfo)||void 0===y?void 0:y.length)>0&&!(g&&E)&&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(Yc,{product:e.productsInfo[0],maxWidth:"100%",height:"100%",cardWidth:o})))),l&&!(g&&E&&h===Be.INNER)&&t.createElement("p",{style:Object.assign({width:o,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},h===Be.INNER&&v?{bottom:"22%"}:{}),className:`my-2 ${h===Be.INNER?"absolute bottom-0 left-0 text-white px-2 z-10":""} text-[12px] cursor-default truncate`},e.title),f&&t.createElement(Wc,{setSelectedProducts:p,products:e.productsInfo,iconSize:o,contentId:e.shortsId}))},Xc=e=>{const{iconShape:r,collection:i}=e;return r===Ne.MANY?t.createElement(Qc,Object.assign({},e)):t.createElement(Zc,Object.assign({},e,{shortform:i.contents[0]}))},Qc=e=>{const{collection:r}=e,{thumbnailAutoPlay:i}=e,{setCollection:n,nextKey:s,setNextKey:a,isFetching:o,setIsFetching:l}=Nc();return t.createElement(Qs,{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 Ra({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?[ta]:[],autoplay:!!i&&{delay:3e3,disableOnInteraction:!1,pauseOnMouseEnter:!0},loop:i||void 0},null==r?void 0:r.contents.map(r=>t.createElement(Zs,{key:r.shortsId,className:"!w-auto"},t.createElement(Zc,Object.assign({},e,{shortform:r})))))},Zc=e=>{const{iconForm:r}=e;return r===Me.INSTA?t.createElement(Hc,Object.assign({},e)):t.createElement(qc,Object.assign({},e))};function Jc(e,t,{checkForDefaultPrevented:r=!0}={}){return function(i){if(e?.(i),!1===r||!i.defaultPrevented)return t?.(i)}}function eu(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function tu(...e){return t=>{let r=!1;const i=e.map(e=>{const i=eu(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():eu(e[t],null)}}}}function ru(...t){return e.useCallback(tu(...t),t)}function iu(...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 nu=globalThis?.document?e.useLayoutEffect:()=>{},su=e[" useId ".trim().toString()]||(()=>{}),au=0;function ou(t){const[r,i]=e.useState(su());return nu(()=>{t||i(e=>e??String(au++))},[t]),t||(r?`radix-${r}`:"")}var lu=e[" useInsertionEffect ".trim().toString()]||nu;function du({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 lu(()=>{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,d=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 c=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[d,c]}function cu(e,t,{checkForDefaultPrevented:r=!0}={}){return function(i){if(e?.(i),!1===r||!i.defaultPrevented)return t?.(i)}}function uu(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function hu(...e){return t=>{let r=!1;const i=e.map(e=>{const i=uu(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():uu(e[t],null)}}}}function fu(...t){return e.useCallback(hu(...t),t)}function pu(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?hu(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 mu=Symbol("radix.slottable");function gu(t){return e.isValidElement(t)&&"function"==typeof t.type&&"__radixId"in t.type&&t.type.__radixId===mu}var vu=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((t,r)=>{const i=function(t){const r=pu(t),i=e.forwardRef((t,i)=>{const{children:n,...s}=t,a=e.Children.toArray(n),o=a.find(gu);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}(`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}},{});var yu,bu="dismissableLayer.update",Eu="dismissableLayer.pointerDownOutside",wu="dismissableLayer.focusOutside",Su=e.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Tu=e.forwardRef((t,r)=>{const{disableOutsidePointerEvents:i=!1,onEscapeKeyDown:n,onPointerDownOutside:s,onFocusOutside:a,onInteractOutside:o,onDismiss:l,...d}=t,c=e.useContext(Su),[u,h]=e.useState(null),f=u?.ownerDocument??globalThis?.document,[,p]=e.useState({}),m=fu(r,e=>h(e)),g=Array.from(c.layers),[v]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),y=g.indexOf(v),E=u?g.indexOf(u):-1,w=c.layersWithOutsidePointerEventsDisabled.size>0,S=E>=y,T=function(t,r=globalThis?.document){const i=po(t),n=e.useRef(!1),s=e.useRef(()=>{});return e.useEffect(()=>{const e=e=>{if(e.target&&!n.current){let t=function(){Au(Eu,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=[...c.branches].some(e=>e.contains(t));S&&!r&&(s?.(e),o?.(e),e.defaultPrevented||l?.())},f),x=function(t,r=globalThis?.document){const i=po(t),n=e.useRef(!1);return e.useEffect(()=>{const e=e=>{if(e.target&&!n.current){Au(wu,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;[...c.branches].some(e=>e.contains(t))||(a?.(e),o?.(e),e.defaultPrevented||l?.())},f);return mo(e=>{E===c.layers.size-1&&(n?.(e),!e.defaultPrevented&&l&&(e.preventDefault(),l()))},f),e.useEffect(()=>{if(u)return i&&(0===c.layersWithOutsidePointerEventsDisabled.size&&(yu=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(u)),c.layers.add(u),xu(),()=>{i&&1===c.layersWithOutsidePointerEventsDisabled.size&&(f.body.style.pointerEvents=yu)}},[u,f,i,c]),e.useEffect(()=>()=>{u&&(c.layers.delete(u),c.layersWithOutsidePointerEventsDisabled.delete(u),xu())},[u,c]),e.useEffect(()=>{const e=()=>p({});return document.addEventListener(bu,e),()=>document.removeEventListener(bu,e)},[]),b(vu.div,{...d,ref:m,style:{pointerEvents:w?S?"auto":"none":void 0,...t.style},onFocusCapture:cu(t.onFocusCapture,x.onFocusCapture),onBlurCapture:cu(t.onBlurCapture,x.onBlurCapture),onPointerDownCapture:cu(t.onPointerDownCapture,T.onPointerDownCapture)})});Tu.displayName="DismissableLayer";function xu(){const e=new CustomEvent(bu);document.dispatchEvent(e)}function Au(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(Su),n=e.useRef(null),s=fu(r,n);return e.useEffect(()=>{const e=n.current;if(e)return i.branches.add(e),()=>{i.branches.delete(e)}},[i.branches]),b(vu.div,{...t,ref:s})}).displayName="DismissableLayerBranch";var ku=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,d]=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=Lu(n.current);a.current="mounted"===l?e:"none"},[l]),nu(()=>{const e=n.current,r=s.current;if(r!==t){const i=a.current,n=Lu(e);if(t)d("MOUNT");else if("none"===n||"none"===e?.display)d("UNMOUNT");else{d(r&&i!==n?"ANIMATION_OUT":"UNMOUNT")}s.current=t}},[t,d]),nu(()=>{if(r){let e;const t=r.ownerDocument.defaultView??window,i=i=>{const a=Lu(n.current).includes(i.animationName);if(i.target===r&&a&&(d("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=Lu(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)}}d("ANIMATION_END")},[r,d]),{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=ru(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 Lu(e){return e?.animationName||"none"}function Iu(t){const r=Ru(t),i=e.forwardRef((t,i)=>{const{children:n,...s}=t,a=e.Children.toArray(n),o=a.find(Cu);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 Ru(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?tu(r,t):t),e.cloneElement(i,s)}return e.Children.count(i)>1?e.Children.only(null):null});return r.displayName=`${t}.SlotClone`,r}ku.displayName="Presence";var Pu=Symbol("radix.slottable");function Cu(t){return e.isValidElement(t)&&"function"==typeof t.type&&"__radixId"in t.type&&t.type.__radixId===Pu}var Du=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((t,r)=>{const i=Iu(`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}},{}),_u=0;function Ou(){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 Mu="Dialog",[Nu,Fu]=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,d=e.useMemo(()=>o,Object.values(o));return b(l.Provider,{value:d,children:n})};return o.displayName=r+"Provider",[o,function(i,o){const l=o?.[t]?.[a]||s,d=e.useContext(l);if(d)return d;if(void 0!==n)return n;throw new Error(`\`${i}\` must be used within \`${r}\``)}]},iu(n,...r)]}(Mu),[$u,Bu]=Nu(Mu),Uu=t=>{const{__scopeDialog:r,children:i,open:n,defaultOpen:s,onOpenChange:a,modal:o=!0}=t,l=e.useRef(null),d=e.useRef(null),[c,u]=du({prop:n,defaultProp:s??!1,onChange:a,caller:Mu});return b($u,{scope:r,triggerRef:l,contentRef:d,contentId:ou(),titleId:ou(),descriptionId:ou(),open:c,onOpenChange:u,onOpenToggle:e.useCallback(()=>u(e=>!e),[u]),modal:o,children:i})};Uu.displayName=Mu;var zu="DialogTrigger";e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=Bu(zu,r),s=ru(t,n.triggerRef);return b(Du.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":oh(n.open),...i,ref:s,onClick:Jc(e.onClick,n.onOpenToggle)})}).displayName=zu;var Gu="DialogPortal",[ju,Hu]=Nu(Gu,{forceMount:void 0}),Vu=t=>{const{__scopeDialog:r,forceMount:i,children:n,container:s}=t,a=Bu(Gu,r);return b(ju,{scope:r,forceMount:i,children:e.Children.map(n,e=>b(ku,{present:i||a.open,children:b(Oo,{asChild:!0,container:s,children:e})}))})};Vu.displayName=Gu;var Wu="DialogOverlay",Yu=e.forwardRef((e,t)=>{const r=Hu(Wu,e.__scopeDialog),{forceMount:i=r.forceMount,...n}=e,s=Bu(Wu,e.__scopeDialog);return s.modal?b(ku,{present:i||s.open,children:b(qu,{...n,ref:t})}):null});Yu.displayName=Wu;var Ku=Iu("DialogOverlay.RemoveScroll"),qu=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=Bu(Wu,r);return b(Tl,{as:Ku,allowPinchZoom:!0,shards:[n.contentRef],children:b(Du.div,{"data-state":oh(n.open),...i,ref:t,style:{pointerEvents:"auto",...i.style}})})}),Xu="DialogContent",Qu=e.forwardRef((e,t)=>{const r=Hu(Xu,e.__scopeDialog),{forceMount:i=r.forceMount,...n}=e,s=Bu(Xu,e.__scopeDialog);return b(ku,{present:i||s.open,children:s.modal?b(Zu,{...n,ref:t}):b(Ju,{...n,ref:t})})});Qu.displayName=Xu;var Zu=e.forwardRef((t,r)=>{const i=Bu(Xu,t.__scopeDialog),n=e.useRef(null),s=ru(r,i.contentRef,n);return e.useEffect(()=>{const e=n.current;if(e)return Pl(e)},[]),b(eh,{...t,ref:s,trapFocus:i.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Jc(t.onCloseAutoFocus,e=>{e.preventDefault(),i.triggerRef.current?.focus()}),onPointerDownOutside:Jc(t.onPointerDownOutside,e=>{const t=e.detail.originalEvent,r=0===t.button&&!0===t.ctrlKey;(2===t.button||r)&&e.preventDefault()}),onFocusOutside:Jc(t.onFocusOutside,e=>e.preventDefault())})}),Ju=e.forwardRef((t,r)=>{const i=Bu(Xu,t.__scopeDialog),n=e.useRef(!1),s=e.useRef(!1);return b(eh,{...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()}})}),eh=e.forwardRef((t,r)=>{const{__scopeDialog:i,trapFocus:n,onOpenAutoFocus:s,onCloseAutoFocus:a,...o}=t,l=Bu(Xu,i),d=e.useRef(null),c=ru(r,d);return e.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Ou()),document.body.insertAdjacentElement("beforeend",e[1]??Ou()),_u++,()=>{1===_u&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),_u--}},[]),w(E,{children:[b(Lo,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:s,onUnmountAutoFocus:a,children:b(Tu,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":oh(l.open),...o,ref:c,onDismiss:()=>l.onOpenChange(!1)})}),w(E,{children:[b(uh,{titleId:l.titleId}),b(hh,{contentRef:d,descriptionId:l.descriptionId})]})]})}),th="DialogTitle",rh=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=Bu(th,r);return b(Du.h2,{id:n.titleId,...i,ref:t})});rh.displayName=th;var ih="DialogDescription",nh=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=Bu(ih,r);return b(Du.p,{id:n.descriptionId,...i,ref:t})});nh.displayName=ih;var sh="DialogClose",ah=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=Bu(sh,r);return b(Du.button,{type:"button",...i,ref:t,onClick:Jc(e.onClick,()=>n.onOpenChange(!1))})});function oh(e){return e?"open":"closed"}ah.displayName=sh;var lh="DialogTitleWarning",[dh,ch]=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}\``)}]}(lh,{contentName:Xu,titleName:th,docsSlug:"dialog"}),uh=({titleId:t})=>{const r=ch(lh),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},hh=({contentRef:t,descriptionId:r})=>{const i=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${ch("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},fh=Uu,ph=Vu,mh=Yu,gh=Qu,vh=rh,yh=ah;function bh(t){return e.createElement(fh,Object.assign({"data-slot":"dialog"},t))}function Eh(t){var r=T(t,[]);return e.createElement(ph,Object.assign({"data-slot":"dialog-portal"},r))}function wh(t){var{className:r}=t,i=T(t,["className"]);return e.createElement(mh,Object.assign({"data-slot":"dialog-overlay",className:wt("fixed inset-0 z-50 bg-black/50",r)},i))}function Sh(t){var{className:r,children:i,showCloseButton:n=!0,container:s}=t,a=T(t,["className","children","showCloseButton","container"]);return e.createElement(Eh,{"data-slot":"dialog-portal",container:s},e.createElement(wh,null),e.createElement(gh,Object.assign({"data-slot":"dialog-content",style:{left:"50%",top:"50%",transform:"translate(-50%, -50%)",outline:"none"},className:wt("fixed","z-50 grid w-full max-w-lg sm:mx-0 gap-4 p-6",r)},a),i,n&&e.createElement(yh,{"data-slot":"dialog-close",style:{right:"calc(var(--spacing) * 4)",top:"calc(var(--spacing) * 4)",outline:"none"},className:wt("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(Br,{className:"h-4 w-4 pointer-events-none shrink-0",style:{height:"calc(var(--spacing) * 4)",width:"calc(var(--spacing) * 4)"}}))))}function Th(t){var{className:r}=t,i=T(t,["className"]);return e.createElement("div",Object.assign({"data-slot":"dialog-header",className:wt("flex flex-col gap-2 text-left",r)},i))}function xh(t){var{className:r}=t,i=T(t,["className"]);return e.createElement(vh,Object.assign({"data-slot":"dialog-title",className:wt("text-lg leading-none font-semibold",r)},i))}function Ah({title:e,children:r,contentClassName:i,hideCloseButton:n=!1,portalContainer:s,description:a}){const{open:o,setOpen:l}=Tc();return t.createElement(bh,{open:o,onOpenChange:l},t.createElement(Sh,{container:s,className:i,showCloseButton:!n},e&&t.createElement(Th,null,t.createElement(xh,{style:{color:"#494949"}},e||""),t.createElement(nh,{style:{color:"#5e5e5e",fontSize:"12.5px"}},a||"")),r))}const kh=({products:e,contentId:r})=>{const i=$c().width<430||Ya.isMobile;return t.createElement("div",{onWheel:e=>e.stopPropagation(),onTouchMove:e=>e.stopPropagation(),className:"grid gap-2 "+(i?"grid-cols-1":"grid-cols-2"),style:{fontSize:13}},e.map(i=>t.createElement(Vc,{key:i.productId,product:i,hideMoreBadge:!0,productLength:e.length,contentId:r})))},Lh=({widgetPlayerOption:e,setCollectionUuid:n,portalContainer:s})=>{const{PLAYER_BASE_URL:o}=gt(),{player:l}=e,[d,c]=a(null),{collection:h}=Nc(),{isPreview:f}=$a(),{onSlideChange:p,onCollectionClose:m}=Fc(d,c),g=r(new Set),v=r(null),y=u(e=>{f||h&&(g.current.has(e)||(g.current.add(e),xa({contentId:e,uuid:kt(),type:Et.SHORTS,userId:h.userId,isFirstPlay:!Lt(e)}).catch(e=>console.error("Error joining shorts PV:",e))))},[f,h]);i(()=>{if(f)return;if(!h)return;if(v.current===h.colId)return;v.current=h.colId;const e=kt();n(e),xa({contentId:h.colId,uuid:e,type:Et.COLLECTION,userId:h.userId,isFirstPlay:!Lt(h.colId)}).catch(e=>console.error("Error joining collection PV:",e))},[f,null==h?void 0:h.colId]);const{setOpen:b,open:E}=Tc();i(()=>{E||(d&&(m(),c(null)),w&&S(null))},[E]);const[w,S]=a();return t.createElement(t.Fragment,null,h&&t.createElement(Xc,Object.assign({collection:h},e,{onThumbnailClick:e=>x(void 0,void 0,void 0,function*(){if(l===$e.POPUP){const t=kt();if(c(Object.assign(Object.assign({},h.contents.find(t=>t.shortsId===e)),{uuid:t})),b(!0),f)return;try{yield xa({contentId:e,uuid:t,type:Et.SHORTS,userId:h.userId,isFirstPlay:!Lt(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}})(l),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(`${o}/collection/${h.colId}?${n.toString()}`)}}),onCardView:y,setSelectedProducts:S})),w&&t.createElement(Ah,{portalContainer:s,title:"상품 목록",contentClassName:"bg-white rounded p-4 product-dialog-container",description:"상품 정보를 확인해 보세요"},t.createElement(kh,{products:w.productsInfo,contentId:w.shortsId})),h&&d&&t.createElement(Ah,{portalContainer:s,hideCloseButton:!0,contentClassName:"w-full max-w-none p-0 mx-0"},t.createElement(jc,{collection:h,initialShortsId:d.shortsId,onClosePlayer:()=>x(void 0,void 0,void 0,function*(){m(),b(!1)}),onSlideChange:p})))};const Ih=e=>{const{collectionId:r,isPreview:n,priceText:s,memberOnly:a,container:o}=e,{setIsPreview:l,setPriceText:d,setMemberOnly:c,setIsMemberLoggedIn:u}=$a(),{setCollection:h,setNextKey:f,collection:p}=Nc();i(()=>{s&&d(s);const e=Boolean(n);e&&l(e),a&&(c(!0),u(Boolean(window.MEMBER_UID)))},[]),i(()=>{x(void 0,void 0,void 0,function*(){var e;const t=yield Ra({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,d,c,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!==(d=e.exposeProductBanner)&&void 0!==d&&d,exposeProductBadge:null!==(c=e.exposeProductBadge)&&void 0!==c&&c,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}=Nc(),d=t.useRef(null),[c,u]=t.useState(0);return t.useEffect(()=>{if(!d.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(d.current),()=>e.disconnect()},[]),t.useEffect(()=>{var e;if(!i||!i.contents)return;const t=Math.max(1,r+12),d=Math.ceil((c||0)/t)+4,u=null!==(e=i.count)&&void 0!==e?e:Number.MAX_SAFE_INTEGER,h=Math.min(u,d);if(i.contents.length>=h||o)return;let f=!1;return(()=>{x(this,void 0,void 0,function*(){var e,t,r,o,d;try{l(!0);let c=i,u=s||(null===(e=c.contents.at(-1))||void 0===e?void 0:e.shortsId)||void 0;const p=new Set(c.contents.map(e=>e.shortsId));for(;!f&&c.contents.length<h;){const e=Math.max(6,h-c.contents.length),i=yield Ra({collectionId:c.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)),c=Object.assign(Object.assign({},c),{contents:[...c.contents,...s]}),n(c),a(u||""),c.contents.length>=(null!==(d=c.count)&&void 0!==d?d: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,c,r,o,s,n,l,a]),{containerRef:d}}({collectionId:r,iconSize:m.iconSize});return t.createElement(Er.div,null,t.createElement(Sc,null),t.createElement("div",{ref:g},t.createElement(Lh,{widgetPlayerOption:m,setCollectionUuid:e=>{h(Object.assign(Object.assign({},p),{uuid:e}))},portalContainer:o})))},Rh=e=>{const{container:r}=xc();return r?t.createElement(Mc,null,t.createElement(Ih,Object.assign({},e,{container:r}))):null},Ph=({portalContainer:e,aspectRatio:r})=>{var n;const{collection:s,setNextKey:o}=Nc(),[l,d]=a(),{setOpen:c,open:u}=Tc();i(()=>{u||l&&d(null)},[u]);const h=(null!==(n=$c().width)&&void 0!==n?n:0)<430||Ya.isMobile;return t.createElement(t.Fragment,null,t.createElement("div",{className:"grid gap-4",style:{gridTemplateColumns:`repeat(${h?2:5}, 1fr)`}},null==s?void 0:s.contents.map(e=>t.createElement("div",null,t.createElement("div",{className:"overflow-hidden",style:{borderRadius:"0.625rem",aspectRatio:null!=r?r:"9/16"}},t.createElement("video",{loop:!0,className:"w-full h-full object-cover",muted:!0,autoPlay:!0,playsInline:!0,src:Tt(e.media.objectId),poster:Rt(e.thumbPath)})),t.createElement(Wc,{hideMoreBadge:!0,showMoreBtn:!0,products:e.productsInfo,contentId:e.shortsId,setSelectedProducts:d})))),l&&t.createElement(Ah,{portalContainer:e,title:"상품 목록",contentClassName:"bg-white rounded p-4 product-dialog-container",description:"연결된 전체 상품 정보를 확인해 보세요"},t.createElement(kh,{products:l.productsInfo,contentId:l.shortsId})))},Ch=({collectionId:e,aspectRatio:r,container:n,isPreview:s})=>{const{setCollection:a,setNextKey:o}=Nc();return i(()=>{x(void 0,void 0,void 0,function*(){var t;const r=yield Ra({collectionId:e,size:-1});if(!r)return;const{contents:i,count:n}=r;(null==i?void 0:i.length)&&o(null===(t=i.at(-1))||void 0===t?void 0:t.shortsId),a(Object.assign(Object.assign({},r),{count:n}))})},[e]),t.createElement(Er.div,null,t.createElement(Sc,null),t.createElement(Ph,{portalContainer:n,aspectRatio:r}))},Dh=e=>{const{container:r}=xc();return r?t.createElement(Mc,null,t.createElement(Ch,Object.assign({},e,{container:r}))):null},_h=Fa(e=>({shortform:null,setShortform:t=>e({shortform:t})}));var Oh={exports:{}},Mh={};function Nh(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=Nh(e[t]))&&(i&&(i+=" "),i+=r);else for(t in e)e[t]&&(i&&(i+=" "),i+=t);return i}function Fh(){for(var e,t,r=0,i="";r<arguments.length;)(e=arguments[r++])&&(t=Nh(e))&&(i&&(i+=" "),i+=t);return i}var $h,Bh=He(Object.freeze({__proto__:null,clsx:Fh,default:Fh})),Uh={},zh={};function Gh(){if($h)return zh;return $h=1,Object.defineProperty(zh,"__esModule",{value:!0}),zh.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."))},zh.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]},zh.int=function(e){return parseInt(e,10)},zh.isFunction=function(e){return"function"==typeof e||"[object Function]"===Object.prototype.toString.call(e)},zh.isNum=function(e){return"number"==typeof e&&!isNaN(e)},zh}var jh,Hh,Vh={};function Wh(){if(Hh)return Uh;Hh=1,Object.defineProperty(Uh,"__esModule",{value:!0}),Uh.addClassName=a,Uh.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},Uh.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")},Uh.createCSSTransform=function(e,r){const i=s(e,r,"px");return{[(0,t.browserPrefixToKey)("transform",t.default)]:i}},Uh.createSVGTransform=function(e,t){return s(e,t,"")},Uh.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)},Uh.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},Uh.getTranslation=s,Uh.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},Uh.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},Uh.matchesSelector=n,Uh.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},Uh.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}},Uh.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},Uh.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},Uh.removeClassName=o,Uh.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},Uh.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=Gh(),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(jh)return Vh;jh=1,Object.defineProperty(Vh,"__esModule",{value:!0}),Vh.browserPrefixToKey=r,Vh.browserPrefixToStyle=function(e,t){return t?"-".concat(t.toLowerCase(),"-").concat(e):e},Vh.default=void 0,Vh.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 Vh.default=t(),Vh}());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 Uh}var Yh,Kh={};function qh(){if(Yh)return Kh;Yh=1,Object.defineProperty(Kh,"__esModule",{value:!0}),Kh.canDragX=function(e){return"both"===e.props.axis||"x"===e.props.axis},Kh.canDragY=function(e){return"both"===e.props.axis||"y"===e.props.axis},Kh.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}},Kh.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}},Kh.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),d=i.getComputedStyle(s);a={left:-o.offsetLeft+(0,e.int)(d.paddingLeft)+(0,e.int)(l.marginLeft),top:-o.offsetTop+(0,e.int)(d.paddingTop)+(0,e.int)(l.marginTop),right:(0,t.innerWidth)(s)-(0,t.outerWidth)(o)-o.offsetLeft+(0,e.int)(d.paddingRight)-(0,e.int)(l.marginRight),bottom:(0,t.innerHeight)(s)-(0,t.outerHeight)(o)-o.offsetTop+(0,e.int)(d.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]},Kh.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)},Kh.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=Gh(),t=Wh();function r(e){const t=e.findDOMNode();if(!t)throw new Error("<DraggableCore>: Unmounted during event!");return t}return Kh}var Xh,Qh,Zh,Jh,ef={},tf={};function rf(){if(Xh)return tf;return Xh=1,Object.defineProperty(tf,"__esModule",{value:!0}),tf.default=function(){},tf}function nf(){if(Qh)return ef;Qh=1,Object.defineProperty(ef,"__esModule",{value:!0}),ef.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=d(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(ar()),i=l(m),n=Wh(),s=qh(),a=Gh(),o=l(rf());function l(e){return e&&e.__esModule?e:{default:e}}function d(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(d=function(e){return e?r:t})(e)}function c(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),c(this,"dragging",!1),c(this,"lastX",NaN),c(this,"lastY",NaN),c(this,"touchIdentifier",null),c(this,"mounted",!1),c(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:d}=a,c=(0,s.createCoreData)(this,l,d);(0,o.default)("DraggableCore: handleDragStart: %j",c),(0,o.default)("calling",this.props.onStart);!1!==this.props.onStart(e,c)&&!1!==this.mounted&&(this.props.enableUserSelectHack&&(0,n.addUserSelectStyles)(r),this.dragging=!0,this.lastX=l,this.lastY=d,(0,n.addEvent)(r,f.move,this.handleDrag),(0,n.addEvent)(r,f.stop,this.handleDragStop))}),c(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)}}),c(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))}),c(this,"onMouseDown",e=>(f=h,this.handleDragStart(e))),c(this,"onMouseUp",e=>(f=h,this.handleDragStop(e))),c(this,"onTouchStart",e=>(f=u,this.handleDragStart(e))),c(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 ef.default=p,c(p,"displayName","DraggableCore"),c(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}),c(p,"defaultProps",{allowAnyClick:!1,disabled:!1,enableUserSelectHack:!0,onStart:function(){},onDrag:function(){},onStop:function(){},onMouseDown:function(){},scale:1}),ef}function sf(){return Zh||(Zh=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"DraggableCore",{enumerable:!0,get:function(){return d.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(ar()),n=u(m),s=u(Bh),a=Wh(),o=qh(),l=Gh(),d=u(nf()),c=u(rf());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,c.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,c.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,c.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,c.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:c,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,{[c]:this.state.dragging,[u]:this.state.dragged});return r.createElement(d.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",{...d.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",{...d.default.defaultProps,axis:"both",bounds:!1,defaultClassName:"react-draggable",defaultClassNameDragging:"react-draggable-dragging",defaultClassNameDragged:"react-draggable-dragged",defaultPosition:{x:0,y:0},scale:1})}(Mh)),Mh}var af=function(){if(Jh)return Oh.exports;Jh=1;const{default:e,DraggableCore:t}=sf();return Oh.exports=e,Oh.exports.default=e,Oh.exports.DraggableCore=t,Oh.exports}(),of=je(af),lf=function(){return lf=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},lf.apply(this,arguments)},df={width:"100%",height:"10px",top:"0px",left:"0px",cursor:"row-resize"},cf={width:"10px",height:"100%",top:"0px",left:"0px",cursor:"col-resize"},uf={width:"20px",height:"20px",position:"absolute",zIndex:1},hf={top:lf(lf({},df),{top:"-5px"}),right:lf(lf({},cf),{left:void 0,right:"-5px"}),bottom:lf(lf({},df),{top:void 0,bottom:"-5px"}),left:lf(lf({},cf),{left:"-5px"}),topRight:lf(lf({},uf),{right:"-10px",top:"-10px",cursor:"ne-resize"}),bottomRight:lf(lf({},uf),{right:"-10px",bottom:"-10px",cursor:"se-resize"}),bottomLeft:lf(lf({},uf),{left:"-10px",bottom:"-10px",cursor:"sw-resize"}),topLeft:lf(lf({},uf),{left:"-10px",top:"-10px",cursor:"nw-resize"})},ff=h(function(e){var t=e.onResizeStart,r=e.direction,i=e.children,n=e.replaceStyles,s=e.className,a=u(function(e){t(e,r)},[t,r]),o=u(function(e){t(e,r)},[t,r]),l=c(function(){return lf(lf({position:"absolute",userSelect:"none"},hf[r]),null!=n?n:{})},[n,r]);return b("div",{className:s||void 0,style:l,onMouseDown:a,onTouchStart:o,children:i})}),pf=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)}}(),mf=function(){return mf=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},mf.apply(this,arguments)},gf={width:"auto",height:"auto"},vf=function(e,t,r){return Math.max(Math.min(e,r),t)},yf=function(e,t,r){var i=Math.round(e/t);return i*t+r*(i-1)},bf=function(e,t){return new RegExp(e,"i").test(t)},Ef=function(e){return Boolean(e.touches&&e.touches.length)},wf=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},Sf=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")},Tf=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},xf=["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"],Af="__resizable_base__",kf=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(Af):t.className+=Af,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 pf(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||gf},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 Sf(e.state[t])};return{width:t&&void 0!==t.width&&!this.state.isResizing?Sf(t.width):r("width"),height:t&&void 0!==t.height&&!this.state.isResizing?Sf(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&&bf("left",s),o=n&&bf("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,d=o.original,c=this.props,u=c.lockAspectRatio,h=c.lockAspectRatioExtraHeight,f=c.lockAspectRatioExtraWidth,p=d.width,m=d.height,g=h||0,v=f||0;return bf("right",l)&&(p=d.width+(e-d.x)*s/i,u&&(m=(p-v)/this.ratio+g)),bf("left",l)&&(p=d.width-(e-d.x)*s/i,u&&(m=(p-v)/this.ratio+g)),bf("bottom",l)&&(m=d.height+(t-d.y)*a/i,u&&(p=(m-g)*this.ratio+v)),bf("top",l)&&(m=d.height-(t-d.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,d=void 0===r.width||r.width<0?e:r.width,c=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=(c-h)*this.ratio+f,m=(u-h)*this.ratio+f,g=(l-f)/this.ratio+h,v=(d-f)/this.ratio+h,y=Math.max(l,p),b=Math.min(d,m),E=Math.max(c,g),w=Math.min(u,v);e=vf(e,y,b),t=vf(t,E,w)}else e=vf(e,l,d),t=vf(t,c,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&&Ef(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:mf(mf({},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&&Ef(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=Ef(e)?e.touches[0].clientX:e.clientX,l=Ef(e)?e.touches[0].clientY:e.clientY,d=this.state,c=d.direction,u=d.original,h=d.width,f=d.height,p=this.getParentSize(),m=function(e,t,r,i,n,s,a){return i=Tf(i,e.width,t,r),n=Tf(n,e.height,t,r),s=Tf(s,e.width,t,r),a=Tf(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=wf(b,this.props.snap.x,this.props.snapGap)),this.props.snap&&this.props.snap.y&&(y=wf(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=yf(b,this.props.grid[0],this.props.gridGap?this.props.gridGap[0]:0),T=yf(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 L=b/this.window.innerWidth*100;b="".concat(L,"vw")}else if(h.endsWith("vh")){var I=b/this.window.innerHeight*100;b="".concat(I,"vh")}if(f&&"string"==typeof f)if(f.endsWith("%")){k=y/p.height*100;y="".concat(k,"%")}else if(f.endsWith("vw")){L=y/this.window.innerWidth*100;y="".concat(L,"vw")}else if(f.endsWith("vh")){I=y/this.window.innerHeight*100;y="".concat(I,"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,c,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:mf(mf({},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(ff,{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!==xf.indexOf(r)||(t[r]=e.props[r]),t},{}),r=mf(mf(mf({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,mf({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),Lf=function(e,t){return Lf=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])},Lf(e,t)};var If=function(){return If=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},If.apply(this,arguments)};var Rf={width:"auto",height:"auto",display:"inline-block",position:"absolute",top:0,left:0},Pf=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}Lf(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,d=document.body.getBoundingClientRect(),c=-(o-n.offsetLeft*s-d.left)/s,u=-(l-n.offsetTop*s-d.top)/s,h=(document.body.offsetWidth-this.resizable.size.width*s)/s+c,f=(document.body.offsetHeight-this.resizable.size.height*s)/s+u;return this.setState({bounds:{top:u,right:h,bottom:f,left:c}})}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,If(If({},t),{x:t.x+i,y:this.originalPosition.y+n,deltaY:0})):"y"===this.props.dragAxis?this.props.onDrag(e,If(If({},t),{x:this.originalPosition.x+i,y:t.y+n,deltaX:0})):void 0:this.props.onDrag(e,If(If({},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,If(If({},t),{x:t.x+i,y:this.originalPosition.y+n,deltaY:0})):"y"===this.props.dragAxis?this.props.onDragStop(e,If(If({},t),{x:this.originalPosition.x+i,y:t.y+n,deltaX:0})):void 0:this.props.onDragStop(e,If(If({},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 d=this.getMaxSizesFromProps(),c=d.maxWidth,u=d.maxHeight,h=this.getParentSize();if(c&&"string"==typeof c)if(c.endsWith("%")){var f=Number(c.replace("%",""))/100;c=h.width*f}else c.endsWith("px")&&(c=Number(c.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(c)?c:k})}if(T||this.props.lockAspectRatio&&!S&&!x){k=E+(y-m)/i;this.setState({maxWidth:k>Number(c)?c: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 d=this.offsetFromParent,c=this.getDraggablePosition().x+d.left,u=this.getDraggablePosition().y+d.top;this.resizingPosition={x:c,y:u},this.props.onResize&&this.props.onResize(e,t,r,i,{x:c,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,d=t.scrollTop;this.offsetFromParent={left:a.left-n+l-o.x*e,top:a.top-s+d-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,d=t.dragAxis,c=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?If({},this.props.default):void 0;delete A.default;var L,I=r||n?{cursor:"auto"}:{cursor:"move"},R=If(If(If({},Rf),I),i),P=this.offsetFromParent,C=P.left,D=P.top;s&&(L={x:s.x-C,y:s.y-D});var _,O=this.state.resizing?void 0:L,M=this.state.resizing?"both":d;return l(of,{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:c,bounds:u?this.state.bounds:void 0,position:O,enableUserSelectHack:h,cancel:f,scale:S,allowAnyClick:T,nodeRef:this.resizableElement,positionOffset:x},l(kf,If({},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 Cf=({shortform:e,setClose:r})=>{const[n,s]=t.useState(!0),[o,l]=a(!0),[d,c]=a(!1),u=t.useRef(null),h=()=>{u.current&&(window.clearTimeout(u.current),u.current=null)},f=(e=1500)=>{h(),u.current=window.setTimeout(()=>c(!1),e)};return i(()=>()=>h(),[]),t.createElement("div",{className:"relative w-full h-full",onClick:()=>{c(!0),f(2e3)},onMouseLeave:()=>f(800),onMouseEnter:()=>d&&f(1500)},t.createElement("div",{className:"absolute inset-0 bg-black",style:{zIndex:1,opacity:d?.4:0,transition:"opacity 300ms ease",pointerEvents:d?"auto":"none"}}),t.createElement("div",{className:"absolute inset-0",style:{zIndex:2,opacity:d?1:0,transition:"opacity 300ms ease",pointerEvents:d?"auto":"none"}},t.createElement("div",{className:"absolute text-white flex gap-2",style:{zIndex:3,top:8,right:8}},t.createElement("button",{className:"cursor-pointer",onClick:e=>{e.stopPropagation(),s(e=>!e)},"aria-label":n?"Unmute":"Mute"},n?t.createElement($r,{size:20}):t.createElement(Fr,{size:20})),t.createElement("button",{className:"cursor-pointer",onClick:e=>{null==e||e.stopPropagation(),r()},"aria-label":"Close"},t.createElement(Br,{size:20}))),t.createElement("div",{className:"absolute inset-0 flex items-center justify-center",style:{pointerEvents:"none"}},t.createElement("button",{onClick:e=>{null==e||e.stopPropagation(),l(e=>!e)},"aria-label":o?"Pause":"Play",className:"cursor-pointer text-white p-2 ",style:{pointerEvents:"auto"}},o?t.createElement(Or,{size:28}):t.createElement(Mr,{size:28})))),t.createElement(Dt,{shortform:e,mute:n,play:o}))},Df=({shortsId:e,type:r})=>{const{shortform:n}=_h(),[s,o]=a(!1),{playtime:l}=_c(),d=()=>{if(!n)return;o(!0);const{shortsId:e,uuid:t,userId:r}=n;Aa({contentId:e,uuid:t,type:Et.SHORTS,playtime:l,userId:r})};(({shorform:e,playtime:t})=>{i(()=>{if(!e)return;const{shortsId:t,shortsUuid:r,userId:i}=e;xa({contentId:t,uuid:r,type:Et.SHORTS,userId:i,isFirstPlay:!Lt(t)})},[]);const r=Cc();i(()=>{if(!e||r)return;const{shortsId:i,uuid:n,userId:s}=e;Aa({contentId:i,uuid:n,type:Et.SHORTS,playtime:t,userId:s})},[r])})({shorform:n,playtime:l});const{w:c,h:u,left:h,top:f}=(()=>{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 n&&!s&&t.createElement(Pf,{minWidth:240,lockAspectRatio:9/16,style:{zIndex:99999},default:{width:240,height:427,x:h+c-240-50,y:f+u-427-50},bounds:"window"},"shopping"===r&&n.productsInfo.length>0?t.createElement(uc,{shortForm:n,handleClose:d}):t.createElement(Cf,{shortform:n,setClose:d}))},_f=({shortsId:e,type:r,isPreview:n})=>{const{setShortform:s,shortform:a}=_h();return i(()=>{if(!e)return;e&&x(void 0,void 0,void 0,function*(){const t=yield Pa(e,n);t&&s(Object.assign(Object.assign({},t),{uuid:kt()}))})},[e]),a?t.createElement(Er.div,{style:{position:"fixed",inset:0,pointerEvents:"none",zIndex:99999}},t.createElement(Sc,null),t.createElement("div",{style:{pointerEvents:"auto"}},t.createElement(Df,{shortsId:e,type:r}))):null},Of=t.createContext(null),Mf=({children:e})=>{const r=t.useRef(null);return r.current||(r.current=_a(e=>({liveWidget:null,setLiveWidget:t=>e({liveWidget:t}),nextKey:"",setNextKey:t=>e({nextKey:t}),isFetching:!1,setIsFetching:t=>e({isFetching:t})}))),t.createElement(Of.Provider,{value:r.current},e)};function Nf(e){const r=t.useContext(Of);if(!r)throw new Error("Missing LiveWidgetProvider");return Ma(r,e)}var Ff;!function(e){e[e.READY=1]="READY",e[e.STREAMING=2]="STREAMING",e[e.PAUSED=3]="PAUSED"}(Ff||(Ff={}));const $f=({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"}})},Bf=({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"})},Uf=(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],d=l/o;let c,u;i>0&&s>0?(c=i,u=Math.round(c*d),u>s&&(u=s,c=Math.round(u/d)),n({width:c,height:u})):n({});const h="number"==typeof c?c: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}},zf=({content:e,aspectRatio:r="9/16",cursor:i="default",borderRadius:n})=>{var s,o;const{leftTime:l}=(e=>{const{start:t}=e,r=qe().tz("Asia/Seoul").unix(),[i,n]=a(t-r>0?t-r:0);return Dc(()=>{n(i<=0?0:e=>e-1)},1e3),{leftTime:i}})(e),d=null===(o=null===(s=null==e?void 0:e.designInfo)||void 0===s?void 0:s.thumbPath)||void 0===o?void 0:o.preview,c=t.useRef(null),{boxSize:u,fontSize:h}=Uf(r,c),{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:c},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:d?`url(${Rt(d)})`:void 0,backgroundColor:d?void 0:"black"}},1===e.openStatus?t.createElement(t.Fragment,null,t.createElement(Bf,{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($f,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($f,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`}},"곧 라이브가 시작됩니다!")))))},Gf=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},jf=Number.isSafeInteger||function(e){return"number"==typeof e&&Math.abs(e)<=Hf},Hf=Number.MAX_SAFE_INTEGER||9007199254740991;let Vf=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}({}),Wf=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}({}),Yf=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 Kf="manifest",qf="level",Xf="audioTrack",Qf="subtitleTrack",Zf="main",Jf="audio",ep="subtitle";class tp{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 rp{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 tp(e),this.fast_=new tp(t),this.defaultTTFB_=i,this.ttfb_=new tp(e)}update(e,t){const{slow_:r,fast_:i,ttfb_:n}=this;r.halfLife!==e&&(this.slow_=new tp(e,r.getEstimate(),r.getTotalWeight())),i.halfLife!==t&&(this.fast_=new tp(t,i.getEstimate(),i.getTotalWeight())),n.halfLife!==e&&(this.ttfb_=new tp(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 ip(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 np(){return np=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},np.apply(null,arguments)}function sp(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 ap(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?sp(Object(r),!0).forEach(function(t){ip(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):sp(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}class op{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=lp,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 lp=function(){},dp={trace:lp,debug:lp,log:lp,warn:lp,info:lp,error:lp};function cp(){return np({},dp)}function up(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}] >`):lp}(e,r)}const hp=cp();const fp=hp;function pp(e=!0){if("undefined"==typeof self)return;return(e||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function mp(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 gp(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 vp(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 yp(e){return Uint8Array.from(e.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}function bp(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ep,wp={exports:{}};var Sp,Tp,xp,Ap,kp,Lp=Ep?wp.exports:(Ep=1,Sp=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,Tp=/^(?=([^\/?#]*))\1([^]*)$/,xp=/(?:\/|^)\.(?=\/)/g,Ap=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,wp.exports=kp={buildAbsoluteURL:function(e,t,r){if(r=r||{},e=e.trim(),!(t=t.trim())){if(!r.alwaysNormalize)return e;var i=kp.parseURL(e);if(!i)throw new Error("Error trying to parse base URL.");return i.path=kp.normalizePath(i.path),kp.buildURLFromParts(i)}var n=kp.parseURL(t);if(!n)throw new Error("Error trying to parse relative URL.");if(n.scheme)return r.alwaysNormalize?(n.path=kp.normalizePath(n.path),kp.buildURLFromParts(n)):t;var s=kp.parseURL(e);if(!s)throw new Error("Error trying to parse base URL.");if(!s.netLoc&&s.path&&"/"!==s.path[0]){var a=Tp.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,d=l.substring(0,l.lastIndexOf("/")+1)+n.path;o.path=kp.normalizePath(d)}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?kp.normalizePath(n.path):n.path),kp.buildURLFromParts(o)},parseURL:function(e){var t=Sp.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(xp,"");e.length!==(e=e.replace(Ap,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}});class Ip{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 Rp="audio",Pp="video",Cp="audiovideo";class Dp{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=Np(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={[Rp]:null,[Pp]:null,[Cp]: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 Ip),this._stats}set stats(e){this._stats=e}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Lp.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}clearElementaryStreamInfo(){const{elementaryStreams:e}=this;e[Rp]=null,e[Pp]=null,e[Cp]=null}}function _p(e){return"initSegment"!==e.sn}class Op extends Dp{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(Gf(e)&&Gf(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=Gf(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){Gf(e)?this._programDateTime=e:this._programDateTime=this.rawProgramDateTime=null}get ref(){return _p(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 Mp extends Dp{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 Np(e,t){const r=Object.getPrototypeOf(e);if(r){const e=Object.getOwnPropertyDescriptor(r,t);return e||Np(r,t)}}const Fp=Math.pow(2,32)-1,$p=[].push,Bp={video:1,audio:2,id3:3,text:4};function Up(e){return String.fromCharCode.apply(null,e)}function zp(e,t){const r=e[t]<<8|e[t+1];return r<0?65536+r:r}function Gp(e,t){const r=Hp(e,t);return r<0?4294967296+r:r}function jp(e,t){let r=Gp(e,t);return r*=Math.pow(2,32),r+=Gp(e,t+4),r}function Hp(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function Vp(e,t){const r=[];if(!t.length)return r;const i=e.byteLength;for(let n=0;n<i;){const s=Gp(e,n),a=s>1?n+s:i;if(Up(e.subarray(n+4,n+8))===t[0])if(1===t.length)r.push(e.subarray(n+8,a));else{const i=Vp(e.subarray(n+8,a),t.slice(1));i.length&&$p.apply(r,i)}n=a}return r}function Wp(e){const t=[],r=e[0];let i=8;const n=Gp(e,i);i+=4;let s=0,a=0;0===r?(s=Gp(e,i),a=Gp(e,i+4),i+=8):(s=jp(e,i),a=jp(e,i+8),i+=16),i+=2;let o=e.length+a;const l=zp(e,i);i+=2;for(let r=0;r<l;r++){let r=i;const s=Gp(e,r);r+=4;const a=2147483647&s;if(1===(2147483648&s)>>>31)return fp.warn("SIDX has hierarchical references (not supported)"),null;const l=Gp(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 Yp(e){const t=[],r=Vp(e,["moov","trak"]);for(let e=0;e<r.length;e++){const i=r[e],n=Vp(i,["tkhd"])[0];if(n){let e=n[0];const r=Gp(n,0===e?12:20),s=Vp(i,["mdia","mdhd"])[0];if(s){e=s[0];const n=Gp(s,0===e?12:20),a=Vp(i,["mdia","hdlr"])[0];if(a){const e=Up(a.subarray(8,12)),s={soun:Rp,vide:Pp}[e],o=Kp(Vp(i,["mdia","minf","stbl","stsd"])[0]);s?(t[r]={timescale:n,type:s,stsd:o},t[s]=ap({timescale:n,id:r},o)):t[r]={timescale:n,type:e,stsd:o}}}}}return Vp(e,["moov","mvex","trex"]).forEach(e=>{const r=Gp(e,4),i=t[r];i&&(i.default={duration:Gp(e,12),flags:Gp(e,20)})}),t}function Kp(e){const t=e.subarray(8),r=t.subarray(86),i=Up(t.subarray(4,8));let n,s=i;const a="enca"===i||"encv"===i;if(a){const e=Vp(t,[i])[0];Vp(e.subarray("enca"===i?28:78),["sinf"]).forEach(e=>{const t=Vp(e,["schm"])[0];if(t){const r=Up(t.subarray(4,8));if("cbcs"===r||"cenc"===r){const t=Vp(e,["frma"])[0];t&&(s=Up(t))}}})}const o=s;switch(s){case"avc1":case"avc2":case"avc3":case"avc4":{const e=Vp(r,["avcC"])[0];e&&e.length>3&&(s+="."+Qp(e[1])+Qp(e[2])+Qp(e[3]),n=qp("avc1"===o?"dva1":"dvav",r));break}case"mp4a":{const e=Vp(t,[i])[0],r=Vp(e.subarray(28),["esds"])[0];if(r&&r.length>7){let e=4;if(3!==r[e++])break;e=Xp(r,e),e+=2;const t=r[e++];if(128&t&&(e+=2),64&t&&(e+=r[e++]),4!==r[e++])break;e=Xp(r,e);const i=r[e++];if(64!==i)break;if(s+="."+Qp(i),e+=12,5!==r[e++])break;e=Xp(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=Vp(r,["hvcC"])[0];if(e&&e.length>12){const t=e[1],r=["","A","B","C"][t>>6],i=31&t,n=Gp(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 d="";for(let e=l.length;e--;){const t=l[e];if(t||d){d="."+t.toString(16).toUpperCase()+d}}s+=d}n=qp("hev1"==o?"dvhe":"dvh1",r);break}case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":s=qp(s,r)||s;break;case"vp09":{const e=Vp(r,["vpcC"])[0];if(e&&e.length>6){const t=e[4],r=e[5],i=e[6]>>4&15;s+="."+Zp(t)+"."+Zp(r)+"."+Zp(i)}break}case"av01":{const e=Vp(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,d=2===t&&o?l?12:10:o?10:8,c=(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+"."+Zp(i)+a+"."+Zp(d)+"."+c+"."+u+h+f+"."+Zp(p)+"."+Zp(m)+"."+Zp(g)+"."+v,n=qp("dav1",r)}break}}return{codec:s,encrypted:a,supplemental:n}}function qp(e,t){const r=Vp(t,["dvvC"]),i=r.length?r[0]:Vp(t,["dvcC"])[0];if(i){const t=i[2]>>1&127,r=i[2]<<5&32|i[3]>>3&31;return e+"."+Zp(t)+"."+Zp(r)}}function Xp(e,t){const r=t+5;for(;128&e[t++]&&t<r;);return t}function Qp(e){return("0"+e.toString(16).toUpperCase()).slice(-2)}function Zp(e){return(e<10?"0":"")+e}function Jp(e,t){Vp(e,["moov","trak"]).forEach(e=>{const r=Vp(e,["mdia","minf","stbl","stsd"])[0];if(!r)return;const i=r.subarray(8);let n=Vp(i,["enca"]);const s=n.length>0;s||(n=Vp(i,["encv"])),n.forEach(e=>{Vp(s?e.subarray(28):e.subarray(78),["sinf"]).forEach(e=>{const r=em(e);r&&t(r,s)})})})}function em(e){const t=Vp(e,["schm"])[0];if(t){const r=Up(t.subarray(4,8));if("cbcs"===r||"cenc"===r){const t=Vp(e,["schi","tenc"])[0];if(t)return t}}}function tm(e,t){const r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}function rm(e,t){const r=[],i=t.samples,n=t.timescale,s=t.id;let a=!1;return Vp(i,["moof"]).map(o=>{const l=o.byteOffset-8;Vp(o,["traf"]).map(o=>{const d=Vp(o,["tfdt"]).map(e=>{const t=e[0];let r=Gp(e,4);return 1===t&&(r*=Math.pow(2,32),r+=Gp(e,8)),r/n})[0];return void 0!==d&&(e=d),Vp(o,["tfhd"]).map(d=>{const c=Gp(d,4),u=16777215&Gp(d,0);let h=0;const f=!!(16&u);let p=0;const m=!!(32&u);let g=8;c===s&&(!!(1&u)&&(g+=8),!!(2&u)&&(g+=4),!!(8&u)&&(h=Gp(d,g),g+=4),f&&(p=Gp(d,g),g+=4),m&&(g+=4),"video"===t.type&&(a=im(t.codec)),Vp(o,["trun"]).map(s=>{const o=s[0],d=16777215&Gp(s,0),c=!!(1&d);let u=0;const f=!!(4&d),m=!!(256&d);let g=0;const v=!!(512&d);let y=0;const b=!!(1024&d),E=!!(2048&d);let w=0;const S=Gp(s,4);let T=8;c&&(u=Gp(s,T),T+=4),f&&(T+=4);let x=u+l;for(let l=0;l<S;l++){if(m?(g=Gp(s,T),T+=4):g=h,v?(y=Gp(s,T),T+=4):y=p,b&&(T+=4),E&&(w=0===o?Gp(s,T):Hp(s,T),T+=4),t.type===Pp){let t=0;for(;t<y;){const s=Gp(i,x);if(x+=4,nm(a,i[x])){sm(i.subarray(x,x+s),a?2:1,e+w/n,r)}x+=s,t+=s+4}}e+=g/n}}))})})}),r}function im(e){if(!e)return!1;const t=e.substring(0,4);return"hvc1"===t||"hev1"===t||"dvh1"===t||"dvhe"===t}function nm(e,t){if(e){const e=t>>1&63;return 39===e||40===e}return 6===(31&t)}function sm(e,t,r,i){const n=am(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){fp.error(`Malformed SEI payload. ${o} is too small, only ${e} bytes left to parse.`);break}if(4===a){if(181===n[t++]){const e=zp(n,t);if(t+=2,49===e){const e=Gp(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,d=new Uint8Array(l);if(o){d[0]=s;for(let e=1;e<l;e++)d[e]=n[t++]}i.push({type:e,payloadType:a,pts:r,bytes:d})}}}}}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:gp(l),userDataBytes:l})}}}function am(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 om(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 lm(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=vp(new Uint8Array(s,r+12,16));let o=null,l=null,d=0;if(0===n)d=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));d=32+16*n}if(!d)return{offset:r,size:t};const c=e.getUint32(d);return t-32<c?{offset:r,size:t}:(l=new Uint8Array(s,r+d+4,c),{version:n,systemId:a,kids:o,data:l,offset:r,size:t})}const dm=()=>/\(Windows.+Firefox\//i.test(navigator.userAgent),cm={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 um(e,t){const r=cm[t];return!!r&&!!r[e.slice(0,4)]}function hm(e,t,r=!0){return!e.split(",").some(e=>!fm(e,t,r))}function fm(e,t,r=!0){var i;const n=pp(r);return null!=(i=null==n?void 0:n.isTypeSupported(pm(e,t)))&&i}function pm(e,t){return`${t}/mp4;codecs=${e}`}function mm(e){if(e){const t=e.substring(0,4);return cm.video[t]}return 2}function gm(e){const t=dm();return e.split(",").reduce((e,r)=>{const i=t&&im(r)?9:cm.video[r];return i?(2*i+e)/(e?3:2):(cm.audio[r]+e)/(e?2:1)},0)}const vm={};const ym=/flac|opus|mp4a\.40\.34/i;function bm(e,t=!0){return e.replace(ym,e=>function(e,t=!0){if(vm[e])return vm[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(fm(r[n],"audio",t))return vm[e]=r[n],r[n];if("mp3"===r[n]&&null!=(i=pp(t))&&i.isTypeSupported("audio/mpeg"))return""}return e}(e.toLowerCase(),t))}function Em(e,t){if(e&&(e.length>4||-1!==["ac-3","ec-3","alac","fLaC","Opus"].indexOf(e))&&(wm(e,"audio")||wm(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 wm(e,t){return um(e,t)&&fm(e,t)}function Sm(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 Tm(e){const t=pp(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 xm(e){return e.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}const Am={supported:!1,smooth:!1,powerEfficient:!1},km={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]};function Lm(e,t){return{supported:!1,configurations:t,decodingInfoResults:[Am],error:e}}function Im(e,t,r,i,n,s){const a=e.videoCodec,o=e.audioCodec?e.audioGroups:null,l=null==s?void 0:s.audioCodec,d=null==s?void 0:s.channels,c=d?parseInt(d):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=>im(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&&Gf(c)&&Object.keys(u).some(e=>parseInt(e)>c)}function Rm(e,t,r,i={}){const n=e.videoCodec;if(!n&&!e.audioCodec||!r)return Promise.resolve(km);const s=[],a=function(e){var t;const r=null==(t=e.videoCodec)?void 0:t.split(","),i=Cm(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:pm(Sm(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=Cm(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:pm(t,"audio"),bitrate:r?Pm(t,s):s};i&&(n.channels=""+i),e.push(n)})}return e},e):e},[]);return[]}(e,t,o>0),d=l.length;for(let e=o||1*d||1;e--;){const t={type:"media-source"};if(o&&(t.video=a[e%o]),d){t.audio=l[e%d];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=>im(e))&&dm())return Promise.resolve(Lm(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+=`${xm(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?"_":""}${xm(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 Pm(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 Cm(e){return 1e3*Math.ceil(Math.max(.9*e.bitrate,e.averageBitrate)/1e3)||1}const Dm=["NONE","TYPE-0","TYPE-1",null];const _m=["SDR","PQ","HLG"];var Om="",Mm="YES",Nm="v2";function Fm(e){const{canSkipUntil:t,canSkipDateRanges:r,age:i}=e;return t&&i<t/2?r?Nm:Mm:Om}class $m{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 Bm{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 Um(this._audioGroups,e)}hasSubtitleGroup(e){return Um(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 Um(e,t){return!(!t||!e)&&-1!==e.indexOf(t)}function zm(e,t){let r=!1,i=[];if(e&&(r="SDR"!==e,i=[e]),t){i=t.allowedVideoRanges||_m.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 Gm=(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 jm(e,t){fp.log(`[abr] start candidates with "${e}" ignored because ${t}`)}function Hm(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 Vm(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 Wm(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(Ym(e,t[i],r))return i}return-1}function Ym(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 Km(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 qm(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 Xm(e,t){var r;return!!e&&e!==(null==(r=t.loadLevelObj)?void 0:r.uri)}const Qm=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 Zm(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===Jm(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=Qm(t,Jm.bind(null,r,i));return!a||a===e&&s?s:a}function Jm(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 eg(e,t,r){const i=1e3*Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return(r.endProgramDateTime||0)-i>e}function tg(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)),Qm(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 rg(e){switch(e.details){case Wf.FRAG_LOAD_TIMEOUT:case Wf.KEY_LOAD_TIMEOUT:case Wf.LEVEL_LOAD_TIMEOUT:case Wf.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function ig(e){return e.details.startsWith("key")}function ng(e){return ig(e)&&!!e.frag&&!e.frag.decryptdata}function sg(e,t){const r=rg(t);return e.default[(r?"timeout":"error")+"Retry"]}function ag(e,t){const r="linear"===e.backoff?1:Math.pow(2,t);return Math.min(r*e.retryDelayMs,e.maxRetryDelayMs)}function og(e){return ap(ap({},e),{errorRetry:null,timeoutRetry:null})}function lg(e,t,r,i){if(!e)return!1;const n=null==i?void 0:i.code,s=t<e.maxNumRetry&&(function(e){return dg(e)||!!e&&(e<400||e>499)}(n)||!!r);return e.shouldRetry?e.shouldRetry(e,t,r,i,s):s}function dg(e){return 0===e&&!1===navigator.onLine}var cg=0,ug=2,hg=3,fg=5,pg=0,mg=1,gg=2,vg=4;function yg(e){const t={action:cg,flags:pg};return e&&(t.resolved=!0),t}var bg="NOT_LOADED",Eg="APPENDING",wg="PARTIAL",Sg="OK";class Tg{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(Yf.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Yf.BUFFER_APPENDED,this.onBufferAppended,this),e.on(Yf.FRAG_BUFFERED,this.onFragBuffered,this),e.on(Yf.FRAG_LOADED,this.onFragLoaded,this))}_unregisterListeners(){const{hls:e}=this;e&&(e.off(Yf.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Yf.BUFFER_APPENDED,this.onBufferAppended,this),e.off(Yf.FRAG_BUFFERED,this.onFragBuffered,this),e.off(Yf.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=Ag(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),xg(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]=kg(r,t=>t.fragment.sn>=e))}fragBuffered(e,t){const r=Ag(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 d=o[l];d&&xg(d)&&(r=d.body.start-a,i=d.body.end+a,e>=r&&e<=i&&(t=Math.min(e-r,i-e),s<=t&&(n=d.body,s=t)))}),n}isEndListAppended(e){const t=this.endListFragments[e];return void 0!==t&&(t.buffered||xg(t))}getState(e){const t=Ag(e),r=this.fragments[t];return r?r.buffered?xg(r)?wg:Sg:Eg:bg}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=Ag(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=Ag(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=Ag(e);e.clearElementaryStreamInfo();const r=this.activePartLists[e.type];if(r){const t=e.sn;this.activePartLists[e.type]=kg(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 xg(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 Ag(e){return`${e.type}_${e.level}_${e.sn}`}function kg(e,t){return e.filter(e=>{const r=t(e);return r||e.clearElementaryStreamInfo(),r})}var Lg=0,Ig=1;class Rg{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 Lg:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e);case Ig: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 Pg{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],d=o[1],c=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,d[r]=v<<16|v>>>16,c[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),d=this.invKeySchedule=new Uint32Array(s),c=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=c[y>>>24]<<24|c[y>>>16&255]<<16|c[y>>>8&255]<<8|c[255&y],y^=u[a/n|0]<<24):n>6&&a%n===4&&(y=c[y>>>24]<<24|c[y>>>16&255]<<16|c[y>>>8&255]<<8|c[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],d[o]=o<4||a<=4?y:f[c[y>>>24]]^p[c[y>>>16&255]]^m[c[y>>>8&255]]^g[c[255&y]],d[o]=d[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],d=a[2],c=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,L,I,R,P,C;const D=this.networkToHostOrderSwap;for(;t<g.length;){for(k=D(g[t]),L=D(g[t+1]),I=D(g[t+2]),R=D(g[t+3]),S=k^n[0],T=R^n[1],x=I^n[2],A=L^n[3],P=4,C=1;C<i;C++)y=o[S>>>24]^l[T>>16&255]^d[x>>8&255]^c[255&A]^n[P],b=o[T>>>24]^l[x>>16&255]^d[A>>8&255]^c[255&S]^n[P+1],E=o[x>>>24]^l[A>>16&255]^d[S>>8&255]^c[255&T]^n[P+2],w=o[A>>>24]^l[S>>16&255]^d[T>>8&255]^c[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=L,p=I,m=R,t+=4}return v.buffer}}class Cg{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 Lg:return"AES-CBC";case Ig: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 Dg{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!==Lg||16!==t.byteLength)return fp.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),a&&(e=tm(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 Pg),l.expandKey(t);const d=s;return this.currentResult=l.decrypt(o.buffer,0,r),this.currentIV=o.slice(-16).buffer,d||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 Cg(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 Rg(this.subtle,new Uint8Array(r),i).decrypt(e.buffer,t)}).catch(n=>(fp.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&&(fp.log(`[decrypter]: ${e}`),this.logEnabled=!1)}}const _g=Math.pow(2,17);class Og{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 Fg({type:Vf.NETWORK_ERROR,details:Wf.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(Ng(e));e.gap=!1}const l=this.loader=n?new n(i):new s(i),d=Mg(e);e.loader=l;const c=og(i.fragLoadPolicy.default),u={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===e.sn?1/0:_g};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 Fg({type:Vf.NETWORK_ERROR,details:Wf.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:ap({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 Fg({type:Vf.NETWORK_ERROR,details:Wf.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:i,stats:t}))},onTimeout:(t,r,i)=>{this.resetLoader(e,l),o(new Fg({type:Vf.NETWORK_ERROR,details:Wf.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(d,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(Ng(e,t));const l=this.loader=n?new n(i):new s(i),d=Mg(e,t);e.loader=l;const c=og(i.fragLoadPolicy.default),u={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:_g};t.stats=l.stats,l.load(d,u,{onSuccess:(i,n,s,o)=>{this.resetLoader(e,l),this.updateStatsFromPart(e,t);const d={frag:e,part:t,payload:i.data,networkDetails:o};r(d),a(d)},onError:(r,i,n,s)=>{this.resetLoader(e,l),o(new Fg({type:Vf.NETWORK_ERROR,details:Wf.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:ap({url:d.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 Fg({type:Vf.NETWORK_ERROR,details:Wf.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 Fg({type:Vf.NETWORK_ERROR,details:Wf.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 Mg(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(Gf(n)&&Gf(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 Ng(e,t){const r=new Error(`GAP ${e.gap?"tag":"attribute"} found`),i={type:Vf.MEDIA_ERROR,details:Wf.FRAG_GAP,fatal:!1,frag:e,error:r,networkDetails:null};return t&&(i.part=t),(t||e).stats.aborted=!0,new Fg(i)}class Fg extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class $g extends op{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 Bg{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 Ug={length:0,start:()=>0,end:()=>0};class zg{static isBuffered(e,t){if(e){const r=zg.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=zg.getBuffered(e);return zg.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=zg.bufferedRanges(e);if(i.length)return zg.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 d=n[e].start,c=n[e].end;if(-1===i&&t>=d&&t<=c&&(i=e),t+r>=d&&t<c)o=d,l=c,a=l-t;else if(t+r<d){s=d;break}}return{len:a,start:o||0,end:l||0,nextStart:s,buffered:e,bufferedIndex:i}}static getBuffered(e){try{return e.buffered||Ug}catch(e){return fp.log("failed to get media.buffered",e),Ug}}}const Gg=/\{\$([a-zA-Z0-9-_]+)\}/g;function jg(e){return Gg.test(e)}function Hg(e,t){if(null!==e.variableList||e.hasVariableRefs){const r=e.variableList;return t.replace(Gg,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 Vg(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 Wg(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 Yg=/^(\d+)x(\d+)$/,Kg=/(.+?)=(".*?"|.*?)(?:,|$)/g;class qg{constructor(e,t){"string"==typeof e&&(e=qg.parseAttrList(e,t)),np(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=Yg.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(Kg.lastIndex=0;null!==(r=Kg.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=Hg(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":fp.warn(`${e}: attribute ${n} is missing quotes`)}i[n]=s}return i}}function Xg(e){return"ID"!==e&&"CLASS"!==e&&"CUE"!==e&&"START-DATE"!==e&&"DURATION"!==e&&"END-DATE"!==e&&"END-ON-NEXT"!==e}function Qg(e){return"SCTE35-OUT"===e||"SCTE35-IN"===e||"SCTE35-CMD"===e}class Zg{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]){fp.warn(`DATERANGE tag attribute: "${t}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=t;break}e=np(new qg({}),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"]);Gf(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?(fp.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(Gf(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&&Gf(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 Jg{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&&Gf(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 ev(e,t){return e.length===t.length&&!e.some((e,r)=>e!==t[r])}function tv(e,t){return!e&&!t||!(!e||!t)&&ev(e,t)}function rv(e){return"AES-128"===e||"AES-256"===e||"AES-256-CTR"===e}function iv(e){switch(e){case"AES-128":case"AES-256":return Lg;case"AES-256-CTR":return Ig;default:throw new Error(`invalid full segment method ${e}`)}}function nv(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0))}function sv(e){return Uint8Array.from(unescape(encodeURIComponent(e)),e=>e.charCodeAt(0))}function av(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 ov(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=nv(n)):r=function(e){const t=sv(e).subarray(0,16),r=new Uint8Array(16);return r.set(t,16-t.length),r}(n)}}return r}const lv="undefined"!=typeof self?self:void 0;var dv={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},cv="org.w3.clearkey",uv="com.apple.streamingkeydelivery",hv="com.microsoft.playready",fv="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function pv(e){switch(e){case uv:return dv.FAIRPLAY;case hv:return dv.PLAYREADY;case fv:return dv.WIDEVINE;case cv:return dv.CLEARKEY}}function mv(e){switch(e){case dv.FAIRPLAY:return uv;case dv.PLAYREADY:return hv;case dv.WIDEVINE:return fv;case dv.CLEARKEY:return cv}}function gv(e){const{drmSystems:t,widevineLicenseUrl:r}=e,i=t?[dv.FAIRPLAY,dv.WIDEVINE,dv.PLAYREADY,dv.CLEARKEY].filter(e=>!!t[e]):[];return!i[dv.WIDEVINE]&&r&&i.push(dv.WIDEVINE),i}const vv=null!=lv&&null!=(yv=lv.navigator)&&yv.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;var yv;function bv(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=nv(e).subarray(0,16);return av(t),t}}return null}let Ev={};class wv{static clearKeyUriToKeyIdMap(){Ev={}}static setKeyIdForUri(e,t){Ev[e]=t}static addKeyIdForUri(e){const t=Object.keys(Ev).length%Number.MAX_SAFE_INTEGER,r=new Uint8Array(16);return new DataView(r.buffer,12,4).setUint32(0,t),Ev[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&&!rv(e),null!=s&&s.startsWith("0x")&&(this.keyId=new Uint8Array(yp(s)))}matches(e){return e.uri===this.uri&&e.method===this.method&&e.encrypted===this.encrypted&&e.keyFormat===this.keyFormat&&ev(e.keyFormatVersions,this.keyFormatVersions)&&tv(e.iv,this.iv)&&tv(e.keyId,this.keyId)}isSupported(){if(this.method){if(rv(this.method)||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method;switch(this.keyFormat){case uv:case fv:case hv:case cv: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(rv(this.method)){let t=this.iv;t||("number"!=typeof e&&(fp.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 wv(this.method,this.uri,"identity",this.keyFormatVersions,t)}if(this.keyId){const e=Ev[this.uri];if(e&&!ev(this.keyId,e)&&wv.setKeyIdForUri(this.uri,this.keyId),this.pssh)return this}const r=ov(this.uri);if(r)switch(this.keyFormat){case fv: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=lm(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=Sv(t));break;case hv:{const e=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=om(e,0,r),this.keyId=bv(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[fv];if(t)return t.keyId;return null}(t),e||(e=Sv(t),e||(e=Ev[this.uri])),e&&(this.keyId=e,wv.setKeyIdForUri(this.uri,e))}return this}}function Sv(e){const t=null==e?void 0:e[hv];if(t){const e=ov(t.uri);if(e)return bv(e)}return null}const Tv=/#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,xv=/#EXT-X-MEDIA:(.*)/g,Av=/^#EXT(?:INF|-X-TARGETDURATION):/m,kv=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),Lv=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 Iv{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 Lp.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return Av.test(e)}static parseMasterPlaylist(e,t){const r={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:jg(e)},i=[];if(Tv.lastIndex=0,!e.startsWith("#EXTM3U"))return r.playlistParsingError=new Error("no EXTM3U delimiter"),r;let n;for(;null!=(n=Tv.exec(e));)if(n[1]){var s;const e=new qg(n[1],r),a=Hg(r,n[2]),o={attrs:e,bitrate:e.decimalInteger("BANDWIDTH")||e.decimalInteger("AVERAGE-BANDWIDTH"),name:e.NAME,url:Iv.resolve(a,t)},l=e.decimalResolution("RESOLUTION");l&&(o.width=l.width,o.height=l.height),_v(e.CODECS,o);const d=e["SUPPLEMENTAL-CODECS"];d&&(o.supplemental={},_v(d,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 qg(i,r),t=e["DATA-ID"];t&&(null===r.sessionData&&(r.sessionData={}),r.sessionData[t]=e);break}case"SESSION-KEY":{const e=Cv(i,t,r);e.encrypted&&e.isSupported()?(null===r.sessionKeys&&(r.sessionKeys=[]),r.sessionKeys.push(e)):fp.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${i}"`);break}case"DEFINE":Vg(r,new qg(i,r),t);break;case"CONTENT-STEERING":{const e=new qg(i,r);r.contentSteering={uri:Iv.resolve(e["SERVER-URI"],t),pathwayId:e["PATHWAY-ID"]||"."};break}case"START":r.startTimeOffset=Dv(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(xv.lastIndex=0;null!==(i=xv.exec(e));){const e=new qg(i[1],r),s=e.TYPE;if(s){const r=a[s],i=n[s]||[];n[s]=i;const l=e.LANGUAGE,d=e["ASSOC-LANGUAGE"],c=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?Iv.resolve(e.URI,t):""};if(d&&(f.assocLang=d),c&&(f.channels=c),u&&(f.characteristics=u),h&&(f.instreamId=h),null!=r&&r.length){const e=Iv.findGroup(r,f.groupId)||r[0];Ov(f,e,"audioCodec"),Ov(f,e,"textCodec")}i.push(f)}}return n}static parseLevelPlaylist(e,t,r,i,n,s){var a;const o={url:t},l=new Jg(t),d=l.fragments,c=[];let u,h,f,p,m=null,g=0,v=0,y=0,b=0,E=0,w=null,S=new Op(i,o),T=-1,x=!1,A=null;if(kv.lastIndex=0,l.m3u8=e,l.hasVariableRefs=jg(e),"#EXTM3U"!==(null==(a=kv.exec(e))?void 0:a[0]))return l.playlistParsingError=new Error("Missing format identifier #EXTM3U"),l;for(;null!==(u=kv.exec(e));){x&&(x=!1,S=new Op(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(Gf(S.duration)){S.playlistOffset=y,S.setStart(y),f&&Fv(S,f,l),S.sn=g,S.level=r,S.cc=b,d.push(S);const e=(" "+u[3]).slice(1);S.relurl=Hg(l,e),Mv(S,w,c),w=S,y+=S.duration,g++,v=0,x=!0}}else{if(u=u[0].match(Lv),!u){fp.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=d.length);break;case"PLAYLIST-TYPE":l.type&&$v(l,e,u),l.type=n.toUpperCase();break;case"MEDIA-SEQUENCE":0!==l.startSN?$v(l,e,u):d.length>0&&Bv(l,e,u),g=l.startSN=parseInt(n);break;case"SKIP":{l.skippedSegments&&$v(l,e,u);const t=new qg(n,l),r=t.decimalInteger("SKIPPED-SEGMENTS");if(Gf(r)){l.skippedSegments+=r;for(let e=r;e--;)d.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&&$v(l,e,u),l.targetduration=Math.max(parseInt(n),1);break;case"VERSION":null!==l.version&&$v(l,e,u),l.version=parseInt(n);break;case"INDEPENDENT-SEGMENTS":break;case"ENDLIST":l.live||$v(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),Gf(E)?S.bitrate=E:E=0;break;case"DATERANGE":{const e=new qg(n,l),t=new Zg(e,l.dateRanges[e.ID],l.dateRangeTagCount);l.dateRangeTagCount++,t.isValid||l.skippedSegments?l.dateRanges[t.id]=t:fp.warn(`Ignoring invalid DATERANGE tag: "${n}"`),S.tagList.push(["EXT-X-DATERANGE",n]);break}case"DEFINE":{const e=new qg(n,l);"IMPORT"in e?Wg(l,e,s):Vg(l,e,t)}break;case"DISCONTINUITY-SEQUENCE":0!==l.startCC?$v(l,e,u):d.length>0&&Bv(l,e,u),l.startCC=b=parseInt(n);break;case"KEY":{const e=Cv(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=np({},f)),f[e.keyFormat]=e)}else fp.warn(`[Keys] Ignoring unsupported EXT-X-KEY tag: "${n}"`);break}case"START":l.startTimeOffset=Dv(n);break;case"MAP":{const e=new qg(n,l);if(S.duration){const t=new Op(i,o);Nv(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;Nv(S,e,r,f),m=S,x=!0}m.cc=b;break}case"SERVER-CONTROL":p&&$v(l,e,u),p=new qg(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&&$v(l,e,u);const t=new qg(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 qg(n,l),s=new Mp(i,S,o,r,t);e.push(s),S.duration+=s.duration;break}case"PRELOAD-HINT":{const e=new qg(n,l);l.preloadHint=e;break}case"RENDITION-REPORT":{const e=new qg(n,l);l.renditionReports=l.renditionReports||[],l.renditionReports.push(e);break}default:fp.warn(`line parsed but not handled: ${u}`)}}}w&&!w.relurl?(d.pop(),y-=w.duration,l.partList&&(l.fragmentHint=w)):l.partList&&(Mv(S,w,c),S.cc=b,l.fragmentHint=S,f&&Fv(S,f,l)),l.targetduration||(l.playlistParsingError=new Error("Missing Target Duration"));const k=d.length,L=d[0],I=d[k-1];if(y+=l.skippedSegments*l.targetduration,y>0&&k&&I){l.averagetargetduration=y/k;const e=I.sn;l.endSN="initSegment"!==e?e:0,l.live||(I.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}}(d,T),L&&c.unshift(L))}return l.fragmentHint&&(y+=l.fragmentHint.duration),l.totalduration=y,c.length&&l.dateRangeTagCount&&L&&Rv(c,l),l.endCC=b,l}}function Rv(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]],d=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=Pv(t,d,e,i,n);if(-1!==r){l.tagAnchor=t.fragments[r].ref;break}}}}function Pv(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 Cv(e,t,r){var i,n;const s=new qg(e,r),a=null!=(i=s.METHOD)?i:"",o=s.URI,l=s.hexadecimalInteger("IV"),d=s.KEYFORMATVERSIONS,c=null!=(n=s.KEYFORMAT)?n:"identity";o&&s.IV&&!l&&fp.error(`Invalid IV: ${s.IV}`);const u=o?Iv.resolve(o,t):"",h=(d||"1").split("/").map(Number).filter(Number.isFinite);return new wv(a,u,c,h,l,s.KEYID)}function Dv(e){const t=new qg(e).decimalFloatingPoint("TIME-OFFSET");return Gf(t)?t:null}function _v(e,t){let r=(e||"").split(/[ ,]+/).filter(e=>e);["video","audio","text"].forEach(e=>{const i=r.filter(t=>um(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 Ov(e,t,r){const i=t[r];i&&(e[r]=i)}function Mv(e,t,r){e.rawProgramDateTime?r.push(e):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime)}function Nv(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 Fv(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 $v(e,t,r){e.playlistParsingError=new Error(`#EXT-X-${t} must not appear more than once (${r[0]})`)}function Bv(e,t,r){e.playlistParsingError=new Error(`#EXT-X-${t} must appear before the first Media Segment (${r[0]})`)}function Uv(e,t){const r=t.startPTS;if(Gf(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 zv(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 d=t.startPTS,c=t.endPTS;if(Gf(d)){const u=Math.abs(d-r);e&&u>e.totalduration?a.warn(`media timestamps and playlist times differ by ${u}s for level ${t.level} ${e.url}`):Gf(t.deltaPTS)?t.deltaPTS=Math.max(u,t.deltaPTS):t.deltaPTS=u,o=Math.max(r,d),r=Math.min(r,d),n=void 0!==t.startDTS?Math.min(n,t.startDTS):n,l=Math.min(i,c),i=Math.max(i,c),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--)Uv(m[f],m[f-1]);for(f=p;f<m.length-1;f++)Uv(m[f],m[f+1]);return e.fragmentHint&&Uv(m[m.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,u}function Gv(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 d=n;d<=s;d++){const n=l[a+d];let s=o[d];if(i&&!s&&n&&(s=t.fragments[d]=n),n&&s){r(n,s,d,o);const i=n.relurl,a=s.relurl;if(i&&Qv(i,a))return void(t.playlistParsingError=jv(`media sequence mismatch ${s.sn}:`,e,t,n,s));if(n.cc!==s.cc)return void(t.playlistParsingError=jv(`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}Gf(e.startPTS)&&Gf(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=np({},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 Zg(i[e].attr,t);n.isValid?(s[e]=n,t||(n.tagOrder+=a)):r.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${Gm(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&&Mv(o[e],o[e-1],i);Rv(i,t)}t.endCC=a[a.length-1].cc}if(!t.startCC){var l;const r=Yv(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?zv(t,s,s.startPTS,s.endPTS,s.startDTS,s.endDTS,r):Hv(e,t),a.length&&(t.totalduration=t.edge-a[0].start),t.driftStartTime=e.driftStartTime,t.driftStart=e.driftStart;const d=t.advancedDateTime;if(t.advanced&&d){const e=t.edge;t.driftStart||(t.driftStartTime=d,t.driftStart=e),t.driftEndTime=d,t.driftEnd=e}else t.driftEndTime=e.driftEndTime,t.driftEnd=e.driftEnd,t.advancedDateTime=e.advancedDateTime;-1===t.requestScheduled&&(t.requestScheduled=e.requestScheduled)}function jv(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 Hv(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}Vv(t,a)}function Vv(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 Wv(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 Yv(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 Kv(e,t,r){return e?qv(e.partList,t,r):null}function qv(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 Xv(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 Qv(e,t){return!(e===t||!t)&&Zv(e)!==Zv(t)}function Zv(e){return e.replace(/\?[^?]*$/,"")}function Jv(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 ey(e,t){const r=e.start+t;e.startPTS=r,e.setStart(r),e.endPTS=r+e.duration}function ty(e,t){const r=t.fragments;for(let t=0,i=r.length;t<i;t++)ey(r[t],e);t.fragmentHint&&ey(t.fragmentHint,e),t.alignedSliding=!0}function ry(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=Jv(t.fragments,r),n=Jv(e.fragments,r);if(!i||!n)return;fp.log(`Aligning playlist at start of dicontinuity sequence ${r}`);ty(i.start-n.start,e)}function iy(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=Jv(i,a),s=Jv(r,a)),n&&s||(n=i[Math.floor(i.length/2)],s=Jv(r,n.cc)||r[Math.floor(r.length/2)]);const o=n.programDateTime,l=s.programDateTime;if(!o||!l)return;ty((l-o)/1e3-(s.start-n.start),e)}function ny(e,t,r){sy(e,t,r),e.addEventListener(t,r)}function sy(e,t,r){e.removeEventListener(t,r)}const ay=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},oy="STOPPED",ly="IDLE",dy="KEY_LOADING",cy="FRAG_LOADING",uy="FRAG_LOADING_WAITING_RETRY",hy="WAITING_TRACK",fy="PARSING",py="PARSED",my="ENDED",gy="ERROR",vy="WAITING_INIT_PTS",yy="WAITING_LEVEL";class by extends $g{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=oy,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=zg.bufferInfo(i||r,s,e.maxBufferHole),o=!a.len;if(this.log(`Media seeking to ${Gf(s)?s.toFixed(3):s}, state: ${n}, ${o?"out of":"in"} buffer`),this.state===my)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===ly&&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 Og(e.config),this.keyLoader=r,this.fragmentTracker=t,this.config=e.config,this.decrypter=new Dg(e.config)}registerListeners(){const{hls:e}=this;e.on(Yf.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Yf.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Yf.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Yf.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(Yf.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(Yf.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Yf.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Yf.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Yf.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(Yf.ERROR,this.onError,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){if(this.state===oy)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=oy}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=zg.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 zg.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;ny(r,"seeking",this.onMediaSeeking),ny(r,"ended",this.onMediaEnded);const i=this.config;this.levels&&i.autoStartLoad&&this.state===oy&&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),sy(i,"seeking",this.onMediaSeeking),sy(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=oy,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===cy||!this.fragCurrent&&t===fy)&&(this.fragmentTracker.removeFragment(r),this.state=ly):("payload"in e&&(this.log(`Loaded ${r.type} sn: ${r.sn} of ${this.playlistLabel()} ${r.level}`),this.hls.trigger(Yf.FRAG_LOADED,e)),this._handleFragmentLoadComplete(e))}).catch(t=>{this.state!==oy&&this.state!==gy&&(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)===Eg){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)===wg&&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(Yf.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&&rv(n.method)){const s=self.performance.now();return this.decrypter.decrypt(new Uint8Array(i),n.key.buffer,n.iv.buffer,iv(n.method)).catch(e=>{throw t.trigger(Yf.ERROR,{type:Vf.MEDIA_ERROR,details:Wf.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:r}),e}).then(i=>{const n=self.performance.now();return t.trigger(Yf.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!==oy&&this.state!==gy&&(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!==oy&&(this.state=ly),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(Yf.ERROR,{type:Vf.KEY_SYSTEM_ERROR,details:Wf.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?ay(zg.getBuffered(r)):"(detached)"})`),_p(e)){var i;if(e.type!==ep){const t=e.elementaryStreams;if(!Object.keys(t).some(e=>!!t[e]))return void(this.state=ly)}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=ly}_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 Bg(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=dy,this.fragCurrent=e,a=this.keyLoader.load(e).then(e=>{if(!this.fragContextChanged(e.frag))return this.hls.trigger(Yf.KEY_LOADED,e),this.state===dy&&(this.state=ly),e}),this.hls.trigger(Yf.KEY_LOADING,{frag:e}),null===this.fragCurrent)return this.log("context changed in KEY_LOADING"),Promise.resolve(null);const o=this.fragPrevious;if(_p(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&&_p(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 d;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=cy,d=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(Yf.FRAG_LOADING,{frag:e,part:l,targetBufferTime:r}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):d}if(!e.url||this.loadedEndOfParts(n,r))return Promise.resolve(null)}}var l;if(_p(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))}`),Gf(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=cy;const d=this.config.progressive&&e.type!==ep;let c;return c=d&&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,d?i:void 0),a]).then(([e])=>(!d&&i&&i(e),e)).catch(e=>this.handleFragLoadError(e)),this.hls.trigger(Yf.FRAG_LOADING,{frag:e,targetBufferTime:r}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):c}doFragPartsLoad(e,t,r,i){return new Promise((n,s)=>{var a;const o=[],l=null==(a=r.details)?void 0:a.partList,d=t=>{this.fragmentLoader.loadPart(e,t,i).then(i=>{o[t.index]=i;const s=i.part;this.hls.trigger(Yf.FRAG_LOADED,i);const a=Kv(r.details,e.sn,t.index+1)||qv(l,e.sn,t.index+1);if(!a)return n({frag:e,part:s,partsLoaded:o});d(a)}).catch(s)};d(t)})}handleFragLoadError(e){if("data"in e){const t=e.data;t.frag&&t.details===Wf.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):t.frag&&t.type===Vf.KEY_SYSTEM_ERROR?(t.frag.abortRequests(),this.resetStartWhenNotLoaded(),this.resetFragmentLoading(t.frag)):this.hls.trigger(Yf.ERROR,t)}else this.hls.trigger(Yf.ERROR,{type:Vf.OTHER_ERROR,details:Wf.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){const t=this.getCurrentContext(e);if(!t||this.state!==fy)return void(this.fragCurrent||this.state===oy||this.state===gy||(this.state=ly));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===ep)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?Kv(o,n,s):null,d=l?l.fragment:Yv(o,n,r);return d?(r&&r!==d&&(d.stats=r.stats),{frag:d,part:l,level:a}):null}bufferFragmentData(e,t,r,i,n){if(this.state!==fy)return;const{data1:s,data2:a}=e;let o=s;if(a&&(o=tm(s,a)),!o.length)return;const l=this.initPTS[t.cc],d=l?-l.baseTime/l.timescale:void 0,c={type:e.type,frag:t,part:r,chunkMeta:i,offset:d,parent:t.type,data:o};if(this.hls.trigger(Yf.BUFFER_APPENDING,c),e.dropped&&e.independent&&!r){if(n)return;this.flushBufferGap(t)}}flushBufferGap(e){const t=this.media;if(!t)return;if(!zg.isBuffered(t,t.currentTime))return void this.flushMainBuffer(0,e.start);const r=t.currentTime,i=zg.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(!Gf(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=zg.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 zg.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=Zf){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 d=this.filterReplacedPrimary(o,t);if(!d&&o){const e=o.sn-t.startSN;d=this.filterReplacedPrimary(r[e+1]||null,t)}return this.mapToInitFragWhenRequired(d)}isLoopLoading(e,t){const r=this.fragmentTracker.getState(e);return(r===Sg||r===wg&&!!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(Ey(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(Ey(this.config)&&e.type!==ep){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||!Gf(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(eg(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=tg(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,d=r.partList,c=!!(this.loadingParts&&null!=d&&d.length&&o);let u;if(c&&!this.bitrateTest&&d[d.length-1].fragment.sn===o.sn&&(s=s.concat(o),a=o.sn),e<t){var h;u=Zm(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===Sg||t===wg&&u.gap)&&(n=u),n&&u.sn===n.sn&&(!c||d[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)!==Sg?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&&Gf(n);if(s||!a&&!n){!function(e,t){e&&(ry(t,e),t.alignedSliding||iy(t,e),t.alignedSliding||t.skippedSegments||Hv(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&&Gf(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&&_p(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===uy)||(this.state=ly)}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===Wf.FRAG_GAP;s&&this.fragmentTracker.fragBuffered(i,!0);const a=t.errorAction;if(!a)return void(this.state=gy);const{action:o,flags:l,retryCount:d=0,retryConfig:c}=a,u=!!c,h=u&&o===fg,f=u&&!a.resolved&&l===mg,p=null==(r=this.hls.latestLevelDetails)?void 0:r.live;if(!h&&f&&_p(i)&&!i.endList&&p&&!ng(t))this.resetFragmentErrors(e),this.treatAsGap(i),a.resolved=!0;else if((h||f)&&d<c.maxNumRetry){var m;const r=dg(null==(m=t.response)?void 0:m.code),n=ag(c,d);if(this.resetStartWhenNotLoaded(),this.retryDate=self.performance.now()+n,this.state=uy,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 ${d+1}/${c.maxNumRetry} in ${n}ms`)}else if(c){if(this.resetFragmentErrors(e),!(d<c.maxNumRetry))return void this.warn(`${t.details} reached or exceeded max retry (${d})`);s||o===hg||(a.resolved=!0)}else this.state=o===ug?yy:gy;this.tickImmediate()}checkRetryDate(){const e=self.performance.now(),t=this.retryDate,r=t===1/0;(!t||e>=t||r&&!dg(0))&&(r&&this.log("Connection restored (online)"),this.resetStartWhenNotLoaded(),this.state=ly)}reduceLengthAndFlushBuffer(e){if(this.state===fy||this.state===py){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===Jf&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==oy&&(this.state=ly)}afterBufferFlushed(e,t,r){if(!e)return;const i=zg.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,i,r),this.state===my&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==oy&&(this.state=ly)}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:zv(n,e,a.startPTS,a.endPTS,a.startDTS,a.endDTS,this);return this.hls.trigger(Yf.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(Yf.ERROR,{type:Vf.MEDIA_ERROR,details:Wf.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=py,this.log(`Parsed ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)})`),this.hls.trigger(Yf.FRAG_PARSED,{frag:e,part:t})}playlistLabel(){return this.playlistType===Zf?"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 Ey(e){return!!e.interstitialsController&&!1!==e.enableInterstitialPlayback}class wy{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 Sy,Ty={exports:{}};var xy=(Sy||(Sy=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,d,c=this._events[o],u=arguments.length;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),u){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,i),!0;case 4:return c.fn.call(c.context,t,i,n),!0;case 5:return c.fn.call(c.context,t,i,n,s),!0;case 6:return c.fn.call(c.context,t,i,n,s,a),!0}for(d=1,l=new Array(u-1);d<u;d++)l[d-1]=arguments[d];c.fn.apply(c.context,l)}else{var h,f=c.length;for(d=0;d<f;d++)switch(c[d].once&&this.removeListener(e,c[d].fn,void 0,!0),u){case 1:c[d].fn.call(c[d].context);break;case 2:c[d].fn.call(c[d].context,t);break;case 3:c[d].fn.call(c[d].context,t,i);break;case 4:c[d].fn.call(c[d].context,t,i,n);break;default:if(!l)for(h=1,l=new Array(u-1);h<u;h++)l[h-1]=arguments[h];c[d].fn.apply(c[d].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,d=[],c=o.length;l<c;l++)(o[l].fn!==t||n&&!o[l].once||i&&o[l].context!==i)&&d.push(o[l]);d.length?this._events[s]=1===d.length?d[0]:d: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}(Ty)),Ty.exports),Ay=bp(xy);const ky="1.6.15",Ly={};function Iy(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 Ry(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 Py(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 Cy(e,t){const r=t;let i=0;for(;Ry(e,t);){i+=10;i+=Py(e,t+6),Iy(e,t+10)&&(i+=10),t+=i}if(i>0)return e.subarray(r,r+i)}function Dy(e,t){return 255===e[t]&&240==(246&e[t+1])}function _y(e,t){return 1&e[t+1]?7:9}function Oy(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function My(e,t){return t+1<e.length&&Dy(e,t)}function Ny(e,t){if(My(e,t)){const r=_y(e,t);if(t+r>=e.length)return!1;const i=Oy(e,t);if(i<=r)return!1;const n=t+i;return n===e.length||My(e,n)}return!1}function Fy(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(Yf.ERROR,Yf.ERROR,{type:Vf.MEDIA_ERROR,details:Wf.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,d=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][s];let c=s;5!==a&&29!==a||(c-=3);const u=[a<<3|(14&c)>>1,(1&c)<<7|o<<3];return fp.log(`manifest codec:${i}, parsed codec:${l}, channels:${o}, rate:${d} (ADTS object type:${a} sampling index:${s})`),{config:u,samplerate:d,channelCount:o,codec:l,parsedCodec:l,manifestCodec:i}}(t,r,i,n);if(!s)return;np(e,s)}}function $y(e){return 9216e4/e}function By(e,t,r,i,n){const s=i+n*$y(e.samplerate),a=function(e,t){const r=_y(e,t);if(t+r<=e.length){const i=Oy(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,d=Math.max(0,r+l-t.length);d?(o=new Uint8Array(l-n),o.set(t.subarray(r+n,t.length),0)):o=t.subarray(r+n,r+l);const c={unit:o,pts:s};return d||e.samples.push(c),{sample:c,length:l,missing:d}}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 Uy(e,t){return Ry(e,t)&&Py(e,t+6)+10<=e.length-t}function zy(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,d=Math.floor(Math.max(0,Math.min(l,o))),c=Math.floor(Math.min(d+Math.max(r,0),o));var u;return new i(n,d,c-d)}(e,t,r,Uint8Array)}function Gy(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=gp(zy(e.data,1,r)),n=e.data[2+r],s=e.data.subarray(3+r).indexOf(0);if(-1===s)return;const a=gp(zy(e.data,3+r,s));let o;return o="--\x3e"===i?gp(zy(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 jy(e){return"PRIV"===e.type?function(e){if(e.size<2)return;const t=gp(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=gp(e.data.subarray(t),!0);t+=r.length+1;const i=gp(e.data.subarray(t));return{key:e.type,info:r,data:i}}const t=gp(e.data);return{key:e.type,info:"",data:t}}(e):"APIC"===e.type?Gy(e):function(e){if(e.size<2)return;if("TXXX"===e.type){let t=1;const r=gp(e.data.subarray(t),!0);t+=r.length+1;const i=gp(e.data.subarray(t));return{key:e.type,info:r,data:i}}const t=gp(e.data.subarray(1));return{key:e.type,info:"",data:t}}(e)}function Hy(e){const t=String.fromCharCode(e[0],e[1],e[2],e[3]),r=Py(e,4);return{type:t,size:r,data:e.subarray(10,10+r)}}function Vy(e){let t=0;const r=[];for(;Ry(e,t);){const i=Py(e,t+6);e[t+5]>>6&1&&(t+=10),t+=10;const n=t+i;for(;t+10<n;){const i=Hy(e.subarray(t)),n=jy(i);n&&r.push(n),t+=i.size+10}Iy(e,t)&&(t+=10)}return r}function Wy(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info}function Yy(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 Ky(e){const t=Vy(e);for(let e=0;e<t.length;e++){const r=t[e];if(Wy(r))return Yy(r)}}let qy=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 Xy(e="",t=9e4){return{type:e,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}class Qy{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=tm(this.cachedData,e),this.cachedData=null);let r,i=Cy(e,0),n=i?i.length:0;const s=this._audioTrack,a=this._id3Track,o=i?Ky(i):void 0,l=e.length;for((null===this.basePTS||0===this.frameIndex&&Gf(o))&&(this.basePTS=Zy(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:qy.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 Uy(e,n)?(i=Cy(e,n),a.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:qy.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=tm(this.cachedData,t):this.cachedData=t}}return{audioTrack:s,videoTrack:Xy(),id3Track:a,textTrack:Xy()}}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:Xy(),id3Track:this._id3Track,textTrack:Xy()}}destroy(){this.cachedData=null,this._audioTrack=this._id3Track=void 0}}const Zy=(e,t,r)=>{if(Gf(e))return 90*e;return 9e4*t+(r?9e4*r.baseTime/r.timescale:0)};let Jy=null;const eb=[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],tb=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],rb=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],ib=[0,1,1,4];function nb(e,t,r,i,n){if(r+24>t.length)return;const s=sb(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 sb(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*eb[14*(3===r?3-i:3===i?3:4)+n-1],d=tb[3*(3===r?0:2===r?1:2)+s],c=3===o?1:2,u=rb[r][i],h=ib[i],f=8*u*h,p=Math.floor(u*l/d+a)*h;if(null===Jy){const e=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Jy=e?parseInt(e[1]):0}return!!Jy&&Jy<=87&&2===i&&l>=224e3&&0===o&&(e[t+3]=128|e[t+3]),{sampleRate:d,channelCount:c,frameLength:p,samplesPerFrame:f}}}function ab(e,t){return!(255!==e[t]||224&~e[t+1]||!(6&e[t+1]))}function ob(e,t){return t+1<e.length&&ab(e,t)}function lb(e,t){if(t+1<e.length&&ab(e,t)){const r=4,i=sb(e,t);let n=r;null!=i&&i.frameLength&&(n=i.frameLength);const s=t+n;return s===e.length||ob(e,s)}return!1}const db=(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 cb extends Qy{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=ub(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=Cy(e,0);if(!t)return!1;const r=t.length;return 11===e[r]&&119===e[r+1]&&void 0!==Ky(t)&&db(e,r)<16}}function ub(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 d=t[r+6]>>5;let c=0;2===d?c+=2:(1&d&&1!==d&&(c+=2),4&d&&(c+=2));const u=(t[r+6]<<8|t[r+7])>>12-c&1,h=[2,1,2,3,3,4,4,5][d]+u,f=t[r+5]>>3,p=7&t[r+5],m=new Uint8Array([s<<6|f<<1|p>>2,(3&p)<<6|d<<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 hb=/\/emsg[-/]ID3/i;function fb(e,t){return Gf(e.presentationTime)?e.presentationTime/e.timeScale:t+e.presentationTimeDelta/e.timeScale}class pb{constructor(e,t,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new Dg(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,Lg)}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=am(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 mb{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,d,c=0,u=-1,h=0;for(-1===n&&(u=0,h=this.getNALuType(t,0),n=0,c=1);c<i;)if(o=t[c++],n)if(1!==n)if(o)if(1===o){if(l=c-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&&c<=4-s&&r.state&&(r.data=r.data.subarray(0,r.data.byteLength-s)),l>0&&(r.data=tm(r.data,t.subarray(0,l)),r.state=0))}c<i?(d=this.getNALuType(t,c),u=c,h=d,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=tm(r.data,t))}return e.naluState=n,a}}class gb{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&&fp.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 vb extends mb{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 d;if(t)null!=(d=a)&&d.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,sm(i.data,1,r.pts,t.samples);break;case 7:{var c,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==(c=e.pixelRatio)?void 0:c[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 gb(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 gb(e);let r,i,n,s=0,a=0,o=0,l=0;const d=t.readUByte.bind(t),c=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);d();const v=d();if(c(5),f(3),d(),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=c(1);0===w&&f(1),f(1),h()&&(s=u(),a=u(),o=u(),l=u());let S=[1,1];if(h()&&h()){switch(d()){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=[d()<<8|d(),d()<<8|d()]}}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 yb extends mb{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 d;if(s=!0,o)null!=(d=a)&&d.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,sm(i.data,2,r.pts,t.samples);break;case 32:s=!0,e.vps||("object"!=typeof e.params&&(e.params={}),e.params=np(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 gb(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 gb(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(),d=t.readUByte(),c=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 L=t.readUEG(),I=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|d;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,d],general_constraint_indicator_flags:[c,u,h,f,p,m],general_level_idc:g,bit_depth:L+8,bit_depth_luma_minus8:L,bit_depth_chroma_minus8:I,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 gb(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 bb=188;class Eb{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=Eb.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-bb)+1,i=0;for(;i<r;){let n=!1,s=-1,a=0;for(let o=i;o<t;o+=bb){if(71!==e[o]||t-o!==bb&&71!==e[o+bb]){if(a)return-1;break}if(a++,-1===s&&(s=o,0!==s&&(r=Math.min(s+18612,e.length-bb)+1)),n||(n=0===wb(e,o)),n&&a>1&&(0===s&&a>2||o+bb>r))return s}i++}return-1}static createTrack(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:Bp[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=Eb.createTrack("video"),this._videoTrack.duration=i,this._audioTrack=Eb.createTrack("audio",i),this._id3Track=Eb.createTrack("id3"),this._txtTrack=Eb.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 d=s.pid,c=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=tm(this.remainderData,e)).length,this.remainderData=null),y<bb&&!i)return this.remainderData=e,{audioTrack:a,videoTrack:s,id3Track:o,textTrack:l};const b=Math.max(0,Eb.syncOffset(e));y-=(y-b)%bb,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+=bb)if(71===e[t]){const i=!!(64&e[t+1]),y=wb(e,t);let E;if((48&e[t+3])>>4>1){if(E=t+5+e[t+4],E===t+bb)continue}else E=t+4;switch(y){case d:i&&(c&&(n=kb(c,this.logger))&&(this.readyVideoParser(s.segmentCodec),null!==this.videoParser&&this.videoParser.parsePES(s,l,n,!1)),c={data:[],size:0}),c&&(c.data.push(e.subarray(E,t+bb)),c.size+=t+bb-E);break;case u:if(i){if(f&&(n=kb(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+bb)),f.size+=t+bb-E);break;case h:i&&(p&&(n=kb(p,this.logger))&&this.parseID3PES(o,n),p={data:[],size:0}),p&&(p.data.push(e.subarray(E,t+bb)),p.size+=t+bb-E);break;case 0:i&&(E+=e[E]+1),v=this._pmtId=Sb(e,E);break;case v:{i&&(E+=e[E]+1);const n=Tb(e,E,this.typeSupported,r,this.observer,this.logger);d=n.videoPid,d>0&&(s.pid=d,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&&xb(this.observer,new Error(`Found ${E} TS packet/s that do not start with 0x47`),void 0,this.logger),s.pesData=c,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=kb(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=kb(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=kb(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 pb(this.observer,this.config,t);return this.decrypt(i,n)}readyVideoParser(e){null===this.videoParser&&("avc"===e?this.videoParser=new vb:"hevc"===e&&(this.videoParser=new yb))}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=tm(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&&!My(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",xb(this.observer,new Error(e),t,this.logger),!t)return}if(Fy(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=$y(e.samplerate);a=i.sample.pts+t}}let l,d=0;for(;n<s;){if(l=By(e,o,n,a,d),n+=l.length,l.missing){this.aacOverFlow=l;break}for(d++;n<s-1&&!My(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(ob(r,s)){const t=nb(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=ub(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=np({},t,{type:this._videoTrack?qy.emsg:qy.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(r)}}function wb(e,t){return((31&e[t+1])<<8)+e[t+2]}function Sb(e,t){return(31&e[t+10])<<8|e[t+11]}function Tb(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=wb(e,t),l=(15&e[t+3])<<8|e[t+4];switch(e[t]){case 207:if(!i){Ab("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){Ab("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){Ab("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 xb(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 xb(e,t,r,i){i.warn(`parsing error: ${t.message}`),e.emit(Yf.ERROR,Yf.ERROR,{type:Vf.MEDIA_ERROR,details:Wf.FRAG_PARSING_ERROR,fatal:!1,levelRetry:r,error:t,reason:t.message})}function Ab(e,t){t.log(`${e} with AES-128-CBC encryption found in unencrypted stream`)}function kb(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]=tm(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 d=r[7];192&d&&(s=536870912*(14&r[9])+4194304*(255&r[10])+16384*(254&r[11])+128*(255&r[12])+(254&r[13])/2,64&d?(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 c=n+9;if(e.size<=c)return null;e.size-=c;const u=new Uint8Array(e.size);for(let e=0,t=l.length;e<t;e++){r=l[e];let t=r.byteLength;if(c){if(c>t){c-=t;continue}r=r.subarray(c),t-=c,c=0}u.set(r,o),o+=t}return i&&(i-=n+3),{data:u,pts:s,dts:a,len:i}}return null}class Lb{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 Ib=Math.pow(2,32)-1;class Rb{static init(){let e;for(e in Rb.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:[]},Rb.types)Rb.types.hasOwnProperty(e)&&(Rb.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]);Rb.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]);Rb.STTS=Rb.STSC=Rb.STCO=n,Rb.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),Rb.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),Rb.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),Rb.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]);Rb.FTYP=Rb.box(Rb.types.ftyp,s,o,s,a),Rb.DINF=Rb.box(Rb.types.dinf,Rb.box(Rb.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 Rb.box(Rb.types.hdlr,Rb.HDLR_TYPES[e])}static mdat(e){return Rb.box(Rb.types.mdat,e)}static mdhd(e,t){t*=e;const r=Math.floor(t/(Ib+1)),i=Math.floor(t%(Ib+1));return Rb.box(Rb.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 Rb.box(Rb.types.mdia,Rb.mdhd(e.timescale||0,e.duration||0),Rb.hdlr(e.type),Rb.minf(e))}static mfhd(e){return Rb.box(Rb.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?Rb.box(Rb.types.minf,Rb.box(Rb.types.smhd,Rb.SMHD),Rb.DINF,Rb.stbl(e)):Rb.box(Rb.types.minf,Rb.box(Rb.types.vmhd,Rb.VMHD),Rb.DINF,Rb.stbl(e))}static moof(e,t,r){return Rb.box(Rb.types.moof,Rb.mfhd(e),Rb.traf(r,t))}static moov(e){let t=e.length;const r=[];for(;t--;)r[t]=Rb.trak(e[t]);return Rb.box.apply(null,[Rb.types.moov,Rb.mvhd(e[0].timescale||0,e[0].duration||0)].concat(r).concat(Rb.mvex(e)))}static mvex(e){let t=e.length;const r=[];for(;t--;)r[t]=Rb.trex(e[t]);return Rb.box.apply(null,[Rb.types.mvex,...r])}static mvhd(e,t){t*=e;const r=Math.floor(t/(Ib+1)),i=Math.floor(t%(Ib+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 Rb.box(Rb.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 Rb.box(Rb.types.sdtp,r)}static stbl(e){return Rb.box(Rb.types.stbl,Rb.stsd(e),Rb.box(Rb.types.stts,Rb.STTS),Rb.box(Rb.types.stsc,Rb.STSC),Rb.box(Rb.types.stsz,Rb.STSZ),Rb.box(Rb.types.stco,Rb.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=Rb.box(Rb.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,d=e.pixelRatio[0],c=e.pixelRatio[1];return Rb.box(Rb.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,Rb.box(Rb.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),Rb.box(Rb.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,255&d,c>>24,c>>16&255,c>>8&255,255&c])))}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 Rb.box(Rb.types.mp4a,Rb.audioStsd(e),Rb.box(Rb.types.esds,Rb.esds(e)))}static mp3(e){return Rb.box(Rb.types[".mp3"],Rb.audioStsd(e))}static ac3(e){return Rb.box(Rb.types["ac-3"],Rb.audioStsd(e),Rb.box(Rb.types.dac3,e.config))}static stsd(e){const{segmentCodec:t}=e;if("audio"===e.type){if("aac"===t)return Rb.box(Rb.types.stsd,Rb.STSD,Rb.mp4a(e));if("ac3"===t&&e.config)return Rb.box(Rb.types.stsd,Rb.STSD,Rb.ac3(e));if("mp3"===t&&"mp3"===e.codec)return Rb.box(Rb.types.stsd,Rb.STSD,Rb.mp3(e))}else{if(!e.pps||!e.sps)throw new Error("video track missing pps or sps");if("avc"===t)return Rb.box(Rb.types.stsd,Rb.STSD,Rb.avc1(e));if("hevc"===t&&e.vps)return Rb.box(Rb.types.stsd,Rb.STSD,Rb.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/(Ib+1)),a=Math.floor(r%(Ib+1));return Rb.box(Rb.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=Rb.sdtp(e),i=e.id,n=Math.floor(t/(Ib+1)),s=Math.floor(t%(Ib+1));return Rb.box(Rb.types.traf,Rb.box(Rb.types.tfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i])),Rb.box(Rb.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])),Rb.trun(e,r.length+16+20+8+16+8+8),r)}static trak(e){return e.duration=e.duration||4294967295,Rb.box(Rb.types.trak,Rb.tkhd(e),Rb.mdia(e))}static trex(e){const t=e.id;return Rb.box(Rb.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,d,c,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,d=o.size,c=o.flags,u=o.cts,s.set([l>>>24&255,l>>>16&255,l>>>8&255,255&l,d>>>24&255,d>>>16&255,d>>>8&255,255&d,c.isLeading<<2|c.dependsOn,c.isDependedOn<<6|c.hasRedundancy<<4|c.paddingValue<<1|c.isNonSync,61440&c.degradPrio,15&c.degradPrio,u>>>24&255,u>>>16&255,u>>>8&255,255&u],12+16*a);return Rb.box(Rb.types.trun,s)}static initSegment(e){Rb.types||Rb.init();const t=Rb.moov(e);return tm(Rb.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=Rb.box(Rb.types.hvcC,s),l=e.width,d=e.height,c=e.pixelRatio[0],u=e.pixelRatio[1];return Rb.box(Rb.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,d>>8&255,255&d,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,Rb.box(Rb.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),Rb.box(Rb.types.pasp,new Uint8Array([c>>24,c>>16&255,c>>8&255,255&c,u>>24,u>>16&255,u>>8&255,255&u])))}}Rb.types=void 0,Rb.HDLR_TYPES=void 0,Rb.STTS=void 0,Rb.STSC=void 0,Rb.STCO=void 0,Rb.STSZ=void 0,Rb.VMHD=void 0,Rb.SMHD=void 0,Rb.STSD=void 0,Rb.FTYP=void 0,Rb.DINF=void 0;function Pb(e,t,r=1,i=!1){const n=e*t*r;return i?Math.round(n):n}function Cb(e,t=!1){return Pb(e,1e3,1/9e4,t)}function Db(e){const{baseTime:t,timescale:r,trackId:i}=e;return`${t/r} (${t}/${r}) trackId: ${i}`}let _b,Ob=null,Mb=null;function Nb(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 Fb extends op{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===Ob){const e=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Ob=e?parseInt(e[1]):0}if(null===Mb){const e=navigator.userAgent.match(/Safari\/(\d+)/i);Mb=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?Db(t):t} > ${e?Db(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=$b(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,d,c,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||(c=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=($b(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"),c=this.generateIS(e,t,n,s)),d=this.remuxAudio(e,p,this.isAudioContiguous,s,v||E||o===Jf?m:void 0),E){const i=d?d.endPTS-d.startPTS:0;t.inputTimeScale||(this.warn("regenerate InitSegment as video detected"),c=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=Bb(r,n,this._initPTS,this._initDTS)),i.samples.length&&(u=Ub(i,n,this._initPTS))),{audio:d,video:l,initSegment:c,independent:f,text:u,id3:h}}computeInitPts(e,t,r,i){const n=Math.round(r*t);let s=$b(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 d,c,u,h=!l||i,f="audio/mp4",p=-1;if(h&&(d=c=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):Rb.initSegment([e]),metadata:{channelCount:e.channelCount}},h&&(p=e.id,u=e.inputTimeScale,l&&u===l.timescale?h=!1:d=c=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:Rb.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=$b(s[0].dts,e),i=this.computeInitPts(t,u,r,"video"),n=this.computeInitPts(e,u,r,"video");c=Math.min(c,i),d=Math.min(d,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} ${d/u} != initPTS: ${l.baseTime/l.timescale} (${l.baseTime}/${l.timescale}) trackId: ${l.trackId}`),this.log(`Found initPTS at playlist time: ${r} offset: ${d/u} (${d}/${u}) trackId: ${p}`),this._initPTS={baseTime:d,timescale:u,trackId:p},this._initDTS={baseTime:c,timescale:u,trackId:p}):d=u=void 0,{tracks:o,initPTS:d,timescale:u,trackId:p}}remuxVideo(e,t,r,i){const n=e.inputTimeScale,s=e.samples,a=[],o=s.length,l=this._initPTS,d=l.baseTime*n/l.timescale;let c,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=d+t*n,i=s[0].pts-$b(s[0].dts,s[0].pts);Ob&&null!==h&&Math.abs(e-i-(h+d))<15e3?r=!0:h=e-i-d}const y=h+d;for(let e=0;e<o;e++){const t=s[e];t.pts=$b(t.pts,y),t.dts=$b(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}),c=s[0].dts,u=s[s.length-1].dts;const b=u-c,E=b?Math.round(b/(o-1)):p||e.inputTimeScale/30;if(r){const r=c-y,i=r>E,n=r<-1;if((i||n)&&(i?this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${Cb(r,!0)} ms (${r}dts) hole between fragments detected at ${t.toFixed(3)}`):this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${Cb(-r,!0)} ms (${r}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!n||y>=s[0].pts||Ob)){c=y;const e=s[0].pts-r;if(i)s[0].dts=c,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: ${Cb(e,!0)}/${Cb(c,!0)}, delta: ${Cb(r,!0)} ms`)}}c=Math.max(0,c);let w=0,S=0,T=c;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(Yf.ERROR,Yf.ERROR,{type:Vf.MUX_ERROR,details:Wf.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(Rb.types.mdat,4);let L=!1,I=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,c=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,c+=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+d)-t.pts;s>e?(p=s-a,p<0?p=a:L=!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);I=Math.min(I,p),P=Math.max(P,p),R=Math.min(R,l),C=Math.max(C,l),a.push(Nb(t.key,p,c,u))}if(a.length)if(Ob){if(Ob<70){const e=a[0].flags;e.dependsOn=2,e.isNonSync=0}}else if(Mb&&C-R<P-I&&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=c;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=L||!p?E:p;const D=u+p;this.nextVideoTs=h=D-d,this.videoSampleDuration=p,this.isVideoContiguous=!0;const _={data1:Rb.moof(e.sequenceNumber++,c,np(e,{samples:a})),data2:A,startPTS:(m-d)/n,endPTS:(g+p-d)/n,startDTS:(c-d)/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,d=this._initPTS,c="mp3"===e.segmentCodec&&this.typeSupported.mpeg,u=[],h=void 0!==n;let f=e.samples,p=c?0:8,m=this.nextAudioTs||-1;const g=d.baseTime*s/d.timescale,v=g+t*s;if(this.isAudioContiguous=r=r||f.length&&m>0&&(i&&Math.abs(v-(m+g))<9e3||Math.abs($b(f[0].pts,v)-(m+g))<20*l),f.forEach(function(e){e.pts=$b(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,d=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&&d<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=Lb.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(Yf.ERROR,Yf.ERROR,{type:Vf.MUX_ERROR,details:Wf.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:w,reason:`fail allocating audio mdat ${w}`})}if(!c){new DataView(y.buffer).setUint32(0,w),y.set(Rb.types.mdat,4)}}y.set(n,p);const l=n.byteLength;p+=l,u.push(Nb(!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=c?new Uint8Array(0):Rb.moof(e.sequenceNumber++,b/a,np({},e,{samples:u}));e.samples=[];const k=(b-g)/s,L=this.nextAudioTs/s,I={data1:A,data2:y,startPTS:k,endPTS:L,startDTS:k,endDTS:L,type:"audio",hasAudio:!0,hasVideo:!1,nb:T};return this.isAudioContiguous=!0,I}}function $b(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 Bb(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=$b(n.pts-r.baseTime*s/r.timescale,t*s)/s,n.dts=$b(n.dts-i.baseTime*s/i.timescale,t*s)/s}const a=e.samples;return e.samples=[],{samples:a}}function Ub(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=$b(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 zb(e,t,r=!1){return void 0!==(null==e?void 0:e.start)?(e.start+(r?e.duration:0))/e.timescale:t}function Gb(e,t,r){const i=e.codec;if(i&&i.length>4)return i;if(t===Rp){if("ec-3"===i||"ac-3"===i||"alac"===i)return i;if("fLaC"===i||"Opus"===i){return bm(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{_b=self.performance.now.bind(self.performance)}catch(e){_b=Date.now}const jb=[{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=Xy("video",1),s=this.audioTrack=Xy("audio",1),a=this.txtTrack=Xy("text",1);if(this.id3Track=Xy("id3",1),this.timeOffset=0,null==e||!e.byteLength)return;const o=Yp(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=Bp.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=Gp(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=tm(this.remainderData,e));const t=function(e){const t={valid:null,remainder:null},r=Vp(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=rm(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=rm(e,t),{videoTrack:t,audioTrack:Xy(),id3Track:i,textTrack:Xy()}}extractID3Track(e,t){const r=this.id3Track;if(e.samples.length){const i=Vp(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,d=0;if(0===t){for(;"\0"!==Up(e.subarray(d,d+1));)r+=Up(e.subarray(d,d+1)),d+=1;for(r+=Up(e.subarray(d,d+1)),d+=1;"\0"!==Up(e.subarray(d,d+1));)i+=Up(e.subarray(d,d+1)),d+=1;i+=Up(e.subarray(d,d+1)),d+=1,n=Gp(e,12),s=Gp(e,16),o=Gp(e,20),l=Gp(e,24),d=28}else if(1===t){d+=4,n=Gp(e,d),d+=4;const t=Gp(e,d);d+=4;const s=Gp(e,d);for(d+=4,a=2**32*t+s,jf(a)||(a=Number.MAX_SAFE_INTEGER,fp.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=Gp(e,d),d+=4,l=Gp(e,d),d+=4;"\0"!==Up(e.subarray(d,d+1));)r+=Up(e.subarray(d,d+1)),d+=1;for(r+=Up(e.subarray(d,d+1)),d+=1;"\0"!==Up(e.subarray(d,d+1));)i+=Up(e.subarray(d,d+1)),d+=1;i+=Up(e.subarray(d,d+1)),d+=1}return{schemeIdUri:r,value:i,timeScale:n,presentationTime:a,presentationTimeDelta:s,eventDuration:o,id:l,payload:e.subarray(d,e.byteLength)}}(e);if(hb.test(i.schemeIdUri)){const e=fb(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:qy.emsg,duration:n})}else if(this.config.enableEmsgKLVMetadata&&i.schemeIdUri.startsWith("urn:misb:KLV:bin:1910.1")){const e=fb(i,t);r.samples.push({data:i.payload,len:i.payload.byteLength,dts:e,pts:e,type:qy.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 op{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=Yp(e);if(t)!function(e,t){if(!e||!t)return;const r=t.keyId;r&&t.isCommonEncryption&&Jp(e,(e,t)=>{const i=e.subarray(8,24);i.some(e=>0!==e)||(fp.log(`[eme] Patching keyId in 'enc${t?"a":"v"}>sinf>>tenc' box: ${vp(i)} -> ${vp(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=Gb(n,Rp,this)),s&&(i=Gb(s,Pp,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:d}=this;const c={audio:void 0,video:void 0,text:i,id3:r,initSegment:void 0};Gf(d)||(d=this.lastEndTime=n||0);const u=t.samples;if(!u.length)return c;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."),c;this.emitInitSegment&&(h.tracks=this.initTracks,this.emitInitSegment=!1);const p=function(e,t,r){const i={},n=Vp(e,["moof","traf"]);for(let e=0;e<n.length;e++){const s=n[e],a=Vp(s,["tfhd"])[0],o=Gp(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 d=i[o],c=Vp(s,["tfdt"])[0];if(c){const e=c[0];let t=Gp(c,4);1===e&&(t===Fp?r.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"):(t*=Fp+1,t+=Gp(c,8))),Gf(t)&&(!Gf(d.start)||t<d.start)&&(d.start=t)}const u=l.default,h=Gp(a,0)|(null==u?void 0:u.flags);let f=(null==u?void 0:u.duration)||0;8&h&&(f=Gp(a,2&h?12:8));const p=Vp(s,["trun"]);let m=d.start||0,g=0,v=f;for(let e=0;e<p.length;e++){const t=p[e],r=Gp(t,4),i=d.sampleCount;d.sampleCount+=r;const n=1&t[3],s=4&t[3],a=1&t[2],o=2&t[2],l=4&t[2],c=8&t[2];let u=8,h=r;for(n&&(u+=4),s&&r&&(1&t[u+1]||void 0!==d.keyFrameIndex||(d.keyFrameIndex=i),u+=4,a?(v=Gp(t,u),u+=4):v=f,o&&(u+=4),c&&(u+=4),m+=v,g+=v,h--);h--;)a?(v=Gp(t,u),u+=4):v=f,o&&(u+=4),l&&(1&t[u+1]||void 0===d.keyFrameIndex&&(d.keyFrameIndex=d.sampleCount-(h+1),d.keyFrameStart=m),u+=4),c&&(u+=4),m+=v,g+=v;!g&&f&&(g+=f*r)}d.duration+=g}if(!Object.keys(i).some(e=>i[e].duration)){let t=1/0,r=0;const n=Vp(e,["sidx"]);for(let e=0;e<n.length;e++){const i=Wp(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&&Gf(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=zb(g,1/0),y=zb(m,1/0),b=zb(g,0,!0),E=zb(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 L=!!f.audio,I=!!f.video;let R="";L&&(R+="audio"),I&&(R+="video");const P={data1:u,startPTS:A,startDTS:A,endPTS:k,endDTS:k,type:R,hasAudio:L,hasVideo:I,nb:1,dropped:0,encrypted:!!f.audio&&f.audio.encrypted||!!f.video&&f.video.encrypted};c.audio=L&&!I?P:void 0,c.video=I?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||(c.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 c.initSegment=h,c.id3=Bb(r,n,l,l),i.samples.length&&(c.text=Ub(i,n,l)),c}}},{demux:Eb,remux:Fb},{demux:class extends Qy{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=Cy(e,0);let i=(null==r?void 0:r.length)||0;if(lb(e,i))return!1;for(let r=e.length;i<r;i++)if(Ny(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)&&Dy(e,t)&&Oy(e,t)<=e.length-t}(e,t)}appendFrame(e,t,r){Fy(e,this.observer,t,r,e.manifestCodec);const i=By(e,t,r,this.basePTS,this.frameIndex);if(i&&0===i.missing)return i}},remux:Fb},{demux:class extends Qy{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=Cy(e,0);let r=(null==t?void 0:t.length)||0;if(t&&11===e[r]&&119===e[r+1]&&void 0!==Ky(t)&&db(e,r)<=16)return!1;for(let t=e.length;r<t;r++)if(lb(e,r))return fp.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return function(e,t){return ab(e,t)&&4<=e.length-t}(e,t)}appendFrame(e,t,r){if(null!==this.basePTS)return nb(e,t,r,this.basePTS,this.frameIndex)}},remux:Fb}];jb.splice(2,0,{demux:cb,remux:Fb});class Hb{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=_b();let s=new Uint8Array(e);const{currentTransmuxState:a,transmuxConfig:o}=this;i&&(this.currentTransmuxState=i);const{contiguous:l,discontinuity:d,trackSwitch:c,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&&rv(b.method)){const e=this.getDecrypter(),t=iv(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=_b(),Vb(r);s=new Uint8Array(i)}}const E=this.needsProbing(d,c);if(E){const e=this.configureTransmuxer(s);if(e)return this.logger.warn(`[transmuxer] ${e.message}`),this.observer.emit(Yf.ERROR,Yf.ERROR,{type:Vf.MEDIA_ERROR,details:Wf.FRAG_PARSING_ERROR,fatal:!1,error:e,reason:e.message}),n.executeEnd=_b(),Vb(r)}(d||c||f||E)&&this.resetInitSegment(y,p,m,v,t),(d||f||E)&&this.resetInitialTimestamp(g),l||this.resetContiguity();const w=this.transmux(s,b,h,u,r);this.asyncResult=Wb(w);const S=this.currentTransmuxState;return S.contiguous=!0,S.discontinuity=!1,S.trackSwitch=!1,n.executeEnd=_b(),w}flush(e){const t=e.transmuxing;t.executeStart=_b();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=_b();const r=[Vb(e)];return this.asyncResult?Promise.resolve(r):r}const d=o.flush(a);return Wb(d)?(this.asyncResult=!0,d.then(t=>(this.flushRemux(s,t,e),s))):(this.flushRemux(s,d,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===Zf?"level":"track"} ${r.level}`);const d=this.remuxer.remux(i,n,s,a,l,o,!0,this.id);e.push({remuxResult:d,chunkMeta:r}),r.transmuxing.executeEnd=_b()}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=jb.length;t<r;t++){var s;if(null!=(s=jb[t].demux)&&s.probe(e,this.logger)){n=jb[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,d=n.demux;o&&o instanceof l||(this.remuxer=new l(r,t,i,this.logger)),a&&a instanceof d||(this.demuxer=new d(r,t,i,this.logger),this.probe=d.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new Dg(this.config)),e}}const Vb=e=>({remuxResult:{},chunkMeta:e});function Wb(e){return"then"in e&&e.then instanceof Function}class Yb{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 Kb{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 qb=0;class Xb{constructor(e,t,r,i){this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=qb++,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(Yf.ERROR,{type:Vf.OTHER_ERROR,details:Wf.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===Yf.ERROR&&(t.parent=this.id,t.part=this.part,this.error=t.error),this.hls.trigger(e,t)};this.observer=new Ay,this.observer.on(Yf.FRAG_DECRYPTED,s),this.observer.on(Yf.ERROR,s);const a=Tm(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=Ly[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 Ly[e]=i,i}(n.workerPath)):(r.log(`injecting Web Worker for "${t}"`),this.workerContext=function(){const e=Ly[ky];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 Ly[ky]=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:Gm(n)})}catch(i){r.warn(`Error setting up "${t}" Web Worker, fallback to inline`,i),this.terminateWorker(),this.error=null,this.transmuxer=new Hb(this.observer,a,n,"",t,e.logger)}return}}this.transmuxer=new Hb(this.observer,a,n,"",t,e.logger)}reset(){if(this.frag=null,this.part=null,this.workerContext){const e=this.instanceNo;this.instanceNo=qb++;const t=this.hls.config,r=Tm(t.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:e,typeSupported:r,id:this.id,config:Gm(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=Ly[e||ky];if(t&&1===t.clientCount--){const{worker:r,objectURL:i}=t;delete Ly[e||ky],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,d){var c,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==(c=n.initSegment)?void 0:c.url)===(null==(u=g.initSegment)?void 0:u.url)),A=new Kb(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===Zf?"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 Yb(r,i,t,a,d);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);Wb(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);Wb(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(Yf.ERROR,{type:Vf.MEDIA_ERROR,details:Wf.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 Qb extends op{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&&Fm(r);return new $m(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){Gv(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(Yf.ERROR,{type:Vf.NETWORK_ERROR,details:Wf.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 d=this.hls.mainForwardBufferInfo,c=d?d.end-d.len:0,u=Wv(i,1e3*(i.edge-c));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,d=n===a;-1!==l?d?(f=a+1,p=e?0:l):(f=n,p=e?l+1:i.maxPartIndex):f=a+1;const c=i.age,u=c+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 ${c.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 ${c.toFixed(2)}s goal: ${m} skip sn ${e} to part ${p}`)}i.tuneInGoal=m}if(h=this.getDeliveryDirectives(i,t.deliveryDirectives,f,p),e||!d)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=Fm(e);return null!=t&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,i=t.part,n=Om),new $m(r,i,n)}checkRetry(e){const t=e.details,r=rg(e),i=e.errorAction,{action:n,retryCount:s=0,retryConfig:a}=i||{},o=!!i&&!!a&&(n===fg||!i.resolved&&n===ug);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=ag(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 Zb(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!Jb(e[r].attrs,t[r].attrs))return!1;return!0}function Jb(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 eE(e,t){return t.label.toLowerCase()===e.name.toLowerCase()&&(!t.language||t.language.toLowerCase()===(e.lang||"").toLowerCase())}class tE{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 rE=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,iE="HlsJsTrackRemovedError";class nE extends Error{constructor(e){super(e),this.name=iE}}function sE(e){const t=e.querySelectorAll("source");[].slice.call(t).forEach(t=>{e.removeChild(t)})}function aE(e){return"audio"===e?1:0}class oE{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(Yf.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(Yf.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(Yf.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Yf.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(Yf.BUFFER_CODECS,this.onBufferCodecs,this),e.on(Yf.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:e}=this;e.off(Yf.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(Yf.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(Yf.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Yf.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(Yf.BUFFER_CODECS,this.onBufferCodecs,this),e.off(Yf.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&&Gf(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,oE.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 lE={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"},dE={HLS:"h"};class cE{constructor(e,t){Array.isArray(e)&&(e=e.map(e=>e instanceof cE?e:new cE(e))),this.value=e,this.params=t}}function uE(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 hE(e,t,r){return uE("serialize",e,t,r)}class fE{constructor(e){this.description=e}}const pE="Bare Item";function mE(e){if(!1===ArrayBuffer.isView(e))throw hE(e,"Byte Sequence");return`:${t=e,btoa(String.fromCharCode(...t))}:`;var t}function gE(e){if(function(e){return e<-999999999999999||999999999999999<e}(e))throw hE(e,"Integer");return e.toString()}function vE(e,t){if(e<0)return-vE(-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 yE(e){const t=vE(e,3);if(Math.floor(Math.abs(t)).toString().length>12)throw hE(e,"Decimal");const r=t.toString();return r.includes(".")?r:`${r}.0`}const bE=/[\x00-\x1f\x7f]+/;function EE(e){const t=(r=e).description||r.toString().slice(7,-1);var r;if(!1===/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(t))throw hE(t,"Token");return t}function wE(e){switch(typeof e){case"number":if(!Gf(e))throw hE(e,pE);return Number.isInteger(e)?gE(e):yE(e);case"string":return function(e){if(bE.test(e))throw hE(e,"String");return`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}(e);case"symbol":return EE(e);case"boolean":return function(e){if("boolean"!=typeof e)throw hE(e,"Boolean");return e?"?1":"?0"}(e);case"object":if(e instanceof Date)return function(e){return`@${gE(e.getTime()/1e3)}`}(e);if(e instanceof Uint8Array)return mE(e);if(e instanceof fE)return EE(e);default:throw hE(e,pE)}}function SE(e){if(!1===/^[a-z*][a-z0-9\-_.*]*$/.test(e))throw hE(e,"Key");return e}function TE(e){return null==e?"":Object.entries(e).map(([e,t])=>!0===t?`;${SE(e)}`:`;${SE(e)}=${wE(t)}`).join("")}function xE(e){return e instanceof cE?`${wE(e.value)}${TE(e.params)}`:wE(e)}function AE(e,t={whitespace:!0}){if("object"!=typeof e||null==e)throw hE(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 cE==!1&&(t=new cE(t));let r=SE(e);var i;return!0===t.value?r+=TE(t.params):(r+="=",Array.isArray(t.value)?r+=`(${(i=t).value.map(xE).join(" ")})${TE(i.params)}`:r+=xE(t)),r}).join(`,${i}`)}function kE(e,t){return AE(e,t)}const LE="CMCD-Object",IE="CMCD-Request",RE="CMCD-Session",PE="CMCD-Status",CE={br:LE,ab:LE,d:LE,ot:LE,tb:LE,tpb:LE,lb:LE,tab:LE,lab:LE,url:LE,pb:IE,bl:IE,tbl:IE,dl:IE,ltc:IE,mtp:IE,nor:IE,nrr:IE,rc:IE,sn:IE,sta:IE,su:IE,ttfb:IE,ttfbb:IE,ttlb:IE,cmsdd:IE,cmsds:IE,smrt:IE,df:IE,cs:IE,ts:IE,cid:RE,pr:RE,sf:RE,sid:RE,st:RE,v:RE,msd:RE,bs:PE,bsd:PE,cdn:PE,rtp:PE,bg:PE,pt:PE,ec:PE,e:PE},DE=IE;function _E(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=CE[r]||n[r]||DE;return(null!==(i=t[s])&&void 0!==i?i:t[s]={})[r]=e[r],t},r)}const OE="event";const ME=e=>Math.round(e),NE=(e,t)=>Array.isArray(e)?e.map(e=>NE(e,t)):e instanceof cE&&"string"==typeof e.value?new cE(NE(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),FE=e=>100*ME(e/100),$E={br:ME,d:ME,bl:FE,dl:FE,mtp:FE,nor:(e,t)=>{let r=e;return t.version>=2&&(e instanceof cE&&"string"==typeof e.value?r=new cE([e]):"string"==typeof e&&(r=[e])),NE(r,t)},rtp:FE,tb:ME},BE="request",UE="response",zE=["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"],GE=["e"],jE=/^[a-zA-Z0-9-.]+-[a-zA-Z0-9-.]+$/;function HE(e){return jE.test(e)}const VE=["d","dl","nor","ot","rtp","su"];const WE=["cmsdd","cmsds","rc","smrt","ttfb","ttfbb","ttlb","url"];const YE=["bl","br","bs","cid","d","dl","mtp","nor","nrr","ot","pr","rtp","sf","sid","st","su","tb","v"];function KE(e){return YE.includes(e)||HE(e)}const qE={[UE]:function(e){return zE.includes(e)||VE.includes(e)||WE.includes(e)||HE(e)},[OE]:function(e){return zE.includes(e)||GE.includes(e)||HE(e)},[BE]:function(e){return zE.includes(e)||VE.includes(e)||HE(e)}};function XE(e,t={}){const r={};if(null==e||"object"!=typeof e)return r;const i=t.version||e.v||1,n=t.reportingMode||BE,s=1===i?KE:qE[n];let a=Object.keys(e).filter(s);const o=t.filter;"function"==typeof o&&(a=a.filter(o));const l=n===UE||n===OE;l&&!a.includes("ts")&&a.push("ts"),i>1&&!a.includes("v")&&a.push("v");const d=np({},$E,t.formatters),c={version:i,reportingMode:n,baseUrl:t.baseUrl};return a.sort().forEach(t=>{let n=e[t];const s=d[t];if("function"==typeof s&&(n=s(n,c)),"v"===t){if(1===i)return;n=i}"pr"==t&&1===n||(l&&"ts"===t&&!Gf(n)&&(n=Date.now()),function(e){return"number"==typeof e?Gf(e):null!=e&&""!==e&&!1!==e}(n)&&(function(e){return["ot","sf","st","e","sta"].includes(e)}(t)&&"string"==typeof n&&(n=new fE(n)),r[t]=n))}),r}function QE(e,t,r){return np(e,function(e,t={}){const r={};if(!e)return r;const i=_E(XE(e,t),null==t?void 0:t.customHeaderMap);return Object.entries(i).reduce((e,[t,r])=>{const i=kE(r,{whitespace:!1});return i&&(e[t]=i),e},r)}(t,r))}function ZE(e,t={}){if(!e)return"";const r=function(e,t={}){return e?kE(XE(e,t),{whitespace:!1}):""}(e,t);return encodeURIComponent(r)}const JE=/CMCD=[^&#]+/;function ew(e,t,r){const i=function(e,t={}){return e?`CMCD=${ZE(e,t)}`:""}(t,r);if(!i)return e;if(JE.test(e))return e.replace(JE,i);const n=e.includes("?")?"&":"?";return`${e}${n}${i}`}function tw(e,t,r,i){e&&Object.keys(t).forEach(n=>{const s=e.filter(e=>e.groupId===n).map(e=>{const s=np({},e);return s.details=void 0,s.attrs=new qg(s.attrs),s.url=s.attrs.URI=rw(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 rw(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 iw extends op{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=iw.CDMCleanupPromise?[iw.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=gv(this.config));const t=e.map(mv).filter(e=>!!e);this.keyFormatPromise=this.getKeyFormatPromise(t)}this.keyFormatPromise.then(n=>{const s=pv(n);if("sinf"!==t||s!==dv.FAIRPLAY)return void this.log(`Ignoring "${e.type}" event with init data type: "${t}" for selected key-system ${s}`);let a;try{const e=Up(new Uint8Array(r)),t=em(nv(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=vp(a),{keyIdToKeySessionPromise:l,mediaKeySessions:d}=this;let c=l[o];for(let e=0;e<d.length;e++){const i=d[e],n=i.decryptdata;if(!n.keyId)continue;const s=vp(n.keyId);if(ev(a,n.keyId)||-1!==n.uri.replace(/-/g,"").indexOf(o)){if(c=l[s],!c)continue;if(n.pssh)break;delete l[s],n.pssh=new Uint8Array(r),n.keyId=a,c=l[o]=c.then(()=>this.generateRequestWithPreferredKeySession(i,t,r,"encrypted-event-key-match")),c.catch(e=>this.handleError(e));break}}c||this.handleError(new Error(`Key ID ${o} not encountered in playlist. Key-system sessions ${d.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(Yf.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(Yf.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(Yf.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(Yf.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.on(Yf.DESTROYING,this.onDestroying,this)}unregisterListeners(){this.hls.off(Yf.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(Yf.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(Yf.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(Yf.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.off(Yf.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===dv.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 aw?t:new aw({type:Vf.KEY_SYSTEM_ERROR,details:Wf.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===vv&&"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 dv.FAIRPLAY:n=["cenc","sinf"];break;case dv.WIDEVINE:case dv.PLAYREADY:n=["cenc"];break;case dv.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: ${Gm(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: ${vp(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=nw(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 ${vp(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})=>mv(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=mv(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=gv(this.config),r=e.map(pv).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=sw(e,t[r]);if(i)return i}}loadKey(e){const t=e.keyInfo.decryptdata,r=nw(t),i=this.bannedKeyIds[r];if(i||"internal-error"===this.getKeyStatus(t)){const r=ow(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 aw){const i=ap({},r.data);"internal-error"===this.getKeyStatus(t)&&(i.decryptdata=t);const n=new aw(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 aw){t&&(e.data.frag=t);const r=e.data.decryptdata;this.error(`${e.message}${r?` (${vp(r.keyId||[])})`:""}`),this.hls.trigger(Yf.ERROR,e.data)}else this.error(e.message),this.hls.trigger(Yf.ERROR,{type:Vf.KEY_SYSTEM_ERROR,details:Wf.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0})}getKeySystemForKeyPromise(e){const t=nw(e),r=this.keyIdToKeySessionPromise[t];if(!r){const t=pv(e.keyFormat),r=t?[t]:gv(this.config);return this.attemptKeySystemAccess(r)}return r}getKeySystemSelectionPromise(e){if(e.length||(e=gv(this.config)),0===e.length)throw new aw({type:Vf.KEY_SYSTEM_ERROR,details:Wf.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${Gm({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=nw(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 Ay,d=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===dv.FAIRPLAY&&this.updateKeySession(e,sv("acknowledged")).then(()=>this.removeSession(e)).catch(e=>this.handleError(e)):this.warn(`unhandled media key message type "${i}"`)},c=(e,t)=>{let r;t.keyStatus=e,e.startsWith("usable")?l.emit("resolved"):"internal-error"===e||"output-restricted"===e||"output-downscaled"===e?r=ow(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 ${Gm(r)} in key-session "${e.mediaKeysSession.sessionId}"`),void this.renewKeySession(e);let i=r[a];if(i)c(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.`),c(r,e);this.log(`key status for ${a} in key-session "${e.mediaKeysSession.sessionId}" timed out after ${t}ms`),i="internal-error",c(i,e)},t)),this.log(`No status for keyId ${a} (${Gm(r)}).`)}};ny(e.mediaKeysSession,"message",d),ny(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 aw({type:Vf.KEY_SYSTEM_ERROR,details:Wf.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===dv.PLAYREADY&&16===n.length){const e=vp(n);t[e]=r,av(n)}const s=vp(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},d={onSuccess:(e,t,r,i)=>{n(e.data)},onError:(t,r,n,o)=>{s(new aw({type:Vf.KEY_SYSTEM_ERROR,details:Wf.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:n,response:ap({url:a.url,data:void 0},t)},`"${e}" certificate request failed (${i}). Status: ${t.code} (${t.text})`))},onTimeout:(t,r,n)=>{s(new aw({type:Vf.KEY_SYSTEM_ERROR,details:Wf.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,d)})):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 aw({type:Vf.KEY_SYSTEM_ERROR,details:Wf.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 aw({type:Vf.KEY_SYSTEM_ERROR,details:Wf.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 sv(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 aw({type:Vf.KEY_SYSTEM_ERROR,details:Wf.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==dv.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,ny(r,"encrypted",this.onMediaEncrypted),ny(r,"waitingforkey",this.onWaitingForKey);const i=this.mediaResolved;i?i():this.mediaKeys=r.mediaKeys}onMediaDetached(){const e=this.media;e&&(sy(e,"encrypted",this.onMediaEncrypted),sy(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,wv.clearKeyUriToKeyIdMap();const n=i.length;iw.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(Yf.ERROR,{type:Vf.OTHER_ERROR,details:Wf.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(Yf.ERROR,{type:Vf.OTHER_ERROR,details:Wf.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: ${vp((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(Yf.ERROR,{type:Vf.OTHER_ERROR,details:Wf.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(Yf.ERROR,{type:Vf.OTHER_ERROR,details:Wf.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close session: ${e}`)})})}return Promise.resolve()}}function nw(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(null===e.keyId)throw new Error("keyId is null");return vp(e.keyId)}function sw(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}iw.CDMCleanupPromise=void 0;class aw 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 ow(e,t){const r="output-restricted"===e,i=r?Wf.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:Wf.KEY_SYSTEM_STATUS_INTERNAL_ERROR;return new aw({type:Vf.KEY_SYSTEM_ERROR,details:i,fatal:!1,decryptdata:t},r?"HDCP level output restricted":`key status changed to "${e}"`)}function lw(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 dw(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){fp.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){fp.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${e}`)}}"disabled"===r&&(e.mode=r)}function cw(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 uw(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 hw(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 fw(e){let t=5381,r=e.length;for(;r;)t=33*t^e.charCodeAt(--r);return(t>>>0).toString()}const pw=.025;let mw=function(e){return e[e.Point=0]="Point",e[e.Range=1]="Range",e}({});function gw(e,t,r){return`${e.identifier}-${r+1}-${fw(t)}`}class vw{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 yw(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-yw(t,e)<.1}return!1}get resumptionOffset(){const e=this.resumeOffset,t=Gf(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 yw(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)<pw))}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"]?mw.Range:mw.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 yw(e,t){return e-t.start<t.duration/2&&!(Math.abs(e-(t.start+t.duration))<pw)?t.start:t.start+t.duration}function bw(e,t,r){const i=new self.URL(e,r);return"data:"!==i.protocol&&i.searchParams.set("_HLS_primary_id",t),i}function Ew(e,t){for(;null!=(r=e.assetList[++t])&&r.error;)var r;return t}function ww(e){const t=e.timelineStart,r=e.duration||0;return`["${e.identifier}" ${t.toFixed(2)}-${(t+r).toFixed(2)}]`}class Sw{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(Yf.PLAYOUT_LIMIT_REACHED,{})};const n=this.hls=new e(t);this.interstitial=r,this.assetItem=i;const s=()=>{this.hasDetails=!0};n.once(Yf.LEVEL_LOADED,s),n.once(Yf.AUDIO_TRACK_LOADED,s),n.once(Yf.SUBTITLE_TRACK_LOADED,s),n.on(Yf.MEDIA_ATTACHING,(e,{media:t})=>{this.removeMediaListeners(),this.mediaAttached=t;this.interstitial.playoutLimit&&(t.addEventListener("timeupdate",this.checkPlayout),this.appendInPlace&&n.on(Yf.BUFFER_APPENDED,()=>{const e=this.bufferedEnd;this.reachedPlayout(e)&&(this._bufferedEosTime=e,n.trigger(Yf.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=bw(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=zg.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=zg.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: ${ww(this.assetItem)} ${null==(e=this.hls)?void 0:e.sessionId} ${this.appendInPlace?"append-in-place":""}`}}class Tw extends op{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 vw(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,d=t.cue.post,c=e[a-1]||null,u=t.appendInPlace,h=d?n:t.startOffset,f=t.duration,p=t.timelineOccupancy===mw.Range?f:0,m=t.resumptionOffset,g=(null==c?void 0:c.startTime)===h,v=h+t.cumulativeDuration;let y=u?v+f:h+m;if(l||!d&&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,d=o;o+=n;const c=s;s+=n;const u={previousEvent:e[a-1]||null,nextEvent:t,start:l,end:l+n,playout:{start:c,end:s},integrated:{start:d,end:o}};r.push(u)}else n>0&&c&&(c.cumulativeDuration+=n,r[r.length-1].end=h)}d&&(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=d||b>n?n:b}),i<n){var a;const e=i,t=o,l=n-i;o+=l;const d=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:d,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,d=a.cue.post,c=l?0:d?i:a.startTime;this.updateAssetDurations(a);if(s===c?a.cumulativeDuration=n:(n=0,s=c),!d&&a.snapOptions.in&&(a.resumeAnchor=Zm(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=Gf(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)>pw)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=Zm(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)<pw+o||Math.abs(a.end-r)<pw+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 xw(e){return`[${e.event?'"'+e.event.identifier+'"':"primary"}: ${e.start.toFixed(2)}-${e.end.toFixed(2)}]`}class Aw{constructor(e){this.hls=void 0,this.hls=e}destroy(){this.hls=null}loadAssetList(e,t){const r=e.assetListUrl;let i;try{i=bw(r,this.hls.sessionId,e.baseUrl)}catch(t){const i=this.assignAssetListError(e,Wf.ASSET_LIST_LOAD_ERROR,t,r);return void this.hls.trigger(Yf.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},d={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,Wf.ASSET_LIST_PARSING_ERROR,new Error("Invalid interstitial asset list"),i.url,r,n);return void this.hls.trigger(Yf.ERROR,t)}e.assetListResponse=s,this.hls.trigger(Yf.ASSET_LIST_LOADED,{event:e,assetListResponse:s,networkDetails:n})},onError:(t,r,i,n)=>{const s=this.assignAssetListError(e,Wf.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(Yf.ERROR,s)},onTimeout:(t,r,i)=>{const n=this.assignAssetListError(e,Wf.ASSET_LIST_LOAD_TIMEOUT,new Error(`Timeout loading X-ASSET-LIST (${r.url})`),r.url,t,i);this.hls.trigger(Yf.ERROR,n)}};return s.load(a,l,d),this.hls.trigger(Yf.ASSET_LIST_LOADING,{event:e}),s}assignAssetListError(e,t,r,i,n,s){return e.error=r,{type:Vf.NETWORK_ERROR,details:t,fatal:!1,interstitial:e,url:i,error:r,networkDetails:s,stats:n}}}function kw(e){var t;null==e||null==(t=e.play())||t.catch(()=>{})}function Lw(e,t){return`[${e}] Advancing timeline position to ${t}`}class Iw{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 Rw={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},Pw=e=>String.fromCharCode(Rw[e]||e),Cw=15,Dw=100,_w={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},Ow={17:2,18:4,21:6,22:8,23:10,19:13,20:15},Mw={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},Nw={25:2,26:4,29:6,30:8,31:10,27:13,28:15},Fw=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class $w{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){const r="function"==typeof t?t():t;fp.log(`${this.time} [${e}] ${r}`)}}}const Bw=function(e){const t=[];for(let r=0;r<e.length;r++)t.push(e[r].toString(16));return t};class Uw{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 zw{constructor(){this.uchar=" ",this.penState=new Uw}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 Gw{constructor(e){this.chars=[],this.pos=0,this.currPenState=new Uw,this.cueStartTime=null,this.logger=void 0;for(let e=0;e<Dw;e++)this.chars.push(new zw);this.logger=e}equals(e){for(let t=0;t<Dw;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}copy(e){for(let t=0;t<Dw;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<Dw;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>Dw&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=Dw)}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=Pw(e);this.pos>=Dw?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<Dw;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<Dw;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 jw{constructor(e){this.rows=[],this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let t=0;t<Cw;t++)this.rows.push(new Gw(e));this.logger=e}reset(){for(let e=0;e<Cw;e++)this.rows[e].clear();this.currRow=14}equals(e){let t=!0;for(let r=0;r<Cw;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t}copy(e){for(let t=0;t<Cw;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<Cw;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 = "+Gm(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<Cw;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 = "+Gm(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<Cw;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 Hw{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 jw(r),this.nonDisplayedMemory=new jw(r),this.lastOutputScreen=new jw(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: "+Gm(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 Vw{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 $w;this.channels=[null,new Hw(e,t,i),new Hw(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,()=>"["+Bw([t[e],t[e+1]])+"] -> ("+Bw([r,i])+")");const a=this.cmdHistory;if(r>=16&&r<=31){if(Yw(r,i,a)){Ww(null,null,a),this.logger.log(3,()=>"Repeated command ("+Bw([r,i])+") is dropped");continue}Ww(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 Ww(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 "+Bw([r,i])+" orig: "+Bw([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 ("+Bw([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?_w[e]:Mw[e]:1===i?Ow[e]:Nw[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 '"+Pw(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 = "+Bw(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=Fw[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()}Ww(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 Ww(e,t,r){r.a=e,r.b=t}function Yw(e,t,r){return r.a===e&&r.b===t}var Kw=function(){if(null!=lv&&lv.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 d="",c=!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 d},set:function(e){d=""+e}})),Object.defineProperty(o,"pauseOnExit",n({},l,{get:function(){return c},set:function(e){c=!!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 qw{decode(e,t){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}function Xw(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 Qw{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 Zw(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 Jw=new Kw(0,0,""),eS="middle"===Jw.align?"middle":"center";function tS(e,t,r){const i=e;function n(){const t=Xw(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 Qw;Zw(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",eS,"end"]);break;case"position":n=t.split(","),i.percent(e,n[0]),2===n.length&&i.alt("positionAlign",n[1],["start",eS,"end","line-left","line-right","auto"]);break;case"size":i.percent(e,t);break;case"align":i.alt(e,t,["start",eS,"end","left","right"])}},/:/,/\s/),t.region=i.get("region",null),t.vertical=i.get("vertical","");let n=i.get("line","auto");"auto"===n&&-1===Jw.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",eS);let s=i.get("position","auto");"auto"===s&&50===Jw.position&&(s="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=s}(e,t)}function rS(e){return e.replace(/<br(?: \/)?>/gi,"\n")}class iS{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new qw,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=rS(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){Zw(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 Kw(0,0,""),t.state="CUE",-1===e.indexOf("--\x3e")){t.cue.id=e;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{tS(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 nS=/\r\n|\n\r|\n|\r/g,sS=function(e,t,r=0){return e.slice(r,r+t.length)===t};function aS(e,t,r){return fw(e.toString())+fw(t.toString())+fw(r)}function oS(e,t,r,i,n,s,a){const o=new iS,l=gp(new Uint8Array(e)).trim().replace(nS,"\n").split("\n"),d=[],c=t?function(e,t=1){return Pb(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-c)/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=$b(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=aS(e.startTime,e.endTime,m)),e.endTime>0&&d.push(e)},o.onparsingerror=function(e){u=e},o.onflush=function(){u?a(u):s(d)},l.forEach(e=>{if(m){if(sS(e,"X-TIMESTAMP-MAP=")){m=!1,e.slice(16).split(",").forEach(e=>{sS(e,"LOCAL:")?h=e.slice(6):sS(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(!(Gf(t)&&Gf(r)&&Gf(i)&&Gf(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 lS="stpp.ttml.im1t",dS=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,cS=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,uS={left:"start",center:"center",right:"end",start:"start",end:"end"};function hS(e,t,r,i){const n=Vp(new Uint8Array(e),["mdat"]);if(0===n.length)return void i(new Error("Could not parse IMSC1 mdat"));const s=n.map(e=>gp(e)),a=function(e,t,r=1,i=!1){return Pb(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=pS(fS(i,"styling","style")),l=pS(fS(i,"layout","region")),d=fS(i,"body","[begin]");return[].map.call(d,e=>{const r=mS(e,a);if(!r||!e.hasAttribute("begin"))return null;const i=yS(e.getAttribute("begin"),s),n=yS(e.getAttribute("dur"),s);let d=yS(e.getAttribute("end"),s);if(null===i)throw vS(e);if(null===d){if(null===n)throw vS(e);d=i+n}const c=new Kw(i-t,d-t,r);c.id=aS(c.startTime,c.endTime,c.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=gS(t,i,s)||gS(e,i,s)||gS(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=uS[h];e&&(c.lineAlign=e),c.align=h}return np(c,u),c}).filter(e=>null!==e)}(e,a)))}catch(e){i(e)}}function fS(e,t,r){const i=e.getElementsByTagName(t)[0];return i?[].slice.call(i.querySelectorAll(r)):[]}function pS(e){return e.reduce((e,t)=>{const r=t.getAttribute("xml:id");return r&&(e[r]=t),e},{})}function mS(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?mS(r,t):t?e+r.textContent.trim().replace(/\s+/g," "):e+r.textContent},"")}function gS(e,t,r){return e&&e.hasAttributeNS(t,r)?e.getAttributeNS(t,r):null}function vS(e){return new Error(`Could not parse ttml timestamp ${e}`)}function yS(e,t){if(!e)return null;let r=Xw(e);return null===r&&(dS.test(e)?r=function(e,t){const r=dS.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):cS.test(e)&&(r=function(e,t){const r=cS.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 bS{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 ES(e){return e.characteristics&&/transcribes-spoken-dialog/gi.test(e.characteristics)&&/describes-music-and-sound/gi.test(e.characteristics)?"captions":"subtitles"}function wS(e,t){return!!e&&e.kind===ES(t)&&eE(t,e)}function SS(e,t,r,i){return Math.min(t,i)-Math.max(e,r)}const TS=/\s/,xS={newCue(e,t,r,i){const n=[];let s,a,o,l,d;const c=self.VTTCue||self.TextTrackCue;for(let h=0;h<i.rows.length;h++)if(s=i.rows[h],o=!0,l=0,d="",!s.isEmpty()){var u;for(let e=0;e<s.chars.length;e++)TS.test(s.chars[e].uchar)&&o?l++:(d+=s.chars[e].uchar,o=!1);s.cueStartTime=t,t===r&&(r+=1e-4),l>=16?l--:l++;const i=rS(d.trim()),f=aS(t,r,i);null!=e&&null!=(u=e.cues)&&u.getCueById(f)||(a=new c(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=>dw(e,t))),n}};const AS=/(\d+)-(\d+)\/(\d+)/;class kS{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||LS,this.controller=new self.AbortController,this.stats=new Ip}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(np({},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&&Gf(o)?o:l,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(i,e,this.response))},t.timeout);(Wb(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 IS(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=AS.exec(e);if(t)return parseInt(t[2])-parseInt(t[1])+1}(t);if(Gf(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&&Gf(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 d={url:o.url,data:r,code:o.status},c=null==(n=this.callbacks)?void 0:n.onProgress;c&&!Gf(t.highWaterMark)&&c(i,e,r,o),null==(s=this.callbacks)||s.onSuccess(d,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 wy,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,d=l.length;return t.loaded+=d,d<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 LS(e,t){return new self.Request(e.url,t)}class IS extends Error{constructor(e,t,r){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=r}}const RS=/^age:\s*[\d.]+\s*$/im;class PS{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 Ip,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&&Gf(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 d={url:t.responseURL,data:n,code:i};return void(null==(a=this.callbacks)||a.onSuccess(d,r,e,t))}}const d=n.loadPolicy.errorRetry;var o;if(lg(d,r.retry,!1,{url:e.url,data:void 0,code:i}))this.retry(d);else fp.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(lg(e,this.stats.retry,!0))this.retry(e);else{var t;fp.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=ag(e,r.retry),r.retry++,fp.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&&RS.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 CS=ap(ap({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:PS,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:class extends op{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,d=i?i.duration:r.duration,c=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(c<=Math.max(v,d/(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(d*(r.bitrate||x.averageBitrate)/8));let k=w?c-E:c;k<1&&w&&(k=Math.min(c,8*l.loaded/S));const L=w?1e3*l.loaded/k:0,I=v/1e3,R=L?(A-l.loaded)/L:8*A/S+I;if(R<=b)return;const P=L?8*L: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(I,P,d*e,t),O<Math.min(b,d+I))break}if(O>=R)return;if(O>10*d)return;w?this.bwEstimator.sample(c-Math.min(v,E),l.loaded):this.bwEstimator.sampleTTFB(c);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: ${Gf(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(Yf.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 rp(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){const{hls:e}=this;e.on(Yf.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Yf.FRAG_LOADING,this.onFragLoading,this),e.on(Yf.FRAG_LOADED,this.onFragLoaded,this),e.on(Yf.FRAG_BUFFERED,this.onFragBuffered,this),e.on(Yf.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(Yf.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Yf.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(Yf.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(Yf.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e&&(e.off(Yf.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Yf.FRAG_LOADING,this.onFragLoading,this),e.off(Yf.FRAG_LOADED,this.onFragLoaded,this),e.off(Yf.FRAG_BUFFERED,this.onFragBuffered,this),e.off(Yf.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(Yf.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Yf.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(Yf.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(Yf.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 Wf.BUFFER_ADD_CODEC_ERROR:case Wf.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case Wf.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;Gf(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===Zf&&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(Yf.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!==Zf||"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 d=n.abrBandWidthFactor,c=n.abrBandWidthUpFactor;if(l){const e=this.findBestLevel(o,s,i,l,0,d,c);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`),d=c=1}}const h=this.findBestLevel(o,s,i,l,u,d,c);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,d=this.lastLoadedFragLevel,c=-1===d?this.hls.firstLevel:d,{fragCurrent:u,partCurrent:h}=this,{levels:f,allAudioTracks:p,loadLevel:m,config:g}=this.hls;if(1===f.length)return 0;const v=f[c],y=!(null==(o=this.hls.latestLevelDetails)||!o.live),b=-1===m||-1===d;let E,w="SDR",S=(null==v?void 0:v.frameRate)||0;const{audioPreference:T,videoPreference:x}=g,A=this.audioTracksByGroup||(this.audioTracksByGroup=Hm(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,d=a&&2===parseInt(a);let c=!1,u=!1,h=1/0,f=1/0,p=1/0,m=1/0,g=0,v=[];const{preferHDR:y,allowedVideoRanges:b}=zm(t,n);for(let t=s.length;t--;){const r=e[s[t]];c||(c=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=Gf(h)?h:0,f=Gf(f)?f:0;const E=Math.max(1080,h),w=Math.max(30,f);p=Gf(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 jm(i,`min bitrate of ${n.minBitrate} > current estimate of ${r}`),t;if(!n.hasDefaultAudio)return jm(i,"no renditions with default or auto-select sound found"),t;if(o&&i.indexOf(o.substring(0,4))%5!=0)return jm(i,`audio codec preference "${o}" not found`),t;if(a&&!d){if(!n.channels[a])return jm(i,`no renditions with ${a} channel sound found (channels options: ${Object.keys(n.channels)})`),t}else if((!o||d)&&c&&0===n.channels[2])return jm(i,"no renditions with stereo sound found"),t;if(n.minHeight>E)return jm(i,`min resolution of ${n.minHeight} > maximum of ${E}`),t;if(n.minFramerate>w)return jm(i,`min framerate of ${n.minFramerate} > maximum of ${w}`),t;if(!v.some(e=>n.videoRanges[e]>0))return jm(i,`no variants with VIDEO-RANGE of ${Gm(v)} found`),t;if(l&&i.indexOf(l.substring(0,4))%5!=0)return jm(i,`video codec preference "${l}" not found`),t;if(n.maxScore<g)return jm(i,`max score of ${n.maxScore} < selected max of ${g}`),t}return t&&(gm(i)>=gm(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:d,preferHDR:c}=n;k=d,E=s,w=c?a[a.length-1]:a[0],S=o,e=Math.max(e,l),this.log(`picked start tier ${Gm(n)}`)}else E=null==v?void 0:v.codecSet,w=null==v?void 0:v.videoRange;const L=h?h.duration:u?u.duration:0,I=this.bwEstimator.getEstimateTTFB()/1e3,R=[];for(let o=r;o>=t;o--){var P;const t=f[o],u=o>c;if(!t)continue;if(g.useMediaCapabilities&&!t.supportedResult&&!t.supportedPromise){const r=navigator.mediaCapabilities;"function"==typeof(null==r?void 0:r.decodingInfo)&&Im(t,A,w,S,e,T)?(t.supportedPromise=Rm(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} ${Gm(e)}`):e.supported?e.decodingInfoResults.some(e=>!1===e.smooth||!1===e.powerEfficient)&&this.log(`MediaCapabilities decodingInfo for level ${i} not smooth or powerEfficient: ${Gm(e)}`):(this.warn(`Unsupported MediaCapabilities decodingInfo result for level ${i} ${Gm(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=km}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)||L;let x;x=u?a*e:s*e;const C=L&&i>=2*L&&0===n?t.averageBitrate:t.maxBitrate,D=this.getTimeToLoadFrag(I,x,C*v,void 0===p);if(x>=C&&(o===d||0===t.loadError&&0===t.fragmentError)&&(D<=I||!Gf(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:${c}->${o} adjustedbw(${Math.round(x)})-bitrate=${Math.round(x-C)} ttfb:${I.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 op{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(Yf.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=pp(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(Yf.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(Yf.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Yf.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Yf.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Yf.BUFFER_RESET,this.onBufferReset,this),e.on(Yf.BUFFER_APPENDING,this.onBufferAppending,this),e.on(Yf.BUFFER_CODECS,this.onBufferCodecs,this),e.on(Yf.BUFFER_EOS,this.onBufferEos,this),e.on(Yf.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(Yf.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(Yf.FRAG_PARSED,this.onFragParsed,this),e.on(Yf.FRAG_CHANGED,this.onFragChanged,this),e.on(Yf.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(Yf.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(Yf.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Yf.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Yf.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Yf.BUFFER_RESET,this.onBufferReset,this),e.off(Yf.BUFFER_APPENDING,this.onBufferAppending,this),e.off(Yf.BUFFER_CODECS,this.onBufferCodecs,this),e.off(Yf.BUFFER_EOS,this.onBufferEos,this),e.off(Yf.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(Yf.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(Yf.FRAG_PARSED,this.onFragParsed,this),e.off(Yf.FRAG_CHANGED,this.onFragChanged,this),e.off(Yf.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?np(r,i.tracks):this.sourceBuffers.forEach(e=>{const[t]=e;t&&(r[t]=np({},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=pp(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,sE(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: ${Gm(r,(e,t)=>"initSegment"===e?void 0:t)};\ntransfer tracks: ${Gm(i,(e,t)=>"initSegment"===e?void 0:t)}}`),!mp(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(Yf.MEDIA_DETACHING,{}),this.onMediaAttaching(Yf.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=zg.getBuffered(e);i.detectEvictedFragments(t,r,n,null,!0)}const s=aE(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&&sE(i),i.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null),this.hls.trigger(Yf.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[aE(e)]=[null,null];const t=this.tracks[e];t&&(t.buffer=void 0)}resetQueue(){this.operationQueue&&this.operationQueue.destroy(),this.operationQueue=new tE(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:d,metadata:c,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:d,levelCodec:l,metadata:c,id:a});const v=Em(m,g),y=null==v?void 0:v.replace(rE,"$1");let b=Em(o,l);const E=null==(n=b)?void 0:n.replace(rE,"$1");b&&v&&y!==E&&("audio"===e.slice(0,5)&&(b=bm(b,this.appendSource)),this.log(`switching codec ${m} to ${b}`),b!==(h.pendingCodec||h.codec)&&(h.pendingCodec=b),h.container=d,this.appendChangeType(e,d,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,Zf))?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&&zg.isBuffered(t.buffer,i)||!0===(null==(e=this.fragmentTracker.getAppendedFrag(i,Zf))?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:d}=t,c=l.buffering[n],{sn:u,cc:h}=a,f=self.performance.now();c.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||zg.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&&!zg.isBuffered(b,t)&&this.lastVideoAppendEnd<t&&this.blockAudio(e):this.blockAudio(e)}}const E=(o||a).start,w={label:`append-${n}`,execute:()=>{var e;c.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!==d&&Gf(d)&&this.updateTimestampOffset(t,d,1e-6,n,u,h)),this.appendExecutor(i,n)},onStart:()=>{},onComplete:()=>{const e=self.performance.now();c.executeEnd=c.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]=zg.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(Yf.BUFFER_APPENDED,{type:n,frag:a,part:o,chunkMeta:l,parent:a.type,timeRanges:t})},onError:e=>{var t;const r={type:Vf.MEDIA_ERROR,parent:a.type,details:Wf.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=Wf.BUFFER_FULL_ERROR;else if(e.code===DOMException.INVALID_STATE_ERR&&this.mediaSourceOpenOrEnded&&!i)r.errorAction=yg(!0);else if(e.name===iE&&0===this.sourceBufferCount)r.errorAction=yg(!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(Yf.ERROR,r)}};this.log(`queuing "${n}" append sn: ${u}${o?" p: "+o.index:""} of ${a.type===Zf?"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(Yf.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[Cp]?n.push("audiovideo"):(s[Rp]&&n.push("audio"),s[Pp]&&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(Yf.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(Yf.BUFFERED_TO_END,void 0)):e&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${e.readyState}`)})):(this.tracksEnded(),this.hls.trigger(Yf.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===Wf.BUFFER_APPEND_ERROR&&t.frag){var r;const e=null==(r=t.errorAction)?void 0:r.nextAutoLevel;Gf(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(Gf(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(Gf(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=zg.getBuffered(t);if(n.length>0&&r>n.start(0)){var i;this.hls.trigger(Yf.BACK_BUFFER_REACHED,{bufferEnd:r});const t=this.tracks[e];if(null!=(i=this.details)&&i.live)this.hls.trigger(Yf.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(Yf.BUFFER_FLUSHING,{startOffset:0,endOffset:r,type:e})}}})}flushFrontBuffer(e,t,r){this.sourceBuffers.forEach(([t,i])=>{if(i){const n=zg.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(Yf.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 Gf(n)?{duration:n}:null;const s=this.media.duration;return i>(Gf(r.duration)?r.duration:0)&&i>s||!Gf(s)?{duration:i}:null}updateMediaSource({duration:e,start:t,end:r}){const i=this.mediaSource;this.media&&i&&"open"===i.readyState&&(i.duration!==e&&(Gf(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}) ${Gm(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(Yf.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(Yf.ERROR,{type:Vf.MEDIA_ERROR,details:Wf.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":""} ${Gm(a)}`);try{const e=r.addSourceBuffer(n),i=aE(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(Yf.ERROR,{type:Vf.MEDIA_ERROR,details:Wf.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)&&hm(r,"video")&&(i=function(e,t){const r=[];if(e){const t=e.split(",");for(let e=0;e<t.length;e++)um(t[e],"video")||r.push(t[e])}return t&&r.push(t),r.join(",")}(i,r));const n=Em(i,e.levelCodec);return n?"audio"===t.slice(0,5)?bm(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(Yf.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(Yf.ERROR,{type:Vf.MEDIA_ERROR,details:Wf.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=Gf(i.duration)?i.duration:1/0,l=Gf(n.duration)?n.duration:1/0,d=Math.max(0,t),c=Math.min(r,o,l);c>d&&(!s.ending||s.ended)?(s.ended=!1,this.log(`Removing [${d},${c}] from the ${e} SourceBuffer`),a.remove(d,c)):this.shiftAndExecuteNext(e)}appendExecutor(e,t){const r=this.tracks[t],i=null==r?void 0:r.buffer;if(!i)throw new nE(`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:oE,errorController:class extends op{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(Yf.ERROR,this.onError,this),e.on(Yf.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Yf.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const e=this.hls;e&&(e.off(Yf.ERROR,this.onError,this),e.off(Yf.ERROR,this.onErrorOut,this),e.off(Yf.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Yf.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)===Zf?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 Wf.FRAG_LOAD_ERROR:case Wf.FRAG_LOAD_TIMEOUT:case Wf.KEY_LOAD_ERROR:case Wf.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case Wf.FRAG_PARSING_ERROR:if(null!=(r=t.frag)&&r.gap)return void(t.errorAction=yg());case Wf.FRAG_GAP:case Wf.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=ug);case Wf.LEVEL_EMPTY_ERROR:case Wf.LEVEL_PARSING_ERROR:{var s;const e=t.parent===Zf?t.level:i.loadLevel;t.details===Wf.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 Wf.LEVEL_LOAD_ERROR:case Wf.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==n?void 0:n.level)&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.level)));case Wf.AUDIO_TRACK_LOAD_ERROR:case Wf.AUDIO_TRACK_LOAD_TIMEOUT:case Wf.SUBTITLE_LOAD_ERROR:case Wf.SUBTITLE_TRACK_LOAD_TIMEOUT:if(n){const e=i.loadLevelObj;if(e&&(n.type===Xf&&e.hasAudioGroup(n.groupId)||n.type===Qf&&e.hasSubtitleGroup(n.groupId)))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,i.loadLevel),t.errorAction.action=ug,void(t.errorAction.flags=mg)}return;case Wf.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:return void(t.errorAction={action:ug,flags:gg});case Wf.KEY_SYSTEM_SESSION_UPDATE_FAILED:case Wf.KEY_SYSTEM_STATUS_INTERNAL_ERROR:case Wf.KEY_SYSTEM_NO_SESSION:return void(t.errorAction={action:ug,flags:vg});case Wf.BUFFER_ADD_CODEC_ERROR:case Wf.REMUX_ALLOC_ERROR:case Wf.BUFFER_APPEND_ERROR:var a;if(!t.errorAction)t.errorAction=this.getLevelSwitchAction(t,null!=(a=t.level)?a:i.loadLevel);return;case Wf.INTERNAL_EXCEPTION:case Wf.BUFFER_APPENDING_ERROR:case Wf.BUFFER_FULL_ERROR:case Wf.LEVEL_SWITCH_ERROR:case Wf.BUFFER_STALLED_ERROR:case Wf.BUFFER_SEEK_OVER_HOLE:case Wf.BUFFER_NUDGE_ON_STALL:return void(t.errorAction=yg())}t.type===Vf.KEY_SYSTEM_ERROR&&(t.levelRetry=!1,t.errorAction=yg())}getPlaylistRetryOrSwitchAction(e,t){const r=sg(this.hls.config.playlistLoadPolicy,e),i=this.playlistError++;if(lg(r,i,rg(e),e.response))return{action:fg,flags:pg,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=sg(ig(e)?s:n,e),o=t.levels.reduce((e,t)=>e+t.fragmentError,0);if(i&&(e.details!==Wf.FRAG_GAP&&i.fragmentError++,!ng(e))){if(lg(a,o,rg(e),e.response))return{action:fg,flags:pg,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===Wf.BUFFER_APPEND_ERROR&&i.fragmentError++;let l=-1;const{levels:d,loadLevel:c,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===Jf&&t===Wf.FRAG_PARSING_ERROR||"audio"===e.sourceBufferName&&(t===Wf.BUFFER_ADD_CODEC_ERROR||t===Wf.BUFFER_APPEND_ERROR))&&d.some(({audioCodec:e})=>i.audioCodec!==e),m="video"===e.sourceBufferName&&(t===Wf.BUFFER_ADD_CODEC_ERROR||t===Wf.BUFFER_APPEND_ERROR)&&d.some(({codecSet:e,audioCodec:t})=>i.codecSet!==e&&i.audioCodec===t),{type:g,groupId:v}=null!=(s=e.context)?s:{};for(let r=d.length;r--;){const n=(r+c)%d.length;if(n!==c&&n>=u&&n<=h&&0===d[n].loadError){var a,o;const r=d[n];if(t===Wf.FRAG_GAP&&f===Zf&&e.frag){const t=d[n].details;if(t){const r=Zm(e.frag,t.fragments,e.frag.start);if(null!=r&&r.gap)continue}}else{if(g===Xf&&r.hasAudioGroup(v)||g===Qf&&r.hasSubtitleGroup(v))continue;if(f===Jf&&null!=(a=i.audioGroups)&&a.some(e=>r.hasAudioGroup(e))||f===ep&&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:ug,flags:pg,nextAutoLevel:l}}return{action:ug,flags:mg}}onErrorOut(e,t){var r;switch(null==(r=t.errorAction)?void 0:r.action){case cg:break;case ug:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===Wf.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 pg:this.switchLevel(e,n);break;case gg:{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=Dm[Dm.indexOf(s)-1],r.resolved=!0,this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}}case vg:{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) ${vp(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!==Zf){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===Wf.BUFFER_ADD_CODEC_ERROR&&e.mimeType&&"audiovideo"!==e.sourceBufferName)){const t=xm(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(Yf.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(Yf.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListeners(){this.hls.off(Yf.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(Yf.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(Yf.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(Yf.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:vv,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:xS,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 by{constructor(e,t,r){super(e,t,r,"subtitle-stream-controller",ep),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(Yf.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Yf.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(Yf.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(Yf.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(Yf.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(Yf.BUFFER_FLUSHING,this.onBufferFlushing,this)}unregisterListeners(){super.unregisterListeners();const{hls:e}=this;e.off(Yf.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Yf.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(Yf.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(Yf.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(Yf.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(Yf.BUFFER_FLUSHING,this.onBufferFlushing,this)}startLoad(e,t){this.stopLoad(),this.state=ly,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)||(_p(r)&&(this.fragPrevious=r),this.state=ly),!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,ep)}}onError(e,t){const r=t.frag;(null==r?void 0:r.type)===ep&&(t.details===Wf.FRAG_GAP&&this.fragmentTracker.fragBuffered(r,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==oy&&(this.state=ly))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){this.levels&&Zb(this.levels,t)?this.levels=t.map(e=>new Bm(e)):(this.tracksBuffered=[],this.levels=t.map(e=>{const t=new Bm(e);return this.tracksBuffered[t.id]=[],t}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,ep),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!==oy&&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 d;if(o.details)l=this.alignPlaylists(s,o.details,null==(d=this.levelLastLoaded)?void 0:d.details),0===l&&t&&(l=t.start,Vv(s,l));else s.hasProgramDateTime&&e.hasProgramDateTime?(iy(s,e),l=s.fragmentStart):t&&(l=t.start,Vv(s,l));e&&!this.startFragRequested&&this.setStartPosition(e,l)}if(o.details=s,this.levelLastLoaded=o,a===i&&(this.hls.trigger(Yf.SUBTITLE_TRACK_UPDATED,{details:s,id:a,groupId:t.groupId}),this.tick(),s.live&&!this.fragCurrent&&this.media&&this.state===ly)){Zm(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&&rv(i.method)){const e=performance.now();this.decrypter.decrypt(new Uint8Array(r),i.key.buffer,i.iv.buffer,iv(i.method)).catch(e=>{throw n.trigger(Yf.ERROR,{type:Vf.MEDIA_ERROR,details:Wf.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:t}),e}).then(r=>{const i=performance.now();n.trigger(Yf.FRAG_DECRYPTED,{frag:t,payload:r,stats:{tstart:e,tdecrypt:i}})}).catch(e=>{this.warn(`${e.name}: ${e.message}`),this.state=ly})}}doTick(){if(this.media){if(this.state===ly){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=zg.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 d=l.fragments,c=d.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=Zm(f,d,Math.max(d[0].start,a),t),!h&&f&&f.start<d[0].start&&(h=d[0])}else h=d[c-1];if(h=this.filterReplacedPrimary(h,r.details),!h)return;const p=d[h.sn-l.startSN-1];if(p&&p.cc===h.cc&&this.fragmentTracker.getState(p)===bg&&(h=p),this.fragmentTracker.getState(h)===bg){const e=this.mapToInitFragWhenRequired(h);e&&this.loadFragment(e,r,a)}}}else this.state=ly}loadFragment(e,t,r){_p(e)?super.loadFragment(e,t,r):this._loadInitSegment(e,t)}get mediaBufferTimeRanges(){return new Iw(this.tracksBuffered[this.currentTrackId]||[])}},subtitleTrackController:class extends Qb{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=hw(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(Yf.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Yf.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Yf.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Yf.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Yf.LEVEL_LOADING,this.onLevelLoading,this),e.on(Yf.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(Yf.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(Yf.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(Yf.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Yf.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Yf.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Yf.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Yf.LEVEL_LOADING,this.onLevelLoading,this),e.off(Yf.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(Yf.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(Yf.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;hw(r.textTracks).forEach(e=>{cw(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=Wm(t,e);if(r>-1)n=e[r];else{const e=Wm(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(Yf.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||Ym(n,e)))return i}if(e){for(let r=0;r<t.length;r++){const i=t[r];if(Jb(e.attrs,i.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return r}for(let r=0;r<t.length;r++){const i=t[r];if(Jb(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(eE(t[r],e))return r}}return-1}onError(e,t){!t.fatal&&t.context&&(t.context.type!==Qf||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&&Ym(e,r))return r;const i=Wm(e,this.tracksInGroup);if(i>-1){const e=this.tracksInGroup[i];return this.setSubtitleTrack(i),e}if(r)return null;{const r=Wm(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(Yf.SUBTITLE_TRACK_LOADING,{url:n,id:r,groupId:i,deliveryDirectives:t||null,track:e})}toggleTrackModes(){const{media:e}=this;if(!e)return;const t=hw(e.textTracks),r=this.currentTrack;let i;if(r&&(i=t.filter(e=>eE(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||!Gf(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(Yf.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:d}=i;this.hls.trigger(Yf.SUBTITLE_TRACK_SWITCH,{id:s,groupId:a,name:o,type:l,url:d});const c=this.switchParams(i.url,null==r?void 0:r.details,i.details);this.loadPlaylist(c)}},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(Yf.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(Yf.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Yf.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Yf.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(Yf.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(Yf.FRAG_LOADING,this.onFragLoading,this),e.on(Yf.FRAG_LOADED,this.onFragLoaded,this),e.on(Yf.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(Yf.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(Yf.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(Yf.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(Yf.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:e}=this;e.off(Yf.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(Yf.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Yf.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Yf.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(Yf.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(Yf.FRAG_LOADING,this.onFragLoading,this),e.off(Yf.FRAG_LOADED,this.onFragLoaded,this),e.off(Yf.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(Yf.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(Yf.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(Yf.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(Yf.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.media=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){const e=new bS(this,"textTrack1"),t=new bS(this,"textTrack2"),r=new bS(this,"textTrack3"),i=new bS(this,"textTrack4");this.cea608Parser1=new Vw(1,e,t),this.cea608Parser2=new Vw(3,r,i)}addCues(e,t,r,i,n){let s=!1;for(let e=n.length;e--;){const i=n[e],a=SS(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(Yf.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===Zf&&(this.initPTS[t.cc]={baseTime:i,timescale:n,trackId:s}),a.length&&(this.unparsedVttFrags=[],a.forEach(e=>{this.initPTS[e.frag.cc]?this.onFragLoaded(Yf.FRAG_LOADED,e):this.hls.trigger(Yf.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(wS(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,cw(r[e]),lw(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(Yf.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=>{cw(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++)cw(t[e])}onSubtitleTracksUpdated(e,t){const r=t.subtitleTracks||[],i=r.some(e=>e.textCodec===lS);if(this.config.enableWebVTT||i&&this.config.enableIMSC1){if(Zb(this.tracks,r))return void(this.tracks=r);if(this.textTracks=[],this.tracks=r,this.config.renderTextTracksNatively){const e=this.media,t=e?hw(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]&&wS(t[i],e)){r=t[i],t[i]=null;break}r&&(i=r)}if(i)cw(i);else{const t=ES(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(Yf.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===Zf){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===ep)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===lS?this._parseIMSC1(r,i):this._parseVTTs(t)}}else this.hls.trigger(Yf.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){const r=this.hls;hS(t,this.initPTS[e.cc],t=>{this._appendCues(t,e.level),r.trigger(Yf.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},t=>{r.logger.log(`Failed to parse IMSC1: ${t}`),r.trigger(Yf.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;oS(null!=(t=r.initSegment)&&t.data?tm(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(Yf.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(Yf.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:t})})}_fallbackToIMSC1(e,t){const r=this.tracks[e.level];r.textCodec||hS(t,this.initPTS[e.cc],()=>{r.textCodec=lS,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=>dw(r,e))}else{const i=this.tracks[t];if(!i)return;const n=i.default?"default":"subtitles"+t;r.trigger(Yf.CUES_PARSED,{type:"subtitles",cues:e,track:n})}}onFragDecrypted(e,t){const{frag:r}=t;r.type===ep&&this.onFragLoaded(Yf.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!==Zf||"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=>uw(e[i],t,r))}if(this.config.renderTextTracksNatively&&0===t&&void 0!==i){const{textTracks:e}=this;Object.keys(e).forEach(r=>uw(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 by{constructor(e,t,r){super(e,t,r,"audio-stream-controller",Jf),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(Yf.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Yf.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(Yf.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(Yf.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(Yf.BUFFER_RESET,this.onBufferReset,this),e.on(Yf.BUFFER_CREATED,this.onBufferCreated,this),e.on(Yf.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(Yf.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(Yf.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(Yf.FRAG_LOADING,this.onFragLoading,this),e.on(Yf.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){const{hls:e}=this;e&&(super.unregisterListeners(),e.off(Yf.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Yf.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(Yf.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(Yf.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(Yf.BUFFER_RESET,this.onBufferReset,this),e.off(Yf.BUFFER_CREATED,this.onBufferCreated,this),e.off(Yf.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(Yf.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(Yf.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(Yf.FRAG_LOADING,this.onFragLoading,this),e.off(Yf.FRAG_BUFFERED,this.onFragBuffered,this))}onInitPtsFound(e,{frag:t,id:r,initPTS:i,timescale:n,trackId:s}){if(r===Zf){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===vy){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===ly&&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=tg(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===ly&&this.doTickIdle())}startLoad(e,t){if(!this.levels)return this.startPosition=e,void(this.state=oy);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=ly):this.state=hy,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}doTick(){switch(this.state){case ly:this.doTickIdle();break;case hy:{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=vy}break}case uy:this.checkRetryDate();break;case vy:{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=cy;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=ly}}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=hy,void(this.startFragRequested=!1);const l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,Rp,Jf));const d=this.getFwdBufferInfo(l,Jf);if(null===d)return;if(!this.switchingTrack&&this._streamEnded(d,o))return t.trigger(Yf.BUFFER_EOS,{type:"audio"}),void(this.state=my);const c=d.len,u=t.maxBufferLength,h=o.fragments,f=h[0].start,p=this.getLoadPosition(),m=this.flushing?p:d.end;if(this.switchingTrack&&i){const e=p;o.PTSKnown&&e<f&&(d.end>f||d.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),i.currentTime=f+.05)}if(c>=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,d,Zf,u)),!g)return void(this.bufferFlushed=!0);let v=(null==(e=this.mainFragLoading)?void 0:e.frag)||null;if(!this.audioOnly&&this.startFragRequested&&v&&_p(g)&&!g.endList&&(!o.live||!this.loadingParts&&m<this.hls.liveSyncPosition)&&(this.fragmentTracker.getState(v)===Sg&&(this.mainFragLoading=v=null),v&&_p(v))){if(g.start>v.end){const e=this.fragmentTracker.getFragAtPos(m,Zf);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 Bm(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!==oy&&(this.setInterval(100),this.state=ly,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(Yf.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!==oy&&(this.state=hy));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 d=i[s];let c=0;if(n.live||null!=(r=d.details)&&r.live){if(this.checkLiveUpdate(n),n.deltaUpdateFailed)return;var u;if(d.details)c=this.alignPlaylists(n,d.details,null==(u=this.levelLastLoaded)?void 0:u.details);n.alignedSliding||(ry(n,l),n.alignedSliding||iy(n,l),c=n.fragmentStart)}d.details=n,this.levelLastLoaded=d,this.startFragRequested||this.setStartPosition(l,c),this.hls.trigger(Yf.AUDIO_TRACK_UPDATED,{details:n,id:s,groupId:t.groupId}),this.state!==hy||this.waitForCdnTuneIn(n)||(this.state=ly),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 d=l.details;if(!d)return this.warn("Audio track details undefined on fragment load progress"),void this.removeUnbufferedFrags(r.start);const c=s.defaultAudioCodec||l.audioCodec||"mp4a.40.2";let u=this.transmuxer;u||(u=this.transmuxer=new Xb(this.hls,Jf,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 Bg(r.level,r.sn,r.stats.chunkCount,n.byteLength,t,s);u.push(n,f,c,"",r,i,d.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 [${d.startSN} ,${d.endSN}],track ${a}`);const{cache:e}=this.waitingData=this.waitingData||{frag:r,part:i,cache:new wy,complete:!1};e.push(new Uint8Array(n)),this.state!==oy&&(this.state=vy)}}_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===Zf&&_p(t.frag)&&(this.mainFragLoading=t,this.state===ly&&this.tick())}onFragBuffered(e,t){const{frag:r,part:i}=t;if(r.type===Jf)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(_p(r)){this.fragPrevious=r;const e=this.switchingTrack;e&&(this.bufferedTrack=e,this.switchingTrack=null,this.hls.trigger(Yf.AUDIO_TRACK_SWITCHED,ap({},e)))}this.fragBufferedComplete(r,i),this.media&&this.tick()}else this.audioOnly||r.type!==Zf||r.elementaryStreams.video||r.elementaryStreams.audiovideo||(this.audioOnly=!0,this.mainFragLoading=null)}onError(e,t){var r;if(t.fatal)this.state=gy;else switch(t.details){case Wf.FRAG_GAP:case Wf.FRAG_PARSING_ERROR:case Wf.FRAG_DECRYPT_ERROR:case Wf.FRAG_LOAD_ERROR:case Wf.FRAG_LOAD_TIMEOUT:case Wf.KEY_LOAD_ERROR:case Wf.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Jf,t);break;case Wf.AUDIO_TRACK_LOAD_ERROR:case Wf.AUDIO_TRACK_LOAD_TIMEOUT:case Wf.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==hy||(null==(r=t.context)?void 0:r.type)!==Xf||(this.state=ly);break;case Wf.BUFFER_ADD_CODEC_ERROR:case Wf.BUFFER_APPEND_ERROR:if("audio"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)||this.resetLoadingState();break;case Wf.BUFFER_FULL_ERROR:if("audio"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case Wf.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}onBufferFlushing(e,{type:t}){t!==Pp&&(this.flushing=!0)}onBufferFlushed(e,{type:t}){if(t!==Pp){this.flushing=!1,this.bufferFlushed=!0,this.state===my&&(this.state=ly);const e=this.mediaBuffer||this.media;e&&(this.afterBufferFlushed(e,t,Jf),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:d}=a,{details:c}=d,{audio:u,text:h,id3:f,initSegment:p}=n;if(!this.fragContextChanged(o)&&c){if(this.state=fy,this.switchingTrack&&u&&this.completeAudioSwitch(this.switchingTrack),null!=p&&p.tracks){const e=o.initSegment||o;if(this.unhandledEncryptionError(p,o))return;this._bufferInitSegment(d,p.tracks,e,s),i.trigger(Yf.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[Rp]={startPTS:e,endPTS:t,startDTS:r,endDTS:i}),o.setElementaryStreamInfo(Rp,e,t,r,i),this.bufferFragmentData(u,o,l,s)}if(null!=f&&null!=(t=f.samples)&&t.length){const e=np({id:r,frag:o,details:c},f);i.trigger(Yf.FRAG_PARSING_METADATA,e)}if(h){const e=np({id:r,frag:o,details:c},h);i.trigger(Yf.FRAG_PARSING_USERDATA,e)}}else this.fragmentTracker.removeFragment(o)}_bufferInitSegment(e,t,r,i){if(this.state!==fy)return;if(t.video&&delete t.video,t.audiovideo&&delete t.audiovideo,!t.audio)return;const n=t.audio;n.id=Jf;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(Yf.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(Yf.BUFFER_APPENDING,e)}this.tickImmediate()}loadFragment(e,t,r){const i=this.fragmentTracker.getState(e);var n;if(this.switchingTrack||i===bg||i===wg)if(_p(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=vy;const r=this.mainDetails;r&&r.fragmentStart!==t.details.fragmentStart&&iy(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;Ym({name:t,lang:r,assocLang:i,characteristics:n,audioCodec:s,channels:a},e,Km)||(Xm(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(Yf.AUDIO_TRACK_SWITCHED,ap({},e))}},audioTrackController:class extends Qb{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(Yf.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Yf.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Yf.LEVEL_LOADING,this.onLevelLoading,this),e.on(Yf.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(Yf.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(Yf.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(Yf.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Yf.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Yf.LEVEL_LOADING,this.onLevelLoading,this),e.off(Yf.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(Yf.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(Yf.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=Wm(t,e,Km);if(r>-1)n=e[r];else{const e=Wm(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(Yf.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(Yf.ERROR,{type:Vf.MEDIA_ERROR,details:Wf.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:t})}}}onError(e,t){!t.fatal&&t.context&&(t.context.type!==Xf||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&&Ym(e,i,Km))return i;const n=Wm(e,this.tracksInGroup,Km);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,d=s.codecSet.substring(0,4),c=qm(t,i,t=>{if(t.videoRange!==o||t.frameRate!==l||t.codecSet.substring(0,4)!==d)return!1;const i=t.audioGroups,s=r.filter(e=>!i||-1!==i.indexOf(e.groupId));return Wm(e,s,n)>-1});return c>-1?c:qm(t,i,t=>{const i=t.audioGroups,s=r.filter(e=>!i||-1!==i.indexOf(e.groupId));return Wm(e,s,n)>-1})}(e,t.levels,r,i,Km);if(-1===n)return null;t.nextLoadLevel=n}if(e.channels||e.audioCodec){const t=Wm(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(Yf.AUDIO_TRACK_SWITCHING,ap({},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||Ym(e,i,Km)))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(Ym({name:r,lang:i,assocLang:n,characteristics:s,audioCodec:a,channels:o},t[e],Km))return e}for(let r=0;r<t.length;r++){const i=t[r];if(Jb(e.attrs,i.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return r}for(let r=0;r<t.length;r++){const i=t[r];if(Jb(e.attrs,i.attrs,["LANGUAGE"]))return r}}return-1}loadPlaylist(e){super.loadPlaylist();const t=this.currentTrack;this.shouldLoadPlaylist(t)&&Xm(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(Yf.AUDIO_TRACK_LOADING,{url:n,id:r,groupId:i,deliveryDirectives:t||null,track:e})}},emeController:iw,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:lE.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!==lE.VIDEO&&n!==lE.AUDIO&&n!=lE.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(Yf.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Yf.MEDIA_DETACHED,this.onMediaDetached,this),e.on(Yf.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const e=this.hls;e.off(Yf.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Yf.MEDIA_DETACHED,this.onMediaDetached,this),e.off(Yf.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:dE.HLS,sid:this.sid,cid:this.cid,pr:null==(e=this.media)?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){np(t,this.createData());const r=t.ot===lE.INIT||t.ot===lE.VIDEO||t.ot===lE.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={}),QE(e.headers,t,n)):e.url=ew(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?lE.TIMED_TEXT:"initSegment"===e.sn?lE.INIT:"audio"===t?lE.AUDIO:"main"===t?this.hls.audioTracks.length?lE.VIDEO:lE.MUXED:void 0}getTopBandwidth(e){let t,r=0;const i=this.hls;if(e===lE.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===lE.AUDIO?this.audioBuffer:this.videoBuffer;if(!r||!t)return NaN;return 1e3*zg.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 op{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(Yf.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Yf.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(Yf.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Yf.ERROR,this.onError,this)}unregisterListeners(){const e=this.hls;e&&(e.off(Yf.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Yf.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(Yf.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Yf.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)===ug&&r.flags===mg){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!==Wf.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: ${Gm(i)} penalized: ${Gm(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,Xv(t),this.hls.trigger(Yf.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===Xf&&i[r].hasAudioGroup(e)||t===Qf&&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 qg(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=rw(e.uri,t["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",a),d=new Bm({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++)d.addGroupId("audio",`${e.audioGroups[t]}_clone_${n}`);if(e.subtitleGroups)for(let t=1;t<e.subtitleGroups.length;t++)d.addGroupId("text",`${e.subtitleGroups[t]}_clone_${n}`);return d});t.push(...o),tw(this.audioTracks,r,a,n),tw(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 d={steeringManifest:s,url:i.toString()};this.hls.trigger(Yf.STEERING_MANIFEST_LOADED,d),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 op{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=>xw(e))} pos: ${this.timelinePos}`),o.length&&this.log(`Removed events ${o}`);let d=null,c=null;i&&(d=this.updateItem(i,this.timelinePos),this.itemsMatch(i,d)?this.playingItem=d:this.waitingItem=this.endedItem=null),this.waitingItem=this.updateItem(this.waitingItem),this.endedItem=this.updateItem(this.endedItem);const u=this.bufferingItem;if(u&&(c=this.updateItem(u,this.bufferedPos),this.itemsMatch(u,c)?this.bufferingItem=c: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)>pw&&this.warn(`${i} ("${e.assetId}" ${e.timelineOffset}->${t})`)}}}),l||t){if(this.hls.trigger(Yf.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(d,i),u&&c!==d&&this.trimInPlace(c,u),this.checkBuffer()}},this.hls=e,this.HlsPlayerClass=t,this.assetListLoader=new Aw(e),this.schedule=new Tw(this.onScheduleUpdate,e.logger),this.registerListeners()}registerListeners(){const e=this.hls;e&&(e.on(Yf.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(Yf.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Yf.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Yf.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Yf.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(Yf.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(Yf.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.on(Yf.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(Yf.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.on(Yf.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.on(Yf.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.on(Yf.BUFFER_APPENDED,this.onBufferAppended,this),e.on(Yf.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(Yf.BUFFERED_TO_END,this.onBufferedToEnd,this),e.on(Yf.MEDIA_ENDED,this.onMediaEnded,this),e.on(Yf.ERROR,this.onError,this),e.on(Yf.DESTROYING,this.onDestroying,this))}unregisterListeners(){const e=this.hls;e&&(e.off(Yf.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(Yf.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Yf.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Yf.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Yf.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(Yf.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(Yf.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.off(Yf.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(Yf.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.off(Yf.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.off(Yf.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.off(Yf.BUFFER_CODECS,this.onBufferCodecs,this),e.off(Yf.BUFFER_APPENDED,this.onBufferAppended,this),e.off(Yf.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(Yf.BUFFERED_TO_END,this.onBufferedToEnd,this),e.off(Yf.MEDIA_ENDED,this.onMediaEnded,this),e.off(Yf.ERROR,this.onError,this),e.off(Yf.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){sy(e,"play",this.onPlay),sy(e,"pause",this.onPause),sy(e,"seeking",this.onSeeking),sy(e,"timeupdate",this.onTimeupdate)}onMediaAttaching(e,t){const r=this.media=t.media;ny(r,"seeking",this.onSeeking),ny(r,"timeupdate",this.onTimeupdate),ny(r,"play",this.onPlay),ny(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 d=t.event;if(d){if("playout"===i||d.timelineOccupancy!==mw.Point){const e=r(s);(null==e?void 0:e.interstitial)===d&&(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,d=e.schedule.findItemIndexAtTime(t,n),c=null==(a=e.schedule.items)?void 0:a[d],u=e.getBufferingPlayer(),h=null==u?void 0:u.interstitial,f=null==h?void 0:h.appendInPlace,p=l&&e.itemsMatch(l,c);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,d=(f?r:a.currentTime)+o;if(d>=0&&(!s||f||d<=s.duration))return void(a.currentTime=d)}}if(c){let r=t;if("primary"!==n){const e=t-c[n].start;r=c.start+e}const i=!e.isInterstitial(c);if(e.isInterstitial(l)&&!l.event.appendInPlace||!i&&!c.event.appendInPlace){if(l){const s=e.findItemIndex(l);if(d>s){const t=e.schedule.findJumpRestrictedIndex(s+1,d);if(t>s)return void e.setSchedulePosition(t)}let a=0;if(i)e.timelinePos=r,e.checkBuffer();else{const e=c.event.assetList,r=t-(c[n]||c).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(d,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&&Gf(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} ${Gm(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 d;if(s.media)o&&(n=s.transferMedia(),this.detachedData=n),d="Primary";else if(l){const e=this.getBufferingPlayer();e?(n=e.transferMedia(),d=`${e}`):d="detached MediaSource"}else d="detached media";if(!n)if(l)n=this.detachedData,this.log(`using detachedData: MediaSource ${Gm(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 c=n&&"mediaSource"in n&&"closed"!==(null==(i=n.mediaSource)?void 0:i.readyState),u=c&&n?n:t;this.log(`${c?"transfering MediaSource":"attaching media"} to ${a?e:"Primary"} from ${d} (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(Lw("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=Ew(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=Ew(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(Lw("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?xw(n):n}) pos: ${this.timelinePos}`);const s=this.waitingItem||this.playingItem,a=this.playingLastItem;if(this.isInterstitial(s)){const r=s.event,d=this.playingAsset,c=null==d?void 0:d.identifier,u=c?this.getAssetPlayer(c):null;if(u&&c&&(!this.eventItemsMatch(s,n)||void 0!==t&&c!==r.assetList[t].identifier)){var o;const t=r.findAssetIndex(d);if(this.log(`INTERSTITIAL_ASSET_ENDED ${t+1}/${r.assetList.length} ${ww(d)}`),this.endedAsset=d,this.playingAsset=null,this.hls.trigger(Yf.INTERSTITIAL_ASSET_ENDED,{asset:d,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(c,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} ${xw(s)}`),r.hasPlayed=!0,this.hls.trigger(Yf.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=Ew(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 d=this.preloadAssets(n,r);if(this.eventItemsMatch(a,l||i)||(this.waitingItem=a,this.log(`INTERSTITIAL_STARTED ${xw(a)} ${n.appendInPlace?"append in place":""}`),this.hls.trigger(Yf.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 c=n.assetList[r];if(!c)return void this.advanceAfterAssetEnded(n,e,r||0);if(d||(d=this.getAssetPlayer(c.identifier)),null===d||d.destroyed){const e=n.assetList.length;this.warn(`asset ${r+1}/${e} player destroyed ${n}`),d=this.createAssetPlayer(n,c,r),d.loadSource()}if(!this.eventItemsMatch(a,this.bufferingItem)&&n.appendInPlace&&this.isAssetBuffered(c))return;this.startAssetPlayer(d,r,t,e,o),this.shouldPlay&&kw(d.media)}else a?(this.resumePrimary(a,e,i),this.shouldPlay&&kw(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 ${xw(e)}`),null==(i=this.detachedData)||!i.mediaSource){let r=this.timelinePos;(r<e.start||r>=e.end)&&(r=this.getPrimaryResumption(e,t),this.log(Lw("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 ${xw(e)}`),this.hls.trigger(Yf.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 zg.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(Lw("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(Yf.BUFFER_CODECS,this.onBufferCodecs,this),this.hls.on(Yf.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=ap(ap({},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=ap(ap({},this.altSelection),{},{audio:r}));const n=ap(ap({},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=ap(ap({},this.altSelection),{},{subtitles:r}));const n=ap(ap({},i),{},{subtitles:r});this.mediaSelection=n}onAudioTrackSwitching(e,t){const r=Vm(t);this.playerQueue.forEach(({hls:e})=>e&&(e.setAudioOption(t)||e.setAudioOption(r)))}onSubtitleTrackSwitch(e,t){const r=Vm(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=zg.bufferInfo(this.primaryMedia,r,0);if(i.end>r||(i.nextStart||0)>r){this.log(`trim buffered interstitial ${xw(e)} (was ${xw(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=zg.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 ${xw(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(Yf.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(Yf.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:gw(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=np({},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 d=0;if(this.primaryLive||e.appendInPlace){const e=this.timelinePos-t.timelineStart;if(e>1){const r=t.duration;r&&e<r&&(d=e)}}const c=t.identifier,u=ap(ap({},n),{},{maxMaxBufferLength:Math.min(180,i.config.maxMaxBufferLength),autoStartLoad:!0,startFragPrefetch:!0,primarySessionId:i.sessionId,assetPlayerId:c,abrEwmaDefaultEstimate:i.bandwidthEstimate,interstitialsController:void 0,startPosition:d,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=np({},h,{contentId:fw(t.uri)})),this.getAssetPlayer(c)&&this.warn(`Duplicate date range identifier ${e} and asset ${c}`);const f=new Sw(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:Vf.OTHER_ERROR,details:Wf.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 "${c}" duration change ${a} > ${s}`),t.duration=s,this.updateSchedule())};f.on(Yf.LEVEL_UPDATED,(e,{details:t})=>m(t)),f.on(Yf.LEVEL_PTS_UPDATED,(e,{details:t})=>m(t)),f.on(Yf.EVENT_CUE_ENTER,()=>this.onInterstitialCueEnter());const g=(e,t)=>{const r=this.getAssetPlayer(c);if(r&&t.tracks){r.off(Yf.BUFFER_CODECS,g),r.tracks=t.tracks;const e=this.primaryMedia;this.bufferingAsset===r.assetItem&&e&&!r.media&&this.bufferAssetPlayer(r,e)}};f.on(Yf.BUFFER_CODECS,g);f.on(Yf.BUFFERED_TO_END,()=>{var r;const i=this.getAssetPlayer(c);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(c)||!this.schedule)return;this.shouldPlay=!0;const r=this.schedule.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,r,t)};return f.once(Yf.MEDIA_ENDED,v(r)),f.once(Yf.PLAYOUT_LIMIT_REACHED,v(1/0)),f.on(Yf.ERROR,(t,i)=>{if(!this.schedule)return;const n=this.getAssetPlayer(c);if(i.details===Wf.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(Yf.DESTROYING,()=>{if(!this.getAssetPlayer(c)||!this.schedule)return;const t=new Error(`Asset player destroyed unexpectedly ${c}`),i={fatal:!0,type:Vf.OTHER_ERROR,details:Wf.INTERSTITIAL_ASSET_ITEM_ERROR,error:t};this.handleAssetItemError(i,e,this.schedule.findEventIndex(e.identifier),r,t.message)}),this.log(`INTERSTITIAL_ASSET_PLAYER_CREATED ${ww(t)}`),this.hls.trigger(Yf.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?xw(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,d=this.playingAsset;this.endedAsset=null,this.playingAsset=a,d&&d.identifier===o||(d&&(this.clearAssetPlayer(d.identifier,r[i]),delete d.error),this.log(`INTERSTITIAL_ASSET_STARTED ${t+1}/${l} ${ww(a)}`),this.hls.trigger(Yf.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 d=n.appendInPlace;if(d&&!1===(null==l?void 0:l.interstitial.appendInPlace))return;const c=(null==l?void 0:l.tracks)||(null==(i=this.detachedData)?void 0:i.tracks)||this.requiredTracks;if(d&&s!==this.playingAsset){if(!e.tracks)return void this.log(`Waiting for track info before buffering ${e}`);if(c&&!mp(c,e.tracks)){const t=new Error(`Asset ${ww(s)} SourceBuffer tracks ('${Object.keys(e.tracks)}') are not compatible with primary content tracks ('${Object.keys(c)}')`),r={fatal:!0,type:Vf.OTHER_ERROR,details:Wf.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===Wf.BUFFER_STALLED_ERROR)return;const s=t.assetList[i]||null;if(this.warn(`INTERSTITIAL_ASSET_ERROR ${s?ww(s):s} ${e.error}`),!this.schedule)return;const a=(null==s?void 0:s.identifier)||"",o=this.getAssetPlayerQueueIndex(a),l=this.playerQueue[o]||null,d=this.schedule.items,c=np({},e,{fatal:!1,errorAction:yg(!0),asset:s,assetListIndex:i,event:t,schedule:d,scheduleIndex:r,player:l});if(this.hls.trigger(Yf.INTERSTITIAL_ASSET_ERROR,c),!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: ${xw(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 d=0;a.forEach((e,t)=>{const r=parseFloat(e.DURATION);this.createAsset(n,t,d,o+d,r,e.URI),d+=r}),n.duration=d,this.log(`Loaded asset-list with duration: ${d} (was: ${l}) ${n}`);const c=this.waitingItem,u=(null==c?void 0:c.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 Wf.ASSET_LIST_PARSING_ERROR:case Wf.ASSET_LIST_LOAD_ERROR:case Wf.ASSET_LIST_LOAD_TIMEOUT:{const e=t.interstitial;e&&(this.updateSchedule(!0),this.primaryFallback(e));break}case Wf.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 DS(e){return e&&"object"==typeof e?Array.isArray(e)?e.map(DS):Object.keys(e).reduce((t,r)=>(t[r]=DS(e[r]),t),{}):e}function _S(e,t){const r=e.loader;if(r!==kS&&r!==PS)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=kS,e.progressive=!0,e.enableSoftwareAES=!0,t.log("[config]: Progressive streaming enabled, using FetchLoader"))}}class OS extends $g{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(Yf.MEDIA_ENDED,{stalled:!1}))},this.hls=e,this.fragmentTracker=t,this.registerListeners()}registerListeners(){const{hls:e}=this;e&&(e.on(Yf.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Yf.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Yf.BUFFER_APPENDED,this.onBufferAppended,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off(Yf.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Yf.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Yf.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;ny(r,"playing",this.onMediaPlaying),ny(r,"waiting",this.onMediaWaiting),ny(r,"ended",this.onMediaEnded)}onMediaDetaching(e,t){this.clearInterval();const{media:r}=this;r&&(sy(r,"playing",this.onMediaPlaying),sy(r,"waiting",this.onMediaWaiting),sy(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,d=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&&!d&&e>t&&this.nudgeOnVideoHole(e,t)),void(0===this.waiting&&this.stallResolved(e));if(l||o)return void(o&&this.stallResolved(e));if(d)return this.nudgeRetry=0,this.stallResolved(e),void(!this.ended&&s.ended&&this.hls&&(this.ended=e||1,this.hls.trigger(Yf.MEDIA_ENDED,{stalled:!1})));if(!zg.getBuffered(s).length)return void(this.nudgeRetry=0);const c=zg.bufferInfo(s,e,0),u=c.nextStart||0,h=this.fragmentTracker;if(a&&h&&this.hls){const t=MS(this.hls.inFlightFragments,e),r=c.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(!(c.len>0)&&!u)return;const t=Math.max(u,c.start||0)-e,r=!(null==f||!f.live)?2*f.targetduration:2,i=FS(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(Yf.MEDIA_ENDED,{stalled:!0})}if(this._reportStall(c),!this.media||!this.hls)return}const E=zg.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(Yf.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=zg.bufferedInfo(zg.timeRangesToArray(this.buffered.audio),e,0);if(r.len>1&&t>=r.start){const r=zg.timeRangesToArray(i),n=zg.bufferedInfo(r,t,0).bufferedIndex;if(n>-1&&n<r.length-1){const t=zg.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=FS(e,this.fragmentTracker);n&&"fragment"in n?n=n.fragment:n||(n=void 0);const a=zg.bufferInfo(this.media,e,0);this.hls.trigger(Yf.ERROR,{type:Vf.MEDIA_ERROR,details:Wf.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,d=FS(r,s);if(d||null!=l&&l.live&&r<l.fragmentStart){if(this._trySkipBufferHole(d)||!this.media)return}const c=e.buffered,u=this.adjacentTraversal(e,r);(c&&c.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,Zf),n=r.getFragAtPos(i,Zf);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 (${Gm(e)})`);this.warn(i.message),t.trigger(Yf.ERROR,{type:Vf.MEDIA_ERROR,details:Wf.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=zg.bufferInfo(i,s,0),o=s<a.start?a.start:a.nextStart;if(o&&this.hls){const t=a.len<=n.maxBufferHole,d=a.len>0&&a.len<1&&i.readyState<3,c=o-s;if(c>0&&(t||d)){if(c>n.maxBufferHole){let t=!1;if(0===s){const e=r.getAppendedFrag(0,Zf);e&&o<e.end&&(t=!0)}if(!t&&e){var l;if(null==(l=this.hls.loadLevelObj)||!l.details)return 0;if(MS(this.hls.inFlightFragments,o))return 0;let t=!1,i=e.end;for(;i<o;){const e=FS(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:Vf.MEDIA_ERROR,details:Wf.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(Yf.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(Yf.ERROR,{type:Vf.MEDIA_ERROR,details:Wf.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(Yf.ERROR,{type:Vf.MEDIA_ERROR,details:Wf.BUFFER_STALLED_ERROR,error:r,fatal:!0,buffer:e.len,bufferInfo:e})}}}function MS(e,t){const r=NS(e.main);if(r&&r.start<=t)return r;const i=NS(e.audio);return i&&i.start<=t?i:null}function NS(e){if(!e)return null;switch(e.state){case ly:case oy:case my:case gy:return null}return e.frag}function FS(e,t){return t.getAppendedFrag(e,Zf)||t.getPartialFragment(e)}function $S(){if("undefined"!=typeof self)return self.VTTCue||self.TextTrackCue}function BS(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,Gm(n?ap({type:n},i):i))}return s}const US=(()=>{const e=$S();try{e&&new e(0,Number.POSITIVE_INFINITY,"")}catch(e){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();class zS{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(Yf.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(Yf.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(Yf.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Yf.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Yf.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Yf.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(Yf.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(Yf.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(Yf.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}_unregisterListeners(){const{hls:e}=this;e&&(e.off(Yf.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(Yf.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Yf.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Yf.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Yf.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(Yf.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(Yf.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(Yf.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&&cw(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 lw(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=$S();if(s)for(let e=0;e<n.length;e++){const t=n[e].type;if(t===qy.emsg&&!r||!i)continue;const a=Vy(n[e].data),o=n[e].pts;let l=o+n[e].duration;l>US&&(l=US);l-o<=0&&(l=o+.25);for(let e=0;e<a.length;e++){const r=a[e];if(!Wy(r)){this.updateId3CueEnds(o,t);const e=BS(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===US&&(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===qy.audioId3&&o:"video"===i?e=>e.type===qy.emsg&&a:e=>e.type===qy.audioId3&&o||e.type===qy.emsg&&a,uw(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=$S();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=BS(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,d=Object.keys(l);let c=this.dateRangeCuesAppended;var u;if(o&&t)if(null!=(u=o.cues)&&u.length){const e=Object.keys(c).filter(e=>!d.includes(e));for(let t=e.length;t--;){var h;const r=e[t],i=null==(h=c[r])?void 0:h.cues;delete c[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 c=this.dateRangeCuesAppended={};const f=e.fragments[e.fragments.length-1];if(0!==d.length&&Gf(null==f?void 0:f.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(let e=0;e<d.length;e++){const t=d[e],r=l[t],i=r.startTime,n=c[t],o=(null==n?void 0:n.cues)||{};let u=(null==n?void 0:n.durationKnown)||!1,h=US;const{duration:f,endDate:p}=r;if(p&&null!==f)h=i+f,u=!0;else if(r.endOnNext&&!u){const e=d.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(!Xg(l))continue;const d=o[l];if(d)!u||null!=n&&n.durationKnown?Math.abs(d.startTime-i)>.01&&(d.startTime=i,d.endTime=h):d.endTime=h;else if(a){let e=r.attr[l];Qg(l)&&(e=yp(e));const n=BS(a,i,h,{key:l,data:e},qy.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)))}}c[t]={cues:o,dateRange:r,durationKnown:u}}}}}class GS{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 d=i;return l+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,d)}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(Yf.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Yf.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Yf.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Yf.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(Yf.ERROR,this.onError,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off(Yf.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Yf.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Yf.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Yf.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(Yf.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===Wf.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 jS extends Qb{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(Yf.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Yf.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(Yf.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Yf.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(Yf.FRAG_BUFFERED,this.onFragBuffered,this),e.on(Yf.ERROR,this.onError,this)}_unregisterListeners(){const{hls:e}=this;e.off(Yf.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Yf.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(Yf.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Yf.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(Yf.FRAG_BUFFERED,this.onFragBuffered,this),e.off(Yf.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:d,videoCodec:c}=e;d&&(e.audioCodec=d=bm(d,r)||void 0),c&&(c=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(",")}(c));const{width:u,height:h,unknownCodecs:f}=e,p=(null==f?void 0:f.length)||0;if(a||(a=!(!u||!h)),o||(o=!!c),l||(l=!!d),p||d&&!this.isAudioSupported(d)||c&&!this.isVideoSupported(c))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 Bm(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=Lm(e,[])}return t}isAudioSupported(e){return hm(e,"audio",this.hls.config.preferManagedMediaSource)}isVideoSupported(e){return hm(e,"video",this.hls.config.preferManagedMediaSource)}filterAndSortMediaOptions(e,t,r,i,n){var s;let a=[],o=[],l=e;const d=(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)&&_m.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: ${Gm(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(Yf.ERROR,{type:Vf.MEDIA_ERROR,details:Wf.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:i,reason:r})}}),void(d.end=performance.now());t.audioTracks&&(a=t.audioTracks.filter(e=>!e.audioCodec||this.isAudioSupported(e.audioCodec)),HS(a)),t.subtitles&&(o=t.subtitles,HS(o));const c=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 _m.indexOf(e.videoRange)-_m.indexOf(t.videoRange);if(e.videoCodec!==t.videoCodec){const r=mm(e.videoCodec),i=mm(t.videoCodec);if(r!==i)return i-r}if(e.uri===t.uri&&e.codecSet!==t.codecSet){const r=gm(e.codecSet),i=gm(t.codecSet);if(r!==i)return i-r}return e.averageBitrate!==t.averageBitrate?e.averageBitrate-t.averageBitrate:0});let u=c[0];if(this.steering&&(l=this.steering.filterParsedLevels(l),l.length!==c.length))for(let e=0;e<c.length;e++)if(c[e].pathwayId===l[0].pathwayId){u=c[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)};d.end=performance.now(),this.hls.trigger(Yf.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(Yf.ERROR,{type:Vf.OTHER_ERROR,details:Wf.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(Yf.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===qf&&t.context.level===this.level&&this.checkRetry(t)}onFragBuffered(e,{frag:t}){if(void 0!==t&&t.type===Zf){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(Yf.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));Xv(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(Yf.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(Yf.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:r}))}}function HS(e){const t={};e.forEach(e=>{const r=e.groupId||"";e.id=t[r]=t[r]||0,t[r]++})}function VS(){return self.SourceBuffer||self.WebKitSourceBuffer}function WS(){if(!pp())return!1;const e=VS();return!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove}class YS extends by{constructor(e,t,r){super(e,t,r,"stream-controller",Zf),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||!Gf(t))return;if(this.log(`Media seeked to ${t.toFixed(3)}`),!this.getBufferedFrag(t))return;const r=this.getFwdBufferInfoAtPos(e,t,Zf,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(Yf.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Yf.LEVEL_LOADING,this.onLevelLoading,this),e.on(Yf.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Yf.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(Yf.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(Yf.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(Yf.BUFFER_CREATED,this.onBufferCreated,this),e.on(Yf.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(Yf.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(Yf.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){super.unregisterListeners();const{hls:e}=this;e.off(Yf.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Yf.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Yf.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(Yf.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(Yf.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(Yf.BUFFER_CREATED,this.onBufferCreated,this),e.off(Yf.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(Yf.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(Yf.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=ly,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}else this._forceStartLoad=!0,this.state=oy}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case yy:{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=ly;break}if(this.hls.nextLoadLevel!==this.level){this.state=ly;break}break}case uy:this.checkRetryDate()}this.state===ly&&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(Yf.BUFFER_EOS,e),void(this.state=my)}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===yy||this.waitForLive(s))return this.level=n,this.state=yy,void(this.startFragRequested=!1);const d=a.len,c=this.getMaxBufferLength(s.maxBitrate);if(d>=c)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&&_p(h)&&this.fragmentTracker.getState(h)!==Sg){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?Rp:Pp,t=(e===Pp?this.videoBuffer:this.mediaBuffer)||this.media;t&&this.afterBufferFlushed(t,e,Zf)}h=this.getNextFragmentLoopLoading(h,l,a,Zf,c)}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===bg||i===wg?_p(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,Zf)}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 dy:case cy:case uy:case fy:case py:this.state=ly}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;ny(r,"playing",this.onMediaPlaying),ny(r,"seeked",this.onMediaSeeked)}onMediaDetaching(e,t){const{media:r}=this;r&&(sy(r,"playing",this.onMediaPlaying),sy(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(Yf.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=VS();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!==ly)return;const i=t.levelInfo;(!i.details||i.details.live&&(this.levelLastLoaded!==i||i.details.expired)||this.waitForCdnTuneIn(i.details))&&(this.state=yy)}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,d=this.fragCurrent;!d||this.state!==cy&&this.state!==uy||d.level!==t.level&&d.loader&&this.abortCurrentFrag();let c=0;if(a.live||null!=(r=l.details)&&r.live){var u;if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;c=this.alignPlaylists(a,l.details,null==(u=this.levelLastLoaded)?void 0:u.details)}if(l.details=a,this.levelLastLoaded=l,n||this.setStartPosition(a,c),this.hls.trigger(Yf.LEVEL_UPDATED,{details:a,level:s}),this.state===yy){if(this.waitForCdnTuneIn(a))return;this.state=ly}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=zg.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}=zg.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,d=o.PTSKnown||!o.live,c=null==(t=r.initSegment)?void 0:t.data,u=this._getAudioCodec(a),h=this.transmuxer=this.transmuxer||new Xb(this.hls,Zf,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),f=i?i.index:-1,p=-1!==f,m=new Bg(r.level,r.sn,r.stats.chunkCount,n.byteLength,f,p),g=this.initPTS[r.cc];h.push(n,c,u,l,r,i,o.totalduration,d,m,g)}onAudioTrackSwitching(e,t){const r=this.hls,i=0!==this.altAudio;if(Xm(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(Yf.BUFFER_FLUSHED,()=>{this.hls&&this.hls.trigger(Yf.AUDIO_TRACK_SWITCHED,t)}),void r.trigger(Yf.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});r.trigger(Yf.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){const r=Xm(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===Zf;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===py&&(this.state=ly));const e=i?i.stats:r.stats;this.fragLastKbps=Math.round(8*e.total/(e.buffering.end-e.loading.first)),_p(r)&&(this.fragPrevious=r),this.fragBufferedComplete(r,i)}const s=this.media;s&&(!this._hasEnoughToStart&&zg.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=gy;else switch(t.details){case Wf.FRAG_GAP:case Wf.FRAG_PARSING_ERROR:case Wf.FRAG_DECRYPT_ERROR:case Wf.FRAG_LOAD_ERROR:case Wf.FRAG_LOAD_TIMEOUT:case Wf.KEY_LOAD_ERROR:case Wf.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Zf,t);break;case Wf.LEVEL_LOAD_ERROR:case Wf.LEVEL_LOAD_TIMEOUT:case Wf.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==yy||(null==(r=t.context)?void 0:r.type)!==qf||(this.state=ly);break;case Wf.BUFFER_ADD_CODEC_ERROR:case Wf.BUFFER_APPEND_ERROR:if("main"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)&&this.resetLoadingState();break;case Wf.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 Wf.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}onFragLoadEmergencyAborted(){this.state=ly,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==Rp||!this.altAudio){const e=(t===Pp?this.videoBuffer:this.mediaBuffer)||this.media;e&&(this.afterBufferFlushed(e,t,Zf),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=zg.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=ly,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(Yf.FRAG_LOADED,e),i.bitrateTest=!1}).catch(t=>{this.state!==oy&&this.state!==gy&&(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:d,text:c,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=fy,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(Yf.FRAG_PARSING_INIT_SEGMENT,{frag:i,id:t,tracks:e})}const i=h.initPTS,s=h.timescale,o=this.initPTS[a.cc];if(Gf(i)&&(!o||o.baseTime!==i||o.timescale!==s)){const e=h.trackId;this.initPTS[a.cc]={baseTime:i,timescale:s,trackId:e},r.trigger(Yf.INIT_PTS_FOUND,{frag:a,id:t,initPTS:i,timescale:s,trackId:e})}}if(d&&f){p&&"audiovideo"===d.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}=d;if(o)o.elementaryStreams[d.type]={startPTS:e,endPTS:i,startDTS:s,endDTS:l};else if(d.firstKeyFrame&&d.independent&&1===n.id&&!r&&(this.couldBacktrack=!0),d.dropped&&d.independent){const n=this.getMainFwdBufferInfo(),s=(n?n.end:this.getLoadPosition())+this.config.maxBufferHole,o=d.firstKeyFramePTS?d.firstKeyFramePTS:e;if(!t&&s<o-this.config.maxBufferHole&&!r)return void this.backtrack(a);r&&(a.gap=!0),a.setElementaryStreamInfo(d.type,a.start,i,a.start,l,!0)}else t&&e-(f.appliedTimelineOffset||0)>2&&(a.gap=!0);a.setElementaryStreamInfo(d.type,e,i,s,l),this.backtrackFragment&&(this.backtrackFragment=a),this.bufferFragmentData(d,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[Rp]={startPTS:e,endPTS:t,startDTS:r,endDTS:i}),a.setElementaryStreamInfo(Rp,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(Yf.FRAG_PARSING_METADATA,e)}if(f&&c){const e={id:t,frag:a,details:f,samples:c.samples};r.trigger(Yf.FRAG_PARSING_USERDATA,e)}}}logMuxedErr(e){this.warn(`${_p(e)?"Media":"Init"} segment with muxed audiovideo where only video expected: ${e.url}`)}_bufferInitSegment(e,t,r,i){if(this.state!==fy)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=Em(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=Zf,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=Zf;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(Yf.BUFFER_CODECS,t),!this.hls)return;o.forEach(e=>{const n=t[e].initSegment;null!=n&&n.byteLength&&this.hls.trigger(Yf.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,Zf)}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=ly}checkFragmentChanged(){const e=this.media;let t=null;if(e&&e.readyState>1&&!1===e.seeking){const r=e.currentTime;if(zg.isBuffered(e,r)?t=this.getAppendedFrag(r):zg.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(Yf.FRAG_CHANGED,{frag:t}),e&&e.level===r||this.hls.trigger(Yf.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 Gf(t)?this.getAppendedFrag(t):null}get currentProgramDateTime(){var e;const t=(null==(e=this.media)?void 0:e.currentTime)||this.lastCurrentTime;if(Gf(t)){const e=this.getLevelDetails(),r=this.currentFrag||(e?Zm(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 KS extends op{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=Wf.KEY_LOAD_ERROR,r,i,n){return new Fg({type:Vf.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&&(!_p(e)||!_p(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=pv(e);return t?this.emeController.getKeySystemAccess([t]):void 0})}if(this.config.requireKeySystemAccessOnStart){const e=gv(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,Wf.KEY_LOAD_ERROR,r))}const s=n.uri;if(!s)return Promise.reject(this.createKeyLoadError(e,Wf.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${s}"`)));const a=qS(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: "+vp(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,Wf.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 Jp(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 ${vp(t)}`),wv.setKeyIdForUri(e.decryptdata.uri,t)):(t=wv.addKeyIdForUri(e.decryptdata.uri),this.log(`Generating keyId to patch media ${vp(t)}`)),e.decryptdata.keyId=t}}if(!e.decryptdata.keyId&&!_p(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},d={onSuccess:(e,t,r,i)=>{const{frag:a,keyInfo:o}=r,l=qS(o.decryptdata);if(!a.decryptdata||o!==this.keyIdToKeyInfo[l])return s(this.createKeyLoadError(a,Wf.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,Wf.KEY_LOAD_ERROR,new Error(`HTTP Error ${e.code} loading key ${e.text}`),i,ap({url:a.url,data:void 0},e)))},onTimeout:(e,r,i)=>{this.resetLoader(r),s(this.createKeyLoadError(t,Wf.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),i))},onAbort:(e,r,i)=>{this.resetLoader(r),s(this.createKeyLoadError(t,Wf.INTERNAL_ABORTED,new Error("key loading aborted"),i))}};i.load(a,l,d)})}resetLoader(e){const{frag:t,keyInfo:r,url:i}=e,n=r.loader;t.keyLoader===n&&(t.keyLoader=null,r.loader=null);const s=qS(r.decryptdata)||i;delete this.keyIdToKeyInfo[s],n&&n.destroy()}}function qS(e){if(e.keyFormat!==uv){const t=e.keyId;if(t)return vp(t)}return e.uri}function XS(e){const{type:t}=e;switch(t){case Xf:return Jf;case Qf:return ep;default:return Zf}}function QS(e,t){let r=e.url;return void 0!==r&&0!==r.indexOf("data:")||(r=t.url),r}class ZS{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(Yf.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Yf.LEVEL_LOADING,this.onLevelLoading,this),e.on(Yf.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(Yf.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.on(Yf.LEVELS_UPDATED,this.onLevelsUpdated,this)}unregisterListeners(){const{hls:e}=this;e.off(Yf.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Yf.LEVEL_LOADING,this.onLevelLoading,this),e.off(Yf.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(Yf.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.off(Yf.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:Kf,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:qf,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:Xf,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:Qf,url:n,deliveryDirectives:s,levelOrTrack:a})}onLevelsUpdated(e,t){const r=this.loaders[qf];if(r){const e=r.context;e&&!t.levels.some(t=>t===e.levelOrTrack)&&(r.abort(),delete this.loaders[qf])}}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===Kf?r.manifestLoadPolicy.default:np({},r.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),n=this.createInternalLoader(e),Gf(null==(t=e.deliveryDirectives)?void 0:t.part)){let t;if(e.type===qf&&null!==e.level?t=this.hls.levels[e.level].details:e.type===Xf&&null!==e.id?t=this.hls.audioTracks[e.id].details:e.type===Qf&&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=np({},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(),Iv.isMediaPlaylist(s)||r.type!==Kf?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=QS(e,r),o=Iv.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:d,sessionData:c,sessionKeys:u,startTimeOffset:h,variableList:f}=o;this.variableList=f,d.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];hm(a,"audio",r)?(e.audioCodec=i=i?`${i},${a}`:a,cm.audio[i.substring(0,4)]=2,t.splice(s,1)):hm(a,"video",r)&&(e.videoCodec=n=n?`${n},${a}`:a,cm.video[n.substring(0,4)]=2,t.splice(s,1))}}});const{AUDIO:p=[],SUBTITLES:m,"CLOSED-CAPTIONS":g}=Iv.parseMasterPlaylistMedia(s,a,o);if(p.length){p.some(e=>!e.url)||!d[0].audioCodec||d[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 qg({}),bitrate:0,url:""}))}n.trigger(Yf.MANIFEST_LOADED,{levels:d,audioTracks:p,subtitles:m,captions:g,contentSteering:l,url:a,stats:t,networkDetails:i,sessionData:c,sessionKeys:u,startTimeOffset:h,variableList:f})}handleTrackOrLevelPlaylist(e,t,r,i,n){const s=this.hls,{id:a,level:o,type:l}=r,d=QS(e,r),c=Gf(o)?o:Gf(a)?a:0,u=XS(r),h=Iv.parseLevelPlaylist(e.data,d,c,u,0,this.variableList);if(l===Kf){const e={attrs:new qg({}),bitrate:0,details:h,name:"",url:d};h.requestScheduled=t.loading.start+Wv(h,0),s.trigger(Yf.MANIFEST_LOADED,{levels:[e],audioTracks:[],url:d,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(Yf.ERROR,{type:Vf.NETWORK_ERROR,details:Wf.MANIFEST_PARSING_ERROR,fatal:t.type===Kf,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===qf?s+=`: ${e.level} id: ${e.id}`:e.type!==Xf&&e.type!==Qf||(s+=` id: ${e.id} group-id: "${e.groupId}"`);const a=new Error(s);this.hls.logger.warn(`[playlist-loader]: ${s}`);let o=Wf.UNKNOWN,l=!1;const d=this.getInternalLoader(e);switch(e.type){case Kf:o=r?Wf.MANIFEST_LOAD_TIMEOUT:Wf.MANIFEST_LOAD_ERROR,l=!0;break;case qf:o=r?Wf.LEVEL_LOAD_TIMEOUT:Wf.LEVEL_LOAD_ERROR,l=!1;break;case Xf:o=r?Wf.AUDIO_TRACK_LOAD_TIMEOUT:Wf.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case Qf:o=r?Wf.SUBTITLE_TRACK_LOAD_TIMEOUT:Wf.SUBTITLE_LOAD_ERROR,l=!1}d&&this.resetInternalLoader(e.type);const c={type:Vf.NETWORK_ERROR,details:o,fatal:l,url:e.url,loader:d,context:e,error:a,networkDetails:t,stats:n};if(i){const r=(null==t?void 0:t.url)||e.url;c.response=ap({url:r,data:void 0},i)}this.hls.trigger(Yf.ERROR,c)}handlePlaylistLoaded(e,t,r,i,n,s){const a=this.hls,{type:o,level:l,levelOrTrack:d,id:c,groupId:u,deliveryDirectives:h}=i,f=QS(t,i),p=XS(i);let m="number"==typeof i.level&&p===Zf?l:void 0;const g=e.playlistParsingError;if(g){if(this.hls.logger.warn(`${g} ${e.url}`),!a.config.ignorePlaylistParsingErrors)return void a.trigger(Yf.ERROR,{type:Vf.NETWORK_ERROR,details:Wf.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(Yf.ERROR,{type:Vf.NETWORK_ERROR,details:Wf.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 Kf:case qf:if(m)if(d){if(d!==a.levels[m]){const e=a.levels.indexOf(d);e>-1&&(m=e)}}else m=0;a.trigger(Yf.LEVEL_LOADED,{details:e,levelInfo:d||a.levels[0],level:m||0,id:c||0,stats:r,networkDetails:n,deliveryDirectives:h,withoutMultiVariant:o===Kf});break;case Xf:a.trigger(Yf.AUDIO_TRACK_LOADED,{details:e,track:d,id:c||0,groupId:u||"",stats:r,networkDetails:n,deliveryDirectives:h});break;case Qf:a.trigger(Yf.SUBTITLE_TRACK_LOADED,{details:e,track:d,id:c||0,groupId:u||"",stats:r,networkDetails:n,deliveryDirectives:h})}}}class JS{static get version(){return ky}static isMSESupported(){return WS()}static isSupported(){return function(){if(!WS())return!1;const e=pp();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(pm(t,"video")))||["mp4a.40.2","fLaC"].some(t=>e.isTypeSupported(pm(t,"audio"))))}()}static getMediaSource(){return pp()}static get Events(){return Yf}static get MetadataSchema(){return qy}static get ErrorTypes(){return Vf}static get ErrorDetails(){return Wf}static get DefaultConfig(){return JS.defaultConfig?JS.defaultConfig:CS}static set DefaultConfig(e){JS.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 Ay,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=cp();if("object"==typeof console&&!0===e||"object"==typeof e){const n=["debug","log","info","warn","error"];n.forEach(t=>{i[t]=up(t,e,r)});try{i.log(`Debug logs enabled for "${t}" in hls.js version 1.6.15`)}catch(e){return cp()}n.forEach(t=>{hp[t]=up(t,e)})}else np(hp,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=DS(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}": ${Gm(t[s])}`)}),ap(ap({},i),t)}(JS.DefaultConfig,e,t);this.userConfig=e,r.progressive&&_S(r,t);const{abrController:i,bufferController:n,capLevelController:s,errorController:a,fpsController:o}=r,l=new a(this),d=this.abrController=new i(this),c=new Tg(this),u=r.interstitialsController,h=u?this.interstitialsController=new u(this,JS):null,f=this.bufferController=new n(this,c),p=this.capLevelController=new s(this),m=new o(this),g=new ZS(this),v=r.contentSteeringController,y=v?new v(this):null,b=this.levelController=new jS(this,y),E=new zS(this),w=new KS(this.config,this.logger),S=this.streamController=new YS(this,c,w),T=this.gapController=new OS(this,c);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=[d,f,T,p,m,E,c];this.audioTrackController=this.createController(r.audioTrackController,x);const k=r.audioStreamController;k&&x.push(this.audioStreamController=new k(this,c,w)),this.subtitleTrackController=this.createController(r.subtitleTrackController,x);const L=r.subtitleStreamController;L&&x.push(this.subtititleStreamController=new L(this,c,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(GS,A),this.coreComponents=A,x.push(l);const I=l.onErrorOut;"function"==typeof I&&this.on(Yf.ERROR,I,l),this.on(Yf.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===Yf.ERROR;this.trigger(Yf.ERROR,{type:Vf.OTHER_ERROR,details:Wf.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(Yf.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(Yf.ERROR,{type:Vf.OTHER_ERROR,details:Wf.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(Yf.MEDIA_ATTACHING,i)}detachMedia(){this.logger.log("detachMedia"),this.trigger(Yf.MEDIA_DETACHING,{}),this._media=null}transferMedia(){this._media=null;const e=this.bufferController.transferMedia();return this.trigger(Yf.MEDIA_DETACHING,{transferMedia:e}),e}loadSource(e){this.stopLoad();const t=this.media,r=this._url,i=this._url=Lp.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(Yf.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={[Zf]:this.streamController.inFlightFrag};return this.audioStreamController&&(e[Jf]=this.audioStreamController.inFlightFrag),this.subtititleStreamController&&(e[ep]=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 Dm.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 Rm(e,Hm(t),navigator.mediaCapabilities)}}JS.defaultConfig=void 0;const eT=({file:e,startTime:n,poster:s,autoplay:o=!0,active:l=!0,visible:d=!0,muted:h=!0})=>{const f=r(null),{isReady:p,prewarm:m,setLowestResolution:g,startBufferBasedUpshift:v}=(({file:e,videoRef:t,autoplay:n=!0,startTime:s,enabled:o=!0,onReady:l,onError:d})=>{const h=r(null),f=r(null),p=r(0),m=r(0),g=r(!1),v=r(!1),[y,b]=a("idle"),[E,w]=a(0),[S,T]=a(!1),[A,k]=a([]),[L,I]=a("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=u(()=>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||!o)return void(e&&!o&&(v.current=!1,T(!1),b("idle")));let s=()=>{};try{null===(r=h.current)||void 0===r||r.destroy()}catch(e){}if(h.current=null,v.current=!1,T(!1),b("loading"),JS.isSupported()){g.current=!1;const t=new JS({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;I(null==r||r<0?"auto":r)},a=()=>{v.current||(v.current=!0,T(!0),b("ready"),p.current=0,R(),null==l||l(),n&&i.play().catch(()=>{}))};t.on(JS.Events.MANIFEST_PARSED,()=>{r(),n||_()}),t.on(JS.Events.FRAG_BUFFERED,a),t.on(JS.Events.BUFFER_APPENDED,a),t.on(JS.Events.LEVEL_SWITCHED,(e,t)=>{const r=null==t?void 0:t.level;I(null==r||r<0?"auto":r)}),t.on(JS.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!==JS.ErrorTypes.NETWORK_ERROR||r.fatal){if(r.fatal){if(r.type===JS.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),s=()=>{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==l||l(),n&&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),n&&i.play().catch(()=>{}),s=()=>{i.removeEventListener("loadedmetadata",t),i.removeEventListener("error",r)}}else b("error"),null==d||d(new Error("HLS not supported"));return()=>{s(),R()}},[e,E,n,l,d,t,o]),i(()=>{if(!S)return;if(null==s||s<=0)return;const e=t.current;if(e)try{Math.abs(e.currentTime-s)>.5&&(e.currentTime=s)}catch(e){}},[S,s,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=u(()=>{const e=h.current;e&&!g.current&&(console.log("Set auto resolution"),e.nextLevel=-1,I("auto"))},[]),_=u(()=>{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=u((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,I("auto"),n=!0)}catch(e){}};return r.on(JS.Events.FRAG_BUFFERED,s),()=>{r.off(JS.Events.FRAG_BUFFERED,s)}},[t]);return{playbackStatus:y,isReady:S,qualities:A,currentLevel:L,isAutoQuality:c(()=>"auto"===L,[L]),canSetResolution:!g.current&&JS.isSupported(),setResolution:e=>{const t=h.current;if(!t||g.current)return;if("string"==typeof e&&"auto"===e.toLowerCase())return t.currentLevel=-1,void I("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,I(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,I(n.id))},setAutoResolution:D,prewarm:C,setLowestResolution:_,startBufferBasedUpshift:O}})({file:e,videoRef:f,autoplay:o,startTime:n,enabled:o||l});return i(()=>{m()},[m]),t.useEffect(()=>{var e,t;const r=f.current;if(r)if(l)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){}},[l,p]),i(()=>{if(!l)return;g();return v(2)},[l,g,v]),t.createElement("video",{ref:f,playsInline:!0,autoPlay:o,muted:h,poster:Rt(s||""),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"}})},tT=({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," 시청")),rT=({content:e,aspectRatio:r="9/16",cursor:i="default",borderRadius:n,playback:s="hover"})=>{var a,o,l,d,c;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}=Uf(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 L=()=>{null!=p.current&&(clearTimeout(p.current),p.current=null)},I=()=>{g(!0),L(),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||(L(),p.current=window.setTimeout(()=>{f(!0)},150)))},onMouseLeave:()=>{L(),f(!1)},onMouseDown:I,onTouchStart:I},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(${Rt(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(eT,{file:k,poster:S,autoplay:"autoplay"===s,active:"autoplay"===s&&b||R&&h,visible:P,muted:!0})),!P&&t.createElement($f,null),t.createElement(tT,{view:null!==(c=null===(d=e.statistics)||void 0===d?void 0:d.pageView)&&void 0!==c?c:0}))))},iT=e=>{var r,i,n,s;const{content:a,title:o,aspectRatio:l="9/16",card:d,titleFontSize:u}=e,h=null!==(r=null==d?void 0:d.layout)&&void 0!==r?r:"slider",f=null!==(i=null==d?void 0:d.sliderPerView)&&void 0!==i?i:3,p=null!==(n=null==d?void 0:d.gridColumns)&&void 0!==n?n:3,m=null!==(s=null==d?void 0:d.gap)&&void 0!==s?s:12,g=null==d?void 0:d.width,v=g?"auto":f,y=c(()=>({fontSize:u?`${u}px`:void 0,fontWeight:600}),[u]),{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(Qs,{key:`${v}-${null!=g?g:""}-${m}`,slidesPerView:v,spaceBetween:m},a.map(r=>{var i,n;return t.createElement(Zs,{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!==Ff.READY?t.createElement(rT,{content:r,aspectRatio:l,cursor:"pointer",borderRadius:null==d?void 0:d.borderRadius,playback:e.playback}):t.createElement(zf,{content:r,aspectRatio:l,cursor:"pointer",borderRadius:null==d?void 0:d.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!==Ff.READY?t.createElement(rT,{content:r,aspectRatio:l,cursor:"pointer",borderRadius:null==d?void 0:d.borderRadius,playback:e.playback}):t.createElement(zf,{content:r,aspectRatio:l,cursor:"pointer",borderRadius:null==d?void 0:d.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},nT=({content:e})=>{const r=t.useMemo(()=>qe(e.start).tz("Asia/Seoul").format("M월 D일 A HH:mm"),[e.start]),i=e.eventStatus!==Ff.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"}},"라이브 입장하기"))},sT=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:d}=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:`${d}/live/${n.eventId}`,target:"_blank",rel:"noopener noreferrer",style:l?{width:`${l}px`}:void 0},t.createElement(zf,{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:`${d}/live/${n.eventId}`,target:"_blank",rel:"noopener noreferrer",style:l?{width:`${l}px`}:void 0},t.createElement(zf,{content:n,aspectRatio:s,borderRadius:o,cursor:"pointer"}))),t.createElement(nT,{content:n})):t.createElement(t.Fragment,null,t.createElement(nT,{content:n}),t.createElement("div",{className:"flex-1"},t.createElement("a",{href:`${d}/live/${n.eventId}`,target:"_blank",rel:"noopener noreferrer",style:l?{width:`${l}px`}:void 0},t.createElement(zf,{content:n,aspectRatio:s,borderRadius:o,cursor:"pointer"})))))},aT=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 oT(t){var{className:r}=t,i=T(t,["className"]);return e.createElement("div",Object.assign({className:wt("animate-pulse rounded-md bg-gray-200",r)},i))}const lT=e=>{var r,i,n,s,a,o,l,d,c;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!==(d=null==p?void 0:p.paddingLeft)&&void 0!==d?d:0,x=null!==(c=null==p?void 0:p.paddingRight)&&void 0!==c?c:0,A="ONE"===f&&"past"!==e.liveType,k=A?1:(null==u?void 0:u.visibleCount)||6,L=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(oT,{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:L}).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(oT,{style:{aspectRatio:h,borderRadius:E,width:"100%"}}),t.createElement(oT,{className:"h-3.5 w-4/5"})))))},dT=e=>{var r,i,n,s;const{widgetType:a,theme:o,layout:l}=e,d=Nf(e=>e.liveWidget),c=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===d?t.createElement(lT,Object.assign({},e)):0===d.length?t.createElement(aT,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:c,paddingBottom:u,paddingLeft:h,paddingRight:f}},"ONE"===a&&"past"!==e.liveType?t.createElement(sT,Object.assign({content:d[0]},e)):t.createElement(iT,Object.assign({content:d},e)))},cT=e=>{const r=Nf(e=>e.liveWidget),n=Nf(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 Ca(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(Er.div,{className:"w-full h-full"},t.createElement(Sc,null),t.createElement(dT,Object.assign({},e)))},uT=e=>t.createElement(Mf,null,t.createElement(cT,Object.assign({},e))),hT=({eventId:e})=>{const[r,i]=a(!1),{PLAYER_BASE_URL:n}=gt();if(r)return null;const{w:s,h:o,left:l,top:d}=(()=>{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(Pf,{minWidth:240,lockAspectRatio:9/17.05,style:{zIndex:99999},default:{width:240,height:455,x:l+s-240-50,y:d+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(Dr,{size:16,color:"#888"}),t.createElement("button",{className:"cursor-pointer",style:{color:"#ccc",lineHeight:0},onClick:()=>i(!0),"aria-label":"Close"},t.createElement(Br,{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"})))},fT=({eventId:e})=>e?t.createElement(Er.div,{style:{position:"fixed",inset:0,pointerEvents:"none",zIndex:99999}},t.createElement(Sc,null),t.createElement("div",{style:{pointerEvents:"auto"}},t.createElement(hT,{eventId:e}))):null;export{Dh as CollectionShowcase,_f as FloatingPlayer,fT as LiveFloatingPlayer,uT as LiveWidget,Lc as PreviewPlayer,kc as ShoppingPlayer,Dt as ViewPlayer,Rh as WidgetPlayer,mt as configure};