1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/AdminLoginPage-Baf5BaEO.js","assets/CbrandsUSA_1766267697192-Dp2hdtod.js","assets/building-2-CD0bocuh.js","assets/AdminDashboardPage-BFsd-QSt.js","assets/InventorySection-y0D8San4.js","assets/sparkles-D4S8l1IF.js","assets/info-D6iFhjfR.js","assets/trophy-DvpJRm65.js","assets/log-out-m8U8dBw3.js","assets/LoungeInventoryPage-DbG5a6GG.js","assets/LoungeMenuPage-CDNTa4wW.js","assets/VendorPortalPage-Dg7f_w8c.js","assets/camera-BFVpH-Xr.js","assets/BusinessPage-C3uS2onk.js","assets/music-2-BdQAzMM6.js","assets/LaunchpadPage-D-WOgt2A.js","assets/GuestProfilePage-bHMpfVUN.js"])))=>i.map(i=>d[i]); 2function MO(n,e){for(var t=0;t<e.length;t++){const s=e[t];if(typeof s!="string"&&!Array.isArray(s)){for(const r in s)if(r!=="default"&&!(r in n)){const i=Object.getOwnPropertyDescriptor(s,r);i&&Object.defineProperty(n,r,i.get?i:{enumerable:!0,get:()=>s[r]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))s(r);new MutationObserver(r=>{for(const i of r)if(i.type==="childList")for(const a of i.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&s(a)}).observe(document,{childList:!0,subtree:!0});function t(r){const i={};return r.integrity&&(i.integrity=r.integrity),r.referrerPolicy&&(i.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?i.credentials="include":r.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function s(r){if(r.ep)return;r.ep=!0;const i=t(r);fetch(r.href,i)}})();const FO="modulepreload",UO=function(n){return"/"+n},K3={},ps=function(e,t,s){let r=Promise.resolve();if(t&&t.length>0){let c=function(d){return Promise.all(d.map(h=>Promise.resolve(h).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),l=a?.nonce||a?.getAttribute("nonce");r=c(t.map(d=>{if(d=UO(d),d in K3)return;K3[d]=!0;const h=d.endsWith(".css"),p=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${p}`))return;const m=document.createElement("link");if(m.rel=h?"stylesheet":FO,h||(m.as="script"),m.crossOrigin="",m.href=d,l&&m.setAttribute("nonce",l),document.head.appendChild(m),h)return new Promise((y,x)=>{m.addEventListener("load",y),m.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${d}`)))})}))}function i(a){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=a,window.dispatchEvent(l),!l.defaultPrevented)throw a}return r.then(a=>{for(const l of a||[])l.status==="rejected"&&i(l.reason);return e().catch(i)})};function x7(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var N2={exports:{}},rp={},L2={exports:{}},Jt={};var q3;function VO(){if(q3)return Jt;q3=1;var n=Symbol.for("react.element"),e=Symbol.for("react.portal"),t=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),a=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),p=Symbol.iterator;function m(H){return H===null||typeof H!="object"?null:(H=p&&H[p]||H["@@iterator"],typeof H=="function"?H:null)}var y={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},x=Object.assign,w={};function S(H,K,pe){this.props=H,this.context=K,this.refs=w,this.updater=pe||y}S.prototype.isReactComponent={},S.prototype.setState=function(H,K){if(typeof H!="object"&&typeof H!="function"&&H!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,H,K,"setState")},S.prototype.forceUpdate=function(H){this.updater.enqueueForceUpdate(this,H,"forceUpdate")};function _(){}_.prototype=S.prototype;function L(H,K,pe){this.props=H,this.context=K,this.refs=w,this.updater=pe||y}var R=L.prototype=new _;R.constructor=L,x(R,S.prototype),R.isPureReactComponent=!0;var M=Array.isArray,V=Object.prototype.hasOwnProperty,W={current:null},I={key:!0,ref:!0,__self:!0,__source:!0};
vendor: 7,650 bytes, line 2
2function k(H,K,pe){var Fe,_e={},ze=null,Ye=null;if(K!=null)for(Fe in K.ref!==void 0&&(Ye=K.ref),K.key!==void 0&&(ze=""+K.key),K)V.call(K,Fe)&&!I.hasOwnProperty(Fe)&&(_e[Fe]=K[Fe]);var tt=arguments.length-2;if(tt===1)_e.children=pe;else if(1<tt){for(var lt=Array(tt),ut=0;ut<tt;ut++)lt[ut]=arguments[ut+2];_e.children=lt}if(H&&H.defaultProps)for(Fe in tt=H.defaultProps,tt)_e[Fe]===void 0&&(_e[Fe]=tt[Fe]);return{$$typeof:n,type:H,key:ze,ref:Ye,props:_e,_owner:W.current}}function P(H,K){return{$$typeof:n,type:H.type,key:K,ref:H.ref,props:H.props,_owner:H._owner}}function N(H){return typeof H=="object"&&H!==null&&H.$$typeof===n}function F(H){var K={"=":"=0",":":"=2"};return"$"+H.replace(/[=:]/g,function(pe){return K[pe]})}var z=/\/+/g;function U(H,K){return typeof H=="object"&&H!==null&&H.key!=null?F(""+H.key):K.toString(36)}function fe(H,K,pe,Fe,_e){var ze=typeof H;(ze==="undefined"||ze==="boolean")&&(H=null);var Ye=!1;if(H===null)Ye=!0;else switch(ze){case"string":case"number":Ye=!0;break;case"object":switch(H.$$typeof){case n:case e:Ye=!0}}if(Ye)return Ye=H,_e=_e(Ye),H=Fe===""?"."+U(Ye,0):Fe,M(_e)?(pe="",H!=null&&(pe=H.replace(z,"$&/")+"/"),fe(_e,K,pe,"",function(ut){return ut})):_e!=null&&(N(_e)&&(_e=P(_e,pe+(!_e.key||Ye&&Ye.key===_e.key?"":(""+_e.key).replace(z,"$&/")+"/")+H)),K.push(_e)),1;if(Ye=0,Fe=Fe===""?".":Fe+":",M(H))for(var tt=0;tt<H.length;tt++){ze=H[tt];var lt=Fe+U(ze,tt);Ye+=fe(ze,K,pe,lt,_e)}else if(lt=m(H),typeof lt=="function")for(H=lt.call(H),tt=0;!(ze=H.next()).done;)ze=ze.value,lt=Fe+U(ze,tt++),Ye+=fe(ze,K,pe,lt,_e);else if(ze==="object")throw K=String(H),Error("Objects are not valid as a React child (found: "+(K==="[object Object]"?"object with keys {"+Object.keys(H).join(", ")+"}":K)+"). If you meant to render a collection of children, use an array instead.");return Ye}function oe(H,K,pe){if(H==null)return H;var Fe=[],_e=0;return fe(H,Fe,"","",function(ze){return K.call(pe,ze,_e++)}),Fe}function X(H){if(H._status===-1){var K=H._result;K=K(),K.then(function(pe){(H._status===0||H._status===-1)&&(H._status=1,H._result=pe)},function(pe){(H._status===0||H._status===-1)&&(H._status=2,H._result=pe)}),H._status===-1&&(H._status=0,H._result=K)}if(H._status===1)return H._result.default;throw H._result}var Q={current:null},G={transition:null},Y={ReactCurrentDispatcher:Q,ReactCurrentBatchConfig:G,ReactCurrentOwner:W};function ee(){throw Error("act(...) is not supported in production builds of React.")}return Jt.Children={map:oe,forEach:function(H,K,pe){oe(H,function(){K.apply(this,arguments)},pe)},count:function(H){var K=0;return oe(H,function(){K++}),K},toArray:function(H){return oe(H,function(K){return K})||[]},only:function(H){if(!N(H))throw Error("React.Children.only expected to receive a single React element child.");return H}},Jt.Component=S,Jt.Fragment=t,Jt.Profiler=r,Jt.PureComponent=L,Jt.StrictMode=s,Jt.Suspense=c,Jt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Y,Jt.act=ee,Jt.cloneElement=function(H,K,pe){if(H==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+H+".");var Fe=x({},H.props),_e=H.key,ze=H.ref,Ye=H._owner;if(K!=null){if(K.ref!==void 0&&(ze=K.ref,Ye=W.current),K.key!==void 0&&(_e=""+K.key),H.type&&H.type.defaultProps)var tt=H.type.defaultProps;for(lt in K)V.call(K,lt)&&!I.hasOwnProperty(lt)&&(Fe[lt]=K[lt]===void 0&&tt!==void 0?tt[lt]:K[lt])}var lt=arguments.length-2;if(lt===1)Fe.children=pe;else if(1<lt){tt=Array(lt);for(var ut=0;ut<lt;ut++)tt[ut]=arguments[ut+2];Fe.children=tt}return{$$typeof:n,type:H.type,key:_e,ref:ze,props:Fe,_owner:Ye}},Jt.createContext=function(H){return H={$$typeof:a,_currentValue:H,_currentValue2:H,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},H.Provider={$$typeof:i,_context:H},H.Consumer=H},Jt.createElement=k,Jt.createFactory=function(H){var K=k.bind(null,H);return K.type=H,K},Jt.createRef=function(){return{current:null}},Jt.forwardRef=function(H){return{$$typeof:l,render:H}},Jt.isValidElement=N,Jt.lazy=function(H){return{$$typeof:h,_payload:{_status:-1,_result:H},_init:X}},Jt.memo=function(H,K){return{$$typeof:d,type:H,compare:K===void 0?null:K}},Jt.startTransition=function(H){var K=G.transition;G.transition={};try{H()}finally{G.transition=K}},Jt.unstable_act=ee,Jt.useCallback=function(H,K){return Q.current.useCallback(H,K)},Jt.useContext=function(H){return Q.current.useContext(H)},Jt.useDebugValue=function(){},Jt.useDeferredValue=function(H){return Q.current.useDeferredValue(H)},Jt.useEffect=function(H,K){return Q.current.useEffect(H,K)},Jt.useId=function(){return Q.current.useId()},Jt.useImperativeHandle=function(H,K,pe){return Q.current.useImperativeHandle(H,K,pe)},Jt.useInsertionEffect=function(H,K){return Q.current.useInsertionEffect(H,K)},Jt.useLayoutEffect=function(H,K){return Q.current.useLayoutEffect(H,K)},Jt.useMemo=function(H,K){return Q.current.useMemo(H,K)},Jt.useReducer=function(H,K,pe){return Q.current.useReducer(H,K,pe)},Jt.useRef=function(H){return Q.current.useRef(H)},Jt.useState=function(H){return Q.current.useState(H)},Jt.useSyncExternalStore=function(H,K,pe){return Q.current.useSyncExternalStore(H,K,pe)},Jt.useTransition=function(){return Q.current.useTransition()},Jt.version="18.3.1",Jt}var Y3;function nx(){return Y3||(Y3=1,L2.exports=VO()),L2.exports}var Q3;function BO(){if(Q3)return rp;Q3=1;var n=nx(),e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,r=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function a(l,c,d){var h,p={},m=null,y=null;d!==void 0&&(m=""+d),c.key!==void 0&&(m=""+c.key),c.ref!==void 0&&(y=c.ref);for(h in c)s.call(c,h)&&!i.hasOwnProperty(h)&&(p[h]=c[h]);if(l&&l.defaultProps)for(h in c=l.defaultProps,c)p[h]===void 0&&(p[h]=c[h]);return{$$typeof:e,type:l,key:m,ref:y,props:p,_owner:r.current}}return rp.Fragment=t,rp.jsx=a,rp.jsxs=a,rp}var X3;function zO(){return X3||(X3=1,N2.exports=BO()),N2.exports}var o=zO(),T=nx();const Tn=x7(T),$O=MO({__proto__:null,default:Tn},[T]);var Ug={},D2={exports:{}},xi={},j2={exports:{}},O2={};var J3;function HO(){return J3||(J3=1,(function(n){function e(G,Y){var ee=G.length;G.push(Y);e:for(;0<ee;){var H=ee-1>>>1,K=G[H];if(0<r(K,Y))G[H]=Y,G[ee]=K,ee=H;else break e}}function t(G){return G.length===0?null:G[0]}function s(G){if(G.length===0)return null;var Y=G[0],ee=G.pop();if(ee!==Y){G[0]=ee;e:for(var H=0,K=G.length,pe=K>>>1;H<pe;){var Fe=2*(H+1)-1,_e=G[Fe],ze=Fe+1,Ye=G[ze];if(0>r(_e,ee))ze<K&&0>r(Ye,_e)?(G[H]=Ye,G[ze]=ee,H=ze):(G[H]=_e,G[Fe]=ee,H=Fe);else if(ze<K&&0>r(Ye,ee))G[H]=Ye,G[ze]=ee,H=ze;else break e}}return Y}function r(G,Y){var ee=G.sortIndex-Y.sortIndex;return ee!==0?ee:G.id-Y.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;n.unstable_now=function(){return i.now()}}else{var a=Date,l=a.now();n.unstable_now=function(){return a.now()-l}}var c=[],d=[],h=1,p=null,m=3,y=!1,x=!1,w=!1,S=typeof setTimeout=="function"?setTimeout:null,_=typeof clearTimeout=="function"?clearTimeout:null,L=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function R(G){for(var Y=t(d);Y!==null;){if(Y.callback===null)s(d);else if(Y.startTime<=G)s(d),Y.sortIndex=Y.expirationTime,e(c,Y);else break;Y=t(d)}}function M(G){if(w=!1,R(G),!x)if(t(c)!==null)x=!0,X(V);else{var Y=t(d);Y!==null&&Q(M,Y.startTime-G)}}function V(G,Y){x=!1,w&&(w=!1,_(k),k=-1),y=!0;var ee=m;try{for(R(Y),p=t(c);p!==null&&(!(p.expirationTime>Y)||G&&!F());
vendor: 47,797 bytes, lines 2-7
2){var H=p.callback;if(typeof H=="function"){p.callback=null,m=p.priorityLevel;var K=H(p.expirationTime<=Y);Y=n.unstable_now(),typeof K=="function"?p.callback=K:p===t(c)&&s(c),R(Y)}else s(c);p=t(c)}if(p!==null)var pe=!0;else{var Fe=t(d);Fe!==null&&Q(M,Fe.startTime-Y),pe=!1}return pe}finally{p=null,m=ee,y=!1}}var W=!1,I=null,k=-1,P=5,N=-1;function F(){return!(n.unstable_now()-N<P)}function z(){if(I!==null){var G=n.unstable_now();N=G;var Y=!0;try{Y=I(!0,G)}finally{Y?U():(W=!1,I=null)}}else W=!1}var U;if(typeof L=="function")U=function(){L(z)};else if(typeof MessageChannel<"u"){var fe=new MessageChannel,oe=fe.port2;fe.port1.onmessage=z,U=function(){oe.postMessage(null)}}else U=function(){S(z,0)};function X(G){I=G,W||(W=!0,U())}function Q(G,Y){k=S(function(){G(n.unstable_now())},Y)}n.unstable_IdlePriority=5,n.unstable_ImmediatePriority=1,n.unstable_LowPriority=4,n.unstable_NormalPriority=3,n.unstable_Profiling=null,n.unstable_UserBlockingPriority=2,n.unstable_cancelCallback=function(G){G.callback=null},n.unstable_continueExecution=function(){x||y||(x=!0,X(V))},n.unstable_forceFrameRate=function(G){0>G||125<G||(P=0<G?Math.floor(1e3/G):5)},n.unstable_getCurrentPriorityLevel=function(){return m},n.unstable_getFirstCallbackNode=function(){return t(c)},n.unstable_next=function(G){switch(m){case 1:case 2:case 3:var Y=3;break;default:Y=m}var ee=m;m=Y;try{return G()}finally{m=ee}},n.unstable_pauseExecution=function(){},n.unstable_requestPaint=function(){},n.unstable_runWithPriority=function(G,Y){switch(G){case 1:case 2:case 3:case 4:case 5:break;default:G=3}var ee=m;m=G;try{return Y()}finally{m=ee}},n.unstable_scheduleCallback=function(G,Y,ee){var H=n.unstable_now();switch(typeof ee=="object"&&ee!==null?(ee=ee.delay,ee=typeof ee=="number"&&0<ee?H+ee:H):ee=H,G){case 1:var K=-1;break;case 2:K=250;break;case 5:K=1073741823;break;case 4:K=1e4;break;default:K=5e3}return K=ee+K,G={id:h++,callback:Y,priorityLevel:G,startTime:ee,expirationTime:K,sortIndex:-1},ee>H?(G.sortIndex=ee,e(d,G),t(c)===null&&G===t(d)&&(w?(_(k),k=-1):w=!0,Q(M,ee-H))):(G.sortIndex=K,e(c,G),x||y||(x=!0,X(V))),G},n.unstable_shouldYield=F,n.unstable_wrapCallback=function(G){var Y=m;return function(){var ee=m;m=Y;try{return G.apply(this,arguments)}finally{m=ee}}}})(O2)),O2}var Z3;function WO(){return Z3||(Z3=1,j2.exports=HO()),j2.exports}var eT;function GO(){if(eT)return xi;eT=1;var n=nx(),e=WO();function t(u){for(var f="https://reactjs.org/docs/error-decoder.html?invariant="+u,g=1;g<arguments.length;g++)f+="&args[]="+encodeURIComponent(arguments[g]);return"Minified React error #"+u+"; visit "+f+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var s=new Set,r={};function i(u,f){a(u,f),a(u+"Capture",f)}function a(u,f){for(r[u]=f,u=0;u<f.length;u++)s.add(f[u])}var l=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),c=Object.prototype.hasOwnProperty,d=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,h={},p={};function m(u){return c.call(p,u)?!0:c.call(h,u)?!1:d.test(u)?p[u]=!0:(h[u]=!0,!1)}function y(u,f,g,b){if(g!==null&&g.type===0)return!1;switch(typeof f){case"function":case"symbol":return!0;case"boolean":return b?!1:g!==null?!g.acceptsBooleans:(u=u.toLowerCase().slice(0,5),u!=="data-"&&u!=="aria-");default:return!1}}function x(u,f,g,b){if(f===null||typeof f>"u"||y(u,f,g,b))return!0;if(b)return!1;if(g!==null)switch(g.type){case 3:return!f;case 4:return f===!1;case 5:return isNaN(f);case 6:return isNaN(f)||1>f}return!1}function w(u,f,g,b,E,C,B){this.acceptsBooleans=f===2||f===3||f===4,this.attributeName=b,this.attributeNamespace=E,this.mustUseProperty=g,this.propertyName=u,this.type=f,this.sanitizeURL=C,this.removeEmptyString=B}var S={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(u){S[u]=new w(u,0,!1,u,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(u){var f=u[0];S[f]=new w(f,1,!1,u[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(u){S[u]=new w(u,2,!1,u.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(u){S[u]=new w(u,2,!1,u,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(u){S[u]=new w(u,3,!1,u.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(u){S[u]=new w(u,3,!0,u,null,!1,!1)}),["capture","download"].forEach(function(u){S[u]=new w(u,4,!1,u,null,!1,!1)}),["cols","rows","size","span"].forEach(function(u){S[u]=new w(u,6,!1,u,null,!1,!1)}),["rowSpan","start"].forEach(function(u){S[u]=new w(u,5,!1,u.toLowerCase(),null,!1,!1)});var _=/[\-:]([a-z])/g;function L(u){return u[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(u){var f=u.replace(_,L);S[f]=new w(f,1,!1,u,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(u){var f=u.replace(_,L);S[f]=new w(f,1,!1,u,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(u){var f=u.replace(_,L);S[f]=new w(f,1,!1,u,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(u){S[u]=new w(u,1,!1,u.toLowerCase(),null,!1,!1)}),S.xlinkHref=new w("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(u){S[u]=new w(u,1,!1,u.toLowerCase(),null,!0,!0)});function R(u,f,g,b){var E=S.hasOwnProperty(f)?S[f]:null;(E!==null?E.type!==0:b||!(2<f.length)||f[0]!=="o"&&f[0]!=="O"||f[1]!=="n"&&f[1]!=="N")&&(x(f,g,E,b)&&(g=null),b||E===null?m(f)&&(g===null?u.removeAttribute(f):u.setAttribute(f,""+g)):E.mustUseProperty?u[E.propertyName]=g===null?E.type===3?!1:"":g:(f=E.attributeName,b=E.attributeNamespace,g===null?u.removeAttribute(f):(E=E.type,g=E===3||E===4&&g===!0?"":""+g,b?u.setAttributeNS(b,f,g):u.setAttribute(f,g))))}var M=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,V=Symbol.for("react.element"),W=Symbol.for("react.portal"),I=Symbol.for("react.fragment"),k=Symbol.for("react.strict_mode"),P=Symbol.for("react.profiler"),N=Symbol.for("react.provider"),F=Symbol.for("react.context"),z=Symbol.for("react.forward_ref"),U=Symbol.for("react.suspense"),fe=Symbol.for("react.suspense_list"),oe=Symbol.for("react.memo"),X=Symbol.for("react.lazy"),Q=Symbol.for("react.offscreen"),G=Symbol.iterator;function Y(u){return u===null||typeof u!="object"?null:(u=G&&u[G]||u["@@iterator"],typeof u=="function"?u:null)}var ee=Object.assign,H;function K(u){if(H===void 0)try{throw Error()}catch(g){var f=g.stack.trim().match(/\n( *(at )?)/);H=f&&f[1]||""}return` 3`+H+u}var pe=!1;function Fe(u,f){if(!u||pe)return"";pe=!0;var g=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(f)if(f=function(){throw Error()},Object.defineProperty(f.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(f,[])}catch(be){var b=be}Reflect.construct(u,[],f)}else{try{f.call()}catch(be){b=be}u.call(f.prototype)}else{try{throw Error()}catch(be){b=be}u()}}catch(be){if(be&&b&&typeof be.stack=="string"){for(var E=be.stack.split(` 4`),C=b.stack.split(` 5`),B=E.length-1,Z=C.length-1;1<=B&&0<=Z&&E[B]!==C[Z];)Z--;for(;1<=B&&0<=Z;B--,Z--)if(E[B]!==C[Z]){if(B!==1||Z!==1)do if(B--,Z--,0>Z||E[B]!==C[Z]){var re=` 6`+E[B].replace(" at new "," at ");return u.displayName&&re.includes("<anonymous>")&&(re=re.replace("<anonymous>",u.displayName)),re}while(1<=B&&0<=Z);break}}}finally{pe=!1,Error.prepareStackTrace=g}return(u=u?u.displayName||u.name:"")?K(u):""}function _e(u){switch(u.tag){case 5:return K(u.type);case 16:return K("Lazy");case 13:return K("Suspense");case 19:return K("SuspenseList");case 0:case 2:case 15:return u=Fe(u.type,!1),u;case 11:return u=Fe(u.type.render,!1),u;case 1:return u=Fe(u.type,!0),u;default:return""}}function ze(u){if(u==null)return null;if(typeof u=="function")return u.displayName||u.name||null;if(typeof u=="string")return u;switch(u){case I:return"Fragment";case W:return"Portal";case P:return"Profiler";case k:return"StrictMode";case U:return"Suspense";case fe:return"SuspenseList"}if(typeof u=="object")switch(u.$$typeof){case F:return(u.displayName||"Context")+".Consumer";case N:return(u._context.displayName||"Context")+".Provider";case z:var f=u.render;return u=u.displayName,u||(u=f.displayName||f.name||"",u=u!==""?"ForwardRef("+u+")":"ForwardRef"),u;case oe:return f=u.displayName||null,f!==null?f:ze(u.type)||"Memo";case X:f=u._payload,u=u._init;try{return ze(u(f))}catch{}}return null}function Ye(u){var f=u.type;switch(u.tag){case 24:return"Cache";case 9:return(f.displayName||"Context")+".Consumer";case 10:return(f._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return u=f.render,u=u.displayName||u.name||"",f.displayName||(u!==""?"ForwardRef("+u+")":"ForwardRef");case 7:return"Fragment";case 5:return f;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return ze(f);case 8:return f===k?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof f=="function")return f.displayName||f.name||null;if(typeof f=="string")return f}return null}function tt(u){switch(typeof u){case"boolean":case"number":case"string":case"undefined":return u;case"object":return u;default:return""}}function lt(u){var f=u.type;return(u=u.nodeName)&&u.toLowerCase()==="input"&&(f==="checkbox"||f==="radio")}function ut(u){var f=lt(u)?"checked":"value",g=Object.getOwnPropertyDescriptor(u.constructor.prototype,f),b=""+u[f];if(!u.hasOwnProperty(f)&&typeof g<"u"&&typeof g.get=="function"&&typeof g.set=="function"){var E=g.get,C=g.set;return Object.defineProperty(u,f,{configurable:!0,get:function(){return E.call(this)},set:function(B){b=""+B,C.call(this,B)}}),Object.defineProperty(u,f,{enumerable:g.enumerable}),{getValue:function(){return b},setValue:function(B){b=""+B},stopTracking:function(){u._valueTracker=null,delete u[f]}}}}function cn(u){u._valueTracker||(u._valueTracker=ut(u))}function ke(u){if(!u)return!1;var f=u._valueTracker;if(!f)return!0;var g=f.getValue(),b="";return u&&(b=lt(u)?u.checked?"true":"false":u.value),u=b,u!==g?(f.setValue(u),!0):!1}function Ue(u){if(u=u||(typeof document<"u"?document:void 0),typeof u>"u")return null;try{return u.activeElement||u.body}catch{return u.body}}function rt(u,f){var g=f.checked;return ee({},f,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:g??u._wrapperState.initialChecked})}function Ct(u,f){var g=f.defaultValue==null?"":f.defaultValue,b=f.checked!=null?f.checked:f.defaultChecked;g=tt(f.value!=null?f.value:g),u._wrapperState={initialChecked:b,initialValue:g,controlled:f.type==="checkbox"||f.type==="radio"?f.checked!=null:f.value!=null}}function at(u,f){f=f.checked,f!=null&&R(u,"checked",f,!1)}function ft(u,f){at(u,f);var g=tt(f.value),b=f.type;if(g!=null)b==="number"?(g===0&&u.value===""||u.value!=g)&&(u.value=""+g):u.value!==""+g&&(u.value=""+g);else if(b==="submit"||b==="reset"){u.removeAttribute("value");return}f.hasOwnProperty("value")?At(u,f.type,g):f.hasOwnProperty("defaultValue")&&At(u,f.type,tt(f.defaultValue)),f.checked==null&&f.defaultChecked!=null&&(u.defaultChecked=!!f.defaultChecked)}function Nt(u,f,g){if(f.hasOwnProperty("value")||f.hasOwnProperty("defaultValue")){var b=f.type;if(!(b!=="submit"&&b!=="reset"||f.value!==void 0&&f.value!==null))return;f=""+u._wrapperState.initialValue,g||f===u.value||(u.value=f),u.defaultValue=f}g=u.name,g!==""&&(u.name=""),u.defaultChecked=!!u._wrapperState.initialChecked,g!==""&&(u.name=g)}function At(u,f,g){(f!=="number"||Ue(u.ownerDocument)!==u)&&(g==null?u.defaultValue=""+u._wrapperState.initialValue:u.defaultValue!==""+g&&(u.defaultValue=""+g))}var ot=Array.isArray;function Yt(u,f,g,b){if(u=u.options,f){f={};for(var E=0;E<g.length;E++)f["$"+g[E]]=!0;for(g=0;g<u.length;g++)E=f.hasOwnProperty("$"+u[g].value),u[g].selected!==E&&(u[g].selected=E),E&&b&&(u[g].defaultSelected=!0)}else{for(g=""+tt(g),f=null,E=0;E<u.length;E++){if(u[E].value===g){u[E].selected=!0,b&&(u[E].defaultSelected=!0);return}f!==null||u[E].disabled||(f=u[E])}f!==null&&(f.selected=!0)}}function zt(u,f){if(f.dangerouslySetInnerHTML!=null)throw Error(t(91));return ee({},f,{value:void 0,defaultValue:void 0,children:""+u._wrapperState.initialValue})}function wn(u,f){var g=f.value;if(g==null){if(g=f.children,f=f.defaultValue,g!=null){if(f!=null)throw Error(t(92));if(ot(g)){if(1<g.length)throw Error(t(93));g=g[0]}f=g}f==null&&(f=""),g=f}u._wrapperState={initialValue:tt(g)}}function Dt(u,f){var g=tt(f.value),b=tt(f.defaultValue);g!=null&&(g=""+g,g!==u.value&&(u.value=g),f.defaultValue==null&&u.defaultValue!==g&&(u.defaultValue=g)),b!=null&&(u.defaultValue=""+b)}function Ee(u){var f=u.textContent;f===u._wrapperState.initialValue&&f!==""&&f!==null&&(u.value=f)}function He(u){switch(u){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function le(u,f){return u==null||u==="http://www.w3.org/1999/xhtml"?He(f):u==="http://www.w3.org/2000/svg"&&f==="foreignObject"?"http://www.w3.org/1999/xhtml":u}var ne,J=(function(u){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(f,g,b,E){MSApp.execUnsafeLocalFunction(function(){return u(f,g,b,E)})}:u})(function(u,f){if(u.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in u)u.innerHTML=f;else{for(ne=ne||document.createElement("div"),ne.innerHTML="<svg>"+f.valueOf().toString()+"</svg>",f=ne.firstChild;u.firstChild;)u.removeChild(u.firstChild);for(;f.firstChild;)u.appendChild(f.firstChild)}});function De(u,f){if(f){var g=u.firstChild;if(g&&g===u.lastChild&&g.nodeType===3){g.nodeValue=f;return}}u.textContent=f}var Le={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Lt=["Webkit","ms","Moz","O"];Object.keys(Le).forEach(function(u){Lt.forEach(function(f){f=f+u.charAt(0).toUpperCase()+u.substring(1),Le[f]=Le[u]})});function Qe(u,f,g){return f==null||typeof f=="boolean"||f===""?"":g||typeof f!="number"||f===0||Le.hasOwnProperty(u)&&Le[u]?(""+f).trim():f+"px"}function it(u,f){u=u.style;for(var g in f)if(f.hasOwnProperty(g)){var b=g.indexOf("--")===0,E=Qe(g,f[g],b);g==="float"&&(g="cssFloat"),b?u.setProperty(g,E):u[g]=E}}var Cn=ee({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Mn(u,f){if(f){if(Cn[u]&&(f.children!=null||f.dangerouslySetInnerHTML!=null))throw Error(t(137,u));if(f.dangerouslySetInnerHTML!=null){if(f.children!=null)throw Error(t(60));if(typeof f.dangerouslySetInnerHTML!="object"||!("__html"in f.dangerouslySetInnerHTML))throw Error(t(61))}if(f.style!=null&&typeof f.style!="object")throw Error(t(62))}}function Gn(u,f){if(u.indexOf("-")===-1)return typeof f.is=="string";switch(u){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var ii=null;function ai(u){return u=u.target||u.srcElement||window,u.correspondingUseElement&&(u=u.correspondingUseElement),u.nodeType===3?u.parentNode:u}var Fs=null,os=null,vn=null;function ln(u){if(u=$f(u)){if(typeof Fs!="function")throw Error(t(280));var f=u.stateNode;f&&(f=eg(f),Fs(u.stateNode,u.type,f))}}function Qs(u){os?vn?vn.push(u):vn=[u]:os=u}function Tr(){if(os){var u=os,f=vn;if(vn=os=null,ln(u),f)for(u=0;u<f.length;u++)ln(f[u])}}function hr(u,f){return u(f)}function Na(){}var Xs=!1;function oi(u,f,g){if(Xs)return u(f,g);Xs=!0;try{return hr(u,f,g)}finally{Xs=!1,(os!==null||vn!==null)&&(Na(),Tr())}}function _r(u,f){var g=u.stateNode;if(g===null)return null;var b=eg(g);if(b===null)return null;g=b[f];e:switch(f){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(b=!b.disabled)||(u=u.type,b=!(u==="button"||u==="input"||u==="select"||u==="textarea")),u=!b;break e;default:u=!1}if(u)return null;if(g&&typeof g!="function")throw Error(t(231,f,typeof g));return g}var es=!1;if(l)try{var Ir={};Object.defineProperty(Ir,"passive",{get:function(){es=!0}}),window.addEventListener("test",Ir,Ir),window.removeEventListener("test",Ir,Ir)}catch{es=!1}function Ar(u,f,g,b,E,C,B,Z,re){var be=Array.prototype.slice.call(arguments,3);try{f.apply(g,be)}catch(Ve){this.onError(Ve)}}var Re=!1,St=null,Un=!1,Vn=null,La={onError:function(u){Re=!0,St=u}};function Br(u,f,g,b,E,C,B,Z,re){Re=!1,St=null,Ar.apply(La,arguments)}function Da(u,f,g,b,E,C,B,Z,re){if(Br.apply(this,arguments),Re){if(Re){var be=St;Re=!1,St=null}else throw Error(t(198));Un||(Un=!0,Vn=be)}}function Rn(u){var f=u,g=u;if(u.alternate)for(;f.return;)f=f.return;else{u=f;do f=u,(f.flags&4098)!==0&&(g=f.return),u=f.return;while(u)}return f.tag===3?g:null}function Te(u){if(u.tag===13){var f=u.memoizedState;if(f===null&&(u=u.alternate,u!==null&&(f=u.memoizedState)),f!==null)return f.dehydrated}return null}function pt(u){if(Rn(u)!==u)throw Error(t(188))}function ys(u){var f=u.alternate;if(!f){if(f=Rn(u),f===null)throw Error(t(188));return f!==u?null:u}for(var g=u,b=f;;){var E=g.return;if(E===null)break;var C=E.alternate;if(C===null){if(b=E.return,b!==null){g=b;continue}break}if(E.child===C.child){for(C=E.child;C;){if(C===g)return pt(E),u;if(C===b)return pt(E),f;C=C.sibling}throw Error(t(188))}if(g.return!==b.return)g=E,b=C;else{for(var B=!1,Z=E.child;Z;){if(Z===g){B=!0,g=E,b=C;break}if(Z===b){B=!0,b=E,g=C;break}Z=Z.sibling}if(!B){for(Z=C.child;Z;){if(Z===g){B=!0,g=C,b=E;break}if(Z===b){B=!0,b=C,g=E;break}Z=Z.sibling}if(!B)throw Error(t(189))}}if(g.alternate!==b)throw Error(t(190))}if(g.tag!==3)throw Error(t(188));return g.stateNode.current===g?u:f}function fr(u){return u=ys(u),u!==null?zr(u):null}function zr(u){if(u.tag===5||u.tag===6)return u;for(u=u.child;u!==null;){var f=zr(u);if(f!==null)return f;u=u.sibling}return null}var ja=e.unstable_scheduleCallback,ia=e.unstable_cancelCallback,rl=e.unstable_shouldYield,Li=e.unstable_requestPaint,xn=e.unstable_now,il=e.unstable_getCurrentPriorityLevel,al=e.unstable_ImmediatePriority,Oa=e.unstable_UserBlockingPriority,go=e.unstable_NormalPriority,tc=e.unstable_LowPriority,ol=e.unstable_IdlePriority,xo=null,Sn=null;function Ma(u){if(Sn&&typeof Sn.onCommitFiberRoot=="function")try{Sn.onCommitFiberRoot(xo,u,void 0,(u.current.flags&128)===128)}catch{}}var As=Math.clz32?Math.clz32:Fa,$r=Math.log,Cr=Math.LN2;function Fa(u){return u>>>=0,u===0?32:31-($r(u)/Cr|0)|0}var li=64,Ua=4194304;function un(u){switch(u&-u){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return u&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return u&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return u}}function aa(u,f){var g=u.pendingLanes;if(g===0)return 0;var b=0,E=u.suspendedLanes,C=u.pingedLanes,B=g&268435455;if(B!==0){var Z=B&~E;Z!==0?b=un(Z):(C&=B,C!==0&&(b=un(C)))}else B=g&~E,B!==0?b=un(B):C!==0&&(b=un(C));if(b===0)return 0;if(f!==0&&f!==b&&(f&E)===0&&(E=b&-b,C=f&-f,E>=C||E===16&&(C&4194240)!==0))return f;if((b&4)!==0&&(b|=g&16),f=u.entangledLanes,f!==0)for(u=u.entanglements,f&=b;0<f;)g=31-As(f),E=1<<g,b|=u[g],f&=~E;return b}function yo(u,f){switch(u){case 1:case 2:case 4:return f+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return f+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function vo(u,f){for(var g=u.suspendedLanes,b=u.pingedLanes,E=u.expirationTimes,C=u.pendingLanes;0<C;){var B=31-As(C),Z=1<<B,re=E[B];re===-1?((Z&g)===0||(Z&b)!==0)&&(E[B]=yo(Z,f)):re<=f&&(u.expiredLanes|=Z),C&=~Z}}function Di(u){return u=u.pendingLanes&-1073741825,u!==0?u:u&1073741824?1073741824:0}function nc(){var u=li;return li<<=1,(li&4194240)===0&&(li=64),u}function sc(u){for(var f=[],g=0;31>g;g++)f.push(u);return f}function ls(u,f,g){u.pendingLanes|=f,f!==536870912&&(u.suspendedLanes=0,u.pingedLanes=0),u=u.eventTimes,f=31-As(f),u[f]=g}function Us(u,f){var g=u.pendingLanes&~f;u.pendingLanes=f,u.suspendedLanes=0,u.pingedLanes=0,u.expiredLanes&=f,u.mutableReadLanes&=f,u.entangledLanes&=f,f=u.entanglements;var b=u.eventTimes;for(u=u.expirationTimes;0<g;){var E=31-As(g),C=1<<E;f[E]=0,b[E]=-1,u[E]=-1,g&=~C}}function Hr(u,f){var g=u.entangledLanes|=f;for(u=u.entanglements;g;){var b=31-As(g),E=1<<b;E&f|u[b]&f&&(u[b]|=f),g&=~E}}var Qt=0;function Va(u){return u&=-u,1<u?4<u?(u&268435455)!==0?16:536870912:4:1}var wu,bo,rc,Su,Xt,Kn=!1,Pn=[],rn=null,Js=null,an=null,Ba=new Map,oa=new Map,Zs=[],la="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function ji(u,f){switch(u){case"focusin":case"focusout":rn=null;break;case"dragenter":case"dragleave":Js=null;break;case"mouseover":case"mouseout":an=null;break;case"pointerover":case"pointerout":Ba.delete(f.pointerId);break;case"gotpointercapture":case"lostpointercapture":oa.delete(f.pointerId)}}function er(u,f,g,b,E,C){return u===null||u.nativeEvent!==C?(u={blockedOn:f,domEventName:g,eventSystemFlags:b,nativeEvent:C,targetContainers:[E]},f!==null&&(f=$f(f),f!==null&&bo(f)),u):(u.eventSystemFlags|=b,f=u.targetContainers,E!==null&&f.indexOf(E)===-1&&f.push(E),u)}function Oi(u,f,g,b,E){switch(f){case"focusin":return rn=er(rn,u,f,g,b,E),!0;case"dragenter":return Js=er(Js,u,f,g,b,E),!0;case"mouseover":return an=er(an,u,f,g,b,E),!0;case"pointerover":var C=E.pointerId;return Ba.set(C,er(Ba.get(C)||null,u,f,g,b,E)),!0;case"gotpointercapture":return C=E.pointerId,oa.set(C,er(oa.get(C)||null,u,f,g,b,E)),!0}return!1}function Mi(u){var f=Au(u.target);if(f!==null){var g=Rn(f);if(g!==null){if(f=g.tag,f===13){if(f=Te(g),f!==null){u.blockedOn=f,Xt(u.priority,function(){rc(g)});return}}else if(f===3&&g.stateNode.current.memoizedState.isDehydrated){u.blockedOn=g.tag===3?g.stateNode.containerInfo:null;return}}}u.blockedOn=null}function En(u){if(u.blockedOn!==null)return!1;for(var f=u.targetContainers;0<f.length;){var g=wo(u.domEventName,u.eventSystemFlags,f[0],u.nativeEvent);if(g===null){g=u.nativeEvent;var b=new g.constructor(g.type,g);ii=b,g.target.dispatchEvent(b),ii=null}else return f=$f(g),f!==null&&bo(f),u.blockedOn=g,!1;f.shift()}return!0}function ic(u,f,g){En(u)&&g.delete(f)}function Fd(){Kn=!1,rn!==null&&En(rn)&&(rn=null),Js!==null&&En(Js)&&(Js=null),an!==null&&En(an)&&(an=null),Ba.forEach(ic),oa.forEach(ic)}function ca(u,f){u.blockedOn===f&&(u.blockedOn=null,Kn||(Kn=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,Fd)))}function Fi(u){function f(E){return ca(E,u)}if(0<Pn.length){ca(Pn[0],u);for(var g=1;g<Pn.length;g++){var b=Pn[g];b.blockedOn===u&&(b.blockedOn=null)}}for(rn!==null&&ca(rn,u),Js!==null&&ca(Js,u),an!==null&&ca(an,u),Ba.forEach(f),oa.forEach(f),g=0;g<Zs.length;g++)b=Zs[g],b.blockedOn===u&&(b.blockedOn=null);for(;0<Zs.length&&(g=Zs[0],g.blockedOn===null);)Mi(g),g.blockedOn===null&&Zs.shift()}var Ui=M.ReactCurrentBatchConfig,Vi=!0;function tr(u,f,g,b){var E=Qt,C=Ui.transition;Ui.transition=null;try{Qt=1,ll(u,f,g,b)}finally{Qt=E,Ui.transition=C}}function ua(u,f,g,b){var E=Qt,C=Ui.transition;Ui.transition=null;try{Qt=4,ll(u,f,g,b)}finally{Qt=E,Ui.transition=C}}function ll(u,f,g,b){if(Vi){var E=wo(u,f,g,b);if(E===null)Ey(u,f,b,ci,g),ji(u,b);else if(Oi(E,u,f,g,b))b.stopPropagation();else if(ji(u,b),f&4&&-1<la.indexOf(u)){for(;E!==null;){var C=$f(E);if(C!==null&&wu(C),C=wo(u,f,g,b),C===null&&Ey(u,f,b,ci,g),C===E)break;E=C}E!==null&&b.stopPropagation()}else Ey(u,f,b,null,g)}}var ci=null;function wo(u,f,g,b){if(ci=null,u=ai(b),u=Au(u),u!==null)if(f=Rn(u),f===null)u=null;else if(g=f.tag,g===13){if(u=Te(f),u!==null)return u;u=null}else if(g===3){if(f.stateNode.current.memoizedState.isDehydrated)return f.tag===3?f.stateNode.containerInfo:null;u=null}else f!==u&&(u=null);return ci=u,null}function da(u){switch(u){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(il()){case al:return 1;case Oa:return 4;case go:case tc:return 16;case ol:return 536870912;default:return 16}default:return 16}}var pr=null,ui=null,Wr=null;function za(){if(Wr)return Wr;var u,f=ui,g=f.length,b,E="value"in pr?pr.value:pr.textContent,C=E.length;for(u=0;u<g&&f[u]===E[u];u++);var B=g-u;for(b=1;b<=B&&f[g-b]===E[C-b];b++);return Wr=E.slice(u,1<b?1-b:void 0)}function $a(u){var f=u.keyCode;return"charCode"in u?(u=u.charCode,u===0&&f===13&&(u=13)):u=f,u===10&&(u=13),32<=u||u===13?u:0}function Bi(){return!0}function ac(){return!1}function ts(u){function f(g,b,E,C,B){this._reactName=g,this._targetInst=E,this.type=b,this.nativeEvent=C,this.target=B,this.currentTarget=null;for(var Z in u)u.hasOwnProperty(Z)&&(g=u[Z],this[Z]=g?g(C):C[Z]);return this.isDefaultPrevented=(C.defaultPrevented!=null?C.defaultPrevented:C.returnValue===!1)?Bi:ac,this.isPropagationStopped=ac,this}return ee(f.prototype,{preventDefault:function(){this.defaultPrevented=!0;var g=this.nativeEvent;g&&(g.preventDefault?g.preventDefault():typeof g.returnValue!="unknown"&&(g.returnValue=!1),this.isDefaultPrevented=Bi)},stopPropagation:function(){var g=this.nativeEvent;g&&(g.stopPropagation?g.stopPropagation():typeof g.cancelBubble!="unknown"&&(g.cancelBubble=!0),this.isPropagationStopped=Bi)},persist:function(){},isPersistent:Bi}),f}var vs={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(u){return u.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},cl=ts(vs),So=ee({},vs,{view:0,detail:0}),oc=ts(So),di,lc,bs,ul=ee({},So,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Ft,button:0,buttons:0,relatedTarget:function(u){return u.relatedTarget===void 0?u.fromElement===u.srcElement?u.toElement:u.fromElement:u.relatedTarget},movementX:function(u){return"movementX"in u?u.movementX:(u!==bs&&(bs&&u.type==="mousemove"?(di=u.screenX-bs.screenX,lc=u.screenY-bs.screenY):lc=di=0,bs=u),di)},movementY:function(u){return"movementY"in u?u.movementY:lc}}),nr=ts(ul),Ud=ee({},ul,{dataTransfer:0}),dl=ts(Ud),cc=ee({},So,{relatedTarget:0}),ws=ts(cc),uc=ee({},vs,{animationName:0,elapsedTime:0,pseudoElement:0}),Eu=ts(uc),Eo=ee({},vs,{clipboardData:function(u){return"clipboardData"in u?u.clipboardData:window.clipboardData}}),v=ts(Eo),A=ee({},vs,{data:0}),O=ts(A),$={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},ue={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},we={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Ke(u){var f=this.nativeEvent;return f.getModifierState?f.getModifierState(u):(u=we[u])?!!f[u]:!1}function Ft(){return Ke}var pn=ee({},So,{key:function(u){if(u.key){var f=$[u.key]||u.key;if(f!=="Unidentified")return f}return u.type==="keypress"?(u=$a(u),u===13?"Enter":String.fromCharCode(u)):u.type==="keydown"||u.type==="keyup"?ue[u.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Ft,charCode:function(u){return u.type==="keypress"?$a(u):0},keyCode:function(u){return u.type==="keydown"||u.type==="keyup"?u.keyCode:0},which:function(u){return u.type==="keypress"?$a(u):u.type==="keydown"||u.type==="keyup"?u.keyCode:0}}),ye=ts(pn),qn=ee({},ul,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),sr=ts(qn),Ha=ee({},So,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Ft}),ns=ts(Ha),ha=ee({},vs,{propertyName:0,elapsedTime:0,pseudoElement:0}),hl=ts(ha),Tu=ee({},ul,{deltaX:function(u){return"deltaX"in u?u.deltaX:"wheelDeltaX"in u?-u.wheelDeltaX:0},deltaY:function(u){return"deltaY"in u?u.deltaY:"wheelDeltaY"in u?-u.wheelDeltaY:"wheelDelta"in u?-u.wheelDelta:0},deltaZ:0,deltaMode:0}),jf=ts(Tu),Of=[9,13,27,32],fl=l&&"CompositionEvent"in window,To=null;l&&"documentMode"in document&&(To=document.documentMode);var Vd=l&&"TextEvent"in window&&!To,_u=l&&(!fl||To&&8<To&&11>=To),D=" ",q=!1;function se(u,f){switch(u){case"keyup":return Of.indexOf(f.keyCode)!==-1;case"keydown":return f.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function me(u){return u=u.detail,typeof u=="object"&&"data"in u?u.data:null}var xe=!1;function Be(u,f){switch(u){case"compositionend":return me(f);case"keypress":return f.which!==32?null:(q=!0,D);case"textInput":return u=f.data,u===D&&q?null:u;default:return null}}function Ne(u,f){if(xe)return u==="compositionend"||!fl&&se(u,f)?(u=za(),Wr=ui=pr=null,xe=!1,u):null;switch(u){case"paste":return null;case"keypress":if(!(f.ctrlKey||f.altKey||f.metaKey)||f.ctrlKey&&f.altKey){if(f.char&&1<f.char.length)return f.char;if(f.which)return String.fromCharCode(f.which)}return null;case"compositionend":return _u&&f.locale!=="ko"?null:f.data;default:return null}}var mt={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Ut(u){var f=u&&u.nodeName&&u.nodeName.toLowerCase();return f==="input"?!!mt[u.type]:f==="textarea"}function tn(u,f,g,b){Qs(b),f=Xm(f,"onChange"),0<f.length&&(g=new cl("onChange","change",null,g,b),u.push({event:g,listeners:f}))}var cs=null,Kt=null;function Vs(u){cE(u,0)}function zi(u){var f=qd(u);if(ke(f))return u}function $i(u,f){if(u==="change")return f}var Iu=!1;if(l){var Bd;if(l){var dc="oninput"in document;if(!dc){var fa=document.createElement("div");fa.setAttribute("oninput","return;"),dc=typeof fa.oninput=="function"}Bd=dc}else Bd=!1;Iu=Bd&&(!document.documentMode||9<document.documentMode)}function pl(){cs&&(cs.detachEvent("onpropertychange",_o),Kt=cs=null)}function _o(u){if(u.propertyName==="value"&&zi(Kt)){var f=[];tn(f,Kt,u,ai(u)),oi(Vs,f)}}function zd(u,f,g){u==="focusin"?(pl(),cs=f,Kt=g,cs.attachEvent("onpropertychange",_o)):u==="focusout"&&pl()}function $d(u){if(u==="selectionchange"||u==="keyup"||u==="keydown")return zi(Kt)}function Km(u,f){if(u==="click")return zi(f)}function zj(u,f){if(u==="input"||u==="change")return zi(f)}function $j(u,f){return u===f&&(u!==0||1/u===1/f)||u!==u&&f!==f}var Wa=typeof Object.is=="function"?Object.is:$j;function Mf(u,f){if(Wa(u,f))return!0;if(typeof u!="object"||u===null||typeof f!="object"||f===null)return!1;var g=Object.keys(u),b=Object.keys(f);if(g.length!==b.length)return!1;for(b=0;b<g.length;b++){var E=g[b];if(!c.call(f,E)||!Wa(u[E],f[E]))return!1}return!0}function QS(u){for(;u&&u.firstChild;)u=u.firstChild;return u}function XS(u,f){var g=QS(u);u=0;for(var b;g;){if(g.nodeType===3){if(b=u+g.textContent.length,u<=f&&b>=f)return{node:g,offset:f-u};u=b}e:{for(;g;){if(g.nextSibling){g=g.nextSibling;break e}g=g.parentNode}g=void 0}g=QS(g)}}function JS(u,f){return u&&f?u===f?!0:u&&u.nodeType===3?!1:f&&f.nodeType===3?JS(u,f.parentNode):"contains"in u?u.contains(f):u.compareDocumentPosition?!!(u.compareDocumentPosition(f)&16):!1:!1}function ZS(){for(var u=window,f=Ue();f instanceof u.HTMLIFrameElement;){try{var g=typeof f.contentWindow.location.href=="string"}catch{g=!1}if(g)u=f.contentWindow;else break;f=Ue(u.document)}return f}function gy(u){var f=u&&u.nodeName&&u.nodeName.toLowerCase();return f&&(f==="input"&&(u.type==="text"||u.type==="search"||u.type==="tel"||u.type==="url"||u.type==="password")||f==="textarea"||u.contentEditable==="true")}function Hj(u){var f=ZS(),g=u.focusedElem,b=u.selectionRange;if(f!==g&&g&&g.ownerDocument&&JS(g.ownerDocument.documentElement,g)){if(b!==null&&gy(g)){if(f=b.start,u=b.end,u===void 0&&(u=f),"selectionStart"in g)g.selectionStart=f,g.selectionEnd=Math.min(u,g.value.length);else if(u=(f=g.ownerDocument||document)&&f.defaultView||window,u.getSelection){u=u.getSelection();var E=g.textContent.length,C=Math.min(b.start,E);b=b.end===void 0?C:Math.min(b.end,E),!u.extend&&C>b&&(E=b,b=C,C=E),E=XS(g,C);var B=XS(g,b);E&&B&&(u.rangeCount!==1||u.anchorNode!==E.node||u.anchorOffset!==E.offset||u.focusNode!==B.node||u.focusOffset!==B.offset)&&(f=f.createRange(),f.setStart(E.node,E.offset),u.removeAllRanges(),C>b?(u.addRange(f),u.extend(B.node,B.offset)):(f.setEnd(B.node,B.offset),u.addRange(f)))}}for(f=[],u=g;u=u.parentNode;)u.nodeType===1&&f.push({element:u,left:u.scrollLeft,top:u.scrollTop});for(typeof g.focus=="function"&&g.focus(),g=0;g<f.length;g++)u=f[g],u.element.scrollLeft=u.left,u.element.scrollTop=u.top}}var Wj=l&&"documentMode"in document&&11>=document.documentMode,Hd=null,xy=null,Ff=null,yy=!1;function eE(u,f,g){var b=g.window===g?g.document:g.nodeType===9?g:g.ownerDocument;yy||Hd==null||Hd!==Ue(b)||(b=Hd,"selectionStart"in b&&gy(b)?b={start:b.selectionStart,end:b.selectionEnd}:(b=(b.ownerDocument&&b.ownerDocument.defaultView||window).getSelection(),b={anchorNode:b.anchorNode,anchorOffset:b.anchorOffset,focusNode:b.focusNode,focusOffset:b.focusOffset}),Ff&&Mf(Ff,b)||(Ff=b,b=Xm(xy,"onSelect"),0<b.length&&(f=new cl("onSelect","select",null,f,g),u.push({event:f,listeners:b}),f.target=Hd)))}function qm(u,f){var g={};return g[u.toLowerCase()]=f.toLowerCase(),g["Webkit"+u]="webkit"+f,g["Moz"+u]="moz"+f,g}var Wd={animationend:qm("Animation","AnimationEnd"),animationiteration:qm("Animation","AnimationIteration"),animationstart:qm("Animation","AnimationStart"),transitionend:qm("Transition","TransitionEnd")},vy={},tE={};l&&(tE=document.createElement("div").style,"AnimationEvent"in window||(delete Wd.animationend.animation,delete Wd.animationiteration.animation,delete Wd.animationstart.animation),"TransitionEvent"in window||delete Wd.transitionend.transition);function Ym(u){if(vy[u])return vy[u];if(!Wd[u])return u;var f=Wd[u],g;for(g in f)if(f.hasOwnProperty(g)&&g in tE)return vy[u]=f[g];return u}var nE=Ym("animationend"),sE=Ym("animationiteration"),rE=Ym("animationstart"),iE=Ym("transitionend"),aE=new Map,oE="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function hc(u,f){aE.set(u,f),i(f,[u])}for(var by=0;by<oE.length;by++){var wy=oE[by],Gj=wy.toLowerCase(),Kj=wy[0].toUpperCase()+wy.slice(1);hc(Gj,"on"+Kj)}hc(nE,"onAnimationEnd"),hc(sE,"onAnimationIteration"),hc(rE,"onAnimationStart"),hc("dblclick","onDoubleClick"),hc("focusin","onFocus"),hc("focusout","onBlur"),hc(iE,"onTransitionEnd"),a("onMouseEnter",["mouseout","mouseover"]),a("onMouseLeave",["mouseout","mouseover"]),a("onPointerEnter",["pointerout","pointerover"]),a("onPointerLeave",["pointerout","pointerover"]),i("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),i("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),i("onBeforeInput",["compositionend","keypress","textInput","paste"]),i("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),i("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),i("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Uf="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),qj=new Set("cancel close invalid load scroll toggle".split(" ").concat(Uf));function lE(u,f,g){var b=u.type||"unknown-event";u.currentTarget=g,Da(b,f,void 0,u),u.currentTarget=null}function cE(u,f){f=(f&4)!==0;for(var g=0;g<u.length;g++){var b=u[g],E=b.event;b=b.listeners;e:{var C=void 0;if(f)for(var B=b.length-1;0<=B;B--){var Z=b[B],re=Z.instance,be=Z.currentTarget;if(Z=Z.listener,re!==C&&E.isPropagationStopped())break e;lE(E,Z,be),C=re}else for(B=0;B<b.length;B++){if(Z=b[B],re=Z.instance,be=Z.currentTarget,Z=Z.listener,re!==C&&E.isPropagationStopped())break e;lE(E,Z,be),C=re}}}if(Un)throw u=Vn,Un=!1,Vn=null,u}function Bn(u,f){var g=f[ky];g===void 0&&(g=f[ky]=new Set);var b=u+"__bubble";g.has(b)||(uE(f,u,2,!1),g.add(b))}function Sy(u,f,g){var b=0;f&&(b|=4),uE(g,u,b,f)}var Qm="_reactListening"+Math.random().toString(36).slice(2);function Vf(u){if(!u[Qm]){u[Qm]=!0,s.forEach(function(g){g!=="selectionchange"&&(qj.has(g)||Sy(g,!1,u),Sy(g,!0,u))});var f=u.nodeType===9?u:u.ownerDocument;f===null||f[Qm]||(f[Qm]=!0,Sy("selectionchange",!1,f))}}function uE(u,f,g,b){switch(da(f)){case 1:var E=tr;break;case 4:E=ua;break;default:E=ll}g=E.bind(null,f,g,u),E=void 0,!es||f!=="touchstart"&&f!=="touchmove"&&f!=="wheel"||(E=!0),b?E!==void 0?u.addEventListener(f,g,{capture:!0,passive:E}):u.addEventListener(f,g,!0):E!==void 0?u.addEventListener(f,g,{passive:E}):u.addEventListener(f,g,!1)}function Ey(u,f,g,b,E){var C=b;if((f&1)===0&&(f&2)===0&&b!==null)e:for(;;){if(b===null)return;var B=b.tag;if(B===3||B===4){var Z=b.stateNode.containerInfo;if(Z===E||Z.nodeType===8&&Z.parentNode===E)break;if(B===4)for(B=b.return;B!==null;){var re=B.tag;if((re===3||re===4)&&(re=B.stateNode.containerInfo,re===E||re.nodeType===8&&re.parentNode===E))return;B=B.return}for(;Z!==null;){if(B=Au(Z),B===null)return;if(re=B.tag,re===5||re===6){b=C=B;continue e}Z=Z.parentNode}}b=b.return}oi(function(){var be=C,Ve=ai(g),$e=[];e:{var Me=aE.get(u);if(Me!==void 0){var nt=cl,dt=u;switch(u){case"keypress":if($a(g)===0)break e;case"keydown":case"keyup":nt=ye;break;case"focusin":dt="focus",nt=ws;break;case"focusout":dt="blur",nt=ws;break;case"beforeblur":case"afterblur":nt=ws;break;case"click":if(g.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":nt=nr;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":nt=dl;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":nt=ns;break;case nE:case sE:case rE:nt=Eu;break;case iE:nt=hl;break;case"scroll":nt=oc;break;case"wheel":nt=jf;break;case"copy":case"cut":case"paste":nt=v;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":nt=sr}var gt=(f&4)!==0,Ss=!gt&&u==="scroll",ge=gt?Me!==null?Me+"Capture":null:Me;gt=[];for(var ae=be,ve;ae!==null;){ve=ae;var Ge=ve.stateNode;if(ve.tag===5&&Ge!==null&&(ve=Ge,ge!==null&&(Ge=_r(ae,ge),Ge!=null&>.push(Bf(ae,Ge,ve)))),Ss)break;ae=ae.return}0<gt.length&&(Me=new nt(Me,dt,null,g,Ve),$e.push({event:Me,listeners:gt}))}}if((f&7)===0){e:{if(Me=u==="mouseover"||u==="pointerover",nt=u==="mouseout"||u==="pointerout",Me&&g!==ii&&(dt=g.relatedTarget||g.fromElement)&&(Au(dt)||dt[ml]))break e;if((nt||Me)&&(Me=Ve.window===Ve?Ve:(Me=Ve.ownerDocument)?Me.defaultView||Me.parentWindow:window,nt?(dt=g.relatedTarget||g.toElement,nt=be,dt=dt?Au(dt):null,dt!==null&&(Ss=Rn(dt),dt!==Ss||dt.tag!==5&&dt.tag!==6)&&(dt=null)):(nt=null,dt=be),nt!==dt)){if(gt=nr,Ge="onMouseLeave",ge="onMouseEnter",ae="mouse",(u==="pointerout"||u==="pointerover")&&(gt=sr,Ge="onPointerLeave",ge="onPointerEnter",ae="pointer"),Ss=nt==null?Me:qd(nt),ve=dt==null?Me:qd(dt),Me=new gt(Ge,ae+"leave",nt,g,Ve),Me.target=Ss,Me.relatedTarget=ve,Ge=null,Au(Ve)===be&&(gt=new gt(ge,ae+"enter",dt,g,Ve),gt.target=ve,gt.relatedTarget=Ss,Ge=gt),Ss=Ge,nt&&dt)t:{for(gt=nt,ge=dt,ae=0,ve=gt;ve;ve=Gd(ve))ae++;for(ve=0,Ge=ge;Ge;Ge=Gd(Ge))ve++;for(;0<ae-ve;)gt=Gd(gt),ae--;for(;0<ve-ae;)ge=Gd(ge),ve--;for(;ae--;){if(gt===ge||ge!==null&>===ge.alternate)break t;gt=Gd(gt),ge=Gd(ge)}gt=null}else gt=null;nt!==null&&dE($e,Me,nt,gt,!1),dt!==null&&Ss!==null&&dE($e,Ss,dt,gt,!0)}}e:{if(Me=be?qd(be):window,nt=Me.nodeName&&Me.nodeName.toLowerCase(),nt==="select"||nt==="input"&&Me.type==="file")var vt=$i;else if(Ut(Me))if(Iu)vt=zj;else{vt=$d;var kt=zd}else(nt=Me.nodeName)&&nt.toLowerCase()==="input"&&(Me.type==="checkbox"||Me.type==="radio")&&(vt=Km);if(vt&&(vt=vt(u,be))){tn($e,vt,g,Ve);break e}kt&&kt(u,Me,be),u==="focusout"&&(kt=Me._wrapperState)&&kt.controlled&&Me.type==="number"&&At(Me,"number",Me.value)}switch(kt=be?qd(be):window,u){case"focusin":(Ut(kt)||kt.contentEditable==="true")&&(Hd=kt,xy=be,Ff=null);break;case"focusout":Ff=xy=Hd=null;break;case"mousedown":yy=!0;break;case"contextmenu":case"mouseup":case"dragend":yy=!1,eE($e,g,Ve);break;case"selectionchange":if(Wj)break;case"keydown":case"keyup":eE($e,g,Ve)}var Rt;if(fl)e:{switch(u){case"compositionstart":var jt="onCompositionStart";break e;case"compositionend":jt="onCompositionEnd";break e;case"compositionupdate":jt="onCompositionUpdate";break e}jt=void 0}else xe?se(u,g)&&(jt="onCompositionEnd"):u==="keydown"&&g.keyCode===229&&(jt="onCompositionStart");jt&&(_u&&g.locale!=="ko"&&(xe||jt!=="onCompositionStart"?jt==="onCompositionEnd"&&xe&&(Rt=za()):(pr=Ve,ui="value"in pr?pr.value:pr.textContent,xe=!0)),kt=Xm(be,jt),0<kt.length&&(jt=new O(jt,u,null,g,Ve),$e.push({event:jt,listeners:kt}),Rt?jt.data=Rt:(Rt=me(g),Rt!==null&&(jt.data=Rt)))),(Rt=Vd?Be(u,g):Ne(u,g))&&(be=Xm(be,"onBeforeInput"),0<be.length&&(Ve=new O("onBeforeInput","beforeinput",null,g,Ve),$e.push({event:Ve,listeners:be}),Ve.data=Rt))}cE($e,f)})}function Bf(u,f,g){return{instance:u,listener:f,currentTarget:g}}function Xm(u,f){for(var g=f+"Capture",b=[];u!==null;){var E=u,C=E.stateNode;E.tag===5&&C!==null&&(E=C,C=_r(u,g),C!=null&&b.unshift(Bf(u,C,E)),C=_r(u,f),C!=null&&b.push(Bf(u,C,E))),u=u.return}return b}function Gd(u){if(u===null)return null;do u=u.return;while(u&&u.tag!==5);return u||null}function dE(u,f,g,b,E){for(var C=f._reactName,B=[];g!==null&&g!==b;){var Z=g,re=Z.alternate,be=Z.stateNode;if(re!==null&&re===b)break;Z.tag===5&&be!==null&&(Z=be,E?(re=_r(g,C),re!=null&&B.unshift(Bf(g,re,Z))):E||(re=_r(g,C),re!=null&&B.push(Bf(g,re,Z)))),g=g.return}B.length!==0&&u.push({event:f,listeners:B})}var Yj=/\r\n?/g,Qj=/\u0000|\uFFFD/g;function hE(u){return(typeof u=="string"?u:""+u).replace(Yj,` 7`).replace(Qj,"")}function Jm(u,f,g){if(f=hE(f),hE(u)!==f&&g)throw Error(t(425))}function Zm(){}var Ty=null,_y=null;function Iy(u,f){return u==="textarea"||u==="noscript"||typeof f.children=="string"||typeof f.children=="number"||typeof f.dangerouslySetInnerHTML=="object"&&f.dangerouslySetInnerHTML!==null&&f.dangerouslySetInnerHTML.__html!=null}var Ay=typeof setTimeout=="function"?setTimeout:void 0,Xj=typeof clearTimeout=="function"?clearTimeout:void 0,fE=typeof Promise=="function"?Promise:void 0,Jj=typeof queueMicrotask=="function"?queueMicrotask:typeof fE<"u"?function(u){return fE.resolve(null).then(u).catch(Zj)}:Ay;function Zj(u){setTimeout(function(){throw u})}function Cy(u,f){var g=f,b=0;do{var E=g.nextSibling;if(u.removeChild(g),E&&E.nodeType===8)if(g=E.data,g==="/$"){if(b===0){u.removeChild(E),Fi(f);return}b--}else g!=="$"&&g!=="$?"&&g!=="$!"||b++;
vendor: 9,333 bytes, line 7
7g=E}while(g);Fi(f)}function fc(u){for(;u!=null;u=u.nextSibling){var f=u.nodeType;if(f===1||f===3)break;if(f===8){if(f=u.data,f==="$"||f==="$!"||f==="$?")break;if(f==="/$")return null}}return u}function pE(u){u=u.previousSibling;for(var f=0;u;){if(u.nodeType===8){var g=u.data;if(g==="$"||g==="$!"||g==="$?"){if(f===0)return u;f--}else g==="/$"&&f++}u=u.previousSibling}return null}var Kd=Math.random().toString(36).slice(2),Io="__reactFiber$"+Kd,zf="__reactProps$"+Kd,ml="__reactContainer$"+Kd,ky="__reactEvents$"+Kd,eO="__reactListeners$"+Kd,tO="__reactHandles$"+Kd;function Au(u){var f=u[Io];if(f)return f;for(var g=u.parentNode;g;){if(f=g[ml]||g[Io]){if(g=f.alternate,f.child!==null||g!==null&&g.child!==null)for(u=pE(u);u!==null;){if(g=u[Io])return g;u=pE(u)}return f}u=g,g=u.parentNode}return null}function $f(u){return u=u[Io]||u[ml],!u||u.tag!==5&&u.tag!==6&&u.tag!==13&&u.tag!==3?null:u}function qd(u){if(u.tag===5||u.tag===6)return u.stateNode;throw Error(t(33))}function eg(u){return u[zf]||null}var Ry=[],Yd=-1;function pc(u){return{current:u}}function zn(u){0>Yd||(u.current=Ry[Yd],Ry[Yd]=null,Yd--)}function Fn(u,f){Yd++,Ry[Yd]=u.current,u.current=f}var mc={},kr=pc(mc),hi=pc(!1),Cu=mc;function Qd(u,f){var g=u.type.contextTypes;if(!g)return mc;var b=u.stateNode;if(b&&b.__reactInternalMemoizedUnmaskedChildContext===f)return b.__reactInternalMemoizedMaskedChildContext;var E={},C;for(C in g)E[C]=f[C];return b&&(u=u.stateNode,u.__reactInternalMemoizedUnmaskedChildContext=f,u.__reactInternalMemoizedMaskedChildContext=E),E}function fi(u){return u=u.childContextTypes,u!=null}function tg(){zn(hi),zn(kr)}function mE(u,f,g){if(kr.current!==mc)throw Error(t(168));Fn(kr,f),Fn(hi,g)}function gE(u,f,g){var b=u.stateNode;if(f=f.childContextTypes,typeof b.getChildContext!="function")return g;b=b.getChildContext();for(var E in b)if(!(E in f))throw Error(t(108,Ye(u)||"Unknown",E));return ee({},g,b)}function ng(u){return u=(u=u.stateNode)&&u.__reactInternalMemoizedMergedChildContext||mc,Cu=kr.current,Fn(kr,u),Fn(hi,hi.current),!0}function xE(u,f,g){var b=u.stateNode;if(!b)throw Error(t(169));g?(u=gE(u,f,Cu),b.__reactInternalMemoizedMergedChildContext=u,zn(hi),zn(kr),Fn(kr,u)):zn(hi),Fn(hi,g)}var gl=null,sg=!1,Py=!1;function yE(u){gl===null?gl=[u]:gl.push(u)}function nO(u){sg=!0,yE(u)}function gc(){if(!Py&&gl!==null){Py=!0;var u=0,f=Qt;try{var g=gl;for(Qt=1;u<g.length;u++){var b=g[u];do b=b(!0);while(b!==null)}gl=null,sg=!1}catch(E){throw gl!==null&&(gl=gl.slice(u+1)),ja(al,gc),E}finally{Qt=f,Py=!1}}return null}var Xd=[],Jd=0,rg=null,ig=0,pa=[],ma=0,ku=null,xl=1,yl="";function Ru(u,f){Xd[Jd++]=ig,Xd[Jd++]=rg,rg=u,ig=f}function vE(u,f,g){pa[ma++]=xl,pa[ma++]=yl,pa[ma++]=ku,ku=u;var b=xl;u=yl;var E=32-As(b)-1;b&=~(1<<E),g+=1;var C=32-As(f)+E;if(30<C){var B=E-E%5;C=(b&(1<<B)-1).toString(32),b>>=B,E-=B,xl=1<<32-As(f)+E|g<<E|b,yl=C+u}else xl=1<<C|g<<E|b,yl=u}function Ny(u){u.return!==null&&(Ru(u,1),vE(u,1,0))}function Ly(u){for(;u===rg;)rg=Xd[--Jd],Xd[Jd]=null,ig=Xd[--Jd],Xd[Jd]=null;for(;u===ku;)ku=pa[--ma],pa[ma]=null,yl=pa[--ma],pa[ma]=null,xl=pa[--ma],pa[ma]=null}var Hi=null,Wi=null,Yn=!1,Ga=null;function bE(u,f){var g=va(5,null,null,0);g.elementType="DELETED",g.stateNode=f,g.return=u,f=u.deletions,f===null?(u.deletions=[g],u.flags|=16):f.push(g)}function wE(u,f){switch(u.tag){case 5:var g=u.type;return f=f.nodeType!==1||g.toLowerCase()!==f.nodeName.toLowerCase()?null:f,f!==null?(u.stateNode=f,Hi=u,Wi=fc(f.firstChild),!0):!1;case 6:return f=u.pendingProps===""||f.nodeType!==3?null:f,f!==null?(u.stateNode=f,Hi=u,Wi=null,!0):!1;case 13:return f=f.nodeType!==8?null:f,f!==null?(g=ku!==null?{id:xl,overflow:yl}:null,u.memoizedState={dehydrated:f,treeContext:g,retryLane:1073741824},g=va(18,null,null,0),g.stateNode=f,g.return=u,u.child=g,Hi=u,Wi=null,!0):!1;default:return!1}}function Dy(u){return(u.mode&1)!==0&&(u.flags&128)===0}function jy(u){if(Yn){var f=Wi;if(f){var g=f;if(!wE(u,f)){if(Dy(u))throw Error(t(418));f=fc(g.nextSibling);var b=Hi;f&&wE(u,f)?bE(b,g):(u.flags=u.flags&-4097|2,Yn=!1,Hi=u)}}else{if(Dy(u))throw Error(t(418));u.flags=u.flags&-4097|2,Yn=!1,Hi=u}}}function SE(u){for(u=u.return;u!==null&&u.tag!==5&&u.tag!==3&&u.tag!==13;)u=u.return;Hi=u}function ag(u){if(u!==Hi)return!1;if(!Yn)return SE(u),Yn=!0,!1;var f;if((f=u.tag!==3)&&!(f=u.tag!==5)&&(f=u.type,f=f!=="head"&&f!=="body"&&!Iy(u.type,u.memoizedProps)),f&&(f=Wi)){if(Dy(u))throw EE(),Error(t(418));for(;f;)bE(u,f),f=fc(f.nextSibling)}if(SE(u),u.tag===13){if(u=u.memoizedState,u=u!==null?u.dehydrated:null,!u)throw Error(t(317));e:{for(u=u.nextSibling,f=0;u;){if(u.nodeType===8){var g=u.data;if(g==="/$"){if(f===0){Wi=fc(u.nextSibling);break e}f--}else g!=="$"&&g!=="$!"&&g!=="$?"||f++}u=u.nextSibling}Wi=null}}else Wi=Hi?fc(u.stateNode.nextSibling):null;return!0}function EE(){for(var u=Wi;u;)u=fc(u.nextSibling)}function Zd(){Wi=Hi=null,Yn=!1}function Oy(u){Ga===null?Ga=[u]:Ga.push(u)}var sO=M.ReactCurrentBatchConfig;function Hf(u,f,g){if(u=g.ref,u!==null&&typeof u!="function"&&typeof u!="object"){if(g._owner){if(g=g._owner,g){if(g.tag!==1)throw Error(t(309));var b=g.stateNode}if(!b)throw Error(t(147,u));var E=b,C=""+u;return f!==null&&f.ref!==null&&typeof f.ref=="function"&&f.ref._stringRef===C?f.ref:(f=function(B){var Z=E.refs;B===null?delete Z[C]:Z[C]=B},f._stringRef=C,f)}if(typeof u!="string")throw Error(t(284));if(!g._owner)throw Error(t(290,u))}return u}function og(u,f){throw u=Object.prototype.toString.call(f),Error(t(31,u==="[object Object]"?"object with keys {"+Object.keys(f).join(", ")+"}":u))}function TE(u){var f=u._init;return f(u._payload)}function _E(u){function f(ge,ae){if(u){var ve=ge.deletions;ve===null?(ge.deletions=[ae],ge.flags|=16):ve.push(ae)}}function g(ge,ae){if(!u)return null;for(;ae!==null;)f(ge,ae),ae=ae.sibling;return null}function b(ge,ae){for(ge=new Map;ae!==null;)ae.key!==null?ge.set(ae.key,ae):ge.set(ae.index,ae),ae=ae.sibling;return ge}function E(ge,ae){return ge=Tc(ge,ae),ge.index=0,ge.sibling=null,ge}function C(ge,ae,ve){return ge.index=ve,u?(ve=ge.alternate,ve!==null?(ve=ve.index,ve<ae?(ge.flags|=2,ae):ve):(ge.flags|=2,ae)):(ge.flags|=1048576,ae)}function B(ge){return u&&ge.alternate===null&&(ge.flags|=2),ge}function Z(ge,ae,ve,Ge){return ae===null||ae.tag!==6?(ae=I2(ve,ge.mode,Ge),ae.return=ge,ae):(ae=E(ae,ve),ae.return=ge,ae)}function re(ge,ae,ve,Ge){var vt=ve.type;return vt===I?Ve(ge,ae,ve.props.children,Ge,ve.key):ae!==null&&(ae.elementType===vt||typeof vt=="object"&&vt!==null&&vt.$$typeof===X&&TE(vt)===ae.type)?(Ge=E(ae,ve.props),Ge.ref=Hf(ge,ae,ve),Ge.return=ge,Ge):(Ge=Pg(ve.type,ve.key,ve.props,null,ge.mode,Ge),Ge.ref=Hf(ge,ae,ve),Ge.return=ge,Ge)}function be(ge,ae,ve,Ge){return ae===null||ae.tag!==4||ae.stateNode.containerInfo!==ve.containerInfo||ae.stateNode.implementation!==ve.implementation?(ae=A2(ve,ge.mode,Ge),ae.return=ge,ae):(ae=E(ae,ve.children||[]),ae.return=ge,ae)}function Ve(ge,ae,ve,Ge,vt){return ae===null||ae.tag!==7?(ae=Fu(ve,ge.mode,Ge,vt),ae.return=ge,ae):(ae=E(ae,ve),ae.return=ge,ae)}function $e(ge,ae,ve){if(typeof ae=="string"&&ae!==""||typeof ae=="number")return ae=I2(""+ae,ge.mode,ve),ae.return=ge,ae;if(typeof ae=="object"&&ae!==null){switch(ae.$$typeof){case V:return ve=Pg(ae.type,ae.key,ae.props,null,ge.mode,ve),ve.ref=Hf(ge,null,ae),ve.return=ge,ve;case W:return ae=A2(ae,ge.mode,ve),ae.return=ge,ae;case X:var Ge=ae._init;return $e(ge,Ge(ae._payload),ve)}if(ot(ae)||Y(ae))return ae=Fu(ae,ge.mode,ve,null),ae.return=ge,ae;og(ge,ae)}return null}function Me(ge,ae,ve,Ge){var vt=ae!==null?ae.key:null;if(typeof ve=="string"&&ve!==""||typeof ve=="number")return vt!==null?null:Z(ge,ae,""+ve,Ge);if(typeof ve=="object"&&ve!==null){switch(ve.$$typeof){case V:return ve.key===vt?re(ge,ae,ve,Ge):null;case W:return ve.key===vt?be(ge,ae,ve,Ge):null;case X:return vt=ve._init,Me(ge,ae,vt(ve._payload),Ge)}if(ot(ve)||Y(ve))return vt!==null?null:Ve(ge,ae,ve,Ge,null);og(ge,ve)}return null}function nt(ge,ae,ve,Ge,vt){if(typeof Ge=="string"&&Ge!==""||typeof Ge=="number")return ge=ge.get(ve)||null,Z(ae,ge,""+Ge,vt);if(typeof Ge=="object"&&Ge!==null){switch(Ge.$$typeof){case V:return ge=ge.get(Ge.key===null?ve:Ge.key)||null,re(ae,ge,Ge,vt);case W:return ge=ge.get(Ge.key===null?ve:Ge.key)||null,be(ae,ge,Ge,vt);case X:var kt=Ge._init;return nt(ge,ae,ve,kt(Ge._payload),vt)}if(ot(Ge)||Y(Ge))return ge=ge.get(ve)||null,Ve(ae,ge,Ge,vt,null);og(ae,Ge)}return null}function dt(ge,ae,ve,Ge){for(var vt=null,kt=null,Rt=ae,jt=ae=0,ar=null;Rt!==null&&jt<ve.length;jt++){Rt.index>jt?(ar=Rt,Rt=null):ar=Rt.sibling;var yn=Me(ge,Rt,ve[jt],Ge);if(yn===null){Rt===null&&(Rt=ar);break}u&&Rt&&yn.alternate===null&&f(ge,Rt),ae=C(yn,ae,jt),kt===null?vt=yn:kt.sibling=yn,kt=yn,Rt=ar}if(jt===ve.length)return g(ge,Rt),Yn&&Ru(ge,jt),vt;if(Rt===null){for(;jt<ve.length;jt++)Rt=$e(ge,ve[jt],Ge),Rt!==null&&(ae=C(Rt,ae,jt),kt===null?vt=Rt:kt.sibling=Rt,kt=Rt);return Yn&&Ru(ge,jt),vt}for(Rt=b(ge,Rt);jt<ve.length;jt++)ar=nt(Rt,ge,jt,ve[jt],Ge),ar!==null&&(u&&ar.alternate!==null&&Rt.delete(ar.key===null?jt:ar.key),ae=C(ar,ae,jt),kt===null?vt=ar:kt.sibling=ar,kt=ar);return u&&Rt.forEach(function(_c){return f(ge,_c)}),Yn&&Ru(ge,jt),vt}function gt(ge,ae,ve,Ge){var vt=Y(ve);if(typeof vt!="function")throw Error(t(150));if(ve=vt.call(ve),ve==null)throw Error(t(151));for(var kt=vt=null,Rt=ae,jt=ae=0,ar=null,yn=ve.next();Rt!==null&&!yn.done;
vendor: 13,677 bytes, line 7
7jt++,yn=ve.next()){Rt.index>jt?(ar=Rt,Rt=null):ar=Rt.sibling;var _c=Me(ge,Rt,yn.value,Ge);if(_c===null){Rt===null&&(Rt=ar);break}u&&Rt&&_c.alternate===null&&f(ge,Rt),ae=C(_c,ae,jt),kt===null?vt=_c:kt.sibling=_c,kt=_c,Rt=ar}if(yn.done)return g(ge,Rt),Yn&&Ru(ge,jt),vt;if(Rt===null){for(;!yn.done;jt++,yn=ve.next())yn=$e(ge,yn.value,Ge),yn!==null&&(ae=C(yn,ae,jt),kt===null?vt=yn:kt.sibling=yn,kt=yn);return Yn&&Ru(ge,jt),vt}for(Rt=b(ge,Rt);!yn.done;jt++,yn=ve.next())yn=nt(Rt,ge,jt,yn.value,Ge),yn!==null&&(u&&yn.alternate!==null&&Rt.delete(yn.key===null?jt:yn.key),ae=C(yn,ae,jt),kt===null?vt=yn:kt.sibling=yn,kt=yn);return u&&Rt.forEach(function(OO){return f(ge,OO)}),Yn&&Ru(ge,jt),vt}function Ss(ge,ae,ve,Ge){if(typeof ve=="object"&&ve!==null&&ve.type===I&&ve.key===null&&(ve=ve.props.children),typeof ve=="object"&&ve!==null){switch(ve.$$typeof){case V:e:{for(var vt=ve.key,kt=ae;kt!==null;){if(kt.key===vt){if(vt=ve.type,vt===I){if(kt.tag===7){g(ge,kt.sibling),ae=E(kt,ve.props.children),ae.return=ge,ge=ae;break e}}else if(kt.elementType===vt||typeof vt=="object"&&vt!==null&&vt.$$typeof===X&&TE(vt)===kt.type){g(ge,kt.sibling),ae=E(kt,ve.props),ae.ref=Hf(ge,kt,ve),ae.return=ge,ge=ae;break e}g(ge,kt);break}else f(ge,kt);kt=kt.sibling}ve.type===I?(ae=Fu(ve.props.children,ge.mode,Ge,ve.key),ae.return=ge,ge=ae):(Ge=Pg(ve.type,ve.key,ve.props,null,ge.mode,Ge),Ge.ref=Hf(ge,ae,ve),Ge.return=ge,ge=Ge)}return B(ge);case W:e:{for(kt=ve.key;ae!==null;){if(ae.key===kt)if(ae.tag===4&&ae.stateNode.containerInfo===ve.containerInfo&&ae.stateNode.implementation===ve.implementation){g(ge,ae.sibling),ae=E(ae,ve.children||[]),ae.return=ge,ge=ae;break e}else{g(ge,ae);break}else f(ge,ae);ae=ae.sibling}ae=A2(ve,ge.mode,Ge),ae.return=ge,ge=ae}return B(ge);case X:return kt=ve._init,Ss(ge,ae,kt(ve._payload),Ge)}if(ot(ve))return dt(ge,ae,ve,Ge);if(Y(ve))return gt(ge,ae,ve,Ge);og(ge,ve)}return typeof ve=="string"&&ve!==""||typeof ve=="number"?(ve=""+ve,ae!==null&&ae.tag===6?(g(ge,ae.sibling),ae=E(ae,ve),ae.return=ge,ge=ae):(g(ge,ae),ae=I2(ve,ge.mode,Ge),ae.return=ge,ge=ae),B(ge)):g(ge,ae)}return Ss}var eh=_E(!0),IE=_E(!1),lg=pc(null),cg=null,th=null,My=null;function Fy(){My=th=cg=null}function Uy(u){var f=lg.current;zn(lg),u._currentValue=f}function Vy(u,f,g){for(;u!==null;){var b=u.alternate;if((u.childLanes&f)!==f?(u.childLanes|=f,b!==null&&(b.childLanes|=f)):b!==null&&(b.childLanes&f)!==f&&(b.childLanes|=f),u===g)break;u=u.return}}function nh(u,f){cg=u,My=th=null,u=u.dependencies,u!==null&&u.firstContext!==null&&((u.lanes&f)!==0&&(pi=!0),u.firstContext=null)}function ga(u){var f=u._currentValue;if(My!==u)if(u={context:u,memoizedValue:f,next:null},th===null){if(cg===null)throw Error(t(308));th=u,cg.dependencies={lanes:0,firstContext:u}}else th=th.next=u;return f}var Pu=null;function By(u){Pu===null?Pu=[u]:Pu.push(u)}function AE(u,f,g,b){var E=f.interleaved;return E===null?(g.next=g,By(f)):(g.next=E.next,E.next=g),f.interleaved=g,vl(u,b)}function vl(u,f){u.lanes|=f;var g=u.alternate;for(g!==null&&(g.lanes|=f),g=u,u=u.return;u!==null;)u.childLanes|=f,g=u.alternate,g!==null&&(g.childLanes|=f),g=u,u=u.return;return g.tag===3?g.stateNode:null}var xc=!1;function zy(u){u.updateQueue={baseState:u.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function CE(u,f){u=u.updateQueue,f.updateQueue===u&&(f.updateQueue={baseState:u.baseState,firstBaseUpdate:u.firstBaseUpdate,lastBaseUpdate:u.lastBaseUpdate,shared:u.shared,effects:u.effects})}function bl(u,f){return{eventTime:u,lane:f,tag:0,payload:null,callback:null,next:null}}function yc(u,f,g){var b=u.updateQueue;if(b===null)return null;if(b=b.shared,(mn&2)!==0){var E=b.pending;return E===null?f.next=f:(f.next=E.next,E.next=f),b.pending=f,vl(u,g)}return E=b.interleaved,E===null?(f.next=f,By(b)):(f.next=E.next,E.next=f),b.interleaved=f,vl(u,g)}function ug(u,f,g){if(f=f.updateQueue,f!==null&&(f=f.shared,(g&4194240)!==0)){var b=f.lanes;b&=u.pendingLanes,g|=b,f.lanes=g,Hr(u,g)}}function kE(u,f){var g=u.updateQueue,b=u.alternate;if(b!==null&&(b=b.updateQueue,g===b)){var E=null,C=null;if(g=g.firstBaseUpdate,g!==null){do{var B={eventTime:g.eventTime,lane:g.lane,tag:g.tag,payload:g.payload,callback:g.callback,next:null};C===null?E=C=B:C=C.next=B,g=g.next}while(g!==null);C===null?E=C=f:C=C.next=f}else E=C=f;g={baseState:b.baseState,firstBaseUpdate:E,lastBaseUpdate:C,shared:b.shared,effects:b.effects},u.updateQueue=g;return}u=g.lastBaseUpdate,u===null?g.firstBaseUpdate=f:u.next=f,g.lastBaseUpdate=f}function dg(u,f,g,b){var E=u.updateQueue;xc=!1;var C=E.firstBaseUpdate,B=E.lastBaseUpdate,Z=E.shared.pending;if(Z!==null){E.shared.pending=null;var re=Z,be=re.next;re.next=null,B===null?C=be:B.next=be,B=re;var Ve=u.alternate;Ve!==null&&(Ve=Ve.updateQueue,Z=Ve.lastBaseUpdate,Z!==B&&(Z===null?Ve.firstBaseUpdate=be:Z.next=be,Ve.lastBaseUpdate=re))}if(C!==null){var $e=E.baseState;B=0,Ve=be=re=null,Z=C;do{var Me=Z.lane,nt=Z.eventTime;if((b&Me)===Me){Ve!==null&&(Ve=Ve.next={eventTime:nt,lane:0,tag:Z.tag,payload:Z.payload,callback:Z.callback,next:null});e:{var dt=u,gt=Z;switch(Me=f,nt=g,gt.tag){case 1:if(dt=gt.payload,typeof dt=="function"){$e=dt.call(nt,$e,Me);break e}$e=dt;break e;case 3:dt.flags=dt.flags&-65537|128;case 0:if(dt=gt.payload,Me=typeof dt=="function"?dt.call(nt,$e,Me):dt,Me==null)break e;$e=ee({},$e,Me);break e;case 2:xc=!0}}Z.callback!==null&&Z.lane!==0&&(u.flags|=64,Me=E.effects,Me===null?E.effects=[Z]:Me.push(Z))}else nt={eventTime:nt,lane:Me,tag:Z.tag,payload:Z.payload,callback:Z.callback,next:null},Ve===null?(be=Ve=nt,re=$e):Ve=Ve.next=nt,B|=Me;if(Z=Z.next,Z===null){if(Z=E.shared.pending,Z===null)break;Me=Z,Z=Me.next,Me.next=null,E.lastBaseUpdate=Me,E.shared.pending=null}}while(!0);if(Ve===null&&(re=$e),E.baseState=re,E.firstBaseUpdate=be,E.lastBaseUpdate=Ve,f=E.shared.interleaved,f!==null){E=f;do B|=E.lane,E=E.next;while(E!==f)}else C===null&&(E.shared.lanes=0);Du|=B,u.lanes=B,u.memoizedState=$e}}function RE(u,f,g){if(u=f.effects,f.effects=null,u!==null)for(f=0;f<u.length;f++){var b=u[f],E=b.callback;if(E!==null){if(b.callback=null,b=g,typeof E!="function")throw Error(t(191,E));E.call(b)}}}var Wf={},Ao=pc(Wf),Gf=pc(Wf),Kf=pc(Wf);function Nu(u){if(u===Wf)throw Error(t(174));return u}function $y(u,f){switch(Fn(Kf,f),Fn(Gf,u),Fn(Ao,Wf),u=f.nodeType,u){case 9:case 11:f=(f=f.documentElement)?f.namespaceURI:le(null,"");break;default:u=u===8?f.parentNode:f,f=u.namespaceURI||null,u=u.tagName,f=le(f,u)}zn(Ao),Fn(Ao,f)}function sh(){zn(Ao),zn(Gf),zn(Kf)}function PE(u){Nu(Kf.current);var f=Nu(Ao.current),g=le(f,u.type);f!==g&&(Fn(Gf,u),Fn(Ao,g))}function Hy(u){Gf.current===u&&(zn(Ao),zn(Gf))}var ss=pc(0);function hg(u){for(var f=u;f!==null;){if(f.tag===13){var g=f.memoizedState;if(g!==null&&(g=g.dehydrated,g===null||g.data==="$?"||g.data==="$!"))return f}else if(f.tag===19&&f.memoizedProps.revealOrder!==void 0){if((f.flags&128)!==0)return f}else if(f.child!==null){f.child.return=f,f=f.child;continue}if(f===u)break;for(;f.sibling===null;){if(f.return===null||f.return===u)return null;f=f.return}f.sibling.return=f.return,f=f.sibling}return null}var Wy=[];function Gy(){for(var u=0;u<Wy.length;u++)Wy[u]._workInProgressVersionPrimary=null;Wy.length=0}var fg=M.ReactCurrentDispatcher,Ky=M.ReactCurrentBatchConfig,Lu=0,rs=null,Bs=null,rr=null,pg=!1,qf=!1,Yf=0,rO=0;function Rr(){throw Error(t(321))}function qy(u,f){if(f===null)return!1;for(var g=0;g<f.length&&g<u.length;g++)if(!Wa(u[g],f[g]))return!1;return!0}function Yy(u,f,g,b,E,C){if(Lu=C,rs=f,f.memoizedState=null,f.updateQueue=null,f.lanes=0,fg.current=u===null||u.memoizedState===null?lO:cO,u=g(b,E),qf){C=0;do{if(qf=!1,Yf=0,25<=C)throw Error(t(301));C+=1,rr=Bs=null,f.updateQueue=null,fg.current=uO,u=g(b,E)}while(qf)}if(fg.current=xg,f=Bs!==null&&Bs.next!==null,Lu=0,rr=Bs=rs=null,pg=!1,f)throw Error(t(300));return u}function Qy(){var u=Yf!==0;return Yf=0,u}function Co(){var u={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return rr===null?rs.memoizedState=rr=u:rr=rr.next=u,rr}function xa(){if(Bs===null){var u=rs.alternate;u=u!==null?u.memoizedState:null}else u=Bs.next;var f=rr===null?rs.memoizedState:rr.next;if(f!==null)rr=f,Bs=u;else{if(u===null)throw Error(t(310));Bs=u,u={memoizedState:Bs.memoizedState,baseState:Bs.baseState,baseQueue:Bs.baseQueue,queue:Bs.queue,next:null},rr===null?rs.memoizedState=rr=u:rr=rr.next=u}return rr}function Qf(u,f){return typeof f=="function"?f(u):f}function Xy(u){var f=xa(),g=f.queue;if(g===null)throw Error(t(311));g.lastRenderedReducer=u;var b=Bs,E=b.baseQueue,C=g.pending;if(C!==null){if(E!==null){var B=E.next;E.next=C.next,C.next=B}b.baseQueue=E=C,g.pending=null}if(E!==null){C=E.next,b=b.baseState;var Z=B=null,re=null,be=C;do{var Ve=be.lane;if((Lu&Ve)===Ve)re!==null&&(re=re.next={lane:0,action:be.action,hasEagerState:be.hasEagerState,eagerState:be.eagerState,next:null}),b=be.hasEagerState?be.eagerState:u(b,be.action);else{var $e={lane:Ve,action:be.action,hasEagerState:be.hasEagerState,eagerState:be.eagerState,next:null};re===null?(Z=re=$e,B=b):re=re.next=$e,rs.lanes|=Ve,Du|=Ve}be=be.next}while(be!==null&&be!==C);re===null?B=b:re.next=Z,Wa(b,f.memoizedState)||(pi=!0),f.memoizedState=b,f.baseState=B,f.baseQueue=re,g.lastRenderedState=b}if(u=g.interleaved,u!==null){E=u;do C=E.lane,rs.lanes|=C,Du|=C,E=E.next;while(E!==u)}else E===null&&(g.lanes=0);return[f.memoizedState,g.dispatch]}function Jy(u){var f=xa(),g=f.queue;if(g===null)throw Error(t(311));g.lastRenderedReducer=u;var b=g.dispatch,E=g.pending,C=f.memoizedState;if(E!==null){g.pending=null;var B=E=E.next;do C=u(C,B.action),B=B.next;while(B!==E);Wa(C,f.memoizedState)||(pi=!0),f.memoizedState=C,f.baseQueue===null&&(f.baseState=C),g.lastRenderedState=C}return[C,b]}function NE(){}function LE(u,f){var g=rs,b=xa(),E=f(),C=!Wa(b.memoizedState,E);if(C&&(b.memoizedState=E,pi=!0),b=b.queue,Zy(OE.bind(null,g,b,u),[u]),b.getSnapshot!==f||C||rr!==null&&rr.memoizedState.tag&1){if(g.flags|=2048,Xf(9,jE.bind(null,g,b,E,f),void 0,null),ir===null)throw Error(t(349));(Lu&30)!==0||DE(g,f,E)}return E}function DE(u,f,g){u.flags|=16384,u={getSnapshot:f,value:g},f=rs.updateQueue,f===null?(f={lastEffect:null,stores:null},rs.updateQueue=f,f.stores=[u]):(g=f.stores,g===null?f.stores=[u]:g.push(u))}function jE(u,f,g,b){f.value=g,f.getSnapshot=b,ME(f)&&FE(u)}function OE(u,f,g){return g(function(){ME(f)&&FE(u)})}function ME(u){var f=u.getSnapshot;u=u.value;try{var g=f();return!Wa(u,g)}catch{return!0}}function FE(u){var f=vl(u,1);f!==null&&Qa(f,u,1,-1)}function UE(u){var f=Co();return typeof u=="function"&&(u=u()),f.memoizedState=f.baseState=u,u={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Qf,lastRenderedState:u},f.queue=u,u=u.dispatch=oO.bind(null,rs,u),[f.memoizedState,u]}function Xf(u,f,g,b){return u={tag:u,create:f,destroy:g,deps:b,next:null},f=rs.updateQueue,f===null?(f={lastEffect:null,stores:null},rs.updateQueue=f,f.lastEffect=u.next=u):(g=f.lastEffect,g===null?f.lastEffect=u.next=u:(b=g.next,g.next=u,u.next=b,f.lastEffect=u)),u}function VE(){return xa().memoizedState}function mg(u,f,g,b){var E=Co();rs.flags|=u,E.memoizedState=Xf(1|f,g,void 0,b===void 0?null:b)}function gg(u,f,g,b){var E=xa();b=b===void 0?null:b;var C=void 0;if(Bs!==null){var B=Bs.memoizedState;if(C=B.destroy,b!==null&&qy(b,B.deps)){E.memoizedState=Xf(f,g,C,b);return}}rs.flags|=u,E.memoizedState=Xf(1|f,g,C,b)}function BE(u,f){return mg(8390656,8,u,f)}function Zy(u,f){return gg(2048,8,u,f)}function zE(u,f){return gg(4,2,u,f)}function $E(u,f){return gg(4,4,u,f)}function HE(u,f){if(typeof f=="function")return u=u(),f(u),function(){f(null)};if(f!=null)return u=u(),f.current=u,function(){f.current=null}}function WE(u,f,g){return g=g!=null?g.concat([u]):null,gg(4,4,HE.bind(null,f,u),g)}function e2(){}function GE(u,f){var g=xa();f=f===void 0?null:f;var b=g.memoizedState;return b!==null&&f!==null&&qy(f,b[1])?b[0]:(g.memoizedState=[u,f],u)}function KE(u,f){var g=xa();f=f===void 0?null:f;var b=g.memoizedState;return b!==null&&f!==null&&qy(f,b[1])?b[0]:(u=u(),g.memoizedState=[u,f],u)}function qE(u,f,g){return(Lu&21)===0?(u.baseState&&(u.baseState=!1,pi=!0),u.memoizedState=g):(Wa(g,f)||(g=nc(),rs.lanes|=g,Du|=g,u.baseState=!0),f)}function iO(u,f){var g=Qt;Qt=g!==0&&4>g?g:4,u(!0);var b=Ky.transition;Ky.transition={};try{u(!1),f()}finally{Qt=g,Ky.transition=b}}function YE(){return xa().memoizedState}function aO(u,f,g){var b=Sc(u);if(g={lane:b,action:g,hasEagerState:!1,eagerState:null,next:null},QE(u))XE(f,g);else if(g=AE(u,f,g,b),g!==null){var E=Kr();Qa(g,u,b,E),JE(g,f,b)}}function oO(u,f,g){var b=Sc(u),E={lane:b,action:g,hasEagerState:!1,eagerState:null,next:null};if(QE(u))XE(f,E);else{var C=u.alternate;if(u.lanes===0&&(C===null||C.lanes===0)&&(C=f.lastRenderedReducer,C!==null))try{var B=f.lastRenderedState,Z=C(B,g);if(E.hasEagerState=!0,E.eagerState=Z,Wa(Z,B)){var re=f.interleaved;re===null?(E.next=E,By(f)):(E.next=re.next,re.next=E),f.interleaved=E;return}}catch{}g=AE(u,f,E,b),g!==null&&(E=Kr(),Qa(g,u,b,E),JE(g,f,b))}}function QE(u){var f=u.alternate;return u===rs||f!==null&&f===rs}function XE(u,f){qf=pg=!0;var g=u.pending;g===null?f.next=f:(f.next=g.next,g.next=f),u.pending=f}function JE(u,f,g){if((g&4194240)!==0){var b=f.lanes;b&=u.pendingLanes,g|=b,f.lanes=g,Hr(u,g)}}var xg={readContext:ga,useCallback:Rr,useContext:Rr,useEffect:Rr,useImperativeHandle:Rr,useInsertionEffect:Rr,useLayoutEffect:Rr,useMemo:Rr,useReducer:Rr,useRef:Rr,useState:Rr,useDebugValue:Rr,useDeferredValue:Rr,useTransition:Rr,useMutableSource:Rr,useSyncExternalStore:Rr,useId:Rr,unstable_isNewReconciler:!1},lO={readContext:ga,useCallback:function(u,f){return Co().memoizedState=[u,f
vendor: 4,262 bytes, line 7
7===void 0?null:f],u},useContext:ga,useEffect:BE,useImperativeHandle:function(u,f,g){return g=g!=null?g.concat([u]):null,mg(4194308,4,HE.bind(null,f,u),g)},useLayoutEffect:function(u,f){return mg(4194308,4,u,f)},useInsertionEffect:function(u,f){return mg(4,2,u,f)},useMemo:function(u,f){var g=Co();return f=f===void 0?null:f,u=u(),g.memoizedState=[u,f],u},useReducer:function(u,f,g){var b=Co();return f=g!==void 0?g(f):f,b.memoizedState=b.baseState=f,u={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:u,lastRenderedState:f},b.queue=u,u=u.dispatch=aO.bind(null,rs,u),[b.memoizedState,u]},useRef:function(u){var f=Co();return u={current:u},f.memoizedState=u},useState:UE,useDebugValue:e2,useDeferredValue:function(u){return Co().memoizedState=u},useTransition:function(){var u=UE(!1),f=u[0];return u=iO.bind(null,u[1]),Co().memoizedState=u,[f,u]},useMutableSource:function(){},useSyncExternalStore:function(u,f,g){var b=rs,E=Co();if(Yn){if(g===void 0)throw Error(t(407));g=g()}else{if(g=f(),ir===null)throw Error(t(349));(Lu&30)!==0||DE(b,f,g)}E.memoizedState=g;var C={value:g,getSnapshot:f};return E.queue=C,BE(OE.bind(null,b,C,u),[u]),b.flags|=2048,Xf(9,jE.bind(null,b,C,g,f),void 0,null),g},useId:function(){var u=Co(),f=ir.identifierPrefix;if(Yn){var g=yl,b=xl;g=(b&~(1<<32-As(b)-1)).toString(32)+g,f=":"+f+"R"+g,g=Yf++,0<g&&(f+="H"+g.toString(32)),f+=":"}else g=rO++,f=":"+f+"r"+g.toString(32)+":";return u.memoizedState=f},unstable_isNewReconciler:!1},cO={readContext:ga,useCallback:GE,useContext:ga,useEffect:Zy,useImperativeHandle:WE,useInsertionEffect:zE,useLayoutEffect:$E,useMemo:KE,useReducer:Xy,useRef:VE,useState:function(){return Xy(Qf)},useDebugValue:e2,useDeferredValue:function(u){var f=xa();return qE(f,Bs.memoizedState,u)},useTransition:function(){var u=Xy(Qf)[0],f=xa().memoizedState;return[u,f]},useMutableSource:NE,useSyncExternalStore:LE,useId:YE,unstable_isNewReconciler:!1},uO={readContext:ga,useCallback:GE,useContext:ga,useEffect:Zy,useImperativeHandle:WE,useInsertionEffect:zE,useLayoutEffect:$E,useMemo:KE,useReducer:Jy,useRef:VE,useState:function(){return Jy(Qf)},useDebugValue:e2,useDeferredValue:function(u){var f=xa();return Bs===null?f.memoizedState=u:qE(f,Bs.memoizedState,u)},useTransition:function(){var u=Jy(Qf)[0],f=xa().memoizedState;return[u,f]},useMutableSource:NE,useSyncExternalStore:LE,useId:YE,unstable_isNewReconciler:!1};function Ka(u,f){if(u&&u.defaultProps){f=ee({},f),u=u.defaultProps;for(var g in u)f[g]===void 0&&(f[g]=u[g]);return f}return f}function t2(u,f,g,b){f=u.memoizedState,g=g(b,f),g=g==null?f:ee({},f,g),u.memoizedState=g,u.lanes===0&&(u.updateQueue.baseState=g)}var yg={isMounted:function(u){return(u=u._reactInternals)?Rn(u)===u:!1},enqueueSetState:function(u,f,g){u=u._reactInternals;var b=Kr(),E=Sc(u),C=bl(b,E);C.payload=f,g!=null&&(C.callback=g),f=yc(u,C,E),f!==null&&(Qa(f,u,E,b),ug(f,u,E))},enqueueReplaceState:function(u,f,g){u=u._reactInternals;var b=Kr(),E=Sc(u),C=bl(b,E);C.tag=1,C.payload=f,g!=null&&(C.callback=g),f=yc(u,C,E),f!==null&&(Qa(f,u,E,b),ug(f,u,E))},enqueueForceUpdate:function(u,f){u=u._reactInternals;var g=Kr(),b=Sc(u),E=bl(g,b);E.tag=2,f!=null&&(E.callback=f),f=yc(u,E,b),f!==null&&(Qa(f,u,b,g),ug(f,u,b))}};function ZE(u,f,g,b,E,C,B){return u=u.stateNode,typeof u.shouldComponentUpdate=="function"?u.shouldComponentUpdate(b,C,B):f.prototype&&f.prototype.isPureReactComponent?!Mf(g,b)||!Mf(E,C):!0}function e3(u,f,g){var b=!1,E=mc,C=f.contextType;return typeof C=="object"&&C!==null?C=ga(C):(E=fi(f)?Cu:kr.current,b=f.contextTypes,C=(b=b!=null)?Qd(u,E):mc),f=new f(g,C),u.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,f.updater=yg,u.stateNode=f,f._reactInternals=u,b&&(u=u.stateNode,u.__reactInternalMemoizedUnmaskedChildContext=E,u.__reactInternalMemoizedMaskedChildContext=C),f}function t3(u,f,g,b){u=f.state,typeof f.componentWillReceiveProps=="function"&&f.componentWillReceiveProps(g,b),typeof f.UNSAFE_componentWillReceiveProps=="function"&&f.UNSAFE_componentWillReceiveProps(g,b),f.state!==u&&yg.enqueueReplaceState(f,f.state,null)}function n2(u,f,g,b){var E=u.stateNode;E.props=g,E.state=u.memoizedState,E.refs={},zy(u);var C=f.contextType;typeof C=="object"&&C!==null?E.context=ga(C):(C=fi(f)?Cu:kr.current,E.context=Qd(u,C)
vendor: 49,200 bytes, lines 7-9
7),E.state=u.memoizedState,C=f.getDerivedStateFromProps,typeof C=="function"&&(t2(u,f,C,g),E.state=u.memoizedState),typeof f.getDerivedStateFromProps=="function"||typeof E.getSnapshotBeforeUpdate=="function"||typeof E.UNSAFE_componentWillMount!="function"&&typeof E.componentWillMount!="function"||(f=E.state,typeof E.componentWillMount=="function"&&E.componentWillMount(),typeof E.UNSAFE_componentWillMount=="function"&&E.UNSAFE_componentWillMount(),f!==E.state&&yg.enqueueReplaceState(E,E.state,null),dg(u,g,E,b),E.state=u.memoizedState),typeof E.componentDidMount=="function"&&(u.flags|=4194308)}function rh(u,f){try{var g="",b=f;do g+=_e(b),b=b.return;while(b);var E=g}catch(C){E=` 8Error generating stack: `+C.message+` 9`+C.stack}return{value:u,source:f,stack:E,digest:null}}function s2(u,f,g){return{value:u,source:null,stack:g??null,digest:f??null}}function pde(u,f){}var dO=typeof WeakMap=="function"?WeakMap:Map;function n3(u,f,g){g=bl(-1,g),g.tag=3,g.payload={element:null};var b=f.value;return g.callback=function(){_g||(_g=!0,y2=b)},g}function s3(u,f,g){g=bl(-1,g),g.tag=3;var b=u.type.getDerivedStateFromError;if(typeof b=="function"){var E=f.value;g.payload=function(){return b(E)},g.callback=function(){}}var C=u.stateNode;return C!==null&&typeof C.componentDidCatch=="function"&&(g.callback=function(){typeof b!="function"&&(bc===null?bc=new Set([this]):bc.add(this));var B=f.stack;this.componentDidCatch(f.value,{componentStack:B!==null?B:""})}),g}function r3(u,f,g){var b=u.pingCache;if(b===null){b=u.pingCache=new dO;var E=new Set;b.set(f,E)}else E=b.get(f),E===void 0&&(E=new Set,b.set(f,E));E.has(g)||(E.add(g),u=_O.bind(null,u,f,g),f.then(u,u))}function i3(u){do{var f;if((f=u.tag===13)&&(f=u.memoizedState,f=f!==null?f.dehydrated!==null:!0),f)return u;u=u.return}while(u!==null);return null}function a3(u,f,g,b,E){return(u.mode&1)===0?(u===f?u.flags|=65536:(u.flags|=128,g.flags|=131072,g.flags&=-52805,g.tag===1&&(g.alternate===null?g.tag=17:(f=bl(-1,1),f.tag=2,yc(g,f,1))),g.lanes|=1),u):(u.flags|=65536,u.lanes=E,u)}var hO=M.ReactCurrentOwner,pi=!1;function Gr(u,f,g,b){f.child=u===null?IE(f,null,g,b):eh(f,u.child,g,b)}function o3(u,f,g,b,E){g=g.render;var C=f.ref;return nh(f,E),b=Yy(u,f,g,b,C,E),g=Qy(),u!==null&&!pi?(f.updateQueue=u.updateQueue,f.flags&=-2053,u.lanes&=~E,wl(u,f,E)):(Yn&&g&&Ny(f),f.flags|=1,Gr(u,f,b,E),f.child)}function l3(u,f,g,b,E){if(u===null){var C=g.type;return typeof C=="function"&&!_2(C)&&C.defaultProps===void 0&&g.compare===null&&g.defaultProps===void 0?(f.tag=15,f.type=C,c3(u,f,C,b,E)):(u=Pg(g.type,null,b,f,f.mode,E),u.ref=f.ref,u.return=f,f.child=u)}if(C=u.child,(u.lanes&E)===0){var B=C.memoizedProps;if(g=g.compare,g=g!==null?g:Mf,g(B,b)&&u.ref===f.ref)return wl(u,f,E)}return f.flags|=1,u=Tc(C,b),u.ref=f.ref,u.return=f,f.child=u}function c3(u,f,g,b,E){if(u!==null){var C=u.memoizedProps;if(Mf(C,b)&&u.ref===f.ref)if(pi=!1,f.pendingProps=b=C,(u.lanes&E)!==0)(u.flags&131072)!==0&&(pi=!0);else return f.lanes=u.lanes,wl(u,f,E)}return r2(u,f,g,b,E)}function u3(u,f,g){var b=f.pendingProps,E=b.children,C=u!==null?u.memoizedState:null;if(b.mode==="hidden")if((f.mode&1)===0)f.memoizedState={baseLanes:0,cachePool:null,transitions:null},Fn(ah,Gi),Gi|=g;else{if((g&1073741824)===0)return u=C!==null?C.baseLanes|g:g,f.lanes=f.childLanes=1073741824,f.memoizedState={baseLanes:u,cachePool:null,transitions:null},f.updateQueue=null,Fn(ah,Gi),Gi|=u,null;f.memoizedState={baseLanes:0,cachePool:null,transitions:null},b=C!==null?C.baseLanes:g,Fn(ah,Gi),Gi|=b}else C!==null?(b=C.baseLanes|g,f.memoizedState=null):b=g,Fn(ah,Gi),Gi|=b;return Gr(u,f,E,g),f.child}function d3(u,f){var g=f.ref;(u===null&&g!==null||u!==null&&u.ref!==g)&&(f.flags|=512,f.flags|=2097152)}function r2(u,f,g,b,E){var C=fi(g)?Cu:kr.current;return C=Qd(f,C),nh(f,E),g=Yy(u,f,g,b,C,E),b=Qy(),u!==null&&!pi?(f.updateQueue=u.updateQueue,f.flags&=-2053,u.lanes&=~E,wl(u,f,E)):(Yn&&b&&Ny(f),f.flags|=1,Gr(u,f,g,E),f.child)}function h3(u,f,g,b,E){if(fi(g)){var C=!0;ng(f)}else C=!1;if(nh(f,E),f.stateNode===null)bg(u,f),e3(f,g,b),n2(f,g,b,E),b=!0;else if(u===null){var B=f.stateNode,Z=f.memoizedProps;B.props=Z;var re=B.context,be=g.contextType;typeof be=="object"&&be!==null?be=ga(be):(be=fi(g)?Cu:kr.current,be=Qd(f,be));var Ve=g.getDerivedStateFromProps,$e=typeof Ve=="function"||typeof B.getSnapshotBeforeUpdate=="function";$e||typeof B.UNSAFE_componentWillReceiveProps!="function"&&typeof B.componentWillReceiveProps!="function"||(Z!==b||re!==be)&&t3(f,B,b,be),xc=!1;var Me=f.memoizedState;B.state=Me,dg(f,b,B,E),re=f.memoizedState,Z!==b||Me!==re||hi.current||xc?(typeof Ve=="function"&&(t2(f,g,Ve,b),re=f.memoizedState),(Z=xc||ZE(f,g,Z,b,Me,re,be))?($e||typeof B.UNSAFE_componentWillMount!="function"&&typeof B.componentWillMount!="function"||(typeof B.componentWillMount=="function"&&B.componentWillMount(),typeof B.UNSAFE_componentWillMount=="function"&&B.UNSAFE_componentWillMount()),typeof B.componentDidMount=="function"&&(f.flags|=4194308)):(typeof B.componentDidMount=="function"&&(f.flags|=4194308),f.memoizedProps=b,f.memoizedState=re),B.props=b,B.state=re,B.context=be,b=Z):(typeof B.componentDidMount=="function"&&(f.flags|=4194308),b=!1)}else{B=f.stateNode,CE(u,f),Z=f.memoizedProps,be=f.type===f.elementType?Z:Ka(f.type,Z),B.props=be,$e=f.pendingProps,Me=B.context,re=g.contextType,typeof re=="object"&&re!==null?re=ga(re):(re=fi(g)?Cu:kr.current,re=Qd(f,re));var nt=g.getDerivedStateFromProps;(Ve=typeof nt=="function"||typeof B.getSnapshotBeforeUpdate=="function")||typeof B.UNSAFE_componentWillReceiveProps!="function"&&typeof B.componentWillReceiveProps!="function"||(Z!==$e||Me!==re)&&t3(f,B,b,re),xc=!1,Me=f.memoizedState,B.state=Me,dg(f,b,B,E);var dt=f.memoizedState;Z!==$e||Me!==dt||hi.current||xc?(typeof nt=="function"&&(t2(f,g,nt,b),dt=f.memoizedState),(be=xc||ZE(f,g,be,b,Me,dt,re)||!1)?(Ve||typeof B.UNSAFE_componentWillUpdate!="function"&&typeof B.componentWillUpdate!="function"||(typeof B.componentWillUpdate=="function"&&B.componentWillUpdate(b,dt,re),typeof B.UNSAFE_componentWillUpdate=="function"&&B.UNSAFE_componentWillUpdate(b,dt,re)),typeof B.componentDidUpdate=="function"&&(f.flags|=4),typeof B.getSnapshotBeforeUpdate=="function"&&(f.flags|=1024)):(typeof B.componentDidUpdate!="function"||Z===u.memoizedProps&&Me===u.memoizedState||(f.flags|=4),typeof B.getSnapshotBeforeUpdate!="function"||Z===u.memoizedProps&&Me===u.memoizedState||(f.flags|=1024),f.memoizedProps=b,f.memoizedState=dt),B.props=b,B.state=dt,B.context=re,b=be):(typeof B.componentDidUpdate!="function"||Z===u.memoizedProps&&Me===u.memoizedState||(f.flags|=4),typeof B.getSnapshotBeforeUpdate!="function"||Z===u.memoizedProps&&Me===u.memoizedState||(f.flags|=1024),b=!1)}return i2(u,f,g,b,C,E)}function i2(u,f,g,b,E,C){d3(u,f);var B=(f.flags&128)!==0;if(!b&&!B)return E&&xE(f,g,!1),wl(u,f,C);b=f.stateNode,hO.current=f;var Z=B&&typeof g.getDerivedStateFromError!="function"?null:b.render();return f.flags|=1,u!==null&&B?(f.child=eh(f,u.child,null,C),f.child=eh(f,null,Z,C)):Gr(u,f,Z,C),f.memoizedState=b.state,E&&xE(f,g,!0),f.child}function f3(u){var f=u.stateNode;f.pendingContext?mE(u,f.pendingContext,f.pendingContext!==f.context):f.context&&mE(u,f.context,!1),$y(u,f.containerInfo)}function p3(u,f,g,b,E){return Zd(),Oy(E),f.flags|=256,Gr(u,f,g,b),f.child}var a2={dehydrated:null,treeContext:null,retryLane:0};function o2(u){return{baseLanes:u,cachePool:null,transitions:null}}function m3(u,f,g){var b=f.pendingProps,E=ss.current,C=!1,B=(f.flags&128)!==0,Z;if((Z=B)||(Z=u!==null&&u.memoizedState===null?!1:(E&2)!==0),Z?(C=!0,f.flags&=-129):(u===null||u.memoizedState!==null)&&(E|=1),Fn(ss,E&1),u===null)return jy(f),u=f.memoizedState,u!==null&&(u=u.dehydrated,u!==null)?((f.mode&1)===0?f.lanes=1:u.data==="$!"?f.lanes=8:f.lanes=1073741824,null):(B=b.children,u=b.fallback,C?(b=f.mode,C=f.child,B={mode:"hidden",children:B},(b&1)===0&&C!==null?(C.childLanes=0,C.pendingProps=B):C=Ng(B,b,0,null),u=Fu(u,b,g,null),C.return=f,u.return=f,C.sibling=u,f.child=C,f.child.memoizedState=o2(g),f.memoizedState=a2,u):l2(f,B));if(E=u.memoizedState,E!==null&&(Z=E.dehydrated,Z!==null))return fO(u,f,B,b,Z,E,g);if(C){C=b.fallback,B=f.mode,E=u.child,Z=E.sibling;var re={mode:"hidden",children:b.children};return(B&1)===0&&f.child!==E?(b=f.child,b.childLanes=0,b.pendingProps=re,f.deletions=null):(b=Tc(E,re),b.subtreeFlags=E.subtreeFlags&14680064),Z!==null?C=Tc(Z,C):(C=Fu(C,B,g,null),C.flags|=2),C.return=f,b.return=f,b.sibling=C,f.child=b,b=C,C=f.child,B=u.child.memoizedState,B=B===null?o2(g):{baseLanes:B.baseLanes|g,cachePool:null,transitions:B.transitions},C.memoizedState=B,C.childLanes=u.childLanes&~g,f.memoizedState=a2,b}return C=u.child,u=C.sibling,b=Tc(C,{mode:"visible",children:b.children}),(f.mode&1)===0&&(b.lanes=g),b.return=f,b.sibling=null,u!==null&&(g=f.deletions,g===null?(f.deletions=[u],f.flags|=16):g.push(u)),f.child=b,f.memoizedState=null,b}function l2(u,f){return f=Ng({mode:"visible",children:f},u.mode,0,null),f.return=u,u.child=f}function vg(u,f,g,b){return b!==null&&Oy(b),eh(f,u.child,null,g),u=l2(f,f.pendingProps.children),u.flags|=2,f.memoizedState=null,u}function fO(u,f,g,b,E,C,B){if(g)return f.flags&256?(f.flags&=-257,b=s2(Error(t(422))),vg(u,f,B,b)):f.memoizedState!==null?(f.child=u.child,f.flags|=128,null):(C=b.fallback,E=f.mode,b=Ng({mode:"visible",children:b.children},E,0,null),C=Fu(C,E,B,null),C.flags|=2,b.return=f,C.return=f,b.sibling=C,f.child=b,(f.mode&1)!==0&&eh(f,u.child,null,B),f.child.memoizedState=o2(B),f.memoizedState=a2,C);if((f.mode&1)===0)return vg(u,f,B,null);if(E.data==="$!"){if(b=E.nextSibling&&E.nextSibling.dataset,b)var Z=b.dgst;return b=Z,C=Error(t(419)),b=s2(C,b,void 0),vg(u,f,B,b)}if(Z=(B&u.childLanes)!==0,pi||Z){if(b=ir,b!==null){switch(B&-B){case 4:E=2;break;case 16:E=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:E=32;break;case 536870912:E=268435456;break;default:E=0}E=(E&(b.suspendedLanes|B))!==0?0:E,E!==0&&E!==C.retryLane&&(C.retryLane=E,vl(u,E),Qa(b,u,E,-1))}return T2(),b=s2(Error(t(421))),vg(u,f,B,b)}return E.data==="$?"?(f.flags|=128,f.child=u.child,f=IO.bind(null,u),E._reactRetry=f,null):(u=C.treeContext,Wi=fc(E.nextSibling),Hi=f,Yn=!0,Ga=null,u!==null&&(pa[ma++]=xl,pa[ma++]=yl,pa[ma++]=ku,xl=u.id,yl=u.overflow,ku=f),f=l2(f,b.children),f.flags|=4096,f)}function g3(u,f,g){u.lanes|=f;var b=u.alternate;b!==null&&(b.lanes|=f),Vy(u.return,f,g)}function c2(u,f,g,b,E){var C=u.memoizedState;C===null?u.memoizedState={isBackwards:f,rendering:null,renderingStartTime:0,last:b,tail:g,tailMode:E}:(C.isBackwards=f,C.rendering=null,C.renderingStartTime=0,C.last=b,C.tail=g,C.tailMode=E)}function x3(u,f,g){var b=f.pendingProps,E=b.revealOrder,C=b.tail;if(Gr(u,f,b.children,g),b=ss.current,(b&2)!==0)b=b&1|2,f.flags|=128;else{if(u!==null&&(u.flags&128)!==0)e:for(u=f.child;u!==null;){if(u.tag===13)u.memoizedState!==null&&g3(u,g,f);else if(u.tag===19)g3(u,g,f);else if(u.child!==null){u.child.return=u,u=u.child;continue}if(u===f)break e;for(;u.sibling===null;){if(u.return===null||u.return===f)break e;u=u.return}u.sibling.return=u.return,u=u.sibling}b&=1}if(Fn(ss,b),(f.mode&1)===0)f.memoizedState=null;else switch(E){case"forwards":for(g=f.child,E=null;g!==null;)u=g.alternate,u!==null&&hg(u)===null&&(E=g),g=g.sibling;g=E,g===null?(E=f.child,f.child=null):(E=g.sibling,g.sibling=null),c2(f,!1,E,g,C);break;case"backwards":for(g=null,E=f.child,f.child=null;E!==null;){if(u=E.alternate,u!==null&&hg(u)===null){f.child=E;break}u=E.sibling,E.sibling=g,g=E,E=u}c2(f,!0,g,null,C);break;case"together":c2(f,!1,null,null,void 0);break;default:f.memoizedState=null}return f.child}function bg(u,f){(f.mode&1)===0&&u!==null&&(u.alternate=null,f.alternate=null,f.flags|=2)}function wl(u,f,g){if(u!==null&&(f.dependencies=u.dependencies),Du|=f.lanes,(g&f.childLanes)===0)return null;if(u!==null&&f.child!==u.child)throw Error(t(153));if(f.child!==null){for(u=f.child,g=Tc(u,u.pendingProps),f.child=g,g.return=f;u.sibling!==null;)u=u.sibling,g=g.sibling=Tc(u,u.pendingProps),g.return=f;g.sibling=null}return f.child}function pO(u,f,g){switch(f.tag){case 3:f3(f),Zd();break;case 5:PE(f);break;case 1:fi(f.type)&&ng(f);break;case 4:$y(f,f.stateNode.containerInfo);break;case 10:var b=f.type._context,E=f.memoizedProps.value;Fn(lg,b._currentValue),b._currentValue=E;break;case 13:if(b=f.memoizedState,b!==null)return b.dehydrated!==null?(Fn(ss,ss.current&1),f.flags|=128,null):(g&f.child.childLanes)!==0?m3(u,f,g):(Fn(ss,ss.current&1),u=wl(u,f,g),u!==null?u.sibling:null);Fn(ss,ss.current&1);break;case 19:if(b=(g&f.childLanes)!==0,(u.flags&128)!==0){if(b)return x3(u,f,g);f.flags|=128}if(E=f.memoizedState,E!==null&&(E.rendering=null,E.tail=null,E.lastEffect=null),Fn(ss,ss.current),b)break;return null;case 22:case 23:return f.lanes=0,u3(u,f,g)}return wl(u,f,g)}var y3,u2,v3,b3;y3=function(u,f){for(var g=f.child;g!==null;){if(g.tag===5||g.tag===6)u.appendChild(g.stateNode);else if(g.tag!==4&&g.child!==null){g.child.return=g,g=g.child;continue}if(g===f)break;for(;g.sibling===null;){if(g.return===null||g.return===f)return;g=g.return}g.sibling.return=g.return,g=g.sibling}},u2=function(){},v3=function(u,f,g,b){var E=u.memoizedProps;if(E!==b){u=f.stateNode,Nu(Ao.current);var C=null;switch(g){case"input":E=rt(u,E),b=rt(u,b),C=[];break;case"select":E=ee({},E,{value:void 0}),b=ee({},b,{value:void 0}),C=[];break;case"textarea":E=zt(u,E),b=zt(u,b),C=[];break;default:typeof E.onClick!="function"&&typeof b.onClick=="function"&&(u.onclick=Zm)}Mn(g,b);var B;g=null;for(be in E)if(!b.hasOwnProperty(be)&&E.hasOwnProperty(be)&&E[be]!=null)if(be==="style"){var Z=E[be];for(B in Z)Z.hasOwnProperty(B)&&(g||(g={}),g[B]="")}else be!=="dangerouslySetInnerHTML"&&be!=="children"&&be!=="suppressContentEditableWarning"&&be!=="suppressHydrationWarning"&&be!=="autoFocus"&&(r.hasOwnProperty(be)?C||(C=[]):(C=C||[]).push(be,null));for(be in b){var re=b[be];if(Z=E?.[be],b.hasOwnProperty(be)&&re!==Z&&(re!=null||Z!=null))if(be==="style")if(Z){for(B in Z)!Z.hasOwnProperty(B)||re&&re.hasOwnProperty(B)||(g||(g={}),g[B]="");for(B in re)re.hasOwnProperty(B)&&Z[B]!==re[B]&&(g||(g={}),g[B]=re[B])}else g||(C||(C=[]),C.push(be,g)),g=re;else be==="dangerouslySetInnerHTML"?(re=re?re.__html:void 0,Z=Z?Z.__html:void 0,re!=null&&Z!==re&&(C=C||[]).push(be,re)):be==="children"?typeof re!="string"&&typeof re!="number"||(C=C||[]).push(be,""+re):be!=="suppressContentEditableWarning"&&be!=="suppressHydrationWarning"&&(r.hasOwnProperty(be)?(re!=null&&be==="onScroll"&&Bn("scroll",u),C||Z===re||(C=[])):(C=C||[]).push(be,re))}g&&(C=C||[]).push("style",g);var be=C;(f.updateQueue=be)&&(f.flags|=4)}},b3=function(u,f,g,b){g!==b&&(f.flags|=4)};function Jf(u,f){if(!Yn)switch(u.tailMode){case"hidden":f=u.tail;for(var g=null;f!==null;)f.alternate!==null&&(g=f),f=f.sibling;g===null?u.tail=null:g.sibling=null;break;case"collapsed":g=u.tail;for(var b=null;g!==null;)g.alternate!==null&&(b=g),g=g.sibling;b===null?f||u.tail===null?u.tail=null:u.tail.sibling=null:b.sibling=null}}function Pr(u){var f=u.alternate!==null&&u.alternate.child===u.child,g=0,b=0;if(f)for(var E=u.child;E!==null;)g|=E.lanes|E.childLanes,b|=E.subtreeFlags&14680064,b|=E.flags&14680064,E.return=u,E=E.sibling;else for(E=u.child;E!==null;)g|=E.lanes|E.childLanes,b|=E.subtreeFlags,b|=E.flags,E.return=u,E=E.sibling;return u.subtreeFlags|=b,u.childLanes=g,f}function mO(u,f,g){var b=f.pendingProps;switch(Ly(f),f.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Pr(f),null;case 1:return fi(f.type)&&tg(),Pr(f),null;case 3:return b=f.stateNode,sh(),zn(hi),zn(kr),Gy(),b.pendingContext&&(b.context=b.pendingContext,b.pendingContext=null),(u===null||u.child===null)&&(ag(f)?f.flags|=4:u===null||u.memoizedState.isDehydrated&&(f.flags&256)===0||(f.flags|=1024,Ga!==null&&(w2(Ga),Ga=null))),u2(u,f),Pr(f),null;case 5:Hy(f);var E=Nu(Kf.current);if(g=f.type,u!==null&&f.stateNode!=null)v3(u,f,g,b,E),u.ref!==f.ref&&(f.flags|=512,f.flags|=2097152);else{if(!b){if(f.stateNode===null)throw Error(t(166));return Pr(f),null}if(u=Nu(Ao.current),ag(f)){b=f.stateNode,g=f.type;var C=f.memoizedProps;switch(b[Io]=f,b[zf]=C,u=(f.mode&1)!==0,g){case"dialog":Bn("cancel",b),Bn("close",b);break;case"iframe":case"object":case"embed":Bn("load",b);break;case"video":case"audio":for(E=0;E<Uf.length;E++)Bn(Uf[E],b);break;case"source":Bn("error",b);break;case"img":case"image":case"link":Bn("error",b),Bn("load",b);break;case"details":Bn("toggle",b);break;case"input":Ct(b,C),Bn("invalid",b);break;case"select":b._wrapperState={wasMultiple:!!C.multiple},Bn("invalid",b);break;case"textarea":wn(b,C),Bn("invalid",b)}Mn(g,C),E=null;for(var B in C)if(C.hasOwnProperty(B)){var Z=C[B];B==="children"?typeof Z=="string"?b.textContent!==Z&&(C.suppressHydrationWarning!==!0&&Jm(b.textContent,Z,u),E=["children",Z]):typeof Z=="number"&&b.textContent!==""+Z&&(C.suppressHydrationWarning!==!0&&Jm(b.textContent,Z,u),E=["children",""+Z]):r.hasOwnProperty(B)&&Z!=null&&B==="onScroll"&&Bn("scroll",b)}switch(g){case"input":cn(b),Nt(b,C,!0);break;case"textarea":cn(b),Ee(b);break;case"select":case"option":break;default:typeof C.onClick=="function"&&(b.onclick=Zm)}b=E,f.updateQueue=b,b!==null&&(f.flags|=4)}else{B=E.nodeType===9?E:E.ownerDocument,u==="http://www.w3.org/1999/xhtml"&&(u=He(g)),u==="http://www.w3.org/1999/xhtml"?g==="script"?(u=B.createElement("div"),u.innerHTML="<script><\/script>",u=u.removeChild(u.firstChild)):typeof b.is=="string"?u=B.createElement(g,{is:b.is}):(u=B.createElement(g),g==="select"&&(B=u,b.multiple?B.multiple=!0:b.size&&(B.size=b.size))):u=B.createElementNS(u,g),u[Io]=f,u[zf]=b,y3(u,f,!1,!1),f.stateNode=u;e:{switch(B=Gn(g,b),g){case"dialog":Bn("cancel",u),Bn("close",u),E=b;break;case"iframe":case"object":case"embed":Bn("load",u),E=b;break;case"video":case"audio":for(E=0;E<Uf.length;E++)Bn(Uf[E],u);E=b;break;case"source":Bn("error",u),E=b;break;case"img":case"image":case"link":Bn("error",u),Bn("load",u),E=b;break;case"details":Bn("toggle",u),E=b;break;case"input":Ct(u,b),E=rt(u,b),Bn("invalid",u);break;case"option":E=b;break;case"select":u._wrapperState={wasMultiple:!!b.multiple},E=ee({},b,{value:void 0}),Bn("invalid",u);break;case"textarea":wn(u,b),E=zt(u,b),Bn("invalid",u);break;default:E=b}Mn(g,E),Z=E;for(C in Z)if(Z.hasOwnProperty(C)){var re=Z[C];C==="style"?it(u,re):C==="dangerouslySetInnerHTML"?(re=re?re.__html:void 0,re!=null&&J(u,re)):C==="children"?typeof re=="string"?(g!=="textarea"||re!=="")&&De(u,re):typeof re=="number"&&De(u,""+re):C!=="suppressContentEditableWarning"&&C!=="suppressHydrationWarning"&&C!=="autoFocus"&&(r.hasOwnProperty(C)?re!=null&&C==="onScroll"&&Bn("scroll",u):re!=null&&R(u,C,re,B))}switch(g){case"input":cn(u),Nt(u,b,!1);break;case"textarea":cn(u),Ee(u);break;case"option":b.value!=null&&u.setAttribute("value",""+tt(b.value));break;case"select":u.multiple=!!b.multiple,C=b.value,C!=null?Yt(u,!!b.multiple,C,!1):b.defaultValue!=null&&Yt(u,!!b.multiple,b.defaultValue,!0);break;default:typeof E.onClick=="function"&&(u.onclick=Zm)}switch(g){case"button":case"input":case"select":case"textarea":b=!!b.autoFocus;break e;case"img":b=!0;break e;default:b=!1}}b&&(f.flags|=4)}f.ref!==null&&(f.flags|=512,f.flags|=2097152)}return Pr(f),null;case 6:if(u&&f.stateNode!=null)b3(u,f,u.memoizedProps,b);else{if(typeof b!="string"&&f.stateNode===null)throw Error(t(166));if(g=Nu(Kf.current),Nu(Ao.current),ag(f)){if(b=f.stateNode,g=f.memoizedProps,b[Io]=f,(C=b.nodeValue!==g)&&(u=Hi,u!==null))switch(u.tag){case 3:Jm(b.nodeValue,g,(u.mode&1)!==0);break;case 5:u.memoizedProps.suppressHydrationWarning!==!0&&Jm(b.nodeValue,g,(u.mode&1)!==0)}C&&(f.flags|=4)}else b=(g.nodeType===9?g:g.ownerDocument).createTextNode(b),b[Io]=f,f.stateNode=b}return Pr(f),null;case 13:if(zn(ss),b=f.memoizedState,u===null||u.memoizedState!==null&&u.memoizedState.dehydrated!==null){if(Yn&&Wi!==null&&(f.mode&1)!==0&&(f.flags&128)===0)EE(),Zd(),f.flags|=98560,C=!1;else if(C=ag(f),b!==null&&b.dehydrated!==null){if(u===null){if(!C)throw Error(t(318));if(C=f.memoizedState,C=C!==null?C.dehydrated:null,!C)throw Error(t(317));C[Io]=f}else Zd(),(f.flags&128)===0&&(f.memoizedState=null),f.flags|=4;Pr(f),C=!1}else Ga!==null&&(w2(Ga),Ga=null),C=!0;if(!C)return f.flags&65536?f:null}return(f.flags&128)!==0?(f.lanes=g,f):(b=b!==null,b!==(u!==null&&u.memoizedState!==null)&&b&&(f.child.flags|=8192,(f.mode&1)!==0&&(u===null||(ss.current&1)!==0?zs===0&&(zs=3):T2())),f.updateQueue!==null&&(f.flags|=4),Pr(f),null);case 4:return sh(),u2(u,f),u===null&&Vf(f.stateNode.containerInfo),Pr(f),null;case 10:return Uy(f.type._context),Pr(f),null;case 17:return fi(f.type)&&tg(),Pr(f),null;case 19:if(zn(ss),C=f.memoizedState,C===null)return Pr(f),null;if(b=(f.flags&128)!==0,B=C.rendering,B===null)if(b)Jf(C,!1);else{if(zs!==0||u!==null&&(u.flags&128)!==0)for(u=f.child;u!==null;){if(B=hg(u),B!==null){for(f.flags|=128,Jf(C,!1),b=B.updateQueue,b!==null&&(f.updateQueue=b,f.flags|=4),f.subtreeFlags=0,b=g,g=f.child;g!==null;)C=g,u=b,C.flags&=14680066,B=C.alternate,B===null?(C.childLanes=0,C.lanes=u,C.child=null,C.subtreeFlags=0,C.memoizedProps=null,C.memoizedState=null,C.updateQueue=null,C.dependencies=null,C.stateNode=null):(C.childLanes=B.childLanes,C.lanes=B.lanes,C.child=B.child,C.subtreeFlags=0,C.deletions=null,C.memoizedProps=B.memoizedProps,C.memoizedState=B.memoizedState,C.updateQueue=B.updateQueue,C.type=B.type,u=B.dependencies,C.dependencies=u===null?null:{lanes:u.lanes,firstContext:u.firstContext}),g=g.sibling;return Fn(ss,ss.current&1|2),f.child}u=u.sibling}C.tail!==null&&xn()>oh&&(f.flags|=128,b=!0,Jf(C,!1),f.lanes=4194304)}else{if(!b)if(u=hg(B),u!==null){if(f.flags|=128,b=!0,g=u.updateQueue,g!==null&&(f.updateQueue=g,f.flags|=4),Jf(C,!0),C.tail===null&&C.tailMode==="hidden"&&!B.alternate&&!Yn)return Pr(f),null}else 2*xn()-C.renderingStartTime>oh&&g!==1073741824&&(f.flags|=128,b=!0,Jf(C,!1),f.lanes=4194304);C.isBackwards?(B.sibling=f.child,f.child=B):(g=C.last,g!==null?g.sibling=B:f.child=B,C.last=B)}return C.tail!==null?(f=C.tail,C.rendering=f,C.tail=f.sibling,C.renderingStartTime=xn(),f.sibling=null,g=ss.current,Fn(ss,b?g&1|2:g&1),f):(Pr(f),null);case 22:case 23:return E2(),b=f.memoizedState!==null,u!==null&&u.memoizedState!==null!==b&&(f.flags|=8192),b&&(f.mode&1)!==0?(Gi&1073741824)!==0&&(Pr(f),f.subtreeFlags&6&&(f.flags|=8192)):Pr(f),null;case 24:return null;case 25:return null}throw Error(t(156,f.tag))}function gO(u,f){switch(Ly(f),f.tag){case 1:return fi(f.type)&&tg(),u=f.flags,u&65536?(f.flags=u&-65537|128,f):null;case 3:return sh(),zn(hi),zn(kr),Gy(),u=f.flags,(u&65536)!==0&&(u&128)===0?(f.flags=u&-65537|128,f):null;case 5:return Hy(f),null;case 13:if(zn(ss),u=f.memoizedState,u!==null&&u.dehydrated!==null){if(f.alternate===null)throw Error(t(340));Zd()}return u=f.flags,u&65536?(f.flags=u&-65537|128,f):null;case 19:return zn(ss),null;case 4:return sh(),null;case 10:return Uy(f.type._context),null;case 22:case 23:return E2(),null;case 24:return null;default:return null}}var wg=!1,Nr=!1,xO=typeof WeakSet=="function"?WeakSet:Set,ct=null;function ih(u,f){var g=u.ref;if(g!==null)if(typeof g=="function")try{g(null)}catch(b){us(u,f,b)}else g.current=null}function d2(u,f,g){try{g()}catch(b){us(u,f,b)}}var w3=!1;function yO(u,f){if(Ty=Vi,u=ZS(),gy(u)){if("selectionStart"in u)var g={start:u.selectionStart,end:u.selectionEnd};else e:{g=(g=u.ownerDocument)&&g.defaultView||window;var b=g.getSelection&&g.getSelection();if(b&&b.rangeCount!==0){g=b.anchorNode;var E=b.anchorOffset,C=b.focusNode;b=b.focusOffset;try{g.nodeType,C.nodeType}catch{g=null;break e}var B=0,Z=-1,re=-1,be=0,Ve=0,$e=u,Me=null;t:for(;;){for(var nt;$e!==g||E!==0&&$e.nodeType!==3||(Z=B+E),$e!==C||b!==0&&$e.nodeType!==3||(re=B+b),$e.nodeType===3&&(B+=$e.nodeValue.length),(nt=$e.firstChild)!==null;)Me=$e,$e=nt;for(;;){if($e===u)break t;if(Me===g&&++be===E&&(Z=B),Me===C&&++Ve===b&&(re=B),(nt=$e.nextSibling)!==null)break;$e=Me,Me=$e.parentNode}$e=nt}g=Z===-1||re===-1?null:{start:Z,end:re}}else g=null}g=g||{start:0,end:0}}else g=null;for(_y={focusedElem:u,selectionRange:g},Vi=!1,ct=f;ct!==null;)if(f=ct,u=f.child,(f.subtreeFlags&1028)!==0&&u!==null)u.return=f,ct=u;else for(;ct!==null;){f=ct;try{var dt=f.alternate;if((f.flags&1024)!==0)switch(f.tag){case 0:case 11:case 15:break;case 1:if(dt!==null){var gt=dt.memoizedProps,Ss=dt.memoizedState,ge=f.stateNode,ae=ge.getSnapshotBeforeUpdate(f.elementType===f.type?gt:Ka(f.type,gt),Ss);ge.__reactInternalSnapshotBeforeUpdate=ae}break;case 3:var ve=f.stateNode.containerInfo;ve.nodeType===1?ve.textContent="":ve.nodeType===9&&ve.documentElement&&ve.removeChild(ve.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(t(163))}}catch(Ge){us(f,f.return,Ge)}if(u=f.sibling,u!==null){u.return=f.return,ct=u;break}ct=f.return}return dt=w3,w3=!1,dt}function Zf(u,f,g){var b=f.updateQueue;if(b=b!==null?b.lastEffect:null,b!==null){var E=b=b.next;do{if((E.tag&u)===u){var C=E.destroy;E.destroy=void 0,C!==void 0&&d2(f,g,C)}E=E.next}while(E!==b)}}function Sg(u,f){if(f=f.updateQueue,f=f!==null?f.lastEffect:null,f!==null){var g=f=f.next;do{if((g.tag&u)===u){var b=g.create;g.destroy=b()}g=g.next}while(g!==f)}}function h2(u){var f=u.ref;if(f!==null){var g=u.stateNode;u.tag,u=g,typeof f=="function"?f(u):f.current=u}}function S3(u){var f=u.alternate;f!==null&&(u.alternate=null,S3(f)),u.child=null,u.deletions=null,u.sibling=null,u.tag===5&&(f=u.stateNode,f!==null&&(delete f[Io],delete f[zf],delete f[ky],delete f[eO],delete f[tO])),u.stateNode=null,u.return=null,u.dependencies=null,u.memoizedProps=null,u.memoizedState=null,u.pendingProps=null,u.stateNode=null,u.updateQueue=null}function E3(u){return u.tag===5||u.tag===3||u.tag===4}function T3(u){e:for(;;){for(;u.sibling===null;){if(u.return===null||E3(u.return))return null;u=u.return}for(u.sibling.return=u.return,u=u.sibling;u.tag!==5&&u.tag!==6&&u.tag!==18;){if(u.flags&2||u.child===null||u.tag===4)continue e;u.child.return=u,u=u.child}if(!(u.flags&2))return u.stateNode}}function f2(u,f,g){var b=u.tag;if(b===5||b===6)u=u.stateNode,f?g.nodeType===8?g.parentNode.insertBefore(u,f):g.insertBefore(u,f):(g.nodeType===8?(f=g.parentNode,f.insertBefore(u,g)):(f=g,f.appendChild(u)),g=g._reactRootContainer,g!=null||f.onclick!==null||(f.onclick=Zm));else if(b!==4&&(u=u.child,u!==null))for(f2(u,f,g),u=u.sibling;u!==null;)f2(u,f,g),u=u.sibling}function p2(u,f,g){var b=u.tag;if(b===5||b===6)u=u.stateNode,f?g.insertBefore(u,f):g.appendChild(u);else if(b!==4&&(u=u.child,u!==null))for(p2(u,f,g),u=u.sibling;u!==null;)p2(u,f,g),u=u.sibling}var mr=null,qa=!1;function vc(u,f,g){for(g=g.child;g!==null;)_3(u,f,g),g=g.sibling}function _3(u,f,g){if(Sn&&typeof Sn.onCommitFiberUnmount=="function")try{Sn.onCommitFiberUnmount(xo,g)}catch{}switch(g.tag){case 5:Nr||ih(g,f);case 6:var b=mr,E=qa;mr=null,vc(u,f,g),mr=b,qa=E,mr!==null&&(qa?(u=mr,g=g.stateNode,u.nodeType===8?u.parentNode.removeChild(g):u.removeChild(g)):mr.removeChild(g.stateNode));break;case 18:mr!==null&&(qa?(u=mr,g=g.stateNode,u.nodeType===8?Cy(u.parentNode,g):u.nodeType===1&&Cy(u,g),Fi(u)):Cy(mr,g.stateNode));break;case 4:b=mr,E=qa,mr=g.stateNode.containerInfo,qa=!0,vc(u,f,g),mr=b,qa=E;break;case 0:case 11:case 14:case 15:if(!Nr&&(b=g.updateQueue,b!==null&&(b=b.lastEffect,b!==null))){E=b=b.next;do{var C=E,B=C.destroy;C=C.tag,B!==void 0&&((C&2)!==0||(C&4)!==0)&&d2(g,f,B),E=E.next}while(E!==b)}vc(u,f,g);break;case 1:if(!Nr&&(ih(g,f),b=g.stateNode,typeof b.componentWillUnmount=="function"))try{b.props=g.memoizedProps,b.state=g.memoizedState,b.componentWillUnmount()}catch(Z){us(g,f,Z)}vc(u,f,g);break;case 21:vc(u,f,g);break;case 22:g.mode&1?(Nr=(b=Nr)||g.memoizedState!==null,vc(u,f,g),Nr=b):vc(u,f,g);break;default:vc(u,f,g)}}function I3(u){var f=u.updateQueue;if(f!==null){u.updateQueue=null;var g=u.stateNode;g===null&&(g=u.stateNode=new xO),f.forEach(function(b){var E=AO.bind(null,u,b);g.has(b)||(g.add(b),b.then(E,E))})}}function Ya(u,f){var g=f.deletions;if(g!==null)for(var b=0;b<g.length;b++){var E=g[b];try{var C=u,B=f,Z=B;e:for(;Z!==null;){switch(Z.tag){case 5:mr=Z.stateNode,qa=!1;break e;case 3:mr=Z.stateNode.containerInfo,qa=!0;break e;case 4:mr=Z.stateNode.containerInfo,qa=!0;break e}Z=Z.return}if(mr===null)throw Error(t(160));_3(C,B,E),mr=null,qa=!1;var re=E.alternate;re!==null&&(re.return=null),E.return=null}catch(be){us(E,f,be)}}if(f.subtreeFlags&12854)for(f=f.child;f!==null;)A3(f,u),f=f.sibling}function A3(u,f){var g=u.alternate,b=u.flags;switch(u.tag){case 0:case 11:case 14:case 15:if(Ya(f,u),ko(u),b&4){try{Zf(3,u,u.return),Sg(3,u)}catch(gt){us(u,u.return,gt)}try{Zf(5,u,u.return)}catch(gt){us(u,u.return,gt)}}break;case 1:Ya(f,u),ko(u),b&512&&g!==null&&ih(g,g.return);break;case 5:if(Ya(f,u),ko(u),b&512&&g!==null&&ih(g,g.return),u.flags&32){var E=u.stateNode;try{De(E,"")}catch(gt){us(u,u.return,gt)}}if(b&4&&(E=u.stateNode,E!=null)){var C=u.memoizedProps,B=g!==null?g.memoizedProps:C,Z=u.type,re=u.updateQueue;if(u.updateQueue=null,re!==null)try{Z==="input"&&C.type==="radio"&&C.name!=null&&at(E,C),Gn(Z,B);var be=Gn(Z,C);for(B=0;B<re.length;B+=2){var Ve=re[B],$e=re[B+1];Ve==="style"?it(E,$e):Ve==="dangerouslySetInnerHTML"?J(E,$e):Ve==="children"?De(E,$e):R(E,Ve,$e,be)}switch(Z){case"input":ft(E,C);break;case"textarea":Dt(E,C);break;case"select":var Me=E._wrapperState.wasMultiple;E._wrapperState.wasMultiple=!!C.multiple;var nt=C.value;nt!=null?Yt(E,!!C.multiple,nt,!1):Me!==!!C.multiple&&(C.defaultValue!=null?Yt(E,!!C.multiple,C.defaultValue,!0):Yt(E,!!C.multiple,C.multiple?[]:"",!1))}E[zf]=C}catch(gt){us(u,u.return,gt)}}break;case 6:if(Ya(f,u),ko(u),b&4){if(u.stateNode===null)throw Error(t(162));E=u.stateNode,C=u.memoizedProps;try{E.nodeValue=C}catch(gt){us(u,u.return,gt)}}break;case 3:if(Ya(f,u),ko(u),b&4&&g!==null&&g.memoizedState.isDehydrated)try{Fi(f.containerInfo)}catch(gt){us(u,u.return,gt)}break;case 4:Ya(f,u),ko(u);break;case 13:Ya(f,u),ko(u),E=u.child,E.flags&8192&&(C=E.memoizedState!==null,E.stateNode.isHidden=C,!C||E.alternate!==null&&E.alternate.memoizedState!==null||(x2=xn())),b&4&&I3(u);break;case 22:if(Ve=g!==null&&g.memoizedState!==null,u.mode&1?(Nr=(be=Nr)||Ve,Ya(f,u),Nr=be):Ya(f,u),ko(u),b&8192){if(be=u.memoizedState!==null,(u.stateNode.isHidden=be)&&!Ve&&(u.mode&1)!==0)for(ct=u,Ve=u.child;Ve!==null;){for($e=ct=Ve;ct!==null;){switch(Me=ct,nt=Me.child,Me.tag){case 0:case 11:case 14:case 15:Zf(4,Me,Me.return);break;case 1:ih(Me,Me.return);var dt=Me.stateNode;if(typeof dt.componentWillUnmount=="function"){b=Me,g=Me.return;try{f=b,dt.props=f.memoizedProps,dt.state=f.memoizedState,dt.componentWillUnmount()}catch(gt){us(b,g,gt)}}break;case 5:ih(Me,Me.return);break;case 22:if(Me.memoizedState!==null){R3($e);continue}}nt!==null?(nt.return=Me,ct=nt):R3($e)}Ve=Ve.sibling}e:for(Ve=null,$e=u;;){if($e.tag===5){if(Ve===null){Ve=$e;try{E=$e.stateNode,be?(C=E.style,typeof C.setProperty=="function"?C.setProperty("display","none","important"):C.display="none"):(Z=$e.stateNode,re=$e.memoizedProps.style,B=re!=null&&re.hasOwnProperty("display")?re.display:null,Z.style.display=Qe("display",B))}catch(gt){us(u,u.return,gt)}}}else if($e.tag===6){if(Ve===null)try{$e.stateNode.nodeValue=be?"":$e.memoizedProps}catch(gt){us(u,u.return,gt)}}else if(($e.tag!==22&&$e.tag!==23||$e.memoizedState===null||$e===u)&&$e.child!==null){$e.child.return=$e,$e=$e.child;continue}if($e===u)break e;for(;$e.sibling===null;){if($e.return===null||$e.return===u)break e;Ve===$e&&(Ve=null),$e=$e.return}Ve===$e&&(Ve=null),$e.sibling.return=$e.return,$e=$e.sibling}}break;case 19:Ya(f,u),ko(u),b&4&&I3(u);break;case 21:break;default:Ya(f,u),ko(u)}}function ko(u){var f=u.flags;if(f&2){try{e:{for(var g=u.return;g!==null;){if(E3(g)){var b=g;break e}g=g.return}throw Error(t(160))}switch(b.tag){case 5:var E=b.stateNode;b.flags&32&&(De(E,""),b.flags&=-33);var C=T3(u);p2(u,C,E);break;case 3:case 4:var B=b.stateNode.containerInfo,Z=T3(u);f2(u,Z,B);break;default:throw Error(t(161))}}catch(re){us(u,u.return,re)}u.flags&=-3}f&4096&&(u.flags&=-4097)}function vO(u,f,g){ct=u,C3(u)}function C3(u,f,g){for(var b=(u.mode&1)!==0;ct!==null;){var E=ct,C=E.child;if(E.tag===22&&b){var B=E.memoizedState!==null||wg;if(!B){var Z=E.alternate,re=Z!==null&&Z.memoizedState!==null||Nr;Z=wg;var be=Nr;if(wg=B,(Nr=re)&&!be)for(ct=E;ct!==null;)B=ct,re=B.child,B.tag===22&&B.memoizedState!==null?P3(E):re!==null?(re.return=B,ct=re):P3(E);for(;C!==null;)ct=C,C3(C),C=C.sibling;ct=E,wg=Z,Nr=be}k3(u)}else(E.subtreeFlags&8772)!==0&&C!==null?(C.return=E,ct=C):k3(u)}}function k3(u){for(;ct!==null;){var f=ct;if((f.flags&8772)!==0){var g=f.alternate;try{if((f.flags&8772)!==0)switch(f.tag){case 0:case 11:case 15:Nr||Sg(5,f);break;case 1:var b=f.stateNode;if(f.flags&4&&!Nr)if(g===null)b.componentDidMount();else{var E=f.elementType===f.type?g.memoizedProps:Ka(f.type,g.memoizedProps);b.componentDidUpdate(E,g.memoizedState,b.__reactInternalSnapshotBeforeUpdate)}var C=f.updateQueue;C!==null&&RE(f,C,b);break;case 3:var B=f.updateQueue;if(B!==null){if(g=null,f.child!==null)switch(f.child.tag){case 5:g=f.child.stateNode;break;case 1:g=f.child.stateNode}RE(f,B,g)}break;case 5:var Z=f.stateNode;if(g===null&&f.flags&4){g=Z;var re=f.memoizedProps;switch(f.type){case"button":case"input":case"select":case"textarea":re.autoFocus&&g.focus();break;case"img":re.src&&(g.src=re.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(f.memoizedState===null){var be=f.alternate;if(be!==null){var Ve=be.memoizedState;if(Ve!==null){var $e=Ve.dehydrated;$e!==null&&Fi($e)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(t(163))}Nr||f.flags&512&&h2(f)}catch(Me){us(f,f.return,Me)}}if(f===u){ct=null;break}if(g=f.sibling,g!==null){g.return=f.return,ct=g;break}ct=f.return}}function R3(u){for(;ct!==null;){var f=ct;if(f===u){ct=null;break}var g=f.sibling;if(g!==null){g.return=f.return,ct=g;break}ct=f.return}}function P3(u){for(;ct!==null;){var f=ct;try{switch(f.tag){case 0:case 11:case 15:var g=f.return;try{Sg(4,f)}catch(re){us(f,g,re)}break;case 1:var b=f.stateNode;if(typeof b.componentDidMount=="function"){var E=f.return;try{b.componentDidMount()}catch(re){us(f,E,re)}}var C=f.return;try{h2(f)}catch(re){us(f,C,re)}break;case 5:var B=f.return;try{h2(f)}catch(re){us(f,B,re)}}}catch(re){us(f,f.return,re)}if(f===u){ct=null;break}var Z=f.sibling;if(Z!==null){Z.return=f.return,ct=Z;break}ct=f.return}}var bO=Math.ceil,Eg=M.ReactCurrentDispatcher,m2=M.ReactCurrentOwner,ya=M.ReactCurrentBatchConfig,mn=0,ir=null,Cs=null,gr=0,Gi=0,ah=pc(0),zs=0,ep=null,Du=0,Tg=0,g2=0,tp=null,mi=null,x2=0,oh=1/0,Sl=null,_g=!1,y2=null,bc=null,Ig=!1,wc=null,Ag=0,np=0,v2=null,Cg=-1,kg=0;function Kr(){return(mn&6)!==0?xn():Cg!==-1?Cg:Cg=xn()}function Sc(u){return(u.mode&1)===0?1:(mn&2)!==0&&gr!==0?gr&-gr:sO.transition!==null?(kg===0&&(kg=nc()),kg):(u=Qt,u!==0||(u=window.event,u=u===void 0?16:da(u.type)),u)}function Qa(u,f,g,b){if(50<np)throw np=0,v2=null,Error(t(185));ls(u,g,b),((mn&2)===0||u!==ir)&&(u===ir&&((mn&2)===0&&(Tg|=g),zs===4&&Ec(u,gr)),gi(u,b),g===1&&mn===0&&(f.mode&1)===0&&(oh=xn()+500,sg&&gc()))}function gi(u,f){var g=u.callbackNode;vo(u,f);var b=aa(u,u===ir?gr:0);if(b===0)g!==null&&ia(g),u.callbackNode=null,u.callbackPriority=0;else if(f=b&-b,u.callbackPriority!==f){if(g!=null&&ia(g),f===1)u.tag===0?nO(L3.bind(null,u)):yE(L3.bind(null,u)),Jj(function(){(mn&6)===0&&gc()}),g=null;else{switch(Va(b)){case 1:g=al;break;case 4:g=Oa;break;case 16:g=go;break;case 536870912:g=ol;break;default:g=go}g=B3(g,N3.bind(null,u))}u.callbackPriority=f,u.callbackNode=g}}function N3(u,f){if(Cg=-1,kg=0,(mn&6)!==0)throw Error(t(327));var g=u.callbackNode;if(lh()&&u.callbackNode!==g)return null;var b=aa(u,u===ir?gr:0);if(b===0)return null;if((b&30)!==0||(b&u.expiredLanes)!==0||f)f=Rg(u,b);else{f=b;var E=mn;mn|=2;var C=j3();(ir!==u||gr!==f)&&(Sl=null,oh=xn()+500,Ou(u,f));do try{EO();break}catch(Z){D3(u,Z)}while(!0);Fy(),Eg.current=C,mn=E,Cs!==null?f=0:(ir=null,gr=0,f=zs)}if(f!==0){if(f===2&&(E=Di(u),E!==0&&(b=E,f=b2(u,E))),f===1)throw g=ep,Ou(u,0),Ec(u,b),gi(u,xn()),g;if(f===6)Ec(u,b);else{if(E=u.current.alternate,(b&30)===0&&!wO(E)&&(f=Rg(u,b),f===2&&(C=Di(u),C!==0&&(b=C,f=b2(u,C))),f===1))throw g=ep,Ou(u,0),Ec(u,b),gi(u,xn()),g;switch(u.finishedWork=E,u.finishedLanes=b,f){case 0:case 1:throw Error(t(345));case 2:Mu(u,mi,Sl);break;case 3:if(Ec(u,b),(b&130023424)===b&&(f=x2+500-xn(),10<f)){if(aa(u,0)!==0)break;if(E=u.suspendedLanes,(E&b)!==b){Kr(),u.pingedLanes|=u.suspendedLanes&E;break}u.timeoutHandle=Ay(Mu.bind(null,u,mi,Sl),f);break}Mu(u,mi,Sl);break;case 4:if(Ec(u,b),(b&4194240)===b)break;for(f=u.eventTimes,E=-1;0<b;){var B=31-As(b);C=1<<B,B=f[B],B>E&&(E=B),b&=~C}if(b=E,b=xn()-b,b=(120>b?120:480>b?480:1080>b?1080:1920>b?1920:3e3>b?3e3:4320>b?4320:1960*bO(b/1960))-b,10<b){u.timeoutHandle=Ay(Mu.bind(null,u,mi,Sl),b);break}Mu(u,mi,Sl);break;case 5:Mu(u,mi,Sl);break;default:throw Error(t(329))}}}return gi(u,xn()),u.callbackNode===g?N3.bind(null,u):null}function b2(u,f){var g=tp;return u.current.memoizedState.isDehydrated&&(Ou(u,f).flags|=256),u=Rg(u,f),u!==2&&(f=mi,mi=g,f!==null&&w2(f)),u}function w2(u){mi===null?mi=u:mi.push.apply(mi,u)}function wO(u){for(var f=u;;){if(f.flags&16384){var g=f.updateQueue;if(g!==null&&(g=g.stores,g!==null))for(var b=0;b<g.length;b++){var E=g[b],C=E.getSnapshot;E=E.value;try{if(!Wa(C(),E))return!1}catch{return!1}}}if(g=f.child,f.subtreeFlags&16384&&g!==null)g.return=f,f=g;else{if(f===u)break;for(;f.sibling===null;){if(f.return===null||f.return===u)return!0;f=f.return}f.sibling.return=f.return,f=f.sibling}}return!0}function Ec(u,f){for(f&=~g2,f&=~Tg,u.suspendedLanes|=f,u.pingedLanes&=~f,u=u.expirationTimes;0<f;){var g=31-As(f),b=1<<g;u[g]=-1,f&=~b}}function L3(u){if((mn&6)!==0)throw Error(t(327));lh();var f=aa(u,0);if((f&1)===0)return gi(u,xn()),null;var g=Rg(u,f);if(u.tag!==0&&g===2){var b=Di(u);b!==0&&(f=b,g=b2(u,b))}if(g===1)throw g=ep,Ou(u,0),Ec(u,f),gi(u,xn()),g;if(g===6)throw Error(t(345));return u.finishedWork=u.current.alternate,u.finishedLanes=f,Mu(u,mi,Sl),gi(u,xn()),null}function S2(u,f){var g=mn;mn|=1;try{return u(f)}finally{mn=g,mn===0&&(oh=xn()+500,sg&&gc())}}function ju(u){wc!==null&&wc.tag===0&&(mn&6)===0&&lh();var f=mn;mn|=1;var g=ya.transition,b=Qt;try{if(ya.transition=null,Qt=1,u)return u()}finally{Qt=b,ya.transition=g,mn=f,(mn&6)===0&&gc()}}function E2(){Gi=ah.current,zn(ah)}function Ou(u,f){u.finishedWork=null,u.finishedLanes=0;var g=u.timeoutHandle;if(g!==-1&&(u.timeoutHandle=-1,Xj(g)),Cs!==null)for(g=Cs.return;g!==null;){var b=g;switch(Ly(b),b.tag){case 1:b=b.type.childContextTypes,b!=null&&tg();break;case 3:sh(),zn(hi),zn(kr),Gy();break;case 5:Hy(b);break;case 4:sh();break;case 13:zn(ss);break;case 19:zn(ss);break;case 10:Uy(b.type._context);break;case 22:case 23:E2()}g=g.return}if(ir=u,Cs=u=Tc(u.current,null),gr=Gi=f,zs=0,ep=null,g2=Tg=Du=0,mi=tp=null,Pu!==null){for(f=0;f<Pu.length;f++)if(g=Pu[f],b=g.interleaved,b!==null){g.interleaved=null;var E=b.next,C=g.pending;if(C!==null){var B=C.next;C.next=E,b.next=B}g.pending=b}Pu=null}return u}function D3(u,f){do{var g=Cs;try{if(Fy(),fg.current=xg,pg){for(var b=rs.memoizedState;b!==null;){var E=b.queue;E!==null&&(E.pending=null),b=b.next}pg=!1}if(Lu=0,rr=Bs=rs=null,qf=!1,Yf=0,m2.current=null,g===null||g.return===null){zs=1,ep=f,Cs=null;break}e:{var C=u,B=g.return,Z=g,re=f;if(f=gr,Z.flags|=32768,re!==null&&typeof re=="object"&&typeof re.then=="function"){var be=re,Ve=Z,$e=Ve.tag;if((Ve.mode&1)===0&&($e===0||$e===11||$e===15)){var Me=Ve.alternate;Me?(Ve.updateQueue=Me.updateQueue,Ve.memoizedState=Me.memoizedState,Ve.lanes=Me.lanes):(Ve.updateQueue=null,Ve.memoizedState=null)}var nt=i3(B);if(nt!==null){nt.flags&=-257,a3(nt,B,Z,C,f),nt.mode&1&&r3(C,be,f),f=nt,re=be;var dt=f.updateQueue;if(dt===null){var gt=new Set;gt.add(re),f.updateQueue=gt}else dt.add(re);break e}else{if((f&1)===0){r3(C,be,f),T2();break e}re=Error(t(426))}}else if(Yn&&Z.mode&1){var Ss=i3(B);if(Ss!==null){(Ss.flags&65536)===0&&(Ss.flags|=256),a3(Ss,B,Z,C,f),Oy(rh(re,Z));break e}}C=re=rh(re,Z),zs!==4&&(zs=2),tp===null?tp=[C]:tp.push(C),C=B;do{switch(C.tag){case 3:C.flags|=65536,f&=-f,C.lanes|=f;var ge=n3(C,re,f);kE(C,ge);break e;case 1:Z=re;var ae=C.type,ve=C.stateNode;if((C.flags&128)===0&&(typeof ae.getDerivedStateFromError=="function"||ve!==null&&typeof ve.componentDidCatch=="function"&&(bc===null||!bc.has(ve)))){C.flags|=65536,f&=-f,C.lanes|=f;var Ge=s3(C,Z,f);kE(C,Ge);break e}}C=C.return}while(C!==null)}M3(g)}catch(vt){f=vt,Cs===g&&g!==null&&(Cs=g=g.return);continue}break}while(!0)}function j3(){var u=Eg.current;return Eg.current=xg,u===null?xg:u}function T2(){(zs===0||zs===3||zs===2)&&(zs=4),ir===null||(Du&268435455)===0&&(Tg&268435455)===0||Ec(ir,gr)}function Rg(u,f){var g=mn;mn|=2;var b=j3();(ir!==u||gr!==f)&&(Sl=null,Ou(u,f));do try{SO();break}catch(E){D3(u,E)}while(!0);if(Fy(),mn=g,Eg.current=b,Cs!==null)throw Error(t(261));return ir=null,gr=0,zs}function SO(){for(;Cs!==null;)O3(Cs)}function EO(){for(;Cs!==null&&!rl();)O3(Cs)}function O3(u){var f=V3(u.alternate,u,Gi);u.memoizedProps=u.pendingProps,f===null?M3(u):Cs=f,m2.current=null}function M3(u){var f=u;do{var g=f.alternate;if(u=f.return,(f.flags&32768)===0){if(g=mO(g,f,Gi),g!==null){Cs=g;return}}else{if(g=gO(g,f),g!==null){g.flags&=32767,Cs=g;return}if(u!==null)u.flags|=32768,u.subtreeFlags=0,u.deletions=null;else{zs=6,Cs=null;return}}if(f=f.sibling,f!==null){Cs=f;return}Cs=f=u}while(f!==null);zs===0&&(zs=5)}function Mu(u,f,g){var b=Qt,E=ya.transition;try{ya.transition=null,Qt=1,TO(u,f,g,b)}finally{ya.transition=E,Qt=b}return null}function TO(u,f,g,b){do lh();while(wc!==null);if((mn&6)!==0)throw Error(t(327));g=u.finishedWork;var E=u.finishedLanes;if(g===null)return null;if(u.finishedWork=null,u.finishedLanes=0,g===u.current)throw Error(t(177));u.callbackNode=null,u.callbackPriority=0;var C=g.lanes|g.childLanes;if(Us(u,C),u===ir&&(Cs=ir=null,gr=0),(g.subtreeFlags&2064)===0&&(g.flags&2064)===0||Ig||(Ig=!0,B3(go,function(){return lh(),null})),C=(g.flags&15990)!==0,(g.subtreeFlags&15990)!==0||C){C=ya.transition,ya.transition=null;var B=Qt;Qt=1;var Z=mn;mn|=4,m2.current=null,yO(u,g),A3(g,u),Hj(_y),Vi=!!Ty,_y=Ty=null,u.current=g,vO(g),Li(),mn=Z,Qt=B,ya.transition=C}else u.current=g;if(Ig&&(Ig=!1,wc=u,Ag=E),C=u.pendingLanes,C===0&&(bc=null),Ma(g.stateNode),gi(u,xn()),f!==null)for(b=u.onRecoverableError,g=0;g<f.length;g++)E=f[g],b(E.value,{componentStack:E.stack,digest:E.digest});if(_g)throw _g=!1,u=y2,y2=null,u;return(Ag&1)!==0&&u.tag!==0&&lh(),C=u.pendingLanes,(C&1)!==0?u===v2?np++:(np=0,v2=u):np=0,gc(),null}function lh(){if(wc!==null){var u=Va(Ag),f=ya.transition,g=Qt;try{if(ya.transition=null,Qt=16>u?16:u,wc===null)var b=!1;else{if(u=wc,wc=null,Ag=0,(mn&6)!==0)throw Error(t(331));var E=mn;for(mn|=4,ct=u.current;ct!==null;){var C=ct,B=C.child;if((ct.flags&16)!==0){var Z=C.deletions;if(Z!==null){for(var re=0;re<Z.length;re++){var be=Z[re];for(ct=be;ct!==null;){var Ve=ct;switch(Ve.tag){case 0:case 11:case 15:Zf(8,Ve,C)}var $e=Ve.child;if($e!==null)$e.return=Ve,ct=$e;else for(;ct!==null;){Ve=ct;var Me=Ve.sibling,nt=Ve.return;if(S3(Ve),Ve===be){ct=null;break}if(Me!==null){Me.return=nt,ct=Me;break}ct=nt}}}var dt=C.alternate;if(dt!==null){var gt=dt.child;if(gt!==null){dt.child=null;do{var Ss=gt.sibling;gt.sibling=null,gt=Ss}while(gt!==null)}}ct=C}}if((C.subtreeFlags&2064)!==0&&B!==null)B.return=C,ct=B;else e:for(;ct!==null;){if(C=ct,(C.flags&2048)!==0)switch(C.tag){case 0:case 11:case 15:Zf(9,C,C.return)}var ge=C.sibling;if(ge!==null){ge.return=C.return,ct=ge;break e}ct=C.return}}var ae=u.current;for(ct=ae;ct!==null;){B=ct;var ve=B.child;if((B.subtreeFlags&2064)!==0&&ve!==null)ve.return=B,ct=ve;else e:for(B=ae;ct!==null;){if(Z=ct,(Z.flags&2048)!==0)try{switch(Z.tag){case 0:case 11:case 15:Sg(9,Z)}}catch(vt){us(Z,Z.return,vt)}if(Z===B){ct=null;break e}var Ge=Z.sibling;if(Ge!==null){Ge.return=Z.return,ct=Ge;break e}ct=Z.return}}if(mn=E,gc(),Sn&&typeof Sn.onPostCommitFiberRoot=="function")try{Sn.onPostCommitFiberRoot(xo,u)}catch{}b=!0}return b}finally{Qt=g,ya.transition=f}}return!1}function F3(u,f,g){f=rh(g,f),f=n3(u,f,1),u=yc(u,f,1),f=Kr(),u!==null&&(ls(u,1,f),gi(u,f))}function us(u,f,g){if(u.tag===3)F3(u,u,g);else for(;f!==null;){if(f.tag===3){F3(f,u,g);break}else if(f.tag===1){var b=f.stateNode;if(typeof f.type.getDerivedStateFromError=="function"||typeof b.componentDidCatch=="function"&&(bc===null||!bc.has(b))){u=rh(g,u),u=s3(f,u,1),f=yc(f,u,1),u=Kr(),f!==null&&(ls(f,1,u),gi(f,u));break}}f=f.return}}function _O(u,f,g){var b=u.pingCache;b!==null&&b.delete(f),f=Kr(),u.pingedLanes|=u.suspendedLanes&g,ir===u&&(gr&g)===g&&(zs===4||zs===3&&(gr&130023424)===gr&&500>xn()-x2?Ou(u,0):g2|=g),gi(u,f)}function U3(u,f){f===0&&((u.mode&1)===0?f=1:(f=Ua,Ua<<=1,(Ua&130023424)===0&&(Ua=4194304)));var g=Kr();u=vl(u,f),u!==null&&(ls(u,f,g),gi(u,g))}function IO(u){var f=u.memoizedState,g=0;f!==null&&(g=f.retryLane),U3(u,g)}function AO(u,f){var g=0;switch(u.tag){case 13:var b=u.stateNode,E=u.memoizedState;E!==null&&(g=E.retryLane);break;case 19:b=u.stateNode;break;default:throw Error(t(314))}b!==null&&b.delete(f),U3(u,g)}var V3;V3=function(u,f,g){if(u!==null)if(u.memoizedProps!==f.pendingProps||hi.current)pi=!0;else{if((u.lanes&g)===0&&(f.flags&128)===0)return pi=!1,pO(u,f,g);pi=(u.flags&131072)!==0}else pi=!1,Yn&&(f.flags&1048576)!==0&&vE(f,ig,f.index);switch(f.lanes=0,f.tag){case 2:var b=f.type;bg(u,f),u=f.pendingProps;var E=Qd(f,kr.current);nh(f,g),E=Yy(null,f,b,u,E,g);var C=Qy();return f.flags|=1,typeof E=="object"&&E!==null&&typeof E.render=="function"&&E.$$typeof===void 0?(f.tag=1,f.memoizedState=null,f.updateQueue=null,fi(b)?(C=!0,ng(f)):C=!1,f.memoizedState=E.state!==null&&E.state!==void 0?E.state:null,zy(f),E.updater=yg,f.stateNode=E,E._reactInternals=f,n2(f,b,u,g),f=i2(null,f,b,!0,C,g)):(f.tag=0,Yn&&C&&Ny(f),Gr(null,f,E,g),f=f.child),f;case 16:b=f.elementType;e:{switch(bg(u,f),u=f.pendingProps,E=b._init,b=E(b._payload),f.type=b,E=f.tag=kO(b),u=Ka(b,u),E){case 0:f=r2(null,f,b,u,g);break e;case 1:f=h3(null,f,b,u,g);break e;case 11:f=o3(null,f,b,u,g);break e;case 14:f=l3(null,f,b,Ka(b.type,u),g);break e}throw Error(t(306,b,""))}return f;case 0:return b=f.type,E=f.pendingProps,E=f.elementType===b?E:Ka(b,E),r2(u,f,b,E,g);case 1:return b=f.type,E=f.pendingProps,E=f.elementType===b?E:Ka(b,E),h3(u,f,b,E,g);case 3:e:{if(f3(f),u===null)throw Error(t(387));b=f.pendingProps,C=f.memoizedState,E=C.element,CE(u,f),dg(f,b,null,g);var B=f.memoizedState;if(b=B.element,C.isDehydrated)if(C={element:b,isDehydrated:!1,cache:B.cache,pendingSuspenseBoundaries:B.pendingSuspenseBoundaries,transitions:B.transitions},f.updateQueue.baseState=C,f.memoizedState=C,f.flags&256){E=rh(Error(t(423)),f),f=p3(u,f,b,g,E);break e}else if(b!==E){E=rh(Error(t(424)),f),f=p3(u,f,b,g,E);break e}else for(Wi=fc(f.stateNode.containerInfo.firstChild),Hi=f,Yn=!0,Ga=null,g=IE(f,null,b,g),f.child=g;g;)g.flags=g.flags&-3|4096,g=g.sibling;else{if(Zd(),b===E){f=wl(u,f,g);break e}Gr(u,f,b,g)}f=f.child}return f;case 5:return PE(f),u===null&&jy(f),b=f.type,E=f.pendingProps,C=u!==null?u.memoizedProps:null,B=E.children,Iy(b,E)?B=null:C!==null&&Iy(b,C)&&(f.flags|=32),d3(u,f),Gr(u,f,B,g),f.child;case 6:return u===null&&jy(f),null;case 13:return m3(u,f,g);case 4:return $y(f,f.stateNode.containerInfo),b=f.pendingProps,u===null?f.child=eh(f,null,b,g):Gr(u,f,b,g),f.child;case 11:return b=f.type,E=f.pendingProps,E=f.elementType===b?E:Ka(b,E),o3(u,f,b,E,g);case 7:return Gr(u,f,f.pendingProps,g),f.child;case 8:return Gr(u,f,f.pendingProps.children,g),f.child;case 12:return Gr(u,f,f.pendingProps.children,g),f.child;case 10:e:{if(b=f.type._context,E=f.pendingProps,C=f.memoizedProps,B=E.value,Fn(lg,b._currentValue),b._currentValue=B,C!==null)if(Wa(C.value,B)){if(C.children===E.children&&!hi.current){f=wl(u,f,g);break e}}else for(C=f.child,C!==null&&(C.return=f);C!==null;){var Z=C.dependencies;if(Z!==null){B=C.child;for(var re=Z.firstContext;re!==null;){if(re.context===b){if(C.tag===1){re=bl(-1,g&-g),re.tag=2;var be=C.updateQueue;if(be!==null){be=be.shared;var Ve=be.pending;Ve===null?re.next=re:(re.next=Ve.next,Ve.next=re),be.pending=re}}C.lanes|=g,re=C.alternate,re!==null&&(re.lanes|=g),Vy(C.return,g,f),Z.lanes|=g;break}re=re.next}}else if(C.tag===10)B=C.type===f.type?null:C.child;else if(C.tag===18){if(B=C.return,B===null)throw Error(t(341));B.lanes|=g,Z=B.alternate,Z!==null&&(Z.lanes|=g),Vy(B,g,f),B=C.sibling}else B=C.child;if(B!==null)B.return=C;else for(B=C;B!==null;){if(B===f){B=null;break}if(C=B.sibling,C!==null){C.return=B.return,B=C;break}B=B.return}C=B}Gr(u,f,E.children,g),f=f.child}return f;case 9:return E=f.type,b=f.pendingProps.children,nh(f,g),E=ga(E),b=b(E),f.flags|=1,Gr(u,f,b,g),f.child;case 14:return b=f.type,E=Ka(b,f.pendingProps),E=Ka(b.type,E),l3(u,f,b,E,g);case 15:return c3(u,f,f.type,f.pendingProps,g);case 17:return b=f.type,E=f.pendingProps,E=f.elementType===b?E:Ka(b,E),bg(u,f),f.tag=1,fi(b)?(u=!0,ng(f)):u=!1,nh(f,g),e3(f,b,E),n2(f,b,E,g),i2(null,f,b,!0,u,g);case 19:return x3(u,f,g);case 22:return u3(u,f,g)}throw Error(t(156,f.tag))};function B3(u,f){return ja(u,f)}function CO(u,f,g,b){this.tag=u,this.key=g,this.sibling=this.child=this.return=this.stateNode=this.t
vendor: 5,211 bytes, line 9
9ype=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=f,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=b,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function va(u,f,g,b){return new CO(u,f,g,b)}function _2(u){return u=u.prototype,!(!u||!u.isReactComponent)}function kO(u){if(typeof u=="function")return _2(u)?1:0;if(u!=null){if(u=u.$$typeof,u===z)return 11;if(u===oe)return 14}return 2}function Tc(u,f){var g=u.alternate;return g===null?(g=va(u.tag,f,u.key,u.mode),g.elementType=u.elementType,g.type=u.type,g.stateNode=u.stateNode,g.alternate=u,u.alternate=g):(g.pendingProps=f,g.type=u.type,g.flags=0,g.subtreeFlags=0,g.deletions=null),g.flags=u.flags&14680064,g.childLanes=u.childLanes,g.lanes=u.lanes,g.child=u.child,g.memoizedProps=u.memoizedProps,g.memoizedState=u.memoizedState,g.updateQueue=u.updateQueue,f=u.dependencies,g.dependencies=f===null?null:{lanes:f.lanes,firstContext:f.firstContext},g.sibling=u.sibling,g.index=u.index,g.ref=u.ref,g}function Pg(u,f,g,b,E,C){var B=2;if(b=u,typeof u=="function")_2(u)&&(B=1);else if(typeof u=="string")B=5;else e:switch(u){case I:return Fu(g.children,E,C,f);case k:B=8,E|=8;break;case P:return u=va(12,g,f,E|2),u.elementType=P,u.lanes=C,u;case U:return u=va(13,g,f,E),u.elementType=U,u.lanes=C,u;case fe:return u=va(19,g,f,E),u.elementType=fe,u.lanes=C,u;case Q:return Ng(g,E,C,f);default:if(typeof u=="object"&&u!==null)switch(u.$$typeof){case N:B=10;break e;case F:B=9;break e;case z:B=11;break e;case oe:B=14;break e;case X:B=16,b=null;break e}throw Error(t(130,u==null?u:typeof u,""))}return f=va(B,g,f,E),f.elementType=u,f.type=b,f.lanes=C,f}function Fu(u,f,g,b){return u=va(7,u,b,f),u.lanes=g,u}function Ng(u,f,g,b){return u=va(22,u,b,f),u.elementType=Q,u.lanes=g,u.stateNode={isHidden:!1},u}function I2(u,f,g){return u=va(6,u,null,f),u.lanes=g,u}function A2(u,f,g){return f=va(4,u.children!==null?u.children:[],u.key,f),f.lanes=g,f.stateNode={containerInfo:u.containerInfo,pendingChildren:null,implementation:u.implementation},f}function RO(u,f,g,b,E){this.tag=f,this.containerInfo=u,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=sc(0),this.expirationTimes=sc(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=sc(0),this.identifierPrefix=b,this.onRecoverableError=E,this.mutableSourceEagerHydrationData=null}function C2(u,f,g,b,E,C,B,Z,re){return u=new RO(u,f,g,Z,re),f===1?(f=1,C===!0&&(f|=8)):f=0,C=va(3,null,null,f),u.current=C,C.stateNode=u,C.memoizedState={element:b,isDehydrated:g,cache:null,transitions:null,pendingSuspenseBoundaries:null},zy(C),u}function PO(u,f,g){var b=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:W,key:b==null?null:""+b,children:u,containerInfo:f,implementation:g}}function z3(u){if(!u)return mc;u=u._reactInternals;e:{if(Rn(u)!==u||u.tag!==1)throw Error(t(170));var f=u;do{switch(f.tag){case 3:f=f.stateNode.context;break e;case 1:if(fi(f.type)){f=f.stateNode.__reactInternalMemoizedMergedChildContext;break e}}f=f.return}while(f!==null);throw Error(t(171))}if(u.tag===1){var g=u.type;if(fi(g))return gE(u,g,f)}return f}function $3(u,f,g,b,E,C,B,Z,re){return u=C2(g,b,!0,u,E,C,B,Z,re),u.context=z3(null),g=u.current,b=Kr(),E=Sc(g),C=bl(b,E),C.callback=f??null,yc(g,C,E),u.current.lanes=E,ls(u,E,b),gi(u,b),u}function Lg(u,f,g,b){var E=f.current,C=Kr(),B=Sc(E);return g=z3(g),f.context===null?f.context=g:f.pendingContext=g,f=bl(C,B),f.payload={element:u},b=b===void 0?null:b,b!==null&&(f.callback=b),u=yc(E,f,B),u!==null&&(Qa(u,E,B,C),ug(u,E,B)),B}function Dg(u){return u=u.current,u.child?(u.child.tag===5,u.child.stateNode):null}function H3(u,f){if(u=u.memoizedState,u!==null&&u.dehydrated!==null){var g=u.retryLane;u.retryLane=g!==0&&g<f?g:f}}function k2(u,f){H3(u,f),(u=u.alternate)&&H3(u,f)}function NO(){return null}var W3=typeof reportError=="function"?reportError:function(u){};function R2(u){this._internalRoot=u}jg.prototype.render=R2.prototype.render=function(u){var f=this._internalRoot;if(f===null)throw Error(t(409));Lg(u,f,null,null)},jg.prototype.unmount=R2.prototype.unmount=function(){var u=this._internalRoot;if(u!==null){this._internalRoot=null;var f=u.containerInfo;ju(function(){Lg(null,u,null,null)}),f[ml]=null}};function jg(u){this._internalRoot=u}jg.prototype.unstable_scheduleHydration=function(u){if(u){var f=Su();u={blockedOn:null,target:u,priority:f};for(var g=0;g<Zs.length&&f!==0&&f<Zs[g].priority;g++);Zs.splice(g,0,u),g===0&&Mi(u)}};function P2(u){return!(!u||u.nodeType!==1&&u.nodeType!==9&&u.nodeType!==11)}function Og(u){return!(!u||u.nodeType!==1&&u.nodeType!==9&&u.nodeType!==11&&(u.nodeType!==8||u.nodeValue!==" react-mount-point-unstable "))}function G3(){}function LO(u,f,g,b,E){if(E){if(typeof b=="function"){var C=b;b=function(){var be=Dg(B);C.call(be)}}var B=$3(f,b,u,0,null,!1,!1,"",G3);return u._reactRootContainer=B,u[ml]=B.current,Vf(u.nodeType===8?u.parentNode:u),ju(),B}for(;
9E=u.lastChild;)u.removeChild(E);if(typeof b=="function"){var Z=b;b=function(){var be=Dg(re);Z.call(be)}}var re=C2(u,0,!1,null,null,!1,!1,"",G3);return u._reactRootContainer=re,u[ml]=re.current,Vf(u.nodeType===8?u.parentNode:u),ju(function(){Lg(f,re,g,b)}),re}function Mg(u,f,g,b,E){var C=g._reactRootContainer;if(C){var B=C;if(typeof E=="function"){var Z=E;E=function(){var re=Dg(B);Z.call(re)}}Lg(f,B,u,E)}else B=LO(g,f,u,E,b);return Dg(B)}wu=function(u){switch(u.tag){case 3:var f=u.stateNode;if(f.current.memoizedState.isDehydrated){var g=un(f.pendingLanes);g!==0&&(Hr(f,g|1),gi(f,xn()),(mn&6)===0&&(oh=xn()+500,gc()))}break;case 13:ju(function(){var b=vl(u,1);if(b!==null){var E=Kr();Qa(b,u,1,E)}}),k2(u,1)}},bo=function(u){if(u.tag===13){var f=vl(u,134217728);if(f!==null){var g=Kr();Qa(f,u,134217728,g)}k2(u,134217728)}},rc=function(u){if(u.tag===13){var f=Sc(u),g=vl(u,f);if(g!==null){var b=Kr();Qa(g,u,f,b)}k2(u,f)}},Su=function(){return Qt},Xt=function(u,f){var g=Qt;try{return Qt=u,f()}finally{Qt=g}},Fs=function(u,f,g){switch(f){case"input":if(ft(u,g),f=g.name,g.type==="radio"&&f!=null){for(g=u;g.parentNode;)g=g.parentNode;for(g=g.querySelectorAll("input[name="+JSON.stringify(""+f)+'][type="radio"]'),f=0;f<g.length;f++){var b=g[f];if(b!==u&&b.form===u.form){var E=eg(b);if(!E)throw Error(t(90));ke(b),ft(b,E)}}}break;case"textarea":Dt(u,g);break;case"select":f=g.value,f!=null&&Yt(u,!!g.multiple,f,!1)}},hr=S2,Na=ju;var DO={usingClientEntryPoint:!1,Events:[$f,qd,eg,Qs,Tr,S2]},sp={findFiberByHostInstance:Au,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},jO={bundleType:sp.bundleType,version:sp.version,rendererPackageName:sp.rendererPackageName,rendererConfig:sp.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:M.ReactCurrentDispatcher,findHostInstanceByFiber:function(u){return u=fr(u),u===null?null:u.stateNode},findFiberByHostInstance:sp.findFiberByHostInstance||NO,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Fg=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Fg.isDisabled&&Fg.supportsFiber)try{xo=Fg.inject(jO),Sn=Fg}catch{}}return xi.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=DO,xi.createPortal=function(u,f){var g=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!P2(f))throw Error(t(200));return PO(u,f,null,g)},xi.createRoot=function(u,f){if(!P2(u))throw Error(t(299));var g=!1,b="",E=W3;return f!=null&&(f.unstable_strictMode===!0&&(g=!0),f.identifierPrefix!==void 0&&(b=f.identifierPrefix),f.onRecoverableError!==void 0&&(E=f.onRecoverableError)),f=C2(u,1,!1,null,null,g,!1,b,E),u[ml]=f.current,Vf(u.nodeType===8?u.parentNode:u),new R2(f)},xi.findDOMNode=function(u){if(u==null)return null;if(u.nodeType===1)return u;var f=u._reactInternals;if(f===void 0)throw typeof u.render=="function"?Error(t(188)):(u=Object.keys(u).join(","),Error(t(268,u)));return u=fr(f),u=u===null?null:u.stateNode,u},xi.flushSync=function(u){return ju(u)},xi.hydrate=function(u,f,g){if(!Og(f))throw Error(t(200));return Mg(null,u,f,!0,g)},xi.hydrateRoot=function(u,f,g){if(!P2(u))throw Error(t(405));var b=g!=null&&g.hydratedSources||null,E=!1,C="",B=W3;if(g!=null&&(g.unstable_strictMode===!0&&(E=!0),g.identifierPrefix!==void 0&&(C=g.identifierPrefix),g.onRecoverableError!==void 0&&(B=g.onRecoverableError)),f=$3(f,null,u,1,g??null,E,!1,C,B),u[ml]=f.current,Vf(u),b)for(u=0;u<b.length;u++)g=b[u],E=g._getVersion,E=E(g._source),f.mutableSourceEagerHydrationData==null?f.mutableSourceEagerHydrationData=[g,E]:f.mutableSourceEagerHydrationData.push(g,E);return new jg(f)},xi.render=function(u,f,g){if(!Og(f))throw Error(t(200));return Mg(null,u,f,!1,g)},xi.unmountComponentAtNode=function(u){if(!Og(u))throw Error(t(40));return u._reactRootContainer?(ju(function(){Mg(null,null,u,!1,function(){u._reactRootContainer=null,u[ml]=null})}),!0):!1},xi.unstable_batchedUpdates=S2,xi.unstable_renderSubtreeIntoContainer=function(u,f,g,b){if(!Og(g))throw Error(t(200));if(u==null||u._reactInternals===void 0)throw Error(t(38));return Mg(u,f,g,!1,b)},xi.version="18.3.1-next-f1338f8080-20240426",xi}var tT;function KO(){if(tT)return D2.exports;tT=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch{}}return n(),D2.exports=GO(),D2.exports}var nT;function qO(){if(nT)return Ug;nT=1;var n=KO();return Ug.createRoot=n.createRoot,Ug.hydrateRoot=n.hydrateRoot,Ug}var YO=qO();const QO=x7(YO);var uf=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(n){return this.listeners.add(n),this.onSubscribe(),()=>{this.listeners.delete(n),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},XO=class extends uf{#e;#t;#n;constructor(){super(),this.#n=n=>{if(typeof window<"u"&&window.addEventListener){const e=()=>n();return window.addEventListener("visibilitychange",e,!1),()=>{window.removeEventListener("visibilitychange",e)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(n){this.#n=n,this.#t?.(),this.#t=n(e=>{typeof e=="boolean"?this.setFocused(e):this.onFocus()})}setFocused(n){this.#e!==n&&(this.#e=n,this.onFocus())}onFocus(){const n=this.isFocused();
9this.listeners.forEach(e=>{e(n)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},Kw=new XO,JO={setTimeout:(n,e)=>setTimeout(n,e),clearTimeout:n=>clearTimeout(n),setInterval:(n,e)=>setInterval(n,e),clearInterval:n=>clearInterval(n)},ZO=class{#e=JO;#t=!1;setTimeoutProvider(n){this.#e=n}setTimeout(n,e){return this.#e.setTimeout(n,e)}clearTimeout(n){this.#e.clearTimeout(n)}setInterval(n,e){return this.#e.setInterval(n,e)}clearInterval(n){this.#e.clearInterval(n)}},Xu=new ZO;function eM(n){setTimeout(n,0)}var tM=typeof window>"u"||"Deno"in globalThis;function Yr(){}function nM(n,e){return typeof n=="function"?n(e):n}function ub(n){return typeof n=="number"&&n>=0&&n!==1/0}function y7(n,e){return Math.max(n+(e||0)-Date.now(),0)}function Fc(n,e){return typeof n=="function"?n(e):n}function Xi(n,e){return typeof n=="function"?n(e):n}function sT(n,e){const{type:t="all",exact:s,fetchStatus:r,predicate:i,queryKey:a,stale:l}=n;if(a){if(s){if(e.queryHash!==qw(a,e.options))return!1}else if(!Wp(e.queryKey,a))return!1}if(t!=="all"){const c=e.isActive();if(t==="active"&&!c||t==="inactive"&&c)return!1}return!(typeof l=="boolean"&&e.isStale()!==l||r&&r!==e.state.fetchStatus||i&&!i(e))}function rT(n,e){const{exact:t,status:s,predicate:r,mutationKey:i}=n;if(i){if(!e.options.mutationKey)return!1;if(t){if(pd(e.options.mutationKey)!==pd(i))return!1}else if(!Wp(e.options.mutationKey,i))return!1}return!(s&&e.state.status!==s||r&&!r(e))}function qw(n,e){return(e?.queryKeyHashFn||pd)(n)}function pd(n){return JSON.stringify(n,(e,t)=>db(t)?Object.keys(t).sort().reduce((s,r)=>(s[r]=t[r],s),{}):t)}function Wp(n,e){return n===e?!0:typeof n!=typeof e?!1:n&&e&&typeof n=="object"&&typeof e=="object"?Object.keys(e).every(t=>Wp(n[t],e[t])):!1}var sM=Object.prototype.hasOwnProperty;function v7(n,e,t=0){if(n===e)return n;if(t>500)return e;const s=iT(n)&&iT(e);if(!s&&!(db(n)&&db(e)))return e;const i=(s?n:Object.keys(n)).length,a=s?e:Object.keys(e),l=a.length,c=s?new Array(l):{};let d=0;for(let h=0;h<l;h++){const p=s?h:a[h],m=n[p],y=e[p];if(m===y){c[p]=m,(s?h<i:sM.call(n,p))&&d++;continue}if(m===null||y===null||typeof m!="object"||typeof y!="object"){c[p]=y;continue}const x=v7(m,y,t+1);c[p]=x,x===m&&d++}return i===l&&d===i?n:c}function Y0(n,e){if(!e||Object.keys(n).length!==Object.keys(e).length)return!1;for(const t in n)if(n[t]!==e[t])return!1;return!0}function iT(n){return Array.isArray(n)&&n.length===Object.keys(n).length}function db(n){if(!aT(n))return!1;const e=n.constructor;if(e===void 0)return!0;const t=e.prototype;return!(!aT(t)||!t.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(n)!==Object.prototype)}function aT(n){return Object.prototype.toString.call(n)==="[object Object]"}function rM(n){return new Promise(e=>{Xu.setTimeout(e,n)})}function hb(n,e,t){return typeof t.structuralSharing=="function"?t.structuralSharing(n,e):t.structuralSharing!==!1?v7(n,e):e}function iM(n,e,t=0){const s=[...n,e];return t&&s.length>t?s.slice(1):s}function aM(n,e,t=0){const s=[e,...n];return t&&s.length>t?s.slice(0,-1):s}var Yw=Symbol();function b7(n,e){return!n.queryFn&&e?.initialPromise?()=>e.initialPromise:!n.queryFn||n.queryFn===Yw?()=>Promise.reject(new Error(`Missing queryFn: '${n.queryHash}'`)):n.queryFn}function Qw(n,e){return typeof n=="function"?n(...e):!!n}function oM(n,e,t){let s=!1,r;return Object.defineProperty(n,"signal",{enumerable:!0,get:()=>(r??=e(),s||(s=!0,r.aborted?t():r.addEventListener("abort",t,{once:!0})),r)}),n}var Gp=(()=>{let n=()=>tM;return{isServer(){return n()},setIsServer(e){n=e}}})();function fb(){let n,e;const t=new Promise((r,i)=>{n=r,e=i});t.status="pending",t.catch(()=>{});function s(r){Object.assign(t,r),delete t.resolve,delete t.reject}return t.resolve=r=>{s({status:"fulfilled",value:r}),n(r)},t.reject=r=>{s({status:"rejected",reason:r}),e(r)},t}var lM=eM;function cM(){let n=[],e=0,t=l=>{l()},s=l=>{l()},r=lM;const i=l=>{e?n.push(l):r(()=>{t(l)})},a=()=>{const l=n;n=[],l.length&&r(()=>{s(()=>{l.forEach(c=>{t(c)})})})};return{batch:l=>{let c;e++;try{c=l()}finally{e--,e||a()}return c},batchCalls:l=>(...c)=>{i(()=>{l(...c)})},schedule:i,setNotifyFunction:l=>{t=l},setBatchNotifyFunction:l=>{s=l},setScheduler:l=>{r=l}}}var Ks=cM(),uM=class extends uf{#e=!0;#t;#n;constructor(){super(),this.#n=n=>{if(typeof window<"u"&&window.addEventListener){const e=()=>n(!0),t=()=>n(!1);return window.addEventListener("online",e,!1),window.addEventListener("offline",t,!1),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(n){this.#n=n,this.#t?.(),this.#t=n(this.setOnline.bind(this))}
9setOnline(n){this.#e!==n&&(this.#e=n,this.listeners.forEach(t=>{t(n)}))}isOnline(){return this.#e}},Q0=new uM;function dM(n){return Math.min(1e3*2**n,3e4)}function w7(n){return(n??"online")==="online"?Q0.isOnline():!0}var pb=class extends Error{constructor(n){super("CancelledError"),this.revert=n?.revert,this.silent=n?.silent}};function S7(n){let e=!1,t=0,s;const r=fb(),i=()=>r.status!=="pending",a=w=>{if(!i()){const S=new pb(w);m(S),n.onCancel?.(S)}},l=()=>{e=!0},c=()=>{e=!1},d=()=>Kw.isFocused()&&(n.networkMode==="always"||Q0.isOnline())&&n.canRun(),h=()=>w7(n.networkMode)&&n.canRun(),p=w=>{i()||(s?.(),r.resolve(w))},m=w=>{i()||(s?.(),r.reject(w))},y=()=>new Promise(w=>{s=S=>{(i()||d())&&w(S)},n.onPause?.()}).then(()=>{s=void 0,i()||n.onContinue?.()}),x=()=>{if(i())return;let w;const S=t===0?n.initialPromise:void 0;try{w=S??n.fn()}catch(_){w=Promise.reject(_)}Promise.resolve(w).then(p).catch(_=>{if(i())return;const L=n.retry??(Gp.isServer()?0:3),R=n.retryDelay??dM,M=typeof R=="function"?R(t,_):R,V=L===!0||typeof L=="number"&&t<L||typeof L=="function"&&L(t,_);if(e||!V){m(_);return}t++,n.onFail?.(t,_),rM(M).then(()=>d()?void 0:y()).then(()=>{e?m(_):x()})})};return{promise:r,status:()=>r.status,cancel:a,continue:()=>(s?.(),r),cancelRetry:l,continueRetry:c,canStart:h,start:()=>(h()?x():y().then(x),r)}}var E7=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),ub(this.gcTime)&&(this.#e=Xu.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(n){this.gcTime=Math.max(this.gcTime||0,n??(Gp.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e!==void 0&&(Xu.clearTimeout(this.#e),this.#e=void 0)}};function hM(n){return{onFetch:(e,t)=>{const s=e.options,r=e.fetchOptions?.meta?.fetchMore?.direction,i=e.state.data?.pages||[],a=e.state.data?.pageParams||[];let l={pages:[],pageParams:[]},c=0;const d=async()=>{let h=!1;const p=x=>{oM(x,()=>e.signal,()=>h=!0)},m=b7(e.options,e.fetchOptions),y=async(x,w,S)=>{if(h)return Promise.reject(e.signal.reason);if(w==null&&x.pages.length)return Promise.resolve(x);const L=(()=>{const W={client:e.client,queryKey:e.queryKey,pageParam:w,direction:S?"backward":"forward",meta:e.options.meta};return p(W),W})(),R=await m(L),{maxPages:M}=e.options,V=S?aM:iM;return{pages:V(x.pages,R,M),pageParams:V(x.pageParams,w,M)}};if(r&&i.length){const x=r==="backward",w=x?fM:oT,S={pages:i,pageParams:a},_=w(s,S);l=await y(S,_,x)}else{const x=n??i.length;do{const w=c===0?a[0]??s.initialPageParam:oT(s,l);if(c>0&&w==null)break;l=await y(l,w),c++}while(c<x)}return l};e.options.persister?e.fetchFn=()=>e.options.persister?.(d,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},t):e.fetchFn=d}}}function oT(n,{pages:e,pageParams:t}){const s=e.length-1;return e.length>0?n.getNextPageParam(e[s],e,t[s],t):void 0}function fM(n,{pages:e,pageParams:t}){return e.length>0?n.getPreviousPageParam?.(e[0],e,t[0],t):void 0}var pM=class extends E7{#e;#t;#n;#s;#i;#r;#o;#a;constructor(e){super(),this.#a=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#s=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=cT(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#r?.promise}setOptions(e){if(this.options={...this.#o,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const t=cT(this.options);t.data!==void 0&&(this.setState(lT(t.data,t.dataUpdatedAt)),this.#t=t)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#s.remove(this)}setData(e,t){const s=hb(this.state.data,e,this.options);return this.#l({data:s,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),s}setState(e){this.#l({type:"setState",state:e})}cancel(e){const t=this.#r?.promise;return this.#r?.cancel(e),t?t.then(Yr).catch(Yr):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>Xi(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Yw||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdate
9Count>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>Fc(e.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e==="static"?!1:this.state.isInvalidated?!0:!y7(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(t=>t.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#r?.continue()}onOnline(){this.observers.find(t=>t.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#r?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#s.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#r&&(this.#a||this.#u()?this.#r.cancel({revert:!0}):this.#r.cancelRetry()),this.scheduleGc()),this.#s.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}#u(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"}invalidate(){this.state.isInvalidated||this.#l({type:"invalidate"})}async fetch(e,t){if(this.state.fetchStatus!=="idle"&&this.#r?.status()!=="rejected"){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#r)return this.#r.continueRetry(),this.#r.promise}if(e&&this.setOptions(e),!this.options.queryFn){const d=this.observers.find(h=>h.options.queryFn);d&&this.setOptions(d.options)}const s=new AbortController,r=d=>{Object.defineProperty(d,"signal",{enumerable:!0,get:()=>(this.#a=!0,s.signal)})},i=()=>{const d=b7(this.options,t),p=(()=>{const m={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(m),m})();return this.#a=!1,this.options.persister?this.options.persister(d,p,this):d(p)},l=(()=>{const d={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(d),d})();(this.#e==="infinite"?hM(this.options.pages):this.options.behavior)?.onFetch(l,this),this.#n=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==l.fetchOptions?.meta)&&this.#l({type:"fetch",meta:l.fetchOptions?.meta}),this.#r=S7({initialPromise:t?.initialPromise,fn:l.fetchFn,onCancel:d=>{d instanceof pb&&d.revert&&this.setState({...this.#n,fetchStatus:"idle"}),s.abort()},onFail:(d,h)=>{this.#l({type:"failed",failureCount:d,error:h})},onPause:()=>{this.#l({type:"pause"})},onContinue:()=>{this.#l({type:"continue"})},retry:l.options.retry,retryDelay:l.options.retryDelay,networkMode:l.options.networkMode,canRun:()=>!0});try{const d=await this.#r.start();if(d===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(d),this.#s.config.onSuccess?.(d,this),this.#s.config.onSettled?.(d,this.state.error,this),d}catch(d){if(d instanceof pb){if(d.silent)return this.#r.promise;if(d.revert){if(this.state.data===void 0)throw d;return this.state.data}}throw this.#l({type:"error",error:d}),this.#s.config.onError?.(d,this),this.#s.config.onSettled?.(this.state.data,d,this),d}finally{this.scheduleGc()}}#l(e){const t=s=>{switch(e.type){case"failed":return{...s,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...s,fetchStatus:"paused"};case"continue":return{...s,fetchStatus:"fetching"};case"fetch":return{...s,...T7(s.data,this.options),fetchMeta:e.meta??null};case"success":const r={...s,...lT(e.data,e.dataUpdatedAt),dataUpdateCount:s.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?r:void 0,r;case"error":const i=e.error;return{...s,error:i,errorUpdateCount:s.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:s.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...s,isInvalidated:!0};case"setState":return{...s,...e.state}}};this.state=t(this.state),Ks.batch(()=>{this.observers.forEach(s=>{s.onQueryUpdate()}),this.#s.notify({query:this,type:"updated",action:e})})}};function T7(n,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:w7(e.networkMode)?"fetching":"paused",...n===void 0&&{error:null,status:"pending"}}}function lT(n,e){return{data:n,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function cT(n){const e=typeof n.initialData=="function"?n.initialData():n.initialData,t=e!==void 0,s=t?typeof n.initialDataUpdatedAt=="function"?n.initialDataUpdatedAt():n.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:t?s??Date.now():0,error:null,errorUpdate
9Count:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:t?"success":"pending",fetchStatus:"idle"}}var mM=class extends uf{constructor(n,e){super(),this.options=e,this.#e=n,this.#a=null,this.#o=fb(),this.bindMethods(),this.setOptions(e)}#e;#t=void 0;#n=void 0;#s=void 0;#i;#r;#o;#a;#u;#l;#p;#d;#h;#c;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),uT(this.#t,this.options)?this.#f():this.updateResult(),this.#v())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return mb(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return mb(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#w(),this.#t.removeObserver(this)}setOptions(n){const e=this.options,t=this.#t;if(this.options=this.#e.defaultQueryOptions(n),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Xi(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#S(),this.#t.setOptions(this.options),e._defaulted&&!Y0(this.options,e)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const s=this.hasListeners();s&&dT(this.#t,t,this.options,e)&&this.#f(),this.updateResult(),s&&(this.#t!==t||Xi(this.options.enabled,this.#t)!==Xi(e.enabled,this.#t)||Fc(this.options.staleTime,this.#t)!==Fc(e.staleTime,this.#t))&&this.#g();const r=this.#x();s&&(this.#t!==t||Xi(this.options.enabled,this.#t)!==Xi(e.enabled,this.#t)||r!==this.#c)&&this.#y(r)}getOptimisticResult(n){const e=this.#e.getQueryCache().build(this.#e,n),t=this.createResult(e,n);return xM(this,t)&&(this.#s=t,this.#r=this.options,this.#i=this.#t.state),t}getCurrentResult(){return this.#s}trackResult(n,e){return new Proxy(n,{get:(t,s)=>(this.trackProp(s),e?.(s),s==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#o.status==="pending"&&this.#o.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(t,s))})}trackProp(n){this.#m.add(n)}getCurrentQuery(){return this.#t}refetch({...n}={}){return this.fetch({...n})}fetchOptimistic(n){const e=this.#e.defaultQueryOptions(n),t=this.#e.getQueryCache().build(this.#e,e);return t.fetch().then(()=>this.createResult(t,e))}fetch(n){return this.#f({...n,cancelRefetch:n.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#s))}#f(n){this.#S();let e=this.#t.fetch(this.options,n);return n?.throwOnError||(e=e.catch(Yr)),e}#g(){this.#b();const n=Fc(this.options.staleTime,this.#t);if(Gp.isServer()||this.#s.isStale||!ub(n))return;const t=y7(this.#s.dataUpdatedAt,n)+1;this.#d=Xu.setTimeout(()=>{this.#s.isStale||this.updateResult()},t)}#x(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#y(n){this.#w(),this.#c=n,!(Gp.isServer()||Xi(this.options.enabled,this.#t)===!1||!ub(this.#c)||this.#c===0)&&(this.#h=Xu.setInterval(()=>{(this.options.refetchIntervalInBackground||Kw.isFocused())&&this.#f()},this.#c))}#v(){this.#g(),this.#y(this.#x())}#b(){this.#d!==void 0&&(Xu.clearTimeout(this.#d),this.#d=void 0)}#w(){this.#h!==void 0&&(Xu.clearInterval(this.#h),this.#h=void 0)}createResult(n,e){const t=this.#t,s=this.options,r=this.#s,i=this.#i,a=this.#r,c=n!==t?n.state:this.#n,{state:d}=n;let h={...d},p=!1,m;if(e._optimisticResults){const k=this.hasListeners(),P=!k&&uT(n,e),N=k&&dT(n,t,e,s);(P||N)&&(h={...h,...T7(d.data,n.options)}),e._optimisticResults==="isRestoring"&&(h.fetchStatus="idle")}let{error:y,errorUpdatedAt:x,status:w}=h;m=h.data;let S=!1;if(e.placeholderData!==void 0&&m===void 0&&w==="pending"){let k;r?.isPlaceholderData&&e.placeholderData===a?.placeholderData?(k=r.data,S=!0):k=typeof e.placeholderData=="function"?e.placeholderData(this.#p?.state.data,this.#p):e.placeholderData,k!==void 0&&(w="success",m=hb(r?.data,k,e),p=!0)}if(e.select&&m!==void 0&&!S)if(r&&m===i?.data&&e.select===this.#u)m=this.#l;else try{this.#u=e.select,m=e.select(m),m=hb(r?.data,m,e),this.#l=m,this.#a=null}catch(k){this.#a=k}this.#a&&(y=this.#a,m=this.#l,x=Date.now(),w="error");const _=h.fetchStatus==="fetching",L=w==="pending",R=w==="error",M=L&&_,V=m!==void 0,I={status:w,fetchStatus:h.fetchStatus,isPending:L,isSuccess:w==="success",isError:R,isInitialLoading:M,isLoading:M,data:m,dataUpdatedAt:h.dataUpdatedAt,error:y,errorUpdatedAt:x,failureCount:h.fetchFailureCount,failureReason:h.fetchFailureReason,errorUpdate
9Count:h.errorUpdateCount,isFetched:n.isFetched(),isFetchedAfterMount:h.dataUpdateCount>c.dataUpdateCount||h.errorUpdateCount>c.errorUpdateCount,isFetching:_,isRefetching:_&&!L,isLoadingError:R&&!V,isPaused:h.fetchStatus==="paused",isPlaceholderData:p,isRefetchError:R&&V,isStale:Xw(n,e),refetch:this.refetch,promise:this.#o,isEnabled:Xi(e.enabled,n)!==!1};if(this.options.experimental_prefetchInRender){const k=I.data!==void 0,P=I.status==="error"&&!k,N=U=>{P?U.reject(I.error):k&&U.resolve(I.data)},F=()=>{const U=this.#o=I.promise=fb();N(U)},z=this.#o;switch(z.status){case"pending":n.queryHash===t.queryHash&&N(z);break;case"fulfilled":(P||I.data!==z.value)&&F();break;case"rejected":(!P||I.error!==z.reason)&&F();break}}return I}updateResult(){const n=this.#s,e=this.createResult(this.#t,this.options);if(this.#i=this.#t.state,this.#r=this.options,this.#i.data!==void 0&&(this.#p=this.#t),Y0(e,n))return;this.#s=e;const t=()=>{if(!n)return!0;const{notifyOnChangeProps:s}=this.options,r=typeof s=="function"?s():s;if(r==="all"||!r&&!this.#m.size)return!0;const i=new Set(r??this.#m);return this.options.throwOnError&&i.add("error"),Object.keys(this.#s).some(a=>{const l=a;return this.#s[l]!==n[l]&&i.has(l)})};this.#E({listeners:t()})}#S(){const n=this.#e.getQueryCache().build(this.#e,this.options);if(n===this.#t)return;const e=this.#t;this.#t=n,this.#n=n.state,this.hasListeners()&&(e?.removeObserver(this),n.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#v()}#E(n){Ks.batch(()=>{n.listeners&&this.listeners.forEach(e=>{e(this.#s)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function gM(n,e){return Xi(e.enabled,n)!==!1&&n.state.data===void 0&&!(n.state.status==="error"&&Xi(e.retryOnMount,n)===!1)}function uT(n,e){return gM(n,e)||n.state.data!==void 0&&mb(n,e,e.refetchOnMount)}function mb(n,e,t){if(Xi(e.enabled,n)!==!1&&Fc(e.staleTime,n)!=="static"){const s=typeof t=="function"?t(n):t;return s==="always"||s!==!1&&Xw(n,e)}return!1}function dT(n,e,t,s){return(n!==e||Xi(s.enabled,n)===!1)&&(!t.suspense||n.state.status!=="error")&&Xw(n,t)}function Xw(n,e){return Xi(e.enabled,n)!==!1&&n.isStaleByTime(Fc(e.staleTime,n))}function xM(n,e){return!Y0(n.getCurrentResult(),e)}var yM=class extends E7{#e;#t;#n;#s;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||_7(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#n.remove(this))}continue(){return this.#s?.continue()??this.execute(this.state.variables)}async execute(e){const t=()=>{this.#i({type:"continue"})},s={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#s=S7({fn:()=>this.options.mutationFn?this.options.mutationFn(e,s):Promise.reject(new Error("No mutationFn found")),onFail:(a,l)=>{this.#i({type:"failed",failureCount:a,error:l})},onPause:()=>{this.#i({type:"pause"})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});const r=this.state.status==="pending",i=!this.#s.canStart();try{if(r)t();else{this.#i({type:"pending",variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,s);const l=await this.options.onMutate?.(e,s);l!==this.state.context&&this.#i({type:"pending",context:l,variables:e,isPaused:i})}const a=await this.#s.start();return await this.#n.config.onSuccess?.(a,e,this.state.context,this,s),await this.options.onSuccess?.(a,e,this.state.context,s),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,s),await this.options.onSettled?.(a,null,e,this.state.context,s),this.#i({type:"success",data:a}),a}catch(a){try{await this.#n.config.onError?.(a,e,this.state.context,this,s)}catch(l){Promise.reject(l)}try{await this.options.onError?.(a,e,this.state.context,s)}catch(l){Promise.reject(l)}try{await this.#n.config.onSettled?.(void 0,a,this.state.variables,this.state.context,this,s)}catch(l){Promise.reject(l)}try{await this.options.onSettled?.(void 0,a,e,this.state.context,s)}catch(l){Promise.reject(l)}throw this.#i({type:"error",error:a}),a}finally{this.#n.runNext(this)}}#i(e){const t=s=>{switch(e.type){case"failed":return{...s,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...s,isPaused:!0};case"continue":return{...s,isPaused:!1};
9case"pending":return{...s,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...s,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...s,data:void 0,error:e.error,failureCount:s.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=t(this.state),Ks.batch(()=>{this.#t.forEach(s=>{s.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:"updated",action:e})})}};function _7(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var vM=class extends uf{constructor(n={}){super(),this.config=n,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(n,e,t){const s=new yM({client:n,mutationCache:this,mutationId:++this.#n,options:n.defaultMutationOptions(e),state:t});return this.add(s),s}add(n){this.#e.add(n);const e=Vg(n);if(typeof e=="string"){const t=this.#t.get(e);t?t.push(n):this.#t.set(e,[n])}this.notify({type:"added",mutation:n})}remove(n){if(this.#e.delete(n)){const e=Vg(n);if(typeof e=="string"){const t=this.#t.get(e);if(t)if(t.length>1){const s=t.indexOf(n);s!==-1&&t.splice(s,1)}else t[0]===n&&this.#t.delete(e)}}this.notify({type:"removed",mutation:n})}canRun(n){const e=Vg(n);if(typeof e=="string"){const s=this.#t.get(e)?.find(r=>r.state.status==="pending");return!s||s===n}else return!0}runNext(n){const e=Vg(n);return typeof e=="string"?this.#t.get(e)?.find(s=>s!==n&&s.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){Ks.batch(()=>{this.#e.forEach(n=>{this.notify({type:"removed",mutation:n})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(n){const e={exact:!0,...n};return this.getAll().find(t=>rT(e,t))}findAll(n={}){return this.getAll().filter(e=>rT(n,e))}notify(n){Ks.batch(()=>{this.listeners.forEach(e=>{e(n)})})}resumePausedMutations(){const n=this.getAll().filter(e=>
9e.state.isPaused);return Ks.batch(()=>Promise.all(n.map(e=>e.continue().catch(Yr))))}};function Vg(n){return n.options.scope?.id}var bM=class extends uf{#e;#t=void 0;#n;#s;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){const t=this.options;this.options=this.#e.defaultMutationOptions(e),Y0(this.options,t)||this.#e.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&pd(t.mutationKey)!==pd(this.options.mutationKey)?this.reset():this.#n?.state.status==="pending"&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#r(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#r()}mutate(e,t){return this.#s=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){const e=this.#n?.state??_7();this.#t={...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset}}#r(e){Ks.batch(()=>{if(this.#s&&this.hasListeners()){const t=this.#t.variables,s=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type==="success"){try{this.#s.onSuccess?.(e.data,t,s,r)}catch(i){Promise.reject(i)}try{this.#s.onSettled?.(e.data,null,t,s,r)}catch(i){Promise.reject(i)}}else if(e?.type==="error"){try{this.#s.onError?.(e.error,t,s,r)}catch(i){Promise.reject(i)}try{this.#s.onSettled?.(void 0,e.error,t,s,r)}catch(i){Promise.reject(i)}}}this.listeners.forEach(t=>{t(this.#t)})})}},wM=class extends uf{constructor(n={}){super(),this.config=n,this.#e=new Map}#e;build(n,e,t){const s=e.queryKey,r=e.queryHash??qw(s,e);let i=this.get(r);return i||(i=new pM({client:n,queryKey:s,queryHash:r,options:n.defaultQueryOptions(e),state:t,defaultOptions:n.getQueryDefaults(s)}),this.add(i)),i}add(n){this.#e.has(n.queryHash)||(this.#e.set(n.queryHash,n),this.notify({type:"added",query:n}))}remove(n){const e=this.#e.get(n.queryHash);e&&(n.destroy(),e===n&&this.#e.delete(n.queryHash),this.notify({type:"removed",query:n}))}clear(){Ks.batch(()=>{this.getAll().forEach(n=>{this.remove(n)})})}get(n){return this.#e.get(n)}getAll(){return[...this.#e.values()]}find(n){const e={exact:!0,...n};return this.getAll().find(t=>sT(e,t))}findAll(n={}){const e=this.getAll();return Object.keys(n).length>0?e.filter(t=>sT(n,t)):e}notify(n){Ks.batch(()=>{this.listeners.forEach(e=>{e(n)})})}onFocus(){Ks.batch(()=>{this.getAll().forEach(n=>{n.onFocus()})})}onOnline(){Ks.batch(()=>{this.getAll().forEach(n=>{n.onOnline()})})}},SM=class{#e;#t;#n;#s;#i;#r;#o;#a;constructor(n={}){this.#e=n.queryCache||new wM,this.#t=n.mutationCache||new vM,this.#n=n.defaultOptions||{},this.#s=new Map,this.#i=new Map,this.#r=0}mount(){this.#r++,this.#r===1&&(this.#o=Kw.subscribe(async n=>{n&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#a=Q0.subscribe(async n=>{n&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#r--,this.#r===0&&(this.#o?.(),this.#o=void 0,this.#a?.(),this.#a=void 0)}isFetching(n){return this.#e.findAll({...n,fetchStatus:"fetching"}).length}isMutating(n){return this.#t.findAll({...n,status:"pending"}).length}getQueryData(n){const e=this.defaultQueryOptions({queryKey:n});return this.#e.get(e.queryHash)?.state.data}ensureQueryData(n){const e=this.defaultQueryOptions(n),t=this.#e.build(this,e),s=t.state.data;return s===void 0?this.fetchQuery(n):(n.revalidateIfStale&&t.isStaleByTime(Fc(e.staleTime,t))&&this.prefetchQuery(e),Promise.resolve(s))}getQueriesData(n){return this.#e.findAll(n).map(({queryKey:e,state:t})=>{const s=t.data;return[e,s]})}setQueryData(n,e,t){const s=this.defaultQueryOptions({queryKey:n}),i=this.#e.get(s.queryHash)?.state.data,a=nM(e,i);if(a!==void 0)return this.#e.build(this,s).setData(a,{...t,manual:!0})}
9setQueriesData(n,e,t){return Ks.batch(()=>this.#e.findAll(n).map(({queryKey:s})=>[s,this.setQueryData(s,e,t)]))}getQueryState(n){const e=this.defaultQueryOptions({queryKey:n});return this.#e.get(e.queryHash)?.state}removeQueries(n){const e=this.#e;Ks.batch(()=>{e.findAll(n).forEach(t=>{e.remove(t)})})}resetQueries(n,e){const t=this.#e;return Ks.batch(()=>(t.findAll(n).forEach(s=>{s.reset()}),this.refetchQueries({type:"active",...n},e)))}cancelQueries(n,e={}){const t={revert:!0,...e},s=Ks.batch(()=>this.#e.findAll(n).map(r=>r.cancel(t)));return Promise.all(s).then(Yr).catch(Yr)}invalidateQueries(n,e={}){return Ks.batch(()=>(this.#e.findAll(n).forEach(t=>{t.invalidate()}),n?.refetchType==="none"?Promise.resolve():this.refetchQueries({...n,type:n?.refetchType??n?.type??"active"},e)))}refetchQueries(n,e={}){const t={...e,cancelRefetch:e.cancelRefetch??!0},s=Ks.batch(()=>this.#e.findAll(n).filter(r=>!r.isDisabled()&&!r.isStatic()).map(r=>{let i=r.fetch(void 0,t);return t.throwOnError||(i=i.catch(Yr)),r.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(s).then(Yr)}fetchQuery(n){const e=this.defaultQueryOptions(n);e.retry===void 0&&(e.retry=!1);const t=this.#e.build(this,e);return t.isStaleByTime(Fc(e.staleTime,t))?t.fetch(e):Promise.resolve(t.state.data)}prefetchQuery(n){return this.fetchQuery(n).then(Yr).catch(Yr)}fetchInfiniteQuery(n){return n._type="infinite",this.fetchQuery(n)}prefetchInfiniteQuery(n){return this.fetchInfiniteQuery(n).then(Yr).catch(Yr)}ensureInfiniteQueryData(n){return n._type="infinite",this.ensureQueryData(n)}resumePausedMutations(){return Q0.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(n){this.#n=n}setQueryDefaults(n,e){this.#s.set(pd(n),{queryKey:n,defaultOptions:e})}getQueryDefaults(n){const e=[...this.#s.values()],t={};return e.forEach(s=>{Wp(n,s.queryKey)&&Object.assign(t,s.defaultOptions)}),t}setMutationDefaults(n,e){this.#i.set(pd(n),{mutationKey:n,defaultOptions:e})}getMutationDefaults(n){const e=[...this.#i.values()],t={};return e.forEach(s=>{Wp(n,s.mutationKey)&&Object.assign(t,s.defaultOptions)}),t}defaultQueryOptions(n){if(n._defaulted)return n;const e={...this.#n.queries,...this.getQueryDefaults(n.queryKey),...n,_defaulted:!0};return e.queryHash||(e.queryHash=qw(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===Yw&&(e.enabled=!1),e}defaultMutationOptions(n){return n?._defaulted?n:{...this.#n.mutations,...n?.mutationKey&&this.getMutationDefaults(n.mutationKey),...n,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},I7=T.createContext(void 0),sx=n=>{const e=T.useContext(I7);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},EM=({client:n,children:e})=>(T.useEffect(()=>(n.mount(),()=>{n.unmount()}),[n]),o.jsx(I7.Provider,{value:n,children:e})),A7=T.createContext(!1),TM=()=>T.useContext(A7);A7.Provider;function _M(){let n=!1;return{clearReset:()=>{n=!1},reset:()=>{n=!0},isReset:()=>n}}var IM=T.createContext(_M()),AM=()=>T.useContext(IM),CM=(n,e,t)=>{const s=t?.state.error&&typeof n.throwOnError=="function"?Qw(n.throwOnError,[t.state.error,t]):n.throwOnError;(n.suspense||n.experimental_prefetchInRender||s)&&(e.isReset()||(n.retryOnMount=!1))},kM=n=>{T.useEffect(()=>{n.clearReset()},[n])},RM=({result:n,errorResetBoundary:e,throwOnError:t,query:s,suspense:r})=>n.isError&&!e.isReset()&&!n.isFetching&&s&&(r&&n.data===void 0||Qw(t,[n.error,s])),PM=n=>{if(n.suspense){const t=r=>r==="static"?r:Math.max(r??1e3,1e3),s=n.staleTime;n.staleTime=typeof s=="function"?(...r)=>t(s(...r)):t(s),typeof n.gcTime=="number"&&(n.gcTime=Math.max(n.gcTime,1e3))}},NM=(n,e)=>n.isLoading&&n.isFetching&&!e,LM=(n,e)=>n?.suspense&&e.isPending,hT=(n,e,t)=>e.fetchOptimistic(n).catch(()=>{t.clearReset()});function DM(n,e,t){const s=TM(),r=AM(),i=sx(),a=i.defaultQueryOptions(n);i.getDefaultOptions().queries?._experimental_beforeQuery?.(a);const l=i.getQueryCache().get(a.queryHash),c=n.subscribed!==!1;a._optimisticResults=s?"isRestoring":c?"optimistic":void 0,PM(a),CM(a,r,l),kM(r);const d=!i.getQueryCache().get(a.queryHash),[h]=T.useState(()=>new e(i,a)),p=h.getOptimisticResult(a),m=!s&&c;if(T.useSyncExternalStore(T.useCallback(y=>{const x=m?h.subscribe(Ks.batchCalls(y)):Yr;return h.updateResult(),x},[h,m]),()=>h.getCurrentResult(),()=>h.getCurrentResult()),T.useEffect(()=>{h.setOptions(a)},[a,h]),LM(a,p))throw hT(a,h,r);if(RM({result:p,errorResetBoundary:r,throwOnError:a.throwOnError,query:l,suspense:a.suspense}))throw p.error;return i.getDefaultOptions().queries?._experimental_afterQuery?.(a,p),a.experimental_prefetchInRender&&!Gp.isServer()&&NM(
9p,s)&&(d?hT(a,h,r):l?.promise)?.catch(Yr).finally(()=>{h.updateResult()}),a.notifyOnChangeProps?p:h.trackResult(p)}function gn(n,e){return DM(n,mM)}function C7(n,e){const t=sx(),[s]=T.useState(()=>new bM(t,n));T.useEffect(()=>{s.setOptions(n)},[s,n]);const r=T.useSyncExternalStore(T.useCallback(a=>s.subscribe(Ks.batchCalls(a)),[s]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),i=T.useCallback((a,l)=>{s.mutate(a,l).catch(Yr)},[s]);if(r.error&&Qw(s.options.throwOnError,[r.error]))throw r.error;return{...r,mutate:i,mutateAsync:r.mutate}}function jM(n,e){if(n instanceof RegExp)return{keys:!1,pattern:n};var t,s,r,i,a=[],l="",c=n.split("/");for(c[0]||c.shift();r=c.shift();)t=r[0],t==="*"?(a.push(t),l+=r[1]==="?"?"(?:/(.*))?":"/(.*)"):t===":"?(s=r.indexOf("?",1),i=r.indexOf(".",1),a.push(r.substring(1,~s?s:~i?i:r.length)),l+=~s&&!~i?"(?:/([^/]+?))?":"/([^/]+?)",~i&&(l+=(~s?"?":"")+"\\"+r.substring(i))):l+="/"+r;return{keys:a,pattern:new RegExp("^"+l+(e?"(?=$|/)":"/?$"),"i")}}var M2={exports:{}},F2={};var fT;function OM(){if(fT)return F2;fT=1;var n=nx();function e(p,m){return p===m&&(p!==0||1/p===1/m)||p!==p&&m!==m}var t=typeof Object.is=="function"?Object.is:e,s=n.useState,r=n.useEffect,i=n.useLayoutEffect,a=n.useDebugValue;function l(p,m){var y=m(),x=s({inst:{value:y,getSnapshot:m}}),w=x[0].inst,S=x[1];return i(function(){w.value=y,w.getSnapshot=m,c(w)&&S({inst:w})},[p,y,m]),r(function(){return c(w)&&S({inst:w}),p(function(){c(w)&&S({inst:w})})},[p]),a(y),y}function c(p){var m=p.getSnapshot;p=p.value;try{var y=m();return!t(p,y)}catch{return!0}}function d(p,m){return m()}var h=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?d:l;return F2.useSyncExternalStore=n.useSyncExternalStore!==void 0?n.useSyncExternalStore:h,F2}var pT;function MM(){return pT||(pT=1,M2.exports=OM()),M2.exports}var FM=MM();const UM=$O.useInsertionEffect,VM=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",BM=VM?T.useLayoutEffect:T.useEffect,zM=UM||BM,k7=n=>{const e=T.useRef([n,(...t)=>e[0](...t)]).current;return zM(()=>{e[0]=n}),e[1]},$M="popstate",Jw="pushState",Zw="replaceState",HM="hashchange",mT=[$M,Jw,Zw,HM],WM=n=>{for(const e of mT)addEventListener(e,n);return()=>{for(const e of mT)removeEventListener(e,n)}},R7=(n,e)=>FM.useSyncExternalStore(WM,n,e),gT=()=>location.search,GM=({ssrSearch:n}={})=>R7(gT,n!=null?()=>n:gT),xT=()=>location.pathname,KM=({ssrPath:n}={})=>R7(xT,n!=null?()=>n:xT),qM=(n,{replace:e=!1,state:t=null}={})=>history[e?Zw:Jw](t,"",n),YM=(n={})=>[KM(n),qM],yT=Symbol.for("wouter_v3");if(typeof history<"u"&&typeof window[yT]>"u"){for(const n of[Jw,Zw]){const e=history[n];history[n]=function(){const t=e.apply(this,arguments),s=new Event(n);return s.arguments=arguments,dispatchEvent(s),t}}Object.defineProperty(window,yT,{value:!0})}const QM=(n,e)=>e.toLowerCase().indexOf(n.toLowerCase())?"~"+e:e.slice(n.length)||"/",P7=(n="")=>n==="/"?"":n,XM=(n,e)=>n[0]==="~"?n.slice(1):P7(e)+n,JM=(n="",e)=>QM(vT(P7(n)),vT(e)),vT=n=>{try{return decodeURI(n)}catch{return n}},N7={hook:YM,searchHook:GM,parser:jM,base:"",ssrPath:void 0,ssrSearch:void 0,ssrContext:void 0,hrefs:n=>n,aroundNav:(n,e,t)=>n(e,t)},L7=T.createContext(N7),df=()=>T.useContext(L7),D7={},j7=T.createContext(D7),ZM=()=>T.useContext(j7),rx=n=>{const[e,t]=n.hook(n);return[JM(n.base,e),k7((s,r)=>n.aroundNav(t,XM(s,n.base),r))]},Xl=()=>rx(df()),e4=(n,e,t,s)=>{const{pattern:r,keys:i}=e instanceof RegExp?{keys:!1,pattern:e}:n(e||"*",s),a=r.exec(t)||[],[l,...c]=a;return l!==void 0?[!0,(()=>{const d=i!==!1?Object.fromEntries(i.map((p,m)=>[p,c[m]])):a.groups;let h={...c};return d&&Object.assign(h,d),h})(),...s?[l]:[]]:[!1,null]},eF=n=>e4(df().parser,n,Xl()[0]),tF=({children:n,...e})=>{const t=df(),s=e.hook?N7:t;let r=s;const[i,a=e.ssrSearch??""]=e.ssrPath?.split("?")??[];i&&(e.ssrSearch=a,e.ssrPath=i),e.hrefs=e.hrefs??e.hook?.hrefs,e.searchHook=e.searchHook??e.hook?.searchHook;let l=T.useRef({}),c=l.current,d=c;for(let h in s){const p=h==="base"?s[h]+(e[h]??""):e[h]??s[h];c===d&&p!==d[h]&&(l.current=d={...d}),d[h]=p,(p!==s[h]||p!==r[h])&&(r=d)}return T.createElement(L7.Provider,{value:r,children:n})},bT=({children:n,component:e},t)=>e?T.createElement(e,{params:t}):typeof n=="function"?n(t):n,nF=n=>{let e=T.useRef(D7);const t=e.current;return e.current=Object.keys(n).length!==Object.keys(t).length||Object.entries(n).some(([s,r])=>r!==t[s])?n:t},Ht=({path:n,nest:e,match:t,...s})=>{const r=df(),[i]=rx(r),[a,l,c]=t??e4(r.parser,n,i,e),d=nF({...ZM(),...l});if(!a)return null;const h=c?T.createElement(tF,{base:c},bT(s,d)):bT(s,d);return T.createElement(j7.Provider,{value:d,children:h})},Et=T.forwardRef((n,e)=>{const t=df(),[s,r]=rx(t),{to:i="",href:a=i,onClick:l,asChild:c,children:d,className:h,replace:p,state:m,transition:y,...x}=n,w=k7(_=>{_.ctrlKey||_.metaKey||_.altKey||_.shiftKey||_.button!==0||(l?.(_),_.defaultPrevented||(_.preventDefault(),r(a,n)))}),S=t.hrefs(a[0]==="~"?a.slice(1):t.base+a,t);return c&&T.isValidElement(d)?T.cloneElement(d,{onClick:w,href:S}):T.createElement("a",{...x,onClick:w,href:S,className:h?.call?h(s===a):h,children:d,ref:e})}),O7=n=>Array.isArray(n)?n.flatMap(e=>O7(e&&e.type===T.Fragment?e.props.children:e)):[n],wT=({children:n,location:e})=>{const t=df(),[s]=rx(t);for(const r of O7(n)){let i=0;if(T.isValidElement(r)&&(i=e4(t.parser,r.props.path,e||s,r.props.nest))[0])return T.cloneElement(r,{match:i})}return null};function sF(n){return n.replace(/\[REMEMBER\][\s\S]*?\[\/REMEMBER\]/g,"").replace(/\[HELP_TICKET\][\s\S]*?\[\/HELP_TICKET\]/g,"").replace(/\[MANAGE_EVENT\][\s\S]*?\[\/MA
9NAGE_EVENT\]/g,"").replace(/\[MANAGE_SHOW\][\s\S]*?\[\/MANAGE_SHOW\]/g,"").replace(/\[TEMPLATE_FIX\][\s\S]*?\[\/TEMPLATE_FIX\]/g,"").trim()}function rF({endpoint:n="/api/gizmo/public/chat",getToken:e,surfaceName:t="Gizmo",accentColor:s="#4ade80"}){const[r,i]=T.useState(!1),[a,l]=T.useState([]),[c,d]=T.useState(""),[h,p]=T.useState(!1),[m,y]=T.useState(!1),[x,w]=T.useState(""),[S,_]=T.useState(""),[L,R]=T.useState(""),[M,V]=T.useState(""),[W,I]=T.useState(!1),k=T.useRef(Math.random().toString(36).slice(2)),P=T.useRef(null);T.useEffect(()=>{r&&P.current&&P.current.scrollIntoView({behavior:"smooth"})},[a,r]);const N=async()=>{const z=c.trim();if(!(!z||h)){d(""),p(!0),l(U=>[...U,{role:"user",text:z}]);try{const U={"Content-Type":"application/json"};if(e){const Y=await e();Y&&(U.Authorization=`Bearer ${Y}`)}const fe=a.slice(-20).map(Y=>({role:Y.role,text:Y.text})),X=await(await fetch(n,{method:"POST",headers:U,body:JSON.stringify({message:z,history:fe,sessionId:k.current})})).json(),Q=X.reply||X.message||"",G=sF(Q);l(Y=>[...Y,{role:"gizmo",text:G||"Sorry, I had trouble with that. Try again!"}])}catch{l(U=>[...U,{role:"gizmo",text:"Something went wrong. Please try again."}])}finally{p(!1)}}},F=async()=>{if(!(!x||!L||!M))try{await fetch("/api/gizmo/help-ticket",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:t,name:x,email:S,subject:L,description:M})}),I(!0),w(""),_(""),R(""),V("")}catch{}};return r?o.jsxs("div",{style:{position:"fixed",bottom:"max(12px, env(safe-area-inset-bottom))",right:12,zIndex:9999,width:360,maxWidth:"calc(100vw - 24px)",height:520,maxHeight:"min(520px, calc(100dvh - 24px))",background:"#111",border:`1px solid ${s}40`,borderRadius:18,boxShadow:`0 8px 40px ${s}25`,display:"flex",flexDirection:"column",overflow:"hidden"},children:[o.jsxs("div",{style:{padding:"12px 16px",borderBottom:`1px solid ${s}25`,display:"flex",alignItems:"center",justifyContent:"space-between",background:"#0a0a0a"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[o.jsx("div",{style:{width:32,height:32,borderRadius:"50%",background:`${s}20`,border:`1px solid ${s}50`,display:"flex",alignItems:"center",justifyContent:"center"},children:o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:s,strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M12 2a10 10 0 1 0 10 10A10 10 0 0 0 12 2z"}),o.jsx("path",{d:"M12 8v4l3 3"})]})}),o.jsxs("div",{children:[o.jsx("div",{style:{color:"#fff",fontWeight:700,fontSize:14,lineHeight:1.2},children:"Gizmo"}),o.jsx("div",{style:{color:s,fontSize:11},children:"Chronic Brands AI"})]})]}),o.jsxs("div",{style:{display:"flex",gap:8},children:[o.jsx("button",{onClick:()=>y(!m),title:"Submit support ticket",style:{background:"none",border:`1px solid ${s}30`,borderRadius:6,padding:"8px 10px",minHeight:40,cursor:"pointer",color:s,fontSize:11,transition:"all 0.2s"},children:"Help"}),o.jsx("button",{onClick:()=>i(!1),style:{background:"none",border:"none",minWidth:40,minHeight:40,cursor:"pointer",color:"#aaa",fontSize:18,lineHeight:1},"aria-label":"Close",children:"Ã"})]})]}),m&&o.jsx("div",{style:{padding:14,borderBottom:`1px solid ${s}20`,background:"#0d0d0d"},children:W?o.jsx("p",{style:{color:s,fontSize:13,textAlign:"center",margin:0},children:"â Ticket submitted! We'll be in touch."}):o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[o.jsx("p",{style:{color:"#aaa",fontSize:12,margin:0},children:"Submit a support ticket"}),[{val:x,set:w,ph:"Your name *"},{val:S,set:_,ph:"Email (optional)"},{val:L,set:R,ph:"Subject *"}].map(({val:z,set:U,ph:fe})=>o.jsx("input",{value:z,onChange:oe=>U(oe.target.value),placeholder:fe,style:{...U2,minHeight:44,minWidth:0}},fe)),o.jsx("textarea",{value:M,onChange:z=>V(z.target.value),placeholder:"Describe your issue *",rows:2,style:{...U2,resize:"none"}}),o.jsx("button",{onClick:F,style:ST(s),children:"Send Ticket"})]})}),o.jsxs("div",{style:{flex:1,overflowY:"auto",padding:14,display:"flex",flexDirection:"column",gap:10},children:[a.length===0&&o.jsxs("div",{style:{textAlign:"center",marginTop:40},children:[o.jsx("div",{style:{color:s,fontSize:32,marginBottom:8},children:"ð"}),o.jsxs("p",{style:{color:"#888",fontSize:13,lineHeight:1.5},children:["Hey! I'm Gizmo, the Chronic Brands AI.",o.jsx("br",{}),"Ask me anything!"]})]}),a.map((z,U)=>o.jsx("div",{style:{alignSelf:z.role==="user"?"flex-end":"flex-start",background:z.role==="user"?s:"#1e1e1e",color:z.role==="user"?"#111":"#e5e5e5",borderRadius:z.role==="user"?"14px 14px 2px 14px":"14px 14px 14px 2px",padding:"9px 13px",maxWidth:"82%",fontSize:13,lineHeight:1.55,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:z.text},U)),h&&o.jsx("div",{style:{alignSelf:"flex-start",background:"#1e1e1e",borderRadius:"14px 14px 14px 2px",padding:"9px 16px"},children:o.jsx("span",{style:{color:s,letterSpacing:4,animation:"pulse 1s infinite"},children:"â¢â¢â¢"})}),o.jsx("div",{ref:P})]}),o.jsxs("div",{style:{padding:"10px 12px",borderTop:`1px solid ${s}20`,display:"flex",gap:8,background:"#0a0a0a"},children:[o.jsx("input",{value:c,onChange:z=>d(z.target.value),onKeyDown:z=>z.key==="Enter"&&!z.shiftKey&&N(),placeholder:"Ask anything...",disabled:h,style:U2}),o.jsx("button",{"aria-label":"Send message",onClick:N,disabled:h||!c.trim(),style:{...ST(s),minWidth:44,minHeight:44},children:o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),o.jsx("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})})]})]}):o.jsx("button",{onClick:()=>i(!0),"aria-label":"Open Gizmo chat",style:{position:"fixed",bottom:"max(16px, env(safe-area-inset-bottom))",right:16,zIndex:9999,width:56,height:56,borderRadius:"50%",background:s,border:"none",cursor:"pointer",boxShadow:`0 4px 20px ${s}55`,display:"flex",alignItems:"center",justifyContent:"center",transition:"transform 0.2s"},onMouseEnter:z=>z.currentTarget.style.transform="scale(1.08)",onMouseLeave:z=>z.currentTarget.style.transform="scale(1)",children:o.jsx("svg",{width:"26",height:"26",viewBox:"0 0 24 24",fill:"none",stroke:"#111",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:o.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})})}const U2={flex:1,background:"#1a1a1a",border:"1px solid #333",borderRadius:10,padding:"8px 12px",color:"#e5e5e5",fontSize:13,outline:"none",width:"100%"},ST=n=>({background:n,color:"#111",border:"none",borderRadius:10,padding:"8px 12px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,fontWeight:600,fontSize:13,transition:"opacity 0.2s"});const iF=n=>n.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),M7=(...n)=>n.filter((e,t,s)=>!!e&&s.indexOf(e)===t).join(" ");var aF={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const oF=T.forwardRef(({color:n="currentColor",size:e=24,strokeWidth:t=2,absoluteStrokeWidth:s,className:r="",children:i,iconNode:a,...l},c)=>T.createElement("svg",{ref:c,...aF,width:e,height:e,stroke:n,strokeWidth:s?Number(t)*24/Number(e):t,className:M7("lucide",r),...l},[...a.map(([d,h])=>T.createElement(d,h)),...Array.isArray(i)?i:[i]]));const Oe=(n,e)=>{const t=T.forwardRef(({className:s,...r},i)=>T.createElement(oF,{ref:i,iconNode:e,className:M7(`lucide-${iF(n)}`,s),...r}));return t.displayName=`${n}`,t};const Fr=Oe("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);const lF=Oe("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);const xh=Oe("Award",[["path",{d:"m15.477 12.89 1.515 8.526a.5.5 0 0 1-.81.47l-3.58-2.687a1 1 0 0 0-1.197 0l-3.586 2.686a.5.5 0 0 1-.81-.469l1.514-8.526",key:"1yiouv"}],["circle",{cx:"12",cy:"8",r:"6",key:"1vp47v"}]]);const cF=Oe("BellOff",[["path",{d:"M8.7 3A6 6 0 0 1 18 8a21.3 21.3 0 0 0 .6 5",key:"o7mx20"}],["path",{d:"M17 17H3s3-2 3-9a4.67 4.67 0 0 1 .3-1.7",key:"16f1lm"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);const uF=Oe("Bell",[["path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9",key:"1qo2s2"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}]]);const ET=Oe("Building",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["path",{d:"M9 22v-4h6v4",key:"r93iot"}],["path",{d:"M8 6h.01",key:"1dz90k"}],["path",{d:"M16 6h.01",key:"1x0f13"}],["path",{d:"M12 6h.01",key:"1vi96p"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M8 14h.01",key:"6423bh"}]]);const Xc=Oe("Calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);const dF=Oe("CheckCheck",[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]]);const _a=Oe("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const ao=Oe("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const md=Oe("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);const Uc=Oe("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const ix=Oe("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);const Lh=Oe("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const Vc=Oe("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);const F7=Oe("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const hF=Oe("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const fF=Oe("CirclePlay",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polygon",{points:"10 8 16 12 10 16 10 8",key:"1cimsy"}]]);const pF=Oe("CirclePlus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]);const ax=Oe("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);const uo=Oe("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);const U7=Oe("Cog",[["path",{d:"M12 20a8 8 0 1 0 0-16 8 8 0 0 0 0 16Z",key:"sobvz5"}],["path",{d:"M12 14a2 2 0 1 0 0-4 2 2 0 0 0 0 4Z",key:"11i496"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 22v-2",key:"1osdcq"}],["path",{d:"m17 20.66-1-1.73",key:"eq3orb"}],["path",{d:"M11 10.27 7 3.34",key:"16pf9h"}
9],["path",{d:"m20.66 17-1.73-1",key:"sg0v6f"}],["path",{d:"m3.34 7 1.73 1",key:"1ulond"}],["path",{d:"M14 12h8",key:"4f43i9"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"m20.66 7-1.73 1",key:"1ow05n"}],["path",{d:"m3.34 17 1.73-1",key:"nuk764"}],["path",{d:"m17 3.34-1 1.73",key:"2wel8s"}],["path",{d:"m11 13.73-4 6.93",key:"794ttg"}]]);const Dh=Oe("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);const v0=Oe("CreditCard",[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]]);const mF=Oe("Crown",[["path",{d:"M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z",key:"1vdc57"}],["path",{d:"M5 21h14",key:"11awu3"}]]);const gF=Oe("DollarSign",[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]]);const xF=Oe("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);const yh=Oe("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const yF=Oe("FilePenLine",[["path",{d:"m18 5-2.414-2.414A2 2 0 0 0 14.172 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2",key:"142zxg"}],["path",{d:"M21.378 12.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"2t3380"}],["path",{d:"M8 18h1",key:"13wk12"}]]);const gb=Oe("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const vF=Oe("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]);const hf=Oe("Gamepad2",[["line",{x1:"6",x2:"10",y1:"11",y2:"11",key:"1gktln"}],["line",{x1:"8",x2:"8",y1:"9",y2:"13",key:"qnk9ow"}],["line",{x1:"15",x2:"15.01",y1:"12",y2:"12",key:"krot7o"}],["line",{x1:"18",x2:"18.01",y1:"10",y2:"10",key:"1lcuu1"}],["path",{d:"M17.32 5H6.68a4 4 0 0 0-3.978 3.59c-.006.052-.01.101-.017.152C2.604 9.416 2 14.456 2 16a3 3 0 0 0 3 3c1 0 1.5-.5 2-1l1.414-1.414A2 2 0 0 1 9.828 16h4.344a2 2 0 0 1 1.414.586L17 18c.5.5 1 1 2 1a3 3 0 0 0 3-3c0-1.545-.604-6.584-.685-7.258-.007-.05-.011-.1-.017-.151A4 4 0 0 0 17.32 5z",key:"mfqc10"}]]);const t4=Oe("Gift",[["rect",{x:"3",y:"8",width:"18",height:"4",rx:"1",key:"bkv52"}],["path",{d:"M12 8v13",key:"1c76mn"}],["path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7",key:"6wjy6b"}],["path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5",key:"1ihvrl"}]]);const bF=Oe("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);const V7=Oe("HardDrive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]]);const wF=Oe("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"}]]);const TT=Oe("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);const SF=Oe("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);const EF=Oe("Instagram",[["rect",{width:"20",height:"20",x:"2",y:"2",rx:"5",ry:"5",key:"2e1cvw"}],["path",{d:"M16 11.37A4 4 0 1 1 12.63 8 4 4 0 0 1 16 11.37z",key:"9exkf1"}],["line",{x1:"17.5",x2:"17.51",y1:"6.5",y2:"6.5",key:"r4j83e"}]]);
9const TF=Oe("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);const Nn=Oe("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const Gh=Oe("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);const B7=Oe("LogIn",[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]]);const xb=Oe("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]);const z7=Oe("MapPin",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]]);const _F=Oe("Maximize2",[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);const $7=Oe("Menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]]);const _T=Oe("MessageCircle",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]]);const IF=Oe("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);const AF=Oe("MicOff",[["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}],["path",{d:"M18.89 13.23A7.12 7.12 0 0 0 19 12v-2",key:"80xlxr"}],["path",{d:"M5 10v2a7 7 0 0 0 12 5",key:"p2k8kg"}],["path",{d:"M15 9.34V5a3 3 0 0 0-5.68-1.33",key:"1gzdoj"}],["path",{d:"M9 9v3a3 3 0 0 0 5.12 2.12",key:"r2i35w"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]]);const V2=Oe("MicVocal",[["path",{d:"m11 7.601-5.994 8.19a1 1 0 0 0 .1 1.298l.817.818a1 1 0 0 0 1.314.087L15.09 12",key:"80a601"}],["path",{d:"M16.5 21.174C15.5 20.5 14.372 20 13 20c-2.058 0-3.928 2.356-6 2-2.072-.356-2.775-3.369-1.5-4.5",key:"j0ngtp"}],["circle",{cx:"16",cy:"7",r:"5",key:"d08jfb"}]]);const CF=Oe("Mic",[["path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",key:"131961"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]]);const kF=Oe("Minimize2",[["polyline",{points:"4 14 10 14 10 20",key:"11kfnr"}],["polyline",{points:"20 10 14 10 14 4",key:"rlmsce"}],["line",{x1:"14",x2:"21",y1:"10",y2:"3",key:"o5lafz"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);const RF=Oe("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);const PF=Oe("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);const B2=Oe("Music",[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]]);const NF=Oe("Newspaper",[["path",{d:"M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-2 2Zm0 0a2 2 0 0 1-2-2v-9c0-1.1.9-2 2-2h2",key:"7pis2x"}],["path",{d:"M18 14h-8",key:"sponae"}],["path",{d:"M15 18h-5",key:"95g1m2"}],["path",{d:"M10 6h8v4h-8V6Z",key:"smlsk5"}]]);const gd=Oe("Package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["path",{d:"m3.3 7 7.703 4.734a2 2 0 0 0 1.994 0L20.7 7",key:"yx3hmr"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]);const IT=Oe("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"}]]);const LF=Oe("Phone",[["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);const Bc=Oe("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);const b0=Oe("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const DF=Oe("Printer",[["path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",key:"143wyd"}],["path",{d:"M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6",key:"1itne7"}],["rect",{x:"6",y:"14",width:"12",height:"8",rx:"1",key:"1ue0tg"}]]);
9const Yu=Oe("QrCode",[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]]);const n4=Oe("Radio",[["path",{d:"M4.9 19.1C1 15.2 1 8.8 4.9 4.9",key:"1vaf9d"}],["path",{d:"M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5",key:"u1ii0m"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5",key:"1j5fej"}],["path",{d:"M19.1 4.9C23 8.8 23 15.1 19.1 19",key:"10b0cb"}]]);const AT=Oe("Repeat1",[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}],["path",{d:"M11 10h1v4",key:"70cz1p"}]]);const CT=Oe("Repeat",[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]]);const kT=Oe("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);const jF=Oe("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);const s4=Oe("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);const r4=Oe("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const Jc=Oe("Share2",[["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"}]]);const OF=Oe("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const MF=Oe("Shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);const X0=Oe("ShoppingBag",[["path",{d:"M6 2 3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4Z",key:"hou9p0"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M16 10a4 4 0 0 1-8 0",key:"1ltviw"}]]);const Fl=Oe("ShoppingCart",[["circle",{cx:"8",cy:"21",r:"1",key:"jimo8o"}],["circle",{cx:"19",cy:"21",r:"1",key:"13723u"}],["path",{d:"M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12",key:"9zh506"}]]);const yb=Oe("Shuffle",[["path",{d:"M2 18h1.4c1.3 0 2.5-.6 3.3-1.7l6.1-8.6c.7-1.1 2-1.7 3.3-1.7H22",key:"1wmou1"}],["path",{d:"m18 2 4 4-4 4",key:"pucp1d"}],["path",{d:"M2 6h1.9c1.5 0 2.9.9 3.6 2.2",key:"10bdb2"}],["path",{d:"M22 18h-5.9c-1.3 0-2.6-.7-3.3-1.8l-.5-.8",key:"vgxac0"}],["path",{d:"m18 14 4 4-4 4",key:"10pe0f"}]]);const RT=Oe("SkipBack",[["polygon",{points:"19 20 9 12 19 4 19 20",key:"o2sva"}],["line",{x1:"5",x2:"5",y1:"19",y2:"5",key:"1ocqjk"}]]);const PT=Oe("SkipForward",[["polygon",{points:"5 4 15 12 5 20 5 4",key:"16p6eg"}],["line",{x1:"19",x2:"19",y1:"5",y2:"19",key:"futhcm"}]]);const FF=Oe("Smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);const H7=Oe("Star",[["polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2",key:"8f66p6"}]]);
9const z2=Oe("Store",[["path",{d:"m2 7 4.41-4.41A2 2 0 0 1 7.83 2h8.34a2 2 0 0 1 1.42.59L22 7",key:"ztvudi"}],["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}],["path",{d:"M15 22v-4a2 2 0 0 0-2-2h-2a2 2 0 0 0-2 2v4",key:"2ebpfo"}],["path",{d:"M2 7h20",key:"1fcdvo"}],["path",{d:"M22 7v3a2 2 0 0 1-2 2a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 16 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 12 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 8 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 4 12a2 2 0 0 1-2-2V7",key:"6c3vgh"}]]);const vb=Oe("Swords",[["polyline",{points:"14.5 17.5 3 6 3 3 6 3 17.5 14.5",key:"1hfsw2"}],["line",{x1:"13",x2:"19",y1:"19",y2:"13",key:"1vrmhu"}],["line",{x1:"16",x2:"20",y1:"16",y2:"20",key:"1bron3"}],["line",{x1:"19",x2:"21",y1:"21",y2:"19",key:"13pww6"}],["polyline",{points:"14.5 6.5 18 3 21 3 21 6 17.5 9.5",key:"hbey2j"}],["line",{x1:"5",x2:"9",y1:"14",y2:"18",key:"1hf58s"}],["line",{x1:"7",x2:"4",y1:"17",y2:"20",key:"pidxm4"}],["line",{x1:"3",x2:"5",y1:"19",y2:"21",key:"1pehsh"}]]);const ox=Oe("Tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);const UF=Oe("Target",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);const VF=Oe("ThumbsDown",[["path",{d:"M17 14V2",key:"8ymqnk"}],["path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z",key:"m61m77"}]]);const BF=Oe("ThumbsUp",[["path",{d:"M7 10v12",key:"1qc93n"}],["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z",key:"emmmcr"}]]);const Kp=Oe("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);const zF=Oe("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const W7=Oe("Truck",[["path",{d:"M14 18V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v11a1 1 0 0 0 1 1h2",key:"wrbu53"}],["path",{d:"M15 18H9",key:"1lyqi6"}],["path",{d:"M19 18h2a1 1 0 0 0 1-1v-3.65a1 1 0 0 0-.22-.624l-3.48-4.35A1 1 0 0 0 17.52 8H14",key:"lysw3i"}],["circle",{cx:"17",cy:"18",r:"2",key:"332jqn"}],["circle",{cx:"7",cy:"18",r:"2",key:"19iecd"}]]);const NT=Oe("TvMinimal",[["path",{d:"M7 21h10",key:"1b0cd5"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}]]);const oo=Oe("Tv",[["rect",{width:"20",height:"15",x:"2",y:"7",rx:"2",ry:"2",key:"10ag99"}],["polyline",{points:"17 2 12 7 7 2",key:"11pgbg"}]]);const $F=Oe("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]);const HF=Oe("UserCheck",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["polyline",{points:"16 11 18 13 22 9",key:"1pwet4"}]]);const lx=Oe("UserPlus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);const jh=Oe("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);const ff=Oe("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);const Bg=Oe("VideoOff",[["path",{d:"M10.66 6H14a2 2 0 0 1 2 2v2.5l5.248-3.062A.5.5 0 0 1 22 7.87v8.196",key:"w8jjjt"}],["path",{d:"M16 16a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h2",key:"1xawa7"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);const G7=Oe("Video",[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]]);const K7=Oe("Volume2",[["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"}]]);const WF=Oe("WifiOff",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}
vendor: 4,615 bytes, line 9
9],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);const GF=Oe("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);const Mr=Oe("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);const q7=Oe("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);var Y7={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},LT=Tn.createContext&&Tn.createContext(Y7),KF=["attr","size","title"];function qF(n,e){if(n==null)return{};var t,s,r=YF(n,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);for(s=0;s<i.length;s++)t=i[s],e.indexOf(t)===-1&&{}.propertyIsEnumerable.call(n,t)&&(r[t]=n[t])}return r}function YF(n,e){if(n==null)return{};var t={};for(var s in n)if({}.hasOwnProperty.call(n,s)){if(e.indexOf(s)!==-1)continue;t[s]=n[s]}return t}function J0(){return J0=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var s in t)({}).hasOwnProperty.call(t,s)&&(n[s]=t[s])}return n},J0.apply(null,arguments)}function DT(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(n);e&&(s=s.filter(function(r){return Object.getOwnPropertyDescriptor(n,r).enumerable})),t.push.apply(t,s)}return t}function Z0(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?DT(Object(t),!0).forEach(function(s){QF(n,s,t[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):DT(Object(t)).forEach(function(s){Object.defineProperty(n,s,Object.getOwnPropertyDescriptor(t,s))})}return n}function QF(n,e,t){return(e=XF(e))in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function XF(n){var e=JF(n,"string");return typeof e=="symbol"?e:e+""}function JF(n,e){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var s=t.call(n,e);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}function Q7(n){return n&&n.map((e,t)=>Tn.createElement(e.tag,Z0({key:t},e.attr),Q7(e.child)))}function mu(n){return e=>Tn.createElement(ZF,J0({attr:Z0({},n.attr)},e),Q7(n.child))}function ZF(n){var e=t=>{var{attr:s,size:r,title:i}=n,a=qF(n,KF),l=r||t.size||"1em",c;return t.className&&(c=t.className),n.className&&(c=(c?c+" ":"")+n.className),Tn.createElement("svg",J0({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},t.attr,s,a,{className:c,style:Z0(Z0({color:n.color||t.color},t.style),n.style),height:l,width:l,xmlns:"http://www.w3.org/2000/svg"}),i&&Tn.createElement("title",null,i),n.children)};return LT!==void 0?Tn.createElement(LT.Consumer,null,t=>e(t)):e(Y7)}function yde(n){return mu({attr:{role:"img",viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M23.498 6.186a3.016 3.016 0 0 0-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 0 0 .502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 0 0 2.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 0 0 2.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814zM9.545 15.568V8.432L15.818 12l-6.273 3.568z"},child:[]}]})(n)}function vde(n){return mu({attr:{role:"img",viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M23.9765 6.4168c-.105 2.338-1.739 5.5429-4.894 9.6088-3.2679 4.247-6.0258 6.3699-8.2898 6.3699-1.409 0-2.578-1.294-3.553-3.881l-1.9179-7.1138c-.719-2.584-1.488-3.878-2.312-3.878-.179 0-.806.378-1.8809 1.132l-1.129-1.457a315.06 315.06 0 003.501-3.1279c1.579-1.368 2.765-2.085 3.5539-2.159 1.867-.18 3.016 1.1 3.447 3.838.465 2.953.789 4.789.971 5.5069.5389 2.45 1.1309 3.674 1.7759 3.674.502 0 1.256-.796 2.265-2.385 1.004-1.589 1.54-2.797 1.612-3.628.144-1.371-.395-2.061-1.614-2.061-.574 0-1.167.121-1.777.391 1.186-3.8679 3.434-5.7568 6.7619-5.6368 2.4729.06 3.6279 1.664 3.4929 4.7969z"},child:[]}]})(n)}function bde(n){return mu({attr:{role:"img",viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M12.525.02c1.31-.02 2.61-.01 3.91-.02.08 1.53.63 3.09 1.75 4.17 1.12 1.11 2.7 1.62 4.24 1.79v4.03c-1.44-.05-2.89-.35-4.2-.97-.57-.26-1.1-.59-1.62-.93-.01 2.92.01 5.84-.02 8.75-.08 1.4-.54 2.79-1.35 3.94-1.31 1.92-3.58 3.17-5.91 3.21-1.43.08-2.86-.31-4.08
9-1.03-2.02-1.19-3.44-3.37-3.65-5.71-.02-.5-.03-1-.01-1.49.18-1.9 1.12-3.72 2.58-4.96 1.66-1.44 3.98-2.13 6.15-1.72.02 1.48-.04 2.96-.04 4.44-.99-.32-2.15-.23-3.02.37-.63.41-1.11 1.04-1.36 1.75-.21.51-.15 1.07-.14 1.61.24 1.64 1.82 3.02 3.5 2.87 1.12-.01 2.19-.66 2.77-1.61.19-.33.4-.67.41-1.06.1-1.79.06-3.57.07-5.36.01-4.03-.01-8.05.02-12.07z"},child:[]}]})(n)}function i4(n){return mu({attr:{role:"img",viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M16.34 9.853l-2.254 2.254v-2.26H12.13v5.744h1.957v-2.33l2.353 2.33h2.46l-2.988-2.99 2.477-2.476v3.411c0 1.133.679 2.177 2.393 2.177.815 0 1.56-.462 1.922-.88l.88.759H24v-5.74h-1.951v3.718c-.22.384-.528.627-1.002.627-.482 0-.703-.286-.703-1.198V9.853zm-4.591 2.869A3.004 3.004 0 1 1 8.738 9.73a2.997 2.997 0 0 1 3.011 2.99m-3.011-1.57c-.518 0-.956.704-.956 1.572 0 .867.438 1.57.956 1.57.528 0 .968-.702.968-1.57 0-.869-.438-1.572-.968-1.572zm-2.206 4.447H4.313L2.55 13.153h-.594v2.44H0V8.26h2.8c1.616 0 2.935 1.1 2.935 2.45 0 .826-.505 1.562-1.273 2.013l2.07 2.875m-2.75-4.888A1.226 1.226 0 0 0 2.56 9.478h-.604v2.453h.605a1.225 1.225 0 0 0 1.22-1.221Z"},child:[]}]})(n)}function wde(n){return mu({attr:{role:"img",viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M7.0301.084c-1.2768.0602-2.1487.264-2.911.5634-.7888.3075-1.4575.72-2.1228 1.3877-.6652.6677-1.075 1.3368-1.3802 2.127-.2954.7638-.4956 1.6365-.552 2.914-.0564 1.2775-.0689 1.6882-.0626 4.947.0062 3.2586.0206 3.6671.0825 4.9473.061 1.2765.264 2.1482.5635 2.9107.308.7889.72 1.4573 1.388 2.1228.6679.6655 1.3365 1.0743 2.1285 1.38.7632.295 1.6361.4961 2.9134.552 1.2773.056 1.6884.069 4.9462.0627 3.2578-.0062 3.668-.0207 4.9478-.0814 1.28-.0607 2.147-.2652 2.9098-.5633.7889-.3086 1.4578-.72 2.1228-1.3881.665-.6682 1.0745-1.3378 1.3795-2.1284.2957-.7632.4966-1.636.552-2.9124.056-1.2809.0692-1.6898.063-4.948-.0063-3.2583-.021-3.6668-.0817-4.9465-.0607-1.2797-.264-2.1487-.5633-2.9117-.3084-.7889-.72-1.4568-1.3876-2.1228C21.2982 1.33 20.628.9208 19.8378.6165 19.074.321 18.2017.1197 16.9244.0645 15.6471.0093 15.236-.005 11.977.0014 8.718.0076 8.31.0215 7.0301.0839m.1402 21.6932c-1.17-.0509-1.8053-.2453-2.2287-.408-.5606-.216-.96-.4771-1.3819-.895-.422-.4178-.6811-.8186-.9-1.378-.1644-.4234-.3624-1.058-.4171-2.228-.0595-1.2645-.072-1.6442-.079-4.848-.007-3.2037.0053-3.583.0607-4.848.05-1.169.2456-1.805.408-2.2282.216-.5613.4762-.96.895-1.3816.4188-.4217.8184-.6814 1.3783-.9003.423-.1651 1.0575-.3614 2.227-.4171 1.2655-.06 1.6447-.072 4.848-.079 3.2033-.007 3.5835.005 4.8495.0608 1.169.0508 1.8053.2445 2.228.408.5608.216.96.4754 1.3816.895.4217.4194.6816.8176.9005 1.3787.1653.4217.3617 1.056.4169 2.2263.0602 1.2655.0739 1.645.0796 4.848.0058 3.203-.0055 3.5834-.061 4.848-.051 1.17-.245 1.8055-.408 2.2294-.216.5604-.4763.96-.8954 1.3814-.419.4215-.8181.6811-1.3783.9-.4224.1649-1.0577.3617-2.2262.4174-1.2656.0595-1.6448.072-4.8493.079-3.2045.007-3.5825-.006-4.848-.0608M16.953 5.5864A1.44 1.44 0 1 0 18.39 4.144a1.44 1.44 0 0 0-1.437 1.4424M5.8385 12.012c.0067 3.4032 2.7706 6.1557 6.173 6.1493 3.4026-.0065 6.157-2.7701 6.1506-6.1733-.0065-3.4032-2.771-6.1565-6.174-6.1498-3.403.0067-6.156 2.771-6.1496 6.1738M8 12.0077a4 4 0 1 1 4.008 3.9921A3.9996 3.9996 0 0 1 8 12.0077"},child:[]}]})(n)}function a4(n){return mu({attr:{role:"img",viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M22.018 13.298l-3.919 2.218-3.515-3.493 3.543-3.521 3.891 2.202a1.49 1.49 0 0 1 0 2.594zM1.337.924a1.486 1.486 0 0 0-.112.568v21.017c0 .217.045.419.124.6l11.155-11.087L1.337.924zm12.207 10.065l3.258-3.238L3.45.195a1.466 1.466 0 0 0-.946-.179l11.04 10.973zm0 2.067l-11 10.933c.298.036.612-.016.906-.183l13.324-7.54-3.23-3.21z"},child:[]}]})(n)}function Sde(n){return mu({attr:{role:"img",viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M9.101 23.691v-7.98H6.627v-3.667h2.474v-1.58c0-4.085 1.848-5.978 5.858-5.978.401 0 .955.042 1.468.103a8.68 8.68 0 0 1 1.141.195v3.325a8.623 8.623 0 0 0-.653-.036 26.805 26.805 0 0 0-.733-.009c-.707 0-1.259.096-1.675.309a1.686 1.686 0 0 0-.679.622c-.258.42-.374.995-.374 1.752v1.297h3.919l-.386 2.103-.287 1.564h-3.246v8.245C19.396 23.238 24 18.179 24 12.044c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.628 3.874 10.35 9.101 11.647Z"},child:[]}]})(n)}function o4(n){return mu({attr:{role:"img",viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.546 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701"},child:[]}]})(n)}var eU=Object.defineProperty,e1=Object.getOwnPropertySymbols,X7=Object.prototype.hasOwnProperty,J7=Object.prototype.propertyIsEnumerable,jT=(n,e,t)=>e in n?eU(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,bb=(n,e)=>{for(var t in e||(e={}
9))X7.call(e,t)&&jT(n,t,e[t]);if(e1)for(var t of e1(e))J7.call(e,t)&&jT(n,t,e[t]);return n},wb=(n,e)=>{var t={};for(var s in n)X7.call(n,s)&&e.indexOf(s)<0&&(t[s]=n[s]);if(n!=null&&e1)for(var s of e1(n))e.indexOf(s)<0&&J7.call(n,s)&&(t[s]=n[s]);return t};var xd;(n=>{const e=class nn{constructor(c,d,h,p){if(this.version=c,this.errorCorrectionLevel=d,this.modules=[],this.isFunction=[],c<nn.MIN_VERSION||c>nn.MAX_VERSION)throw new RangeError("Version value out of range");if(p<-1||p>7)throw new RangeError("Mask value out of range");this.size=c*4+17;let m=[];for(let x=0;x<this.size;x++)m.push(!1);for(let x=0;x<this.size;x++)this.modules.push(m.slice()),this.isFunction.push(m.slice());this.drawFunctionPatterns();const y=this.addEccAndInterleave(h);if(this.drawCodewords(y),p==-1){let x=1e9;for(let w=0;w<8;w++){this.applyMask(w),this.drawFormatBits(w);const S=this.getPenaltyScore();S<x&&(p=w,x=S),this.applyMask(w)}}r(0<=p&&p<=7),this.mask=p,this.applyMask(p),this.drawFormatBits(p),this.isFunction=[]}static encodeText(c,d){const h=n.QrSegment.makeSegments(c);return nn.encodeSegments(h,d)}static encodeBinary(c,d){const h=n.QrSegment.makeBytes(c);return nn.encodeSegments([h],d)}static encodeSegments(c,d,h=1,p=40,m=-1,y=!0){if(!(nn.MIN_VERSION<=h&&h<=p&&p<=nn.MAX_VERSION)||m<-1||m>7)throw new RangeError("Invalid value");let x,w;for(x=h;;x++){const R=nn.getNumDataCodewords(x,d)*8,M=a.getTotalBits(c,x);if(M<=R){w=M;break}if(x>=p)throw new RangeError("Data too long")}for(const R of[nn.Ecc.MEDIUM,nn.Ecc.QUARTILE,nn.Ecc.HIGH])y&&w<=nn.getNumDataCodewords(x,R)*8&&(d=R);let S=[];for(const R of c){t(R.mode.modeBits,4,S),t(R.numChars,R.mode.numCharCountBits(x),S);for(const M of R.getData())S.push(M)}r(S.length==w);const _=nn.getNumDataCodewords(x,d)*8;r(S.length<=_),t(0,Math.min(4,_-S.length),S),t(0,(8-S.length%8)%8,S),r(S.length%8==0);for(let R=236;S.length<_;R^=253)t(R,8,S);let L=[];for(;L.length*8<S.length;)L.push(0);return S.forEach((R,M)=>L[M>>>3]|=R<<7-(M&7)),new nn(x,d,L,m)}getModule(c,d){return 0<=c&&c<this.size&&0<=d&&d<this.size&&this.modules[d][c]}getModules(){return this.modules}drawFunctionPatterns(){for(let h=0;h<this.size;h++)this.setFunctionModule(6,h,h%2==0),this.setFunctionModule(h,6,h%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const c=this.getAlignmentPatternPositions(),d=c.length;for(let h=0;h<d;h++)for(let p=0;p<d;p++)h==0&&p==0||h==0&&p==d-1||h==d-1&&p==0||this.drawAlignmentPattern(c[h],c[p]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(c){const d=this.errorCorrectionLevel.formatBits<<3|c;let h=d;for(let m=0;m<10;m++)h=h<<1^(h>>>9)*1335;const p=(d<<10|h)^21522;r(p>>>15==0);for(let m=0;m<=5;m++)this.setFunctionModule(8,m,s(p,m));this.setFunctionModule(8,7,s(p,6)),this.setFunctionModule(8,8,s(p,7)),this.setFunctionModule(7,8,s(p,8));for(let m=9;m<15;m++)this.setFunctionModule(14-m,8,s(p,m));for(let m=0;m<8;m++)this.setFunctionModule(this.size-1-m,8,s(p,m));for(let m=8;m<15;m++)this.setFunctionModule(8,this.size-15+m,s(p,m));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let c=this.version;for(let h=0;h<12;h++)c=c<<1^(c>>>11)*7973;const d=this.version<<12|c;r(d>>>18==0);for(let h=0;h<18;h++){const p=s(d,h),m=this.size-11+h%3,y=Math.floor(h/3);this.setFunctionModule(m,y,p),this.setFunctionModule(y,m,p)}}drawFinderPattern(c,d){for(let h=-4;h<=4;h++)for(let p=-4;p<=4;p++){const m=Math.max(Math.abs(p),Math.abs(h)),y=c+p,x=d+h;0<=y&&y<this.size&&0<=x&&x<this.size&&this.setFunctionModule(y,x,m!=2&&m!=4)}}drawAlignmentPattern(c,d){for(let h=-2;h<=2;h++)for(let p=-2;p<=2;p++)this.setFunctionModule(c+p,d+h,Math.max(Math.abs(p),Math.abs(h))!=1)}setFunctionModule(c,d,h){this.modules[d][c]=h,this.isFunction[d][c]=!0}addEccAndInterleave(c){const d=this.version,h=this.errorCorrectionLevel;if(c.length!=nn.getNumDataCodewords(d,h))throw new RangeError("Invalid argument");const p=nn.NUM_ERROR_CORRECTION_BLOCKS[h.ordinal][d],m=nn.ECC_CODEWORDS_PER_BLOCK[h.ordinal][d],y=Math.floor(nn.getNumRawDataModules(d)/8),x=p-y%p,w=Math.floor(y/p);let S=[];const _=nn.reedSolomonComputeDivisor(m);for(let R=0,M=0;R<p;R++){let V=c.slice(M,M+w-m+(R<x?0:1));M+=V.length;const W=nn.reedSolomonComputeRemainder(V,_);R<x&&V.push(0),S.push(V.concat(W))}let L=[];for(let R=0;R<S[0].length;R++)S.forEach((M,V)=>{(R!=w-m||V>=x)&&L.push(M[R])});return r(L.length==y),L}drawCodewords(c){if(c.length!=Math.floor(nn.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let d=0;for(let h=this.size-1;h>=1;h-=2){h==6&&(h=5);for(let p=0;p<this.size;p++)for(let m=0;m<2;m++){const y=h-m,w=(h+1&2)==0?this.size-1-p:p;!this.isFunction[w][y]&&d<c.length*8&&(this.modules[w][y]=s(c[d>>>3],7-(d&7)),d++)}}r(d==c.length*8)}
9applyMask(c){if(c<0||c>7)throw new RangeError("Mask value out of range");for(let d=0;d<this.size;d++)for(let h=0;h<this.size;h++){let p;switch(c){case 0:p=(h+d)%2==0;break;case 1:p=d%2==0;break;case 2:p=h%3==0;break;case 3:p=(h+d)%3==0;break;case 4:p=(Math.floor(h/3)+Math.floor(d/2))%2==0;break;case 5:p=h*d%2+h*d%3==0;break;case 6:p=(h*d%2+h*d%3)%2==0;break;case 7:p=((h+d)%2+h*d%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[d][h]&&p&&(this.modules[d][h]=!this.modules[d][h])}}getPenaltyScore(){let c=0;for(let m=0;m<this.size;m++){let y=!1,x=0,w=[0,0,0,0,0,0,0];for(let S=0;S<this.size;S++)this.modules[m][S]==y?(x++,x==5?c+=nn.PENALTY_N1:x>5&&c++):(this.finderPenaltyAddHistory(x,w),y||(c+=this.finderPenaltyCountPatterns(w)*nn.PENALTY_N3),y=this.modules[m][S],x=1);c+=this.finderPenaltyTerminateAndCount(y,x,w)*nn.PENALTY_N3}for(let m=0;m<this.size;m++){let y=!1,x=0,w=[0,0,0,0,0,0,0];for(let S=0;S<this.size;S++)this.modules[S][m]==y?(x++,x==5?c+=nn.PENALTY_N1:x>5&&c++):(this.finderPenaltyAddHistory(x,w),y||(c+=this.finderPenaltyCountPatterns(w)*nn.PENALTY_N3),y=this.modules[S][m],x=1);c+=this.finderPenaltyTerminateAndCount(y,x,w)*nn.PENALTY_N3}for(let m=0;m<this.size-1;m++)for(let y=0;y<this.size-1;y++){const x=this.modules[m][y];x==this.modules[m][y+1]&&x==this.modules[m+1][y]&&x==this.modules[m+1][y+1]&&(c+=nn.PENALTY_N2)}let d=0;for(const m of this.modules)d=m.reduce((y,x)=>y+(x?1:0),d);const h=this.size*this.size,p=Math.ceil(Math.abs(d*20-h*10)/h)-1;return r(0<=p&&p<=9),c+=p*nn.PENALTY_N4,r(0<=c&&c<=2568888),c}getAlignmentPatternPositions(){if(this.version==1)return[];{const c=Math.floor(this.version/7)+2,d=this.version==32?26:Math.ceil((this.version*4+4)/(c*2-2))*2;let h=[6];for(let p=this.size-7;h.length<c;p-=d)h.splice(1,0,p);return h}}static getNumRawDataModules(c){if(c<nn.MIN_VERSION||c>nn.MAX_VERSION)throw new RangeError("Version number out of range");let d=(16*c+128)*c+64;if(c>=2){const h=Math.floor(c/7)+2;d-=(25*h-10)*h-55,c>=7&&(d-=36)}return r(208<=d&&d<=29648),d}static getNumDataCodewords(c,d){return Math.floor(nn.getNumRawDataModules(c)/8)-nn.ECC_CODEWORDS_PER_BLOCK[d.ordinal][c]*nn.NUM_ERROR_CORRECTION_BLOCKS[d.ordinal][c]}static reedSolomonComputeDivisor(c){if(c<1||c>255)throw new RangeError("Degree out of range");let d=[];for(let p=0;p<c-1;p++)d.push(0);d.push(1);let h=1;for(let p=0;p<c;p++){for(let m=0;m<d.length;m++)d[m]=nn.reedSolomonMultiply(d[m],h),m+1<d.length&&(d[m]^=d[m+1]);h=nn.reedSolomonMultiply(h,2)}return d}static reedSolomonComputeRemainder(c,d){let h=d.map(p=>0);for(const p of c){const m=p^h.shift();h.push(0),d.forEach((y,x)=>h[x]^=nn.reedSolomonMultiply(y,m))}return h}static reedSolomonMultiply(c,d){if(c>>>8||d>>>8)throw new RangeError("Byte out of range");let h=0;for(let p=7;p>=0;p--)h=h<<1^(h>>>7)*285,h^=(d>>>p&1)*c;return r(h>>>8==0),h}finderPenaltyCountPatterns(c){const d=c[1];r(d<=this.size*3);const h=d>0&&c[2]==d&&c[3]==d*3&&c[4]==d&&c[5]==d;return(h&&c[0]>=d*4&&c[6]>=d?1:0)+(h&&c[6]>=d*4&&c[0]>=d?1:0)}finderPenaltyTerminateAndCount(c,d,h){return c&&(this.finderPenaltyAddHistory(d,h),d=0),d+=this.size,this.finderPenaltyAddHistory(d,h),this.finderPenaltyCountPatterns(h)}finderPenaltyAddHistory(c,d){d[0]==0&&(c+=this.size),d.pop(),d.unshift(c)}};e.MIN_VERSION=1,e.MAX_VERSION=40,e.PENALTY_N1=3,e.PENALTY_N2=3,e.PENALTY_N3=40,e.PENALTY_N4=10,e.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],e.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],n.QrCode=e;function t(l,c,d){if(c<0||c>31||l>>>c)throw new RangeError("Value out of range");for(let h=c-1;h>=0;h--)d.push(l>>>h&1)}function s(l,c){return(l>>>c&1)!=0}function r(l){if(!l)throw new Error("Assertion error")}const i=class ds{constructor(c,d,h){if(this.mode=c,this.numChars=d,this.bitData=h,d<0)throw new RangeError("Invalid argument");this.bitData=h.slice()}static makeBytes(c){let d=[];
9for(const h of c)t(h,8,d);return new ds(ds.Mode.BYTE,c.length,d)}static makeNumeric(c){if(!ds.isNumeric(c))throw new RangeError("String contains non-numeric characters");let d=[];for(let h=0;h<c.length;){const p=Math.min(c.length-h,3);t(parseInt(c.substring(h,h+p),10),p*3+1,d),h+=p}return new ds(ds.Mode.NUMERIC,c.length,d)}static makeAlphanumeric(c){if(!ds.isAlphanumeric(c))throw new RangeError("String contains unencodable characters in alphanumeric mode");let d=[],h;for(h=0;h+2<=c.length;h+=2){let p=ds.ALPHANUMERIC_CHARSET.indexOf(c.charAt(h))*45;p+=ds.ALPHANUMERIC_CHARSET.indexOf(c.charAt(h+1)),t(p,11,d)}return h<c.length&&t(ds.ALPHANUMERIC_CHARSET.indexOf(c.charAt(h)),6,d),new ds(ds.Mode.ALPHANUMERIC,c.length,d)}static makeSegments(c){return c==""?[]:ds.isNumeric(c)?[ds.makeNumeric(c)]:ds.isAlphanumeric(c)?[ds.makeAlphanumeric(c)]:[ds.makeBytes(ds.toUtf8ByteArray(c))]}static makeEci(c){let d=[];if(c<0)throw new RangeError("ECI assignment value out of range");if(c<128)t(c,8,d);else if(c<16384)t(2,2,d),t(c,14,d);else if(c<1e6)t(6,3,d),t(c,21,d);else throw new RangeError("ECI assignment value out of range");return new ds(ds.Mode.ECI,0,d)}static isNumeric(c){return ds.NUMERIC_REGEX.test(c)}static isAlphanumeric(c){return ds.ALPHANUMERIC_REGEX.test(c)}getData(){return this.bitData.slice()}static getTotalBits(c,d){let h=0;for(const p of c){const m=p.mode.numCharCountBits(d);if(p.numChars>=1<<m)return 1/0;h+=4+m+p.bitData.length}return h}static toUtf8ByteArray(c){c=encodeURI(c);let d=[];for(let h=0;h<c.length;h++)c.charAt(h)!="%"?d.push(c.charCodeAt(h)):(d.push(parseInt(c.substring(h+1,h+3),16)),h+=2);return d}};i.NUMERIC_REGEX=/^[0-9]*$/,i.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,i.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let a=i;n.QrSegment=i})(xd||(xd={}));(n=>{(e=>{const t=class{constructor(r,i){this.ordinal=r,this.formatBits=i}};t.LOW=new t(0,1),t.MEDIUM=new t(1,0),t.QUARTILE=new t(2,3),t.HIGH=new t(3,2),e.Ecc=t})(n.QrCode||(n.QrCode={}))})(xd||(xd={}));(n=>{(e=>{const t=class{constructor(r,i){this.modeBits=r,this.numBitsCharCount=i}numCharCountBits(r){return this.numBitsCharCount[Math.floor((r+7)/17)]}};t.NUMERIC=new t(1,[10,12,14]),t.ALPHANUMERIC=new t(2,[9,11,13]),t.BYTE=new t(4,[8,16,16]),t.KANJI=new t(8,[8,10,12]),t.ECI=new t(7,[0,0,0]),e.Mode=t})(n.QrSegment||(n.QrSegment={}))})(xd||(xd={}));var Ah=xd;var tU={L:Ah.QrCode.Ecc.LOW,M:Ah.QrCode.Ecc.MEDIUM,Q:Ah.QrCode.Ecc.QUARTILE,H:Ah.QrCode.Ecc.HIGH},Z7=128,eC="L",tC="#FFFFFF",nC="#000000",sC=!1,rC=1,nU=4,sU=0,rU=.1;function iC(n,e=0){const t=[];return n.forEach(function(s,r){let i=null;
9s.forEach(function(a,l){if(!a&&i!==null){t.push(`M${i+e} ${r+e}h${l-i}v1H${i+e}z`),i=null;return}if(l===s.length-1){if(!a)return;i===null?t.push(`M${l+e},${r+e} h1v1H${l+e}z`):t.push(`M${i+e},${r+e} h${l+1-i}v1H${i+e}z`);return}a&&i===null&&(i=l)})}),t.join("")}function aC(n,e){return n.slice().map((t,s)=>s<e.y||s>=e.y+e.h?t:t.map((r,i)=>i<e.x||i>=e.x+e.w?r:!1))}function iU(n,e,t,s){if(s==null)return null;const r=n.length+t*2,i=Math.floor(e*rU),a=r/e,l=(s.width||i)*a,c=(s.height||i)*a,d=s.x==null?n.length/2-l/2:s.x*a,h=s.y==null?n.length/2-c/2:s.y*a,p=s.opacity==null?1:s.opacity;let m=null;if(s.excavate){let x=Math.floor(d),w=Math.floor(h),S=Math.ceil(l+d-x),_=Math.ceil(c+h-w);m={x,y:w,w:S,h:_}}const y=s.crossOrigin;return{x:d,y:h,h:c,w:l,excavation:m,opacity:p,crossOrigin:y}}function aU(n,e){return e!=null?Math.max(Math.floor(e),0):n?nU:sU}function oC({value:n,level:e,minVersion:t,includeMargin:s,marginSize:r,imageSettings:i,size:a,boostLevel:l}){let c=Tn.useMemo(()=>{const x=(Array.isArray(n)?n:[n]).reduce((w,S)=>(w.push(...Ah.QrSegment.makeSegments(S)),w),[]);return Ah.QrCode.encodeSegments(x,tU[e],t,void 0,void 0,l)},[n,e,t,l]);const{cells:d,margin:h,numCells:p,calculatedImageSettings:m}=Tn.useMemo(()=>{let y=c.getModules();const x=aU(s,r),w=y.length+x*2,S=iU(y,a,x,i);return{cells:y,margin:x,numCells:w,calculatedImageSettings:S}},[c,a,i,s,r]);return{qrcode:c,margin:h,cells:d,numCells:p,calculatedImageSettings:m}}var oU=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),lU=Tn.forwardRef(function(e,t){const s=e,{value:r,size:i=Z7,level:a=eC,bgColor:l=tC,fgColor:c=nC,includeMargin:d=sC,minVersion:h=rC,boostLevel:p,marginSize:m,imageSettings:y}=s,w=wb(s,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:S}=w,_=wb(w,["style"]),L=y?.src,R=Tn.useRef(null),M=Tn.useRef(null),V=Tn.useCallback(fe=>{R.current=fe,typeof t=="function"?t(fe):t&&(t.current=fe)},[t]),[W,I]=Tn.useState(!1),{margin:k,cells:P,numCells:N,calculatedImageSettings:F}=oC({value:r,level:a,minVersion:h,boostLevel:p,includeMargin:d,marginSize:m,imageSettings:y,size:i});Tn.useEffect(()=>{if(R.current!=null){const fe=R.current,oe=fe.getContext("2d");if(!oe)return;let X=P;const Q=M.current,G=F!=null&&Q!==null&&Q.complete&&Q.naturalHeight!==0&&Q.naturalWidth!==0;G&&F.excavation!=null&&(X=aC(P,F.excavation));const Y=window.devicePixelRatio||1;fe.height=fe.width=i*Y;const ee=i/N*Y;oe.scale(ee,ee),oe.fillStyle=l,oe.fillRect(0,0,N,N),oe.fillStyle=c,oU?oe.fill(new Path2D(iC(X,k))):P.forEach(function(H,K){H.forEach(function(pe,Fe){pe&&oe.fillRect(Fe+k,K+k,1,1)})}),F&&(oe.globalAlpha=F.opacity),G&&oe.drawImage(Q,F.x+k,F.y+k,F.w,F.h)}}),Tn.useEffect(()=>{I(!1)},[L]);const z=bb({height:i,width:i},S);let U=null;return L!=null&&(U=Tn.createElement("img",{src:L,key:L,style:{display:"none"},onLoad:()=>{I(!0)},ref:M,crossOrigin:F?.crossOrigin})),Tn.createElement(Tn.Fragment,null,Tn.createElement("canvas",bb({style:z,height:i,width:i,ref:V,role:"img"},_)),U)});lU.displayName="QRCodeCanvas";var l4=Tn.forwardRef(function(e,t){const s=e,{value:r,size:i=Z7,level:a=eC,bgColor:l=tC,fgColor:c=nC,includeMargin:d=sC,minVersion:h=rC,boostLevel:p,title:m,marginSize:y,imageSettings:x}=s,w=wb(s,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:S,cells:_,numCells:L,calculatedImageSettings:R}=oC({value:r,level:a,minVersion:h,boostLevel:p,includeMargin:d,marginSize:y,imageSettings:x,size:i});let M=_,V=null;x!=null&&R!=null&&(R.excavation!=null&&(M=aC(_,R.excavation)),V=Tn.createElement("image",{href:x.src,height:R.h,width:R.w,x:R.x+S,y:R.y+S,preserveAspectRatio:"none",opacity:R.opacity,crossOrigin:R.crossOrigin}));const W=iC(M,S);return Tn.createElement("svg",bb({height:i,width:i,viewBox:`0 0 ${L} ${L}`,ref:t,role:"img"},w),!!m&&Tn.createElement("title",null,m),Tn.createElement("path",{fill:l,d:`M0,0 h${L}v${L}H0z`,shapeRendering:"crispEdges"}),Tn.createElement("path",{fill:c,d:W,shapeRendering:"crispEdges"}),V)});l4.displayName="QRCodeSVG";const cU="/assets/ChronicBrandsFont_1766124908465-DFtn3dof.png",uU="/assets/BrandsFont_1766128091942-Su6rLfdc.png",dU={xs:"60px",sm:"70px",base:"80px",lg:"90px",xl:"100px","2xl":"120px","3xl":"150px","4xl":"180px"};function hU(n){const e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);if(!e)return null;let t=parseInt(e[1],16)/255,s=parseInt(e[2],16)/255,r=parseInt(e[3],16)/255;const i=Math.max(t,s,r),a=Math.min(t,s,r);let l=0,c=0;const d=(i+a)/2;if(i!==a){const h=i-a;switch(c=d>.5?h/(2-i-a):h/(i+a),i){case t:l=((s-r)/h+(s<r?6:0))/6;break;case s:l=((r-t)/h+2)/6;break;case r:l=((t-s)/h+4)/6;break}}return{h:l*360,s:c*100,l:d*100}}function fU(n){const e=n.match(/hsl\(\s*(\d+)\s*,\s*(\d+(?:\.\d+)?)\s*%\s*,\s*(\d+(?:\.\d+)?)\s*%\s*\)/);return e?{h:parseFloat(e[1]),s:parseFloat(e[2]),l:parseFloat(e[3])}:null}function pU(n){if(!n)return"invert(1)";let e=hU(n);if(e||(e=fU(n)),!e)return"invert(1)";const t=e.h-50,s=Math.max(.5,e.s/50),r=e.l/50*.9;return`invert(1) grayscale(100%) sepia(100%) saturate(${s.toFixed(2)}) hue-rotate(${t.toFixed(0)}deg) brightness(${r.toFixed(2)})`}function mU({size:n="base",color:e,className:t="",style:s}){const r=dU[n],i=pU(e||"");return o.jsx("img",{src:uU,alt:"Brands",style:{height:r,width:"auto",filter:i,display:"inline-block",...s},className:t})}const gU={xs:{textHeight:12,containerHeight:12,suffixClass:"text-xs"},sm:{textHeight:14,containerHeight:14,suffixClass:"text-sm"},base:{textHeight:16,containerHeight:16,suffixClass:"text-base"},lg:{textHeight:18,containerHeight:18,suffixClass:"text-lg"},xl:{textHeight:20,containerHeight:20,suffixClass:"text-xl"},"2xl":{textHeight:24,containerHeight:24,suffixClass:"text-2xl"},"3xl":{textHeight:30,containerHeight:30,suffixClass:"text-3xl"},"4xl":{textHeight:36,containerHeight:36,suffixClass:"text-4xl"}};function xU(n){const e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);if(!e)return null;let t=parseInt(e[1],16)/255,s=parseInt(e[2],16)/255,r=parseInt(e[3],16)/255;const i=Math.max(t,s,r),a=Math.min(t,s,r);let l=0,c=0;const d=(i+a)/2;if(i!==a){const h=i-a;switch(c=d>.5?h/(2-i-a):h/(i+a),i){case t:l=((s-r)/h+(s<r?6:0))/6;break;case s:l=((r-t)/h+2)/6;break;case r:l=((t-s)/h+4)/6;break}}return{h:l*360,s:c*100,l:d*100}}function yU(n){if(!n||n==="#4ade80")return"none";const e=xU(n);if(!e)return"none";const t=e.h-50,s=Math.max(.5,e.s/50),r=e.l/50*.9;return`grayscale(100%) sepia(100%) saturate(${s.toFixed(2)}) hue-rotate(${t.toFixed(0)}deg) brightness(${r.toFixed(2)})`}function Is({suffix:n="",size:e="base",color:t,suffixColor:s="hsl(45,93%,47%)",className:r="",style:i}){const a=gU[e],l=t?yU(t):"none",c=80,d=a.textHeight/16,h=c*d,p=h*.38;return o.jsxs("span",{className:r,style:{display:"inline",...i},children:[o.jsx("img",{src:cU,alt:"Chronic",style:{height:`${h}px`,width:"auto",filter:l,display:"inline-block",verticalAlign:"middle",marginTop:`-${p}px`,marginBottom:`-${p}px`}}),n&&(n.trim().toLowerCase()==="brands"?o.jsx(mU,{size:e,color:s,style:{marginLeft:"-8px"}}):o.jsx("span",{className:a.suffixClass,style:{color:s},children:n}))]})}const OT="/assets/usa_trimmed-oRlC1gZT.png",vU=()=>{};var MT={};const lC=function(n){const e=[];let t=0;for(let s=0;s<n.length;s++){let r=n.charCodeAt(s);r<128?e[t++]=r:r<2048?(e[t++]=r>>6|192,e[t++]=r&63|128):(r&64512)===55296&&s+1<n.length&&(n.charCodeAt(s+1)&64512)===56320?(r=65536+((r&1023)<<10)+(n.charCodeAt(++s)&1023),e[t++]=r>>18|240,e[t++]=r>>12&63|128,e[t++]=r>>6&63|128,e[t++]=r&63|128):(e[t++]=r>>12|224,e[t++]=r>>6&63|128,e[t++]=r&63|128)}return e},bU=function(n){const e=[];let t=0,s=0;for(;t<n.length;){const r=n[t++];if(r<128)e[s++]=String.fromCharCode(r);else if(r>191&&r<224){const i=n[t++];e[s++]=String.fromCharCode((r&31)<<6|i&63)}else if(r>239&&r<365){const i=n[t++],a=n[t++],l=n[t++],c=((r&7)<<18|(i&63)<<12|(a&63)<<6|l&63)-65536;e[s++]=String.fromCharCode(55296+(c>>10)),e[s++]=String.fromCharCode(56320+(c&1023))}else{const i=n[t++],a=n[t++];e[s++]=String.fromCharCode((r&15)<<12|(i&63)<<6|a&63)}}return e.join("")},cC={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:typeof atob=="function",encodeByteArray(n,e){if(!Array.isArray(n))throw Error("encodeByteArray takes an array as a parameter");this.init_();const t=e?this.byteToCharMapWebSafe_:this.byteToCharMap_,s=[];for(let r=0;r<n.length;r+=3){const i=n[r],a=r+1<n.length,l=a?n[r+1]:0,c=r+2<n.length,d=c?n[r+2]:0,h=i>>2,p=(i&3)<<4|l>>4;let m=(l&15)<<2|d>>6,y=d&63;c||(y=64,a||(m=64)),s.push(t[h],t[p],t[m],t[y])}return s.join("")},encodeString(n,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(n):this.encodeByteArray(lC(n),e)},decodeString(n,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(n):bU(this.decodeStringToByteArray(n,e))},decodeStringToByteArray(n,e){this.init_();const t=e?this.charToByteMapWebSafe_:this.charToByteMap_,s=[];for(let r=0;r<n.length;){const i=t[n.charAt(r++)],l=r<n.length?t[n.charAt(r)]:0;++r;
9const d=r<n.length?t[n.charAt(r)]:64;++r;const p=r<n.length?t[n.charAt(r)]:64;if(++r,i==null||l==null||d==null||p==null)throw new wU;const m=i<<2|l>>4;if(s.push(m),d!==64){const y=l<<4&240|d>>2;if(s.push(y),p!==64){const x=d<<6&192|p;s.push(x)}}}return s},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let n=0;n<this.ENCODED_VALS.length;n++)this.byteToCharMap_[n]=this.ENCODED_VALS.charAt(n),this.charToByteMap_[this.byteToCharMap_[n]]=n,this.byteToCharMapWebSafe_[n]=this.ENCODED_VALS_WEBSAFE.charAt(n),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[n]]=n,n>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(n)]=n,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(n)]=n)}}};class wU extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}const SU=function(n){const e=lC(n);return cC.encodeByteArray(e,!0)},t1=function(n){return SU(n).replace(/\./g,"")},uC=function(n){try{return cC.decodeString(n,!0)}catch{}return null};function EU(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("Unable to locate global object.")}const TU=()=>EU().__FIREBASE_DEFAULTS__,_U=()=>
9{if(typeof process>"u"||typeof MT>"u")return;const n=MT.__FIREBASE_DEFAULTS__;if(n)return JSON.parse(n)},IU=()=>{if(typeof document>"u")return;let n;try{n=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch{return}const e=n&&uC(n[1]);return e&&JSON.parse(e)},cx=()=>{try{return vU()||TU()||_U()||IU()}catch{return}},dC=n=>cx()?.emulatorHosts?.[n],hC=n=>{const e=dC(n);if(!e)return;const t=e.lastIndexOf(":");if(t<=0||t+1===e.length)throw new Error(`Invalid host ${e} with no separate hostname and port!`);const s=parseInt(e.substring(t+1),10);return e[0]==="["?[e.substring(1,t-1),s]:[e.substring(0,t),s]},fC=()=>cx()?.config,pC=n=>cx()?.[`_${n}`];class mC{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}wrapCallback(e){return(t,s)=>{t?this.reject(t):this.resolve(s),typeof e=="function"&&(this.promise.catch(()=>{}),e.length===1?e(t):e(t,s))}}}function gC(n,e){if(n.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');const t={alg:"none",type:"JWT"},s=e||"demo-project",r=n.iat||0,i=n.sub||n.user_id;if(!i)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const a={iss:`https://securetoken.google.com/${s}`,aud:s,iat:r,exp:r+3600,auth_time:r,sub:i,user_id:i,firebase:{sign_in_provider:"custom",identities:{}},...n};return[t1(JSON.stringify(t)),t1(JSON.stringify(a)),""].join(".")}function Ur(){return typeof navigator<"u"&&typeof navigator.userAgent=="string"?navigator.userAgent:""}function AU(){return typeof window<"u"&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(Ur())}function CU(){const n=cx()?.forceEnvironment;if(n==="node")return!0;if(n==="browser")return!1;try{return Object.prototype.toString.call(global.process)==="[object process]"}catch{return!1}}function kU(){return typeof navigator<"u"&&navigator.userAgent==="Cloudflare-Workers"}function xC(){const n=typeof chrome=="object"?chrome.runtime:typeof browser=="object"?browser.runtime:void 0;return typeof n=="object"&&n.id!==void 0}function RU(){return typeof navigator=="object"&&navigator.product==="ReactNative"}function PU(){const n=Ur();return n.indexOf("MSIE ")>=0||n.indexOf("Trident/")>=0}function NU(){return!CU()&&!!navigator.userAgent&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")}function yC(){try{return typeof indexedDB=="object"}catch{return!1}}function vC(){return new Promise((n,e)=>{try{let t=!0;const s="validate-browser-context-for-indexeddb-analytics-module",r=self.indexedDB.open(s);r.onsuccess=()=>{r.result.close(),t||self.indexedDB.deleteDatabase(s),n(!0)},r.onupgradeneeded=()=>{t=!1},r.onerror=()=>{e(r.error?.message||"")}}catch(t){e(t)}})}function LU(){return!(typeof navigator>"u"||!navigator.cookieEnabled)}const DU="FirebaseError";class Ra extends Error{constructor(e,t,s){super(t),this.code=e,this.customData=s,this.name=DU,Object.setPrototypeOf(this,Ra.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,Ad.prototype.create)}}class Ad{constructor(e,t,s){this.service=e,this.serviceName=t,this.errors=s}create(e,...t){const s=t[0]||{},r=`${this.service}/${e}`,i=this.errors[e],a=i?jU(i,s):"Error",l=`${this.serviceName}: ${a} (${r}).`;return new Ra(r,l,s)}}function jU(n,e){return n.replace(OU,(t,s)=>{const r=e[s];return r!=null?String(r):`<${s}?>`})}const OU=/\{\$([^}]+)}/g;function MU(n){for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e))return!1;return!0}function qo(n,e){if(n===e)return!0;const t=Object.keys(n),s=Object.keys(e);for(const r of t){if(!s.includes(r))return!1;const i=n[r],a=e[r];if(FT(i)&&FT(a)){if(!qo(i,a))return!1}else if(i!==a)return!1}for(const r of s)if(!t.includes(r))return!1;return!0}function FT(n){return n!==null&&typeof n=="object"}function pf(n){const e=[];for(const[t,s]of Object.entries(n))Array.isArray(s)?s.forEach(r=>{e.push(encodeURIComponent(t)+"="+encodeURIComponent(r))}):e.push(encodeURIComponent(t)+"="+encodeURIComponent(s));return e.length?"&"+e.join("&"):""}function pp(n){const e={};return n.replace(/^\?/,"").split("&").forEach(s=>{if(s){const[r,i]=s.split("=");e[decodeURIComponent(r)]=decodeURIComponent(i)}}),e}function mp(n){const e=n.indexOf("?");if(!e)return"";const t=n.indexOf("#",e);return n.substring(e,t>0?t:void 0)}function FU(n,e){const t=new UU(n,e);return t.subscribe.bind(t)}class UU{constructor(e,t){this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Prom
9ise.resolve(),this.finalized=!1,this.onNoObservers=t,this.task.then(()=>{e(this)}).catch(s=>{this.error(s)})}next(e){this.forEachObserver(t=>{t.next(e)})}error(e){this.forEachObserver(t=>{t.error(e)}),this.close(e)}complete(){this.forEachObserver(e=>{e.complete()}),this.close()}subscribe(e,t,s){let r;if(e===void 0&&t===void 0&&s===void 0)throw new Error("Missing Observer.");VU(e,["next","error","complete"])?r=e:r={next:e,error:t,complete:s},r.next===void 0&&(r.next=$2),r.error===void 0&&(r.error=$2),r.complete===void 0&&(r.complete=$2);const i=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(()=>{try{this.finalError?r.error(this.finalError):r.complete()}catch{}}),this.observers.push(r),i}unsubscribeOne(e){this.observers===void 0||this.observers[e]===void 0||(delete this.observers[e],this.observerCount-=1,this.observerCount===0&&this.onNoObservers!==void 0&&this.onNoObservers(this))}forEachObserver(e){if(!this.finalized)for(let t=0;t<this.observers.length;t++)this.sendOne(t,e)}sendOne(e,t){this.task.then(()=>{if(this.observers!==void 0&&this.observers[e]!==void 0)try{t(this.observers[e])}catch{}})}close(e){this.finalized||(this.finalized=!0,e!==void 0&&(this.finalError=e),this.task.then(()=>{this.observers=void 0,this.onNoObservers=void 0}))}}function VU(n,e){if(typeof n!="object"||n===null)return!1;for(const t of e)if(t in n&&typeof n[t]=="function")return!0;return!1}function $2(){}const BU=1e3,zU=2,$U=14400*1e3,HU=.5;function UT(n,e=BU,t=zU){const s=e*Math.pow(t,n),r=Math.round(HU*s*(Math.random()-.5)*2);return Math.min($U,s+r)}function wt(n){return n&&n._delegate?n._delegate:n}function Cd(n){try{return(n.startsWith("http://")||n.startsWith("https://")?new URL(n).hostname:n).endsWith(".cloudworkstations.dev")}catch{return!1}}async function c4(n){return(await fetch(n,{credentials:"include"})).ok}class Ia{constructor(e,t,s){this.name=e,this.instanceFactory=t,this.type=s,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(e){return this.instantiationMode=e,this}setMultipleInstances(e){return this.multipleInstances=e,this}setServiceProps(e){return this.serviceProps=e,this}setInstanceCreatedCallback(e){return this.onInstanceCreated=e,this}}const Wu="[DEFAULT]";class WU{constructor(e,t){this.name=e,this.container=t,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(e){const t=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(t)){const s=new mC;if(this.instancesDeferred.set(t,s),this.isInitialized(t)||this.shouldAutoInitialize())try{const r=this.getOrInitializeService({instanceIdentifier:t});r&&s.resolve(r)}catch{}}return this.instancesDeferred.get(t).promise}getImmediate(e){const t=this.normalizeInstanceIdentifier(e?.identifier),s=e?.optional??!1;if(this.isInitialized(t)||this.shouldAutoInitialize())try{return this.getOrInitializeService({instanceIdentifier:t})}catch(r){if(s)return null;throw r}else{if(s)return null;throw Error(`Service ${this.name} is not available`)}}getComponent(){return this.component}setComponent(e){if(e.name!==this.name)throw Error(`Mismatching Component ${e.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=e,!!this.shouldAutoInitialize()){if(KU(e))try{this.getOrInitializeService({instanceIdentifier:Wu})}catch{}for(const[t,s]of this.instancesDeferred.entries()){const r=this.normalizeInstanceIdentifier(t);try{const i=this.getOrInitializeService({instanceIdentifier:r});s.resolve(i)}catch{}}}}clearInstance(e=Wu){this.instancesDeferred.delete(e),this.instancesOptions.delete(e),this.instances.delete(e)}async delete(){const e=Array.from(this.instances.values());await Promise.all([...e.filter(t=>"INTERNAL"in t).map(t=>t.INTERNAL.delete()),...e.filter(t=>"_delete"in t).map(t=>t._delete())])}isComponentSet(){return this.component!=null}isInitialized(e=Wu){return this.instances.has(e)}getOptions(e=Wu){return this.instancesOptions.get(e)||{}}initialize(e={}){const{options:t={}}=e,s=this.normalizeInstanceIdentifier(e.instanceIdentifier);if(this.isInitialized(s))throw Error(`${this.name}(${s}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);const r=this.getOrInitializeService({instanceIdentifier:s,options:t});for(const[i,a]of this.instancesDeferred.entries()){const l=this.normalizeInstanceIdentifier(i);s===l&&a.resolve(r)}return r}onInit(e,t){const s=this.normalizeInstanceIdentifier(t),r=this.onInitCallbacks.get(s)??new Set;r.add(e),this.onInitCallbacks.set(s,r);const i=this.instances.get(s);return i&&e(i,s),()=>{r.delete(e)}}invokeOnInitCallbacks(e,t){const s=this.onInitCallbacks.get(t);if(s)for(const r of s)try{r(e,t)}catch{}}getOrInitializeService({instanceIdentifier:e,options:t={}}){let s=this.instances.get(e);if(!s&&this.component&&(s=this.component.instanceFactory(this.container,{instanceIdentifier:GU(e),options:t}),this.instances.set(e,s),this.instancesOptions.set(e,t),this.invokeOnInitCallbacks(s,e),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,e,s)}catch{}return s||null}normalizeInstanceIdentifier(e=Wu){return this.component?this.component.multipleInstances?e:Wu:e}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!=="EXPLICIT"}}function GU(n){return n===Wu?void 0:n}function KU(n){return n.instantiationMode==="EAGER"}class qU{constructor(e){this.name=e,this.providers=new Map}addComponent(e){const t=this.getProvider(e.name);if(t.isComponentSet())throw new Error(`Component ${e.name} has already been registered with ${this.name}`);t.setComponent(e)}addOrOverwriteComponent(e){this.getProvider(e.name).isComponentSet()&&this.providers.delete(e.name),this.addComponent(e)}getProvider(e){if(this.providers.has(e))return this.providers.get(e);const t=new WU(e,this);return this.providers.set(e,t),t}getProviders(){return Array.from(this.providers.values())}}var on;(function(n){n[n.DEBUG=0]="DEBUG",n[n.VERBOSE=1]="VERBOSE",n[n.INFO=2]="INFO",n[n.WARN=3]="WARN",n[n.ERROR=4]="ERROR",n[n.SILENT=5]="SILENT"})(on||(on={}));const YU={debug:on.DEBUG,verbose:on.VERBOSE,info:on.INFO,warn:on.WARN,error:on.ERROR,silent:on.SILENT},QU=on.INFO,XU={[on.DEBUG]:"log",[on.VERBOSE]:"log",[on.INFO]:"info",[on.WARN]:"warn",[on.ERROR]:"error"},JU=(n,e,...t)=>{if(e<n.logLevel)return;const s=new Date().toISOString(),r=XU[e];if(!r)throw new Error(`Attempted to log a message with an invali
9d logType (value: ${e})`)};let ux=class{constructor(e){this.name=e,this._logLevel=QU,this._logHandler=JU,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in on))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel=typeof e=="string"?YU[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if(typeof e!="function")throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=e}get userLogHandler(){return this._userLogHandler}set userLogHandler(e){this._userLogHandler=e}debug(...e){this._userLogHandler&&this._userLogHandler(this,on.DEBUG,...e),this._logHandler(this,on.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,on.VERBOSE,...e),this._logHandler(this,on.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,on.INFO,...e),this._logHandler(this,on.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,on.WARN,...e),this._logHandler(this,on.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,on.ERROR,...e),this._logHandler(this,on.ERROR,...e)}};const ZU=(n,e)=>e.some(t=>n instanceof t);let VT,BT;function eV(){return VT||(VT=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function tV(){return BT||(BT=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const bC=new WeakMap,Sb=new WeakMap,wC=new WeakMap,H2=new WeakMap,u4=new WeakMap;function nV(n){const e=new Promise((t,s)=>{const r=()=>{n.removeEventListener("success",i),n.removeEventListener("error",a)},i=()=>{t(zc(n.result)),r()},a=()=>{s(n.error),r()};n.addEventListener("success",i),n.addEventListener("error",a)});return e.then(t=>{t instanceof IDBCursor&&bC.set(t,n)}).catch(()=>{}),u4.set(e,n),e}function sV(n){if(Sb.has(n))return;const e=new Promise((t,s)=>{const r=()=>{n.removeEventListener("complete",i),n.removeEventListener("error",a),n.removeEventListener("abort",a)},i=()=>{t(),r()},a=()=>{s(n.error||new DOMException("AbortError","AbortError")),r()};n.addEventListener("complete",i),n.addEventListener("error",a),n.addEventListener("abort",a)});Sb.set(n,e)}let Eb={get(n,e,t){if(n instanceof IDBTransaction){if(e==="done")return Sb.get(n);if(e==="objectStoreNames")return n.objectStoreNames||wC.get(n);if(e==="store")return t.objectStoreNames[1]?void 0:t.objectStore(t.objectStoreNames[0])}return zc(n[e])},set(n,e,t){return n[e]=t,!0},has(n,e){return n instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in n}};function rV(n){Eb=n(Eb)}function iV(n){return n===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...t){const s=n.call(W2(this),e,...t);return wC.set(s,e.sort?e.sort():[e]),zc(s)}:tV().includes(n)?function(...e){return n.apply(W2(this),e),zc(bC.get(this))}:function(...e){return zc(n.apply(W2(this),e))}}function aV(n){return typeof n=="function"?iV(n):(n instanceof IDBTransaction&&sV(n),ZU(n,eV())?new Proxy(n,Eb):n)}function zc(n){if(n instanceof IDBRequest)return nV(n);if(H2.has(n))return H2.get(n);const e=aV(n);return e!==n&&(H2.set(n,e),u4.set(e,n)),e}const W2=n=>u4.get(n);function oV(n,e,{blocked:t,upgrade:s,blocking:r,terminated:i}={}){const a=indexedDB.open(n,e),l=zc(a);return s&&a.addEventListener("upgradeneeded",c=>{s(zc(a.result),c.oldVersion,c.newVersion,zc(a.transaction),c)}),t&&a.addEventListener("blocked",c=>t(c.oldVersion,c.newVersion,c)),l.then(c=>{i&&c.addEventListener("close",()=>i()),r&&c.addEventListener("versionchange",d=>r(d.oldVersion,d.newVersion,d))}).catch(()=>{}),l}const lV=["get","getKey","getAll","getAllKeys","count"],cV=["put","add","delete","clear"],G2=new Map;function zT(n,e){if(!(n instanceof IDBDatabase&&!(e in n)&&typeof e=="string"))return;if(G2.get(e))return G2.get(e);const t=e.replace(/FromIndex$/,""),s=e!==t,r=cV.includes(t);if(!(t in(s?IDBIndex:IDBObjectStore).prototype)||!(r||lV.includes(t)))return;const i=async function(a,...l){const c=this.transaction(a,r?"readwrite":"readonly");let d=c.store;
9return s&&(d=d.index(l.shift())),(await Promise.all([d[t](...l),r&&c.done]))[0]};return G2.set(e,i),i}rV(n=>({...n,get:(e,t,s)=>zT(e,t)||n.get(e,t,s),has:(e,t)=>!!zT(e,t)||n.has(e,t)}));class uV{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(t=>{if(dV(t)){const s=t.getImmediate();return`${s.library}/${s.version}`}else return null}).filter(t=>t).join(" ")}}function dV(n){return n.getComponent()?.type==="VERSION"}const Tb="@firebase/app",$T="0.15.0";const $l=new ux("@firebase/app"),hV="@firebase/app-compat",fV="@firebase/analytics-compat",pV="@firebase/analytics",mV="@firebase/app-check-compat",gV="@firebase/app-check",xV="@firebase/auth",yV="@firebase/auth-compat",vV="@firebase/database",bV="@firebase/data-connect",wV="@firebase/database-compat",SV="@firebase/functions",EV="@firebase/functions-compat",TV="@firebase/installations",_V="@firebase/installations-compat",IV="@firebase/messaging",AV="@firebase/messaging-compat",CV="@firebase/performance",kV="@firebase/performance-compat",RV="@firebase/remote-config",PV="@firebase/remote-config-compat",NV="@firebase/storage",LV="@firebase/storage-compat",DV="@firebase/firestore",jV="@firebase/ai",OV="@firebase/firestore-compat",MV="firebase",FV="12.15.0";const _b="[DEFAULT]",UV={[Tb]:"fire-core",[hV]:"fire-core-compat",[pV]:"fire-analytics",[fV]:"fire-analytics-compat",[gV]:"fire-app-check",[mV]:"fire-app-check-compat",[xV]:"fire-auth",[yV]:"fire-auth-compat",[vV]:"fire-rtdb",[bV]:"fire-data-connect",[wV]:"fire-rtdb-compat",[SV]:"fire-fn",[EV]:"fire-fn-compat",[TV]:"fire-iid",[_V]:"fire-iid-compat",[IV]:"fire-fcm",[AV]:"fire-fcm-compat",[CV]:"fire-perf",[kV]:"fire-perf-compat",[RV]:"fire-rc",[PV]:"fire-rc-compat",[NV]:"fire-gcs",[LV]:"fire-gcs-compat",[DV]:"fire-fst",[OV]:"fire-fst-compat",[jV]:"fire-vertex","fire-js":"fire-js",[MV]:"fire-js-all"};const qp=new Map,VV=new Map,Ib=new Map;function HT(n,e){try{n.container.addComponent(e)}catch(t){$l.debug(`Component ${e.name} failed to register with FirebaseApp ${n.name}`,t)}}function ho(n){const e=n.name;if(Ib.has(e))return $l.debug(`There were multiple attempts to register component ${e}.`),!1;Ib.set(e,n);for(const t of qp.values())HT(t,n);for(const t of VV.values())HT(t,n);return!0}function gu(n,e){const t=n.container.getProvider("heartbeat").getImmediate({optional:!0});return t&&t.triggerHeartbeat(),n.container.getProvider(e)}function Jn(n){return n==null?!1:n.settings!==void 0}const BV={"no-app":"No Firebase App '{$appName}' has been created - call initializeApp() first","bad-app-name":"Illegal App name: '{$appName}'","duplicate-app":"Firebase App named '{$appName}' already exists with different options or config","app-deleted":"Firebase App named '{$appName}' already deleted","server-app-deleted":"Firebase Server App has been deleted","no-options":"Need to provide options, when not being deployed to hosting via source.","invalid-app-argument":"firebase.{$appName}() takes either no argument or a Firebase App instance.","invali
9d-log-argument":"First argument to `onLog` must be null or a function.","idb-open":"Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.","idb-get":"Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.","idb-set":"Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.","idb-delete":"Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.","finalization-registry-not-supported":"FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.","invalid-server-app-environment":"FirebaseServerApp is not for use in browser environments."},$c=new Ad("app","Firebase",BV);class zV{constructor(e,t,s){this._isDeleted=!1,this._options={...e},this._config={...t},this._name=t.name,this._automaticDataCollectionEnabled=t.automaticDataCollectionEnabled,this._container=s,this.container.addComponent(new Ia("app",()=>this,"PUBLIC"))}get automaticDataCollectionEnabled(){return this.checkDestroyed(),this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(e){this.checkDestroyed(),this._automaticDataCollectionEnabled=e}get name(){return this.checkDestroyed(),this._name}get options(){return this.checkDestroyed(),this._options}get config(){return this.checkDestroyed(),this._config}get container(){return this._container}get isDeleted(){return this._isDeleted}set isDeleted(e){this._isDeleted=e}checkDestroyed(){if(this.isDeleted)throw $c.create("app-deleted",{appName:this._name})}}const kd=FV;function d4(n,e={}){let t=n;typeof e!="object"&&(e={name:e});const s={name:_b,automaticDataCollectionEnabled:!0,...e},r=s.name;if(typeof r!="string"||!r)throw $c.create("bad-app-name",{appName:String(r)});if(t||(t=fC()),!t)throw $c.create("no-options");const i=qp.get(r);if(i){if(qo(t,i.options)&&qo(s,i.config))return i;throw $c.create("duplicate-app",{appName:r})}const a=new qU(r);for(const c of Ib.values())a.addComponent(c);const l=new zV(t,s,a);return qp.set(r,l),l}function Im(n=_b){const e=qp.get(n);if(!e&&n===_b&&fC())return d4();if(!e)throw $c.create("no-app",{appName:n});return e}function $V(){return Array.from(qp.values())}function _i(n,e,t){let s=UV[n]??n;t&&(s+=`-${t}`);const r=s.match(/\s|\//),i=e.match(/\s|\//);if(r||i){const a=[`Unable to register library "${s}" with version "${e}":`];r&&a.push(`library name "${s}" contains illegal characters (whitespace or "/")`),r&&i&&a.push("and"),i&&a.push(`version name "${e}" contains illegal characters (whitespace or "/")`),$l.warn(a.join(" "));return}ho(new Ia(`${s}-version`,()=>({library:s,version:e}),"VERSION"))}const HV="firebase-heartbeat-database",WV=1,Yp="firebase-heartbeat-store";let K2=null;function SC(){return K2||(K2=oV(HV,WV,{upgrade:(n,e)=>{switch(e){case 0:try{n.createObjectStore(Yp)}catch{}}}}).catch(n=>{throw $c.create("idb-open",{originalErrorMessage:n.message})})),K2}async function GV(n){try{const t=(await SC()).transaction(Yp),s=await t.objectStore(Yp).get(EC(n));return await t.done,s}catch(e){if(e instanceof Ra)$l.warn(e.message);else{const t=$c.create("idb-get",{originalErrorMessage:e?.message});$l.warn(t.message)}}}async function WT(n,e){try{const s=(await SC()).transaction(Yp,"readwrite");await s.objectStore(Yp).put(e,EC(n)),await s.done}catch(t){if(t instanceof Ra)$l.warn(t.message);else{const s=$c.create("idb-set",{originalErrorMessage:t?.message});$l.warn(s.message)}}}function EC(n){return`${n.name}!${n.options.appId}`}const KV=1024,qV=30;class YV{constructor(e){this.container=e,this._heartbeatsCache=null;const t=this.container.getProvider("app").getImmediate();this._storage=new XV(t),this._heartbeatsCachePromise=this._storage.read().then(s=>(this._heartbeatsCache=s,s))}async triggerHeartbeat(){try{const t=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),s=GT();if(this._heartbeatsCache?.heartbeats==null&&(this._heartbeatsCache=await this._heartbeatsCachePromise,this._heartbeatsCache?.heartbeats==null)||this._heartbeatsCache.lastSentHeartbeatDate===s||this._heartbeatsCache.heartbeats.some(r=>r.date===s))return;if(this._heartbeatsCache.heartbeats.push({date:s,agent:t}),this._heartbeatsCache.heartbeats.length>qV){const r=JV(this._heartbeatsCache.heartbeats);this._heartbeatsCache.heartbeats.splice(r,1)}return this._storage.overwrite(this._heartbeatsCache)}catch(e){$l.warn(e)}}async getHeartbeatsHeader(){try{if(this._heartbeatsCache===null&&await this._heartbeatsCachePromise,this._heartbeatsCache?.heartbeats==null||this._heartbeatsCache.heartbeats.length===0)return"";const e=GT(),{heartbeatsToSend:t,unsentEntries:s}=QV(this._heartbeatsCache.heartbeats),r=t1(JSON.stringify({version:2,heartbeats:t}));return this._heartbeatsCache.lastSentHeartbeatDate=e,s.length>0?(this._heartbeatsCache.heartbeats=s,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),r}catch(e){return $l.warn(e),""}}}function GT(){return new Date().toISOString().substring(0,10)}function QV(n,e=KV){const t=[];let s=n.slice();for(const r of n){const i=t.find(a=>a.agent===r.agent);if(i){if(i.dates.push(r.date),KT(t)>e){i.dates.pop();break}}else if(t.push({agent:r.agent,dates:[r.date]}),KT(t)>e){t.pop();break}s=s.slice(1)}return{heartbeatsToSend:t,unsentEntries:s}}class XV{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return yC()?vC().then(()=>!0).catch(()=>!1):!1}async read(){if(await this._canUseIndexedDBPromise){const t=await GV(this.app);return t?.heartbeats?t:{heartbeats:[]}}else return{heartbeats:[]}}async overwrite(e){if(await this._canUseIndexedDBPromise){const s=await this.read();return WT(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??s.lastSentHeartbeatDate,heartbeats:e.heartbeats})}else return}async add(e){if(await this._canUseIndexedDBPromise){const s=await this.read();return WT(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??s.lastSentHeartbeatDate,heartbeats:[...s.heartbeats,...e.heartbeats]})}else return}}function KT(n){return t1(JSON.stringify({version:2,heartbeats:n})).length}
vendor: 973 bytes, line 9
9function JV(n){if(n.length===0)return-1;let e=0,t=n[0].date;for(let s=1;s<n.length;s++)n[s].date<t&&(t=n[s].date,e=s);return e}function ZV(n){ho(new Ia("platform-logger",e=>new uV(e),"PRIVATE")),ho(new Ia("heartbeat",e=>new YV(e),"PRIVATE")),_i(Tb,$T,n),_i(Tb,$T,"esm2020"),_i("fire-js","")}ZV("");var eB="firebase",tB="12.15.0";_i(eB,tB,"app");const nB={PHONE:"phone",TOTP:"totp"},sB={FACEBOOK:"facebook.com",GITHUB:"github.com",GOOGLE:"google.com",PASSWORD:"password",PHONE:"phone",TWITTER:"twitter.com"},rB={EMAIL_LINK:"emailLink",EMAIL_PASSWORD:"password",FACEBOOK:"facebook.com",GITHUB:"github.com",GOOGLE:"google.com",PHONE:"phone",TWITTER:"twitter.com"},iB={LINK:"link",REAUTHENTICATE:"reauthenticate",SIGN_IN:"signIn"},aB={EMAIL_SIGNIN:"EMAIL_SIGNIN",PASSWORD_RESET:"PASSWORD_RESET",RECOVER_EMAIL:"RECOVER_EMAIL",REVERT_SECOND_FACTOR_ADDITION:"REVERT_SECOND_FACTOR_ADDITION",VERIFY_AND_CHANGE_EMAIL:"VERIFY_AND_CHANGE_EMAIL",VERIFY_EMAIL:"VERIFY_EMAIL"};function oB
vendor: 12,061 bytes, line 9
9(){return{"admin-restricted-operation":"This operation is restricted to administrators only.","argument-error":"","app-not-authorized":"This app, identified by the domain where it's hosted, is not authorized to use Firebase Authentication with the provided API key. Review your key configuration in the Google API console.","app-not-installed":"The requested mobile application corresponding to the identifier (Android package name or iOS bundle ID) provided is not installed on this device.","captcha-check-failed":"The reCAPTCHA response token provided is either invalid, expired, already used or the domain associated with it does not match the list of whitelisted domains.","code-expired":"The SMS code has expired. Please re-send the verification code to try again.","cordova-not-ready":"Cordova framework is not ready.","cors-unsupported":"This browser is not supported.","credential-already-in-use":"This credential is already associated with a different user account.","custom-token-mismatch":"The custom token corresponds to a different audience.","requires-recent-login":"This operation is sensitive and requires recent authentication. Log in again before retrying this request.","dependent-sdk-initialized-before-auth":"Another Firebase SDK was initialized and is trying to use Auth before Auth is initialized. Please be sure to call `initializeAuth` or `getAuth` before starting any other Firebase SDK.","dynamic-link-not-activated":"Please activate Dynamic Links in the Firebase Console and agree to the terms and conditions.","email-change-needs-verification":"Multi-factor users must always have a verified email.","email-already-in-use":"The email address is already in use by another account.","emulator-config-failed":'Auth instance has already been used to make a network call. Auth can no longer be configured to use the emulator. Try calling "connectAuthEmulator()" sooner.',"expired-action-code":"The action code has expired.","cancelled-popup-request":"This operation has been cancelled due to another conflicting popup being opened.","internal-error":"An internal AuthError has occurred.","invalid-app-credential":"The phone verification request contains an invalid application verifier. The reCAPTCHA token response is either invalid or expired.","invalid-app-id":"The mobile app identifier is not registered for the current project.","invalid-user-token":"This user's credential isn't valid for this project. This can happen if the user's token has been tampered with, or if the user isn't for the project associated with this API key.","invalid-auth-event":"An internal AuthError has occurred.","invalid-verification-code":"The SMS verification code used to create the phone auth credential is invalid. Please resend the verification code sms and be sure to use the verification code provided by the user.","invalid-continue-uri":"The continue URL provided in the request is invalid.","invalid-cordova-configuration":"The following Cordova plugins must be installed to enable OAuth sign-in: cordova-plugin-buildinfo, cordova-universal-links-plugin, cordova-plugin-browsertab, cordova-plugin-inappbrowser and cordova-plugin-customurlscheme.","invalid-custom-token":"The custom token format is incorrect. Please check the documentation.","invalid-dynamic-link-domain":"The provided dynamic link domain is not configured or authorized for the current project.","invalid-email":"The email address is badly formatted.","invalid-emulator-scheme":"Emulator URL must start with a valid scheme (http:// or https://).","invalid-api-key":"Your API key is invalid, please check you have copied it correctly.","invalid-cert-hash":"The SHA-1 certificate hash provided is invalid.","invalid-credential":"The supplied auth credential is incorrect, malformed or has expired.","invalid-message-payload":"The email template corresponding to this action contains invalid characters in its message. Please fix by going to the Auth email templates section in the Firebase Console.","invalid-multi-factor-session":"The request does not contain a valid proof of first factor successful sign-in.","invalid-oauth-provider":"EmailAuthProvider is not supported for this operation. This operation only supports OAuth providers.","invalid-oauth-client-id":"The OAuth client ID provided is either invalid or does not match the specified API key.","unauthorized-domain":"This domain is not authorized for OAuth operations for your Firebase project. Edit the list of authorized domains from the Firebase console.","invalid-action-code":"The action code is invalid. This can happen if the code is malformed, expired, or has already been used.","wrong-password":"The password is invalid or the user does not have a password.","invalid-persistence-type":"The specified persistence type is invalid. It can only be local, session or none.","invalid-phone-number":"The format of the phone number provided is incorrect. Please enter the phone number in a format that can be parsed into E.164 format. E.164 phone numbers are written in the format [+][country code][subscriber number including area code].","invalid-provider-id":"The specified provider ID is invalid.","invalid-recipient-email":"The email corresponding to this action failed to send as the provided recipient email address is invalid.","invalid-sender":"The email template corresponding to this action contains an invalid sender email or name. Please fix by going to the Auth email templates section in the Firebase Console.","invalid-verification-id":"The verification ID used to create the phone auth credential is invalid.","invalid-tenant-id":"The Auth instance's tenant ID is invalid.","login-blocked":"Login blocked by user-provided method: {$originalMessage}","missing-android-pkg-name":"An Android Package Name must be provided if the Android App is required to be installed.","auth-domain-config-required":"Be sure to include authDomain when calling firebase.initializeApp(), by following the instructions in the Firebase console.","missing-app-credential":"The phone verification request is missing an application verifier assertion. A reCAPTCHA response token needs to be provided.","missing-verification-code":"The phone auth credential was created with an empty SMS verification code.","missing-continue-uri":"A continue URL must be provided in the request.","missing-iframe-start":"An internal AuthError has occurred.","missing-ios-bundle-id":"An iOS Bundle ID must be provided if an App Store ID is provided.","missing-or-invalid-nonce":"The request does not contain a valid nonce. This can occur if the SHA-256 hash of the provided raw nonce does not match the hashed nonce in the ID token payload.","missing-password":"A non-empty password must be provided","missing-multi-factor-info":"No second factor identifier is provided.","missing-multi-factor-session":"The request is missing proof of first factor successful sign-in.","missing-phone-number":"To send verification codes, provide a phone number for the recipient.","missing-verification-id":"The phone auth credential was created with an empty verification ID.","app-deleted":"This instance of FirebaseApp has been deleted.","multi-factor-info-not-found":"The user does not have a second factor matching the identifier provided.","multi-factor-auth-required":"Proof of ownership of a second factor is required to complete sign-in.","account-exists-with-different-credential":"An account already exists with the same email address but different sign-in credentials. Sign in using a provider associated with this email address.","network-request-failed":"A network AuthError (such as timeout, interrupted connection or unreachable host) has occurred.","no-auth-event":"An internal AuthError has occurred.","no-such-provider":"User was not linked to an account with the given provider.","null-user":"A null user object was provided as the argument for an operation which requires a non-null user object.","operation-not-allowed":"The given sign-in provider is disabled for this Firebase project. Enable it in the Firebase console, under the sign-in method tab of the Auth section.","operation-not-supported-in-this-environment":'This operation is not supported in the environment this application is running on. "location.protocol" must be http, https or chrome-extension and web storage must be enabled.',"popup-blocked":"Unable to establish a connection with the popup. It may have been blocked by the browser.","popup-closed-by-user":"The popup has been closed by the user before finalizing the operation.","provider-already-linked":"User can only be linked to one identity for the given provider.","quota-exceeded":"The project's quota for this operation has been exceeded.","redirect-cancelled-by-user":"The redirect operation has been cancelled by the user before finalizing.","redirect-operation-pending":"A redirect sign-in operation is already pending.","rejected-credential":"The request contains malformed or mismatching credentials.","second-factor-already-in-use":"The second factor is already enrolled on this account.","maximum-second-factor-count-exceeded":"The maximum allowed number of second factors on a user has been exceeded.","tenant-id-mismatch":"The provided tenant ID does not match the Auth instance's tenant ID",timeout:"The operation has timed out.","user-token-expired":"The user's credential is no longer valid. The user must sign in again.","too-many-requests":"We have blocked all requests from this device due to unusual activity. Try again later.","unauthorized-continue-uri":"The domain of the continue URL is not whitelisted. Please whitelist the domain in the Firebase console.","unsupported-first-factor":"Enrolling a second factor or signing in with a multi-factor account requires sign-in with a supported first factor.","unsupported-persistence-type":"The current environment does not support the specified persistence type.","unsupported-tenant-operation":"This operation is not supported in a multi-tenant context.","unverified-email":"The operation requires a verified email.","user-cancelled":"The user did not grant your application the permissions it requested.","user-not-found":"There is no user record corresponding to this identifier. The user may have been deleted.","user-disabled":"The user account has been disabled by an administrator.","user-mismatch":"The supplied credentials do not correspond to the previously signed in user.","user-signed-out":"","weak-password":"The password must be 6 characters long or more.","web-storage-unsupported":"This browser is not supported or 3rd party cookies and data may be disabled.","already-initialized":"initializeAuth() has already been called with different options. To avoid this error, call initializeAuth() with the same options as when it was originally called, or call getAuth() to return the already initialized instance.","missing-recaptcha-token":"The reCAPTCHA token is missing when sending request to the backend.","invalid-recaptcha-token":"The reCAPTCHA token is invalid when sending request to the backend.","invalid-recaptcha-action":"The reCAPTCHA action is invalid when sending request to the backend.","recaptcha-not-enabled":"reCAPTCHA Enterprise integration is not enabled for this project.","missing-client-type":"The reCAPTCHA client type is missing when sending request to the backend.","missing-recaptcha-version":"The reCAPTCHA version is missing when sending request to the backend.","invalid-req-type":"Invalid request parameters.","invalid-recaptcha-version":"The reCAPTCHA version is invalid when sending request to the backend.","unsupported-password-policy-schema-version":"The password policy received from the backend uses a schema version that is not supported by this version of the Firebase SDK.","password-does-not-meet-requirements":"The password does not meet the requirements.","invalid-hosting-link-domain":"The provided Hosting link domain is not configured in Firebase Hosting or is not owned by the current project. This cannot be a default Hosting domain (`web.app` or `firebaseapp.com`)."}}
9function TC(){return{"dependent-sdk-initialized-before-auth":"Another Firebase SDK was initialized and is trying to use Auth before Auth is initialized. Please be sure to call `initializeAuth` or `getAuth` before starting any other Firebase SDK."}}const lB=oB,_C=TC,IC=new Ad("auth","Firebase",TC()),cB={ADMIN_ONLY_OPERATION:"auth/admin-restricted-operation",ARGUMENT_ERROR:"auth/argument-error",APP_NOT_AUTHORIZED:"auth/app-not-authorized",APP_NOT_INSTALLED:"auth/app-not-installed",CAPTCHA_CHECK_FAILED:"auth/captcha-check-failed",CODE_EXPIRED:"auth/code-expired",CORDOVA_NOT_READY:"auth/cordova-not-ready",CORS_UNSUPPORTED:"auth/cors-unsupported",CREDENTIAL_ALREADY_IN_USE:"auth/credential-already-in-use",CREDENTIAL_MISMATCH:"auth/custom-token-mismatch",CREDENTIAL_TOO_OLD_LOGIN_AGAIN:"auth/requires-recent-login",DEPENDENT_SDK_INIT_BEFORE_AUTH:"auth/dependent-sdk-initialized-before-auth",DYNAMIC_LINK_NOT_ACTIVATED:"auth/dynamic-link-not-activated",EMAIL_CHANGE_NEEDS_VERIFICATION:"auth/email-change-needs-verification",EMAIL_EXISTS:"auth/email-already-in-use",EMULATOR_CONFIG_FAILED:"auth/emulator-config-failed",EXPIRED_OOB_CODE:"auth/expired-action-code",EXPIRED_POPUP_REQUEST:"auth/cancelled-popup-request",INTERNAL_ERROR:"auth/internal-error",INVALID_API_KEY:"auth/invalid-api-key",INVALID_APP_CREDENTIAL:"auth/invalid-app-credential",INVALID_APP_ID:"auth/invalid-app-id",INVALID_AUTH:"auth/invalid-user-token",INVALID_AUTH_EVENT:"auth/invalid-auth-event",INVALID_CERT_HASH:"auth/invalid-cert-hash",INVALID_CODE:"auth/invalid-verification-code",INVALID_CONTINUE_URI:"auth/invalid-continue-uri",INVALID_CORDOVA_CONFIGURATION:"auth/invalid-cordova-configuration",INVALID_CUSTOM_TOKEN:"auth/invalid-custom-token",INVALID_DYNAMIC_LINK_DOMAIN:"auth/invalid-dynamic-link-domain",INVALID_EMAIL:"auth/invalid-email",INVALID_EMULATOR_SCHEME:"auth/invalid-emulator-scheme",INVALID_IDP_RESPONSE:"auth/invalid-credential",INVALID_LOGIN_CREDENTIALS:"auth/invalid-credential",INVALID_MESSAGE_PAYLOAD:"auth/invalid-message-payload",INVALID_MFA_SESSION:"auth/invalid-multi-factor-session",INVALID_OAUTH_CLIENT_ID:"auth/invalid-oauth-client-id",INVALID_OAUTH_PROVIDER:"auth/invalid-oauth-provider",INVALID_OOB_CODE:"auth/invalid-action-code",INVALID_ORIGIN:"auth/unauthorized-domain",INVALID_PASSWORD:"auth/wrong-password",INVALID_PERSISTENCE:"auth/invalid-persistence-type",INVALID_PHONE_NUMBER:"auth/invalid-phone-number",INVALID_PROVIDER_ID:"auth/invalid-provider-id",INVALID_RECIPIENT_EMAIL:"auth/invalid-recipient-email",INVALID_SENDER:"auth/invalid-sender",INVALID_SESSION_INFO:"auth/invalid-verification-id",INVALID_TENANT_ID:"auth/invalid-tenant-id",MFA_INFO_NOT_FOUND:"auth/multi-factor-info-not-found",MFA_REQUIRED:"auth/multi-factor-auth-required",MISSING_ANDROID_PACKAGE_NAME:"auth/missing-android-pkg-name",MISSING_APP_CREDENTIAL:"auth/missing-app-credential",MISSING_AUTH_DOMAIN:"auth/auth-domain-config-required",MISSING_CODE:"auth/missing-verification-code",MISSING_CONTINUE_URI:"auth/missing-continue-uri",MISSING_IFRAME_START:"auth/missing-iframe-start",MISSING_IOS_BUNDLE_ID:"auth/missing-ios-bundle-id",MISSING_OR_INVALID_
9NONCE:"auth/missing-or-invalid-nonce",MISSING_MFA_INFO:"auth/missing-multi-factor-info",MISSING_MFA_SESSION:"auth/missing-multi-factor-session",MISSING_PHONE_NUMBER:"auth/missing-phone-number",MISSING_PASSWORD:"auth/missing-password",MISSING_SESSION_INFO:"auth/missing-verification-id",MODULE_DESTROYED:"auth/app-deleted",NEED_CONFIRMATION:"auth/account-exists-with-different-credential",NETWORK_REQUEST_FAILED:"auth/network-request-failed",NULL_USER:"auth/null-user",NO_AUTH_EVENT:"auth/no-auth-event",NO_SUCH_PROVIDER:"auth/no-such-provider",OPERATION_NOT_ALLOWED:"auth/operation-not-allowed",OPERATION_NOT_SUPPORTED:"auth/operation-not-supported-in-this-environment",POPUP_BLOCKED:"auth/popup-blocked",POPUP_CLOSED_BY_USER:"auth/popup-closed-by-user",PROVIDER_ALREADY_LINKED:"auth/provider-already-linked",QUOTA_EXCEEDED:"auth/quota-exceeded",REDIRECT_CANCELLED_BY_USER:"auth/redirect-cancelled-by-user",REDIRECT_OPERATION_PENDING:"auth/redirect-operation-pending",REJECTED_CREDENTIAL:"auth/rejected-credential",SECOND_FACTOR_ALREADY_ENROLLED:"auth/second-factor-already-in-use",SECOND_FACTOR_LIMIT_EXCEEDED:"auth/maximum-second-factor-count-exceeded",TENANT_ID_MISMATCH:"auth/tenant-id-mismatch",TIMEOUT:"auth/timeout",TOKEN_EXPIRED:"auth/user-token-expired",TOO_MANY_ATTEMPTS_TRY_LATER:"auth/too-many-requests",UNAUTHORIZED_DOMAIN:"auth/unauthorized-continue-uri",UNSUPPORTED_FIRST_FACTOR:"auth/unsupported-first-factor",UNSUPPORTED_PERSISTENCE:"auth/unsupported-persistence-type",UNSUPPORTED_TENANT_OPERATION:"auth/unsupported-tenant-operation",UNVERIFIED_EMAIL:"auth/unverified-email",USER_CANCELLED:"auth/user-cancelled",USER_DELETED:"auth/user-not-found",USER_DISABLED:"auth/user-disabled",USER_MISMATCH:"auth/user-mismatch",USER_SIGNED_OUT:"auth/user-signed-out",WEAK_PASSWORD:"auth/weak-password",WEB_STORAGE_UNSUPPORTED:"auth/web-storage-unsupported",ALREADY_INITIALIZED:"auth/already-initialized",RECAPTCHA_NOT_ENABLED:"auth/recaptcha-not-enabled",MISSING_RECAPTCHA_TOKEN:"auth/missing-recaptcha-token",INVALID_RECAPTCHA_TOKEN:"auth/invalid-recaptcha-token",INVALID_RECAPTCHA_ACTION:"auth/invalid-recaptcha-action",MISSING_CLIENT_TYPE:"auth/missing-client-type",MISSING_RECAPTCHA_VERSION:"auth/missing-recaptcha-version",INVALID_RECAPTCHA_VERSION:"auth/invalid-recaptcha-version",INVALID_REQ_TYPE:"auth/invalid-req-type",INVALID_HOSTING_LINK_DOMAIN:"auth/invalid-hosting-link-domain"};const n1=new ux("@firebase/auth");function uB(n,...e){n1.logLevel<=on.WARN&&n1.warn(`Auth (${kd}): ${n}`,...e)}function w0(n,...e){n1.logLevel<=on.ERROR&&n1.error(`Auth (${kd}): ${n}`,...e)}function Ci(n,...e){throw f4(n,...e)}function si(n,...e){return f4(n,...e)}function h4(n,e,t){const s={..._C(),[e]:t};return new Ad("auth","Firebase",s).create(e,{appName:n.name})}function dr(n){return h4(n,"operation-not-supported-in-this-environment","Operations that alter the current user are not supported in conjunction with FirebaseServerApp")}function mf(n,e,t){const s=t;if(!(e instanceof s))throw s.name!==e.constructor.name&&Ci(n,"argument-error"),h4(n,"argument-error",`Type of ${e.constructor.name} does not match expected instance.Did you pass a reference from a different Auth SDK?`)}function f4(n,...e){if(typeof n!="string"){const t=e[0],s=[...e.slice(1)];return s[0]&&(s[0].appName=n.name),n._errorFactory.create(t,...s)}return IC.create(n,...e)}function We(n,e,...t){if(!n)throw f4(e,...t)}function Uo(n){const e="INTERNAL ASSERTION FAILED: "+n;throw w0(e),new Error(e)}function Hl(n,e){n||Uo(e)}function Qp(){return typeof self<"u"&&self.location?.href||""}function p4(){return qT()==="http:"||qT()==="https:"}function qT(){return typeof self<"u"&&self.location?.protocol||null}function dB(){return typeof navigator<"u"&&navigator&&"onLine"in navigator&&typeof navigator.onLine=="boolean"&&(p4()||xC()||"connection"in navigator)?navigator.onLine:!0}function hB(){if(typeof navigator>"u")return null;const n=navigator;return n.languages&&n.languages[0]||n.language||null}class Am{constructor(e,t){this.shortDelay=e,this.longDelay=t,Hl(t>e,"Short delay should be less than long delay!"),this.isMobile=AU()||RU()}get(){return dB()?this.isMobile?this.longDelay:this.shortDelay:Math.min(5e3,this.shortDelay)}}function m4(n,e){Hl(n.emulator,"Emulator should always be set here");const{url:t}=n.emulator;return e?`${t}${e.startsWith("/")?e.slice(1):e}`:t}
9class AC{static initialize(e,t,s){this.fetchImpl=e,t&&(this.headersImpl=t),s&&(this.responseImpl=s)}static fetch(){if(this.fetchImpl)return this.fetchImpl;if(typeof self<"u"&&"fetch"in self)return self.fetch;if(typeof globalThis<"u"&&globalThis.fetch)return globalThis.fetch;if(typeof fetch<"u")return fetch;Uo("Could not find fetch implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static headers(){if(this.headersImpl)return this.headersImpl;if(typeof self<"u"&&"Headers"in self)return self.Headers;if(typeof globalThis<"u"&&globalThis.Headers)return globalThis.Headers;if(typeof Headers<"u")return Headers;Uo("Could not find Headers implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static response(){if(this.responseImpl)return this.responseImpl;if(typeof self<"u"&&"Response"in self)return self.Response;if(typeof globalThis<"u"&&globalThis.Response)return globalThis.Response;if(typeof Response<"u")return Response;Uo("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}}const fB={CREDENTIAL_MISMATCH:"custom-token-mismatch",MISSING_CUSTOM_TOKEN:"internal-error",INVALID_IDENTIFIER:"invalid-email",MISSING_CONTINUE_URI:"internal-error",INVALID_PASSWORD:"wrong-password",MISSING_PASSWORD:"missing-password",INVALID_LOGIN_CREDENTIALS:"invalid-credential",EMAIL_EXISTS:"email-already-in-use",PASSWORD_LOGIN_DISABLED:"operation-not-allowed",INVALID_IDP_RESPONSE:"invalid-credential",INVALID_PENDING_TOKEN:"invalid-credential",FEDERATED_USER_ID_ALREADY_LINKED:"credential-already-in-use",MISSING_REQ_TYPE:"internal-error",EMAIL_NOT_FOUND:"user-not-found",RESET_PASSWORD_EXCEED_LIMIT:"too-many-requests",EXPIRED_OOB_CODE:"expired-action-code",INVALID_OOB_CODE:"invalid-action-code",MISSING_OOB_CODE:"internal-error",CREDENTIAL_TOO_OLD_LOGIN_AGAIN:"requires-recent-login",INVALID_ID_TOKEN:"invalid-user-token",TOKEN_EXPIRED:"user-token-expired",USER_NOT_FOUND:"user-token-expired",TOO_MANY_ATTEMPTS_TRY_LATER:"too-many-requests",PASSWORD_DOES_NOT_MEET_REQUIREMENTS:"password-does-not-meet-requirements",INVALID_CODE:"invalid-verification-code",INVALID_SESSION_INFO:"invalid-verification-id",INVALID_TEMPORARY_PROOF:"invalid-credential",MISSING_SESSION_INFO:"missing-verification-id",SESSION_EXPIRED:"code-expired",MISSING_ANDROID_PACKAGE_NAME:"missing-android-pkg-name",UNAUTHORIZED_DOMAIN:"unauthorized-continue-uri",INVALID_OAUTH_CLIENT_ID:"invalid-oauth-client-id",ADMIN_ONLY_OPERATION:"admin-restricted-operation",INVALID_MFA_PENDING_CREDENTIAL:"invalid-multi-factor-session",MFA_ENROLLMENT_NOT_FOUND:"multi-factor-info-not-found",MISSING_MFA_ENROLLMENT_ID:"missing-multi-factor-info",MISSING_MFA_PENDING_CREDENTIAL:"missing-multi-factor-session",SECOND_FACTOR_EXISTS:"second-factor-already-in-use",SECOND_FACTOR_LIMIT_EXCEEDED:"maximum-second-factor-count-exceeded",BLOCKING_FUNCTION_ERROR_RESPONSE:"internal-error",RECAPTCHA_NOT_ENABLED:"recaptcha-not-enabled",MISSING_RECAPTCHA_TOKEN:"missing-recaptcha-token",INVALID_RECAPTCHA_TOKEN:"invalid-recaptcha-token",INVALID_RECAPTCHA_ACTION:"invalid-recaptcha-action",MISSING_CLIENT_TYPE:"missing-client-type",MISSING_RECAPTCHA_VERSION:"missing-recaptcha-version",INVALID_RECAPTCHA_VERSION:"invalid-recaptcha-version",INVALID_REQ_TYPE:"invalid-req-type"};const pB=["/v1/accounts:signInWithCustomToken","/v1/accounts:signInWithEmailLink","/v1/accounts:signInWithIdp","/v1/accounts:signInWithPassword","/v1/accounts:signInWithPhoneNumber","/v1/token"],mB=new Am(3e4,6e4);function Hn(n,e){return n.tenantId&&!e.tenantId?{...e,tenantId:n.tenantId}:e}async function Wn(n,e,t,s,r={}){return CC(n,r,async()=>{let i={},a={};s&&(e==="GET"?a=s:i={body:JSON.stringify(s)});const l=pf({...a,key:n.config.apiKey}).slice(1),c=await n._getAdditionalHeaders();c["Content-Type"]="application/json",n.languageCode&&(c["X-Firebase-Locale"]=n.languageCode);const d={method:e,headers:c,...i};return kU()||(d.referrerPolicy="strict-origin-when-cross-origin"),n.emulatorConfig&&Cd(n.emulatorConfig.host)&&(d.credentials="include"),AC.fetch()(await kC(n,n.config.apiHost,t,l),d)})}async function CC(n,e,t){n._canInitEmulator=!1;const s={...fB,...e};try{const r=new xB(n),i=await Promise.race([t(),r.promise]);r.clearNetworkTimeout();const a=await i.json();if("needConfirmation"in a)throw gp(n,"account-exists-with-different-credential",a);if(i.ok&&!("errorMessage"in a))return a;{const l=i.ok?a.errorMessage:a.error.message,[c,d]=l.split(" : ");if(c==="FEDERATED_USER_ID_ALREADY_LINKED")throw gp(n,"credential-already-in-use",a);if(c==="EMAIL_EXISTS")throw gp(n,"email-already-in-use",a);if(c==="USER_DISABLED")throw gp(n,"user-disabled",a);const h=s[c]||c.toLowerCase().replace(/[_\s]+/g,"-");if(d)throw h4(n,h,d);Ci(n,h)}}catch(r){if(r instanceof Ra)throw r;Ci(n,"network-request-failed",{message:String(r)})}}async function Jl(n,e,t,s,r={}){const i=await Wn(n,e,t,s,r);return"mfaPendingCredential"in i&&Ci(n,"multi-factor-auth-required",{_serverResponse:i}),i}async function kC(n,e,t,s){const r=`${e}${t}?${s}`,i=n,a=i.config.emulator?m4(n.config,r):`${n.config.apiScheme}://${r}`;return pB.includes(t)&&(await i._persistenceManagerAvailable,i._getPersistenceType()==="COOKIE")?
9i._getPersistence()._getFinalTarget(a).toString():a}function gB(n){switch(n){case"ENFORCE":return"ENFORCE";case"AUDIT":return"AUDIT";case"OFF":return"OFF";default:return"ENFORCEMENT_STATE_UNSPECIFIED"}}class xB{clearNetworkTimeout(){clearTimeout(this.timer)}constructor(e){this.auth=e,this.timer=null,this.promise=new Promise((t,s)=>{this.timer=setTimeout(()=>s(si(this.auth,"network-request-failed")),mB.get())})}}function gp(n,e,t){const s={appName:n.name};t.email&&(s.email=t.email),t.phoneNumber&&(s.phoneNumber=t.phoneNumber);const r=si(n,e,s);return r.customData._tokenResponse=t,r}function YT(n){return n!==void 0&&n.getResponse!==void 0}function QT(n){return n!==void 0&&n.enterprise!==void 0}class RC{constructor(e){if(this.siteKey="",this.recaptchaEnforcementState=[],e.recaptchaKey===void 0)throw new Error("recaptchaKey undefined");this.siteKey=e.recaptchaKey.split("/")[3],this.recaptchaEnforcementState=e.recaptchaEnforcementState}getProviderEnforcementState(e){if(!this.recaptchaEnforcementState||this.recaptchaEnforcementState.length===0)return null;for(const t of this.recaptchaEnforcementState)if(t.provider&&t.provider===e)return gB(t.enforcementState);return null}isProviderEnabled(e){return this.getProviderEnforcementState(e)==="ENFORCE"||this.getProviderEnforcementState(e)==="AUDIT"}isAnyProviderEnabled(){return this.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")||this.isProviderEnabled("PHONE_PROVIDER")}}async function yB(n){return(await Wn(n,"GET","/v1/recaptchaParams")).recaptchaSiteKey||""}async function PC(n,e){return Wn(n,"GET","/v2/recaptchaConfig",Hn(n,e))}async function vB(n,e){return Wn(n,"POST","/v1/accounts:delete",e)}async function bB(n,e){return Wn(n,"POST","/v1/accounts:update",e)}async function s1(n,e){return Wn(n,"POST","/v1/accounts:lookup",e)}function Ep(n){if(n)try{const e=new Date(Number(n));if(!isNaN(e.getTime()))return e.toUTCString()}catch{}}function wB(n,e=!1){return wt(n).getIdToken(e)}async function NC(n,e=!1){const t=wt(n),s=await t.getIdToken(e),r=dx(s);We(r&&r.exp&&r.auth_time&&r.iat,t.auth,"internal-error");const i=typeof r.firebase=="object"?r.firebase:void 0,a=i?.sign_in_provider;return{claims:r,token:s,authTime:Ep(q2(r.auth_time)),issuedAtTime:Ep(q2(r.iat)),expirationTime:Ep(q2(r.exp)),signInProvider:a||null,signInSecondFactor:i?.sign_in_second_factor||null}}function q2(n){return Number(n)*1e3}function dx(n){const[e,t,s]=n.split(".");if(e===void 0||t===void 0||s===void 0)return w0("JWT malformed, contained fewer than 3 sections"),null;try{const r=uC(t);return r?JSON.parse(r):(w0("Failed to decode base64 JWT payload"),null)}catch(r){return w0("Caught error parsing JWT payload as JSON",r?.toString()),null}}function XT(n){const e=dx(n);return We(e,"internal-error"),We(typeof e.exp<"u","internal-error"),We(typeof e.iat<"u","internal-error"),Number(e.exp)-Number(e.iat)}async function Wl(n,e,t=!1){if(t)return e;try{return await e}catch(s){throw s instanceof Ra&&SB(s)&&n.auth.currentUser===n&&await n.auth.signOut(),s}}function SB({code:n}){return n==="auth/user-disabled"||n==="auth/user-token-expired"}class EB{constructor(e){this.user=e,this.isRunning=!1,this.timerId=null,this.errorBackoff=3e4}_start(){this.isRunning||(this.isRunning=!0,this.schedule())}_stop(){this.isRunning&&(this.isRunning=!1,this.timerId!==null&&clearTimeout(this.timerId))}getInterval(e){if(e){const t=this.errorBackoff;return this.errorBackoff=Math.min(this.errorBackoff*2,96e4),t}else{this.errorBackoff=3e4;const s=(this.user.stsTokenManager.expirationTime??0)-Date.now()-3e5;return Math.max(0,s)}}schedule(e=!1){if(!this.isRunning)return;const t=this.getInterval(e);this.timerId=setTimeout(async()=>{await this.iteration()},t)}async iteration(){try{await this.user.getIdToken(!0)}catch(e){e?.code==="auth/network-request-failed"&&this.schedule(!0);return}this.schedule()}}class Ab{constructor(e,t){this.createdAt=e,this.lastLoginAt=t,this._initializeTime()}_initializeTime(){this.lastSignInTime=Ep(this.lastLoginAt),this.creationTime=Ep(this.createdAt)}_copy(e){this.createdAt=e.createdAt,this.lastLoginAt=e.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}}async function Xp(n){const e=n.auth,t=await n.getIdToken(),s=await Wl(n,s1(e,{idToken:t}));We(s?.users.length,e,"internal-error");const r=s.users[0];n._notifyReloadListener(r);const i=r.providerUserInfo?.length?DC(r.providerUserInfo):[],a=TB(n.providerData,i),l=n.isAnonymous,c=!(n.email&&r.passwordHash)&&!a?.length,d=l?c:!1,h={uid:r.localId,displayName:r.displayName||null,photoURL:r.photoUrl||null,email:r.email||null,emailVerified:r.emailVerified||!1,phoneNumber:r.phoneNumber||null,tenantId:r.tenantId||null,providerData:a,metadata:new Ab(r.createdAt,r.lastLoginAt),isAnonymous:d};Object.assign(n,h)}async function LC(n){const e=wt(n);await Xp(e),await e.auth._persistUserIfCurrent(e),e.auth._notifyListenersIfCurrent(e)}function TB(n,e){return[...n.filter(s=>
9!e.some(r=>r.providerId===s.providerId)),...e]}function DC(n){return n.map(({providerId:e,...t})=>({providerId:e,uid:t.rawId||"",displayName:t.displayName||null,email:t.email||null,phoneNumber:t.phoneNumber||null,photoURL:t.photoUrl||null}))}async function _B(n,e){const t=await CC(n,{},async()=>{const s=pf({grant_type:"refresh_token",refresh_token:e}).slice(1),{tokenApiHost:r,apiKey:i}=n.config,a=await kC(n,r,"/v1/token",`key=${i}`),l=await n._getAdditionalHeaders();l["Content-Type"]="application/x-www-form-urlencoded";const c={method:"POST",headers:l,body:s};return n.emulatorConfig&&Cd(n.emulatorConfig.host)&&(c.credentials="include"),AC.fetch()(a,c)});return{accessToken:t.access_token,expiresIn:t.expires_in,refreshToken:t.refresh_token}}async function IB(n,e){return Wn(n,"POST","/v2/accounts:revokeToken",Hn(n,e))}class Oh{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(e){We(e.idToken,"internal-error"),We(typeof e.idToken<"u","internal-error"),We(typeof e.refreshToken<"u","internal-error");const t="expiresIn"in e&&typeof e.expiresIn<"u"?Number(e.expiresIn):XT(e.idToken);this.updateTokensAndExpiration(e.idToken,e.refreshToken,t)}updateFromIdToken(e){We(e.length!==0,"internal-error");const t=XT(e);this.updateTokensAndExpiration(e,null,t)}async getToken(e,t=!1){return!t&&this.accessToken&&!this.isExpired?this.accessToken:(We(this.refreshToken,e,"user-token-expired"),this.refreshToken?(await this.refresh(e,this.refreshToken),this.accessToken):null)}clearRefreshToken(){this.refreshToken=null}async refresh(e,t){const{accessToken:s,refreshToken:r,expiresIn:i}=await _B(e,t);this.updateTokensAndExpiration(s,r,Number(i))}updateTokensAndExpiration(e,t,s){this.refreshToken=t||null,this.accessToken=e||null,this.expirationTime=Date.now()+s*1e3}static fromJSON(e,t){const{refreshToken:s,accessToken:r,expirationTime:i}=t,a=new Oh;return s&&(We(typeof s=="string","internal-error",{appName:e}),a.refreshToken=s),r&&(We(typeof r=="string","internal-error",{appName:e}),a.accessToken=r),i&&(We(typeof i=="number","internal-error",{appName:e}),a.expirationTime=i),a}toJSON(){return{refreshToken:this.refreshToken,accessToken:this.accessToken,expirationTime:this.expirationTime}}_assign(e){this.accessToken=e.accessToken,this.refreshToken=e.refreshToken,this.expirationTime=e.expirationTime}_clone(){return Object.assign(new Oh,this.toJSON())}_performRefresh(){return Uo("not implemented")}}function Ic(n,e){We(typeof n=="string"||typeof n>"u","internal-error",{appName:e})}class ro{constructor({uid:e,auth:t,stsTokenManager:s,...r}){this.providerId="firebase",this.proactiveRefresh=new EB(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=e,this.auth=t,this.stsTokenManager=s,this.accessToken=s.accessToken,this.displayName=r.displayName||null,this.email=r.email||null,this.emailVerified=r.emailVerified||!1,this.phoneNumber=r.phoneNumber||null,this.photoURL=r.photoURL||null,this.isAnonymous=r.isAnonymous||!1,this.tenantId=r.tenantId||null,this.providerData=r.providerData?[...r.providerData]:[],this.metadata=new Ab(r.createdAt||void 0,r.lastLoginAt||void 0)}async getIdToken(e){const t=await Wl(this,this.stsTokenManager.getToken(this.auth,e));return We(t,this.auth,"internal-error"),this.accessToken!==t&&(this.accessToken=t,await this.auth._persistUserIfCurrent(this),this.auth._notifyListenersIfCurrent(this)),t}getIdTokenResult(e){return NC(this,e)}reload(){return LC(this)}_assign(e){this!==e&&(We(this.uid===e.uid,this.auth,"internal-error"),this.displayName=e.displayName,this.photoURL=e.photoURL,this.email=e.email,this.emailVerified=e.emailVerified,this.phoneNumber=e.phoneNumber,this.isAnonymous=e.isAnonymous,this.tenantId=e.tenantId,this.providerData=e.providerData.map(t=>({...t})),this.metadata._copy(e.metadata),this.stsTokenManager._assign(e.stsTokenManager))}_clone(e){const t=new ro({...this,auth:e,stsTokenManager:this.stsTokenManager._clone()});return t.metadata._copy(this.metadata),t}_onReload(e){We(!this.reloadListener,this.auth,"internal-error"),this.reloadListener=e,this.reloadUserInfo&&(this._notifyReloadListener(this.reloadUserInfo),this.reloadUserInfo=null)}_notifyReloadListener(e){this.reloadListener?this.reloadListener(e):this.reloadUserInfo=e}_startProactiveRefresh(){this.proactiveRefresh._start()}_stopProactiveRefresh(){this.proactiveRefresh._stop()}async _updateTokensIfNecessary(e,t=!1){let s=!1;e.idToken&&e.idToken!==this.stsTokenManager.accessToken&&(this.stsTokenManager.updateFromServerResponse(e),s=!0),t&&await Xp(this),await this.auth._persistUserIfCurrent(this),s&&this.auth._notifyListenersIfCurrent(this)}async delete(){if(Jn(this.auth.app))return Promise.reject(dr(this.auth));const e=await this.getIdToken();return await Wl(this,vB(this.auth,{idToken:e})),this.stsTokenManager.clearRefreshToken(),this.auth.signOut()}toJSON(){return{uid:this.uid,email:this.email||void 0,emailVerified:this.emailVerified,displayName:this.displayName||void 0,isA
9nonymous:this.isAnonymous,photoURL:this.photoURL||void 0,phoneNumber:this.phoneNumber||void 0,tenantId:this.tenantId||void 0,providerData:this.providerData.map(e=>({...e})),stsTokenManager:this.stsTokenManager.toJSON(),_redirectEventId:this._redirectEventId,...this.metadata.toJSON(),apiKey:this.auth.config.apiKey,appName:this.auth.name}}get refreshToken(){return this.stsTokenManager.refreshToken||""}static _fromJSON(e,t){const s=t.displayName??void 0,r=t.email??void 0,i=t.phoneNumber??void 0,a=t.photoURL??void 0,l=t.tenantId??void 0,c=t._redirectEventId??void 0,d=t.createdAt??void 0,h=t.lastLoginAt??void 0,{uid:p,emailVerified:m,isAnonymous:y,providerData:x,stsTokenManager:w}=t;We(p&&w,e,"internal-error");const S=Oh.fromJSON(this.name,w);We(typeof p=="string",e,"internal-error"),Ic(s,e.name),Ic(r,e.name),We(typeof m=="boolean",e,"internal-error"),We(typeof y=="boolean",e,"internal-error"),Ic(i,e.name),Ic(a,e.name),Ic(l,e.name),Ic(c,e.name),Ic(d,e.name),Ic(h,e.name);const _=new ro({uid:p,auth:e,email:r,emailVerified:m,displayName:s,isAnonymous:y,photoURL:a,phoneNumber:i,tenantId:l,stsTokenManager:S,createdAt:d,lastLoginAt:h});return x&&Array.isArray(x)&&(_.providerData=x.map(L=>({...L}))),c&&(_._redirectEventId=c),_}static async _fromIdTokenResponse(e,t,s=!1){const r=new Oh;r.updateFromServerResponse(t);const i=new ro({uid:t.localId,auth:e,stsTokenManager:r,isAnonymous:s});return await Xp(i),i}static async _fromGetAccountInfoResponse(e,t,s){const r=t.users[0];We(r.localId!==void 0,"internal-error");const i=r.providerUserInfo!==void 0?DC(r.providerUserInfo):[],a=!(r.email&&r.passwordHash)&&!i?.length,l=new Oh;l.updateFromIdToken(s);const c=new ro({uid:r.localId,auth:e,stsTokenManager:l,isAnonymous:a}),d={uid:r.localId,displayName:r.displayName||null,photoURL:r.photoUrl||null,email:r.email||null,emailVerified:r.emailVerified||!1,phoneNumber:r.phoneNumber||null,tenantId:r.tenantId||null,providerData:i,metadata:new Ab(r.createdAt,r.lastLoginAt),isAnonymous:!(r.email&&r.passwordHash)&&!i?.length};return Object.assign(c,d),c}}const JT=new Map;function Ll(n){Hl(n instanceof Function,"Expected a class definition");let e=JT.get(n);return e?(Hl(e instanceof n,"Instance stored in cache mismatched with class"),e):(e=new n,JT.set(n,e),e)}class jC{constructor(){this.type="NONE",this.storage={}}async _isAvailable(){return!0}async _set(e,t){this.storage[e]=t}async _get(e){const t=this.storage[e];return t===void 0?null:t}async _remove(e){delete this.storage[e]}_addListener(e,t){}_removeListener(e,t){}}jC.type="NONE";const Cb=jC;function S0(n,e,t){return`firebase:${n}:${e}:${t}`}class Mh{constructor(e,t,s){this.persistence=e,this.auth=t,this.userKey=s;const{config:r,name:i}=this.auth;this.fullUserKey=S0(this.userKey,r.apiKey,i),this.fullPersistenceKey=S0("persistence",r.apiKey,i),this.boundEventHandler=t._onStorageEvent.bind(t),this.persistence._addListener(this.fullUserKey,this.boundEventHandler)}setCurrentUser(e){return this.persistence._set(this.fullUserKey,e.toJSON())}async getCurrentUser(){const e=await this.persistence._get(this.fullUserKey);if(!e)return null;if(typeof e=="string"){const t=await s1(this.auth,{idToken:e}).catch(()=>{});return t?ro._fromGetAccountInfoResponse(this.auth,t,e):null}return ro._fromJSON(this.auth,e)}removeCurrentUser(){return this.persistence._remove(this.fullUserKey)}savePersistenceForRedirect(){return this.persistence._set(this.fullPersistenceKey,this.persistence.type)}async setPersistence(e){if(this.persistence===e)return;const t=await this.getCurrentUser();if(await this.removeCurrentUser(),this.persistence=e,t)return this.setCurrentUser(t)}delete(){this.persistence._removeListener(this.fullUserKey,this.boundEventHandler)}static async create(e,t,s="authUser"){if(!t.length)return new Mh(Ll(Cb),e,s);const r=(await Promise.all(t.map(async d=>{if(await d._isAvailable())return d}))).filter(d=>d);let i=r[0]||Ll(Cb);const a=S0(s,e.config.apiKey,e.name);let l=null;for(const d of t)try{const h=await d._get(a);if(h){let p;if(typeof h=="string"){const m=await s1(e,{idToken:h}).catch(()=>{});if(!m)break;p=await ro._fromGetAccountInfoResponse(e,m,h)}else p=ro._fromJSON(e,h);d!==i&&(l=p),i=d;break}}catch{}const c=r.filter(d=>d._shouldAllowMigration);return!i._shouldAllowMigration||!c.length?new Mh(i,e,s):(i=c[0],l&&await i._set(a,l.toJSON()),await Promise.all(t.map(async d=>{if(d!==i)try{await d._remove(a)}catch{}})),new Mh(i,e,s))}}function ZT(n){const e=n.toLowerCase();if(e.includes("opera/")||e.includes("opr/")||e.includes("opios/"))return"Opera";if(UC(e))return"IEMobile";if(e.includes("msie")||e.includes("trident/"))return"IE";if(e.includes("edge/"))return"Edge";if(OC(e))return"Firefox";if(e.includes("silk/"))return"Silk";if(BC(e))return"Blackberry";if(zC(e))return"Webos";if(MC(e))return"Safari";if((e.includes("chrome/")||FC(e))&&!e.includes("edge/"))return"Chrome";if(VC(e))return"Android";{const t=/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/,s=n.match(t);if(s?.length===2)return s[1]}return"Other"}function OC(n=Ur()){return/firefox\//i.test(n)}function MC(n=Ur()){const e=n.toLowerCase();return e.includes("safari/")&&!e.includes("chrome/")&&!e.includes("crios/")&&!e.includes("android")}function FC(n=Ur()){return/crios\//i.test(n)}function UC(n=Ur()){return/iemobile/i.test(n)}function VC(n=Ur()){return/android/i.test(n)}function BC(n=Ur()){return/blackberry/i.test(n)}function zC(n=Ur()){return/webos/i.test(n)}function g4(n=Ur()){return/iphone|ipad|ipod/i.test(n)||/macintosh/i.test(n)&&/mobile/i.test(n)}function AB(n=Ur()){return g4(n)&&!!window.navigator?.standalone}function CB(){return PU()&&document.documentMode===10}function $C(n=Ur()){return g4(n)||VC(n)||zC(n)||BC(n)||/windows phone/i.test(n)||UC(n)}function HC(n,e=[]){let t;switch(n){case"Browser":t=ZT(Ur());break;case"Worker":t=`${ZT(Ur())}-${n}`;break;default:t=n}const s=e.length?e.join(","):"FirebaseCore-web";return`${t}/JsCore/${kd}/${s}`}class kB{constructor(e){this.auth=e,this.queue=[]}pushCallback(e,t){const s=i=>new Promise((a,l)=>{try{const c=e(i);a(c)}catch(c){l(c)}});s.onAbort=t,this.queue.push(s);const r=this.queue.length-1;return()=>{this.queue[r]=()=>Promise.resolve()}}async runMiddleware(e){if(this.auth.currentUser===e)return;const t=[];try{for(const s of this.queue)await s(e),s.onAbort&&t.push(s.onAbort)}catch(s){t.reverse();for(const r of t)try{r()}catch{}throw this.auth._errorFactory.create("login-blocked",{originalMessage:s?.message})}}}async function RB(n,e={}){return Wn(n,"GET","/v2/passwordPolicy",Hn(n,e))}const PB=6;class NB{constructor(e){const t=e.customStrengthOptions;this.customStrengthOptions={},this.customStrengthOptions.minPasswordLength=t.minPasswordLength??PB,t.maxPasswordLength&&(this.customStrengthOptions.maxPasswordLength=t.maxPasswordLength),t.containsLowercaseCharacter!==void 0&&(this.customStrengthOptions.containsLowercaseLetter=t.containsLowercaseCharacter),t.containsUppercaseCharacter!==void 0&&(this.customStrengthOptions.containsUppercaseLetter=t.containsUppercaseCharacter),t.containsNumericCharacter!==void 0&&(this.customStrengthOptions.containsNumericCharacter=t.containsNumericCharacter),t.containsNonAlphanumericCharacter!==void 0&&(this.customStrengthOptions.containsNonAlphanumericCharacter=t.containsNonAlphanumericCharacter),this.enforcementState=e.enforcementState,this.enforcementState==="ENFORCEMENT_STATE_UNSPECIFIED"&&(this.enforcementState="OFF"),this.allowedNonAlphanumericCharacters=e.allowedNonAlphanumericCharacters?.join("")??"",this.forceUpgradeOnSignin=e.forceUpgradeOnSignin??!1,this.schemaVersion=e.schemaVersion}validatePassword(e){const t={isValid:!0,passwordPolicy:this};return this.validatePasswordLengthOptions(e,t),this.validatePasswordCharacterOptions(e,t),t.isValid&&
9(t.isValid=t.meetsMinPasswordLength??!0),t.isValid&&(t.isValid=t.meetsMaxPasswordLength??!0),t.isValid&&(t.isValid=t.containsLowercaseLetter??!0),t.isValid&&(t.isValid=t.containsUppercaseLetter??!0),t.isValid&&(t.isValid=t.containsNumericCharacter??!0),t.isValid&&(t.isValid=t.containsNonAlphanumericCharacter??!0),t}validatePasswordLengthOptions(e,t){const s=this.customStrengthOptions.minPasswordLength,r=this.customStrengthOptions.maxPasswordLength;s&&(t.meetsMinPasswordLength=e.length>=s),r&&(t.meetsMaxPasswordLength=e.length<=r)}validatePasswordCharacterOptions(e,t){this.updatePasswordCharacterOptionsStatuses(t,!1,!1,!1,!1);let s;for(let r=0;r<e.length;r++)s=e.charAt(r),this.updatePasswordCharacterOptionsStatuses(t,s>="a"&&s<="z",s>="A"&&s<="Z",s>="0"&&s<="9",this.allowedNonAlphanumericCharacters.includes(s))}updatePasswordCharacterOptionsStatuses(e,t,s,r,i){this.customStrengthOptions.containsLowercaseLetter&&(e.containsLowercaseLetter||(e.containsLowercaseLetter=t)),this.customStrengthOptions.containsUppercaseLetter&&(e.containsUppercaseLetter||(e.containsUppercaseLetter=s)),this.customStrengthOptions.containsNumericCharacter&&(e.containsNumericCharacter||(e.containsNumericCharacter=r)),this.customStrengthOptions.containsNonAlphanumericCharacter&&(e.containsNonAlphanumericCharacter||(e.containsNonAlphanumericCharacter=i))}}class LB{constructor(e,t,s,r){this.app=e,this.heartbeatServiceProvider=t,this.appCheckServiceProvider=s,this.config=r,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new e8(this),this.idTokenSubscription=new e8(this),this.beforeStateQueue=new kB(this),this.redirectUser=null,this.isProactiveRefreshEnabled=!1,this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION=1,this._canInitEmulator=!0,this._isInitialized=!1,this._deleted=!1,this._initializationPromise=null,this._popupRedirectResolver=null,this._errorFactory=IC,this._agentRecaptchaConfig=null,this._tenantRecaptchaConfigs={},this._projectPasswordPolicy=null,this._tenantPasswordPolicies={},this._resolvePersistenceManagerAvailable=void 0,this.lastNotifiedUid=void 0,this.languageCode=null,this.tenantId=null,this.settings={appVerificationDisabledForTesting:!1},this.frameworks=[],this.name=e.name,this.clientVersion=r.sdkClientVersion,this._persistenceManagerAvailable=new Promise(i=>this._resolvePersistenceManagerAvailable=i)}_initializeWithPersistence(e,t){return t&&(this._popupRedirectResolver=Ll(t)),this._initializationPromise=this.queue(async()=>{if(!this._deleted&&(this.persistenceManager=await Mh.create(this,e),this._resolvePersistenceManagerAvailable?.(),!this._deleted)){if(this._popupRedirectResolver?._shouldInitProactively)try{await this._popupRedirectResolver._initialize(this)}catch{}await this.initializeCurrentUser(t),this.lastNotifiedUid=this.currentUser?.uid||null,!this._deleted&&(this._isInitialized=!0)}}),this._initializationPromise}async _onStorageEvent(){if(this._deleted)return;const e=await this.assertedPersistence.getCurrentUser();if(!(!this.currentUser&&!e)){if(this.currentUser&&e&&this.currentUser.uid===e.uid){this._currentUser._assign(e),await this.currentUser.getIdToken();return}await this._updateCurrentUser(e,!0)}}async initializeCurrentUserFromIdToken(e){try{const t=await s1(this,{idToken:e}),s=await ro._fromGetAccountInfoResponse(this,t,e);await this.directlySetCurrentUser(s)}catch{await this.directlySetCurrentUser(null)}}async initializeCurrentUser(e){if(Jn(this.app)){const i=this.app.settings.authIdToken;return i?new Promise(a=>{setTimeout(()=>this.initializeCurrentUserFromIdToken(i).then(a,a))}):this.directlySetCurrentUser(null)}const t=await this.assertedPersistence.getCurrentUser();let s=t,r=!1;if(e&&this.config.authDomain){await this.getOrInitRedirectPersistenceManager();const i=this.redirectUser?._redirectEventId,a=s?._redirectEventId,l=await this.tryRedirectSignIn(e);(!i||i===a)&&l?.user&&(s=l.user,r=!0)}if(!s)return this.directlySetCurrentUser(null);if(!s._redirectEventId){if(r)try{await this.beforeStateQueue.runMiddleware(s)}catch(i){s=t,this._popupRedirectResolver._overrideRedirectResult(this,()=>Promise.reject(i))}return s?this.reloadAndSetCurrentUserOrClear(s):this.directlySetCurrentUser(null)}return We(this._popupRedirectResolver,this,"argument-error"),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===s._redirectEventId?this.directlySetCurrentUser(s):this.reloadAndSetCurrentUserOrClear(s)}async tryRedirectSignIn(e){let t=null;try{t=await this._popupRedirectResolver._completeRedirectFn(this,e,!0)}catch{await this._setRedirectUser(null)}return t}async reloadAndSetCurrentUserOrClear(e){try{await Xp(e)}catch(t){if(t?.code!=="auth/network-request-failed")return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(e)}useDeviceLanguage(){this.languageCode=hB()}async _delete(){this._deleted=!0}
9async updateCurrentUser(e){if(Jn(this.app))return Promise.reject(dr(this));const t=e?wt(e):null;return t&&We(t.auth.config.apiKey===this.config.apiKey,this,"invalid-user-token"),this._updateCurrentUser(t&&t._clone(this))}async _updateCurrentUser(e,t=!1){if(!this._deleted)return e&&We(this.tenantId===e.tenantId,this,"tenant-id-mismatch"),t||await this.beforeStateQueue.runMiddleware(e),this.queue(async()=>{await this.directlySetCurrentUser(e),this.notifyAuthListeners()})}async signOut(){return Jn(this.app)?Promise.reject(dr(this)):(await this.beforeStateQueue.runMiddleware(null),(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null,!0))}setPersistence(e){return Jn(this.app)?Promise.reject(dr(this)):this.queue(async()=>{await this.assertedPersistence.setPersistence(Ll(e))})}_getRecaptchaConfig(){return this.tenantId==null?this._agentRecaptchaConfig:this._tenantRecaptchaConfigs[this.tenantId]}async validatePassword(e){this._getPasswordPolicyInternal()||await this._updatePasswordPolicy();const t=this._getPasswordPolicyInternal();return t.schemaVersion!==this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION?Promise.reject(this._errorFactory.create("unsupported-password-policy-schema-version",{})):t.validatePassword(e)}_getPasswordPolicyInternal(){return this.tenantId===null?this._projectPasswordPolicy:this._tenantPasswordPolicies[this.tenantId]}async _updatePasswordPolicy(){const e=await RB(this),t=new NB(e);this.tenantId===null?this._projectPasswordPolicy=t:this._tenantPasswordPolicies[this.tenantId]=t}_getPersistenceType(){return this.assertedPersistence.persistence.type}_getPersistence(){return this.assertedPersistence.persistence}_updateErrorMap(e){this._errorFactory=new Ad("auth","Firebase",e())}onAuthStateChanged(e,t,s){return this.registerStateListener(this.authStateSubscription,e,t,s)}beforeAuthStateChanged(e,t){return this.beforeStateQueue.pushCallback(e,t)}onIdTokenChanged(e,t,s){return this.registerStateListener(this.idTokenSubscription,e,t,s)}authStateReady(){return new Promise((e,t)=>{if(this.currentUser)e();else{const s=this.onAuthStateChanged(()=>{s(),e()},t)}})}async revokeAccessToken(e){if(this.currentUser){const t=await this.currentUser.getIdToken(),s={providerId:"apple.com",tokenType:"ACCESS_TOKEN",token:e,idToken:t};this.tenantId!=null&&(s.tenantId=this.tenantId),await IB(this,s)}}toJSON(){return{apiKey:this.config.apiKey,authDomain:this.config.authDomain,appName:this.name,currentUser:this._currentUser?.toJSON()}}async _setRedirectUser(e,t){const s=await this.getOrInitRedirectPersistenceManager(t);return e===null?s.removeCurrentUser():s.setCurrentUser(e)}async getOrInitRedirectPersistenceManager(e){if(!this.redirectPersistenceManager){const t=e&&Ll(e)||this._popupRedirectResolver;We(t,this,"argument-error"),this.redirectPersistenceManager=await Mh.create(this,[Ll(t._redirectPersistence)],"redirectUser"),this.redirectUser=await this.redirectPersistenceManager.getCurrentUser()}return this.redirectPersistenceManager}async _redirectUserForId(e){return this._isInitialized&&await this.queue(async()=>{}),this._currentUser?._redirectEventId===e?this._currentUser:this.redirectUser?._redirectEventId===e?this.redirectUser:null}async _persistUserIfCurrent(e){if(e===this.currentUser)return this.queue(async()=>this.directlySetCurrentUser(e))}_notifyListenersIfCurrent(e){e===this.currentUser&&this.notifyAuthListeners()}_key(){return`${this.config.authDomain}:${this.config.apiKey}:${this.name}`}_startProactiveRefresh(){this.isProactiveRefreshEnabled=!0,this.currentUser&&this._currentUser._startProactiveRefresh()}_stopProactiveRefresh(){this.isProactiveRefreshEnabled=!1,this.currentUser&&this._currentUser._stopProactiveRefresh()}get _currentUser(){return this.currentUser}notifyAuthListeners(){if(!this._isInitialized)return;this.idTokenSubscription.next(this.currentUser);const e=this.currentUser?.uid??null;this.lastNotifiedUid!==e&&(this.lastNotifiedUid=e,this.authStateSubscription.next(this.currentUser))}registerStateListener(e,t,s,r){if(this._deleted)return()=>{};const i=typeof t=="function"?t:t.next.bind(t);let a=!1;const l=this._isInitialized?Promise.resolve():this._initializationPromise;if(We(l,this,"internal-error"),l.then(()=>{a||i(this.currentUser)}),typeof t=="function"){const c=e.addObserver(t,s,r);return()=>{a=!0,c()}}else{const c=e.addObserver(t);return()=>{a=!0,c()}}}async directlySetCurrentUser(e){this.currentUser&&this.currentUser!==e&&this._currentUser._stopProactiveRefresh(),e&&this.isProactiveRefreshEnabled&&e._startProactiveRefresh(),this.currentUser=e,e?await this.assertedPersistence.setCurrentUser(e):await this.assertedPersistence.removeCurrentUser()}queue(e){return this.operations=this.operations.then(e,e),this.operations}get assertedPersistence(){return We(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(e){!e||this.frameworks.includes(e)||(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=HC(this.config.clientPlatform,this._getFrameworks()))}_getFrameworks(){return this.frameworks}async _getAdditionalHeaders(){const e={"X-Client-Version":this.clientVersion};this.app.options.appId&&(e["X-Firebase-gmpid"]=this.app.options.appId);const t=await this.heartbeatServiceProvider.getImmediate({optional:!0})?.getHeartbeatsHeader();t&&(e["X-Firebase-Client"]=t);const s=await this._getAppCheckToken();return s&&(e["X-Firebase-AppCheck"]=s),e}async _getAppCheckToken(){if(Jn(this.app)&&this.app.settings.appCheckToken)return this.app.settings.appCheckToken;const e=await this.appCheckServiceProvider.getImmediate({optional:!0})?.getToken();return e?.error&&uB(`Error while retrieving App Check token: ${e.error}`),e?.token}}function gs(n){return wt(n)}class e8{constructor(e){this.auth=e,this.observer=null,this.addObserver=FU(t=>this.observer=t)}get next(){return We(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}let Cm={async loadJS(){throw new Error("Unable to load external scripts")},recaptchaV2Script:"",recaptchaEnterpriseScript:"",gapiScript:""};function DB(n){Cm=n}function x4(n){return Cm.loadJS(n)}function jB(){return Cm.recaptchaV2Script}function OB(){return Cm.recaptchaEnterpriseScript}function MB(){return Cm.gapiScript}function WC(n){return`__${n}${Math.floor(Math.random()*1e6)}`}const FB=500,UB=6e4,zg=1e12;class VB{constructor(e){this.auth=e,this.counter=zg,this._widgets=new Map}render(e,t){const s=this.counter;return this._widgets.set(s,new $B(e,this.auth.name,t||{})),this.counter++,s}reset(e){const t=e||zg;this._widgets.get(t)?.delete(),this._widgets.delete(t)}getResponse(e){const t=e||zg;return this._widgets.get(t)?.getResponse()||""}async execute(e){const t=e||zg;return this._widgets.get(t)?.execute(),""}}class BB{constructor(){this.enterprise=new zB}ready(e){e()}execute(e,t){return Promise.resolve("token")}render(e,t){return""}}class zB{ready(e){e()}execute(e,t){return Promise.resolve("token")}render(e,t){return""}}class $B{constructor(e,t,s){this.params=s,this.timerId=null,this.deleted=!1,this.responseToken=null,this.clickHandler=()=>{this.execute()};const r=typeof e=="string"?document.getElementById(e):e;We(r,"argument-error",{appName:t}),this.container=r,this.isVisible=this.params.size!=="invisible",this.isVisible?this.execute():this.container.addEventListener("click",this.clickHandler)}getResponse(){return this.checkIfDeleted(),this.responseToken}delete(){this.checkIfDeleted(),this.deleted=!0,this.timerId&&(clearTimeout(this.timerId),this.timerId=null),this.container.removeEventListener("click",this.clickHandler)}execute(){this.checkIfDeleted(),!this.timerId&&(this.timerId=window.setTimeout(()=>{this.responseToken=HB(50);const{callback:e,"expired-callback":t}=this.params;if(e)try{e(this.responseToken)}catch{}this.timerId=window.setTimeout(()=>{if(this.timerId=null,this.responseToken=null,t)try{t()}catch{}this.isVisible&&this.execute()},UB)},FB))}checkIfDeleted(){if(this.deleted)throw new Error("reCAPTCHA mock was already deleted!")}}function HB(n){const e=[],t="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";for(let s=0;s<n;s++)e.push(t.charAt(Math.floor(Math.random()*t.length)));return e.join("")}const WB="recaptcha-enterprise",Tp="NO_RECAPTCHA",t8="onFirebaseAuthREInstanceReady";class kl{constructor(e){this.type=WB,this.auth=gs(e)}async verify(e="verify",t=!1){async function s(i){if(!t){if(i.tenantId==null&&i._agentRecaptchaConfig!=null)return i._agentRecaptchaConfig.siteKey;if(i.tenantId!=null&&i._tenantRecaptchaConfigs[i.tenantId]!==void 0)return i._tenantRecaptchaConfigs[i.tenantId].siteKey}return new Promise(async(a,l)=>
9{PC(i,{clientType:"CLIENT_TYPE_WEB",version:"RECAPTCHA_ENTERPRISE"}).then(c=>{if(c.recaptchaKey===void 0)l(new Error("recaptcha Enterprise site key undefined"));else{const d=new RC(c);return i.tenantId==null?i._agentRecaptchaConfig=d:i._tenantRecaptchaConfigs[i.tenantId]=d,a(d.siteKey)}}).catch(c=>{l(c)})})}function r(i,a,l){const c=window.grecaptcha;QT(c)?c.enterprise.ready(()=>{c.enterprise.execute(i,{action:e}).then(d=>{a(d)}).catch(()=>{a(Tp)})}):l(Error("No reCAPTCHA enterprise script loaded."))}return this.auth.settings.appVerificationDisabledForTesting?new BB().execute("siteKey",{action:"verify"}):new Promise((i,a)=>{s(this.auth).then(async l=>{if(!t&&QT(window.grecaptcha)&&kl.scriptInjectionDeferred)await kl.scriptInjectionDeferred.promise,r(l,i,a);else{if(typeof window>"u"){a(new Error("RecaptchaVerifier is only supported in browser"));return}let c=OB();c.length!==0&&(c+=l+`&onload=${t8}`),kl.scriptInjectionDeferred=new mC,window[t8]=()=>{kl.scriptInjectionDeferred?.resolve()},x4(c).then(()=>kl.scriptInjectionDeferred?.promise).then(()=>{r(l,i,a)}).catch(d=>{a(d)})}}).catch(l=>{a(l)})})}}kl.scriptInjectionDeferred=null;async function ip(n,e,t,s=!1,r=!1){const i=new kl(n);let a;if(r)a=Tp;else try{a=await i.verify(t)}catch{a=await i.verify(t,!0)}const l={...e};if(t==="mfaSmsEnrollment"||t==="mfaSmsSignIn"){if("phoneEnrollmentInfo"in l){const c=l.phoneEnrollmentInfo.phoneNumber,d=l.phoneEnrollmentInfo.recaptchaToken;Object.assign(l,{phoneEnrollmentInfo:{phoneNumber:c,recaptchaToken:d,captchaResponse:a,clientType:"CLIENT_TYPE_WEB",recaptchaVersion:"RECAPTCHA_ENTERPRISE"}})}else if("phoneSignInInfo"in l){const c=l.phoneSignInInfo.recaptchaToken;Object.assign(l,{phoneSignInInfo:{recaptchaToken:c,captchaResponse:a,clientType:"CLIENT_TYPE_WEB",recaptchaVersion:"RECAPTCHA_ENTERPRISE"}})}return l}return s?Object.assign(l,{captchaResp:a}):Object.assign(l,{captchaResponse:a}),Object.assign(l,{clientType:"CLIENT_TYPE_WEB"}),Object.assign(l,{recaptchaVersion:"RECAPTCHA_ENTERPRISE"}),l}async function Hc(n,e,t,s,r){if(r==="EMAIL_PASSWORD_PROVIDER")if(n._getRecaptchaConfig()?.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")){const i=await ip(n,e,t,t==="getOobCode");return s(n,i)}else return s(n,e).catch(async i=>{if(i.code==="auth/missing-recaptcha-token"){const a=await ip(n,e,t,t==="getOobCode");return s(n,a)}else return Promise.reject(i)});else if(r==="PHONE_PROVIDER")if(n._getRecaptchaConfig()?.isProviderEnabled("PHONE_PROVIDER")){const i=await ip(n,e,t);return s(n,i).catch(async a=>{if(n._getRecaptchaConfig()?.getProviderEnforcementState("PHONE_PROVIDER")==="AUDIT"&&(a.code==="auth/missing-recaptcha-token"||a.code==="auth/invalid-app-credential")){const l=await ip(n,e,t,!1,!0);return s(n,l)}return Promise.reject(a)})}else{const i=await ip(n,e,t,!1,!0);return s(n,i)}else return Promise.reject(r+" provider is not supported.")}async function GC(n){const e=gs(n),t=await PC(e,{clientType:"CLIENT_TYPE_WEB",version:"RECAPTCHA_ENTERPRISE"}),s=new RC(t);e.tenantId==null?e._agentRecaptchaConfig=s:e._tenantRecaptchaConfigs[e.tenantId]=s,s.isAnyProviderEnabled()&&new kl(e).verify()}function KC(n,e){const t=gu(n,"auth");if(t.isInitialized()){const r=t.getImmediate(),i=t.getOptions();if(qo(i,e??{}))return r;Ci(r,"already-initialized")}return t.initialize({options:e})}function GB(n,e){const t=e?.persistence||[],s=(Array.isArray(t)?t:[t]).map(Ll);e?.errorMap&&n._updateErrorMap(e.errorMap),n._initializeWithPersistence(s,e?.popupRedirectResolver)}function qC(n,e,t){const s=gs(n);We(/^https?:\/\//.test(e),s,"invalid-emulator-scheme");const r=!!t?.disableWarnings,i=YC(e),{host:a,port:l}=KB(e),c=l===null?"":`:${l}`,d={url:`${i}//${a}${c}/`},h=Object.freeze({host:a,port:l,protocol:i.replace(":",""),options:Object.freeze({disableWarnings:r})});if(!s._canInitEmulator){We(s.config.emulator&&s.emulatorConfig,s,"emulator-config-failed"),We(qo(d,s.config.emulator)&&qo(h,s.emulatorConfig),s,"emulator-config-failed");return}s.config.emulator=d,s.emulatorConfig=h,s.settings.appVerificationDisabledForTesting=!0,Cd(a)?c4(`${i}//${a}${c}`):r||qB()}function YC(n){const e=n.indexOf(":");return e<0?"":n.substr(0,e+1)}function KB(n){const e=YC(n),t=/(\/\/)?([^?#/]+)/.exec(n.substr(e.length));if(!t)return{host:"",port:null};const s=t[2].split("@").pop()||"",r=/^(\[[^\]]+\])(:|$)/.exec(s);if(r){const i=r[1];return{host:i,port:n8(s.substr(i.length+1))}}else{const[i,a]=s.split(":");return{host:i,port:n8(a)}}}function n8(n){if(!n)return null;const e=Number(n);return isNaN(e)?null:e}function qB(){function n(){const e=document.createElement("p"),t=e.style;e.innerText="Running in emulator mode. Do not use with production credentials.",t.position="fixed",t.width="100%",t.backgroundColor="#ffffff",t.border=".1em solid #000000",t.color="#b50000",t.bottom="0px",t.left="0px",t.margin="0px",t.zIndex="10000",t.textAlign="center",e.classList.add("firebase-emulator-warning"),document.body.appendChild(e)}typeof window<"u"&&typeof document<"u"&&(document.readyState==="loading"?window.addEventListener("DOMContentLoaded",n):n())}class gf{constructor(e,t){this.providerId=e,this.signInMethod=t}toJSON(){return Uo("not implemented")}_getIdTokenResponse(e){return Uo("not implemented")}_linkToIdToken(e,t){return Uo("not implemented")}_getReauthenticationResolver(e){return Uo("not implemented")}}async function QC(n,e){return Wn(n,"POST","/v1/accounts:resetPassword",Hn(n,e))}async function YB(n,e){return Wn(n,"POST","/v1/accounts:update",e)}async function QB(n,e){return Wn(n,"POST","/v1/accounts:signUp",e)}async function XB(n,e){return Wn(n,"POST","/v1/accounts:update",Hn(n,e))}async function JB(n,e){return Jl(n,"POST","/v1/accounts:signInWithPassword",Hn(n,e))}async function hx(n,e){return Wn(n,"POST","/v1/accounts:sendOobCode",Hn(n,e))}async function ZB(n,e){return hx(n,e)}async function ez(n,e){return hx(n,e)}async function tz(n,e){return hx(n,e)}async function nz(n,e){return hx(n,e)}async function sz(n,e){return Jl(n,"POST","/v1/accounts:signInWithEmailLink",Hn(n,e))}async function rz(n,e){return Jl(n,"POST","/v1/accounts:signInWithEmailLink",Hn(n,e))}class Kh extends gf{constructor(e,t,s,r=null){super("password",s),this._email=e,this._password=t,this._tenantId=r}static _fromEmailAndPassword(e,t){return new Kh(e,t,"password")}static _fromEmailAndCode(e,t,s=null){return new Kh(e,t,"emailLink",s)}toJSON(){return{email:this._email,password:this._password,signInMethod:this.signInMethod,tenantId:this._tenantId}}static fromJSON(e){const t=typeof e=="string"?JSON.parse(e):e;if(t?.email&&t?.password){if(t.signInMethod==="password")return this._fromEmailAndPassword(t.email,t.password);if(t.signInMethod==="emailLink")return this._fromEmailAndCode(t.email,t.password,t.tenantId)}return null}async _getIdTokenResponse(e){switch(this.signInMethod){case"password":const t={returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"};return Hc(e,t,"signInWithPassword",JB,"EMAIL_PASSWORD_PROVIDER");case"emailLink":return sz(e,{email:this._email,oobCode:this._password});default:Ci(e,"internal-error")}}async _linkToIdToken(e,t){switch(this.signInMethod){case"password":const s={idToken:t,returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"};return Hc(e,s,"signUpPassword",QB,"EMAIL_PASSWORD_PROVIDER");case"emailLink":return rz(e,{idToken:t,email:this._email,oobCode:this._password});default:Ci(e,"internal-error")}}_getReauthenticationResolver(e){return this._getIdTokenResponse(e)}}async function Ul(n,e){return Jl(n,"POST","/v1/accounts:signInWithIdp",Hn(n,e))}const iz="http://localhost";class Yo extends gf{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(e){const t=new Yo(e.providerId,e.signInMethod);return e.idToken||e.accessToken?(e.idToken&&(t.idToken=e.idToken),e.accessToken&&(t.accessToken=e.accessToken),e.nonce&&!e.pendingToken&&
9(t.nonce=e.nonce),e.pendingToken&&(t.pendingToken=e.pendingToken)):e.oauthToken&&e.oauthTokenSecret?(t.accessToken=e.oauthToken,t.secret=e.oauthTokenSecret):Ci("argument-error"),t}toJSON(){return{idToken:this.idToken,accessToken:this.accessToken,secret:this.secret,nonce:this.nonce,pendingToken:this.pendingToken,providerId:this.providerId,signInMethod:this.signInMethod}}static fromJSON(e){const t=typeof e=="string"?JSON.parse(e):e,{providerId:s,signInMethod:r,...i}=t;if(!s||!r)return null;const a=new Yo(s,r);return a.idToken=i.idToken||void 0,a.accessToken=i.accessToken||void 0,a.secret=i.secret,a.nonce=i.nonce,a.pendingToken=i.pendingToken||null,a}_getIdTokenResponse(e){const t=this.buildRequest();return Ul(e,t)}_linkToIdToken(e,t){const s=this.buildRequest();return s.idToken=t,Ul(e,s)}_getReauthenticationResolver(e){const t=this.buildRequest();return t.autoCreate=!1,Ul(e,t)}buildRequest(){const e={requestUri:iz,returnSecureToken:!0};if(this.pendingToken)e.pendingToken=this.pendingToken;else{const t={};this.idToken&&(t.id_token=this.idToken),this.accessToken&&(t.access_token=this.accessToken),this.secret&&(t.oauth_token_secret=this.secret),t.providerId=this.providerId,this.nonce&&!this.pendingToken&&(t.nonce=this.nonce),e.postBody=pf(t)}return e}}async function s8(n,e){return Wn(n,"POST","/v1/accounts:sendVerificationCode",Hn(n,e))}async function az(n,e){return Jl(n,"POST","/v1/accounts:signInWithPhoneNumber",Hn(n,e))}async function oz(n,e){const t=await Jl(n,"POST","/v1/accounts:signInWithPhoneNumber",Hn(n,e));if(t.temporaryProof)throw gp(n,"account-exists-with-different-credential",t);return t}const lz={USER_NOT_FOUND:"user-not-found"};async function cz(n,e){const t={...e,operation:"REAUTH"};return Jl(n,"POST","/v1/accounts:signInWithPhoneNumber",Hn(n,t),lz)}class Wc extends gf{constructor(e){super("phone","phone"),this.params=e}static _fromVerification(e,t){return new Wc({verificationId:e,verificationCode:t})}static _fromTokenResponse(e,t){return new Wc({phoneNumber:e,temporaryProof:t})}_getIdTokenResponse(e){return az(e,this._makeVerificationRequest())}_linkToIdToken(e,t){return oz(e,{idToken:t,...this._makeVerificationRequest()})}_getReauthenticationResolver(e){return cz(e,this._makeVerificationRequest())}_makeVerificationRequest(){const{temporaryProof:e,phoneNumber:t,verificationId:s,verificationCode:r}=this.params;return e&&t?{temporaryProof:e,phoneNumber:t}:{sessionInfo:s,code:r}}toJSON(){const e={providerId:this.providerId};return this.params.phoneNumber&&(e.phoneNumber=this.params.phoneNumber),this.params.temporaryProof&&(e.temporaryProof=this.params.temporaryProof),this.params.verificationCode&&(e.verificationCode=this.params.verificationCode),this.params.verificationId&&(e.verificationId=this.params.verificationId),e}static fromJSON(e){typeof e=="string"&&(e=JSON.parse(e));const{verificationId:t,verificationCode:s,phoneNumber:r,temporaryProof:i}=e;return!s&&!t&&!r&&!i?null:new Wc({verificationId:t,verificationCode:s,phoneNumber:r,temporaryProof:i})}}function uz(n){switch(n){case"recoverEmail":return"RECOVER_EMAIL";case"resetPassword":return"PASSWORD_RESET";case"signIn":return"EMAIL_SIGNIN";case"verifyEmail":return"VERIFY_EMAIL";case"verifyAndChangeEmail":return"VERIFY_AND_CHANGE_EMAIL";case"revertSecondFactorAddition":return"REVERT_SECOND_FACTOR_ADDITION";default:return null}}function dz(n){const e=pp(mp(n)).link,t=e?pp(mp(e)).deep_link_id:null,s=pp(mp(n)).deep_link_id;return(s?pp(mp(s)).link:null)||s||t||e||n}class xf{constructor(e){const t=pp(mp(e)),s=t.apiKey??null,r=t.oobCode??null,i=uz(t.mode??null);We(s&&r&&i,"argument-error"),this.apiKey=s,this.operation=i,this.code=r,this.continueUrl=t.continueUrl??null,this.languageCode=t.lang??null,this.tenantId=t.tenantId??null}static parseLink(e){const t=dz(e);try{return new xf(t)}catch{return null}}}function hz(n){return xf.parseLink(n)}class nl{constructor(){this.providerId=nl.PROVIDER_ID}static credential(e,t){return Kh._fromEmailAndPassword(e,t)}static credentialWithLink(e,t){const s=xf.parseLink(t);return We(s,"argument-error"),Kh._fromEmailAndCode(e,s.code,s.tenantId)}}nl.PROVIDER_ID="password";nl.EMAIL_PASSWORD_SIGN_IN_METHOD="password";nl.EMAIL_LINK_SIGN_IN_METHOD="emailLink";class Zl{constructor(e){this.providerId=e,this.defaultLanguageCode=null,this.customParameters={}}setDefaultLanguage(e){this.defaultLanguageCode=e}setCustomParameters(e){return this.customParameters=e,this}getCustomParameters(){return this.customParameters}}class yf extends Zl{constructor(){super(...arguments),this.scopes=[]}addScope(e){return this.scopes.includes(e)||this.scopes.push(e),this}getScopes(){return[...this.scopes]}}class _p extends yf{static credentialFromJSON(e){const t=typeof e=="string"?JSON.parse(e):e;return We("providerId"in t&&"signInMethod"in t,"argument-error"),Yo._fromParams(t)}credential(e){return this._credential({...e,nonce:e.rawNonce})}_credential(e){return We(e.idToken||e.accessToken,"argument-error"),Yo._fromParams({...e,providerId:this.providerId,sign
9InMethod:this.providerId})}static credentialFromResult(e){return _p.oauthCredentialFromTaggedObject(e)}static credentialFromError(e){return _p.oauthCredentialFromTaggedObject(e.customData||{})}static oauthCredentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthIdToken:t,oauthAccessToken:s,oauthTokenSecret:r,pendingToken:i,nonce:a,providerId:l}=e;if(!s&&!r&&!t&&!i||!l)return null;try{return new _p(l)._credential({idToken:t,accessToken:s,nonce:a,pendingToken:i})}catch{return null}}}class Rl extends yf{constructor(){super("facebook.com")}static credential(e){return Yo._fromParams({providerId:Rl.PROVIDER_ID,signInMethod:Rl.FACEBOOK_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return Rl.credentialFromTaggedObject(e)}static credentialFromError(e){return Rl.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return Rl.credential(e.oauthAccessToken)}catch{return null}}}Rl.FACEBOOK_SIGN_IN_METHOD="facebook.com";Rl.PROVIDER_ID="facebook.com";class Si extends yf{constructor(){super("google.com"),this.addScope("profile")}static credential(e,t){return Yo._fromParams({providerId:Si.PROVIDER_ID,signInMethod:Si.GOOGLE_SIGN_IN_METHOD,idToken:e,accessToken:t})}static credentialFromResult(e){return Si.credentialFromTaggedObject(e)}static credentialFromError(e){return Si.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthIdToken:t,oauthAccessToken:s}=e;if(!t&&!s)return null;try{return Si.credential(t,s)}catch{return null}}}Si.GOOGLE_SIGN_IN_METHOD="google.com";Si.PROVIDER_ID="google.com";class Pl extends yf{constructor(){super("github.com")}static credential(e){return Yo._fromParams({providerId:Pl.PROVIDER_ID,signInMethod:Pl.GITHUB_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return Pl.credentialFromTaggedObject(e)}static credentialFromError(e){return Pl.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return Pl.credential(e.oauthAccessToken)}catch{return null}}}Pl.GITHUB_SIGN_IN_METHOD="github.com";Pl.PROVIDER_ID="github.com";const fz="http://localhost";class Jp extends gf{constructor(e,t){super(e,e),this.pendingToken=t}_getIdTokenResponse(e){const t=this.buildRequest();return Ul(e,t)}_linkToIdToken(e,t){const s=this.buildRequest();return s.idToken=t,Ul(e,s)}_getReauthenticationResolver(e){const t=this.buildRequest();return t.autoCreate=!1,Ul(e,t)}toJSON(){return{signInMethod:this.signInMethod,providerId:this.providerId,pendingToken:this.pendingToken}}static fromJSON(e){const t=typeof e=="string"?JSON.parse(e):e,{providerId:s,signInMethod:r,pendingToken:i}=t;return!s||!r||!i||s!==r?null:new Jp(s,i)}static _create(e,t){return new Jp(e,t)}buildRequest(){return{requestUri:fz,returnSecureToken:!0,pendingToken:this.pendingToken}}}const pz="saml.";class r1 extends Zl{constructor(e){We(e.startsWith(pz),"argument-error"),super(e)}static credentialFromResult(e){return r1.samlCredentialFromTaggedObject(e)}static credentialFromError(e){return r1.samlCredentialFromTaggedObject(e.customData||{})}static credentialFromJSON(e){const t=Jp.fromJSON(e);return We(t,"argument-error"),t}static samlCredentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{pendingToken:t,providerId:s}=e;if(!t||!s)return null;try{return Jp._create(s,t)}catch{return null}}}class Nl extends yf{constructor(){super("twitter.com")}static credential(e,t){return Yo._fromParams({providerId:Nl.PROVIDER_ID,signInMethod:Nl.TWITTER_SIGN_IN_METHOD,oauthToken:e,oauthTokenSecret:t})}static credentialFromResult(e){return Nl.credentialFromTaggedObject(e)}static credentialFromError(e){return Nl.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthAccessToken:t,oauthTokenSecret:s}=e;if(!t||!s)return null;try{return Nl.credential(t,s)}catch{return null}}}Nl.TWITTER_SIGN_IN_METHOD="twitter.com";Nl.PROVIDER_ID="twitter.com";async function XC(n,e){return Jl(n,"POST","/v1/accounts:signUp",Hn(n,e))}class Aa{constructor(e){this.user=e.user,this.providerId=e.providerId,this._tokenResponse=e._tokenResponse,this.operationType=e.operationType}static async _fromIdTokenResponse(e,t,s,r=!1){const i=await ro._fromIdTokenResponse(e,s,r),a=r8(s);return new Aa({user:i,providerId:a,_tokenResponse:s,operationType:t})}static async _forOperation(e,t,s){await e._updateTokensIfNecessary(s,!0);const r=r8(s);
9return new Aa({user:e,providerId:r,_tokenResponse:s,operationType:t})}}function r8(n){return n.providerId?n.providerId:"phoneNumber"in n?"phone":null}async function mz(n){if(Jn(n.app))return Promise.reject(dr(n));const e=gs(n);if(await e._initializationPromise,e.currentUser?.isAnonymous)return new Aa({user:e.currentUser,providerId:null,operationType:"signIn"});const t=await XC(e,{returnSecureToken:!0}),s=await Aa._fromIdTokenResponse(e,"signIn",t,!0);return await e._updateCurrentUser(s.user),s}class i1 extends Ra{constructor(e,t,s,r){super(t.code,t.message),this.operationType=s,this.user=r,Object.setPrototypeOf(this,i1.prototype),this.customData={appName:e.name,tenantId:e.tenantId??void 0,_serverResponse:t.customData._serverResponse,operationType:s}}static _fromErrorAndOperation(e,t,s,r){return new i1(e,t,s,r)}}function JC(n,e,t,s){return(e==="reauthenticate"?t._getReauthenticationResolver(n):t._getIdTokenResponse(n)).catch(i=>{throw i.code==="auth/multi-factor-auth-required"?i1._fromErrorAndOperation(n,i,e,s):i})}function ZC(n){return new Set(n.map(({providerId:e})=>e).filter(e=>!!e))}async function ek(n,e){const t=wt(n);await fx(!0,t,e);const{providerUserInfo:s}=await bB(t.auth,{idToken:await t.getIdToken(),deleteProvider:[e]}),r=ZC(s||[]);return t.providerData=t.providerData.filter(i=>r.has(i.providerId)),r.has("phone")||(t.phoneNumber=null),await t.auth._persistUserIfCurrent(t),t}async function y4(n,e,t=!1){const s=await Wl(n,e._linkToIdToken(n.auth,await n.getIdToken()),t);return Aa._forOperation(n,"link",s)}async function fx(n,e,t){await Xp(e);const s=ZC(e.providerData),r=n===!1?"provider-already-linked":"no-such-provider";We(s.has(t)===n,e.auth,r)}async function tk(n,e,t=!1){const{auth:s}=n;if(Jn(s.app))return Promise.reject(dr(s));const r="reauthenticate";try{const i=await Wl(n,JC(s,r,e,n),t);We(i.idToken,s,"internal-error");const a=dx(i.idToken);We(a,s,"internal-error");const{sub:l}=a;return We(n.uid===l,s,"user-mismatch"),Aa._forOperation(n,r,i)}catch(i){throw i?.code==="auth/user-not-found"&&Ci(s,"user-mismatch"),i}}async function nk(n,e,t=!1){if(Jn(n.app))return Promise.reject(dr(n));const s="signIn",r=await JC(n,s,e),i=await Aa._fromIdTokenResponse(n,s,r);return t||await n._updateCurrentUser(i.user),i}async function vf(n,e){return nk(gs(n),e)}async function sk(n,e){const t=wt(n);return await fx(!1,t,e.providerId),y4(t,e)}async function px(n,e){return tk(wt(n),e)}async function gz(n,e){return Jl(n,"POST","/v1/accounts:signInWithCustomToken",Hn(n,e))}async function xz(n,e){if(Jn(n.app))return Promise.reject(dr(n));const t=gs(n),s=await gz(t,{token:e,returnSecureToken:!0}),r=await Aa._fromIdTokenResponse(t,"signIn",s);return await t._updateCurrentUser(r.user),r}class km{constructor(e,t){this.factorId=e,this.uid=t.mfaEnrollmentId,this.enrollmentTime=new Date(t.enrolledAt).toUTCString(),this.displayName=t.displayName}static _fromServerResponse(e,t){return"phoneInfo"in t?v4._fromServerResponse(e,t):"totpInfo"in t?b4._fromServerResponse(e,t):Ci(e,"internal-error")}}class v4 extends km{constructor(e){super("phone",e),this.phoneNumber=e.phoneInfo}static _fromServerResponse(e,t){return new v4(t)}}class b4 extends km{constructor(e){super("totp",e)}static _fromServerResponse(e,t){return new b4(t)}}function mx(n,e,t){We(t.url?.length>0,n,"invalid-continue-uri"),We(typeof t.dynamicLinkDomain>"u"||t.dynamicLinkDomain.length>0,n,"invalid-dynamic-link-domain"),We(typeof t.linkDomain>"u"||t.linkDomain.length>0,n,"invalid-hosting-link-domain"),e.continueUrl=t.url,e.dynamicLinkDomain=t.dynamicLinkDomain,e.linkDomain=t.linkDomain,e.canHandleCodeInApp=t.handleCodeInApp,t.iOS&&(We(t.iOS.bundleId.length>0,n,"missing-ios-bundle-id"),e.iOSBundleId=t.iOS.bundleId),t.android&&(We(t.android.packageName.length>0,n,"missing-android-pkg-name"),e.androidInstallApp=t.android.installApp,e.androidMinimumVersionCode=t.android.minimumVersion,e.androidPackageName=t.android.packageName)}async function w4(n){const e=gs(n);e._getPasswordPolicyInternal()&&await e._updatePasswordPolicy()}async function rk(n,e,t){const s=gs(n),r={requestType:"PASSWORD_RESET",email:e,clientType:"CLIENT_TYPE_WEB"};t&&mx(s,r,t),await Hc(s,r,"getOobCode",ez,"EMAIL_PASSWORD_PROVIDER")}async function yz(n,e,t){await QC(wt(n),{oobCode:e,newPassword:t}).catch(async s=>{throw s.code==="auth/password-does-not-meet-requirements"&&w4(n),s})}async function vz(n,e){await XB(wt(n),{oobCode:e})}async function ik(n,e){const t=wt(n),s=await QC(t,{oobCode:e}),r=s.requestType;switch(We(r,t,"internal-error"),r){case"EMAIL_SIGNIN":break;case"VERIFY_AND_CHANGE_EMAIL":We(s.newEmail,t,"internal-error");break;case"REVERT_SECOND_FACTOR_ADDITION":We(s.mfaInfo,t,"internal-error");default:We(s.email,t,"internal-error")}let i=null;return s.mfaInfo&&(i=km._fromServerResponse(gs(t),s.mfaInfo)),{data:{email:(s.requestType==="VERIFY_AND_CHANGE_EMAIL"?s.newEmail:s.email)||null,previousEmail:(s.requestType==="VERIFY_AND_CHANGE_EMAIL"?s.email:s.newEmail)||null,multiFactorInfo:i},operation:r}}async function bz(n,e){const{data:t}=await ik(wt(n),e);return t.email}async function ak(n,e,t){if(Jn(n.app))return Promise.reject(dr(n));const s=gs(n),a=await Hc(s,{returnSecureToken:!0,email:e,password:t,clientType:"CLIENT_TYPE_WEB"},"signUpPassword",XC,"EMAIL_PASSWORD_PROVIDER").catch(c=>{throw c.code==="auth/password-does-not-meet-requirements"&&w4(n),c}),l=await Aa._fromIdTokenResponse(s,"signIn",a);return await s._updateCurrentUser(l.user),l}function ok(n,e,t){return Jn(n.app)?Promise.reject(dr(n)):vf(wt(n),nl.credential(e,t)).catch(async s=>{throw s.code==="auth/password-does-not-meet-requirements"&&w4(n),s})}async function wz(n,e,t){const s=gs(n),r={requestType:"EMAIL_SIGNIN",email:e,clientType:"CLIENT_TYPE_WEB"};function i(a,l){We(l.handleCodeInApp,s,"argument-error"),l&&mx(s,a,l)}i(r,t),await Hc(s,r,"getOobCode",tz,"EMAIL_PASSWORD_PROVIDER")}function Sz(n,e){return xf.parseLink(e)?.operation==="EMAIL_SIGNIN"}async function Ez(n,e,t){if(Jn(n.app))return Promise.reject(dr(n));const s=wt(n),r=nl.credentialWithLink(e,t||Qp());return We(r._tenantId===(s.tenantId||null),s,"tenant-id-mismatch"),vf(s,r)}async function Tz(n,e){return Wn(n,"POST","/v1/accounts:createAuthUri",Hn(n,e))}async function _z(n,e){const t=p4()?Qp():"http://localhost",s={identifier:e,continueUri:t},{signinMethods:r}=await Tz(wt(n),s);return r||[]}async function Iz(n,e){const t=wt(n),r={requestType:"VERIFY_EMAIL",idToken:await n.getIdToken()};e&&mx(t.auth,r,e);const{email:i}=await ZB(t.auth,r);i!==n.email&&await n.reload()}async function Az(n,e,t){const s=wt(n),i={requestType:"VERIFY_AND_CHANGE_EMAIL",idToken:await n.getIdToken(),newEmail:e};t&&mx(s.auth,i,t);const{email:a}=await nz(s.auth,i);a!==n.email&&await n.reload()}async function Cz(n,e){return Wn(n,"POST","/v1/accounts:update",e)}async function S4(n,{displayName:e,photoURL:t}){if(e===void 0&&t===void 0)return;const s=wt(n),i={idToken:await s.getIdToken(),displayName:e,photoUrl:t,returnSecureToken:!0},a=await Wl(s,Cz(s.auth,i));s.displayName=a.displayName||null,s.photoURL=a.photoUrl||null;const l=s.providerData.find(({providerId:c})=>c==="password");
9l&&(l.displayName=s.displayName,l.photoURL=s.photoURL),await s._updateTokensIfNecessary(a)}function kz(n,e){const t=wt(n);return Jn(t.auth.app)?Promise.reject(dr(t.auth)):lk(t,e,null)}function Rz(n,e){return lk(wt(n),null,e)}async function lk(n,e,t){const{auth:s}=n,i={idToken:await n.getIdToken(),returnSecureToken:!0};e&&(i.email=e),t&&(i.password=t);const a=await Wl(n,YB(s,i));await n._updateTokensIfNecessary(a,!0)}function Pz(n){if(!n)return null;const{providerId:e}=n,t=n.rawUserInfo?JSON.parse(n.rawUserInfo):{},s=n.isNewUser||n.kind==="identitytoolkit#SignupNewUserResponse";if(!e&&n?.idToken){const r=dx(n.idToken)?.firebase?.sign_in_provider;if(r){const i=r!=="anonymous"&&r!=="custom"?r:null;return new Fh(s,i)}}if(!e)return null;switch(e){case"facebook.com":return new Nz(s,t);case"github.com":return new Lz(s,t);case"google.com":return new Dz(s,t);case"twitter.com":return new jz(s,t,n.screenName||null);case"custom":case"anonymous":return new Fh(s,null);default:return new Fh(s,e,t)}}class Fh{constructor(e,t,s={}){this.isNewUser=e,this.providerId=t,this.profile=s}}class ck extends Fh{constructor(e,t,s,r){super(e,t,s),this.username=r}}class Nz extends Fh{constructor(e,t){super(e,"facebook.com",t)}}class Lz extends ck{constructor(e,t){super(e,"github.com",t,typeof t?.login=="string"?t?.login:null)}}class Dz extends Fh{constructor(e,t){super(e,"google.com",t)}}class jz extends ck{constructor(e,t,s){super(e,"twitter.com",t,s)}}function Oz(n){const{user:e,_tokenResponse:t}=n;return e.isAnonymous&&!t?{providerId:null,isNewUser:!1,profile:null}:Pz(t)}function Mz(n,e){return wt(n).setPersistence(e)}function Fz(n){return GC(n)}
9async function Uz(n,e){return gs(n).validatePassword(e)}function uk(n,e,t,s){return wt(n).onIdTokenChanged(e,t,s)}function dk(n,e,t){return wt(n).beforeAuthStateChanged(e,t)}function Rd(n,e,t,s){return wt(n).onAuthStateChanged(e,t,s)}function Vz(n){wt(n).useDeviceLanguage()}function Bz(n,e){return wt(n).updateCurrentUser(e)}function hk(n){return wt(n).signOut()}function zz(n,e){return gs(n).revokeAccessToken(e)}async function fk(n){return wt(n).delete()}class Ju{constructor(e,t,s){this.type=e,this.credential=t,this.user=s}static _fromIdtoken(e,t){return new Ju("enroll",e,t)}static _fromMfaPendingCredential(e){return new Ju("signin",e)}toJSON(){return{multiFactorSession:{[this.type==="enroll"?"idToken":"pendingCredential"]:this.credential}}}static fromJSON(e){if(e?.multiFactorSession){if(e.multiFactorSession?.pendingCredential)return Ju._fromMfaPendingCredential(e.multiFactorSession.pendingCredential);if(e.multiFactorSession?.idToken)return Ju._fromIdtoken(e.multiFactorSession.idToken)}return null}}class E4{constructor(e,t,s){this.session=e,this.hints=t,this.signInResolver=s}static _fromError(e,t){const s=gs(e),r=t.customData._serverResponse,i=(r.mfaInfo||[]).map(l=>km._fromServerResponse(s,l));We(r.mfaPendingCredential,s,"internal-error");const a=Ju._fromMfaPendingCredential(r.mfaPendingCredential);return new E4(a,i,async l=>{const c=await l._process(s,a);delete r.mfaInfo,delete r.mfaPendingCredential;const d={...r,idToken:c.idToken,refreshToken:c.refreshToken};switch(t.operationType){case"signIn":const h=await Aa._fromIdTokenResponse(s,t.operationType,d);return await s._updateCurrentUser(h.user),h;case"reauthenticate":return We(t.user,s,"internal-error"),Aa._forOperation(t.user,t.operationType,d);default:Ci(s,"internal-error")}})}async resolveSignIn(e){const t=e;return this.signInResolver(t)}}function $z(n,e){const t=wt(n),s=e;return We(e.customData.operationType,t,"argument-error"),We(s.customData._serverResponse?.mfaPendingCredential,t,"argument-error"),E4._fromError(t,s)}function i8(n,e){return Wn(n,"POST","/v2/accounts/mfaEnrollment:start",Hn(n,e))}function Hz(n,e){return Wn(n,"POST","/v2/accounts/mfaEnrollment:finalize",Hn(n,e))}function Wz(n,e){return Wn(n,"POST","/v2/accounts/mfaEnrollment:start",Hn(n,e))}function Gz(n,e){return Wn(n,"POST","/v2/accounts/mfaEnrollment:finalize",Hn(n,e))}function Kz(n,e){return Wn(n,"POST","/v2/accounts/mfaEnrollment:withdraw",Hn(n,e))}class T4{constructor(e){this.user=e,this.enrolledFactors=[],e._onReload(t=>{t.mfaInfo&&(this.enrolledFactors=t.mfaInfo.map(s=>km._fromServerResponse(e.auth,s)))})}static _fromUser(e){return new T4(e)}async getSession(){return Ju._fromIdtoken(await this.user.getIdToken(),this.user)}
9async enroll(e,t){const s=e,r=await this.getSession(),i=await Wl(this.user,s._process(this.user.auth,r,t));return await this.user._updateTokensIfNecessary(i),this.user.reload()}async unenroll(e){const t=typeof e=="string"?e:e.uid,s=await this.user.getIdToken();try{const r=await Wl(this.user,Kz(this.user.auth,{idToken:s,mfaEnrollmentId:t}));this.enrolledFactors=this.enrolledFactors.filter(({uid:i})=>i!==t),await this.user._updateTokensIfNecessary(r),await this.user.reload()}catch(r){throw r}}}const Y2=new WeakMap;function qz(n){const e=wt(n);return Y2.has(e)||Y2.set(e,T4._fromUser(e)),Y2.get(e)}const a1="__sak";class pk{constructor(e,t){this.storageRetriever=e,this.type=t}_isAvailable(){try{return this.storage?(this.storage.setItem(a1,"1"),this.storage.removeItem(a1),Promise.resolve(!0)):Promise.resolve(!1)}catch{return Promise.resolve(!1)}}_set(e,t){return this.storage.setItem(e,JSON.stringify(t)),Promise.resolve()}_get(e){const t=this.storage.getItem(e);return Promise.resolve(t?JSON.parse(t):null)}_remove(e){return this.storage.removeItem(e),Promise.resolve()}get storage(){return this.storageRetriever()}}const Yz=1e3,Qz=10;class mk extends pk{constructor(){super(()=>window.localStorage,"LOCAL"),this.boundEventHandler=(e,t)=>this.onStorageEvent(e,t),this.listeners={},this.localCache={},this.pollTimer=null,this.fallbackToPolling=$C(),this._shouldAllowMigration=!0}forAllChangedKeys(e){for(const t of Object.keys(this.listeners)){const s=this.storage.getItem(t),r=this.localCache[t];s!==r&&e(t,r,s)}}onStorageEvent(e,t=!1){if(!e.key){this.forAllChangedKeys((a,l,c)=>{this.notifyListeners(a,c)});return}const s=e.key;t?this.detachListener():this.stopPolling();const r=()=>{const a=this.storage.getItem(s);!t&&this.localCache[s]===a||this.notifyListeners(s,a)},i=this.storage.getItem(s);CB()&&i!==e.newValue&&e.newValue!==e.oldValue?setTimeout(r,Qz):r()}notifyListeners(e,t){this.localCache[e]=t;const s=this.listeners[e];if(s)for(const r of Array.from(s))r(t&&JSON.parse(t))}startPolling(){this.stopPolling(),this.pollTimer=setInterval(()=>{this.forAllChangedKeys((e,t,s)=>{this.onStorageEvent(new StorageEvent("storage",{key:e,oldValue:t,newValue:s}),!0)})},Yz)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}attachListener(){window.addEventListener("storage",this.boundEventHandler)}detachListener(){window.removeEventListener("storage",this.boundEventHandler)}_addListener(e,t){Object.keys(this.listeners).length===0&&(this.fallbackToPolling?this.startPolling():this.attachListener()),this.listeners[e]||(this.listeners[e]=new Set,this.localCache[e]=this.storage.getItem(e)),this.listeners[e].add(t)}_removeListener(e,t){this.listeners[e]&&(this.listeners[e].delete(t),this.listeners[e].size===0&&delete this.listeners[e]),Ob
9ject.keys(this.listeners).length===0&&(this.detachListener(),this.stopPolling())}async _set(e,t){await super._set(e,t),this.localCache[e]=JSON.stringify(t)}async _get(e){const t=await super._get(e);return this.localCache[e]=JSON.stringify(t),t}async _remove(e){await super._remove(e),delete this.localCache[e]}}mk.type="LOCAL";const gk=mk;const Xz=1e3;function Q2(n){const e=n.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),t=RegExp(`${e}=([^;]+)`);return document.cookie.match(t)?.[1]??null}function X2(n){return`${window.location.protocol==="http:"?"__dev_":"__HOST-"}FIREBASE_${n.split(":")[3]}`}class xk{constructor(){this.type="COOKIE",this.listenerUnsubscribes=new Map}_getFinalTarget(e){if(typeof window===void 0)return e;const t=new URL(`${window.location.origin}/__cookies__`);return t.searchParams.set("finalTarget",e),t}async _isAvailable(){return typeof isSecureContext=="boolean"&&!isSecureContext||typeof navigator>"u"||typeof document>"u"?!1:navigator.cookieEnabled??!0}async _set(e,t){}async _get(e){if(!this._isAvailable())return null;const t=X2(e);return window.cookieStore?(await window.cookieStore.get(t))?.value:Q2(t)}async _remove(e){if(!this._isAvailable()||!await this._get(e))return;const s=X2(e);document.cookie=`${s}=;Max-Age=34560000;Partitioned;Secure;SameSite=Strict;Path=/;Priority=High`,await fetch("/__cookies__",{method:"DELETE"}).catch(()=>{})}_addListener(e,t){if(!this._isAvailable())return;const s=X2(e);if(window.cookieStore){const l=(d=>{const h=d.changed.find(m=>m.name===s);h&&t(h.value),d.deleted.find(m=>m.name===s)&&t(null)}),c=()=>window.cookieStore.removeEventListener("change",l);return this.listenerUnsubscribes.set(t,c),window.cookieStore.addEventListener("change",l)}let r=Q2(s);const i=setInterval(()=>{const l=Q2(s);l!==r&&(t(l),r=l)},Xz),a=()=>clearInterval(i);this.listenerUnsubscribes.set(t,a)}_removeListener(e,t){const s=this.listenerUnsubscribes.get(t);s&&(s(),this.listenerUnsubscribes.delete(t))}}xk.type="COOKIE";const Jz=xk;class yk extends pk{constructor(){super(()=>window.sessionStorage,"SESSION")}_addListener(e,t){}_removeListener(e,t){}}yk.type="SESSION";const _4=yk;function Zz(n){return Promise.all(n.map(async e=>{try{return{fulfilled:!0,value:await e}}catch(t){return{fulfilled:!1,reason:t}}}))}class gx{constructor(e){this.eventTarget=e,this.handlersMap={},this.boundEventHandler=this.handleEvent.bind(this)}static _getInstance(e){const t=this.receivers.find(r=>r.isListeningto(e));if(t)return t;const s=new gx(e);return this.receivers.push(s),s}isListeningto(e){return this.eventTarget===e}async handleEvent(e){const t=e,{eventId:s,eventType:r,data:i}=t.data,a=this.handlersMap[r];if(!a?.size)return;t.ports[0].postMessage({status:"ack",eventId:s,eventType:r});const l=Array.from(a).map(async d=>d(t.origin,i)),c=await Zz(l);t.ports[0].postMessage({status:"done",eventId:s,eventType:r,response:c})}_subscribe(e,t){Object.keys(this.handlersMap).length===0&&this.eventTarget.addEventListener("message",this.boundEventHandler),this.handlersMap[e]||(this.handlersMap[e]=new Set),this.handlersMap[e].add(t)}_unsubscribe(e,t){this.handlersMap[e]&&t&&this.handlersMap[e].delete(t),(!t||this.handlersMap[e].size===0)&&delete this.handlersMap[e],Object.keys(this.handlersMap).length===0&&this.eventTarget.removeEventListener("message",this.boundEventHandler)}}gx.receivers=[];function xx(n="",e=10){let t="";for(let s=0;s<e;s++)t+=Math.floor(Math.random()*10);return n+t}class e${constructor(e){this.target=e,this.handlers=new Set}removeMessageHandler(e){e.messageChannel&&(e.messageChannel.port1.removeEventListener("message",e.onMessage),e.messageChannel.port1.close()),this.handlers.delete(e)}async _send(e,t,s=50){const r=typeof MessageChannel<"u"?new MessageChannel:null;if(!r)throw new Error("connection_unavailable");let i,a;return new Promise((l,c)=>{const d=xx("",20);r.port1.start();const h=setTimeout(()=>{c(new Error("unsupported_event"))},s);a={messageChannel:r,onMessage(p){const m=p;if(m.data.eventId===d)switch(m.data.status){case"ack":clearTimeout(h),i=setTimeout(()=>{c(new Error("timeout"))},3e3);break;case"done":clearTimeout(i),l(m.data.response);break;default:clearTimeout(h),clearTimeout(i),c(new Error("invalid_response"));break}}},this.handlers.add(a),r.port1.addEventListener("message",a.onMessage),this.target.postMessage({eventType:e,eventId:d,data:t},[r.port2])}).finally(()=>{a&&this.removeMessageHandler(a)})}}function Ps(){return window}
9function t$(n){Ps().location.href=n}function I4(){return typeof Ps().WorkerGlobalScope<"u"&&typeof Ps().importScripts=="function"}async function n$(){if(!navigator?.serviceWorker)return null;try{return(await navigator.serviceWorker.ready).active}catch{return null}}function s$(){return navigator?.serviceWorker?.controller||null}function r$(){return I4()?self:null}const vk="firebaseLocalStorageDb",i$=1,o1="firebaseLocalStorage",bk="fbase_key";class Rm{constructor(e){this.request=e}toPromise(){return new Promise((e,t)=>{this.request.addEventListener("success",()=>{e(this.request.result)}),this.request.addEventListener("error",()=>{t(this.request.error)})})}}function yx(n,e){return n.transaction([o1],e?"readwrite":"readonly").objectStore(o1)}function a$(){const n=indexedDB.deleteDatabase(vk);return new Rm(n).toPromise()}function wk(){const n=indexedDB.open(vk,i$);return new Promise((e,t)=>{n.addEventListener("error",()=>{t(n.error)}),n.addEventListener("upgradeneeded",()=>{const s=n.result;try{s.createObjectStore(o1,{keyPath:bk})}catch(r){t(r)}}),n.addEventListener("success",async()=>{const s=n.result;s.objectStoreNames.contains(o1)?e(s):(s.close(),await a$(),e(await wk()))})})}async function a8(n,e,t){const s=yx(n,!0).put({[bk]:e,value:t});return new Rm(s).toPromise()}async function o$(n,e){const t=yx(n,!1).get(e),s=await new Rm(t).toPromise();return s===void 0?null:s.value}function o8(n,e){const t=yx(n,!0).delete(e);return new Rm(t).toPromise()}const l$=800,c$=3;class Sk{constructor(){this.type="LOCAL",this.dbPromise=null,this._shouldAllowMigration=!0,this.listeners={},this.localCache={},this.pollTimer=null,this.pendingWrites=0,this.receiver=null,this.sender=null,this.serviceWorkerReceiverAvailable=!1,this.activeServiceWorker=null,this._workerInitializationPromise=this.initializeServiceWorkerMessaging().then(()=>{},()=>{})}async _openDb(){return this.dbPromise?this.dbPromise:(this.dbPromise=wk(),this.dbPromise.catch(()=>{this.dbPromise=null}),this.dbPromise)}async _withRetries(e){let t=0;for(;;)try{const s=await this._openDb();return await e(s)}catch(s){if(t++>c$)throw s;this.dbPromise&&((await this.dbPromise).close(),this.dbPromise=null)}}async initializeServiceWorkerMessaging(){return I4()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=gx._getInstance(r$()),this.receiver._subscribe("keyChanged",async(e,t)=>({keyProcessed:(await this._poll()).includes(t.key)})),this.receiver._subscribe("ping",async(e,t)=>["keyChanged"])}async initializeSender(){if(this.activeServiceWorker=await n$(),!this.activeServiceWorker)return;this.sender=new e$(this.activeServiceWorker);const e=await this.sender._send("ping",{},800);e&&e[0]?.fulfilled&&e[0]?.value.includes("keyChanged")&&(this.serviceWorkerReceiverAvailable=!0)}async notifyServiceWorker(e){if(!(!this.sender||!this.activeServiceWorker||s$()!==this.activeServiceWorker))try{await this.sender._send("keyChanged",{key:e},this.serviceWorkerReceiverAvailable?800:50)}catch{}}async _isAvailable(){try{return indexedDB?(await this._withRetries(async e=>{await a8(e,a1,"1"),await o8(e,a1)}),!0):!1}catch{}return!1}async _withPendingWrite(e){this.pendingWrites++;try{await e()}finally{this.pendingWrites--}}async _set(e,t){return this._withPendingWrite(async()=>(await this._withRetries(s=>a8(s,e,t)),this.localCache[e]=t,this.notifyServiceWorker(e)))}async _get(e){const t=await this._withRetries(s=>o$(s,e));return this.localCache[e]=t,t}async _remove(e){return this._withPendingWrite(async()=>(await this._withRetries(t=>o8(t,e)),delete this.localCache[e],this.notifyServiceWorker(e)))}async _poll(){const e=await this._withRetries(r=>{const i=yx(r,!1).getAll();return new Rm(i).toPromise()});if(!e)return[];if(this.pendingWrites!==0)return[];const t=[],s=new Set;if(e.length!==0)for(const{fbase_key:r,value:i}of e)s.add(r),JSON.stringify(this.localCache[r])!==JSON.stringify(i)&&(this.notifyListeners(r,i),t.push(r));for(const r of Object.keys(this.localCache))this.localCache[r]&&!s.has(r)&&(this.notifyListeners(r,null),t.push(r));return t}notifyListeners(e,t){this.localCache[e]=t;const s=this.listeners[e];if(s)for(const r of Array.from(s))r(t)}startPolling(){this.stopPolling(),this.pollTimer=setInterval(async()=>this._poll(),l$)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}_addListener(e,t){Object.keys(this.listeners).length===0&&this.startPolling(),this.listeners[e]||(this.listeners[e]=new Set,this._get(e)),this.listeners[e].add(t)}_removeListener(e,t){this.listeners[e]&&(this.listeners[e].delete(t),this.listeners[e].size===0&&delete this.listeners[e]),Ob
9ject.keys(this.listeners).length===0&&this.stopPolling()}}Sk.type="LOCAL";const Ek=Sk;function l8(n,e){return Wn(n,"POST","/v2/accounts/mfaSignIn:start",Hn(n,e))}function u$(n,e){return Wn(n,"POST","/v2/accounts/mfaSignIn:finalize",Hn(n,e))}function d$(n,e){return Wn(n,"POST","/v2/accounts/mfaSignIn:finalize",Hn(n,e))}const J2=WC("rcb"),h$=new Am(3e4,6e4);class f${constructor(){this.hostLanguage="",this.counter=0,this.librarySeparatelyLoaded=!!Ps().grecaptcha?.render}load(e,t=""){return We(p$(t),e,"argument-error"),this.shouldResolveImmediately(t)&&YT(Ps().grecaptcha)?Promise.resolve(Ps().grecaptcha):new Promise((s,r)=>{const i=Ps().setTimeout(()=>{r(si(e,"network-request-failed"))},h$.get());Ps()[J2]=()=>{Ps().clearTimeout(i),delete Ps()[J2];const l=Ps().grecaptcha;if(!l||!YT(l)){r(si(e,"internal-error"));return}const c=l.render;l.render=(d,h)=>{const p=c(d,h);return this.counter++,p},this.hostLanguage=t,s(l)};const a=`${jB()}?${pf({onload:J2,render:"explicit",hl:t})}`;x4(a).catch(()=>{clearTimeout(i),r(si(e,"internal-error"))})})}clearedOneInstance(){this.counter--}shouldResolveImmediately(e){return!!Ps().grecaptcha?.render&&(e===this.hostLanguage||this.counter>0||this.librarySeparatelyLoaded)}}function p$(n){return n.length<=6&&/^\s*[a-zA-Z0-9\-]*\s*$/.test(n)}class m${async load(e){return new VB(e)}clearedOneInstance(){}}const Ip="recaptcha",g$={theme:"light",type:"image"};class x${constructor(e,t,s={...g$}){this.parameters=s,this.type=Ip,this.destroyed=!1,this.widgetId=null,this.tokenChangeListeners=new Set,this.renderPromise=null,this.recaptcha=null,this.auth=gs(e),this.isInvisible=this.parameters.size==="invisible",We(typeof document<"u",this.auth,"operation-not-supported-in-this-environment");const r=typeof t=="string"?document.getElementById(t):t;We(r,this.auth,"argument-error"),this.container=r,this.parameters.callback=this.makeTokenCallback(this.parameters.callback),this._recaptchaLoader=this.auth.settings.appVerificationDisabledForTesting?new m$:new f$,this.validateStartingState()}async verify(){this.assertNotDestroyed();const e=await this.render(),t=this.getAssertedRecaptcha(),s=t.getResponse(e);return s||new Promise(r=>{const i=a=>{a&&(this.tokenChangeListeners.delete(i),r(a))};this.tokenChangeListeners.add(i),this.isInvisible&&t.execute(e)})}render(){try{this.assertNotDestroyed()}catch(e){return Promise.reject(e)}return this.renderPromise?this.renderPromise:(this.renderPromise=this.makeRenderPromise().catch(e=>{throw this.renderPromise=null,e}),this.renderPromise)}_reset(){this.assertNotDestroyed(),this.widgetId!==null&&this.getAssertedRecaptcha().reset(this.widgetId)}clear(){this.assertNotDestroyed(),this.destroyed=!0,this._recaptchaLoader.clearedOneInstance(),this.isInvisible||this.container.childNodes.forEach(e=>{this.container.removeChild(e)})}validateStartingState(){We(!this.parameters.sitekey,this.auth,"argument-error"),We(this.isInvisible||!this.container.hasChildNodes(),this.auth,"argument-error"),We(typeof document<"u",this.auth,"operation-not-supported-in-this-environment")}makeTokenCallback(e){return t=>{if(this.tokenChangeListeners.forEach(s=>s(t)),typeof e=="function")e(t);else if(typeof e=="string"){const s=Ps()[e];typeof s=="function"&&s(t)}}}assertNotDestroyed(){We(!this.destroyed,this.auth,"internal-error")}async makeRenderPromise(){if(await this.init(),!this.widgetId){let e=this.container;if(!this.isInvisible){const t=document.createElement("div");e.appendChild(t),e=t}this.widgetId=this.getAssertedRecaptcha().render(e,this.parameters)}return this.widgetId}
9async init(){We(p4()&&!I4(),this.auth,"internal-error"),await y$(),this.recaptcha=await this._recaptchaLoader.load(this.auth,this.auth.languageCode||void 0);const e=await yB(this.auth);We(e,this.auth,"internal-error"),this.parameters.sitekey=e}getAssertedRecaptcha(){return We(this.recaptcha,this.auth,"internal-error"),this.recaptcha}}function y$(){let n=null;return new Promise(e=>{if(document.readyState==="complete"){e();return}n=()=>e(),window.addEventListener("load",n)}).catch(e=>{throw n&&window.removeEventListener("load",n),e})}class A4{constructor(e,t){this.verificationId=e,this.onConfirmation=t}confirm(e){const t=Wc._fromVerification(this.verificationId,e);return this.onConfirmation(t)}}async function v$(n,e,t){if(Jn(n.app))return Promise.reject(dr(n));const s=gs(n),r=await vx(s,e,wt(t));return new A4(r,i=>vf(s,i))}async function b$(n,e,t){const s=wt(n);await fx(!1,s,"phone");const r=await vx(s.auth,e,wt(t));return new A4(r,i=>sk(s,i))}async function w$(n,e,t){const s=wt(n);if(Jn(s.auth.app))return Promise.reject(dr(s.auth));const r=await vx(s.auth,e,wt(t));return new A4(r,i=>px(s,i))}async function vx(n,e,t){if(!n._getRecaptchaConfig())try{await GC(n)}catch{}try{let s;if(typeof e=="string"?s={phoneNumber:e}:s=e,"session"in s){const r=s.session;if("phoneNumber"in s){We(r.type==="enroll",n,"internal-error");const i={idToken:r.credential,phoneEnrollmentInfo:{phoneNumber:s.phoneNumber,clientType:"CLIENT_TYPE_WEB"}};return(await Hc(n,i,"mfaSmsEnrollment",async(d,h)=>{if(h.phoneEnrollmentInfo.captchaResponse===Tp){We(t?.type===Ip,d,"argument-error");const p=await Z2(d,h,t);return i8(d,p)}return i8(d,h)},"PHONE_PROVIDER").catch(d=>Promise.reject(d))).phoneSessionInfo.sessionInfo}else{We(r.type==="signin",n,"internal-error");const i=s.multiFactorHint?.uid||s.multiFactorUid;We(i,n,"missing-multi-factor-info");const a={mfaPendingCredential:r.credential,mfaEnrollmentId:i,phoneSignInInfo:{clientType:"CLIENT_TYPE_WEB"}};return(await Hc(n,a,"mfaSmsSignIn",async(h,p)=>{if(p.phoneSignInInfo.captchaResponse===Tp){We(t?.type===Ip,h,"argument-error");const m=await Z2(h,p,t);return l8(h,m)}return l8(h,p)},"PHONE_PROVIDER").catch(h=>Promise.reject(h))).phoneResponseInfo.sessionInfo}}else{const r={phoneNumber:s.phoneNumber,clientType:"CLIENT_TYPE_WEB"};return(await Hc(n,r,"sendVerificationCode",async(c,d)=>{if(d.captchaResponse===Tp){We(t?.type===Ip,c,"argument-error");const h=await Z2(c,d,t);return s8(c,h)}return s8(c,d)},"PHONE_PROVIDER").catch(c=>Promise.reject(c))).sessionInfo}}finally{t?._reset()}}async function S$(n,e){const t=wt(n);if(Jn(t.auth.app))return Promise.reject(dr(t.auth));await y4(t,e)}async function Z2(n,e,t){We(t.type===Ip,n,"argument-error");const s=await t.verify();We(typeof s=="string",n,"argument-error");const r={...e};if("phoneEnrollmentInfo"in r){const i=r.phoneEnrollmentInfo.phoneNumber,a=r.phoneEnrollmentInfo.captchaResponse,l=r.phoneEnrollmentInfo.clientType,c=r.phoneEnrollmentInfo.recaptchaVersion;return Object.assign(r,{phoneEnrollmentInfo:{phoneNumber:i,recaptchaToken:s,captchaResponse:a,clientType:l,recaptchaVersion:c}}),r}else if("phoneSignInInfo"in r){const i=r.phoneSignInInfo.captchaResponse,a=r.phoneSignInInfo.clientType,l=r.phoneSignInInfo.recaptchaVersion;return Object.assign(r,{phoneSignInInfo:{recaptchaToken:s,captchaResponse:i,clientType:a,recaptchaVersion:l}}),r}else return Object.assign(r,{recaptchaToken:s}),r}class sd{constructor(e){this.providerId=sd.PROVIDER_ID,this.auth=gs(e)}verifyPhoneNumber(e,t){return vx(this.auth,e,wt(t))}static credential(e,t){return Wc._fromVerification(e,t)}static credentialFromResult(e){const t=e;return sd.credentialFromTaggedObject(t)}static credentialFromError(e){return sd.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{phoneNumber:t,temporaryProof:s}=e;return t&&s?Wc._fromTokenResponse(t,s):null}}sd.PROVIDER_ID="phone";sd.PHONE_SIGN_IN_METHOD="phone";function Pd(n,e){return e?Ll(e):(We(n._popupRedirectResolver,n,"argument-error"),n._popupRedirectResolver)}class C4 extends gf{constructor(e){super("custom","custom"),this.params=e}_getIdTokenResponse(e){return Ul(e,this._buildIdpRequest())}_linkToIdToken(e,t){return Ul(e,this._buildIdpRequest(t))}_getReauthenticationResolver(e){return Ul(e,this._buildIdpRequest())}_buildIdpRequest(e){const t={requestUri:this.params.requestUri,sessionId:this.params.sessionId,postBody:this.params.postBody,tenantId:this.params.tenantId,pendingToken:this.params.pendingToken,returnSecureToken:!0,returnIdpCredential:!0};return e&&(t.idToken=e),t}}function E$(n){return nk(n.auth,new C4(n),n.bypassAuthState)}function T$(n){const{auth:e,user:t}=n;return We(t,e,"internal-error"),tk(t,new C4(n),n.bypassAuthState)}async function _$(n){const{auth:e,user:t}=n;return We(t,e,"internal-error"),y4(t,new C4(n),n.bypassAuthState)}class Tk{constructor(e,t,s,r,i=!1){this.auth=e,this.resolver=s,this.user=r,this.bypassAuthState=i,this.pendingPromise=null,this.eventManager=null,this.filter=Array.isArray(t)?t:[t]}execute(){return new Promise(async(e,t)=>{this.pendingPromise={resolve:e,reject:t};try{this.eventManager=await this.resolver._initialize(this.auth),await this.onExecution(),this.eventManager.registerConsumer(this)}catch(s){this.reject(s)}})}async onAuthEvent(e){const{urlResponse:t,sessionId:s,postBody:r,tenantId:i,error:a,type:l}=e;if(a){this.reject(a);return}const c={auth:this.auth,requestUri:t,sessionId:s,tenantId:i||void 0,postBody:r||void 0,user:this.user,bypassAuthState:this.bypassAuthState};try{this.resolve(await this.getIdpTask(l)(c))}catch(d){this.reject(d)}}onError(e){this.reject(e)}getIdpTask(e){switch(e){case"signInViaPopup":case"signInViaRedirect":return E$;case"linkViaPopup":case"linkViaRedirect":return _$;case"reauthViaPopup":case"reauthViaRedirect":return T$;default:Ci(this.auth,"internal-error")}}resolve(e){Hl(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){Hl(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.reject(e),this.unregisterAndCleanUp()}unregisterAndCleanUp(){this.eventManager&&this.eventManager.unregisterConsumer(this),this.pendingPromise=null,this.cleanUp()}}const I$=new Am(2e3,1e4);async function k4(n,e,t){if(Jn(n.app))return Promise.reject(si(n,"operation-not-supported-in-this-environment"));const s=gs(n);mf(n,e,Zl);const r=Pd(s,t);return new Dl(s,"signInViaPopup",e,r).executeNotNull()}async function _k(n,e,t){const s=wt(n);if(Jn(s.auth.app))return Promise.reject(si(s.auth,"operation-not-supported-in-this-environment"));mf(s.auth,e,Zl);const r=Pd(s.auth,t);return new Dl(s.auth,"reauthViaPopup",e,r,s).executeNotNull()}async function Ik(n,e,t){const s=wt(n);mf(s.auth,e,Zl);const r=Pd(s.auth,t);return new Dl(s.auth,"linkViaPopup",e,r,s).executeNotNull()}
9class Dl extends Tk{constructor(e,t,s,r,i){super(e,t,r,i),this.provider=s,this.authWindow=null,this.pollId=null,Dl.currentPopupAction&&Dl.currentPopupAction.cancel(),Dl.currentPopupAction=this}async executeNotNull(){const e=await this.execute();return We(e,this.auth,"internal-error"),e}async onExecution(){Hl(this.filter.length===1,"Popup operations only handle one event");const e=xx();this.authWindow=await this.resolver._openPopup(this.auth,this.provider,this.filter[0],e),this.authWindow.associatedEvent=e,this.resolver._originValidation(this.auth).catch(t=>{this.reject(t)}),this.resolver._isIframeWebStorageSupported(this.auth,t=>{t||this.reject(si(this.auth,"web-storage-unsupported"))}),this.pollUserCancellation()}get eventId(){return this.authWindow?.associatedEvent||null}cancel(){this.reject(si(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,Dl.currentPopupAction=null}pollUserCancellation(){const e=()=>{if(this.authWindow?.window?.closed){this.pollId=window.setTimeout(()=>{this.pollId=null,this.reject(si(this.auth,"popup-closed-by-user"))},8e3);return}this.pollId=window.setTimeout(e,I$.get())};e()}}Dl.currentPopupAction=null;const A$="pendingRedirect",E0=new Map;class C$ extends Tk{constructor(e,t,s=!1){super(e,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],t,void 0,s),this.eventId=null}async execute(){let e=E0.get(this.auth._key());if(!e){try{const s=await k$(this.resolver,this.auth)?await super.execute():null;e=()=>Promise.resolve(s)}catch(t){e=()=>Promise.reject(t)}E0.set(this.auth._key(),e)}return this.bypassAuthState||E0.set(this.auth._key(),()=>Promise.resolve(null)),e()}async onAuthEvent(e){if(e.type==="signInViaRedirect")return super.onAuthEvent(e);if(e.type==="unknown"){this.resolve(null);return}if(e.eventId){const t=await this.auth._redirectUserForId(e.eventId);if(t)return this.user=t,super.onAuthEvent(e);this.resolve(null)}}async onExecution(){}cleanUp(){}}async function k$(n,e){const t=Ck(e),s=Ak(n);if(!await s._isAvailable())return!1;const r=await s._get(t)==="true";return await s._remove(t),r}async function R4(n,e){return Ak(n)._set(Ck(e),"true")}function R$(n,e){E0.set(n._key(),e)}function Ak(n){return Ll(n._redirectPersistence)}function Ck(n){return S0(A$,n.config.apiKey,n.name)}function kk(n,e,t){return P$(n,e,t)}async function P$(n,e,t){if(Jn(n.app))return Promise.reject(dr(n));const s=gs(n);mf(n,e,Zl),await s._initializationPromise;const r=Pd(s,t);return await R4(r,s),r._openRedirect(s,e,"signInViaRedirect")}function N$(n,e,t){return L$(n,e,t)}async function L$(n,e,t){const s=wt(n);if(mf(s.auth,e,Zl),Jn(s.auth.app))return Promise.reject(dr(s.auth));await s.auth._initializationPromise;const r=Pd(s.auth,t);await R4(r,s.auth);const i=await Nk(s);return r._openRedirect(s.auth,e,"reauthViaRedirect",i)}function D$(n,e,t){return j$(n,e,t)}async function j$(n,e,t){const s=wt(n);mf(s.auth,e,Zl),await s.auth._initializationPromise;const r=Pd(s.auth,t);await fx(!1,s,e.providerId),await R4(r,s.auth);const i=await Nk(s);return r._openRedirect(s.auth,e,"linkViaRedirect",i)}async function Rk(n,e){return await gs(n)._initializationPromise,Pk(n,e,!1)}async function Pk(n,e,t=!1){if(Jn(n.app))return Promise.reject(dr(n));const s=gs(n),r=Pd(s,e),a=await new C$(s,r,t).execute();return a&&!t&&(delete a.user._redirectEventId,await s._persistUserIfCurrent(a.user),await s._setRedirectUser(null,e)),a}async function Nk(n){const e=xx(`${n.uid}:::`);return n._redirectEventId=e,await n.auth._setRedirectUser(n),await n.auth._persistUserIfCurrent(n),e}const O$=600*1e3;class M${constructor(e){this.auth=e,this.cachedEventUids=new Set,this.consumers=new Set,this.queuedRedirectEvent=null,this.hasHandledPotentialRedirect=!1,this.lastProcessedEventTime=Date.now()}registerConsumer(e){this.consumers.add(e),this.queuedRedirectEvent&&this.isEventForConsumer(this.queuedRedirectEvent,e)&&(this.sendToConsumer(this.queuedRedirectEvent,e),this.saveEventToCache(this.queuedRedirectEvent),this.queuedRedirectEvent=null)}unregisterConsumer(e){this.consumers.delete(e)}onEvent(e){if(this.hasEventBeenHandled(e))return!1;let t=!1;
9return this.consumers.forEach(s=>{this.isEventForConsumer(e,s)&&(t=!0,this.sendToConsumer(e,s),this.saveEventToCache(e))}),this.hasHandledPotentialRedirect||!F$(e)||(this.hasHandledPotentialRedirect=!0,t||(this.queuedRedirectEvent=e,t=!0)),t}sendToConsumer(e,t){if(e.error&&!Lk(e)){const s=e.error.code?.split("auth/")[1]||"internal-error";t.onError(si(this.auth,s))}else t.onAuthEvent(e)}isEventForConsumer(e,t){const s=t.eventId===null||!!e.eventId&&e.eventId===t.eventId;return t.filter.includes(e.type)&&s}hasEventBeenHandled(e){return Date.now()-this.lastProcessedEventTime>=O$&&this.cachedEventUids.clear(),this.cachedEventUids.has(c8(e))}saveEventToCache(e){this.cachedEventUids.add(c8(e)),this.lastProcessedEventTime=Date.now()}}function c8(n){return[n.type,n.eventId,n.sessionId,n.tenantId].filter(e=>e).join("-")}function Lk({type:n,error:e}){return n==="unknown"&&e?.code==="auth/no-auth-event"}function F$(n){switch(n.type){case"signInViaRedirect":case"linkViaRedirect":case"reauthViaRedirect":return!0;case"unknown":return Lk(n);default:return!1}}async function U$(n,e={}){return Wn(n,"GET","/v1/projects",e)}const V$=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,B$=/^https?/;async function z$(n){if(n.config.emulator)return;const{authorizedDomains:e}=await U$(n);for(const t of e)try{if($$(t))return}catch{}Ci(n,"unauthorized-domain")}function $$(n){const e=Qp(),{protocol:t,hostname:s}=new URL(e);if(n.startsWith("chrome-extension://")){const a=new URL(n);return a.hostname===""&&s===""?t==="chrome-extension:"&&n.replace("chrome-extension://","")===e.replace("chrome-extension://",""):t==="chrome-extension:"&&a.hostname===s}if(!B$.test(t))return!1;if(V$.test(n))return s===n;const r=n.replace(/\./g,"\\.");return new RegExp("^(.+\\."+r+"|"+r+")$","i").test(s)}const H$=new Am(3e4,6e4);function u8(){const n=Ps().___jsl;if(n?.H){for(const e of Object.keys(n.H))if(n.H[e].r=n.H[e].r||[],n.H[e].L=n.H[e].L||[],n.H[e].r=[...n.H[e].L],n.CP)for(let t=0;t<n.CP.length;t++)n.CP[t]=null}}function W$(n){return new Promise((e,t)=>{function s(){u8(),gapi.load("gapi.iframes",{callback:()=>{e(gapi.iframes.getContext())},ontimeout:()=>{u8(),t(si(n,"network-request-failed"))},timeout:H$.get()})}if(Ps().gapi?.iframes?.Iframe)e(gapi.iframes.getContext());else if(Ps().gapi?.load)s();else{const r=WC("iframefcb");return Ps()[r]=()=>{gapi.load?s():t(si(n,"network-request-failed"))},x4(`${MB()}?onload=${r}`).catch(i=>t(i))}}).catch(e=>{throw T0=null,e})}let T0=null;function G$(n){return T0=T0||W$(n),T0}const K$=new Am(5e3,15e3),q$="__/auth/iframe",Y$="emulator/auth/iframe",Q$={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},X$=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);function J$(n){const e=n.config;We(e.authDomain,n,"auth-domain-config-required");const t=e.emulator?m4(e,Y$):`https://${n.config.authDomain}/${q$}`,s={apiKey:e.apiKey,appName:n.name,v:kd},r=X$.get(n.config.apiHost);r&&(s.eid=r);const i=n._getFrameworks();return i.length&&(s.fw=i.join(",")),`${t}?${pf(s).slice(1)}`}async function Z$(n){const e=await G$(n),t=Ps().gapi;return We(t,n,"internal-error"),e.open({where:document.body,url:J$(n),messageHandlersFilter:t.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:Q$,dontclear:!0},s=>new Promise(async(r,i)=>{await s.restyle({setHideOnLeave:!1});const a=si(n,"network-request-failed"),l=Ps().setTimeout(()=>{i(a)},K$.get());function c(){Ps().clearTimeout(l),r(s)}s.ping(c).then(c,()=>{i(a)})}))}const eH={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"},tH=500,nH=600,sH="_blank",rH="http://localhost";class d8{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch{}}}function iH(n,e,t,s=tH,r=nH){const i=Math.max((window.screen.availHeight-r)/2,0).toString(),a=Math.max((window.screen.availWidth-s)/2,0).toString();let l="";const c={...eH,width:s.toString(),height:r.toString(),top:i,left:a},d=Ur().toLowerCase();t&&(l=FC(d)?sH:t),OC(d)&&(e=e||rH,c.scrollbars="yes");const h=Object.entries(c).reduce((m,[y,x])=>`${m}${y}=${x},`,"");if(AB(d)&&l!=="_self")return aH(e||"",l),new d8(null);const p=window.open(e||"",l,h);We(p,n,"popup-blocked");try{p.focus()}catch{}return new d8(p)}function aH(n,e){const t=document.createElement("a");t.href=n,t.target=e;const s=document.createEvent("MouseEvent");
9s.initMouseEvent("click",!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,1,null),t.dispatchEvent(s)}const oH="__/auth/handler",lH="emulator/auth/handler",cH=encodeURIComponent("fac");async function h8(n,e,t,s,r,i){We(n.config.authDomain,n,"auth-domain-config-required"),We(n.config.apiKey,n,"invalid-api-key");const a={apiKey:n.config.apiKey,appName:n.name,authType:t,redirectUrl:s,v:kd,eventId:r};if(e instanceof Zl){e.setDefaultLanguage(n.languageCode),a.providerId=e.providerId||"",MU(e.getCustomParameters())||(a.customParameters=JSON.stringify(e.getCustomParameters()));for(const[h,p]of Object.entries({}))a[h]=p}if(e instanceof yf){const h=e.getScopes().filter(p=>p!=="");h.length>0&&(a.scopes=h.join(","))}n.tenantId&&(a.tid=n.tenantId);const l=a;for(const h of Object.keys(l))l[h]===void 0&&delete l[h];const c=await n._getAppCheckToken(),d=c?`#${cH}=${encodeURIComponent(c)}`:"";return`${uH(n)}?${pf(l).slice(1)}${d}`}function uH({config:n}){return n.emulator?m4(n,lH):`https://${n.authDomain}/${oH}`}const ev="webStorageSupport";class dH{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=_4,this._completeRedirectFn=Pk,this._overrideRedirectResult=R$}async _openPopup(e,t,s,r){Hl(this.eventManagers[e._key()]?.manager,"_initialize() not called before _openPopup()");const i=await h8(e,t,s,Qp(),r);return iH(e,i,xx())}async _openRedirect(e,t,s,r){await this._originValidation(e);const i=await h8(e,t,s,Qp(),r);return t$(i),new Promise(()=>{})}_initialize(e){const t=e._key();if(this.eventManagers[t]){const{manager:r,promise:i}=this.eventManagers[t];return r?Promise.resolve(r):(Hl(i,"If manager is not set, promise should be"),i)}const s=this.initAndGetManager(e);return this.eventManagers[t]={promise:s},s.catch(()=>{delete this.eventManagers[t]}),s}async initAndGetManager(e){const t=await Z$(e),s=new M$(e);return t.register("authEvent",r=>(We(r?.authEvent,e,"invalid-auth-event"),{status:s.onEvent(r.authEvent)?"ACK":"ERROR"}),gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER),this.eventManagers[e._key()]={manager:s},this.iframes[e._key()]=t,s}_isIframeWebStorageSupported(e,t){this.iframes[e._key()].send(ev,{type:ev},r=>{const i=r?.[0]?.[ev];i!==void 0&&t(!!i),Ci(e,"internal-error")},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){const t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=z$(e)),this.originValidationPromises[t]}get _shouldInitProactively(){return $C()||MC()||g4()}}const Dk=dH;class jk{constructor(e){this.factorId=e}_process(e,t,s){switch(t.type){case"enroll":return this._finalizeEnroll(e,t.credential,s);case"signin":return this._finalizeSignIn(e,t.credential);default:return Uo("unexpected MultiFactorSessionType")}}}class P4 extends jk{constructor(e){super("phone"),this.credential=e}static _fromCredential(e){return new P4(e)}_finalizeEnroll(e,t,s){return Hz(e,{idToken:t,displayName:s,phoneVerificationInfo:this.credential._makeVerificationRequest()})}_finalizeSignIn(e,t){return u$(e,{mfaPendingCredential:t,phoneVerificationInfo:this.credential._makeVerificationRequest()})}}class Ok{constructor(){}static assertion(e){return P4._fromCredential(e)}}Ok.FACTOR_ID="phone";class Mk{static assertionForEnrollment(e,t){return Zp._fromSecret(e,t)}static assertionForSignIn(e,t){return Zp._fromEnrollmentId(e,t)}static async generateSecret(e){const t=e;We(typeof t.user?.auth<"u","internal-error");const s=await Wz(t.user.auth,{idToken:t.credential,totpEnrollmentInfo:{}});return bx._fromStartTotpMfaEnrollmentResponse(s,t.user.auth)}}Mk.FACTOR_ID="totp";class Zp extends jk{constructor(e,t,s){super("totp"),this.otp=e,this.enrollmentId=t,this.secret=s}static _fromSecret(e,t){return new Zp(t,void 0,e)}static _fromEnrollmentId(e,t){return new Zp(t,e)}async _finalizeEnroll(e,t,s){return We(typeof this.secret<"u",e,"argument-error"),Gz(e,{idToken:t,displayName:s,totpVerificationInfo:this.secret._makeTotpVerificationInfo(this.otp)})}async _finalizeSignIn(e,t){We(this.enrollmentId!==void 0&&this.otp!==void 0,e,"argument-error");const s={verificationCode:this.otp};return d$(e,{mfaPendingCredential:t,mfaEnrollmentId:this.enrollmentId,totpVerificationInfo:s})}}class bx{constructor(e,t,s,r,i,a,l){this.sessionInfo=a,this.auth=l,this.secretKey=e,this.hashingAlgorithm=t,this.co
9deLength=s,this.codeIntervalSeconds=r,this.enrollmentCompletionDeadline=i}static _fromStartTotpMfaEnrollmentResponse(e,t){return new bx(e.totpSessionInfo.sharedSecretKey,e.totpSessionInfo.hashingAlgorithm,e.totpSessionInfo.verificationCodeLength,e.totpSessionInfo.periodSec,new Date(e.totpSessionInfo.finalizeEnrollmentTime).toUTCString(),e.totpSessionInfo.sessionInfo,t)}_makeTotpVerificationInfo(e){return{sessionInfo:this.sessionInfo,verificationCode:e}}generateQrCodeUrl(e,t){let s=!1;return($g(e)||$g(t))&&(s=!0),s&&($g(e)&&(e=this.auth.currentUser?.email||"unknownuser"),$g(t)&&(t=this.auth.name)),`otpauth://totp/${t}:${e}?secret=${this.secretKey}&issuer=${t}&algorithm=${this.hashingAlgorithm}&digits=${this.codeLength}`}}function $g(n){return typeof n>"u"||n?.length===0}var f8="@firebase/auth",p8="1.13.3";class hH{constructor(e){this.auth=e,this.internalListeners=new Map}getUid(){return this.assertAuthConfigured(),this.auth.currentUser?.uid||null}async getToken(e){return this.assertAuthConfigured(),await this.auth._initializationPromise,this.auth.currentUser?{accessToken:await this.auth.currentUser.getIdToken(e)}:null}addAuthTokenListener(e){if(this.assertAuthConfigured(),this.internalListeners.has(e))return;const t=this.auth.onIdTokenChanged(s=>{e(s?.stsTokenManager.accessToken||null)});this.internalListeners.set(e,t),this.updateProactiveRefresh()}removeAuthTokenListener(e){this.assertAuthConfigured();const t=this.internalListeners.get(e);t&&(this.internalListeners.delete(e),t(),this.updateProactiveRefresh())}assertAuthConfigured(){We(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){this.internalListeners.size>0?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}}function fH(n){switch(n){case"Node":return"node";case"ReactNative":return"rn";case"Worker":return"webworker";case"Cordova":return"cordova";case"WebExtension":return"web-extension";default:return}}function pH(n){ho(new Ia("auth",(e,{options:t})=>{const s=e.getProvider("app").getImmediate(),r=e.getProvider("heartbeat"),i=e.getProvider("app-check-internal"),{apiKey:a,authDomain:l}=s.options;We(a&&!a.includes(":"),"invalid-api-key",{appName:s.name});const c={apiKey:a,authDomain:l,clientPlatform:n,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:HC(n)},d=new LB(s,r,i,c);return GB(d,t),d},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((e,t,s)=>{e.getProvider("auth-internal").initialize()})),ho(new Ia("auth-internal",e=>{const t=gs(e.getProvider("auth").getImmediate());return(s=>new hH(s))(t)},"PRIVATE").setInstantiationMode("EXPLICIT")),_i(f8,p8,fH(n)),_i(f8,p8,"esm2020")}const mH=300,gH=pC("authIdTokenMaxAge")||mH;let m8=null;const xH=n=>async e=>{const t=e&&await e.getIdTokenResult(),s=t&&(new Date().getTime()-Date.parse(t.issuedAtTime))/1e3;if(s&&s>gH)return;const r=t?.token;m8!==r&&(m8=r,await fetch(n,{method:r?"POST":"DELETE",headers:r?{Authorization:`Bearer ${r}`}:{}}))};function yd(n=Im()){const e=gu(n,"auth");if(e.isInitialized())return e.getImmediate();const t=KC(n,{popupRedirectResolver:Dk,persistence:[Ek,gk,_4]}),s=pC("authTokenSyncURL");if(s&&typeof isSecureContext=="boolean"&&isSecureContext){const i=new URL(s,location.origin);if(location.origin===i.origin){const a=xH(i.toString());dk(t,a,()=>a(t.currentUser)),uk(t,l=>a(l))}}const r=dC("auth");return r&&qC(t,`http://${r}`),t}function yH(){return document.getElementsByTagName("head")?.[0]??document}DB({loadJS(n){return new Promise((e,t)=>{const s=document.createElement("script");s.setAttribute("src",n),s.onload=e,s.onerror=r=>{const i=si("internal-error");i.customData=r,t(i)},s.type="text/javascript",s.charset="UTF-8",yH().appendChild(s)})},gapiScript:"https://apis.google.com/js/api.js",recaptchaV2Script:"https://www.google.com/recaptcha/api.js",recaptchaEnterpriseScript:"https://www.google.com/recaptcha/enterprise.js?render="});pH("Browser");const kb=Object.freeze(Object.defineProperty({__proto__:null,ActionCodeOperation:aB,ActionCodeURL:xf,AuthCredential:gf,AuthErrorCodes:cB,EmailAuthCredential:Kh,EmailAuthProvider:nl,FacebookAuthProvider:Rl,FactorId:nB,GithubAuthProvider:Pl,GoogleAuthProvider:Si,OAuthCredential:Yo,OAuthProvider:_p,OperationType:iB,PhoneAuthCredential:Wc,PhoneAuthProvider:sd,PhoneMultiFactorGenerator:Ok,ProviderId:sB,RecaptchaVerifier:x$,SAMLAuthProvider:r1,SignInMethod:rB,TotpMultiFactorGenerator:Mk,TotpSecret:bx,TwitterAuthProvider:Nl,applyActionCode:vz,beforeAuthStateChanged:dk,browserCookiePersistence:Jz,browserLocalPersistence:gk,browserPopupRedirectResolver:Dk,browserSessionPersistence:_4,checkActionCode:ik,confirmPasswordReset:yz,connectAuthEmulator:qC,createUserWithEmailAndPassword:ak,debugErrorMap:lB,deleteUser:fk,fetchSignInMethodsForEmail:_z,getAdditionalUserInfo:Oz,getAuth:yd,getIdToken:wB,getIdTokenResult:NC,getMultiFactorResolver:$z,getRedirectResult:Rk,inMemoryPersistence:Cb,indexedDBLocalPersistence:Ek,initializeAuth:KC,initializeRecaptchaConfig:Fz,isSignInWithEmailLink:Sz,linkWithCredential:sk,linkWithPhoneNumber:b$,linkWithPopup:Ik,linkWithRedirect:D$,multiFactor:qz,onAuthStateChanged:Rd,onIdTokenChanged:uk,parseActionCodeURL:hz,prodErrorMap:_C,reauthenticateWithCredential:px,reauthenticateWithPhoneNumber:w$,reauthenticateWithPopup:_k,reauthenticateWithRedirect:N$,reload:LC,revokeAccessToken:zz,sendEmailVerification:Iz,sendPasswordResetEmail:rk,sendSignInLinkToEmail:wz,setPersistence:Mz,signInAnonymously:mz,signInWithCredential:vf,signInWithCustomToken:xz,signInWithEmailAndPassword:ok,signInWithEmailLink:Ez,signInWithPhoneNumber:v$,signInWithPopup:k4,signInWithRedirect:kk,signOut:hk,unlink:ek,updateCurrentUser:Bz,updateEmail:kz,updatePassword:Rz,updatePhoneNumber:S$,updateProfile:S4,useDeviceLanguage:Vz,validatePassword:Uz,verifyBeforeUpdateEmail:Az,verifyPasswordResetCode:bz},Symbol.toStringTag,{value:"Module"}));var g8=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};var Gc,Fk;(function(){var n;function e(I,k){function P(){}P.prototype=k.prototype,I.F=k.prototype,I.prototype=new P,I.prototype.constructor=I,I.D=function(N,F,z){for(var U=Array(arguments.length-2),fe=2;fe<arguments.length;fe++)U[fe-2]=arguments[fe];return k.prototype[F].apply(N,U)}}function t(){this.blockSize=-1}function s(){this.blockSize=-1,this.blockSize=64,this.g=Array(4),this.C=Array(this.blockSize),this.o=this.h=0,this.u()}e(s,t),s.prototype.u=function(){this.g[0]=1732584193,this.g[1]=4023233417,this.g[2]=2562383102,this.g[3]=271733878,this.o=this.h=0};function r(I,k,P){P||(P=0);const N=Array(16);if(typeof k=="string")for(var F=0;F<16;
9++F)N[F]=k.charCodeAt(P++)|k.charCodeAt(P++)<<8|k.charCodeAt(P++)<<16|k.charCodeAt(P++)<<24;else for(F=0;F<16;++F)N[F]=k[P++]|k[P++]<<8|k[P++]<<16|k[P++]<<24;k=I.g[0],P=I.g[1],F=I.g[2];let z=I.g[3],U;U=k+(z^P&(F^z))+N[0]+3614090360&4294967295,k=P+(U<<7&4294967295|U>>>25),U=z+(F^k&(P^F))+N[1]+3905402710&4294967295,z=k+(U<<12&4294967295|U>>>20),U=F+(P^z&(k^P))+N[2]+606105819&4294967295,F=z+(U<<17&4294967295|U>>>15),U=P+(k^F&(z^k))+N[3]+3250441966&4294967295,P=F+(U<<22&4294967295|U>>>10),U=k+(z^P&(F^z))+N[4]+4118548399&4294967295,k=P+(U<<7&4294967295|U>>>25),U=z+(F^k&(P^F))+N[5]+1200080426&4294967295,z=k+(U<<12&4294967295|U>>>20),U=F+(P^z&(k^P))+N[6]+2821735955&4294967295,F=z+(U<<17&4294967295|U>>>15),U=P+(k^F&(z^k))+N[7]+4249261313&4294967295,P=F+(U<<22&4294967295|U>>>10),U=k+(z^P&(F^z))+N[8]+1770035416&4294967295,k=P+(U<<7&4294967295|U>>>25),U=z+(F^k&(P^F))+N[9]+2336552879&4294967295,z=k+(U<<12&4294967295|U>>>20),U=F+(P^z&(k^P))+N[10]+4294925233&4294967295,F=z+(U<<17&4294967295|U>>>15),U=P+(k^F&(z^k))+N[11]+2304563134&4294967295,P=F+(U<<22&4294967295|U>>>10),U=k+(z^P&(F^z))+N[12]+1804603682&4294967295,k=P+(U<<7&4294967295|U>>>25),U=z+(F^k&(P^F))+N[13]+4254626195&4294967295,z=k+(U<<12&4294967295|U>>>20),U=F+(P^z&(k^P))+N[14]+2792965006&4294967295,F=z+(U<<17&4294967295|U>>>15),U=P+(k^F&(z^k))+N[15]+1236535329&4294967295,P=F+(U<<22&4294967295|U>>>10),U=k+(F^z&(P^F))+N[1]+4129170786&4294967295,k=P+(U<<5&4294967295|U>>>27),U=z+(P^F&(k^P))+N[6]+3225465664&4294967295,z=k+(U<<9&4294967295|U>>>23),U=F+(k^P&(z^k))+N[11]+643717713&4294967295,F=z+(U<<14&4294967295|U>>>18),U=P+(z^k&(F^z))+N[0]+3921069994&4294967295,P=F+(U<<20&4294967295|U>>>12),U=k+(F^z&(P^F))+N[5]+3593408605&4294967295,k=P+(U<<5&4294967295|U>>>27),U=z+(P^F&(k^P))+N[10]+38016083&4294967295,z=k+(U<<9&4294967295|U>>>23),U=F+(k^P&(z^k))+N[15]+3634488961&4294967295,F=z+(U<<14&4294967295|U>>>18),U=P+(z^k&(F^z))+N[4]+3889429448&4294967295,P=F+(U<<20&4294967295|U>>>12),U=k+(F^z&(P^F))+N[9]+568446438&4294967295,k=P+(U<<5&4294967295|U>>>27),U=z+(P^F&(k^P))+N[14]+3275163606&4294967295,z=k+(U<<9&4294967295|U>>>23),U=F+(k^P&(z^k))+N[3]+4107603335&4294967295,F=z+(U<<14&4294967295|U>>>18),U=P+(z^k&(F^z))+N[8]+1163531501&4294967295,P=F+(U<<20&4294967295|U>>>12),U=k+(F^z&(P^F))+N[13]+2850285829&4294967295,k=P+(U<<5&4294967295|U>>>27),U=z+(P^F&(k^P))+N[2]+4243563512&4294967295,z=k+(U<<9&4294967295|U>>>23),U=F+(k^P&(z^k))+N[7]+1735328473&4294967295,F=z+(U<<14&4294967295|U>>>18),U=P+(z^k&(F^z))+N[12]+2368359562&4294967295,P=F+(U<<20&4294967295|U>>>12),U=k+(P^F^z)+N[5]+4294588738&4294967295,k=P+(U<<4&4294967295|U>>>28),U=z+(k^P^F)+N[8]+2272392833&4294967295,z=k+(U<<11&4294967295|U>>>21),U=F+(z^k^P)+N[11]+1839030562&4294967295,F=z+(U<<16&4294967295|U>>>16),U=P+(F^z^k)+N[14]+4259657740&4294967295,P=F+(U<<23&4294967295|U>>>9),U=k+(P^F^z)+N[1]+2763975236&4294967295,k=P+(U<<4&4294967295|U>>>28),U=z+(k^P^F)+N[4]+1272893353&4294967295,z=k+(U<<11&4294967295|U>>>21),U=F+(z^k^P)+N[7]+4139469664&4294967295,F=z+(U<<16&4294967295|U>>>16),U=P+(F^z^k)+N[10]+3200236656&4294967295,P=F+(U<<23&4294967295|U>>>9),U=k+(P^F^z)+N[13]+681279174&4294967295,k=P+(U<<4&4294967295|U>>>28),U=z+(k^P^F)+N[0]+3936430074&4294967295,z=k+(U<<11&4294967295|U>>>21),U=F+(z^k^P)+N[3]+3572445317&4294967295,F=z+(U<<16&4294967295|U>>>16),U=P+(F^z^k)+N[6]+76029189&4294967295,P=F+(U<<23&4294967295|U>>>9),U=k+(P^F^z)+N[9]+3654602809&4294967295,k=P+(U<<4&4294967295|U>>>28),U=z+(k^P^F)+N[12]+3873151461&4294967295,z=k+(U<<11&4294967295|U>>>21),U=F+(z^k^P)+N[15]+530742520&4294967295,F=z+(U<<16&4294967295|U>>>16),U=P+(F^z^k)+N[2]+3299628645&4294967295,P=F+(U<<23&4294967295|U>>>9),U=k+(F^(P|~z))+N[0]+4096336452&4294967295,k=P+(U<<6&4294967295|U>>>26),U=z+(P^(k|~F))+N[7]+1126891415&4294967295,z=k+(U<<10&4294967295|U>>>22),U=F+(k^(z|~P))+N[14]+2878612391&4294967295,F=z+(U<<15&4294967295|U>>>17),U=P+(z^(F|~k))+N[5]+4237533241&4294967295,P=F+(U<<21&4294967295|U>>>11),U=k+(F^(P|~z))+N[12]+1700485571&4294967295,k=P+(U<<6&4294967295|U>>>26),U=z+(P^(k|~F))+N[3]+2399980690&4294967295,z=k+(U<<10&4294967295|U>>>22),U=F+(k^(z|~P))+N[10]+4293915773&4294967295,F=z+(U<<15&4294967295|U>>>17),U=P+(z^(F|~k))+N[1]+2240044497&4294967295,P=F+(U<<21&4294967295|U>>>11),U=k+(F^(P|~z))+N[8]+1873313359&4294967295,k=P+(U<<6&4294967295|U>>>26),U=z+(P^(k|~F))+N[15]+4264355552&4294967295,z=k+(U<<10&4294967295|U>>>22),U=F+(k^(z|~P))+N[6]+2734768916&4294967295,F=z+(U<<15&4294967295|U>>>17),U=P+(z^(F|~k))+N[13]+1309151649&4294967295,P=F+(U<<21&4294967295|U>>>11),U=k+(F^(P|~z))+N[4]+4149444226&4294967295,k=P+(U<<6&4294967295|U>>>26),U=z+(P^(k|~F))+N[11]+3174756917&4294967295,z=k+(U<<10&4294967295|U>>>22),U=F+(k^(z|~P))+N[2]+718787259&4294967295,F=z+(U<<15&4294967295|U>>>17),U=P+(z^(F|~k))+N[9]+3951481745&4294967295,I.g[0]=I.g[0]+k&4294967295,I.g[1]=I.g[1]+(F+(U<<21&4294967295|U>>>11))&4294967295,I.g[2]=I.g[2]+F&4294967295,I.g[3]=I.g[3]+z&4294967295}s.prototype.v=function(I,k){k===void 0&&(k=I.length);const P=k-this.blockSize,N=this.C;let F=this.h,z=0;for(;z<k;){if(F==0)for(;z<=P;)r(this,I,z),z+=this.blockSize;
9if(typeof I=="string"){for(;z<k;)if(N[F++]=I.charCodeAt(z++),F==this.blockSize){r(this,N),F=0;break}}else for(;z<k;)if(N[F++]=I[z++],F==this.blockSize){r(this,N),F=0;break}}this.h=F,this.o+=k},s.prototype.A=function(){var I=Array((this.h<56?this.blockSize:this.blockSize*2)-this.h);I[0]=128;for(var k=1;k<I.length-8;++k)I[k]=0;k=this.o*8;for(var P=I.length-8;P<I.length;++P)I[P]=k&255,k/=256;for(this.v(I),I=Array(16),k=0,P=0;P<4;++P)for(let N=0;N<32;N+=8)I[k++]=this.g[P]>>>N&255;return I};function i(I,k){var P=l;return Object.prototype.hasOwnProperty.call(P,I)?P[I]:P[I]=k(I)}function a(I,k){this.h=k;const P=[];let N=!0;for(let F=I.length-1;F>=0;F--){const z=I[F]|0;N&&z==k||(P[F]=z,N=!1)}this.g=P}var l={};function c(I){return-128<=I&&I<128?i(I,function(k){return new a([k|0],k<0?-1:0)}):new a([I|0],I<0?-1:0)}function d(I){if(isNaN(I)||!isFinite(I))return p;if(I<0)return S(d(-I));const k=[];let P=1;for(let N=0;I>=P;N++)k[N]=I/P|0,P*=4294967296;return new a(k,0)}function h(I,k){if(I.length==0)throw Error("number format error: empty string");if(k=k||10,k<2||36<k)throw Error("radix out of range: "+k);if(I.charAt(0)=="-")return S(h(I.substring(1),k));if(I.indexOf("-")>=0)throw Error('number format error: interior "-" character');const P=d(Math.pow(k,8));let N=p;for(let z=0;z<I.length;z+=8){var F=Math.min(8,I.length-z);const U=parseInt(I.substring(z,z+F),k);F<8?(F=d(Math.pow(k,F)),N=N.j(F).add(d(U))):(N=N.j(P),N=N.add(d(U)))}return N}var p=c(0),m=c(1),y=c(16777216);n=a.prototype,n.m=function(){if(w(this))return-S(this).m();let I=0,k=1;for(let P=0;P<this.g.length;P++){const N=this.i(P);I+=(N>=0?N:4294967296+N)*k,k*=4294967296}return I},n.toString=function(I){if(I=I||10,I<2||36<I)throw Error("radix out of range: "+I);if(x(this))return"0";if(w(this))return"-"+S(this).toString(I);const k=d(Math.pow(I,6));var P=this;let N="";for(;;){const F=M(P,k).g;P=_(P,F.j(k));let z=((P.g.length>0?P.g[0]:P.h)>>>0).toString(I);if(P=F,x(P))return z+N;for(;z.length<6;)z="0"+z;N=z+N}},n.i=function(I){return I<0?0:I<this.g.length?this.g[I]:this.h};function x(I){if(I.h!=0)return!1;for(let k=0;k<I.g.length;k++)if(I.g[k]!=0)return!1;return!0}function w(I){return I.h==-1}n.l=function(I){return I=_(this,I),w(I)?-1:x(I)?0:1};function S(I){const k=I.g.length,P=[];for(let N=0;N<k;N++)P[N]=~I.g[N];return new a(P,~I.h).add(m)}n.abs=function(){return w(this)?S(this):this},n.add=function(I){const k=Math.max(this.g.length,I.g.length),P=[];let N=0;for(let F=0;F<=k;F++){let z=N+(this.i(F)&65535)+(I.i(F)&65535),U=(z>>>16)+(this.i(F)>>>16)+(I.i(F)>>>16);N=U>>>16,z&=65535,U&=65535,P[F]=U<<16|z}return new a(P,P[P.length-1]&-2147483648?-1:0)};function _(I,k){return I.add(S(k))}n.j=function(I){if(x(this)||x(I))return p;if(w(this))return w(I)?S(this).j(S(I)):S(S(this).j(I));if(w(I))return S(this.j(S(I)));if(this.l(y)<0&&I.l(y)<0)return d(this.m()*I.m());const k=this.g.length+I.g.length,P=[];for(var N=0;N<2*k;N++)P[N]=0;for(N=0;N<this.g.length;N++)for(let F=0;F<I.g.length;F++){const z=this.i(N)>>>16,U=this.i(N)&65535,fe=I.i(F)>>>16,oe=I.i(F)&65535;P[2*N+2*F]+=U*oe,L(P,2*N+2*F),P[2*N+2*F+1]+=z*oe,L(P,2*N+2*F+1),P[2*N+2*F+1]+=U*fe,L(P,2*N+2*F+1),P[2*N+2*F+2]+=z*fe,L(P,2*N+2*F+2)}for(I=0;I<k;I++)P[I]=P[2*I+1]<<16|P[2*I];for(I=k;I<2*k;I++)P[I]=0;return new a(P,0)};function L(I,k){for(;(I[k]&65535)!=I[k];)I[k+1]+=I[k]>>>16,I[k]&=65535,k++}function R(I,k){this.g=I,this.h=k}function M(I,k){if(x(k))throw Error("division by zero");if(x(I))return new R(p,p);if(w(I))return k=M(S(I),k),new R(S(k.g),S(k.h));if(w(k))return k=M(I,S(k)),new R(S(k.g),k.h);if(I.g.length>30){if(w(I)||w(k))throw Error("slowDivide_ only works with positive integers.");for(var P=m,N=k;N.l(I)<=0;)P=V(P),N=V(N);var F=W(P,1),z=W(N,1);for(N=W(N,2),P=W(P,2);!x(N);){var U=z.add(N);U.l(I)<=0&&(F=F.add(P),z=U),N=W(N,1),P=W(P,1)}return k=_(I,F.j(k)),new R(F,k)}for(F=p;I.l(k)>=0;
9){for(P=Math.max(1,Math.floor(I.m()/k.m())),N=Math.ceil(Math.log(P)/Math.LN2),N=N<=48?1:Math.pow(2,N-48),z=d(P),U=z.j(k);w(U)||U.l(I)>0;)P-=N,z=d(P),U=z.j(k);x(z)&&(z=m),F=F.add(z),I=_(I,U)}return new R(F,I)}n.B=function(I){return M(this,I).h},n.and=function(I){const k=Math.max(this.g.length,I.g.length),P=[];for(let N=0;N<k;N++)P[N]=this.i(N)&I.i(N);return new a(P,this.h&I.h)},n.or=function(I){const k=Math.max(this.g.length,I.g.length),P=[];for(let N=0;N<k;N++)P[N]=this.i(N)|I.i(N);return new a(P,this.h|I.h)},n.xor=function(I){const k=Math.max(this.g.length,I.g.length),P=[];for(let N=0;N<k;N++)P[N]=this.i(N)^I.i(N);return new a(P,this.h^I.h)};function V(I){const k=I.g.length+1,P=[];for(let N=0;N<k;N++)P[N]=I.i(N)<<1|I.i(N-1)>>>31;return new a(P,I.h)}function W(I,k){const P=k>>5;k%=32;const N=I.g.length-P,F=[];for(let z=0;z<N;z++)F[z]=k>0?I.i(z+P)>>>k|I.i(z+P+1)<<32-k:I.i(z+P);return new a(F,I.h)}s.prototype.digest=s.prototype.A,s.prototype.reset=s.prototype.u,s.prototype.update=s.prototype.v,Fk=s,a.prototype.add=a.prototype.add,a.prototype.multiply=a.prototype.j,a.prototype.modulo=a.prototype.B,a.prototype.compare=a.prototype.l,a.prototype.toNumber=a.prototype.m,a.prototype.toString=a.prototype.toString,a.prototype.getBits=a.prototype.i,a.fromNumber=d,a.fromString=h,Gc=a}).apply(typeof g8<"u"?g8:typeof self<"u"?self:typeof window<"u"?window:{});var Hg=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};var Uk,xp,Vk,_0,Rb,Bk,zk,$k;(function(){var n,e=Object.defineProperty;function t(v){v=[typeof globalThis=="object"&&globalThis,v,typeof window=="object"&&window,typeof self=="object"&&self,typeof Hg=="object"&&Hg];for(var A=0;A<v.length;++A){var O=v[A];if(O&&O.Math==Math)return O}throw Error("Cannot find global object")}var s=t(this);function r(v,A){if(A)e:{var O=s;v=v.split(".");for(var $=0;$<v.length-1;$++){var ue=v[$];if(!(ue in O))break e;O=O[ue]}v=v[v.length-1],$=O[v],A=A($),A!=$&&A!=null&&e(O,v,{configurable:!0,writable:!0,value:A})}}r("Symbol.dispose",function(v){return v||Symbol("Symbol.dispose")}),r("Array.prototype.values",function(v){return v||function(){return this[Symbol.iterator]()}}),r("Object.entries",function(v){return v||function(A){var O=[],$;for($ in A)Object.prototype.hasOwnProperty.call(A,$)&&O.push([$,A[$]]);return O}});var i=i||{},a=this||self;function l(v){var A=typeof v;return A=="object"&&v!=null||A=="function"}function c(v,A,O){return v.call.apply(v.bind,arguments)}function d(v,A,O){return d=c,d.apply(null,arguments)}function h(v,A){var O=Array.prototype.slice.call(arguments,1);return function(){var $=O.slice();return $.push.apply($,arguments),v.apply(this,$)}}function p(v,A){function O(){}O.prototype=A.prototype,v.Z=A.prototype,v.prototype=new O,v.prototype.constructor=v,v.Ob=function($,ue,we){for(var Ke=Array(arguments.length-2),Ft=2;Ft<arguments.length;
9Ft++)Ke[Ft-2]=arguments[Ft];return A.prototype[ue].apply($,Ke)}}var m=typeof AsyncContext<"u"&&typeof AsyncContext.Snapshot=="function"?v=>v&&AsyncContext.Snapshot.wrap(v):v=>v;function y(v){const A=v.length;if(A>0){const O=Array(A);for(let $=0;$<A;$++)O[$]=v[$];return O}return[]}function x(v,A){for(let $=1;$<arguments.length;$++){const ue=arguments[$];var O=typeof ue;if(O=O!="object"?O:ue?Array.isArray(ue)?"array":O:"null",O=="array"||O=="object"&&typeof ue.length=="number"){O=v.length||0;const we=ue.length||0;v.length=O+we;for(let Ke=0;Ke<we;Ke++)v[O+Ke]=ue[Ke]}else v.push(ue)}}class w{constructor(A,O){this.i=A,this.j=O,this.h=0,this.g=null}get(){let A;return this.h>0?(this.h--,A=this.g,this.g=A.next,A.next=null):A=this.i(),A}}function S(v){a.setTimeout(()=>{throw v},0)}function _(){var v=I;let A=null;return v.g&&(A=v.g,v.g=v.g.next,v.g||(v.h=null),A.next=null),A}class L{constructor(){this.h=this.g=null}add(A,O){const $=R.get();$.set(A,O),this.h?this.h.next=$:this.g=$,this.h=$}}var R=new w(()=>new M,v=>v.reset());class M{constructor(){this.next=this.g=this.h=null}set(A,O){this.h=A,this.g=O,this.next=null}reset(){this.next=this.g=this.h=null}}let V,W=!1,I=new L,k=()=>{const v=Promise.resolve(void 0);V=()=>{v.then(P)}};function P(){for(var v;v=_();){try{v.h.call(v.g)}catch(O){S(O)}var A=R;A.j(v),A.h<100&&(A.h++,v.next=A.g,A.g=v)}W=!1}function N(){this.u=this.u,this.C=this.C}N.prototype.u=!1,N.prototype.dispose=function(){this.u||(this.u=!0,this.N())},N.prototype[Symbol.dispose]=function(){this.dispose()},N.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()};function F(v,A){this.type=v,this.g=this.target=A,this.defaultPrevented=!1}F.prototype.h=function(){this.defaultPrevented=!0};var z=(function(){if(!a.addEventListener||!Object.defineProperty)return!1;var v=!1,A=Object.defineProperty({},"passive",{get:function(){v=!0}});try{const O=()=>{};a.addEventListener("test",O,A),a.removeEventListener("test",O,A)}catch{}return v})();function U(v){return/^[\s\xa0]*$/.test(v)}function fe(v,A){F.call(this,v?v.type:""),this.relatedTarget=this.g=this.target=null,this.button=this.screenY=this.screenX=this.clientY=this.clientX=0,this.key="",this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1,this.state=null,this.pointerId=0,this.pointerType="",this.i=null,v&&this.init(v,A)}p(fe,F),fe.prototype.init=function(v,A){const O=this.type=v.type,$=v.changedTouches&&v.changedTouches.length?v.changedTouches[0]:null;this.target=v.target||v.srcElement,this.g=A,A=v.relatedTarget,A||(O=="mouseover"?A=v.fromElement:O=="mouseout"&&(A=v.toElement)),this.relatedTarget=A,$?(this.clientX=$.clientX!==void 0?$.clientX:$.pageX,this.clientY=$.clientY!==void 0?$.clientY:$.pageY,this.screenX=$.screenX||0,this.screenY=$.screenY||0):(this.clientX=v.clientX!==void 0?v.clientX:v.pageX,this.clientY=v.clientY!==void 0?v.clientY:v.pageY,this.screenX=v.screenX||0,this.screenY=v.screenY||0),this.button=v.button,this.key=v.key||"",this.ctrlKey=v.ctrlKey,this.altKey=v.altKey,this.shiftKey=v.shiftKey,this.metaKey=v.metaKey,this.pointerId=v.pointerId||0,this.pointerType=v.pointerType,this.state=v.state,this.i=v,v.defaultPrevented&&fe.Z.h.call(this)},fe.prototype.h=function(){fe.Z.h.call(this);const v=this.i;v.preventDefault?v.preventDefault():v.returnValue=!1};var oe="closure_listenable_"+(Math.random()*1e6|0),X=0;function Q(v,A,O,$,ue){this.listener=v,this.proxy=null,this.src=A,this.type=O,this.capture=!!$,this.ha=ue,this.key=++X,this.da=this.fa=!1}function G(v){v.da=!0,v.listener=null,v.proxy=null,v.src=null,v.ha=null}function Y(v,A,O){for(const $ in v)A.call(O,v[$],$,v)}function ee(v,A){for(const O in v)A.call(void 0,v[O],O,v)}function H(v){const A={};for(const O in v)A[O]=v[O];return A}const K="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function pe(v,A){let O,$;for(let ue=1;ue<arguments.length;ue++){$=arguments[ue];for(O in $)v[O]=$[O];for(let we=0;we<K.length;we++)O=K[we],Object.prototype.hasOwnProperty.call($,O)&&(v[O]=$[O])}}function Fe(v){this.src=v,this.g={},this.h=0}Fe.prototype.add=function(v,A,O,$,ue){const we=v.toString();v=this.g[we],v||(v=this.g[we]=[],this.h++);const Ke=ze(v,A,$,ue);return Ke>-1?(A=v[Ke],O||(A.fa=!1)):(A=new Q(A,this.src,we,!!$,ue),A.fa=O,v.push(A)),A};function _e(v,A){const O=A.type;if(O in v.g){var $=v.g[O],ue=Array.prototype.indexOf.call($,A,void 0),we;(we=ue>=0)&&Array.prototype.splice.call($,ue,1),we&&(G(A),v.g[O].length==0&&(delete v.g[O],v.h--))}}function ze(v,A,O,$){for(let ue=0;ue<v.length;++ue){const we=v[ue];if(!we.da&&we.listener==A&&we.capture==!!O&&we.ha==$)return ue}return-1}var Ye="closure_lm_"+(Math.random()*1e6|0),tt={};function lt(v,A,O,$,ue){if(Array.isArray(A)){for(let we=0;we<A.length;we++)lt(v,A[we],O,$,ue);return null}return O=Nt(O),v&&v[oe]?v.J(A,O,l($)?!!$.capture:!1,ue):ut(v,A,O,!1,$,ue)}function ut(v,A,O,$,ue,we){if(!A)throw Error("Invalid event type");const Ke=l(ue)?!!ue.capture:!!ue;let Ft=at(v);
9if(Ft||(v[Ye]=Ft=new Fe(v)),O=Ft.add(A,O,$,Ke,we),O.proxy)return O;if($=cn(),O.proxy=$,$.src=v,$.listener=O,v.addEventListener)z||(ue=Ke),ue===void 0&&(ue=!1),v.addEventListener(A.toString(),$,ue);else if(v.attachEvent)v.attachEvent(rt(A.toString()),$);else if(v.addListener&&v.removeListener)v.addListener($);else throw Error("addEventListener and attachEvent are unavailable.");return O}function cn(){function v(O){return A.call(v.src,v.listener,O)}const A=Ct;return v}function ke(v,A,O,$,ue){if(Array.isArray(A))for(var we=0;we<A.length;we++)ke(v,A[we],O,$,ue);else $=l($)?!!$.capture:!!$,O=Nt(O),v&&v[oe]?(v=v.i,we=String(A).toString(),we in v.g&&(A=v.g[we],O=ze(A,O,$,ue),O>-1&&(G(A[O]),Array.prototype.splice.call(A,O,1),A.length==0&&(delete v.g[we],v.h--)))):v&&(v=at(v))&&(A=v.g[A.toString()],v=-1,A&&(v=ze(A,O,$,ue)),(O=v>-1?A[v]:null)&&Ue(O))}function Ue(v){if(typeof v!="number"&&v&&!v.da){var A=v.src;if(A&&A[oe])_e(A.i,v);else{var O=v.type,$=v.proxy;A.removeEventListener?A.removeEventListener(O,$,v.capture):A.detachEvent?A.detachEvent(rt(O),$):A.addListener&&A.removeListener&&A.removeListener($),(O=at(A))?(_e(O,v),O.h==0&&(O.src=null,A[Ye]=null)):G(v)}}}function rt(v){return v in tt?tt[v]:tt[v]="on"+v}function Ct(v,A){if(v.da)v=!0;else{A=new fe(A,this);const O=v.listener,$=v.ha||v.src;v.fa&&Ue(v),v=O.call($,A)}return v}function at(v){return v=v[Ye],v instanceof Fe?v:null}var ft="__closure_events_fn_"+(Math.random()*1e9>>>0);function Nt(v){return typeof v=="function"?v:(v[ft]||(v[ft]=function(A){return v.handleEvent(A)}),v[ft])}function At(){N.call(this),this.i=new Fe(this),this.M=this,this.G=null}p(At,N),At.prototype[oe]=!0,At.prototype.removeEventListener=function(v,A,O,$){ke(this,v,A,O,$)};function ot(v,A){var O,$=v.G;if($)for(O=[];$;$=$.G)O.push($);if(v=v.M,$=A.type||A,typeof A=="string")A=new F(A,v);else if(A instanceof F)A.target=A.target||v;else{var ue=A;A=new F($,v),pe(A,ue)}ue=!0;let we,Ke;if(O)for(Ke=O.length-1;Ke>=0;Ke--)we=A.g=O[Ke],ue=Yt(we,$,!0,A)&&ue;if(we=A.g=v,ue=Yt(we,$,!0,A)&&ue,ue=Yt(we,$,!1,A)&&ue,O)for(Ke=0;Ke<O.length;Ke++)we=A.g=O[Ke],ue=Yt(we,$,!1,A)&&ue}At.prototype.N=function(){if(At.Z.N.call(this),this.i){var v=this.i;for(const A in v.g){const O=v.g[A];for(let $=0;$<O.length;$++)G(O[$]);delete v.g[A],v.h--}}this.G=null},At.prototype.J=function(v,A,O,$){return this.i.add(String(v),A,!1,O,$)},At.prototype.K=function(v,A,O,$){return this.i.add(String(v),A,!0,O,$)};function Yt(v,A,O,$){if(A=v.i.g[String(A)],!A)return!0;A=A.concat();let ue=!0;for(let we=0;we<A.length;++we){const Ke=A[we];if(Ke&&!Ke.da&&Ke.capture==O){const Ft=Ke.listener,pn=Ke.ha||Ke.src;Ke.fa&&_e(v.i,Ke),ue=Ft.call(pn,$)!==!1&&ue}}return ue&&!$.defaultPrevented}function zt(v,A){if(typeof v!="function")if(v&&typeof v.handleEvent=="function")v=d(v.handleEvent,v);else throw Error("Invalid listener argument");return Number(A)>2147483647?-1:a.setTimeout(v,A||0)}function wn(v){v.g=zt(()=>{v.g=null,v.i&&(v.i=!1,wn(v))},v.l);const A=v.h;v.h=null,v.m.apply(null,A)}class Dt extends N{constructor(A,O){super(),this.m=A,this.l=O,this.h=null,this.i=!1,this.g=null}j(A){this.h=arguments,this.g?this.i=!0:wn(this)}N(){super.N(),this.g&&(a.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function Ee(v){N.call(this),this.h=v,this.g={}}p(Ee,N);var He=[];function le(v){Y(v.g,function(A,O){this.g.hasOwnProperty(O)&&Ue(A)},v),v.g={}}Ee.prototype.N=function(){Ee.Z.N.call(this),le(this)},Ee.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var ne=a.JSON.stringify,J=a.JSON.parse,De=class{stringify(v){return a.JSON.stringify(v,void 0)}parse(v){return a.JSON.parse(v,void 0)}};function Le(){}function Lt(){}var Qe={OPEN:"a",hb:"b",ERROR:"c",tb:"d"};function it(){F.call(this,"d")}p(it,F);function Cn(){F.call(this,"c")}p(Cn,F);var Mn={},Gn=null;function ii(){return Gn=Gn||new At}Mn.Ia="serverreachability";function ai(v){F.call(this,Mn.Ia,v)}p(ai,F);function Fs(v){const A=ii();ot(A,new ai(A))}Mn.STAT_EVENT="statevent";function os(v,A){F.call(this,Mn.STAT_EVENT,v),this.stat=A}p(os,F);function vn(v){const A=ii();ot(A,new os(A,v))}Mn.Ja="timingevent";function ln(v,A){F.call(this,Mn.Ja,v),this.size=A}p(ln,F);function Qs(v,A){if(typeof v!="function")throw Error("Fn must not be null and must be a function");return a.setTimeout(function(){v()},A)}function Tr(){this.g=!0}Tr.prototype.ua=function(){this.g=!1};function hr(v,A,O,$,ue,we){v.info(function(){if(v.g)if(we){var Ke="",Ft=we.split("&");for(let ye=0;ye<Ft.length;ye++){var pn=Ft[ye].split("=");if(pn.length>1){const qn=pn[0];pn=pn[1];const sr=qn.split("_");Ke=sr.length>=2&&sr[1]=="type"?Ke+(qn+"="+pn+"&"):Ke+(qn+"=redacted&")}}}else Ke=null;else Ke=we;return"XMLHTTP REQ ("+$+") [attempt "+ue+"]: "+A+` 10`+O+` 11`+Ke})}function Na(v,A,O,$,ue,we,Ke){v.info(function(){return"XMLHTTP RESP ("+$+") [ attempt "+ue+"]: "+A+` 12`+O+` 13`+we+" "+Ke})}function Xs(v,A,O,$){v.info(function(){return"XMLHTTP TEXT ("+A+"): "+_r(v,O)+($?" "+$:"")})}function oi(v,A){v.info(function(){return"TIMEOUT: "+A})}Tr.prototype.info=function(){};function _r(v,A){if(!v.g)return A;if(!A)return null;try{const we=JSON.parse(A);if(we){for(v=0;v<we.length;v++)if(Array.isArray(we[v])){var O=we[v];
13if(!(O.length<2)){var $=O[1];if(Array.isArray($)&&!($.length<1)){var ue=$[0];if(ue!="noop"&&ue!="stop"&&ue!="close")for(let Ke=1;Ke<$.length;Ke++)$[Ke]=""}}}}return ne(we)}catch{return A}}var es={NO_ERROR:0,cb:1,qb:2,pb:3,kb:4,ob:5,rb:6,Ga:7,TIMEOUT:8,ub:9},Ir={ib:"complete",Fb:"success",ERROR:"error",Ga:"abort",xb:"ready",yb:"readystatechange",TIMEOUT:"timeout",sb:"incrementaldata",wb:"progress",lb:"downloadprogress",Nb:"uploadprogress"},Ar;function Re(){}p(Re,Le),Re.prototype.g=function(){return new XMLHttpRequest},Ar=new Re;function St(v){return encodeURIComponent(String(v))}function Un(v){var A=1;v=v.split(":");const O=[];for(;A>0&&v.length;)O.push(v.shift()),A--;return v.length&&O.push(v.join(":")),O}function Vn(v,A,O,$){this.j=v,this.i=A,this.l=O,this.S=$||1,this.V=new Ee(this),this.H=45e3,this.J=null,this.o=!1,this.u=this.B=this.A=this.M=this.F=this.T=this.D=null,this.G=[],this.g=null,this.C=0,this.m=this.v=null,this.X=-1,this.K=!1,this.P=0,this.O=null,this.W=this.L=this.U=this.R=!1,this.h=new La}function La(){this.i=null,this.g="",this.h=!1}var Br={},Da={};function Rn(v,A,O){v.M=1,v.A=aa(Cr(A)),v.u=O,v.R=!0,Te(v,null)}function Te(v,A){v.F=Date.now(),zr(v),v.B=Cr(v.A);var O=v.B,$=v.S;Array.isArray($)||($=[String($)]),Su(O.i,"t",$),v.C=0,O=v.j.L,v.h=new La,v.g=Ud(v.j,O?A:null,!v.u),v.P>0&&(v.O=new Dt(d(v.Y,v,v.g),v.P)),A=v.V,O=v.g,$=v.ba;var ue="readystatechange";Array.isArray(ue)||(ue&&(He[0]=ue.toString()),ue=He);for(let we=0;we<ue.length;we++){const Ke=lt(O,ue[we],$||A.handleEvent,!1,A.h||A);if(!Ke)break;A.g[Ke.key]=Ke}A=v.J?H(v.J):{},v.u?(v.v||(v.v="POST"),A["Content-Type"]="application/x-www-form-urlencoded",v.g.ea(v.B,v.v,v.u,A)):(v.v="GET",v.g.ea(v.B,v.v,null,A)),Fs(),hr(v.i,v.v,v.B,v.l,v.S,v.u)}Vn.prototype.ba=function(v){v=v.target;const A=this.O;A&&tr(v)==3?A.j():this.Y(v)},Vn.prototype.Y=function(v){try{if(v==this.g)e:{const Ft=tr(this.g),pn=this.g.ya(),ye=this.g.ca();if(!(Ft<3)&&(Ft!=3||this.g&&(this.h.h||this.g.la()||ua(this.g)))){this.K||Ft!=4||pn==7||(pn==8||ye<=0?Fs(3):Fs(2)),ia(this);var A=this.g.ca();this.X=A;var O=pt(this);if(this.o=A==200,Na(this.i,this.v,this.B,this.l,this.S,Ft,A),this.o){if(this.U&&!this.L){t:{if(this.g){var $,ue=this.g;if(($=ue.g?ue.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!U($)){var we=$;break t}}we=null}if(v=we)Xs(this.i,this.l,v,"Initial handshake response via X-HTTP-Initial-Response"),this.L=!0,xn(this,v);else{this.o=!1,this.m=3,vn(12),Li(this),rl(this);break e}}if(this.R){v=!0;let qn;for(;!this.K&&this.C<O.length;)if(qn=fr(this,O),qn==Da){Ft==4&&(this.m=4,vn(14),v=!1),Xs(this.i,this.l,null,"[Incomplete Response]");break}else if(qn==Br){this.m=4,vn(15),Xs(this.i,this.l,O,"[Invalid Chunk]"),v=!1;break}else Xs(this.i,this.l,qn,null),xn(this,qn);if(ys(this)&&this.C!=0&&(this.h.g=this.h.g.slice(this.C),this.C=0),Ft!=4||O.length!=0||this.h.h||(this.m=1,vn(16),v=!1),this.o=this.o&&v,!v)Xs(this.i,this.l,O,"[Invalid Chunked Response]"),Li(this),rl(this);else if(O.length>0&&!this.W){this.W=!0;var Ke=this.j;Ke.g==this&&Ke.aa&&!Ke.P&&(Ke.j.info("Great, no buffering proxy detected. Bytes received: "+O.length),cl(Ke),Ke.P=!0,vn(11))}}else Xs(this.i,this.l,O,null),xn(this,O);Ft==4&&Li(this),this.o&&!this.K&&(Ft==4?di(this.j,this):(this.o=!1,zr(this)))}else ll(this.g),A==400&&O.indexOf("Unknown SID")>0?(this.m=3,vn(12)):(this.m=0,vn(13)),Li(this),rl(this)}}}catch{}};function pt(v){if(!ys(v))return v.g.la();const A=ua(v.g);if(A==="")return"";let O="";const $=A.length,ue=tr(v.g)==4;if(!v.h.i){if(typeof TextDecoder>"u")return Li(v),rl(v),"";v.h.i=new a.TextDecoder}for(let we=0;we<$;we++)v.h.h=!0,O+=v.h.i.decode(A[we],{stream:!(ue&&we==$-1)});return A.length=0,v.h.g+=O,v.C=0,v.h.g}function ys(v){return v.g?v.v=="GET"&&v.M!=2&&v.j.Aa:!1}function fr(v,A){var O=v.C,$=A.indexOf(` 14`,O);return $==-1?Da:(O=Number(A.substring(O,$)),isNaN(O)?Br:($+=1,$+O>A.length?Da:(A=A.slice($,$+O),v.C=$+O,A)))}Vn.prototype.cancel=function(){this.K=!0,Li(this)};function zr(v){v.T=Date.now()+v.H,ja(v,v.H)}function ja(v,A){if(v.D!=null)throw Error("WatchDog timer not null");v.D=Qs(d(v.aa,v),A)}function ia(v){v.D&&(a.clearTimeout(v.D),v.D=null)}Vn.prototype.aa=function(){this.D=null;const v=Date.now();v-this.T>=0?(oi(this.i,this.B),this.M!=2&&(Fs(),vn(17)),Li(this),this.m=2,rl(this)):ja(this,this.T-v)};function rl(v){v.j.I==0||v.K||di(v.j,v)}function Li(v){ia(v);var A=v.O;A&&typeof A.dispose=="function"&&A.dispose(),v.O=null,le(v.V),v.g&&(A=v.g,v.g=null,A.abort(),A.dispose())}function xn(v,A){try{var O=v.j;if(O.I!=0&&(O.g==v||tc(O.h,v))){if(!v.L&&tc(O.h,v)&&O.I==3){try{var $=O.Ba.g.parse(A)}catch{$=null}if(Array.isArray($)&&$.length==3){var ue=$;if(ue[0]==0){e:if(!O.v){if(O.g)if(O.g.F+3e3<v.F)oc(O),pr(O);else break e;vs(O),vn(18)}}else O.xa=ue[1],0<O.xa-O.K&&ue[2]<37500&&O.F&&O.A==0&&!O.C&&(O.C=Qs(d(O.Va,O),6e3));go(O.h)<=1&&O.ta&&(O.ta=void 0)}else bs(O,11)}else if((v.L||O.g==v)&&oc(O),!U(A))for(ue=O.Ba.g.parse(A),A=0;A<ue.length;A++){let ye=ue[A];const qn=ye[0];if(!(qn<=O.K))if(O.K=qn,ye=ye[1],O.I==2)if(ye[0]=="c"){O.M=ye[1],O.ba=ye[2];const sr=ye[3];sr!=null&&(O.ka=sr,O.j.info("VER="+O.ka));const Ha=ye[4];Ha!=null&&(O.za=Ha,O.j.info("SVER="+O.za));const ns=ye[5];ns!=null&&typeof ns=="number"&&ns>0&&($=1.5*ns,O.O=$,O.j.info("backChannelRequestTimeoutMs_="+$)),$=O;const ha=v.g;if(ha){const hl=ha.g?ha.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(hl){var we=$.h;we.g||hl.indexOf("spdy")==-1&&hl.indexOf("quic")==-1&&hl.indexOf("h2")==-1||(we.j=we.l,we.g=new Set,we.h&&(ol(we,we.h),we.h=null))}if($.G){const Tu=ha.g?ha.g.getResponseHeader("X-HTTP-Session-Id"):null;Tu&&($.wa=Tu,un($.J,$.G,Tu))}}O.I=3,O.l&&O.l.ra(),O.aa&&(O.T=Date.now()-v.F,O.j.info("Handshake RTT: "+O.T+"ms")),$=O;var Ke=v;if($.na=nr($,$.L?$.ba:null,$.W),Ke.L){xo($.h,Ke);var Ft=Ke,pn=$.O;pn&&(Ft.H=pn),Ft.D&&(ia(Ft),zr(Ft)),$.g=Ke}else ts($);O.i.length>0&&Wr(O)}else ye[0]!="stop"&&ye[0]!="close"||bs(O,7);else O.I==3&&(ye[0]=="stop"||ye[0]=="close"?ye[0]=="stop"?bs(O,7):da(O):ye[0]!="noop"&&O.l&&O.l.qa(ye),O.A=0)}}Fs(4)}catch{}}var il=class{constructor(v,A){this.g=v,this.map=A}};function al(v){this.l=v||10,a.PerformanceNavigationTiming?(v=a.performance.getEntriesByType("navigation"),v=v.length>0&&(v[0].nextHopProtocol=="hq"||v[0].nextHopProtocol=="h2")):v=!!(a.chrome&&a.chrome.loadTimes&&a.chrome.loadTimes()&&a.chrome.loadTimes().wasFetchedViaSpdy),this.j=v?this.l:1,this.g=null,this.j>1&&(this.g=new Set),this.h=null,this.i=[]}function Oa(v){return v.h?!0:v.g?v.g.size>=v.j:!1}function go(v){return v.h?1:v.g?v.g.size:0}function tc(v,A){return v.h?v.h==A:v.g?v.g.has(A):!1}function ol(v,A){v.g?v.g.add(A):v.h=A}function xo(v,A){v.h&&v.h==A?v.h=null:v.g&&v.g.has(A)&&v.g.delete(A)}al.prototype.cancel=function(){if(this.i=Sn(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&this.g.size!==0){for(const v of this.g.values())v.cancel();this.g.clear()}};function Sn(v){if(v.h!=null)return v.i.concat(v.h.G);if(v.g!=null&&v.g.size!==0){let A=v.i;for(const O of v.g.values())A=A.concat(O.G);return A}return y(v.i)}var Ma=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function As(v,A){if(v){v=v.split("&");for(let O=0;O<v.length;O++){const $=v[O].indexOf("=");let ue,we=null;$>=0?(ue=v[O].substring(0,$),we=v[O].substring($+1)):ue=v[O],A(ue,we?decodeURIComponent(we.replace(/\+/g," ")):"")}}}function $r(v){this.g=this.o=this.j="",this.u=null,this.m=this.h="",this.l=!1;let A;v instanceof $r?(this.l=v.l,Fa(this,v.j),this.o=v.o,this.g=v.g,li(this,v.u),this.h=v.h,Ua(this,Xt(v.i)),this.m=v.m):v&&(A=String(v).match(Ma))?(this.l=!1,Fa(this,A[1]||"",!0),this.o=yo(A[2]||""),this.g=yo(A[3]||"",!0),li(this,A[4]),this.h=yo(A[5]||"",!0),Ua(this,A[6]||"",!0),this.m=yo(A[7]||"")):(this.l=!1,this.i=new Qt(null,this.l))}$r.prototype.toString=function(){const v=[];var A=this.j;A&&v.push(vo(A,nc,!0),":");var O=this.g;return(O||A=="file")&&(v.push("//"),(A=this.o)&&v.push(vo(A,nc,!0),"@"),v.push(St(O).replace(/%25([0-9a-fA-F]{2}
14)/g,"%$1")),O=this.u,O!=null&&v.push(":",String(O))),(O=this.h)&&(this.g&&O.charAt(0)!="/"&&v.push("/"),v.push(vo(O,O.charAt(0)=="/"?ls:sc,!0))),(O=this.i.toString())&&v.push("?",O),(O=this.m)&&v.push("#",vo(O,Hr)),v.join("")},$r.prototype.resolve=function(v){const A=Cr(this);let O=!!v.j;O?Fa(A,v.j):O=!!v.o,O?A.o=v.o:O=!!v.g,O?A.g=v.g:O=v.u!=null;var $=v.h;if(O)li(A,v.u);else if(O=!!v.h){if($.charAt(0)!="/")if(this.g&&!this.h)$="/"+$;else{var ue=A.h.lastIndexOf("/");ue!=-1&&($=A.h.slice(0,ue+1)+$)}if(ue=$,ue==".."||ue==".")$="";else if(ue.indexOf("./")!=-1||ue.indexOf("/.")!=-1){$=ue.lastIndexOf("/",0)==0,ue=ue.split("/");const we=[];for(let Ke=0;Ke<ue.length;){const Ft=ue[Ke++];Ft=="."?$&&Ke==ue.length&&we.push(""):Ft==".."?((we.length>1||we.length==1&&we[0]!="")&&we.pop(),$&&Ke==ue.length&&we.push("")):(we.push(Ft),$=!0)}$=we.join("/")}else $=ue}return O?A.h=$:O=v.i.toString()!=="",O?Ua(A,Xt(v.i)):O=!!v.m,O&&(A.m=v.m),A};function Cr(v){return new $r(v)}function Fa(v,A,O){v.j=O?yo(A,!0):A,v.j&&(v.j=v.j.replace(/:$/,""))}function li(v,A){if(A){if(A=Number(A),isNaN(A)||A<0)throw Error("Bad port number "+A);v.u=A}else v.u=null}function Ua(v,A,O){A instanceof Qt?(v.i=A,Pn(v.i,v.l)):(O||(A=vo(A,Us)),v.i=new Qt(A,v.l))}function un(v,A,O){v.i.set(A,O)}function aa(v){return un(v,"zx",Math.floor(Math.random()*2147483648).toString(36)+Math.abs(Math.floor(Math.random()*2147483648)^Date.now()).toString(36)),v}function yo(v,A){return v?A?decodeURI(v.replace(/%25/g,"%2525")):decodeURIComponent(v):""}function vo(v,A,O){return typeof v=="string"?(v=encodeURI(v).replace(A,Di),O&&(v=v.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),v):null}function Di(v){return v=v.charCodeAt(0),"%"+(v>>4&15).toString(16)+(v&15).toString(16)}var nc=/[#\/\?@]/g,sc=/[#\?:]/g,ls=/[#\?]/g,Us=/[#\?@]/g,Hr=/#/g;function Qt(v,A){this.h=this.g=null,this.i=v||null,this.j=!!A}function Va(v){v.g||(v.g=new Map,v.h=0,v.i&&As(v.i,function(A,O){v.add(decodeURIComponent(A.replace(/\+/g," ")),O)}))}n=Qt.prototype,n.add=function(v,A){Va(this),this.i=null,v=Kn(this,v);let O=this.g.get(v);return O||this.g.set(v,O=[]),O.push(A),this.h+=1,this};function wu(v,A){Va(v),A=Kn(v,A),v.g.has(A)&&(v.i=null,v.h-=v.g.get(A).length,v.g.delete(A))}function bo(v,A){return Va(v),A=Kn(v,A),v.g.has(A)}n.forEach=function(v,A){Va(this),this.g.forEach(function(O,$){O.forEach(function(ue){v.call(A,ue,$,this)},this)},this)};function rc(v,A){Va(v);let O=[];if(typeof A=="string")bo(v,A)&&(O=O.concat(v.g.get(Kn(v,A))));else for(v=Array.from(v.g.values()),A=0;A<v.length;A++)O=O.concat(v[A]);return O}n.set=function(v,A){return Va(this),this.i=null,v=Kn(this,v),bo(this,v)&&(this.h-=this.g.get(v).length),this.g.set(v,[A]),this.h+=1,this},n.get=function(v,A){return v?(v=rc(this,v),v.length>0?String(v[0]):A):A};function Su(v,A,O){wu(v,A),O.length>0&&(v.i=null,v.g.set(Kn(v,A),y(O)),v.h+=O.length)}n.toString=function(){if(this.i)return this.i;if(!this.g)return"";const v=[],A=Array.from(this.g.keys());for(let $=0;$<A.length;$++){var O=A[$];const ue=St(O);O=rc(this,O);for(let we=0;we<O.length;we++){let Ke=ue;O[we]!==""&&(Ke+="="+St(O[we])),v.push(Ke)}}return this.i=v.join("&")};function Xt(v){const A=new Qt;return A.i=v.i,v.g&&(A.g=new Map(v.g),A.h=v.h),A}function Kn(v,A){return A=String(A),v.j&&(A=A.toLowerCase()),A}function Pn(v,A){A&&!v.j&&(Va(v),v.i=null,v.g.forEach(function(O,$){const ue=$.toLowerCase();$!=ue&&(wu(this,$),Su(this,ue,O))},v)),v.j=A}function rn(v,A){const O=new Tr;if(a.Image){const $=new Image;$.onload=h(an,O,"TestLoadImage: loaded",!0,A,$),$.onerror=h(an,O,"TestLoadImage: error",!1,A,$),$.onabort=h(an,O,"TestLoadImage: abort",!1,A,$),$.ontimeout=h(an,O,"TestLoadImage: timeout",!1,A,$),a.setTimeout(function(){$.ontimeout&&$.ontimeout()},1e4),$.src=v}else A(!1)}function Js(v,A){const O=new Tr,$=new AbortController,ue=setTimeout(()=>{$.abort(),an(O,"TestPingServer: timeout",!1,A)},1e4);fetch(v,{signal:$.signal}).then(we=>{clearTimeout(ue),we.ok?an(O,"TestPingServer: ok",!0,A):an(O,"TestPingServer: server error",!1,A)}).catch(()=>{clearTimeout(ue),an(O,"TestPingServer: error",!1,A)})}function an(v,A,O,$,ue){try{ue&&(ue.onload=null,ue.onerror=null,ue.onabort=null,ue.ontimeout=null),$(O)}catch{}}function Ba(){this.g=new De}function oa(v){this.i=v.Sb||null,this.h=v.ab||!1}p(oa,Le),oa.prototype.g=function(){return new Zs(this.i,this.h)};function Zs(v,A){At.call(this),this.H=v,this.o=A,this.m=void 0,this.status=this.readyState=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.A=new Headers,this.h=null,this.F="GET",this.D="",this.g=!1,this.B=this.j=this.l=null,this.v=new AbortController}p(Zs,At),n=Zs.prototype,n.open=function(v,A){if(this.readyState!=0)throw this.abort(),Error("Error reopening a connection");this.F=v,this.D=A,this.readyState=1,er(this)},n.send=function(v){if(this.readyState!=1)throw this.abort(),Error("need to call open() first. ");
14if(this.v.signal.aborted)throw this.abort(),Error("Request was aborted.");this.g=!0;const A={headers:this.A,method:this.F,credentials:this.m,cache:void 0,signal:this.v.signal};v&&(A.body=v),(this.H||a).fetch(new Request(this.D,A)).then(this.Pa.bind(this),this.ga.bind(this))},n.abort=function(){this.response=this.responseText="",this.A=new Headers,this.status=0,this.v.abort(),this.j&&this.j.cancel("Request was aborted.").catch(()=>{}),this.readyState>=1&&this.g&&this.readyState!=4&&(this.g=!1,ji(this)),this.readyState=0},n.Pa=function(v){if(this.g&&(this.l=v,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=v.headers,this.readyState=2,er(this)),this.g&&(this.readyState=3,er(this),this.g)))if(this.responseType==="arraybuffer")v.arrayBuffer().then(this.Na.bind(this),this.ga.bind(this));else if(typeof a.ReadableStream<"u"&&"body"in v){if(this.j=v.body.getReader(),this.o){if(this.responseType)throw Error('responseType must be empty for "streamBinaryChunks" mode responses.');this.response=[]}else this.response=this.responseText="",this.B=new TextDecoder;la(this)}else v.text().then(this.Oa.bind(this),this.ga.bind(this))};function la(v){v.j.read().then(v.Ma.bind(v)).catch(v.ga.bind(v))}n.Ma=function(v){if(this.g){if(this.o&&v.value)this.response.push(v.value);else if(!this.o){var A=v.value?v.value:new Uint8Array(0);(A=this.B.decode(A,{stream:!v.done}))&&(this.response=this.responseText+=A)}v.done?ji(this):er(this),this.readyState==3&&la(this)}},n.Oa=function(v){this.g&&(this.response=this.responseText=v,ji(this))},n.Na=function(v){this.g&&(this.response=v,ji(this))},n.ga=function(){this.g&&ji(this)};function ji(v){v.readyState=4,v.l=null,v.j=null,v.B=null,er(v)}n.setRequestHeader=function(v,A){this.A.append(v,A)},n.getResponseHeader=function(v){return this.h&&this.h.get(v.toLowerCase())||""},n.getAllResponseHeaders=function(){if(!this.h)return"";const v=[],A=this.h.entries();for(var O=A.next();!O.done;)O=O.value,v.push(O[0]+": "+O[1]),O=A.next();return v.join(`\r 15`)};function er(v){v.onreadystatechange&&v.onreadystatechange.call(v)}Object.defineProperty(Zs.prototype,"withCredentials",{get:function(){return this.m==="include"},set:function(v){this.m=v?"include":"same-origin"}});function Oi(v){let A="";return Y(v,function(O,$){A+=$,A+=":",A+=O,A+=`\r 16`}),A}function Mi(v,A,O){e:{for($ in O){var $=!1;break e}$=!0}$||(O=Oi(O),typeof v=="string"?O!=null&&St(O):un(v,A,O))}function En(v){At.call(this),this.headers=new Map,this.L=v||null,this.h=!1,this.g=null,this.D="",this.o=0,this.l="",this.j=this.B=this.v=this.A=!1,this.m=null,this.F="",this.H=!1}p(En,At);var ic=/^https?$/i,Fd=["POST","PUT"];n=En.prototype,n.Fa=function(v){this.H=v},n.ea=function(v,A,O,$){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.D+"; newUri="+v);A=A?A.toUpperCase():"GET",this.D=v,this.l="",this.o=0,this.A=!1,this.h=!0,this.g=this.L?this.L.g():Ar.g(),this.g.onreadystatechange=m(d(this.Ca,this));try{this.B=!0,this.g.open(A,String(v),!0),this.B=!1}catch(we){ca(this,we);return}if(v=O||"",O=new Map(this.headers),$)if(Object.getPrototypeOf($)===Object.prototype)for(var ue in $)O.set(ue,$[ue]);else if(typeof $.keys=="function"&&typeof $.get=="function")for(const we of $.keys())O.set(we,$.get(we));else throw Error("Unknown input type for opt_headers: "+String($));$=Array.from(O.keys()).find(we=>we.toLowerCase()=="content-type"),ue=a.FormData&&v instanceof a.FormData,!(Array.prototype.indexOf.call(Fd,A,void 0)>=0)||$||ue||O.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");for(const[we,Ke]of O)this.g.setRequestHeader(we,Ke);this.F&&(this.g.responseType=this.F),"withCredentials"in this.g&&this.g.withCredentials!==this.H&&(this.g.withCredentials=this.H);try{this.m&&(clearTimeout(this.m),this.m=null),this.v=!0,this.g.send(v),this.v=!1}catch(we){ca(this,we)}};function ca(v,A){v.h=!1,v.g&&(v.j=!0,v.g.abort(),v.j=!1),v.l=A,v.o=5,Fi(v),Vi(v)}function Fi(v){v.A||(v.A=!0,ot(v,"complete"),ot(v,"error"))}n.abort=function(v){this.g&&this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1,this.o=v||7,ot(this,"complete"),ot(this,"abort"),Vi(this))},n.N=function(){this.g&&(this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1),Vi(this,!0)),En.Z.N.call(this)}
16,n.Ca=function(){this.u||(this.B||this.v||this.j?Ui(this):this.Xa())},n.Xa=function(){Ui(this)};function Ui(v){if(v.h&&typeof i<"u"){if(v.v&&tr(v)==4)setTimeout(v.Ca.bind(v),0);else if(ot(v,"readystatechange"),tr(v)==4){v.h=!1;try{const we=v.ca();e:switch(we){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var A=!0;break e;default:A=!1}var O;if(!(O=A)){var $;if($=we===0){let Ke=String(v.D).match(Ma)[1]||null;!Ke&&a.self&&a.self.location&&(Ke=a.self.location.protocol.slice(0,-1)),$=!ic.test(Ke?Ke.toLowerCase():"")}O=$}if(O)ot(v,"complete"),ot(v,"success");else{v.o=6;try{var ue=tr(v)>2?v.g.statusText:""}catch{ue=""}v.l=ue+" ["+v.ca()+"]",Fi(v)}}finally{Vi(v)}}}}function Vi(v,A){if(v.g){v.m&&(clearTimeout(v.m),v.m=null);const O=v.g;v.g=null,A||ot(v,"ready");try{O.onreadystatechange=null}catch{}}}n.isActive=function(){return!!this.g};function tr(v){return v.g?v.g.readyState:0}n.ca=function(){try{return tr(this)>2?this.g.status:-1}catch{return-1}},n.la=function(){try{return this.g?this.g.responseText:""}catch{return""}},n.La=function(v){if(this.g){var A=this.g.responseText;return v&&A.indexOf(v)==0&&(A=A.substring(v.length)),J(A)}};function ua(v){try{if(!v.g)return null;if("response"in v.g)return v.g.response;switch(v.F){case"":case"text":return v.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in v.g)return v.g.mozResponseArrayBuffer}return null}catch{return null}}function ll(v){const A={};v=(v.g&&tr(v)>=2&&v.g.getAllResponseHeaders()||"").split(`\r 17`);for(let $=0;$<v.length;$++){if(U(v[$]))continue;var O=Un(v[$]);const ue=O[0];if(O=O[1],typeof O!="string")continue;O=O.trim();const we=A[ue]||[];A[ue]=we,we.push(O)}ee(A,function($){return $.join(", ")})}n.ya=function(){return this.o},n.Ha=function(){return typeof this.l=="string"?this.l:String(this.l)};function ci(v,A,O){return O&&O.internalChannelParams&&O.internalChannelParams[v]||A}function wo(v){this.za=0,this.i=[],this.j=new Tr,this.ba=this.na=this.J=this.W=this.g=this.wa=this.G=this.H=this.u=this.U=this.o=null,this.Ya=this.V=0,this.Sa=ci("failFast",!1,v),this.F=this.C=this.v=this.m=this.l=null,this.X=!0,this.xa=this.K=-1,this.Y=this.A=this.D=0,this.Qa=ci("baseRetryDelayMs",5e3,v),this.Za=ci("retryDelaySeedMs",1e4,v),this.Ta=ci("forwardChannelMaxRetries",2,v),this.va=ci("forwardChannelRequestTimeoutMs",2e4,v),this.ma=v&&v.xmlHttpFactory||void 0,this.Ua=v&&v.Rb||void 0,this.Aa=v&&v.useFetchStreams||!1,this.O=void 0,this.L=v&&v.supportsCrossDomainXhr||!1,this.M="",this.h=new al(v&&v.concurrentRequestLimit),this.Ba=new Ba,this.S=v&&v.fastHandshake||!1,this.R=v&&v.encodeInitMessageHeaders||!1,this.S&&this.R&&(this.R=!1),this.Ra=v&&v.Pb||!1,v&&v.ua&&this.j.ua(),v&&v.forceLongPolling&&(this.X=!1),this.aa=!this.S&&this.X&&v&&v.detectBufferingProxy||!1,this.ia=void 0,v&&v.longPollingTimeout&&v.longPollingTimeout>0&&(this.ia=v.longPollingTimeout),this.ta=void 0,this.T=0,this.P=!1,this.ja=this.B=null}n=wo.prototype,n.ka=8,n.I=1,n.connect=function(v,A,O,$){vn(0),this.W=v,this.H=A||{},O&&$!==void 0&&(this.H.OSID=O,this.H.OAID=$),this.F=this.X,this.J=nr(this,null,this.W),Wr(this)};function da(v){if(ui(v),v.I==3){var A=v.V++,O=Cr(v.J);if(un(O,"SID",v.M),un(O,"RID",A),un(O,"TYPE","terminate"),Bi(v,O),A=new Vn(v,v.j,A),A.M=2,A.A=aa(Cr(O)),O=!1,a.navigator&&a.navigator.sendBeacon)try{O=a.navigator.sendBeacon(A.A.toString(),"")}catch{}!O&&a.Image&&(new Image().src=A.A,O=!0),O||(A.g=Ud(A.j,null),A.g.ea(A.A)),A.F=Date.now(),zr(A)}ul(v)}function pr(v){v.g&&(cl(v),v.g.cancel(),v.g=null)}function ui(v){pr(v),v.v&&(a.clearTimeout(v.v),v.v=null),oc(v),v.h.cancel(),v.m&&(typeof v.m=="number"&&a.clearTimeout(v.m),v.m=null)}function Wr(v){if(!Oa(v.h)&&!v.m){v.m=!0;var A=v.Ea;V||k(),W||(V(),W=!0),I.add(A,v),v.D=0}}function za(v,A){return go(v.h)>=v.h.j-(v.m?1:0)?!1:v.m?(v.i=A.G.concat(v.i),!0):v.I==1||v.I==2||v.D>=(v.Sa?0:v.Ta)?!1:(v.m=Qs(d(v.Ea,v,A),lc(v,v.D)),v.D++,!0)}n.Ea=function(v){if(this.m)if(this.m=null,this.I==1){if(!v){this.V=Math.floor(Math.random()*1e5),v=this.V++;const ue=new Vn(this,this.j,v);let we=this.o;if(this.U&&(we?(we=H(we),pe(we,this.U)):we=this.U),this.u!==null||this.R||(ue.J=we,we=null),this.S)e:{for(var A=0,O=0;O<this.i.length;O++){t:{var $=this.i[O];if("__data__"in $.map&&($=$.map.__data__,typeof $=="string")){$=$.length;break t}$=void 0}if($===void 0)break;if(A+=$,A>4096){A=O;break e}if(A===4096||O===this.i.length-1){A=O+1;break e}}A=1e3}else A=1e3;A=ac(this,ue,A),O=Cr(this.J),un(O,"RID",v),un(O,"CVER",22),this.G&&un(O,"X-HTTP-Session-Id",this.G),Bi(this,O),we&&(this.R?A="headers="+St(Oi(we))+"&"+A:this.u&&Mi(O,this.u,we)),ol(this.h,ue),this.Ra&&un(O,"TYPE","init"),this.S?(un(O,"$req",A),un(O,"SID","null"),ue.U=!0,Rn(ue,O,null)):Rn(ue,O,A),this.I=2}}else this.I==3&&(v?$a(this,v):this.i.length==0||Oa(this.h)||$a(this))};function $a(v,A){var O;
17A?O=A.l:O=v.V++;const $=Cr(v.J);un($,"SID",v.M),un($,"RID",O),un($,"AID",v.K),Bi(v,$),v.u&&v.o&&Mi($,v.u,v.o),O=new Vn(v,v.j,O,v.D+1),v.u===null&&(O.J=v.o),A&&(v.i=A.G.concat(v.i)),A=ac(v,O,1e3),O.H=Math.round(v.va*.5)+Math.round(v.va*.5*Math.random()),ol(v.h,O),Rn(O,$,A)}function Bi(v,A){v.H&&Y(v.H,function(O,$){un(A,$,O)}),v.l&&Y({},function(O,$){un(A,$,O)})}function ac(v,A,O){O=Math.min(v.i.length,O);const $=v.l?d(v.l.Ka,v.l,v):null;e:{var ue=v.i;let Ft=-1;for(;;){const pn=["count="+O];Ft==-1?O>0?(Ft=ue[0].g,pn.push("ofs="+Ft)):Ft=0:pn.push("ofs="+Ft);let ye=!0;for(let qn=0;qn<O;qn++){var we=ue[qn].g;const sr=ue[qn].map;if(we-=Ft,we<0)Ft=Math.max(0,ue[qn].g-100),ye=!1;else try{we="req"+we+"_"||"";try{var Ke=sr instanceof Map?sr:Object.entries(sr);for(const[Ha,ns]of Ke){let ha=ns;l(ns)&&(ha=ne(ns)),pn.push(we+Ha+"="+encodeURIComponent(ha))}}catch(Ha){throw pn.push(we+"type="+encodeURIComponent("_badmap")),Ha}}catch{$&&$(sr)}}if(ye){Ke=pn.join("&");break e}}Ke=void 0}return v=v.i.splice(0,O),A.G=v,Ke}function ts(v){if(!v.g&&!v.v){v.Y=1;var A=v.Da;V||k(),W||(V(),W=!0),I.add(A,v),v.A=0}}function vs(v){return v.g||v.v||v.A>=3?!1:(v.Y++,v.v=Qs(d(v.Da,v),lc(v,v.A)),v.A++,!0)}n.Da=function(){if(this.v=null,So(this),this.aa&&!(this.P||this.g==null||this.T<=0)){var v=4*this.T;this.j.info("BP detection timer enabled: "+v),this.B=Qs(d(this.Wa,this),v)}},n.Wa=function(){this.B&&(this.B=null,this.j.info("BP detection timeout reached."),this.j.info("Buffering proxy detected and switch to long-polling!"),this.F=!1,this.P=!0,vn(10),pr(this),So(this))};function cl(v){v.B!=null&&(a.clearTimeout(v.B),v.B=null)}function So(v){v.g=new Vn(v,v.j,"rpc",v.Y),v.u===null&&(v.g.J=v.o),v.g.P=0;var A=Cr(v.na);un(A,"RID","rpc"),un(A,"SID",v.M),un(A,"AID",v.K),un(A,"CI",v.F?"0":"1"),!v.F&&v.ia&&un(A,"TO",v.ia),un(A,"TYPE","xmlhttp"),Bi(v,A),v.u&&v.o&&Mi(A,v.u,v.o),v.O&&(v.g.H=v.O);var O=v.g;v=v.ba,O.M=1,O.A=aa(Cr(A)),O.u=null,O.R=!0,Te(O,v)}n.Va=function(){this.C!=null&&(this.C=null,pr(this),vs(this),vn(19))};function oc(v){v.C!=null&&(a.clearTimeout(v.C),v.C=null)}function di(v,A){var O=null;if(v.g==A){oc(v),cl(v),v.g=null;var $=2}else if(tc(v.h,A))O=A.G,xo(v.h,A),$=1;else return;if(v.I!=0){if(A.o)if($==1){O=A.u?A.u.length:0,A=Date.now()-A.F;var ue=v.D;$=ii(),ot($,new ln($,O)),Wr(v)}else ts(v);else if(ue=A.m,ue==3||ue==0&&A.X>0||!($==1&&za(v,A)||$==2&&vs(v)))switch(O&&O.length>0&&(A=v.h,A.i=A.i.concat(O)),ue){case 1:bs(v,5);break;case 4:bs(v,10);break;case 3:bs(v,6);break;default:bs(v,2)}}}function lc(v,A){let O=v.Qa+Math.floor(Math.random()*v.Za);return v.isActive()||(O*=2),O*A}function bs(v,A){if(v.j.info("Error code "+A),A==2){var O=d(v.bb,v),$=v.Ua;const ue=!$;$=new $r($||"//www.google.com/images/cleardot.gif"),a.location&&a.location.protocol=="http"||Fa($,"https"),aa($),ue?rn($.toString(),O):Js($.toString(),O)}else vn(2);v.I=0,v.l&&v.l.pa(A),ul(v),ui(v)}n.bb=function(v){v?(this.j.info("Successfully pinged google.com"),vn(2)):(this.j.info("Failed to ping google.com"),vn(1))};function ul(v){if(v.I=0,v.ja=[],v.l){const A=Sn(v.h);(A.length!=0||v.i.length!=0)&&(x(v.ja,A),x(v.ja,v.i),v.h.i.length=0,y(v.i),v.i.length=0),v.l.oa()}}function nr(v,A,O){var $=O instanceof $r?Cr(O):new $r(O);if($.g!="")A&&($.g=A+"."+$.g),li($,$.u);else{var ue=a.location;$=ue.protocol,A=A?A+"."+ue.hostname:ue.hostname,ue=+ue.port;const we=new $r(null);$&&Fa(we,$),A&&(we.g=A),ue&&li(we,ue),O&&(we.h=O),$=we}return O=v.G,A=v.wa,O&&A&&un($,O,A),un($,"VER",v.ka),Bi(v,$),$}function Ud(v,A,O){if(A&&!v.L)throw Error("Can't create secondary domain capable XhrIo object.");return A=v.Aa&&!v.ma?new En(new oa({ab:O})):new En(v.ma),A.Fa(v.L),A}n.isActive=function(){return!!this.l&&this.l.isActive(this)};function dl(){}n=dl.prototype,n.ra=function(){},n.qa=function(){},n.pa=function(){},n.oa=function(){},n.isActive=function(){return!0},n.Ka=function(){};function cc(){}cc.prototype.g=function(v,A){return new ws(v,A)};function ws(v,A){At.call(this),this.g=new wo(A),this.l=v,this.h=A&&A.messageUrlParams||null,v=A&&A.messageHeaders||null,A&&A.clientProtocolHeaderRequired&&(v?v["X-Client-Protocol"]="webchannel":v={"X-Client-Protocol":"webchannel"}),this.g.o=v,v=A&&A.initMessageHeaders||null,A&&A.messageContentType&&(v?v["X-WebChannel-Content-Type"]=A.messageContentType:v={"X-WebChannel-Content-Type":A.messageContentType}),A&&A.sa&&(v?v["X-WebChannel-Client-Profile"]=A.sa:v={"X-WebChannel-Client-Profile":A.sa}),this.g.U=v,(v=A&&A.Qb)&&!U(v)&&(this.g.u=v),this.A=A&&A.supportsCrossDomainXhr||!1,this.v=A&&A.sendRawJson||!1,(A=A&&A.httpSessionIdParam)&&!U(A)&&(this.g.G=A,v=this.h,v!==null&&A in v&&(v=this.h,A in v&&delete v[A])),this.j=new Eo(this)}p(ws,At),ws.prototype.m=function(){this.g.l=this.j,this.A&&(this.g.L=!0),this.g.connect(this.l,this.h||void 0)},ws.prototype.close=function(){da(this.g)},ws.prototype.o=function(v){var A=this.g;if(typeof v=="string"){var O={};O.__data__=v,v=O}else this.v&&(O={},O.__data__=ne(v),v=O);A.i.push(new il(A.Ya++,v)),A.I==3&&Wr(A)},ws.prototype.N=function(){this.g.l=null,delete this.j,da(this.g),delete this.g,ws.Z.N.call(this)};function uc(v){it.call(this),v.__headers__&&(this.headers=v.__headers__,this.statusCode=v.__status__,delete v.__headers__,delete v.__status__);var A=v.__sm__;if(A){e:{for(const O in A){v=O;break e}v=void 0}(this.i=v)&&(v=this.i,A=A!==null&&v in A?A[v]:void 0),this.data=A}else this.data=v}p(uc,it);function Eu(){Cn.call(this),this.status=1}p(Eu,Cn);function Eo(v){this.g=v}p(Eo,dl),Eo.prototype.ra=function(){ot(this.g,"a")},Eo.prototype.qa=function(v){ot(this.g,new uc(v))},Eo.prototype.pa=function(v){ot(this.g,new Eu)},Eo.prototype.oa=function(){ot(this.g,"b")},cc.prototype.createWebChannel=cc.prototype.g,ws.prototype.send=ws.prototype.o,ws.prototype.open=ws.prototype.m,ws.prototype.close=ws.prototype.close,$k=function(){return new cc},zk=function(){return ii()},Bk=Mn,Rb={jb:0,mb:1,nb:2,Hb:3,Mb:4,Jb:5,Kb:6,Ib:7,Gb:8,Lb:9,PROXY:10,NOPROXY:11,Eb:12,Ab:13,Bb:14,zb:15,Cb:16,Db:17,fb:18,eb:19,gb:20},es.NO_ERROR=0,es.TIMEOUT=8,es.HTTP_ERROR=6,_0=es,Ir.COMPLETE="complete",Vk=Ir,Lt.EventType=Qe,Qe.OPEN="a",Qe.CLOSE="b",Qe.ERROR="c",Qe.MESSAGE="d",At.prototype.listen=At.prototype.J,xp=Lt,En.prototype.listenOnce=En.prototype.K,En.prototype.getLastError=En.prototype.Ha,En.prototype.getLastErrorCode=En.prototype.ya,En.prototype.getStatus=En.prototype.ca,En.prototype.getResponseJson=En.prototype.La,En.prototype.getResponseText=En.prototype.la,En.prototype.send=En.prototype.ea,En.prototype.setWithCredentials=En.prototype.Fa,Uk=En}).apply(typeof Hg<"u"?Hg:typeof self<"u"?self:typeof window<"u"?window:{});class Je{static FOLD_CASE=1;static LITERAL=2;static CLASS_NL=4;static DOT_NL=8;static ONE_LINE=16;static NON_GREEDY=32;static PERL_X=64;static UNICODE_GROUPS=128;static WAS_DOLLAR=256;static MATCH_NL=Je.CLASS_NL|Je.DOT_NL;static PERL=Je.CLASS_NL|Je.ONE_LINE|Je.PERL_X|Je.UNICODE_GROUPS;static POSIX=0;static UNANCHORED=0;static ANCHOR_START=1;static ANCHOR_BOTH=2}class Se{static CODES=new Map([["\x07",7],["\b",8],[" ",9],[` 18`,10],["\v",11],["\f",12],["\r",13],[" ",32],['"',34],["$",36],["&",38],["(",40],[")",41],["*",42],["+",43],["-",45],[".",46],["0",48],["1",49],["2",50],["3",51],["4",52],["5",53],["6",54],["7",55],["8",56],["9",57],[":",58],["<",60],[">",62],["?",63],["A",65],["B",66],["C",67],["F",70],["P",80],["Q",81],["U",85],["Z",90],["[",91],["\\",92],["]",93],["^",94],["_",95],["a",97],["b",98],["f",102],["i",105],["m",109],["n",110],["r",114],["s",115],["t",116],["v",118],["x",120],["z",122],["{",123],["|",124],["}",125]]);static toUpperCase(e){const t=String.fromCodePoint(e).toUpperCase();if(t.length>1)return e;const s=String.fromCodePoint(t.codePointAt(0)).toLowerCase();return s.length>1||s.codePointAt(0)!==e?e:t.codePointAt(0)}static toLowerCase(e){const t=String.fromCodePoint(e).toLowerCase();if(t.length>1)return e;const s=String.fromCodePoint(t.codePointAt(0)).toUpperCase();return s.length>1||s.codePointAt(0)!==e?e:t.codePointAt(0)}}class te{static CASE_ORBIT=new Map([[75,107],[107,8490],[8490,75],[83,115],[115,383],[383,83],[181,924],[924,956],[956,181],[197,229],[229,8491],[8491,197],[452,453],[453,454],[454,452],[455,456],[456,457],[457,455],[458,459],[459,460],[460,458],[497,498],[498,499],[499,497],[837,921],[921,953],[953,8126],[8126,837],[914,946],[946,976],[976,914],[917,949],[949,1013],[1013,917],[920,952],[952,977],[977,1012],[1012,920],[922,954],[954,1008],[1008,922],[928,960],[960,982],[982,928],[929,961],[961,1009],[1009,929],[931,962],[962,963],[963,931],[934,966],[966,981],[981,934],[937,969],[969,8486],[8486,937],[1042,1074],[1074,7296],[7296,1042],[1044,1076],[1076,7297],[7297,1044],[1054,1086],[1086,7298],[7298,1054],[1057,1089],[1089,7299],[7299,1057],[1058,1090],[1090,7300],[7300,7301],[7301,1058],[1066,1098],[1098,7302],[7302,1066],[1122,1123],[1123,7303],[7303,1122],[7304,42570],[42570,42571],[42571,7304],[7776,7777],[7777,7835],[7835,7776],[223,7838],[7838,223],[8064,8072],[8072,8064],[8065,8073],[8073,8065],[8066,8074],[8074,8066],[8067,8075],[8075,8067],[8068,8076],[8076,8068],[8069,8077],[8077,8069],[8070,8078],[8078,8070],[8071,8079],[8079,8071],[8080,8088],[8088,8080],[8081,8089],[8089,8081],[8082,8090],[8090,8082],[8083,8091],[8091,8083],[8084,8092],[8092,8084],[8085,8093],[8093,8085],[8086,8094],[8094,8086],[8087,8095],[8095,8087],[8096,8104],[8104,8096],[8097,8105],[8105,8097],[8098,8106],[8106,8098],[8099,8107],[8107,8099],[8100,8108],[8108,8100],[8101,8109],[8109,8101],[8102,8110],[8110,8102],[8103,8111],[8111,8103],[8115,8124],[8124,8115],[8131,8140],[8140,8131],[912,8
18147],[8147,912],[944,8163],[8163,944],[8179,8188],[8188,8179],[64261,64262],[64262,64261],[66560,66600],[66600,66560],[66561,66601],[66601,66561],[66562,66602],[66602,66562],[66563,66603],[66603,66563],[66564,66604],[66604,66564],[66565,66605],[66605,66565],[66566,66606],[66606,66566],[66567,66607],[66607,66567],[66568,66608],[66608,66568],[66569,66609],[66609,66569],[66570,66610],[66610,66570],[66571,66611],[66611,66571],[66572,66612],[66612,66572],[66573,66613],[66613,66573],[66574,66614],[66614,66574],[66575,66615],[66615,66575],[66576,66616],[66616,66576],[66577,66617],[66617,66577],[66578,66618],[66618,66578],[66579,66619],[66619,66579],[66580,66620],[66620,66580],[66581,66621],[66621,66581],[66582,66622],[66622,66582],[66583,66623],[66623,66583],[66584,66624],[66624,66584],[66585,66625],[66625,66585],[66586,66626],[66626,66586],[66587,66627],[66627,66587],[66588,66628],[66628,66588],[66589,66629],[66629,66589],[66590,66630],[66630,66590],[66591,66631],[66631,66591],[66592,66632],[66632,66592],[66593,66633],[66633,66593],[66594,66634],[66634,66594],[66595,66635],[66635,66595],[66596,66636],[66636,66596],[66597,66637],[66637,66597],[66598,66638],[66638,66598],[66599,66639],[66639,66599],[66736,66776],[66776,66736],[66737,66777],[66777,66737],[66738,66778],[66778,66738],[66739,66779],[66779,66739],[66740,66780],[66780,66740],[66741,66781],[66781,66741],[66742,66782],[66782,66742],[66743,66783],[66783,66743],[66744,66784],[66784,66744],[66745,66785],[66785,66745],[66746,66786],[66786,66746],[66747,66787],[66787,66747],[66748,66788],[66788,66748],[66749,66789],[66789,66749],[66750,66790],[66790,66750],[66751,66791],[66791,66751],[66752,66792],[66792,66752],[66753,66793],[66793,66753],[66754,66794],[66794,66754],[66755,66795],[66795,66755],[66756,66796],[66796,66756],[66757,66797],[66797,66757],[66758,66798],[66798,66758],[66759,66799],[66799,66759],[66760,66800],[66800,66760],[66761,66801],[66801,66761],[66762,66802],[66802,66762],[66763,66803],[66803,66763],[66764,66804],[66804,66764],[66765,66805],[66805,66765],[66766,66806],[66806,66766],[66767,66807],[66807,66767],[66768,66808],[66808,66768],[66769,66809],[66809,66769],[66770,66810],[66810,66770],[66771,66811],[66811,66771],[66928,66967],[66967,66928],[66929,66968],[66968,66929],[66930,66969],[66969,66930],[66931,66970],[66970,66931],[66932,66971],[66971,66932],[66933,66972],[66972,66933],[66934,66973],[66973,66934],[66935,66974],[66974,66935],[66936,66975],[66975,66936],[66937,66976],[66976,66937],[66938,66977],[66977,66938],[66940,66979],[66979,66940],[66941,66980],[66980,66941],[66942,66981],[66981,66942],[66943,66982],[66982,66943],[66944,66983],[66983,66944],[66945,66984],[66984,66945],[66946,66985],[66985,66946],[66947,66986],[66986,66947],[66948,66987],[66987,66948],[66949,66988],[66988,66949],[66950,66989],[66989,66950],[66951,66990],[66990,66951],[66952,66991],[66991,66952],[66953,66992],[66992,66953],[66954,66993],[66993,66954],[66956,66995],[66995,66956],[66957,66996],[66996,66957],[66958,66997],[66997,66958],[66959,66998],[66998,66959],[66960,66999],[66999,66960],[66961,67e3],[67e3,66961],[66962,67001],[67001,66962],[66964,67003],[67003,66964],[66965,67004],[67004,66965],[68736,68800],[68800,68736],[68737,68801],[68801,68737],[68738,68802],[68802,68738],[68739,68803],[68803,68739],[68740,68804],[68804,68740],[68741,68805],[68805,68741],[68742,68806],[68806,68742],[68743,68807],[68807,68743],[68744,68808],[68808,68744],[68745,68809],[68809,68745],[68746,68810],[68810,68746],[68747,68811],[68811,68747],[68748,68812],[68812,68748],[68749,68813],[68813,68749],[68750,68814],[68814,68750],[68751,68815],[68815,68751],[68752,68816],[68816,68752],[68753,68817],[68817,68753],[68754,68818],[68818,68754],[68755,68819],[68819,68755],[68756,68820],[68820,68756],[68757,68821],[68821,68757],[68758,68822],[68822,68758],[68759,68823],[68823,68759],[68760,68824],[68824,68760],[68761,68825],[68825,68761],[68762,68826],[68826,68762],[68763,68827],[68827,68763],[68764,68828],[68828,68764],[68765,68829],[68829,68765],[68766,68830],[68830,68766],[68767,68831],[68831,68767],[68768,68832],[68832,68768],[68769,68833],[68833,68769],[68770,68834],[68834,68770],[68771,68835],[68835,68771],[68772,68836],[68836,68772],[68773,68837],[68837,68773],[68774,68838],[68838,68774],[68775,68839],[68839,68775],[68776,68840],[68840,68776],[68777,68841],[68841,68777],[68778,68842],[68842,68778],[68779,68843],[68843,68779],[68780,68844],[68844,68780],[68781,68845],[68845,68781],[68782,68846],[68846,68782],[68783,68847],[68847,68783],[68784,68848],[68848,68784],[68785,68849],[68849,68785],[68786,68850],[68850,68786],[71840,71872],[71872,71840],[71841,71873],[71873,71841],[71842,71874],[71874,71842],[71843,71875],[71875,71843],[71844,71876],[71876,71844],[71845,71877],[71877,71845],[71846,71878],[71878,71846],[71847,71879],[71879,71847],[71848,71880],[71880,71848],[71849,71881],[71881,71849],[71850,71882],[71882,71850],[71851,71883],[71883,71851],[71852,71884],[71884,71852],[71853,71885],[71885,71853],[71854,71886],[71886,71854],[71855,71887],[71887,71855],[71856,71888],[71888,71856],[71857,71889],[71889,71857],[71858,71890],[71890,71858],[71859,71891],[71891,71859],[71860,71892],[71892,71860],[71861,71893],[71893,71861],[71862,71894],[71894,71862],[71863,71895],[71895,71863],[71864,71896],[71896,71864],[71865,71897],[71897,71865],[71866,71898],[71898,71866],[71867,71899],[71899,71867],[71868,71900],[71900,71868],[71869,71901],[71901,71869],[71870,71902],[71902,71870],[71871,71903],[71903,71871],[93760,93792],[93792,93760],[93761,93793],[93793,93761],[93762,93794],[93794,93762],[93763,93795],[93795,93763],[93764,93796],[93796,93764],[93765,93797],[93797,93765],[93766,93798],[93798,93766],[93767,93799],[93799,93767],[93768,93800],[93800,93768],[93769,93801],[93801,93769],[93770,93802],[93802,93770],[937
1871,93803],[93803,93771],[93772,93804],[93804,93772],[93773,93805],[93805,93773],[93774,93806],[93806,93774],[93775,93807],[93807,93775],[93776,93808],[93808,93776],[93777,93809],[93809,93777],[93778,93810],[93810,93778],[93779,93811],[93811,93779],[93780,93812],[93812,93780],[93781,93813],[93813,93781],[93782,93814],[93814,93782],[93783,93815],[93815,93783],[93784,93816],[93816,93784],[93785,93817],[93817,93785],[93786,93818],[93818,93786],[93787,93819],[93819,93787],[93788,93820],[93820,93788],[93789,93821],[93821,93789],[93790,93822],[93822,93790],[93791,93823],[93823,93791],[125184,125218],[125218,125184],[125185,125219],[125219,125185],[125186,125220],[125220,125186],[125187,125221],[125221,125187],[125188,125222],[125222,125188],[125189,125223],[125223,125189],[125190,125224],[125224,125190],[125191,125225],[125225,125191],[125192,125226],[125226,125192],[125193,125227],[125227,125193],[125194,125228],[125228,125194],[125195,125229],[125229,125195],[125196,125230],[125230,125196],[125197,125231],[125231,125197],[125198,125232],[125232,125198],[125199,125233],[125233,125199],[125200,125234],[125234,125200],[125201,125235],[125235,125201],[125202,125236],[125236,125202],[125203,125237],[125237,125203],[125204,125238],[125238,125204],[125205,125239],[125239,125205],[125206,125240],[125240,125206],[125207,125241],[125241,125207],[125208,125242],[125242,125208],[125209,125243],[125243,125209],[125210,125244],[125244,125210],[125211,125245],[125245,125211],[125212,125246],[125246,125212],[125213,125247],[125247,125213],[125214,125248],[125248,125214],[125215,125249],[125249,125215],[125216,125250],[125250,125216],[125217,125251],[125251,125217]]);static C=[[0,31,1],[127,159,1],[173,888,715],[889,896,7],[897,899,1],[907,909,2],[930,1328,398],[1367,1368,1],[1419,1420,1],[1424,1480,56],[1481,1487,1],[1515,1518,1],[1525,1541,1],[1564,1757,193],[1806,1807,1],[1867,1868,1],[1970,1983,1],[2043,2044,1],[2094,2095,1],[2111,2140,29],[2141,2143,2],[2155,2159,1],[2191,2199,1],[2274,2436,162],[2445,2446,1],[2449,2450,1],[2473,2481,8],[2483,2485,1],[2490,2491,1],[2501,2502,1],[2505,2506,1],[2511,2518,1],[2520,2523,1],[2526,2532,6],[2533,2559,26],[2560,2564,4],[2571,2574,1],[2577,2578,1],[2601,2609,8],[2612,2618,3],[2619,2621,2],[2627,2630,1],[2633,2634,1],[2638,2640,1],[2642,2648,1],[2653,2655,2],[2656,2661,1],[2679,2688,1],[2692,2702,10],[2706,2729,23],[2737,2740,3],[2746,2747,1],[2758,2766,4],[2767,2769,2],[2770,2783,1],[2788,2789,1],[2802,2808,1],[2816,2820,4],[2829,2830,1],[2833,2834,1],[2857,2865,8],[2868,2874,6],[2875,2885,10],[2886,2889,3],[2890,2894,4],[2895,2900,1],[2904,2907,1],[2910,2916,6],[2917,2936,19],[2937,2945,1],[2948,2955,7],[2956,2957,1],[2961,2966,5],[2967,2968,1],[2971,2973,2],[2976,2978,1],[2981,2983,1],[2987,2989,1],[3002,3005,1],[3011,3013,1],[3017,3022,5],[3023,3025,2],[3026,3030,1],[3032,3045,1],[3067,3071,1],[3085,3089,4],[3113,3130,17],[3131,3141,10],[3145,3150,5],[3151,3156,1],[3159,3163,4],[3164,3166,2],[3167,3172,5],[3173,3184,11],[3185,3190,1],[3213,3217,4],[3241,3252,11],[3258,3259,1],[3269,3273,4],[3278,3284,1],[3287,3292,1],[3295,3300,5],[3301,3312,11],[3316,3327,1],[3341,3345,4],[3397,3401,4],[3408,3411,1],[3428,3429,1],[3456,3460,4],[3479,3481,1],[3506,3516,10],[3518,3519,1],[3527,3529,1],[3531,3534,1],[3541,3543,2],[3552,3557,1],[3568,3569,1],[3573,3584,1],[3643,3646,1],[3676,3712,1],[3715,3717,2],[3723,3748,25],[3750,3774,24],[3775,3781,6],[3783,3791,8],[3802,3803,1],[3808,3839,1],[3912,3949,37],[3950,3952,1],[3992,4029,37],[4045,4059,14],[4060,4095,1],[4294,4296,2],[4297,4300,1],[4302,4303,1],[4681,4686,5],[4687,4695,8],[4697,4702,5],[4703,4745,42],[4750,4751,1],[4785,4790,5],[4791,4799,8],[4801,4806,5],[4807,4823,16],[4881,4886,5],[4887,4955,68],[4956,4989,33],[4990,4991,1],[5018,5023,1],[5110,5111,1],[5118,5119,1],[5789,5791,1],[5881,5887,1],[5910,5918,1],[5943,5951,1],[5972,5983,1],[5997,6001,4],[6004,6015,1],[6110,6111,1],[6122,6127,1],[6138,6143,1],[6158,6170,12],[6171,6175,1],[6265,6271,1],[6315,6319,1],[6390,6399,1],[6431,6444,13],[6445,6447,1],[6460,6463,1],[6465,6467,1],[6510,6511,1],[6517,6527,1],[6572,6575,1],[6602,6607,1],[6619,6621,1],[6684,6685,1],[6751,6781,30],[6782,6794,12],[6795,6799,1],[6810,6815,1],[6830,6831,1],[6863,6911,1],[6989,6991,1],[7039,7156,117],[7157,7163,1],[7224,7226,1],[7242,7244,1],[7305,7311,1],[7355,7356,1],[7368,7375,1],[7419,7423,1],[7958,7959,1],[7966,7967,1],[8006,8007,1],[8014,8015,1],[8024,8030,2],[8062,8063,1],[8117,8133,16],[8148,8149,1],[8156,8176,20],[8177,8181,4],[8191,8203,12],[8204,8207,1],[8234,8238,1],[8288,8303,1],[8306,8307,1],[8335,8349,14],[8350,8351,1],[8385,8399,1],[8433,8447,1],[8588,8591,1],[9255,9279,1],[9291,9311,1],[11124,11125,1],[11158,11508,350],[11509,11512,1],[11558,11560,2],[11561,11564,1],[11566,11567,1],[11624,11630,1],[11633,11646,1],[11671,11679,1],[11687,11743,8],[11870,11903,1],[11930,12020,90],[12021,12031,1],[12246,12271,1],[12352,12439,87],[12440,12544,104],[12545,12548,1],[12592,12687,95],[12772,12782,1],[12831,42125,29294],[42126,42127,1],[42183,42191,1],[42540,42559,1],[42744,42751,1],[42955,42959,1],[42962,42964,2],[42970,42993,1],[43053,43055,1],[43066,43071,1],[43128,43135,1],[43206,43213,1],[43226,43231,1],[43348,43358,1],[43389,43391,1],[43470,43482,12],[43483,43485,1],[43519,43575,56],[43576,43583,1],[43598,43599,1],[43610,43611,1],[43715,43738,1],[43767,43776,1],[43783,43784,1],[43791,43792,1],[43799,43807,1],[43815,43823,8],[43884,43887,1],[44014,44015,1],[44026,44031,1],[55204,55215,1],[55239,55242,1],[55292,63743,1],[64110,64111,1],[64218,64255,1],[64263,64274,1],[64280,64284,1],[64311,64317,6],[64319,64325,3],[64451,64466,1],[64912,64913,1],[64968,64974,1],[64976,65007,1],[65050,65055,1],[65107,65127,20],[65132,65135,1],[65141,65277,136],[65278,65280,1],[65471,65473,1],[65480,65481,1],[65488,65489,1],[65496,65497,1],[65501,65503,1],[65511,65519,8],[65520,65531,1],[65534,65535,1],[65548,65575,27],[65595,65598,3],[65614,65615,1],[65630,65663,1],[65787,65791,1],[65795,65798,1],[65844,65846,1],[65935,65949,14],[65950,65951,1],[65953,65999,1],[66046,66175,1],[66205,66207,1],[66257,66271,1],[66300,66303,1],[66340,66348,1],[66379,66383,1],[66427,66431,1],[66462,66500,38],[66501,66503,1],[66518,66559,1],[66718,66719,1],[66730,66735,1],[66772,66775,1],[66812,66815,1],[66856,66863,1],[66916,66926,1],[66939,66955,16],[66963,66966,3],[66978,66994,16],[67002,67005,3],[67006,67071,1],[67383,67391,1],[67414,67423,1],[67432,67455,1],[67462,67505,43],[67515,67583,1],[67590,67591,1],[67593,67638,45],[67641,67643,1],[67645,67646,1],[67670,67743,73],[67744,67750,1],[67760,67807,1],[67827,67830,3],[67831,67834,1],[67868,67870,1],[67898,67902,1],[67904,67967,1],[68024,68027,1],[68048,68049,1],[68100,68103,3],[68104,68107,1],[68116,68120,4],[68150,68151,1],[68155,68158,1],[68169,68175,1],[68185,68191,1],[68256,68287,1],[68327,68330,1],[68343,68351,1],[68406,68408,1],[68438,68439,1],[68467,68471,1],[68498,68504,1],[68509,68520,1],[68528,68607,1],[68681,68735,1],[68787,68799,1],[68851,68857,1],[68904,68911,1],[68922,69215,1],[69247,69290,43],[69294,69295,1],[69298,69372,1],[69416,69423,1],[69466,69487,1],[69514,69551,1],[69580,69599,1],[69623,69631,1],[69710,69713,1],[69750,69758,1],[69821,69827,6],[69828,69839,1],[69865,69871,1],[69882,69887,1],[69941,69960,19],[69961,69967,1],[70007,70015,1],[70112,70133,21],[70134,70143,1],[70162,70210,48],[70211,70271,1],[70279,70281,2],[70286,70302,16],[70314,70319,1],[70379,70383,1],[70394,70399,1],[70404,70413,9],[70414,70417,3],[70418,70441,23],[70449,70452,3],[70458,70469,11],[70470,70473,3],[70474,70478,4],[70479,70481,2],[70482,70486,1],[70488,70492,1],[70500,70501,1],[70509,70511,
181],[70517,70655,1],[70748,70754,6],[70755,70783,1],[70856,70863,1],[70874,71039,1],[71094,71095,1],[71134,71167,1],[71237,71247,1],[71258,71263,1],[71277,71295,1],[71354,71359,1],[71370,71423,1],[71451,71452,1],[71468,71471,1],[71495,71679,1],[71740,71839,1],[71923,71934,1],[71943,71944,1],[71946,71947,1],[71956,71959,3],[71990,71993,3],[71994,72007,13],[72008,72015,1],[72026,72095,1],[72104,72105,1],[72152,72153,1],[72165,72191,1],[72264,72271,1],[72355,72367,1],[72441,72447,1],[72458,72703,1],[72713,72759,46],[72774,72783,1],[72813,72815,1],[72848,72849,1],[72872,72887,15],[72888,72959,1],[72967,72970,3],[73015,73017,1],[73019,73022,3],[73032,73039,1],[73050,73055,1],[73062,73065,3],[73103,73106,3],[73113,73119,1],[73130,73439,1],[73465,73471,1],[73489,73531,42],[73532,73533,1],[73562,73647,1],[73649,73663,1],[73714,73726,1],[74650,74751,1],[74863,74869,6],[74870,74879,1],[75076,77711,1],[77811,77823,1],[78896,78911,1],[78934,82943,1],[83527,92159,1],[92729,92735,1],[92767,92778,11],[92779,92781,1],[92863,92874,11],[92875,92879,1],[92910,92911,1],[92918,92927,1],[92998,93007,1],[93018,93026,8],[93048,93052,1],[93072,93759,1],[93851,93951,1],[94027,94030,1],[94088,94094,1],[94112,94175,1],[94181,94191,1],[94194,94207,1],[100344,100351,1],[101590,101631,1],[101641,110575,1],[110580,110588,8],[110591,110883,292],[110884,110897,1],[110899,110927,1],[110931,110932,1],[110934,110947,1],[110952,110959,1],[111356,113663,1],[113771,113775,1],[113789,113791,1],[113801,113807,1],[113818,113819,1],[113824,118527,1],[118574,118575,1],[118599,118607,1],[118724,118783,1],[119030,119039,1],[119079,119080,1],[119155,119162,1],[119275,119295,1],[119366,119487,1],[119508,119519,1],[119540,119551,1],[119639,119647,1],[119673,119807,1],[119893,119965,72],[119968,119969,1],[119971,119972,1],[119975,119976,1],[119981,119994,13],[119996,120004,8],[120070,120075,5],[120076,120085,9],[120093,120122,29],[120127,120133,6],[120135,120137,1],[120145,120486,341],[120487,120780,293],[120781,121484,703],[121485,121498,1],[121504,121520,16],[121521,122623,1],[122655,122660,1],[122667,122879,1],[122887,122905,18],[122906,122914,8],[122917,122923,6],[122924,122927,1],[122990,123022,1],[123024,123135,1],[123181,123183,1],[123198,123199,1],[123210,123213,1],[123216,123535,1],[123567,123583,1],[123642,123646,1],[123648,124111,1],[124154,124895,1],[124903,124908,5],[124911,124927,16],[125125,125126,1],[125143,125183,1],[125260,125263,1],[125274,125277,1],[125280,126064,1],[126133,126208,1],[126270,126463,1],[126468,126496,28],[126499,126501,2],[126502,126504,2],[126515,126520,5],[126522,126524,2],[126525,126529,1],[126531,126534,1],[126536,126540,2],[126544,126547,3],[126549,126550,1],[126552,126560,2],[126563,126565,2],[126566,126571,5],[126579,126589,5],[126591,126602,11],[126620,126624,1],[126628,126634,6],[126652,126703,1],[126706,126975,1],[127020,127023,1],[127124,127135,1],[127151,127152,1],[127168,127184,16],[127222,127231,1],[127406,127461,1],[127491,127503,1],[127548,127551,1],[127561,127567,1],[127570,127583,1],[127590,127743,1],[128728,128731,1],[128749,128751,1],[128765,128767,1],[128887,128890,1],[128986,128991,1],[129004,129007,1],[129009,129023,1],[129036,129039,1],[129096,129103,1],[129114,129119,1],[129160,129167,1],[129198,129199,1],[129202,129279,1],[129620,129631,1],[129646,129647,1],[129661,129663,1],[129673,129679,1],[129726,129734,8],[129735,129741,1],[129756,129759,1],[129769,129775,1],[129785,129791,1],[129939,129995,56],[129996,130031,1],[130042,131071,1],[173792,173823,1],[177978,177983,1],[178206,178207,1],[183970,183983,1],[191457,191471,1],[192094,194559,1],[195102,196607,1],[201547,201551,1],[205744,917759,1],[918e3,1114111,1]];static Cc=[[0,31,1],[127,159,1]];static Cf=[[173,1536,1363],[1537,1541,1],[1564,1757,193],[1807,2192,385],[2193,2274,81],[6158,8203,2045],[8204,8207,1],[8234,8238,1],[8288,8292,1],[8294,8303,1],[65279,65529,250],[65530,65531,1],[69821,69837,16],[78896,78911,1],[113824,113827,1],[119155,119162,1],[917505,917536,31],[917537,917631,1]];static Co=[[57344,63743,1],[983040,1048573,1],[1048576,1114109,1]];static Cs=[[55296,57343,1]];static L=[[65,90,1],[97,122,1],[170,181,11],[186,192,6],[193,214,1],[216,246,1],[248,705,1],[710,721,1],[736,740,1],[748,750,2],[880,884,1],[886,887,1],[890,893,1],[895,902,7],[904,906,1],[908,910,2],[911,929,1],[931,1013,1],[1015,1153,1],[1162,1327,1],[1329,1366,1],[1369,1376,7
18],[1377,1416,1],[1488,1514,1],[1519,1522,1],[1568,1610,1],[1646,1647,1],[1649,1747,1],[1749,1765,16],[1766,1774,8],[1775,1786,11],[1787,1788,1],[1791,1808,17],[1810,1839,1],[1869,1957,1],[1969,1994,25],[1995,2026,1],[2036,2037,1],[2042,2048,6],[2049,2069,1],[2074,2084,10],[2088,2112,24],[2113,2136,1],[2144,2154,1],[2160,2183,1],[2185,2190,1],[2208,2249,1],[2308,2361,1],[2365,2384,19],[2392,2401,1],[2417,2432,1],[2437,2444,1],[2447,2448,1],[2451,2472,1],[2474,2480,1],[2482,2486,4],[2487,2489,1],[2493,2510,17],[2524,2525,1],[2527,2529,1],[2544,2545,1],[2556,2565,9],[2566,2570,1],[2575,2576,1],[2579,2600,1],[2602,2608,1],[2610,2611,1],[2613,2614,1],[2616,2617,1],[2649,2652,1],[2654,2674,20],[2675,2676,1],[2693,2701,1],[2703,2705,1],[2707,2728,1],[2730,2736,1],[2738,2739,1],[2741,2745,1],[2749,2768,19],[2784,2785,1],[2809,2821,12],[2822,2828,1],[2831,2832,1],[2835,2856,1],[2858,2864,1],[2866,2867,1],[2869,2873,1],[2877,2908,31],[2909,2911,2],[2912,2913,1],[2929,2947,18],[2949,2954,1],[2958,2960,1],[2962,2965,1],[2969,2970,1],[2972,2974,2],[2975,2979,4],[2980,2984,4],[2985,2986,1],[2990,3001,1],[3024,3077,53],[3078,3084,1],[3086,3088,1],[3090,3112,1],[3114,3129,1],[3133,3160,27],[3161,3162,1],[3165,3168,3],[3169,3200,31],[3205,3212,1],[3214,3216,1],[3218,3240,1],[3242,3251,1],[3253,3257,1],[3261,3293,32],[3294,3296,2],[3297,3313,16],[3314,3332,18],[3333,3340,1],[3342,3344,1],[3346,3386,1],[3389,3406,17],[3412,3414,1],[3423,3425,1],[3450,3455,1],[3461,3478,1],[3482,3505,1],[3507,3515,1],[3517,3520,3],[3521,3526,1],[3585,3632,1],[3634,3635,1],[3648,3654,1],[3713,3714,1],[3716,3718,2],[3719,3722,1],[3724,3747,1],[3749,3751,2],[3752,3760,1],[3762,3763,1],[3773,3776,3],[3777,3780,1],[3782,3804,22],[3805,3807,1],[3840,3904,64],[3905,3911,1],[3913,3948,1],[3976,3980,1],[4096,4138,1],[4159,4176,17],[4177,4181,1],[4186,4189,1],[4193,4197,4],[4198,4206,8],[4207,4208,1],[4213,4225,1],[4238,4256,18],[4257,4293,1],[4295,4301,6],[4304,4346,1],[4348,4680,1],[4682,4685,1],[4688,4694,1],[4696,4698,2],[4699,4701,1],[4704,4744,1],[4746,4749,1],[4752,4784,1],[4786,4789,1],[4792,4798,1],[4800,4802,2],[4803,4805,1],[4808,4822,1],[4824,4880,1],[4882,4885,1],[4888,4954,1],[4992,5007,1],[5024,5109,1],[5112,5117,1],[5121,5740,1],[5743,5759,1],[5761,5786,1],[5792,5866,1],[5873,5880,1],[5888,5905,1],[5919,5937,1],[5952,5969,1],[5984,5996,1],[5998,6e3,1],[6016,6067,1],[6103,6108,5],[6176,6264,1],[6272,6276,1],[6279,6312,1],[6314,6320,6],[6321,6389,1],[6400,6430,1],[6480,6509,1],[6512,6516,1],[6528,6571,1],[6576,6601,1],[6656,6678,1],[6688,6740,1],[6823,6917,94],[6918,6963,1],[6981,6988,1],[7043,7072,1],[7086,7087,1],[7098,7141,1],[7168,7203,1],[7245,7247,1],[7258,7293,1],[7296,7304,1],[7312,7354,1],[7357,7359,1],[7401,7404,1],[7406,7411,1],[7413,7414,1],[7418,7424,6],[7425,7615,1],[7680,7957,1],[7960,7965,1],[7968,8005,1],[8008,8013,1],[8016,8023,1],[8025,8031,2],[8032,8061,1],[8064,8116,1],[8118,8124,1],[8126,8130,4],[8131,8132,1],[8134,8140,1],[8144,8147,1],[8150,8155,1],[8160,8172,1],[8178,8180,1],[8182,8188,1],[8305,8319,14],[8336,8348,1],[8450,8455,5],[8458,8467,1],[8469,8473,4],[8474,8477,1],[8484,8490,2],[8491,8493,1],[8495,8505,1],[8508,8511,1],[8517,8521,1],[8526,8579,53],[8580,11264,2684],[11265,11492,1],[11499,11502,1],[11506,11507,1],[11520,11557,1],[11559,11565,6],[11568,11623,1],[11631,11648,17],[11649,11670,1],[11680,11686,1],[11688,11694,1],[11696,11702,1],[11704,11710,1],[11712,11718,1],[11720,11726,1],[11728,11734,1],[11736,11742,1],[11823,12293,470],[12294,12337,43],[12338,12341,1],[12347,12348,1],[12353,12438,1],[12445,12447,1],[12449,12538,1],[12540,12543,1],[12549,12591,1],[12593,12686,1],[12704,12735,1],[12784,12799,1],[13312,19903,1],[19968,42124,1],[42192,42237,1],[42240,42508,1],[42512,42527,1],[42538,42539,1],[42560,42606,1],[42623,42653,1],[42656,42725,1],[42775,42783,1],[42786,42888,1],[42891,42954,1],[42960,42961,1],[42963,42965,2],[42966,42969,1],[42994,43009,1],[43011,43013,1],[43015,43018,1],[43020,43042,1],[43072,43123,1],[43138,43187,1],[43250,43255,1],[43259,43261,2],[43262,43274,12],[43275,43301,1],[43312,43334,1],[43360,43388,1],[43396,43442,1],[43471,43488,17],[43489,43492,1],[43494,43503,1],[43514,43518,1],[43520,43560,1],[43584,43586,1],[43588,43595,1],[43616,43638,1],[43642,43646,4],[43647,43695,1],[43697,43701,4],[43702,43705,3],[43706,43709,1],[43712,43714,2],[43739,43741,1],[43744,43754,1],[43762,43764,1],[43777,43782,1],[43785,43790,1],[43793,43798,1],[43808,43814,1],[43816,43822,1],[43824,43866,1],[43868,43881,1],[43888,44002,1],[44032,55203,1],[55216,55238,1],[55243,5
185291,1],[63744,64109,1],[64112,64217,1],[64256,64262,1],[64275,64279,1],[64285,64287,2],[64288,64296,1],[64298,64310,1],[64312,64316,1],[64318,64320,2],[64321,64323,2],[64324,64326,2],[64327,64433,1],[64467,64829,1],[64848,64911,1],[64914,64967,1],[65008,65019,1],[65136,65140,1],[65142,65276,1],[65313,65338,1],[65345,65370,1],[65382,65470,1],[65474,65479,1],[65482,65487,1],[65490,65495,1],[65498,65500,1],[65536,65547,1],[65549,65574,1],[65576,65594,1],[65596,65597,1],[65599,65613,1],[65616,65629,1],[65664,65786,1],[66176,66204,1],[66208,66256,1],[66304,66335,1],[66349,66368,1],[66370,66377,1],[66384,66421,1],[66432,66461,1],[66464,66499,1],[66504,66511,1],[66560,66717,1],[66736,66771,1],[66776,66811,1],[66816,66855,1],[66864,66915,1],[66928,66938,1],[66940,66954,1],[66956,66962,1],[66964,66965,1],[66967,66977,1],[66979,66993,1],[66995,67001,1],[67003,67004,1],[67072,67382,1],[67392,67413,1],[67424,67431,1],[67456,67461,1],[67463,67504,1],[67506,67514,1],[67584,67589,1],[67592,67594,2],[67595,67637,1],[67639,67640,1],[67644,67647,3],[67648,67669,1],[67680,67702,1],[67712,67742,1],[67808,67826,1],[67828,67829,1],[67840,67861,1],[67872,67897,1],[67968,68023,1],[68030,68031,1],[68096,68112,16],[68113,68115,1],[68117,68119,1],[68121,68149,1],[68192,68220,1],[68224,68252,1],[68288,68295,1],[68297,68324,1],[68352,68405,1],[68416,68437,1],[68448,68466,1],[68480,68497,1],[68608,68680,1],[68736,68786,1],[68800,68850,1],[68864,68899,1],[69248,69289,1],[69296,69297,1],[69376,69404,1],[69415,69424,9],[69425,69445,1],[69488,69505,1],[69552,69572,1],[69600,69622,1],[69635,69687,1],[69745,69746,1],[69749,69763,14],[69764,69807,1],[69840,69864,1],[69891,69926,1],[69956,69959,3],[69968,70002,1],[70006,70019,13],[70020,70066,1],[70081,70084,1],[70106,70108,2],[70144,70161,1],[70163,70187,1],[70207,70208,1],[70272,70278,1],[70280,70282,2],[70283,70285,1],[70287,70301,1],[70303,70312,1],[70320,70366,1],[70405,70412,1],[70415,70416,1],[70419,70440,1],[70442,70448,1],[70450,70451,1],[70453,70457,1],[70461,70480,19],[70493,70497,1],[70656,70708,1],[70727,70730,1],[70751,70753,1],[70784,70831,1],[70852,70853,1],[70855,71040,185],[71041,71086,1],[71128,71131,1],[71168,71215,1],[71236,71296,60],[71297,71338,1],[71352,71424,72],[71425,71450,1],[71488,71494,1],[71680,71723,1],[71840,71903,1],[71935,71942,1],[71945,71948,3],[71949,71955,1],[71957,71958,1],[71960,71983,1],[71999,72001,2],[72096,72103,1],[72106,72144,1],[72161,72163,2],[72192,72203,11],[72204,72242,1],[72250,72272,22],[72284,72329,1],[72349,72368,19],[72369,72440,1],[72704,72712,1],[72714,72750,1],[72768,72818,50],[72819,72847,1],[72960,72966,1],[72968,72969,1],[72971,73008,1],[73030,73056,26],[73057,73061,1],[73063,73064,1],[73066,73097,1],[73112,73440,328],[73441,73458,1],[73474,73476,2],[73477,73488,1],[73490,73523,1],[73648,73728,80],[73729,74649,1],[74880,75075,1],[77712,77808,1],[77824,78895,1],[78913,78918,1],[82944,83526,1],[92160,92728,1],[92736,92766,1],[92784,92862,1],[92880,92909,1],[92928,92975,1],[92992,92995,1],[93027,93047,1],[93053,93071,1],[93760,93823,1],[93952,94026,1],[94032,94099,67],[94100,94111,1],[94176,94177,1],[94179,94208,29],[94209,100343,1],[100352,101589,1],[101632,101640,1],[110576,110579,1],[110581,110587,1],[110589,110590,1],[110592,110882,1],[110898,110928,30],[110929,110930,1],[110933,110948,15],[110949,110951,1],[110960,111355,1],[113664,113770,1],[113776,113788,1],[113792,113800,1],[113808,113817,1],[119808,119892,1],[119894,119964,1],[119966,119967,1],[119970,119973,3],[119974,119977,3],[119978,119980,1],[119982,119993,1],[119995,119997,2],[119998,120003,1],[120005,120069,1],[120071,120074,1],[120077,120084,1],[120086,120092,1],[120094,120121,1],[120123,120126,1],[120128,120132,1],[120134,120138,4],[120139,120144,1],[120146,120485,1],[120488,120512,1],[120514,120538,1],[120540,120570,1],[120572,120596,1],[120598,120628,1],[120630,120654,1],[120656,120686,1],[120688,120712,1],[120714,120744,1],[120746,120770,1],[120772,120779,1],[122624,122654,1],[122661,122666,1],[122928,122989,1],[123136,123180,1],[123191,123197,1],[123214,123536,322],[123537,123565,1],[123584,123627,1],[124112,124139,1],[124896,124902,1],[124904,124907,1],[124909,124910,1],[124912,124926,1],[124928,125124,1],[125184,125251,1],[125259,126464,1205],[126465,126467,1],[126469,126495,1],[126497,126498,1],[126500,126503,3],[126505,126514,1],[126516,126519,1],[126521,126523,2],[126530,126535,5],[126537,126541,2],[126542,126543,1],[126545,126546,1],[126548,126551,3],[126553,126561,2],[126562,126564,2],[126567,126570,1],[126572,126578,1],[126580,126583,1],[126585,126588,1],[126590,126592,2],[126593,126601,1],[126603,126619,1],[126625,126627,1],[126629,126633,1],[126635,126651,1],[131072,173791,1],[173824,177977,1],[177984,178205,1],[178208,183969,1],[183984,191456,1],[191472,192093,1],[194560,195101,1],[196608,201546,1],[201552,205743,1]];static foldL=[[837,837,1]];static Ll=[[97,122,1],[181,223,42],[224,246,1],[248,255,1],[257,311,2],[312,328,2],[329,375,2],[378,382,2],[383,384,1],[387,389,2],[392,396,4],[397,402,5],[405,409,4],[410,411,1],[414,417,3],[419,421,2],[424,426,2],[427,429,2],[432,436,4],[438,441,3],[442,445,3],[446,447,1],[454,460,3],[462,476,2],[477,495,2],[496,499,3],[501,505,4],[507,563,2],[564,569,1],[572,575,3],[576,578,2],[583,591,2],[592,659,1],[661,687,1],[881,883,2],[887,891,4],[892,893,1],[912,940,28],[941,974,1],[976,977,1],[981,983,1],[985,1007,2],[1008,1011,1],[1013,1019,3],[1020,1072,52],[1073,1119,1],[1121,1153,2],[1163,1215,2],[1218,1230,2],[1231,1327,2],[1376,1416,1],[4304,4346,1],[4349,4351,1],[5112,5117,1],[7296,7304,1],[7424,7467,1],[7531,7543,1],[7545,7578,1],[7681,7829,2],[7830,7837,1],[7839,7935,2],[7936,7943,1],[7952,7957,1],[7968,7975,1],[7984,7991,1],[8e3,8005,1],[8016,8023,1],[8032,8039,1],[8048,8061,1],[8064,8071,1],[8080,8087,1],[8096,8103,1],[8112,8116,1],[8118,8119,1],[8126,8130,4],[8131,8132,1],[8134,8135,1],[8144,8147,1],[8150,8151,1],[8160,8167,1],[8178,8180,1],[8182,8183,1],[8458,8462,4],[8463,8467,4],[8495,8505,5],[8508,8509,1],[8518,8521,1],[8526,8580,54],[11312,11359,1],[11361,11365,4],[11366,11372,2],[11377,11379,2],[11380,11382,2],[11383,11387,1],[11393,11491,2],[11492,11500,8],[11502,11507,5],[11520,11557,1],[11559,11565,6],[42561,42605,2],[42625,42651,2],[42787,42799,2],[42800,42801,1],[42803,42865,2],[42866,42872,1],[42874,42876,2],[42879,42887,2],[42892,42894,2],[42897,42899,2],[42900,42901,1],[42903,42921,2],[42927,42933,6],[42935,42947,2],[42952,42954,2],[42961,42969,2],[42998,43002,4],[43824,43866,1],[43872,43880,1],[43888,43967,1],[64256,64262,1],[64275,64279,1],[65345,65370,1],[66600,66639,1],[66776,66811,1],[66967,66977,1],[66979,66993,1],[66995,67001,1],[67003,67004,1],[68800,68850,1],[71872,71903,1],[93792,93823,1],[119834,119859,1],[119886,119892,1],[119894,119911,1],[119938,119963,1],[119990,119993,1],[119995,119997,2],[119998,120003,1],[120005,120015,1],[120042,120067,1],[120094,120119,1],[120146,120171,1],[120198,120223,1],[120250,12
180275,1],[120302,120327,1],[120354,120379,1],[120406,120431,1],[120458,120485,1],[120514,120538,1],[120540,120545,1],[120572,120596,1],[120598,120603,1],[120630,120654,1],[120656,120661,1],[120688,120712,1],[120714,120719,1],[120746,120770,1],[120772,120777,1],[120779,122624,1845],[122625,122633,1],[122635,122654,1],[122661,122666,1],[125218,125251,1]];static foldLl=[[65,90,1],[192,214,1],[216,222,1],[256,302,2],[306,310,2],[313,327,2],[330,376,2],[377,381,2],[385,386,1],[388,390,2],[391,393,2],[394,395,1],[398,401,1],[403,404,1],[406,408,1],[412,413,1],[415,416,1],[418,422,2],[423,425,2],[428,430,2],[431,433,2],[434,435,1],[437,439,2],[440,444,4],[452,453,1],[455,456,1],[458,459,1],[461,475,2],[478,494,2],[497,498,1],[500,502,2],[503,504,1],[506,562,2],[570,571,1],[573,574,1],[577,579,2],[580,582,1],[584,590,2],[837,880,43],[882,886,4],[895,902,7],[904,906,1],[908,910,2],[911,913,2],[914,929,1],[931,939,1],[975,984,9],[986,1006,2],[1012,1015,3],[1017,1018,1],[1021,1071,1],[1120,1152,2],[1162,1216,2],[1217,1229,2],[1232,1326,2],[1329,1366,1],[4256,4293,1],[4295,4301,6],[5024,5109,1],[7312,7354,1],[7357,7359,1],[7680,7828,2],[7838,7934,2],[7944,7951,1],[7960,7965,1],[7976,7983,1],[7992,7999,1],[8008,8013,1],[8025,8031,2],[8040,8047,1],[8072,8079,1],[8088,8095,1],[8104,8111,1],[8120,8124,1],[8136,8140,1],[8152,8155,1],[8168,8172,1],[8184,8188,1],[8486,8490,4],[8491,8498,7],[8579,11264,2685],[11265,11311,1],[11360,11362,2],[11363,11364,1],[11367,11373,2],[11374,11376,1],[11378,11381,3],[11390,11392,1],[11394,11490,2],[11499,11501,2],[11506,42560,31054],[42562,42604,2],[42624,42650,2],[42786,42798,2],[42802,42862,2],[42873,42877,2],[42878,42886,2],[42891,42893,2],[42896,42898,2],[42902,42922,2],[42923,42926,1],[42928,42932,1],[42934,42948,2],[42949,42951,1],[42953,42960,7],[42966,42968,2],[42997,65313,22316],[65314,65338,1],[66560,66599,1],[66736,66771,1],[66928,66938,1],[66940,66954,1],[66956,66962,1],[66964,66965,1],[68736,68786,1],[71840,71871,1],[93760,93791,1],[125184,125217,1]];static Lm=[[688,705,1],[710,721,1],[736,740,1],[748,750,2],[884,890,6],[1369,1600,231],[1765,1766,1],[2036,2037,1],[2042,2074,32],[2084,2088,4],[2249,2417,168],[3654,3782,128],[4348,6103,1755],[6211,6823,612],[7288,7293,1],[7468,7530,1],[7544,7579,35],[7580,7615,1],[8305,8319,14],[8336,8348,1],[11388,11389,1],[11631,11823,192],[12293,12337,44],[12338,12341,1],[12347,12445,98],[12446,12540,94],[12541,12542,1],[40981,42232,1251],[42233,42237,1],[42508,42623,115],[42652,42653,1],[42775,42783,1],[42864,42888,24],[42994,42996,1],[43e3,43001,1],[43471,43494,23],[43632,43741,109],[43763,43764,1],[43868,43871,1],[43881,65392,21511],[65438,65439,1],[67456,67461,1],[67463,67504,1],[67506,67514,1],[92992,92995,1],[94099,94111,1],[94176,94177,1],[94179,110576,16397],[110577,110579,1],[110581,110587,1],[110589,110590,1],[122928,122989,1],[123191,123197,1],[124139,125259,1120]];static Lo=[[170,186,16],[443,448,5],[449,451,1],[660,1488,828],[1489,1514,1],[1519,1522,1],[1568,1599,1],[1601,1610,1],[1646,1647,1],[1649,1747,1],[1749,1774,25],[1775,1786,11],[1787,1788,1],[1791,1808,17],[1810,1839,1],[1869,1957,1],[1969,1994,25],[1995,2026,1],[2048,2069,1],[2112,2136,1],[2144,2154,1],[2160,2183,1],[2185,2190,1],[2208,2248,1],[2308,2361,1],[2365,2384,19],[2392,2401,1],[2418,2432,1],[2437,2444,1],[2447,2448,1],[2451,2472,1],[2474,2480,1],[2482,2486,4],[2487,2489,1],[2493,2510,17],[2524,2525,1],[2527,2529,1],[2544,2545,1],[2556,2565,9],[2566,2570,1],[2575,2576,1],[2579,2600,1],[2602,2608,1],[2610,2611,1],[2613,2614,1],[2616,2617,1],[2649,2652,1],[2654,2674,20],[2675,2676,1],[2693,2701,1],[2703,2705,1],[2707,2728,1],[2730,2736,1],[2738,2739,1],[2741,2745,1],[2749,2768,19],[2784,2785,1],[2809,2821,12],[2822,2828,1],[2831,2832,1],[2835,2856,1],[2858,2864,1],[2866,2867,1],[2869,2873,1],[2877,2908,31],[2909,2911,2],[2912,2913,1],[2929,2947,18],[2949,2954,1],[2958,2960,1],[2962,2965,1],[2969,2970,1],[2972,2974,2],[2975,2979,4],[2980,2984,4],[2985,2986,1],[2990,3001,1],[3024,3077,53],[3078,3084,1],[3086,3088,1],[3090,3112,1],[3114,3129,1],[3133,3160,27],[3161,3162,1],[3165,3168,3],[3169,3200,31],[3205,3212,1],[3214,3216,1],[3218,3240,1],[3242,3251,1],[3253,3257,1],[3261,3293,32],[3294,3296,2],[3297,3313,16],[3314,3332,18],[3333,3340,1],[3342,3344,1],[3346,3386,1],[3389,3406,17],[3412,3414,1],[3423,3425,1],[3450,3455,1],[3461,3478,1],[3482,3505,1],[3507,3515,1],[3517,3520,3],[3521,3526,1],[3585,3632,1],[3634,3635,1],[3648,3653,1],[3713,3714,1],[3716,3718,2],[3719,3722,1],[3724,3747,1],[3749,3751,2],[3752,3760,1],[3762,3763,1],[3773,3776,3],[3777,3780,1],[3804,3807,1],[3840,3904,64],[3905,3911,1],[3913,3948,1],[3976,3980,1],[4096,4138,1],[4159,4176,17],[4177,4181,1],[4186,4189,1],[4193,4197,4],[4198,4206,8],[4207,4208,1],[4213,4225,1],[4238,4352,114],[4353,4680,1],[4682,4685,1],[4688,4694,1],[4696,4698,2],[4699,4701,1],[4704,4744,1],[4746,4749,1],[4752,4784,1],[4786,4789,1],[4792,4798,1],[4800,4802,2],[4803,4805,1],[4808,4822,1],[4824,4880,1],[4882,4885,1],[4888,4954,1],[4992,5007,1],[5121,5740,1],[5743,5759,1],[5761,5786,1],[5792,5866,1],[5873,5880,1],[5888,5905,1],[5919,5937,1],[5952,5969,1],[5984,5996,1],[5998,6e3,1],[6016,6067,1],[6108,6176,68],[6177,6210,1],[6212,6264,1],[6272,6276,1],[6279,6312,1],[6314,6320,6],[6321,6389,1],[6400,6430,1],[6480,6509,1],[6512,6516,1],[6528,6571,1],[6576,6601,1],[6656,6678,1],[6688,6740,1],[6917,6963,1],[6981,6988,1],[7043,7072,1],[7086,7087,1],[7098,7141,1],[7168,7203,1],[7245,7247,1],[7258,7287,1],[7401,7404,1],[7406,7411,1],[7413,7414,1],[7418,8501,1083],[8502,8504,1],[11568,11623,1],[11648,11670,1],[11680,11686,1],[11688,11694,1],[11696,11702,1],[11704,11710,1],[11712,11718,1],[11720,11726,1],[11728,11734,1],[11736,11
18742,1],[12294,12348,54],[12353,12438,1],[12447,12449,2],[12450,12538,1],[12543,12549,6],[12550,12591,1],[12593,12686,1],[12704,12735,1],[12784,12799,1],[13312,19903,1],[19968,40980,1],[40982,42124,1],[42192,42231,1],[42240,42507,1],[42512,42527,1],[42538,42539,1],[42606,42656,50],[42657,42725,1],[42895,42999,104],[43003,43009,1],[43011,43013,1],[43015,43018,1],[43020,43042,1],[43072,43123,1],[43138,43187,1],[43250,43255,1],[43259,43261,2],[43262,43274,12],[43275,43301,1],[43312,43334,1],[43360,43388,1],[43396,43442,1],[43488,43492,1],[43495,43503,1],[43514,43518,1],[43520,43560,1],[43584,43586,1],[43588,43595,1],[43616,43631,1],[43633,43638,1],[43642,43646,4],[43647,43695,1],[43697,43701,4],[43702,43705,3],[43706,43709,1],[43712,43714,2],[43739,43740,1],[43744,43754,1],[43762,43777,15],[43778,43782,1],[43785,43790,1],[43793,43798,1],[43808,43814,1],[43816,43822,1],[43968,44002,1],[44032,55203,1],[55216,55238,1],[55243,55291,1],[63744,64109,1],[64112,64217,1],[64285,64287,2],[64288,64296,1],[64298,64310,1],[64312,64316,1],[64318,64320,2],[64321,64323,2],[64324,64326,2],[64327,64433,1],[64467,64829,1],[64848,64911,1],[64914,64967,1],[65008,65019,1],[65136,65140,1],[65142,65276,1],[65382,65391,1],[65393,65437,1],[65440,65470,1],[65474,65479,1],[65482,65487,1],[65490,65495,1],[65498,65500,1],[65536,65547,1],[65549,65574,1],[65576,65594,1],[65596,65597,1],[65599,65613,1],[65616,65629,1],[65664,65786,1],[66176,66204,1],[66208,66256,1],[66304,66335,1],[66349,66368,1],[66370,66377,1],[66384,66421,1],[66432,66461,1],[66464,66499,1],[66504,66511,1],[66640,66717,1],[66816,66855,1],[66864,66915,1],[67072,67382,1],[67392,67413,1],[67424,67431,1],[67584,67589,1],[67592,67594,2],[67595,67637,1],[67639,67640,1],[67644,67647,3],[67648,67669,1],[67680,67702,1],[67712,67742,1],[67808,67826,1],[67828,67829,1],[67840,67861,1],[67872,67897,1],[67968,68023,1],[68030,68031,1],[68096,68112,16],[68113,68115,1],[68117,68119,1],[68121,68149,1],[68192,68220,1],[68224,68252,1],[68288,68295,1],[68297,68324,1],[68352,68405,1],[68416,68437,1],[68448,68466,1],[68480,68497,1],[68608,68680,1],[68864,68899,1],[69248,69289,1],[69296,69297,1],[69376,69404,1],[69415,69424,9],[69425,69445,1],[69488,69505,1],[69552,69572,1],[69600,69622,1],[69635,69687,1],[69745,69746,1],[69749,69763,14],[69764,69807,1],[69840,69864,1],[69891,69926,1],[69956,69959,3],[69968,70002,1],[70006,70019,13],[70020,70066,1],[70081,70084,1],[70106,70108,2],[70144,70161,1],[70163,70187,1],[70207,70208,1],[70272,70278,1],[70280,70282,2],[70283,70285,1],[70287,70301,1],[70303,70312,1],[70320,70366,1],[70405,70412,1],[70415,70416,1],[70419,70440,1],[70442,70448,1],[70450,70451,1],[70453,70457,1],[70461,70480,19],[70493,70497,1],[70656,70708,1],[70727,70730,1],[70751,70753,1],[70784,70831,1],[70852,70853,1],[70855,71040,185],[71041,71086,1],[71128,71131,1],[71168,71215,1],[71236,71296,60],[71297,71338,1],[71352,71424,72],[71425,71450,1],[71488,71494,1],[71680,71723,1],[71935,71942,1],[71945,71948,3],[71949,71955,1],[71957,71958,1],[71960,71983,1],[71999,72001,2],[72096,72103,1],[72106,72144,1],[72161,72163,2],[72192,72203,11],[72204,72242,1],[72250,72272,22],[72284,72329,1],[72349,72368,19],[72369,72440,1],[72704,72712,1],[72714,72750,1],[72768,72818,50],[72819,72847,1],[72960,72966,1],[72968,72969,1],[72971,73008,1],[73030,73056,26],[73057,73061,1],[73063,73064,1],[73066,73097,1],[73112,73440,328],[73441,73458,1],[73474,73476,2],[73477,73488,1],[73490,73523,1],[73648,73728,80],[73729,74649,1],[74880,75075,1],[77712,77808,1],[77824,78895,1],[78913,78918,1],[82944,83526,1],[92160,92728,1],[92736,92766,1],[92784,92862,1],[92880,92909,1],[92928,92975,1],[93027,93047,1],[93053,93071,1],[93952,94026,1],[94032,94208,176],[94209,100343,1],[100352,101589,1],[101632,101640,1],[110592,110882,1],[110898,110928,30],[110929,110930,1],[110933,110948,15],[110949,110951,1],[110960,111355,1],[113664,113770,1],[113776,113788,1],[113792,113800,1],[113808,113817,1],[122634,123136,502],[123137,123180,1],[123214,123536,322],[123537,123565,1],[123584,123627,1],[124112,124138,1],[124896,124902,1],[124904,124907,1],[124909,124910,1],[124912,124926,1],[124928,125124,1],[126464,126467,1],[126469,126495,1],[126497,126498,1],[126500,126503,3],[126505,126514,1],[126516,126519,1],[126521,126523,2],[126530,126535,5],[126537,126541,2],[126542,126543,1],[126545,126546,1],[126548,126551,3],[126553,126561,2],[126562,126564,2],[126567,126570,1],[126572,126578,1],[126580,126583,1],[126585,126588,1],[126590,126592,2],[126593,126601,1],[126603,126619,1],[126625,126627,1],[126629,126633,1],[126635,126651,1],[131072,173791,1],[173824,177977,1],[177984,178205,1],[178208,183969,1],[183984,191456,1],[191472,192093,1],[194560,195101,1],[196608,201546,1],[201552,205743,1]];static Lt=[[453,459,3],[498,8072,7574],[8073,8079,1],[8088,8095,1],[8104,8111,1],[8124,8140,16],[8188,8188,1]];static foldLt=[[452,454,2],[455,457,2],[458,460,2],[497,499,2],[8064,8071,1],[8080,8087,1],[8096,8103,1],[8115,8131,16],[8179,8179,1]];static Lu=[[65,90,1],[192,214,1],[216,222,1],[256,310,2],[313,327,2],[330,376,2],[377,381,2],[385,386,1],[388,390,2],[391,393,2],[394,395,1],[398,401,1],[403,404,1],[406,408,1],[412,413,1],[415,416,1],[418,422,2],[423,425,2],[428,430,2],[431,433,2],[434,435,1],[437,439,2],[440,444,4],[452,461,3],[463,475,2],[478,494,2],[497,500,3],[502,504,1],[506,562,2],[570,571,1],[573,574,1],[577,579,2],[580,582,1],[584,590,2],[880,882,2],[886,895,9],[902,904,2],[905,906,1],[908,910,2],[911,913,2],[914,929,1],[931,939,1],[975,978,3],[979,980,1],[984,1006,2],[1012,1015,3],[1017,1018,1],[1021,10
1871,1],[1120,1152,2],[1162,1216,2],[1217,1229,2],[1232,1326,2],[1329,1366,1],[4256,4293,1],[4295,4301,6],[5024,5109,1],[7312,7354,1],[7357,7359,1],[7680,7828,2],[7838,7934,2],[7944,7951,1],[7960,7965,1],[7976,7983,1],[7992,7999,1],[8008,8013,1],[8025,8031,2],[8040,8047,1],[8120,8123,1],[8136,8139,1],[8152,8155,1],[8168,8172,1],[8184,8187,1],[8450,8455,5],[8459,8461,1],[8464,8466,1],[8469,8473,4],[8474,8477,1],[8484,8490,2],[8491,8493,1],[8496,8499,1],[8510,8511,1],[8517,8579,62],[11264,11311,1],[11360,11362,2],[11363,11364,1],[11367,11373,2],[11374,11376,1],[11378,11381,3],[11390,11392,1],[11394,11490,2],[11499,11501,2],[11506,42560,31054],[42562,42604,2],[42624,42650,2],[42786,42798,2],[42802,42862,2],[42873,42877,2],[42878,42886,2],[42891,42893,2],[42896,42898,2],[42902,42922,2],[42923,42926,1],[42928,42932,1],[42934,42948,2],[42949,42951,1],[42953,42960,7],[42966,42968,2],[42997,65313,22316],[65314,65338,1],[66560,66599,1],[66736,66771,1],[66928,66938,1],[66940,66954,1],[66956,66962,1],[66964,66965,1],[68736,68786,1],[71840,71871,1],[93760,93791,1],[119808,119833,1],[119860,119885,1],[119912,119937,1],[119964,119966,2],[119967,119973,3],[119974,119977,3],[119978,119980,1],[119982,119989,1],[120016,120041,1],[120068,120069,1],[120071,120074,1],[120077,120084,1],[120086,120092,1],[120120,120121,1],[120123,120126,1],[120128,120132,1],[120134,120138,4],[120139,120144,1],[120172,120197,1],[120224,120249,1],[120276,120301,1],[120328,120353,1],[120380,120405,1],[120432,120457,1],[120488,120512,1],[120546,120570,1],[120604,120628,1],[120662,120686,1],[120720,120744,1],[120778,125184,4406],[125185,125217,1]];static Upper=this.Lu;static foldLu=[[97,122,1],[181,223,42],[224,246,1],[248,255,1],[257,303,2],[307,311,2],[314,328,2],[331,375,2],[378,382,2],[383,384,1],[387,389,2],[392,396,4],[402,405,3],[409,410,1],[414,417,3],[419,421,2],[424,429,5],[432,436,4],[438,441,3],[445,447,2],[453,454,1],[456,457,1],[459,460,1],[462,476,2],[477,495,2],[498,499,1],[501,505,4],[507,543,2],[547,563,2],[572,575,3],[576,578,2],[583,591,2],[592,596,1],[598,599,1],[601,603,2],[604,608,4],[609,613,2],[614,616,2],[617,620,1],[623,625,2],[626,629,3],[637,640,3],[642,643,1],[647,652,1],[658,669,11],[670,837,167],[881,883,2],[887,891,4],[892,893,1],[940,943,1],[945,974,1],[976,977,1],[981,983,1],[985,1007,2],[1008,1011,1],[1013,1019,3],[1072,1119,1],[1121,1153,2],[1163,1215,2],[1218,1230,2],[1231,1327,2],[1377,1414,1],[4304,4346,1],[4349,4351,1],[5112,5117,1],[7296,7304,1],[7545,7549,4],[7566,7681,115],[7683,7829,2],[7835,7841,6],[7843,7935,2],[7936,7943,1],[7952,7957,1],[7968,7975,1],[7984,7991,1],[8e3,8005,1],[8017,8023,2],[8032,8039,1],[8048,8061,1],[8112,8113,1],[8126,8144,18],[8145,8160,15],[8161,8165,4],[8526,8580,54],[11312,11359,1],[11361,11365,4],[11366,11372,2],[11379,11382,3],[11393,11491,2],[11500,11502,2],[11507,11520,13],[11521,11557,1],[11559,11565,6],[42561,42605,2],[42625,42651,2],[42787,42799,2],[42803,42863,2],[42874,42876,2],[42879,42887,2],[42892,42897,5],[42899,42900,1],[42903,42921,2],[42933,42947,2],[42952,42954,2],[42961,42967,6],[42969,42998,29],[43859,43888,29],[43889,43967,1],[65345,65370,1],[66600,66639,1],[66776,66811,1],[66967,66977,1],[66979,66993,1],[66995,67001,1],[67003,67004,1],[68800,68850,1],[71872,71903,1],[93792,93823,1],[125218,125251,1]];static M=[[768,879,1],[1155,1161,1],[1425,1469,1],[1471,1473,2],[1474,1476,2],[1477,1479,2],[1552,1562,1],[1611,1631,1],[1648,1750,102],[1751,1756,1],[1759,1764,1],[1767,1768,1],[1770,1773,1],[1809,1840,31],[1841,1866,1],[1958,1968,1],[2027,2035,1],[2045,2070,25],[2071,2073,1],[2075,2083,1],[2085,2087,1],[2089,2093,1],[2137,2139,1],[2200,2207,1],[2250,2273,1],[2275,2307,1],[2362,2364,1],[2366,2383,1],[2385,2391,1],[2402,2403,1],[2433,2435,1],[2492,2494,2],[2495,2500,1],[2503,2504,1],[2507,2509,1],[2519,2530,11],[2531,2558,27],[2561,2563,1],[2620,2622,2],[2623,2626,1],[2631,2632,1],[2635,2637,1],[2641,2672,31],[2673,2677,4],[2689,2691,1],[2748,2750,2],[2751,2757,1],[2759,2761,1],[2763,2765,1],[2786,2787,1],[2810,2815,1],[2817,2819,1],[2876,2878,2],[2879,2884,1],[2887,2888,1],[2891,2893,1],[2901,2903,1],[2914,2915,1],[2946,3006,60],[3007,3010,1],[3014,3016,1],[3018,3021,1],[3031,3072,41],[3073,3076,1],[3132,3134,2],[3135,3140,1],[3142,3144,1],[3146,3149,1],[3157,3158,1],[3170,3171,1],[3201,3203,1],[3260,3262,2],[3263,3268,1],[3270,3272,1],[3274,3277,1],[3285,3286,1],[3298,3299,1],[3315,3328,13],[3329,3331,1],[3387,3388,1],[3390,3396,1],[3398,3400,1],[3402,3405,1],[3415,3426,11],[3427,3457,30],[3458,3459,1],[3530,3535,5],[3536,3540,1],[3542,3544,2],[3545,3551,1],[3570,3571,1],[3633,3636,3],[3637,3642,1],[3655,3662,1],[3761,3764,3],[3765,3772,1],[3784,3790,1],[3864,3865,1],[3893,3897,2],[3902,3903,1],[3953,3972,1],[3974,3975,1],[3981,3991,1],[3993,4028,1],[4038,4139,101],[4140,4158,1],[4182,4185,1],[4190,4192,1],[4194,4196,1],[4199,4205,1],[4209,4212,1],[4226,4237,1],[4239,4250,11],[4251,4253,1],[4957,4959,1],[5906,5909,1],[5938,5940,1],[5970,5971,1],[6002,6003,1],[6068,6099,1],[6109,6155,46],[6156,6157,1],[6159,6277,118],[6278,6313,35],[6432,6443,1],[6448,6459,1],[6679,6683,1],[6741,6750,1],[6752,6780,1],[6783,6832,49],[6833,6862,1],[6912,6916,1],[6964,6980,1],[7019,7027,1],[7040,7042,1],[7073,7085,
181],[7142,7155,1],[7204,7223,1],[7376,7378,1],[7380,7400,1],[7405,7412,7],[7415,7417,1],[7616,7679,1],[8400,8432,1],[11503,11505,1],[11647,11744,97],[11745,11775,1],[12330,12335,1],[12441,12442,1],[42607,42610,1],[42612,42621,1],[42654,42655,1],[42736,42737,1],[43010,43014,4],[43019,43043,24],[43044,43047,1],[43052,43136,84],[43137,43188,51],[43189,43205,1],[43232,43249,1],[43263,43302,39],[43303,43309,1],[43335,43347,1],[43392,43395,1],[43443,43456,1],[43493,43561,68],[43562,43574,1],[43587,43596,9],[43597,43643,46],[43644,43645,1],[43696,43698,2],[43699,43700,1],[43703,43704,1],[43710,43711,1],[43713,43755,42],[43756,43759,1],[43765,43766,1],[44003,44010,1],[44012,44013,1],[64286,65024,738],[65025,65039,1],[65056,65071,1],[66045,66272,227],[66422,66426,1],[68097,68099,1],[68101,68102,1],[68108,68111,1],[68152,68154,1],[68159,68325,166],[68326,68900,574],[68901,68903,1],[69291,69292,1],[69373,69375,1],[69446,69456,1],[69506,69509,1],[69632,69634,1],[69688,69702,1],[69744,69747,3],[69748,69759,11],[69760,69762,1],[69808,69818,1],[69826,69888,62],[69889,69890,1],[69927,69940,1],[69957,69958,1],[70003,70016,13],[70017,70018,1],[70067,70080,1],[70089,70092,1],[70094,70095,1],[70188,70199,1],[70206,70209,3],[70367,70378,1],[70400,70403,1],[70459,70460,1],[70462,70468,1],[70471,70472,1],[70475,70477,1],[70487,70498,11],[70499,70502,3],[70503,70508,1],[70512,70516,1],[70709,70726,1],[70750,70832,82],[70833,70851,1],[71087,71093,1],[71096,71104,1],[71132,71133,1],[71216,71232,1],[71339,71351,1],[71453,71467,1],[71724,71738,1],[71984,71989,1],[71991,71992,1],[71995,71998,1],[72e3,72002,2],[72003,72145,142],[72146,72151,1],[72154,72160,1],[72164,72193,29],[72194,72202,1],[72243,72249,1],[72251,72254,1],[72263,72273,10],[72274,72283,1],[72330,72345,1],[72751,72758,1],[72760,72767,1],[72850,72871,1],[72873,72886,1],[73009,73014,1],[73018,73020,2],[73021,73023,2],[73024,73029,1],[73031,73098,67],[73099,73102,1],[73104,73105,1],[73107,73111,1],[73459,73462,1],[73472,73473,1],[73475,73524,49],[73525,73530,1],[73534,73538,1],[78912,78919,7],[78920,78933,1],[92912,92916,1],[92976,92982,1],[94031,94033,2],[94034,94087,1],[94095,94098,1],[94180,94192,12],[94193,113821,19628],[113822,118528,4706],[118529,118573,1],[118576,118598,1],[119141,119145,1],[119149,119154,1],[119163,119170,1],[119173,119179,1],[119210,119213,1],[119362,119364,1],[121344,121398,1],[121403,121452,1],[121461,121476,15],[121499,121503,1],[121505,121519,1],[122880,122886,1],[122888,122904,1],[122907,122913,1],[122915,122916,1],[122918,122922,1],[123023,123184,161],[123185,123190,1],[123566,123628,62],[123629,123631,1],[124140,124143,1],[125136,125142,1],[125252,125258,1],[917760,917999,1]];static foldM=[[921,953,32],[8126,8126,1]];static Mc=[[2307,2363,56],[2366,2368,1],[2377,2380,1],[2382,2383,1],[2434,2435,1],[2494,2496,1],[2503,2504,1],[2507,2508,1],[2519,2563,44],[2622,2624,1],[2691,2750,59],[2751,2752,1],[2761,2763,2],[2764,2818,54],[2819,2878,59],[2880,2887,7],[2888,2891,3],[2892,2903,11],[3006,3007,1],[3009,3010,1],[3014,3016,1],[3018,3020,1],[3031,3073,42],[3074,3075,1],[3137,3140,1],[3202,3203,1],[3262,3264,2],[3265,3268,1],[3271,3272,1],[3274,3275,1],[3285,3286,1],[3315,3330,15],[3331,3390,59],[3391,3392,1],[3398,3400,1],[3402,3404,1],[3415,3458,43],[3459,3535,76],[3536,3537,1],[3544,3551,1],[3570,3571,1],[3902,3903,1],[3967,4139,172],[4140,4145,5],[4152,4155,3],[4156,4182,26],[4183,4194,11],[4195,4196,1],[4199,4205,1],[4227,4228,1],[4231,4236,1],[4239,4250,11],[4251,4252,1],[5909,5940,31],[6070,6078,8],[6079,6085,1],[6087,6088,1],[6435,6438,1],[6441,6443,1],[6448,6449,1],[6451,6456,1],[6681,6682,1],[6741,6743,2],[6753,6755,2],[6756,6765,9],[6766,6770,1],[6916,6965,49],[6971,6973,2],[6974,6977,1],[6979,6980,1],[7042,7073,31],[7078,7079,1],[7082,7143,61],[7146,7148,1],[7150,7154,4],[7155,7204,49],[7205,7211,1],[7220,7221,1],[7393,7415,22],[12334,12335,1],[43043,43044,1],[43047,43136,89],[43137,43188,51],[43189,43203,1],[43346,43347,1],[43395,43444,49],[43445,43450,5],[43451,43454,3],[43455,43456,1],[43567,43568,1],[43571,43572,1],[43597,43643,46],[43645,43755,110],[43758,43759,1],[43765,44003,238],[44004,44006,2],[44007,44009,2],[44010,44012,2],[69632,69634,2],[69762,69808,46],[69809,69810,1],[69815,69816,1],[69932,69957,25],[69958,70018,60],[70067,70069,1],[70079,70080,1],[70094,70188,94],[70189,70190,1],[70194,70195,1],[70197,70368,171],[70369,70370,1],[70402,70403,1],[70462,70463,1],[70465,70468,1],[70471,70472,1],[70475,70477,1],[70487,70498,11],[70499,70709,210],[70710,70711,1],[70720,70721,1],[70725,70832,107],[70833,70834,1],[70841,70843,2],[70844,70846,1],[70849,71087,238],[71088,71089,1],[71096,71099,1],[71102,71216,114],[71217,71218,1],[71227,71228,1],[71230,71340,110],[71342,71343,1],[71350,71456,106],[71457,71462,5],[71724,71726,1],[71736,71984,248],[71985,71989,1],[71991,71992,1],[71997,72e3,3],[72002,72145,143],[72146,72147,1],[72156,72159,1],[72164,72249,85],[72279,72280,1],[72343,72751,408],[72766,72873,107],[72881,72884,3],[73098,73102,1],[73107,73108,1],[73110,73461,351],[73462,73475,13],[73524,73525,1],[73534,73535,1],[73537,94033,20496],[94034,94087,1],[94192,94193,1],[119141,119142,1],[119149,119154,1]];static Me=[[1160,1161,1],[6846,8413,1567],[8414,8416,1],[8418,8420,1],[42608,42610,1]];static Mn=[[768,879,1],[1155,1159,1],[1425,1469,1],[1471,1473,2],[1474,1476,2],[1477,1479,2],[1552,1562,1],[1611,1631,1],[1648,1750,102],[1751,1756,1],[1759,1764,1],[1767,1768,1],[1770,1773,1],[1809,1840,31],[1841,1866,1],[1958,1968,1],[2027,2035,1],[2045,2070,25],[2071,2073,1],[2075,2083,1],[2085,2087,
181],[2089,2093,1],[2137,2139,1],[2200,2207,1],[2250,2273,1],[2275,2306,1],[2362,2364,2],[2369,2376,1],[2381,2385,4],[2386,2391,1],[2402,2403,1],[2433,2492,59],[2497,2500,1],[2509,2530,21],[2531,2558,27],[2561,2562,1],[2620,2625,5],[2626,2631,5],[2632,2635,3],[2636,2637,1],[2641,2672,31],[2673,2677,4],[2689,2690,1],[2748,2753,5],[2754,2757,1],[2759,2760,1],[2765,2786,21],[2787,2810,23],[2811,2815,1],[2817,2876,59],[2879,2881,2],[2882,2884,1],[2893,2901,8],[2902,2914,12],[2915,2946,31],[3008,3021,13],[3072,3076,4],[3132,3134,2],[3135,3136,1],[3142,3144,1],[3146,3149,1],[3157,3158,1],[3170,3171,1],[3201,3260,59],[3263,3270,7],[3276,3277,1],[3298,3299,1],[3328,3329,1],[3387,3388,1],[3393,3396,1],[3405,3426,21],[3427,3457,30],[3530,3538,8],[3539,3540,1],[3542,3633,91],[3636,3642,1],[3655,3662,1],[3761,3764,3],[3765,3772,1],[3784,3790,1],[3864,3865,1],[3893,3897,2],[3953,3966,1],[3968,3972,1],[3974,3975,1],[3981,3991,1],[3993,4028,1],[4038,4141,103],[4142,4144,1],[4146,4151,1],[4153,4154,1],[4157,4158,1],[4184,4185,1],[4190,4192,1],[4209,4212,1],[4226,4229,3],[4230,4237,7],[4253,4957,704],[4958,4959,1],[5906,5908,1],[5938,5939,1],[5970,5971,1],[6002,6003,1],[6068,6069,1],[6071,6077,1],[6086,6089,3],[6090,6099,1],[6109,6155,46],[6156,6157,1],[6159,6277,118],[6278,6313,35],[6432,6434,1],[6439,6440,1],[6450,6457,7],[6458,6459,1],[6679,6680,1],[6683,6742,59],[6744,6750,1],[6752,6754,2],[6757,6764,1],[6771,6780,1],[6783,6832,49],[6833,6845,1],[6847,6862,1],[6912,6915,1],[6964,6966,2],[6967,6970,1],[6972,6978,6],[7019,7027,1],[7040,7041,1],[7074,7077,1],[7080,7081,1],[7083,7085,1],[7142,7144,2],[7145,7149,4],[7151,7153,1],[7212,7219,1],[7222,7223,1],[7376,7378,1],[7380,7392,1],[7394,7400,1],[7405,7412,7],[7416,7417,1],[7616,7679,1],[8400,8412,1],[8417,8421,4],[8422,8432,1],[11503,11505,1],[11647,11744,97],[11745,11775,1],[12330,12333,1],[12441,12442,1],[42607,42612,5],[42613,42621,1],[42654,42655,1],[42736,42737,1],[43010,43014,4],[43019,43045,26],[43046,43052,6],[43204,43205,1],[43232,43249,1],[43263,43302,39],[43303,43309,1],[43335,43345,1],[43392,43394,1],[43443,43446,3],[43447,43449,1],[43452,43453,1],[43493,43561,68],[43562,43566,1],[43569,43570,1],[43573,43574,1],[43587,43596,9],[43644,43696,52],[43698,43700,1],[43703,43704,1],[43710,43711,1],[43713,43756,43],[43757,43766,9],[44005,44008,3],[44013,64286,20273],[65024,65039,1],[65056,65071,1],[66045,66272,227],[66422,66426,1],[68097,68099,1],[68101,68102,1],[68108,68111,1],[68152,68154,1],[68159,68325,166],[68326,68900,574],[68901,68903,1],[69291,69292,1],[69373,69375,1],[69446,69456,1],[69506,69509,1],[69633,69688,55],[69689,69702,1],[69744,69747,3],[69748,69759,11],[69760,69761,1],[69811,69814,1],[69817,69818,1],[69826,69888,62],[69889,69890,1],[69927,69931,1],[69933,69940,1],[70003,70016,13],[70017,70070,53],[70071,70078,1],[70089,70092,1],[70095,70191,96],[70192,70193,1],[70196,70198,2],[70199,70206,7],[70209,70367,158],[70371,70378,1],[70400,70401,1],[70459,70460,1],[70464,70502,38],[70503,70508,1],[70512,70516,1],[70712,70719,1],[70722,70724,1],[70726,70750,24],[70835,70840,1],[70842,70847,5],[70848,70850,2],[70851,71090,239],[71091,71093,1],[71100,71101,1],[71103,71104,1],[71132,71133,1],[71219,71226,1],[71229,71231,2],[71232,71339,107],[71341,71344,3],[71345,71349,1],[71351,71453,102],[71454,71455,1],[71458,71461,1],[71463,71467,1],[71727,71735,1],[71737,71738,1],[71995,71996,1],[71998,72003,5],[72148,72151,1],[72154,72155,1],[72160,72193,33],[72194,72202,1],[72243,72248,1],[72251,72254,1],[72263,72273,10],[72274,72278,1],[72281,72283,1],[72330,72342,1],[72344,72345,1],[72752,72758,1],[72760,72765,1],[72767,72850,83],[72851,72871,1],[72874,72880,1],[72882,72883,1],[72885,72886,1],[73009,73014,1],[73018,73020,2],[73021,73023,2],[73024,73029,1],[73031,73104,73],[73105,73109,4],[73111,73459,348],[73460,73472,12],[73473,73526,53],[73527,73530,1],[73536,73538,2],[78912,78919,7],[78920,78933,1],[92912,92916,1],[92976,92982,1],[94031,94095,64],[94096,94098,1],[94180,113821,19641],[113822,118528,4706],[118529,118573,1],[118576,118598,1],[119143,119145,1],[119163,119170,1],[119173,119179,1],[119210,119213,1],[119362,119364,1],[121344,121398,1],[121403,121452,1],[121461,121476,15],[121499,121503,1],[121505,121519,1],[122880,122886,1],[122888,122904,1],[122907,122913,1],[122915,122916,1],[122918,122922,1],[123023,123184,161],[123185,123190,1],[123566,123628,62],[123629,123631,1],[124140,124143,1],[125136,125142,1],[125252,125258,1],[917760,917999,1]];static foldMn=[[921,953,32],[8126,8126,1]];static N=[[48,57,1],[178,179,1],[185,188,3],[189,190,1],[1632,1641,1],[1776,1785,1],[1984,1993,1],[2406,2415,1],[2534,2543,1],[2548,2553,1],[2662,2671,1],[2790,2799,1],[2918,2927,1],[2930,2935,1],[3046,3058,1],[3174,3183,1],[3192,3198,1],[3302,3311,1],[3416,3422,1],[3430,3448,1],[3558,3567,1],[3664,3673,1],[3792,3801,1],[3872,3891,1],[4160,4169,1],[4240,4249,1],[4969,4988,1],[5870,5872,1],[6112,6121,1],[6128,6137,1],[6160,6169,1],[6470,6479,1],[6608,6618,1],[6784,6793,1],[6800,6809,1],[6992,7001,1],[7088,7097,1],[7232,7241,1],[7248,7257,1],[8304,8308,4],[8309,8313,1],[8320,8329,1],[8528,8578,1],[8581,8585,1],[9312,9371,1],[9450,9471,1],[10102,10131,1],[11517,12295,778],[12321,12329,1],[12344,12346,1],[12690,12693,1],[12832,12841,1],[12872,12879,1],[12881,12895,1],[12928,12937,1],[12977,12991,1],[42528,42537,1],[42726,42735,1],[43056,43061,1],[43216,43225,1],[43264,43273,1],[43472,43481,1],[43504,43513,1],[43600,43609,1],[44016,44025,1],[65296,65305,1],[65799,65843,1],[65856,65912,1],[65930,65931,1],[66273,66299,1],[66336,66339,1],[66369,66378,9],[66513,66517,1],[66720,66729,1],[67672,67679,1],[67705,67711,1],[67751,67759,1],[67835,67839,1],[67862,67867,1],[68028,68029,1],[68032,68047,1],[68050,68095,1],[68160,68168,1],[68221,68222,1],[68253,68255,1],[68331,68335,1],[68440,68447,1],[68472,68479,1],[68521,68527,1],[68858,68863,1],[68912,68921,1],[69216,69246,1],[69405,69414,1],[69457,69460,1],[69573,69579,1],[69714,69743,1],[69872,69881,1],[69942,69951,1],[70096,70105,1],[70113,70132,1],[70384,70393,1],[70736,70745,1],[70864,70873,1],[71248,71257,1],[71360,71369,1],[71472,71483,1],[71904,71922,1],[72016,72025,1],[72784,72812,1],[73040,73049,1],[73120,73129,1],[73552,73561,1],[73664,73684,1],[74752,74862,1],[92768,92777,1],[92864,92873,1],[93008,93017,1],[93019,93025,1],[93824,93846,1],[119488,119507,1],[119520,119539,1],[119648,119672,1],[120782,120831,1],[123200,123209,1],[123632,123641,1],[124144,124153,1],[125127,125135,1],[125264,125273,1],[126065,126123,1],[126125,126127,1],[126129,126132,1],[126209,126253,1],[126255,126269,1],[127232,127244,1],[130032,130041,1]];static Nd=[[48,57,1],[1632,1641,1],[1776,1785,1],[1984,1993,1],[2406,2415,1],[2534,2543,1],[2662,2671,1],[2790,2799,1],[2918,2927,1],[3046,3055,1],[3174,3183,1],[3302,3311,1],[3430,3439,1],[3558,3567,1],[3664,3673,1],[3792,3801,1],[3872,3881,1],[4160,4169,1],[4240,4249,1],[6112,6121,1],[6160,6169,1],[6470,6479,1],[6608,6617,1],[6784,6793,1],[6800,6809,1],[6992,7001,1],[7088,7097,1],[7232,7241,1],[7248,7257,1],[42528,42537,1],[43216,43225,1],[43264,43273,1],[43472,43481,1],[43504,43513,1],[43600,43609,1],[44016,44025,1],[65296,65305,1],[66720,66729,1],[68912,68921,1],[69734,69743,1],[69872,69881,1],[69942,69951,1],[70096,70105,1],[70384,70393,1],[70736,70745,1],[70864,70873,1],[71248,71257,1],[71360,71369,1],[71472,71481,1],[71904,71913,1],[72016,72025,1],[72784,72793,1],[73040,73049,1],[73120,73129,1],[73552,73561,1],[92768,92777,1],[92864,92873,1],[93008,93017,1],[120782,120831,1],[123200,123209,1],[123632,123641,1],[124144,124153,1],[125264,125273,1],[130032,130041,1]];static Nl=[[5870,5872,1],[8544,8578,1],[8581,8584,1],[12295,12321,26],[12322,12329,1],[12344,12346,1],[42726,42735,1],[65856,65908,1],[66369,66378,9],[66513,66517,1],[74752,74862,1]];
18static No=[[178,179,1],[185,188,3],[189,190,1],[2548,2553,1],[2930,2935,1],[3056,3058,1],[3192,3198,1],[3416,3422,1],[3440,3448,1],[3882,3891,1],[4969,4988,1],[6128,6137,1],[6618,8304,1686],[8308,8313,1],[8320,8329,1],[8528,8543,1],[8585,9312,727],[9313,9371,1],[9450,9471,1],[10102,10131,1],[11517,12690,1173],[12691,12693,1],[12832,12841,1],[12872,12879,1],[12881,12895,1],[12928,12937,1],[12977,12991,1],[43056,43061,1],[65799,65843,1],[65909,65912,1],[65930,65931,1],[66273,66299,1],[66336,66339,1],[67672,67679,1],[67705,67711,1],[67751,67759,1],[67835,67839,1],[67862,67867,1],[68028,68029,1],[68032,68047,1],[68050,68095,1],[68160,68168,1],[68221,68222,1],[68253,68255,1],[68331,68335,1],[68440,68447,1],[68472,68479,1],[68521,68527,1],[68858,68863,1],[69216,69246,1],[69405,69414,1],[69457,69460,1],[69573,69579,1],[69714,69733,1],[70113,70132,1],[71482,71483,1],[71914,71922,1],[72794,72812,1],[73664,73684,1],[93019,93025,1],[93824,93846,1],[119488,119507,1],[119520,119539,1],[119648,119672,1],[125127,125135,1],[126065,126123,1],[126125,126127,1],[126129,126132,1],[126209,126253,1],[126255,126269,1],[127232,127244,1]];static P=[[33,35,1],[37,42,1],[44,47,1],[58,59,1],[63,64,1],[91,93,1],[95,123,28],[125,161,36],[167,171,4],[182,183,1],[187,191,4],[894,903,9],[1370,1375,1],[1417,1418,1],[1470,1472,2],[1475,1478,3],[1523,1524,1],[1545,1546,1],[1548,1549,1],[1563,1565,2],[1566,1567,1],[1642,1645,1],[1748,1792,44],[1793,1805,1],[2039,2041,1],[2096,2110,1],[2142,2404,262],[2405,2416,11],[2557,2678,121],[2800,3191,391],[3204,3572,368],[3663,3674,11],[3675,3844,169],[3845,3858,1],[3860,3898,38],[3899,3901,1],[3973,4048,75],[4049,4052,1],[4057,4058,1],[4170,4175,1],[4347,4960,613],[4961,4968,1],[5120,5742,622],[5787,5788,1],[5867,5869,1],[5941,5942,1],[6100,6102,1],[6104,6106,1],[6144,6154,1],[6468,6469,1],[6686,6687,1],[6816,6822,1],[6824,6829,1],[7002,7008,1],[7037,7038,1],[7164,7167,1],[7227,7231,1],[7294,7295,1],[7360,7367,1],[7379,8208,829],[8209,8231,1],[8240,8259,1],[8261,8273,1],[8275,8286,1],[8317,8318,1],[8333,8334,1],[8968,8971,1],[9001,9002,1],[10088,10101,1],[10181,10182,1],[10214,10223,1],[10627,10648,1],[10712,10715,1],[10748,10749,1],[11513,11516,1],[11518,11519,1],[11632,11776,144],[11777,11822,1],[11824,11855,1],[11858,11869,1],[12289,12291,1],[12296,12305,1],[12308,12319,1],[12336,12349,13],[12448,12539,91],[42238,42239,1],[42509,42511,1],[42611,42622,11],[42738,42743,1],[43124,43127,1],[43214,43215,1],[43256,43258,1],[43260,43310,50],[43311,43359,48],[43457,43469,1],[43486,43487,1],[43612,43615,1],[43742,43743,1],[43760,43761,1],[44011,64830,20819],[64831,65040,209],[65041,65049,1],[65072,65106,1],[65108,65121,1],[65123,65128,5],[65130,65131,1],[65281,65283,1],[65285,65290,1],[65292,65295,1],[65306,65307,1],[65311,65312,1],[65339,65341,1],[65343,65371,28],[65373,65375,2],[65376,65381,1],[65792,65794,1],[66463,66512,49],[66927,67671,744],[67871,67903,32],[68176,68184,1],[68223,68336,113],[68337,68342,1],[68409,68415,1],[68505,68508,1],[69293,69461,168],[69462,69465,1],[69510,69513,1],[69703,69709,1],[69819,69820,1],[69822,69825,1],[69952,69955,1],[70004,70005,1],[70085,70088,1],[70093,70107,14],[70109,70111,1],[70200,70205,1],[70313,70731,418],[70732,70735,1],[70746,70747,1],[70749,70854,105],[71105,71127,1],[71233,71235,1],[71264,71276,1],[71353,71484,131],[71485,71486,1],[71739,72004,265],[72005,72006,1],[72162,72255,93],[72256,72262,1],[72346,72348,1],[72350,72354,1],[72448,72457,1],[72769,72773,1],[72816,72817,1],[73463,73464,1],[73539,73551,1],[73727,74864,1137],[74865,74868,1],[77809,77810,1],[92782,92783,1],[92917,92983,66],[92984,92987,1],[92996,93847,851],[93848,93850,1],[94178,113823,19645],[121479,121483,1],[125278,125279,1]];static Pc=[[95,8255,8160],[8256,8276,20],[65075,65076,1],[65101,65103,1],[65343,65343,1]];static Pd=[[45,1418,1373],[1470,5120,3650],[6150,8208,2058],[8209,8213,1],[11799,11802,3],[11834,11835,1],[11840,11869,29],[12316,12336,20],[12448,65073,52625],[65074,65112,38],[65123,65293,170],[69293,69293,1]];static Pe=[[41,93,52],[125,3899,3774],[3901,5788,1887],[8262,8318,56],[8334,8969,635],[8971,9002,31],[10089,10101,2],[10182,10215,33],[10217,10223,2],[10628,10648,2],[10713,10715,2],[10749,11811,1062],[11813,11817,2],[11862,11868,2],[12297,12305,2],[12309,12315,2],[12318,12319,1],[64830,65048,218],[65078,65092,2],[65096,65114,18],[65116,65118,2],[65289,65341,52],[65373,65379,3]];static Pf=[[187,8217,8030],[8221,8250,29],[11779,11781,2],[11786,11789,3],[11805,11809,4]];static Pi=[[171,8216,8045],[8219,8220,1],[8223,8249,26],[11778,11780,2],[11785,11788,3],[11804,11808,4]];static Po=[[33,35,1],[37,39,1],[42,46,2],[47,58,11],[59,63,4],[64,92,28],[161,167,6],[182,183,1],[191,894,703],[903,1370,467],[1371,1375,1],[1417,1472,55],[1475,1478,3],[1523,1524,1],[1545,1546,1],[1548,1549,1],[1563,1565,2],[1566,1567,1],[1642,1645,1],[1748,1792,44],[1793,1805,1],[2039,2041,1],[2096,2110,1],[2142,2404,262],[2405,2416,11],[2557,2678,121],[2800,3191,391],[3204,3572,3
1868],[3663,3674,11],[3675,3844,169],[3845,3858,1],[3860,3973,113],[4048,4052,1],[4057,4058,1],[4170,4175,1],[4347,4960,613],[4961,4968,1],[5742,5867,125],[5868,5869,1],[5941,5942,1],[6100,6102,1],[6104,6106,1],[6144,6149,1],[6151,6154,1],[6468,6469,1],[6686,6687,1],[6816,6822,1],[6824,6829,1],[7002,7008,1],[7037,7038,1],[7164,7167,1],[7227,7231,1],[7294,7295,1],[7360,7367,1],[7379,8214,835],[8215,8224,9],[8225,8231,1],[8240,8248,1],[8251,8254,1],[8257,8259,1],[8263,8273,1],[8275,8277,2],[8278,8286,1],[11513,11516,1],[11518,11519,1],[11632,11776,144],[11777,11782,5],[11783,11784,1],[11787,11790,3],[11791,11798,1],[11800,11801,1],[11803,11806,3],[11807,11818,11],[11819,11822,1],[11824,11833,1],[11836,11839,1],[11841,11843,2],[11844,11855,1],[11858,11860,1],[12289,12291,1],[12349,12539,190],[42238,42239,1],[42509,42511,1],[42611,42622,11],[42738,42743,1],[43124,43127,1],[43214,43215,1],[43256,43258,1],[43260,43310,50],[43311,43359,48],[43457,43469,1],[43486,43487,1],[43612,43615,1],[43742,43743,1],[43760,43761,1],[44011,65040,21029],[65041,65046,1],[65049,65072,23],[65093,65094,1],[65097,65100,1],[65104,65106,1],[65108,65111,1],[65119,65121,1],[65128,65130,2],[65131,65281,150],[65282,65283,1],[65285,65287,1],[65290,65294,2],[65295,65306,11],[65307,65311,4],[65312,65340,28],[65377,65380,3],[65381,65792,411],[65793,65794,1],[66463,66512,49],[66927,67671,744],[67871,67903,32],[68176,68184,1],[68223,68336,113],[68337,68342,1],[68409,68415,1],[68505,68508,1],[69461,69465,1],[69510,69513,1],[69703,69709,1],[69819,69820,1],[69822,69825,1],[69952,69955,1],[70004,70005,1],[70085,70088,1],[70093,70107,14],[70109,70111,1],[70200,70205,1],[70313,70731,418],[70732,70735,1],[70746,70747,1],[70749,70854,105],[71105,71127,1],[71233,71235,1],[71264,71276,1],[71353,71484,131],[71485,71486,1],[71739,72004,265],[72005,72006,1],[72162,72255,93],[72256,72262,1],[72346,72348,1],[72350,72354,1],[72448,72457,1],[72769,72773,1],[72816,72817,1],[73463,73464,1],[73539,73551,1],[73727,74864,1137],[74865,74868,1],[77809,77810,1],[92782,92783,1],[92917,92983,66],[92984,92987,1],[92996,93847,851],[93848,93850,1],[94178,113823,19645],[121479,121483,1],[125278,125279,1]];static Ps=[[40,91,51],[123,3898,3775],[3900,5787,1887],[8218,8222,4],[8261,8317,56],[8333,8968,635],[8970,9001,31],[10088,10100,2],[10181,10214,33],[10216,10222,2],[10627,10647,2],[10712,10714,2],[10748,11810,1062],[11812,11816,2],[11842,11861,19],[11863,11867,2],[12296,12304,2],[12308,12314,2],[12317,64831,52514],[65047,65077,30],[65079,65091,2],[65095,65113,18],[65115,65117,2],[65288,65339,51],[65371,65375,4],[65378,65378,1]];static S=[[36,43,7],[60,62,1],[94,96,2],[124,126,2],[162,166,1],[168,169,1],[172,174,2],[175,177,1],[180,184,4],[215,247,32],[706,709,1],[722,735,1],[741,747,1],[749,751,2],[752,767,1],[885,900,15],[901,1014,113],[1154,1421,267],[1422,1423,1],[1542,1544,1],[1547,1550,3],[1551,1758,207],[1769,1789,20],[1790,2038,248],[2046,2047,1],[2184,2546,362],[2547,2554,7],[2555,2801,246],[2928,3059,131],[3060,3066,1],[3199,3407,208],[3449,3647,198],[3841,3843,1],[3859,3861,2],[3862,3863,1],[3866,3871,1],[3892,3896,2],[4030,4037,1],[4039,4044,1],[4046,4047,1],[4053,4056,1],[4254,4255,1],[5008,5017,1],[5741,6107,366],[6464,6622,158],[6623,6655,1],[7009,7018,1],[7028,7036,1],[8125,8127,2],[8128,8129,1],[8141,8143,1],[8157,8159,1],[8173,8175,1],[8189,8190,1],[8260,8274,14],[8314,8316,1],[8330,8332,1],[8352,8384,1],[8448,8449,1],[8451,8454,1],[8456,8457,1],[8468,8470,2],[8471,8472,1],[8478,8483,1],[8485,8489,2],[8494,8506,12],[8507,8512,5],[8513,8516,1],[8522,8525,1],[8527,8586,59],[8587,8592,5],[8593,8967,1],[8972,9e3,1],[9003,9254,1],[9280,9290,1],[9372,9449,1],[9472,10087,1],[10132,10180,1],[10183,10213,1],[10224,10626,1],[10649,10711,1],[10716,10747,1],[10750,11123,1],[11126,11157,1],[11159,11263,1],[11493,11498,1],[11856,11857,1],[11904,11929,1],[11931,12019,1],[12032,12245,1],[12272,12287,1],[12292,12306,14],[12307,12320,13],[12342,12343,1],[12350,12351,1],[12443,12444,1],[12688,12689,1],[12694,12703,1],[12736,12771,1],[12783,12800,17],[12801,12830,1],[12842,12871,1],[12880,12896,16],[12897,12927,1],[12938,12976,
181],[12992,13311,1],[19904,19967,1],[42128,42182,1],[42752,42774,1],[42784,42785,1],[42889,42890,1],[43048,43051,1],[43062,43065,1],[43639,43641,1],[43867,43882,15],[43883,64297,20414],[64434,64450,1],[64832,64847,1],[64975,65020,45],[65021,65023,1],[65122,65124,2],[65125,65126,1],[65129,65284,155],[65291,65308,17],[65309,65310,1],[65342,65344,2],[65372,65374,2],[65504,65510,1],[65512,65518,1],[65532,65533,1],[65847,65855,1],[65913,65929,1],[65932,65934,1],[65936,65948,1],[65952,66e3,48],[66001,66044,1],[67703,67704,1],[68296,71487,3191],[73685,73713,1],[92988,92991,1],[92997,113820,20823],[118608,118723,1],[118784,119029,1],[119040,119078,1],[119081,119140,1],[119146,119148,1],[119171,119172,1],[119180,119209,1],[119214,119274,1],[119296,119361,1],[119365,119552,187],[119553,119638,1],[120513,120539,26],[120571,120597,26],[120629,120655,26],[120687,120713,26],[120745,120771,26],[120832,121343,1],[121399,121402,1],[121453,121460,1],[121462,121475,1],[121477,121478,1],[123215,123647,432],[126124,126128,4],[126254,126704,450],[126705,126976,271],[126977,127019,1],[127024,127123,1],[127136,127150,1],[127153,127167,1],[127169,127183,1],[127185,127221,1],[127245,127405,1],[127462,127490,1],[127504,127547,1],[127552,127560,1],[127568,127569,1],[127584,127589,1],[127744,128727,1],[128732,128748,1],[128752,128764,1],[128768,128886,1],[128891,128985,1],[128992,129003,1],[129008,129024,16],[129025,129035,1],[129040,129095,1],[129104,129113,1],[129120,129159,1],[129168,129197,1],[129200,129201,1],[129280,129619,1],[129632,129645,1],[129648,129660,1],[129664,129672,1],[129680,129725,1],[129727,129733,1],[129742,129755,1],[129760,129768,1],[129776,129784,1],[129792,129938,1],[129940,129994,1]];static Sc=[[36,162,126],[163,165,1],[1423,1547,124],[2046,2047,1],[2546,2547,1],[2555,2801,246],[3065,3647,582],[6107,8352,2245],[8353,8384,1],[43064,65020,21956],[65129,65284,155],[65504,65505,1],[65509,65510,1],[73693,73696,1],[123647,126128,2481]];static Sk=[[94,96,2],[168,175,7],[180,184,4],[706,709,1],[722,735,1],[741,747,1],[749,751,2],[752,767,1],[885,900,15],[901,2184,1283],[8125,8127,2],[8128,8129,1],[8141,8143,1],[8157,8159,1],[8173,8175,1],[8189,8190,1],[12443,12444,1],[42752,42774,1],[42784,42785,1],[42889,42890,1],[43867,43882,15],[43883,64434,20551],[64435,64450,1],[65342,65344,2],[65507,127995,62488],[127996,127999,1]];static Sm=[[43,60,17],[61,62,1],[124,126,2],[172,177,5],[215,247,32],[1014,1542,528],[1543,1544,1],[8260,8274,14],[8314,8316,1],[8330,8332,1],[8472,8512,40],[8513,8516,1],[8523,8592,69],[8593,8596,1],[8602,8603,1],[8608,8614,3],[8622,8654,32],[8655,8658,3],[8660,8692,32],[8693,8959,1],[8992,8993,1],[9084,9115,31],[9116,9139,1],[9180,9185,1],[9655,9665,10],[9720,9727,1],[9839,10176,337],[10177,10180,1],[10183,10213,1],[10224,10239,1],[10496,10626,1],[10649,10711,1],[10716,10747,1],[10750,11007,1],[11056,11076,1],[11079,11084,1],[64297,65122,825],[65124,65126,1],[65291,65308,17],[65309,65310,1],[65372,65374,2],[65506,65513,7],[65514,65516,1],[120513,120539,26],[120571,120597,26],[120629,120655,26],[120687,120713,26],[120745,120771,26],[126704,126705,1]];static So=[[166,169,3],[174,176,2],[1154,1421,267],[1422,1550,128],[1551,1758,207],[1769,1789,20],[1790,2038,248],[2554,2928,374],[3059,3064,1],[3066,3199,133],[3407,3449,42],[3841,3843,1],[3859,3861,2],[3862,3863,1],[3866,3871,1],[3892,3896,2],[4030,4037,1],[4039,4044,1],[4046,4047,1],[4053,4056,1],[4254,4255,1],[5008,5017,1],[5741,6464,723],[6622,6655,1],[7009,7018,1],[7028,7036,1],[8448,8449,1],[8451,8454,1],[8456,8457,1],[8468,8470,2],[8471,8478,7],[8479,8483,1],[8485,8489,2],[8494,8506,12],[8507,8522,15],[8524,8525,1],[8527,8586,59],[8587,8597,10],[8598,8601,1],[8604,8607,1],[8609,8610,1],[8612,8613,1],[8615,8621,1],[8623,8653,1],[8656,8657,1],[8659,8661,2],[8662,8691,1],[8960,8967,1],[8972,8991,1],[8994,9e3,1],[9003,9083,1],[9085,9114,1],[9140,9179,1],[9186,9254,1],[9280,9290,1],[9372,9449,1],[9472,9654,1],[9656,9664,1],[9666,9719,1],[9728,9838,1],[9840,10087,1],[10132,10175,1],[10240,10495,1],[11008,11055,1],[11077,11078,1],[11085,11123,1],[11126,11157,1],[11159,11263,1],[11493,11498,1],[11856,11857,1],[11904,11929,1],[11931,12019,1],[12032,12245,1],[12272,12287,1],[12292,12306,14],[12307,12320,13],[12342,12343,1],[12350,12351,1],[12688,12689,1],[12694,12703,1],[12736,12771,1],[12783,12800,17],[12801,12830,1],[12842,12871,1],[12880,12896,16],[12897,12927,1],[12938,12976,
181],[12992,13311,1],[19904,19967,1],[42128,42182,1],[43048,43051,1],[43062,43063,1],[43065,43639,574],[43640,43641,1],[64832,64847,1],[64975,65021,46],[65022,65023,1],[65508,65512,4],[65517,65518,1],[65532,65533,1],[65847,65855,1],[65913,65929,1],[65932,65934,1],[65936,65948,1],[65952,66e3,48],[66001,66044,1],[67703,67704,1],[68296,71487,3191],[73685,73692,1],[73697,73713,1],[92988,92991,1],[92997,113820,20823],[118608,118723,1],[118784,119029,1],[119040,119078,1],[119081,119140,1],[119146,119148,1],[119171,119172,1],[119180,119209,1],[119214,119274,1],[119296,119361,1],[119365,119552,187],[119553,119638,1],[120832,121343,1],[121399,121402,1],[121453,121460,1],[121462,121475,1],[121477,121478,1],[123215,126124,2909],[126254,126976,722],[126977,127019,1],[127024,127123,1],[127136,127150,1],[127153,127167,1],[127169,127183,1],[127185,127221,1],[127245,127405,1],[127462,127490,1],[127504,127547,1],[127552,127560,1],[127568,127569,1],[127584,127589,1],[127744,127994,1],[128e3,128727,1],[128732,128748,1],[128752,128764,1],[128768,128886,1],[128891,128985,1],[128992,129003,1],[129008,129024,16],[129025,129035,1],[129040,129095,1],[129104,129113,1],[129120,129159,1],[129168,129197,1],[129200,129201,1],[129280,129619,1],[129632,129645,1],[129648,129660,1],[129664,129672,1],[129680,129725,1],[129727,129733,1],[129742,129755,1],[129760,129768,1],[129776,129784,1],[129792,129938,1],[129940,129994,1]];static Z=[[32,160,128],[5760,8192,2432],[8193,8202,1],[8232,8233,1],[8239,8287,48],[12288,12288,1]];static Zl=[[8232,8232,1]];static Zp=[[8233,8233,1]];static Zs=[[32,160,128],[5760,8192,2432],[8193,8202,1],[8239,8287,48],[12288,12288,1]];static Adlam=[[125184,125259,1],[125264,125273,1],[125278,125279,1]];static Ahom=[[71424,71450,1],[71453,71467,1],[71472,71494,1]];static Anatolian_Hieroglyphs=[[82944,83526,1]];static Arabic=[[1536,1540,1],[1542,1547,1],[1549,1562,1],[1564,1566,1],[1568,1599,1],[1601,1610,1],[1622,1647,1],[1649,1756,1],[1758,1791,1],[1872,1919,1],[2160,2190,1],[2192,2193,1],[2200,2273,1],[2275,2303,1],[64336,64450,1],[64467,64829,1],[64832,64911,1],[64914,64967,1],[64975,65008,33],[65009,65023,1],[65136,65140,1],[65142,65276,1],[69216,69246,1],[69373,69375,1],[126464,126467,1],[126469,126495,1],[126497,126498,1],[126500,126503,3],[126505,126514,1],[126516,126519,1],[126521,126523,2],[126530,126535,5],[126537,126541,2],[126542,126543,1],[126545,126546,1],[126548,126551,3],[126553,126561,2],[126562,126564,2],[126567,126570,1],[126572,126578,1],[126580,126583,1],[126585,126588,1],[126590,126592,2],[126593,126601,1],[126603,126619,1],[126625,126627,1],[126629,126633,1],[126635,126651,1],[126704,126705,1]];static Armenian=[[1329,1366,1],[1369,1418,1],[1421,1423,1],[64275,64279,1]];static Avestan=[[68352,68405,1],[68409,68415,1]];static Balinese=[[6912,6988,1],[6992,7038,1]];static Bamum=[[42656,42743,1],[92160,92728,1]];static Bassa_Vah=[[92880,92909,1],[92912,92917,1]];static Batak=[[7104,7155,1],[7164,7167,1]];static Bengali=[[2432,2435,1],[2437,2444,1],[2447,2448,1],[2451,2472,1],[2474,2480,1],[2482,2486,4],[2487,2489,1],[2492,2500,1],[2503,2504,1],[2507,2510,1],[2519,2524,5],[2525,2527,2],[2528,2531,1],[2534,2558,1]];static Bhaiksuki=[[72704,72712,1],[72714,72758,1],[72760,72773,1],[72784,72812,1]];static Bopomofo=[[746,747,1],[12549,12591,1],[12704,12735,1]];static Brahmi=[[69632,69709,1],[69714,69749,1],[69759,69759,1]];static Braille=[[10240,10495,1]];static Buginese=[[6656,6683,1],[6686,6687,1]];static Buhid=[[5952,5971,1]];static Canadian_Aboriginal=[[5120,5759,1],[6320,6389,1],[72368,72383,1]];static Carian=[[66208,66256,1]];static Caucasian_Albanian=[[66864,66915,1],[66927,66927,1]];static Chakma=[[69888,69940,1],[69942,69959,1]];static Cham=[[43520,43574,1],[43584,43597,1],[43600,43609,1],[43612,43615,1]];static Cherokee=[[5024,5109,1],[5112,5117,1],[43888,43967,1]];static Chorasmian=[[69552,69579,1]];static Common=[[0,64,1],[91,96,1],[123,169,1],[171,185,1],[187,191,1],[215,247,32],[697,735,1],[741,745,1],[748,767,1],[884,894,10],[901,903,2],[1541,1548,7],[1563,1567,4],[1600,1757,157],[2274,2404,130],[2405,3647,1242],[4053,4056,1],[4347,5867,1520],[5868,5869,1],[5941,5942,1],[6146,6147,1],[6149,7379,1230],[7393,7401,8],[7402,7404,1],[7406,7411,1],[7413,7415,1],[7418,8192,774],[8193,8203,1],[8206,8292,1],[8294,8304,1],[8308,8318,1],[8320,8334,1],[8352,8384,1],[8448,8485,1],[8487,8489,1],[8492,8497,1],[8499,8525,1],[8527,8543,1],[8585,8587,1],[8592,9254,1],[9280,9290,1],[9312,10239,1],[10496,11123,1],[11126,11157,1],[11159,11263,1],[11776,11869,1],[12272,12292,1],[12294,12296,2],[12297,12320,1],[12336,12343,1],[12348,12351,1],[12443,12444,1],[12448,12539,91],[12540,12688,148],[12689,12703,1],[12736,12771,1],[12783,12832,49],[12833,12895,1],[12927,13007,1],[13055,13144,89],[13145,13311,1],[19904,19967,1],[42752,42785,1],[42888,42890,1],[43056,43065,1],[43310,43471,161],[43867,43882,15],[43883,64830,20947],[64831,65040,209],[65041,65049,1],[65072,65106,1],[65108,65126,1],[65128,65131,1],[65279,65281,2],[65282,65312,1],[65339,65344,1],[65371,65381,1],[65392,65438,46],[65439,65504,65],[65505,65510,1],[65512,65518,1],[65529,65533,1],[65792,65794,1],[65799,65843,1],[65847,65855,1],[65936,65948,1],[66e3,66044,1],[66273,66299,1],[113824,113827,1],[118608,118723,1],[118784,119029,1],[119040,119078,1],[119081,119142,1],[119146,119162,1],[119171,119172,1],[119180,119209,1],[119214,119274,1],[119488,119507,1],[119520,119539,1],[119552,119638,1],[119648,119672,1],[119808,119892,1],[119894,119964,1],[119966,119967,1],[119970,
18119973,3],[119974,119977,3],[119978,119980,1],[119982,119993,1],[119995,119997,2],[119998,120003,1],[120005,120069,1],[120071,120074,1],[120077,120084,1],[120086,120092,1],[120094,120121,1],[120123,120126,1],[120128,120132,1],[120134,120138,4],[120139,120144,1],[120146,120485,1],[120488,120779,1],[120782,120831,1],[126065,126132,1],[126209,126269,1],[126976,127019,1],[127024,127123,1],[127136,127150,1],[127153,127167,1],[127169,127183,1],[127185,127221,1],[127232,127405,1],[127462,127487,1],[127489,127490,1],[127504,127547,1],[127552,127560,1],[127568,127569,1],[127584,127589,1],[127744,128727,1],[128732,128748,1],[128752,128764,1],[128768,128886,1],[128891,128985,1],[128992,129003,1],[129008,129024,16],[129025,129035,1],[129040,129095,1],[129104,129113,1],[129120,129159,1],[129168,129197,1],[129200,129201,1],[129280,129619,1],[129632,129645,1],[129648,129660,1],[129664,129672,1],[129680,129725,1],[129727,129733,1],[129742,129755,1],[129760,129768,1],[129776,129784,1],[129792,129938,1],[129940,129994,1],[130032,130041,1],[917505,917536,31],[917537,917631,1]];static foldCommon=[[924,956,32]];static Coptic=[[994,1007,1],[11392,11507,1],[11513,11519,1]];static Cuneiform=[[73728,74649,1],[74752,74862,1],[74864,74868,1],[74880,75075,1]];static Cypriot=[[67584,67589,1],[67592,67594,2],[67595,67637,1],[67639,67640,1],[67644,67647,3]];static Cypro_Minoan=[[77712,77810,1]];static Cyrillic=[[1024,1156,1],[1159,1327,1],[7296,7304,1],[7467,7544,77],[11744,11775,1],[42560,42655,1],[65070,65071,1],[122928,122989,1],[123023,123023,1]];static Deseret=[[66560,66639,1]];static Devanagari=[[2304,2384,1],[2389,2403,1],[2406,2431,1],[43232,43263,1],[72448,72457,1]];static Dives_Akuru=[[71936,71942,1],[71945,71948,3],[71949,71955,1],[71957,71958,1],[71960,71989,1],[71991,71992,1],[71995,72006,1],[72016,72025,1]];static Dogra=[[71680,71739,1]];static Duployan=[[113664,113770,1],[113776,113788,1],[113792,113800,1],[113808,113817,1],[113820,113823,1]];static Egyptian_Hieroglyphs=[[77824,78933,1]];static Elbasan=[[66816,66855,1]];static Elymaic=[[69600,69622,1]];static Ethiopic=[[4608,4680,1],[4682,4685,1],[4688,4694,1],[4696,4698,2],[4699,4701,1],[4704,4744,1],[4746,4749,1],[4752,4784,1],[4786,4789,1],[4792,4798,1],[4800,4802,2],[4803,4805,1],[4808,4822,1],[4824,4880,1],[4882,4885,1],[4888,4954,1],[4957,4988,1],[4992,5017,1],[11648,11670,1],[11680,11686,1],[11688,11694,1],[11696,11702,1],[11704,11710,1],[11712,11718,1],[11720,11726,1],[11728,11734,1],[11736,11742,1],[43777,43782,1],[43785,43790,1],[43793,43798,1],[43808,43814,1],[43816,43822,1],[124896,124902,1],[124904,124907,1],[124909,124910,1],[124912,124926,1]];static Georgian=[[4256,4293,1],[4295,4301,6],[4304,4346,1],[4348,4351,1],[7312,7354,1],[7357,7359,1],[11520,11557,1],[11559,11565,6]];static Glagolitic=[[11264,11359,1],[122880,122886,1],[122888,122904,1],[122907,122913,1],[122915,122916,1],[122918,122922,1]];static Gothic=[[66352,66378,1]];static Grantha=[[70400,70403,1],[70405,70412,1],[70415,70416,1],[70419,70440,1],[70442,70448,1],[70450,70451,1],[70453,70457,1],[70460,70468,1],[70471,70472,1],[70475,70477,1],[70480,70487,7],[70493,70499,1],[70502,70508,1],[70512,70516,1]];static Greek=[[880,883,1],[885,887,1],[890,893,1],[895,900,5],[902,904,2],[905,906,1],[908,910,2],[911,929,1],[931,993,1],[1008,1023,1],[7462,7466,1],[7517,7521,1],[7526,7530,1],[7615,7936,321],[7937,7957,1],[7960,7965,1],[7968,8005,1],[8008,8013,1],[8016,8023,1],[8025,8031,2],[8032,8061,1],[8064,8116,1],[8118,8132,1],[8134,8147,1],[8150,8155,1],[8157,8175,1],[8178,8180,1],[8182,8190,1],[8486,43877,35391],[65856,65934,1],[65952,119296,53344],[119297,119365,1]];static foldGreek=[[181,837,656]];static Gujarati=[[2689,2691,1],[2693,2701,1],[2703,2705,1],[2707,2728,1],[2730,2736,1],[2738,2739,1],[2741,2745,1],[2748,2757,1],[2759,2761,1],[2763,2765,1],[2768,2784,16],[2785,2787,1],[2790,2801,1],[2809,2815,1]];static Gunjala_Gondi=[[73056,73061,1],[73063,73064,1],[73066,73102,1],[73104,73105,1],[73107,73112,1],[73120,73129,1]];static Gurmukhi=[[2561,2563,1],[2565,2570,1],[2575,2576,1],[2579,2600,1],[2602,2608,1],[2610,2611,1],[2613,2614,1],[2616,2617,1],[2620,2622,2],[2623,2626,1],[2631,2632,1],[2635,2637,1],[2641,2649,8],[2650,2652,1],[2654,2662,8],[2663,2678,1]];static Han=[[11904,11929,1],[11931,12019,1],[12032,12245,1],[12293,12295,2],[12321,12329,1],[12344,12347,1],[13312,19903,1],[19968,40959,1],[63744,64109,1],[64112,64217,1],[94178,94179,1],[94192,94193,1],[131072,173791,1],[173824,177977,1],[177984,178205,1],[178208,183969,1],[183984,191456,1],[191472,192093,1],[194560,195101,1],[196608,201546,1],[201552,205743,1]];
18static Hangul=[[4352,4607,1],[12334,12335,1],[12593,12686,1],[12800,12830,1],[12896,12926,1],[43360,43388,1],[44032,55203,1],[55216,55238,1],[55243,55291,1],[65440,65470,1],[65474,65479,1],[65482,65487,1],[65490,65495,1],[65498,65500,1]];static Hanifi_Rohingya=[[68864,68903,1],[68912,68921,1]];static Hanunoo=[[5920,5940,1]];static Hatran=[[67808,67826,1],[67828,67829,1],[67835,67839,1]];static Hebrew=[[1425,1479,1],[1488,1514,1],[1519,1524,1],[64285,64310,1],[64312,64316,1],[64318,64320,2],[64321,64323,2],[64324,64326,2],[64327,64335,1]];static Hiragana=[[12353,12438,1],[12445,12447,1],[110593,110879,1],[110898,110928,30],[110929,110930,1],[127488,127488,1]];static Imperial_Aramaic=[[67648,67669,1],[67671,67679,1]];static Inherited=[[768,879,1],[1157,1158,1],[1611,1621,1],[1648,2385,737],[2386,2388,1],[6832,6862,1],[7376,7378,1],[7380,7392,1],[7394,7400,1],[7405,7412,7],[7416,7417,1],[7616,7679,1],[8204,8205,1],[8400,8432,1],[12330,12333,1],[12441,12442,1],[65024,65039,1],[65056,65069,1],[66045,66272,227],[70459,118528,48069],[118529,118573,1],[118576,118598,1],[119143,119145,1],[119163,119170,1],[119173,119179,1],[119210,119213,1],[917760,917999,1]];static foldInherited=[[921,953,32],[8126,8126,1]];static Inscriptional_Pahlavi=[[68448,68466,1],[68472,68479,1]];static Inscriptional_Parthian=[[68416,68437,1],[68440,68447,1]];static Javanese=[[43392,43469,1],[43472,43481,1],[43486,43487,1]];static Kaithi=[[69760,69826,1],[69837,69837,1]];static Kannada=[[3200,3212,1],[3214,3216,1],[3218,3240,1],[3242,3251,1],[3253,3257,1],[3260,3268,1],[3270,3272,1],[3274,3277,1],[3285,3286,1],[3293,3294,1],[3296,3299,1],[3302,3311,1],[3313,3315,1]];static Katakana=[[12449,12538,1],[12541,12543,1],[12784,12799,1],[13008,13054,1],[13056,13143,1],[65382,65391,1],[65393,65437,1],[110576,110579,1],[110581,110587,1],[110589,110590,1],[110592,110880,288],[110881,110882,1],[110933,110948,15],[110949,110951,1]];static Kawi=[[73472,73488,1],[73490,73530,1],[73534,73561,1]];static Kayah_Li=[[43264,43309,1],[43311,43311,1]];static Kharoshthi=[[68096,68099,1],[68101,68102,1],[68108,68115,1],[68117,68119,1],[68121,68149,1],[68152,68154,1],[68159,68168,1],[68176,68184,1]];static Khitan_Small_Script=[[94180,101120,6940],[101121,101589,1]];static Khmer=[[6016,6109,1],[6112,6121,1],[6128,6137,1],[6624,6655,1]];static Khojki=[[70144,70161,1],[70163,70209,1]];static Khudawadi=[[70320,70378,1],[70384,70393,1]];static Lao=[[3713,3714,1],[3716,3718,2],[3719,3722,1],[3724,3747,1],[3749,3751,2],[3752,3773,1],[3776,3780,1],[3782,3784,2],[3785,3790,1],[3792,3801,1],[3804,3807,1]];static Latin=[[65,90,1],[97,122,1],[170,186,16],[192,214,1],[216,246,1],[248,696,1],[736,740,1],[7424,7461,1],[7468,7516,1],[7522,7525,1],[7531,7543,1],[7545,7614,1],[7680,7935,1],[8305,8319,14],[8336,8348,1],[8490,8491,1],[8498,8526,28],[8544,8584,1],[11360,11391,1],[42786,42887,1],[42891,42954,1],[42960,42961,1],[42963,42965,2],[42966,42969,1],[42994,43007,1],[43824,43866,1],[43868,43876,1],[43878,43881,1],[64256,64262,1],[65313,65338,1],[65345,65370,1],[67456,67461,1],[67463,67504,1],[67506,67514,1],[122624,122654,1],[122661,122666,1]];static Lepcha=[[7168,7223,1],[7227,7241,1],[7245,7247,1]];static Limbu=[[6400,6430,1],[6432,6443,1],[6448,6459,1],[6464,6468,4],[6469,6479,1]];static Linear_A=[[67072,67382,1],[67392,67413,1],[67424,67431,1]];static Linear_B=[[65536,65547,1],[65549,65574,1],[65576,65594,1],[65596,65597,1],[65599,65613,1],[65616,65629,1],[65664,65786,1]];static Lisu=[[42192,42239,1],[73648,73648,1]];static Lycian=[[66176,66204,1]];static Lydian=[[67872,67897,1],[67903,67903,1]];static Mahajani=[[69968,70006,1]];static Makasar=[[73440,73464,1]];static Malayalam=[[3328,3340,1],[3342,3344,1],[3346,3396,1],[3398,3400,1],[3402,3407,1],[3412,3427,1],[3430,3455,1]];static Mandaic=[[2112,2139,1],[2142,2142,1]];static Manichaean=[[68288,68326,1],[68331,68342,1]];static Marchen=[[72816,72847,1],[72850,72871,1],[72873,72886,1]];static Masaram_Gondi=[[72960,72966,1],[72968,72969,1],[72971,73014,1],[73018,73020,2],[73021,73023,2],[73024,73031,1],[73040,73049,1]];static Medefaidrin=[[93760,93850,1]];static Meetei_Mayek=[[43744,43766,1],[43968,44013,1],[44016,44025,1]];static Mende_Kikakui=[[124928,125124,1],[125127,125142,1]];static Meroitic_Cursive=[[68e3,68023,1],[68028,68047,1],[68050,68095,1]];static Meroitic_Hieroglyphs=[[67968,67999,1]];static Miao=[[93952,94026,1],[94031,94087,1],[94095,94111,1]];static Modi=[[71168,71236,1],[71248,71257,1]];static Mongolian=[[6144,6145,1],[6148,6150,2],[6151,6169,1],[6176,6264,1],[6272,6314,1],[71264,71276,1]];static Mro=[[92736,92766,1],[92768,92777,1],[92782,92783,1]];static Multani=[[70272,70278,1],[70280,70282,2],[70283,70285,1],[70287,70301,1],[70303,70313,1]];static Myanmar=[[4096,4255,1],[43488,43518,1],[43616,43647,1]];static Nabataean=[[67712,67742,1],[67751,67759,1]];static Nag_Mundari=[[124112,124153,1]];static Nandinagari=[[72096,72103,1],[72106,72151,1],[72154,72164,1]];static New_Tai_Lue=[[6528,6571,1],[6576,6601,1],[6608,6618,1],[6622,6623,1]];static Newa=[[70656,70747,1],[70749,70753,1]];static Nko=[[1984,2042,1],[2045,2047,1]];
18static Nushu=[[94177,110960,16783],[110961,111355,1]];static Nyiakeng_Puachue_Hmong=[[123136,123180,1],[123184,123197,1],[123200,123209,1],[123214,123215,1]];static Ogham=[[5760,5788,1]];static Ol_Chiki=[[7248,7295,1]];static Old_Hungarian=[[68736,68786,1],[68800,68850,1],[68858,68863,1]];static Old_Italic=[[66304,66339,1],[66349,66351,1]];static Old_North_Arabian=[[68224,68255,1]];static Old_Permic=[[66384,66426,1]];static Old_Persian=[[66464,66499,1],[66504,66517,1]];static Old_Sogdian=[[69376,69415,1]];static Old_South_Arabian=[[68192,68223,1]];static Old_Turkic=[[68608,68680,1]];static Old_Uyghur=[[69488,69513,1]];static Oriya=[[2817,2819,1],[2821,2828,1],[2831,2832,1],[2835,2856,1],[2858,2864,1],[2866,2867,1],[2869,2873,1],[2876,2884,1],[2887,2888,1],[2891,2893,1],[2901,2903,1],[2908,2909,1],[2911,2915,1],[2918,2935,1]];static Osage=[[66736,66771,1],[66776,66811,1]];static Osmanya=[[66688,66717,1],[66720,66729,1]];static Pahawh_Hmong=[[92928,92997,1],[93008,93017,1],[93019,93025,1],[93027,93047,1],[93053,93071,1]];static Palmyrene=[[67680,67711,1]];static Pau_Cin_Hau=[[72384,72440,1]];static Phags_Pa=[[43072,43127,1]];static Phoenician=[[67840,67867,1],[67871,67871,1]];static Psalter_Pahlavi=[[68480,68497,1],[68505,68508,1],[68521,68527,1]];static Rejang=[[43312,43347,1],[43359,43359,1]];static Runic=[[5792,5866,1],[5870,5880,1]];static Samaritan=[[2048,2093,1],[2096,2110,1]];static Saurashtra=[[43136,43205,1],[43214,43225,1]];static Sharada=[[70016,70111,1]];static Shavian=[[66640,66687,1]];static Siddham=[[71040,71093,1],[71096,71133,1]];static SignWriting=[[120832,121483,1],[121499,121503,1],[121505,121519,1]];static Sinhala=[[3457,3459,1],[3461,3478,1],[3482,3505,1],[3507,3515,1],[3517,3520,3],[3521,3526,1],[3530,3535,5],[3536,3540,1],[3542,3544,2],[3545,3551,1],[3558,3567,1],[3570,3572,1],[70113,70132,1]];static Sogdian=[[69424,69465,1]];static Sora_Sompeng=[[69840,69864,1],[69872,69881,1]];static Soyombo=[[72272,72354,1]];static Sundanese=[[7040,7103,1],[7360,7367,1]];static Syloti_Nagri=[[43008,43052,1]];static Syriac=[[1792,1805,1],[1807,1866,1],[1869,1871,1],[2144,2154,1]];static Tagalog=[[5888,5909,1],[5919,5919,1]];static Tagbanwa=[[5984,5996,1],[5998,6e3,1],[6002,6003,1]];static Tai_Le=[[6480,6509,1],[6512,6516,1]];static Tai_Tham=[[6688,6750,1],[6752,6780,1],[6783,6793,1],[6800,6809,1],[6816,6829,1]];static Tai_Viet=[[43648,43714,1],[43739,43743,1]];static Takri=[[71296,71353,1],[71360,71369,1]];static Tamil=[[2946,2947,1],[2949,2954,1],[2958,2960,1],[2962,2965,1],[2969,2970,1],[2972,2974,2],[2975,2979,4],[2980,2984,4],[2985,2986,1],[2990,3001,1],[3006,3010,1],[3014,3016,1],[3018,3021,1],[3024,3031,7],[3046,3066,1],[73664,73713,1],[73727,73727,1]];static Tangsa=[[92784,92862,1],[92864,92873,1]];static Tangut=[[94176,94208,32],[94209,100343,1],[100352,101119,1],[101632,101640,1]];static Telugu=[[3072,3084,1],[3086,3088,1],[3090,3112,1],[3114,3129,1],[3132,3140,1],[3142,3144,1],[3146,3149,1],[3157,3158,1],[3160,3162,1],[3165,3168,3],[3169,3171,1],[3174,3183,1],[3191,3199,1]];static Thaana=[[1920,1969,1]];static Thai=[[3585,3642,1],[3648,3675,1]];static Tibetan=[[3840,3911,1],[3913,3948,1],[3953,3991,1],[3993,4028,1],[4030,4044,1],[4046,4052,1],[4057,4058,1]];static Tifinagh=[[11568,11623,1],[11631,11632,1],[11647,11647,1]];static Tirhuta=[[70784,70855,1],[70864,70873,1]];static Toto=[[123536,123566,1]];static Ugaritic=[[66432,66461,1],[66463,66463,1]];static Vai=[[42240,42539,1]];static Vithkuqi=[[66928,66938,1],[66940,66954,1],[66956,66962,1],[66964,66965,1],[66967,66977,1],[66979,66993,1],[66995,67001,1],[67003,67004,1]];static Wancho=[[123584,123641,1],[123647,123647,1]];static Warang_Citi=[[71840,71922,1],[71935,71935,1]];static Yezidi=[[69248,69289,1],[69291,69293,1],[69296,69297,1]];static Yi=[[40960,42124,1],[42128,42182,1]];static Zanabazar_Square=[[72192,72263,1]];static CATEGORIES=new Map([["C",te.C],["Cc",te.Cc],["Cf",te.Cf],["Co",te.Co],["Cs",te.Cs],["L",te.L],["Ll",te.Ll],["Lm",te.Lm],["Lo",te.Lo],["Lt",te.Lt],["Lu",te.Lu],["M",te.M],["Mc",te.Mc],["Me",te.Me],["Mn",te.Mn],["N",te.N],["Nd",te.Nd],["Nl",te.Nl],["No",te.No],["P",te.P],["Pc",te.Pc],["Pd",te.Pd],["Pe",te.Pe],["Pf",te.Pf],["Pi",te.Pi],["Po",te.Po],["Ps",te.Ps],["S",te.S],["Sc",te.Sc],["Sk",te.Sk],["Sm",te.Sm],["So",te.So],["Z",te.Z],["Zl",te.Zl],["Zp",te.Zp],["Zs",te.Zs]]);static SCRIPTS=new Map([["Adlam",te.Adlam],["Ahom",te.Ahom],["Anatolian_Hieroglyphs",te.Anatolian_Hieroglyphs],["Arabic",te.Arabic],["Armenian",te.Armenian],["Avestan",te.Avestan],["Balinese",te.Balinese],["Bamum",te.Bamum],["Bassa_Vah",te.Bassa_Vah],["Batak",te.Batak],["Bengali",te.Bengali],["Bhaiksuki",te.Bhaiksuki],["Bopomofo",te.Bopomofo],["Brahmi",te.Brahmi],["Braille",te.Braille],["Buginese",te.Buginese],["Buhid",te.Buhid],["Canadian_Aboriginal",te.Canadian_Aboriginal],["Carian",te.Carian],["Caucasian_Albanian",te.Caucasian_Albanian],["Chakma",te.Chakma],["Cham",te.Cham],["Cherokee",te.Cherokee],["Chorasmian",te.Chorasmian],["Common",te.Common],["Coptic",te.Coptic],["Cuneiform",te.Cuneiform],["Cypriot",te.Cypriot],["Cypro_Minoan",te.Cypro_Minoan],["Cyrillic",te.Cyrillic
18],["Deseret",te.Deseret],["Devanagari",te.Devanagari],["Dives_Akuru",te.Dives_Akuru],["Dogra",te.Dogra],["Duployan",te.Duployan],["Egyptian_Hieroglyphs",te.Egyptian_Hieroglyphs],["Elbasan",te.Elbasan],["Elymaic",te.Elymaic],["Ethiopic",te.Ethiopic],["Georgian",te.Georgian],["Glagolitic",te.Glagolitic],["Gothic",te.Gothic],["Grantha",te.Grantha],["Greek",te.Greek],["Gujarati",te.Gujarati],["Gunjala_Gondi",te.Gunjala_Gondi],["Gurmukhi",te.Gurmukhi],["Han",te.Han],["Hangul",te.Hangul],["Hanifi_Rohingya",te.Hanifi_Rohingya],["Hanunoo",te.Hanunoo],["Hatran",te.Hatran],["Hebrew",te.Hebrew],["Hiragana",te.Hiragana],["Imperial_Aramaic",te.Imperial_Aramaic],["Inherited",te.Inherited],["Inscriptional_Pahlavi",te.Inscriptional_Pahlavi],["Inscriptional_Parthian",te.Inscriptional_Parthian],["Javanese",te.Javanese],["Kaithi",te.Kaithi],["Kannada",te.Kannada],["Katakana",te.Katakana],["Kawi",te.Kawi],["Kayah_Li",te.Kayah_Li],["Kharoshthi",te.Kharoshthi],["Khitan_Small_Script",te.Khitan_Small_Script],["Khmer",te.Khmer],["Khojki",te.Khojki],["Khudawadi",te.Khudawadi],["Lao",te.Lao],["Latin",te.Latin],["Lepcha",te.Lepcha],["Limbu",te.Limbu],["Linear_A",te.Linear_A],["Linear_B",te.Linear_B],["Lisu",te.Lisu],["Lycian",te.Lycian],["Lydian",te.Lydian],["Mahajani",te.Mahajani],["Makasar",te.Makasar],["Malayalam",te.Malayalam],["Mandaic",te.Mandaic],["Manichaean",te.Manichaean],["Marchen",te.Marchen],["Masaram_Gondi",te.Masaram_Gondi],["Medefaidrin",te.Medefaidrin],["Meetei_Mayek",te.Meetei_Mayek],["Mende_Kikakui",te.Mende_Kikakui],["Meroitic_Cursive",te.Meroitic_Cursive],["Meroitic_Hieroglyphs",te.Meroitic_Hieroglyphs],["Miao",te.Miao],["Modi",te.Modi],["Mongolian",te.Mongolian],["Mro",te.Mro],["Multani",te.Multani],["Myanmar",te.Myanmar],["Nabataean",te.Nabataean],["Nag_Mundari",te.Nag_Mundari],["Nandinagari",te.Nandinagari],["New_Tai_Lue",te.New_Tai_Lue],["Newa",te.Newa],["Nko",te.Nko],["Nushu",te.Nushu],["Nyiakeng_Puachue_Hmong",te.Nyiakeng_Puachue_Hmong],["Ogham",te.Ogham],["Ol_Chiki",te.Ol_Chiki],["Old_Hungarian",te.Old_Hungarian],["Old_Italic",te.Old_Italic],["Old_North_Arabian",te.Old_North_Arabian],["Old_Permic",te.Old_Permic],["Old_Persian",te.Old_Persian],["Old_Sogdian",te.Old_Sogdian],["Old_South_Arabian",te.Old_South_Arabian],["Old_Turkic",te.Old_Turkic],["Old_Uyghur",te.Old_Uyghur],["Oriya",te.Oriya],["Osage",te.Osage],["Osmanya",te.Osmanya],["Pahawh_Hmong",te.Pahawh_Hmong],["Palmyrene",te.Palmyrene],["Pau_Cin_Hau",te.Pau_Cin_Hau],["Phags_Pa",te.Phags_Pa],["Phoenician",te.Phoenician],["Psalter_Pahlavi",te.Psalter_Pahlavi],["Rejang",te.Rejang],["Runic",te.Runic],["Samaritan",te.Samaritan],["Saurashtra",te.Saurashtra],["Sharada",te.Sharada],["Shavian",te.Shavian],["Siddham",te.Siddham],["SignWriting",te.SignWriting],["Sinhala",te.Sinhala],["Sogdian",te.Sogdian],["Sora_Sompeng",te.Sora_Sompeng],["Soyombo",te.Soyombo],["Sundanese",te.Sundanese],["Syloti_Nagri",te.Syloti_Nagri],["Syriac",te.Syriac],["Tagalog",te.Tagalog],["Tagbanwa",te.Tagbanwa],["Tai_Le",te.Tai_Le],["Tai_Tham",te.Tai_Tham],["Tai_Viet",te.Tai_Viet],["Takri",te.Takri],["Tamil",te.Tamil],["Tangsa",te.Tangsa],["Tangut",te.Tangut],["Telugu",te.Telugu],["Thaana",te.Thaana],["Thai",te.Thai],["Tibetan",te.Tibetan],["Tifinagh",te.Tifinagh],["Tirhuta",te.Tirhuta],["Toto",te.Toto],["Ugaritic",te.Ugaritic],["Vai",te.Vai],["Vithkuqi",te.Vithkuqi],["Wancho",te.Wancho],["Warang_Citi",te.Warang_Citi],["Yezidi",te.Yezidi],["Yi",te.Yi],["Zanabazar_Square",te.Zanabazar_Square]]);static FOLD_CATEGORIES=new Map([["L",te.foldL],["Ll",te.foldLl],["Lt",te.foldLt],["Lu",te.foldLu],["M",te.foldM],["Mn",te.foldMn]]);static FOLD_SCRIPT=new Map([["Common",te.foldCommon],["Greek",te.foldGreek],["Inherited",te.foldInherited]])}class Wt{static MAX_RUNE=1114111;static MAX_ASCII=127;static MAX_LATIN1=255;static MAX_BMP=65535;static MIN_FOLD=65;static MAX_FOLD=125251;static is32(e,t){let s=0,r=e.length;for(;s<r;){let i=s+Math.floor((r-s)/2),a=e[i];if(a[0]<=t&&t<=a[1])return(t-a[0])%a[2]===0;t<a[0]?r=i:s=i+1}return!1}static is(e,t){if(t<=this.MAX_LATIN1){for(let s of e)if(!(t>s[1]))return t<s[0]?!1:(t-s[0])%s[2]===0;return!1}return e.length>0&&t>=e[0][0]&&this.is32(e,t)}static isUpper(e){if(e<=this.MAX_LATIN1){const t=String.fromCodePoint(e);return t.toUpperCase()===t&&t.toLowerCase()!==t}return this.is(te.Upper,e)}static isPrint(e){return e<=this.MAX_LATIN1?e>=32&&e<127||e>=161&&e!==173:this.is(te.L,e)||this.is(te.M,e)||this.is(te.N,e)||this.is(te.P,e)||this.is(te.S,e)}static simpleFold(e){if(te.CASE_ORBIT.has(e))return te.CASE_ORBIT.get(e);const t=Se.toLowerCase(e);return t!==e?t:Se.toUpperCase(e)}static equalsIgnoreCase(e,t){if(e<0||t<0||e===t)return!0;
18if(e<=this.MAX_ASCII&&t<=this.MAX_ASCII)return Se.CODES.get("A")<=e&&e<=Se.CODES.get("Z")&&(e|=32),Se.CODES.get("A")<=t&&t<=Se.CODES.get("Z")&&(t|=32),e===t;for(let s=this.simpleFold(e);s!==e;s=this.simpleFold(s))if(s===t)return!0;return!1}}class fn{static METACHARACTERS="\\.+*?()|[]{}^$";static EMPTY_BEGIN_LINE=1;static EMPTY_END_LINE=2;static EMPTY_BEGIN_TEXT=4;static EMPTY_END_TEXT=8;static EMPTY_WORD_BOUNDARY=16;static EMPTY_NO_WORD_BOUNDARY=32;static EMPTY_ALL=-1;static emptyInts(){return[]}static isalnum(e){return Se.CODES.get("0")<=e&&e<=Se.CODES.get("9")||Se.CODES.get("a")<=e&&e<=Se.CODES.get("z")||Se.CODES.get("A")<=e&&e<=Se.CODES.get("Z")}static unhex(e){return Se.CODES.get("0")<=e&&e<=Se.CODES.get("9")?e-Se.CODES.get("0"):Se.CODES.get("a")<=e&&e<=Se.CODES.get("f")?e-Se.CODES.get("a")+10:Se.CODES.get("A")<=e&&e<=Se.CODES.get("F")?e-Se.CODES.get("A")+10:-1}static escapeRune(e){let t="";if(Wt.isPrint(e))this.METACHARACTERS.indexOf(String.fromCodePoint(e))>=0&&(t+="\\"),t+=String.fromCodePoint(e);else switch(e){case Se.CODES.get('"'):t+='\\"';break;case Se.CODES.get("\\"):t+="\\\\";break;case Se.CODES.get(" "):t+="\\t";break;case Se.CODES.get(` 19`):t+="\\n";break;case Se.CODES.get("\r"):t+="\\r";break;case Se.CODES.get("\b"):t+="\\b";break;case Se.CODES.get("\f"):t+="\\f";break;default:{let s=e.toString(16);e<256?(t+="\\x",s.length===1&&(t+="0"),t+=s):t+=`\\x{${s}}`;break}}return t}static stringToRunes(e){return String(e).split("").map(t=>t.codePointAt(0))}static runeToString(e){return String.fromCodePoint(e)}static isWordRune(e){return Se.CODES.get("a")<=e&&e<=Se.CODES.get("z")||Se.CODES.get("A")<=e&&e<=Se.CODES.get("Z")||Se.CODES.get("0")<=e&&e<=Se.CODES.get("9")||e===Se.CODES.get("_")}static emptyOpContext(e,t){let s=0;return e<0&&(s|=this.EMPTY_BEGIN_TEXT|this.EMPTY_BEGIN_LINE),e===Se.CODES.get(` 20`)&&(s|=this.EMPTY_BEGIN_LINE),t<0&&(s|=this.EMPTY_END_TEXT|this.EMPTY_END_LINE),t===Se.CODES.get(` 21`)&&(s|=this.EMPTY_END_LINE),this.isWordRune(e)!==this.isWordRune(t)?s|=this.EMPTY_WORD_BOUNDARY:s|=this.EMPTY_NO_WORD_BOUNDARY,s}static quoteMeta(e){return e.split("").map(t=>this.METACHARACTERS.indexOf(t)>=0?`\\${t}`:t).join("")}static charCount(e){return e>Wt.MAX_BMP?2:1}static stringToUtf8ByteArray(e){if(globalThis.TextEncoder)return Array.from(new TextEncoder().encode(e));{let t=[],s=0;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);i<128?t[s++]=i:i<2048?(t[s++]=i>>6|192,t[s++]=i&63|128):(i&64512)===55296&&r+1<e.length&&(e.charCodeAt(r+1)&64512)===56320?(i=65536+((i&1023)<<10)+(e.charCodeAt(++r)&1023),t[s++]=i>>18|240,t[s++]=i>>12&63|128,t[s++]=i>>6&63|128,t[s++]=i&63|128):(t[s++]=i>>12|224,t[s++]=i>>6&63|128,t[s++]=i&63|128)}return t}}static utf8ByteArrayToString(e){if(globalThis.TextDecoder)return new TextDecoder("utf-8").decode(new Uint8Array(e));{let t=[],s=0,r=0;for(;s<e.length;){let i=e[s++];if(i<128)t[r++]=String.fromCharCode(i);else if(i>191&&i<224){let a=e[s++];t[r++]=String.fromCharCode((i&31)<<6|a&63)}else if(i>239&&i<365){let a=e[s++],l=e[s++],c=e[s++],d=((i&7)<<18|(a&63)<<12|(l&63)<<6|c&63)-65536;t[r++]=String.fromCharCode(55296+(d>>10)),t[r++]=String.fromCharCode(56320+(d&1023))}else{let a=e[s++],l=e[s++];t[r++]=String.fromCharCode((i&15)<<12|(a&63)<<6|l&63)}}return t.join("")}}}const Hk=(n=[],e=0)=>{const t={};for(let s=0;s<n.length;s++){const r=n[s],i=e+s;t[r]=i,t[i]=r}return Object.freeze(t)};class Gl{static Encoding=Hk(["UTF_16","UTF_8"]);getEncoding(){throw Error("not implemented")}isUTF8Encoding(){return this.getEncoding()===Gl.Encoding.UTF_8}isUTF16Encoding(){return this.getEncoding()===Gl.Encoding.UTF_16}}class x8 extends Gl{constructor(e=null){super(),this.bytes=e}getEncoding(){return Gl.Encoding.UTF_8}asCharSequence(){return fn.utf8ByteArrayToString(this.bytes)}asBytes(){return this.bytes}length(){return this.bytes.length}}class vH extends Gl{constructor(e=null){super(),this.charSequence=e}getEncoding(){return Gl.Encoding.UTF_16}asCharSequence(){return this.charSequence}asBytes(){return this.charSequence.toString().split("").map(e=>e.codePointAt(0))}length(){return this.charSequence.length}}class l1{static utf16(e){return new vH(e)}static utf8(e){return Array.isArray(e)?new x8(e):new x8(fn.stringToUtf8ByteArray(e))}}
21class wx extends Error{constructor(e){super(e),this.name="RE2JSException"}}class Es extends wx{constructor(e,t=null){let s=`error parsing regexp: ${e}`;t&&(s+=`: \`${t}\``),super(s),this.name="RE2JSSyntaxException",this.message=s,this.error=e,this.input=t}getDescription(){return this.error}getPattern(){return this.input}}class bH extends wx{constructor(e){super(e),this.name="RE2JSCompileException"}}class El extends wx{constructor(e){super(e),this.name="RE2JSGroupException"}}class wH extends wx{constructor(e){super(e),this.name="RE2JSFlagsException"}}class SH{static quoteReplacement(e){return e.indexOf("\\")<0&&e.indexOf("$")<0?e:e.split("").map(t=>{const s=t.codePointAt(0);return s===Se.CODES["\\"]||s===Se.CODES.$?`\\${t}`:t}).join("")}constructor(e,t){if(e===null)throw new Error("pattern is null");this.patternInput=e;const s=this.patternInput.re2();this.patternGroupCount=s.numberOfCapturingGroups(),this.groups=[],this.namedGroups=s.namedGroups,t instanceof Gl?this.resetMatcherInput(t):Array.isArray(t)?this.resetMatcherInput(l1.utf8(t)):this.resetMatcherInput(l1.utf16(t))}pattern(){return this.patternInput}reset(){return this.matcherInputLength=this.matcherInput.length(),this.appendPos=0,this.hasMatch=!1,this.hasGroups=!1,this.anchorFlag=0,this}resetMatcherInput(e){if(e===null)throw new Error("input is null");return this.matcherInput=e,this.reset(),this}start(e=0){if(typeof e=="string"){const t=this.namedGroups[e];if(!Number.isFinite(t))throw new El(`group '${e}' not found`);e=t}return this.loadGroup(e),this.groups[2*e]}end(e=0){if(typeof e=="string"){const t=this.namedGroups[e];if(!Number.isFinite(t))throw new El(`group '${e}' not found`);e=t}return this.loadGroup(e),this.groups[2*e+1]}group(e=0){if(typeof e=="string"){const r=this.namedGroups[e];if(!Number.isFinite(r))throw new El(`group '${e}' not found`);e=r}const t=this.start(e),s=this.end(e);return t<0&&s<0?null:this.substring(t,s)}groupCount(){return this.patternGroupCount}loadGroup(e){if(e<0||e>this.patternGroupCount)throw new El(`Group index out of bounds: ${e}`);if(!this.hasMatch)throw new El("perhaps no match attempted");if(e===0||this.hasGroups)return;let t=this.groups[1]+1;t>this.matcherInputLength&&(t=this.matcherInputLength);const s=this.patternInput.re2().matchMachineInput(this.matcherInput,this.groups[0],t,this.anchorFlag,1+this.patternGroupCount);if(!s[0])throw new El("inconsistency in matching group data");this.groups=s[1],this.hasGroups=!0}matches(){return this.genMatch(0,Je.ANCHOR_BOTH)}lookingAt(){return this.genMatch(0,Je.ANCHOR_START)}find(e=null){if(e!==null){if(e<0||e>this.matcherInputLength)throw new El(`start index out of bounds: ${e}`);return this.reset(),this.genMatch(e,0)}return e=0,this.hasMatch&&(e=this.groups[1],this.groups[0]===this.groups[1]&&e++),this.genMatch(e,Je.UNANCHORED)}genMatch(e,t){const s=this.patternInput.re2().matchMachineInput(this.matcherInput,e,this.matcherInputLength,t,1);return s[0]?(this.groups=s[1],this.hasMatch=!0,this.hasGroups=!1,this.anchorFlag=t,!0):!1}substring(e,t){return this.matcherInput.isUTF8Encoding()?fn.utf8ByteArrayToString(this.matcherInput.asBytes().slice(e,t)):this.matcherInput.asCharSequence().substring(e,t).toString()}inputLength(){return this.matcherInputLength}appendReplacement(e,t=!1){let s="";const r=this.start(),i=this.end();return this.appendPos<r&&(s+=this.substring(this.appendPos,r)),this.appendPos=i,s+=t?this.appendReplacementInternalPerl(e):this.appendReplacementInternal(e),s}appendReplacementInternal(e){let t="",s=0;const r=e.length;for(let i=0;i<r-1;i++){if(e.codePointAt(i)===Se.CODES.get("\\")){s<i&&(t+=e.substring(s,i)),i++,s=i;continue}if(e.codePointAt(i)===Se.CODES.get("$")){let a=e.codePointAt(i+1);if(Se.CODES.get("0")<=a&&a<=Se.CODES.get("9")){let l=a-Se.CODES.get("0");for(s<i&&(t+=e.substring(s,i)),i+=2;i<r&&(a=e.codePointAt(i),!(a<Se.CODES.get("0")||a>Se.CODES.get("9")||l*10+a-Se.CODES.get("0")>this.patternGroupCount));i++)l=l*10+a-Se.CODES.get("0");if(l>this.patternGroupCount)throw new El(`n > number of groups: ${l}`);const c=this.group(l);c!==null&&(t+=c),s=i,i--;continue}else if(a===Se.CODES.get("{")){s<i&&(t+=e.substring(s,i)),i++;let l=i+1;for(;l<e.length&&e.codePointAt(l)!==Se.CODES.get("}")&&e.codePointAt(l)!==Se.CODES.get(" ");)l++;if(l===e.length||e.codePointAt(l)!==Se.CODES.get("}"))throw new El("named capture group is missing trailing '}'");const c=e.substring(i+1,l);t+=this.group(c),s=l+1}}}return s<r&&(t+=e.substring(s,r)),t}appendReplacementInternalPerl(e){let t="",s=0;const r=e.length;for(let i=0;i<r-1;i++)if(e.codePointAt(i)===Se.CODES.get("$")){let a=e.codePointAt(i+1);if(Se.CODES.get("$")===a){s<i&&(t+=e.substring(s,i)),t+="$",i++,s=i+1;continue}else if(Se.CODES.get("&")===a){s<i&&(t+=e.substring(s,i));const l=this.group(0);l!==null?t+=l:t+="$&",i++,s=i+1;continue}else if(Se.CODES.get("1")<=a&&a<=Se.CODES.get("9")){let l=a-Se.CODES.get("0");for(s<i&&(t+=e.substring(s,i)),i+=2;i<r&&(a=e.codePointAt(i),!(a<Se.CODES.get("0")||a>Se.CODES.get("9")||l*10+a-Se.CODES.get("0")>this.patternGroupCount));i++)l=l*10+a-Se.CODES.get("0");if(l>this.patternGroupCount){t+=`$${l}`,s=i,i--;continue}const c=this.group(l);c!==null&&(t+=c),s=i,i--;continue}
21else if(a===Se.CODES.get("<")){s<i&&(t+=e.substring(s,i)),i++;let l=i+1;for(;l<e.length&&e.codePointAt(l)!==Se.CODES.get(">")&&e.codePointAt(l)!==Se.CODES.get(" ");)l++;if(l===e.length||e.codePointAt(l)!==Se.CODES.get(">")){t+=e.substring(i-1,l+1),s=l+1;continue}const c=e.substring(i+1,l);Object.prototype.hasOwnProperty.call(this.namedGroups,c)?t+=this.group(c):t+=`$<${c}>`,s=l+1}}return s<r&&(t+=e.substring(s,r)),t}appendTail(){return this.substring(this.appendPos,this.matcherInputLength)}replaceAll(e,t=!1){return this.replace(e,!0,t)}replaceFirst(e,t=!1){return this.replace(e,!1,t)}replace(e,t=!0,s=!1){let r="";for(this.reset();this.find()&&(r+=this.appendReplacement(e,s),!!t););return r+=this.appendTail(),r}}class Lc{static EOF(){return-8}canCheckPrefix(){return!0}endPos(){return this.end}}class EH extends Lc{constructor(e,t=0,s=e.length){super(),this.bytes=e,this.start=t,this.end=s}step(e){if(e+=this.start,e>=this.end)return Lc.EOF();let t=this.bytes[e++]&255;return(t&128)===0?t<<3|1:(t&224)===192?(t=t&31,e>=this.end?Lc.EOF():(t=t<<6|this.bytes[e++]&63,t<<3|2)):(t&240)===224?(t=t&15,e+1>=this.end?Lc.EOF():(t=t<<6|this.bytes[e++]&63,t=t<<6|this.bytes[e++]&63,t<<3|3)):(t=t&7,e+2>=this.end?Lc.EOF():(t=t<<6|this.bytes[e++]&63,t=t<<6|this.bytes[e++]&63,t=t<<6|this.bytes[e++]&63,t<<3|4))}index(e,t){t+=this.start;const s=this.indexOf(this.bytes,e.prefixUTF8,t);return s<0?s:s-t}context(e){e+=this.start;let t=-1;if(e>this.start&&e<=this.end){let r=e-1;if(t=this.bytes[r--],t>=128){let i=e-4;for(i<this.start&&(i=this.start);r>=i&&(this.bytes[r]&192)===128;)r--;r<this.start&&(r=this.start),t=this.step(r)>>3}}const s=e<this.end?this.step(e)>>3:-1;return fn.emptyOpContext(t,s)}indexOf(e,t,s=0){let r=t.length;if(r===0)return-1;let i=e.length;for(let a=s;a<=i-r;a++)for(let l=0;l<r&&e[a+l]===t[l];l++)if(l===r-1)return a;return-1}}class TH extends Lc{constructor(e,t=0,s=e.length){super(),this.charSequence=e,this.start=t,this.end=s}step(e){if(e+=this.start,e<this.end){const t=this.charSequence.codePointAt(e);return t<<3|fn.charCount(t)}else return Lc.EOF()}index(e,t){t+=this.start;const s=this.charSequence.indexOf(e.prefix,t);return s<0?s:s-t}context(e){e+=this.start;const t=e>0&&e<=this.charSequence.length?this.charSequence.codePointAt(e-1):-1,s=e<this.charSequence.length?this.charSequence.codePointAt(e):-1;return fn.emptyOpContext(t,s)}}class Ts{static fromUTF8(e,t=0,s=e.length){return new EH(e,t,s)}static fromUTF16(e,t=0,s=e.length){return new TH(e,t,s)}}class ce{static Op=Hk(["NO_MATCH","EMPTY_MATCH","LITERAL","CHAR_CLASS","ANY_CHAR_NOT_NL","ANY_CHAR","BEGIN_LINE","END_LINE","BEGIN_TEXT","END_TEXT","WORD_BOUNDARY","NO_WORD_BOUNDARY","CAPTURE","STAR","PLUS","QUEST","REPEAT","CONCAT","ALTERNATE","LEFT_PAREN","VERTICAL_BAR"]);static isPseudoOp(e){return e>=ce.Op.LEFT_PAREN}static emptySubs(){return[]}static quoteIfHyphen(e){return e===Se.CODES.get("-")?"\\":""}static fromRegexp(e){const t=new ce(e.op);return t.flags=e.flags,t.subs=e.subs,t.runes=e.runes,t.cap=e.cap,t.min=e.min,t.max=e.max,t.name=e.name,t.namedGroups=e.namedGroups,t}constructor(e){this.op=e,this.flags=0,this.subs=ce.emptySubs(),this.runes=null,this.min=0,this.max=0,this.cap=0,this.name=null,this.namedGroups={}}reinit(){this.flags=0,this.subs=ce.emptySubs(),this.runes=null,this.cap=0,this.min=0,this.max=0,this.name=null,this.namedGroups={}}toString(){return this.appendTo()}appendTo(){let e="";switch(this.op){case ce.Op.NO_MATCH:e+="[^\\x00-\\x{10FFFF}]";break;case ce.Op.EMPTY_MATCH:e+="(?:)";break;case ce.Op.STAR:case ce.Op.PLUS:case ce.Op.QUEST:case ce.Op.REPEAT:{const t=this.subs[0];switch(t.op>ce.Op.CAPTURE||t.op===ce.Op.LITERAL&&t.runes.length>1?e+=`(?:${t.appendTo()})`:e+=t.appendTo(),this.op){case ce.Op.STAR:e+="*";break;case ce.Op.PLUS:e+="+";break;case ce.Op.QUEST:e+="?";break;case ce.Op.REPEAT:e+=`{${this.min}`,this.min!==this.max&&(e+=",",this.max>=0&&(e+=this.max)),e+="}";break}(this.flags&Je.NON_GREEDY)!==0&&(e+="?");break}case ce.Op.CONCAT:{for(let t of this.subs)t.op===ce.Op.ALTERNATE?e+=`(?:${t.appendTo()})`:e+=t.appendTo();break}case ce.Op.ALTERNATE:{let t="";for(let s of this.subs)e+=t,t="|",e+=s.appendTo();break}case ce.Op.LITERAL:(this.flags&Je.FOLD_CASE)!==0&&(e+="(?i:");for(let t of this.runes)e+=fn.escapeRune(t);(this.flags&Je.FOLD_CASE)!==0&&(e+=")");break;case ce.Op.ANY_CHAR_NOT_NL:e+="(?-s:.)";break;case ce.Op.ANY_CHAR:e+="(?s:.)";break;case ce.Op.CAPTURE:this.name===null||this.name.length===0?e+="(":e+=`(?P<${this.name}>
21`,this.subs[0].op!==ce.Op.EMPTY_MATCH&&(e+=this.subs[0].appendTo()),e+=")";break;case ce.Op.BEGIN_TEXT:e+="\\A";break;case ce.Op.END_TEXT:(this.flags&Je.WAS_DOLLAR)!==0?e+="(?-m:$)":e+="\\z";break;case ce.Op.BEGIN_LINE:e+="^";break;case ce.Op.END_LINE:e+="$";break;case ce.Op.WORD_BOUNDARY:e+="\\b";break;case ce.Op.NO_WORD_BOUNDARY:e+="\\B";break;case ce.Op.CHAR_CLASS:if(this.runes.length%2!==0){e+="[invalid char class]";break}if(e+="[",this.runes.length===0)e+="^\\x00-\\x{10FFFF}";else if(this.runes[0]===0&&this.runes[this.runes.length-1]===Wt.MAX_RUNE){e+="^";for(let t=1;t<this.runes.length-1;t+=2){const s=this.runes[t]+1,r=this.runes[t+1]-1;e+=ce.quoteIfHyphen(s),e+=fn.escapeRune(s),s!==r&&(e+="-",e+=ce.quoteIfHyphen(r),e+=fn.escapeRune(r))}}else for(let t=0;t<this.runes.length;t+=2){const s=this.runes[t],r=this.runes[t+1];e+=ce.quoteIfHyphen(s),e+=fn.escapeRune(s),s!==r&&(e+="-",e+=ce.quoteIfHyphen(r),e+=fn.escapeRune(r))}e+="]";break;default:e+=this.op;break}return e}maxCap(){let e=0;if(this.op===ce.Op.CAPTURE&&(e=this.cap),this.subs!==null)for(let t of this.subs){const s=t.maxCap();e<s&&(e=s)}return e}equals(e){if(!(e!==null&&e instanceof ce)||this.op!==e.op)return!1;switch(this.op){case ce.Op.END_TEXT:{if((this.flags&Je.WAS_DOLLAR)!==(e.flags&Je.WAS_DOLLAR))return!1;break}case ce.Op.LITERAL:case ce.Op.CHAR_CLASS:{if(this.runes===null&&e.runes===null)break;if(this.runes===null||e.runes===null||this.runes.length!==e.runes.length)return!1;for(let t=0;t<this.runes.length;t++)if(this.runes[t]!==e.runes[t])return!1;break}case ce.Op.ALTERNATE:case ce.Op.CONCAT:{if(this.subs.length!==e.subs.length)return!1;for(let t=0;t<this.subs.length;++t)if(!this.subs[t].equals(e.subs[t]))return!1;break}case ce.Op.STAR:case ce.Op.PLUS:case ce.Op.QUEST:{if((this.flags&Je.NON_GREEDY)!==(e.flags&Je.NON_GREEDY)||!this.subs[0].equals(e.subs[0]))return!1;break}case ce.Op.REPEAT:{if((this.flags&Je.NON_GREEDY)!==(e.flags&Je.NON_GREEDY)||this.min!==e.min||this.max!==e.max||!this.subs[0].equals(e.subs[0]))return!1;break}case ce.Op.CAPTURE:{if(this.cap!==e.cap||(this.name===null?e.name!==null:this.name!==e.name)||!this.subs[0].equals(e.subs[0]))return!1;break}}return!0}}class Tt{static ALT=1;static ALT_MATCH=2;static CAPTURE=3;static EMPTY_WIDTH=4;static FAIL=5;static MATCH=6;static NOP=7;static RUNE=8;static RUNE1=9;static RUNE_ANY=10;static RUNE_ANY_NOT_NL=11;static isRuneOp(e){return Tt.RUNE<=e&&e<=Tt.RUNE_ANY_NOT_NL}static escapeRunes(e){let t='"';for(let s of e)t+=fn.escapeRune(s);return t+='"',t}constructor(e){this.op=e,this.out=0,this.arg=0,this.runes=null}matchRune(e){if(this.runes.length===1){const r=this.runes[0];return(this.arg&Je.FOLD_CASE)!==0?Wt.equalsIgnoreCase(r,e):e===r}for(let r=0;r<this.runes.length&&r<=8;r+=2){if(e<this.runes[r])return!1;if(e<=this.runes[r+1])return!0}let t=0,s=this.runes.length/2|0;for(;t<s;){const r=t+((s-t)/2|0);if(this.runes[2*r]<=e){if(e<=this.runes[2*r+1])return!0;t=r+1}else s=r}return!1}toString(){switch(this.op){case Tt.ALT:return`alt -> ${this.out}, ${this.arg}`;case Tt.ALT_MATCH:return`altmatch -> ${this.out}, ${this.arg}`;case Tt.CAPTURE:return`cap ${this.arg} -> ${this.out}`;case Tt.EMPTY_WIDTH:return`empty ${this.arg} -> ${this.out}`;case Tt.MATCH:return"match";case Tt.FAIL:return"fail";case Tt.NOP:return`nop -> ${this.out}`;case Tt.RUNE:return this.runes===null?"rune <null>":["rune ",Tt.escapeRunes(this.runes),(this.arg&Je.FOLD_CASE)!==0?"/i":""," -> ",this.out].join("");case Tt.RUNE1:return`rune1 ${Tt.escapeRunes(this.runes)} -> ${this.out}`;case Tt.RUNE_ANY:return`any -> ${this.out}`;case Tt.RUNE_ANY_NOT_NL:return`anynotnl -> ${this.out}`;default:throw new Error("unhandled case in Inst.toString")}}}class _H{constructor(){this.inst=[],this.start=0,this.numCap=2}getInst(e){return this.inst[e]}numInst(){return this.inst.length}addInst(e){this.inst.push(new Tt(e))}skipNop(e){let t=this.inst[e];for(;t.op===Tt.NOP||t.op===Tt.CAPTURE;)t=this.inst[e],e=t.out;return t}prefix(){let e="",t=this.skipNop(this.start);if(!Tt.isRuneOp(t.op)||t.runes.length!==1)return[t.op===Tt.MATCH,e];for(;Tt.isRuneOp(t.op)&&t.runes.length===1&&(t.arg&Je.FOLD_CASE)===0;)e+=String.fromCodePoint(t.runes[0]),t=this.skipNop(t.out);return[t.op===Tt.MATCH,e]}startCond(){let e=0,t=this.start;e:for(;;){const s=this.inst[t];switch(s.op){case Tt.EMPTY_WIDTH:e|=s.arg;break;case Tt.FAIL:return-1;case Tt.CAPTURE:case Tt.NOP:break;default:break e}t=s.out}return e}next(e){const t=this.inst[e>>1];return(e&1)===0?t.out:t.arg}patch(e,t){for(;e!==0;){const s=this.inst[e>>1];(e&1)===0?(e=s.out,s.out=t):(e=s.arg,s.arg=t)}}append(e,t){if(e===0)return t;if(t===0)return e;let s=e;for(;;){const i=this.next(s);if(i===0)break;s=i}const r=this.inst[s>>1];return(s&1)===0?r.out=t:r.arg=t,e}toString(){let e="";for(let t=0;t<this.inst.length;t++){const s=e.length;e+=t,t===this.start&&(e+="*"),e+=" ".substring(e.length-s),e+=this.inst[t],e+=` 22`}return e}}class Wg{constructor(e=0,t=0,s=!1){this.i=e,this.out=t,this.nullable=s}}class Ap{static ANY_RUNE_NOT_NL(){return[0,Se.CODES.get(` 23`)-1,Se.CODES.get(` 24`)+1,Wt.MAX_RUNE]}static ANY_RUNE(){return[0,Wt.MAX_RUNE]}static compileRegexp(e){const t=new Ap,s=t.compile(e);return t.prog.patch(s.out,t.newInst(Tt.MATCH).i),t.prog.start=s.i,t.prog}constructor(){this.prog=new _H,this.newInst(Tt.FAIL)}newInst(e){return this.prog.addInst(e),new Wg(this.prog.numInst()-1,0,!0)}nop(){const e=this.newInst(Tt.NOP);return e.out=e.i<<1,e}fail(){return new Wg}cap(e){const t=this.newInst(Tt.CAPTURE);return t.out=t.i<<1,this.prog.getInst(t.i).arg=e,this.prog.numCap<e+1&&(this.prog.numCap=e+1),t}cat(e,t){return e.i===0||t.i===0?this.fail():(this.prog.patch(e.out,t.i),new Wg(e.i,t.out,e.nullable&&t.nullable))}alt(e,t){if(e.i===0)return t;if(t.i===0)return e;const s=this.newInst(Tt.ALT),r=this.prog.getInst(s.i);return r.out=e.i,r.arg=t.i,s.out=this.prog.append(e.out,t.out),s.nullable=e.nullable||t.nullable,s}loop(e,t){const s=this.newInst(Tt.ALT),r=this.prog.getInst(s.i);return t?(r.arg=e.i,s.out=s.i<<1):(r.out=e.i,s.out=s.i<<1|1),this.prog.patch(e.out,s.i),s}quest(e,t){const s=this.newInst(Tt.ALT),r=this.prog.getInst(s.i);return t?(r.arg=e.i,s.out=s.i<<1):(r.out=e.i,s.out=s.i<<1|1),s.out=this.prog.append(s.out,e.out),s}star(e,t){return e.nullable?this.quest(this.plus(e,t),t):this.loop(e,t)}plus(e,t){return new Wg(e.i,this.loop(e,t).out,e.nullable)}empty(e){const t=this.newInst(Tt.EMPTY_WIDTH);return this.prog.getInst(t.i).arg=e,t.out=t.i<<1,t}rune(e,t){const s=this.newInst(Tt.RUNE);s.nullable=!1;const r=this.prog.getInst(s.i);return r.runes=e,t&=Je.FOLD_CASE,(e.length!==1||Wt.simpleFold(e[0])===e[0])&&(t&=-2),r.arg=t,s.out=s.i<<1,(t&Je.FOLD_CASE)===0&&e.length===1||e.length===2&&e[0]===e[1]?r.op=Tt.RUNE1:e.length===2&&e[0]===0&&e[1]===Wt.MAX_RUNE?r.op=Tt.RUNE_ANY:e.length===4&&e[0]===0&&e[1]===Se.CODES.get(` 25`)-1&&e[2]===Se.CODES.get(` 26`)+1&&e[3]===Wt.MAX_RUNE&&(r.op=Tt.RUNE_ANY_NOT_NL),s}compile(e){switch(e.op){case ce.Op.NO_MATCH:return this.fail();case ce.Op.EMPTY_MATCH:return this.nop();case ce.Op.LITERAL:if(e.runes.length===0)return this.nop();{let t=null;for(let s of e.runes){const r=this.rune([s],e.flags);t=t===null?r:this.cat(t,r)}return t}case ce.Op.CHAR_CLASS:return this.rune(e.runes,e.flags);case ce.Op.ANY_CHAR_NOT_NL:return this.rune(Ap.ANY_RUNE_NOT_NL(),0);case ce.Op.ANY_CHAR:return this.rune(Ap.ANY_RUNE(),0);case ce.Op.BEGIN_LINE:return this.empty(fn.EMPTY_BEGIN_LINE);case ce.Op.END_LINE:return this.empty(fn.EMPTY_END_LINE);case ce.Op.BEGIN_TEXT:return this.empty(fn.EMPTY_BEGIN_TEXT);case ce.Op.END_TEXT:return this.empty(fn.EMPTY_END_TEXT);case ce.Op.WORD_BOUNDARY:return this.empty(fn.EMPTY_WORD_BOUNDARY);case ce.Op.NO_WORD_BOUNDARY:return this.empty(fn.EMPTY_NO_WORD_BOUNDARY);case ce.Op.CAPTURE:{const t=this.cap(e.cap<<1),s=this.compile(e.subs[0]),r
26=this.cap(e.cap<<1|1);return this.cat(this.cat(t,s),r)}case ce.Op.STAR:return this.star(this.compile(e.subs[0]),(e.flags&Je.NON_GREEDY)!==0);case ce.Op.PLUS:return this.plus(this.compile(e.subs[0]),(e.flags&Je.NON_GREEDY)!==0);case ce.Op.QUEST:return this.quest(this.compile(e.subs[0]),(e.flags&Je.NON_GREEDY)!==0);case ce.Op.CONCAT:{if(e.subs.length===0)return this.nop();{let t=null;for(let s of e.subs){const r=this.compile(s);t=t===null?r:this.cat(t,r)}return t}}case ce.Op.ALTERNATE:{if(e.subs.length===0)return this.nop();{let t=null;for(let s of e.subs){const r=this.compile(s);t=t===null?r:this.alt(t,r)}return t}}default:throw new bH("regexp: unhandled case in compile")}}}class eo{static simplify(e){if(e===null)return null;switch(e.op){case ce.Op.CAPTURE:case ce.Op.CONCAT:case ce.Op.ALTERNATE:{let t=e;for(let s=0;s<e.subs.length;s++){const r=e.subs[s],i=eo.simplify(r);t===e&&i!==r&&(t=ce.fromRegexp(e),t.runes=null,t.subs=e.subs.slice(0,e.subs.length)),t!==e&&(t.subs[s]=i)}return t}case ce.Op.STAR:case ce.Op.PLUS:case ce.Op.QUEST:{const t=eo.simplify(e.subs[0]);return eo.simplify1(e.op,e.flags,t,e)}case ce.Op.REPEAT:{if(e.min===0&&e.max===0)return new ce(ce.Op.EMPTY_MATCH);const t=eo.simplify(e.subs[0]);if(e.max===-1){if(e.min===0)return eo.simplify1(ce.Op.STAR,e.flags,t,null);if(e.min===1)return eo.simplify1(ce.Op.PLUS,e.flags,t,null);const r=new ce(ce.Op.CONCAT),i=[];for(let a=0;a<e.min-1;a++)i.push(t);return i.push(eo.simplify1(ce.Op.PLUS,e.flags,t,null)),r.subs=i.slice(0),r}if(e.min===1&&e.max===1)return t;let s=null;if(e.min>0){s=[];for(let r=0;r<e.min;r++)s.push(t)}if(e.max>e.min){let r=eo.simplify1(ce.Op.QUEST,e.flags,t,null);for(let i=e.min+1;i<e.max;i++){const a=new ce(ce.Op.CONCAT);a.subs=[t,r],r=eo.simplify1(ce.Op.QUEST,e.flags,a,null)}if(s===null)return r;s.push(r)}if(s!==null){const r=new ce(ce.Op.CONCAT);return r.subs=s.slice(0),r}return new ce(ce.Op.NO_MATCH)}}return e}static simplify1(e,t,s,r){return s.op===ce.Op.EMPTY_MATCH||e===s.op&&(t&Je.NON_GREEDY)===(s.flags&Je.NON_GREEDY)?s:(r!==null&&r.op===e&&(r.flags&Je.NON_GREEDY)===(t&Je.NON_GREEDY)&&s===r.subs[0]||(r=new ce(e),r.flags=t,r.subs=[s]),r)}}class hn{constructor(e,t){this.sign=e,this.cls=t}}const y8=[48,57],v8=[9,10,12,13,32,32],b8=[48,57,65,90,95,95,97,122],w8=new Map([["\\d",new hn(1,y8)],["\\D",new hn(-1,y8)],["\\s",new hn(1,v8)],["\\S",new hn(-1,v8)],["\\w",new hn(1,b8)],["\\W",new hn(-1,b8)]]),S8=[48,57,65,90,97,122],E8=[65,90,97,122],T8=[0,127],_8=[9,9,32,32],I8=[0,31,127,127],A8=[48,57],C8=[33,126],k8=[97,122],R8=[32,126],P8=[33,47,58,64,91,96,123,126],N8=[9,13,32,32],L8=[65,90],D8=[48,57,65,90,95,95,97,122],j8=[48,57,65,70,97,102],O8=new Map([["[:alnum:]",new hn(1,S8)],["[:^alnum:]",new hn(-1,S8)],["[:alpha:]",new hn(1,E8)],["[:^alpha:]",new hn(-1,E8)],["[:ascii:]",new hn(1,T8)],["[:^ascii:]",new hn(-1,T8)],["[:blank:]",new hn(1,_8)],["[:^blank:]",new hn(-1,_8)],["[:cntrl:]",new hn(1,I8)],["[:^cntrl:]",new hn(-1,I8)],["[:digit:]",new hn(1,A8)],["[:^digit:]",new hn(-1,A8)],["[:graph:]",new hn(1,C8)],["[:^graph:]",new hn(-1,C8)],["[:lower:]",new hn(1,k8)],["[:^lower:]",new hn(-1,k8)],["[:print:]",new hn(1,R8)],["[:^print:]",new hn(-1,R8)],["[:punct:]",new hn(1,P8)],["[:^punct:]",new hn(-1,P8)],["[:space:]",new hn(1,N8)],["[:^space:]",new hn(-1,N8)],["[:upper:]",new hn(1,L8)],["[:^upper:]",new hn(-1,L8)],["[:word:]",new hn(1,D8)],["[:^word:]",new hn(-1,D8)],["[:xdigit:]",new hn(1,j8)],["[:^xdigit:]",new hn(-1,j8)]]);class Dr{static charClassToString(e,t){let s="[";for(let r=0;r<t;r+=2){r>0&&(s+=" ");const i=e[r],a=e[r+1];i===a?s+=`0x${i.toString(16)}`:s+=`0x${i.toString(16)}-0x${a.toString(16)}`}return s+="]",s}static cmp(e,t,s,r){const i=e[t]-s;return i!==0?i:r-e[t+1]}static qsortIntPair(e,t,s){const r=((t+s)/2|0)&-2,i=e[r],a=e[r+1];let l=t,c=s;for(;l<=c;){for(;l<s&&Dr.cmp(e,l,i,a)<0;)l+=2;for(;c>t&&Dr.cmp(e,c,i,a)>0;)c-=2;if(l<=c){if(l!==c){let d=e[l];e[l]=e[c],e[c]=d,d=e[l+1],e[l+1]=e[c+1],e[c+1]=d}l+=2,c-=2}}t<c&&Dr.qsortIntPair(e,t,c),l<s&&Dr.qsortIntPair(e,l,s)}constructor(e=fn.emptyInts()){this.r=e,this.len=e.length}toArray(){return this.len===this.r.length?this.r:this.r.slice(0,this.len)}cleanClass(){if(this.len<4)return this;Dr.qsortIntPair(this.r,0,this.len-2);let e=2;for(let t=2;t<this.len;t+=2){const s=this.r[t],r=this.r[t+1];if(s<=this.r[e-1]+1){r>this.r[e-1]&&(this.r[e-1]=r);continue}this.r[e]=s,this.r[e+1]=r,e+=2}return this.len=e,this}appendLiteral(e,t){return(t&Je.FOLD_CASE)!==0?this.appendFoldedRange(e,e):this.appendRange(e,e)}appendRange(e,t){if(this.len>0){for(let s=2;s<=4;s+=2)if(this.len>=s){const r=this.r[this.len-s],i=this.r[this.len-s+1];if(e<=i+1&&r<=t+1)return e<r&&(this.r[this.len-s]=e),t>i&&(this.r[this.len-s+1]=t),this}}return this.r[this.len++]=e,this.r[this.len++]=t,this}appendFoldedRange(e,t){if(e<=Wt.MIN_FOLD&&t>=Wt.MAX_FOLD)return this.appendRange(e,t);if(t<Wt.MIN_FOLD||e>Wt.MAX_FOLD)return this.appendRange(e,t);e<Wt.MIN_FOLD&&(this.appendRange(e,Wt.MIN_FOLD-1),e=Wt.MIN_FOLD),t>Wt.MAX_FOLD&&(this.appendRange(Wt.MAX_FOLD+1,t),t=Wt.MAX_FOLD);for(let s=e;s<=t;s++){this.appendRange(s,s);for(let r=Wt.simpleFold(s);r!==s;r=Wt.simpleFold(r))this.appendRange(r,r)}return this}appendClass(e){for(let t=0;t<e.length;t+=2)this.appendRange(e[t],e[t+1]);return this}appendFoldedClass(e){for(let t=0;t<e.length;t+=2)this.appendFoldedRange(e[t],e[t+1]);return this}appendNegatedClass(e){let t=0;for(let s=0;s<e.length;s+=2){const r=e[s],i=e[s+1];t<=r-1&&this.appendRange(t,r-1),t=i+1}return t<=Wt.MAX_RUNE&&this.appendRange(t,Wt.MAX_RUNE),this}appendTable(e){for(let t of e){const s=t[0],r=t[1],i=t[2];if(i===1){this.appendRange(s,r);continue}for(let a=s;a<=r;a+=i)this.appendRange(a,a)}return this}appendNegatedTable(e){let t=0;for(let s of e){const r=s[0],i=s[1],a=s[2];if(a===1){t<=r-1&&this.appendRange(t,r-1),t=i+1;continue}for(let l=r;l<=i;l+=a)t<=l-1&&this.appendRange(t,l-1),t=l+1}return t<=Wt.MAX_RUNE&&this.appendRange(t,Wt.MAX_RUNE),this}appendTableWithSign(e,t){return t<0?this.appendNegatedTable(e):this.appendTable(e)}negateClass(){let e=0,t=0;for(let s=0;s<this.len;s+=2){const r=this.r[s],i=this.r[s+1];
26e<=r-1&&(this.r[t]=e,this.r[t+1]=r-1,t+=2),e=i+1}return this.len=t,e<=Wt.MAX_RUNE&&(this.r[this.len++]=e,this.r[this.len++]=Wt.MAX_RUNE),this}appendClassWithSign(e,t){return t<0?this.appendNegatedClass(e):this.appendClass(e)}appendGroup(e,t){let s=e.cls;return t&&(s=new Dr().appendFoldedClass(s).cleanClass().toArray()),this.appendClassWithSign(s,e.sign)}toString(){return Dr.charClassToString(this.r,this.len)}}class Cp{static of(e,t){return new Cp(e,t)}constructor(e,t){this.first=e,this.second=t}}class IH{constructor(e){this.str=e,this.position=0}pos(){return this.position}rewindTo(e){this.position=e}more(){return this.position<this.str.length}peek(){return this.str.codePointAt(this.position)}skip(e){this.position+=e}skipString(e){this.position+=e.length}pop(){const e=this.str.codePointAt(this.position);return this.position+=fn.charCount(e),e}lookingAt(e){return this.rest().startsWith(e)}rest(){return this.str.substring(this.position)}from(e){return this.str.substring(e,this.position)}toString(){return this.rest()}}class Ot{static ERR_INTERNAL_ERROR="regexp/syntax: internal error";static ERR_INVALID_CHAR_RANGE="invalid character class range";static ERR_INVALID_ESCAPE="invalid escape sequence";static ERR_INVALID_NAMED_CAPTURE="invalid named capture";static ERR_INVALID_PERL_OP="invalid or unsupported Perl syntax";static ERR_INVALID_REPEAT_OP="invalid nested repetition operator";static ERR_INVALID_REPEAT_SIZE="invalid repeat count";static ERR_MISSING_BRACKET="missing closing ]";static ERR_MISSING_PAREN="missing closing )";static ERR_MISSING_REPEAT_ARGUMENT="missing argument to repetition operator";static ERR_TRAILING_BACKSLASH="trailing backslash at end of expression";static ERR_DUPLICATE_NAMED_CAPTURE="duplicate capture group name";static ANY_TABLE(){return[[0,Wt.MAX_RUNE,1]]}static unicodeTable(e){return e==="Any"?Cp.of(Ot.ANY_TABLE(),Ot.ANY_TABLE()):te.CATEGORIES.has(e)?Cp.of(te.CATEGORIES.get(e),te.FOLD_CATEGORIES.get(e)):te.SCRIPTS.has(e)?Cp.of(te.SCRIPTS.get(e),te.FOLD_SCRIPT.get(e)):null}static minFoldRune(e){if(e<Wt.MIN_FOLD||e>Wt.MAX_FOLD)return e;let t=e;const s=e;for(e=Wt.simpleFold(e);e!==s;e=Wt.simpleFold(e))t>e&&(t=e);return t}static leadingRegexp(e){if(e.op===ce.Op.EMPTY_MATCH)return null;if(e.op===ce.Op.CONCAT&&e.subs.length>0){const t=e.subs[0];return t.op===ce.Op.EMPTY_MATCH?null:t}return e}static literalRegexp(e,t){const s=new ce(ce.Op.LITERAL);return s.flags=t,s.runes=fn.stringToRunes(e),s}static parse(e,t){return new Ot(e,t).parseInternal()}static parseRepeat(e){const t=e.pos();if(!e.more()||!e.lookingAt("{"))return-1;e.skip(1);const s=Ot.parseInt(e);if(s===-1||!e.more())return-1;let r;if(!e.lookingAt(","))r=s;else{if(e.skip(1),!e.more())return-1;if(e.lookingAt("}"))r=-1;else if((r=Ot.parseInt(e))===-1)return-1}if(!e.more()||!e.lookingAt("}"))return-1;if(e.skip(1),s<0||s>1e3||r===-2||r>1e3||r>=0&&s>r)throw new Es(Ot.ERR_INVALID_REPEAT_SIZE,e.from(t));return s<<16|r&Wt.MAX_BMP}static isValidCaptureName(e){if(e.length===0)return!1;for(let t=0;t<e.length;t++){const s=e.codePointAt(t);if(s!==Se.CODES.get("_")&&!fn.isalnum(s))return!1}return!0}static parseInt(e){const t=e.pos();for(;e.more()&&e.peek()>=Se.CODES.get("0")&&e.peek()<=Se.CODES.get("9");)e.skip(1);const s=e.from(t);return s.length===0||s.length>1&&s.codePointAt(0)===Se.CODES.get("0")?-1:s.length>8?-2:parseFloat(s,10)}static isCharClass(e){return e.op===ce.Op.LITERAL&&e.runes.length===1||e.op===ce.Op.CHAR_CLASS||e.op===ce.Op.ANY_CHAR_NOT_NL||e.op===ce.Op.ANY_CHAR}static matchRune(e,t){switch(e.op){case ce.Op.LITERAL:return e.runes.length===1&&e.runes[0]===t;case ce.Op.CHAR_CLASS:for(let s=0;s<e.runes.length;s+=2)if(e.runes[s]<=t&&t<=e.runes[s+1])return!0;return!1;case ce.Op.ANY_CHAR_NOT_NL:return t!==Se.CODES.get(` 27`);case ce.Op.ANY_CHAR:return!0}return!1}static mergeCharClass(e,t){switch(e.op){case ce.Op.ANY_CHAR:break;case ce.Op.ANY_CHAR_NOT_NL:Ot.matchRune(t,Se.CODES.get(` 28`))&&(e.op=ce.Op.ANY_CHAR);break;case ce.Op.CHAR_CLASS:t.op===ce.Op.LITERAL?e.runes=new Dr(e.runes).appendLiteral(t.runes[0],t.flags).toArray():e.runes=new Dr(e.runes).appendClass(t.runes).toArray();break;case ce.Op.LITERAL:if(t.runes[0]===e.runes[0]&&t.flags===e.flags)break;e.op=ce.Op.CHAR_CLASS,e.runes=new Dr().appendLiteral(e.runes[0],e.flags).appendLiteral(t.runes[0],t.flags).toArray();break}}static parseEscape(e){const t=e.pos();
28if(e.skip(1),!e.more())throw new Es(Ot.ERR_TRAILING_BACKSLASH);let s=e.pop();e:switch(s){case Se.CODES.get("1"):case Se.CODES.get("2"):case Se.CODES.get("3"):case Se.CODES.get("4"):case Se.CODES.get("5"):case Se.CODES.get("6"):case Se.CODES.get("7"):if(!e.more()||e.peek()<Se.CODES.get("0")||e.peek()>Se.CODES.get("7"))break;case Se.CODES.get("0"):{let r=s-Se.CODES.get("0");for(let i=1;i<3&&!(!e.more()||e.peek()<Se.CODES.get("0")||e.peek()>Se.CODES.get("7"));i++)r=r*8+e.peek()-Se.CODES.get("0"),e.skip(1);return r}case Se.CODES.get("x"):{if(!e.more())break;if(s=e.pop(),s===Se.CODES.get("{")){let a=0,l=0;for(;;){if(!e.more())break e;if(s=e.pop(),s===Se.CODES.get("}"))break;const c=fn.unhex(s);if(c<0||(l=l*16+c,l>Wt.MAX_RUNE))break e;a++}if(a===0)break e;return l}const r=fn.unhex(s);if(!e.more())break;s=e.pop();const i=fn.unhex(s);if(r<0||i<0)break;return r*16+i}case Se.CODES.get("a"):return Se.CODES.get("\x07");case Se.CODES.get("f"):return Se.CODES.get("\f");case Se.CODES.get("n"):return Se.CODES.get(` 29`);case Se.CODES.get("r"):return Se.CODES.get("\r");case Se.CODES.get("t"):return Se.CODES.get(" ");case Se.CODES.get("v"):return Se.CODES.get("\v");default:if(!fn.isalnum(s))return s;break}throw new Es(Ot.ERR_INVALID_ESCAPE,e.from(t))}static parseClassChar(e,t){if(!e.more())throw new Es(Ot.ERR_MISSING_BRACKET,e.from(t));return e.lookingAt("\\")?Ot.parseEscape(e):e.pop()}static concatRunes(e,t){return[...e,...t]}constructor(e,t=0){this.wholeRegexp=e,this.flags=t,this.numCap=0,this.namedGroups={},this.stack=[],this.free=null}newRegexp(e){let t=this.free;return t!==null&&t.subs!==null&&t.subs.length>0?(this.free=t.subs[0],t.reinit(),t.op=e):t=new ce(e),t}reuse(e){e.subs!==null&&e.subs.length>0&&(e.subs[0]=this.free),this.free=e}pop(){return this.stack.pop()}popToPseudo(){const e=this.stack.length;let t=e;for(;t>0&&!ce.isPseudoOp(this.stack[t-1].op);)t--;const s=this.stack.slice(t,e);return this.stack=this.stack.slice(0,t),s}push(e){if(e.op===ce.Op.CHAR_CLASS&&e.runes.length===2&&e.runes[0]===e.runes[1]){if(this.maybeConcat(e.runes[0],this.flags&-2))return null;e.op=ce.Op.LITERAL,e.runes=[e.runes[0]],e.flags=this.flags&-2}else if(e.op===ce.Op.CHAR_CLASS&&e.runes.length===4&&e.runes[0]===e.runes[1]&&e.runes[2]===e.runes[3]&&Wt.simpleFold(e.runes[0])===e.runes[2]&&Wt.simpleFold(e.runes[2])===e.runes[0]||e.op===ce.Op.CHAR_CLASS&&e.runes.length===2&&e.runes[0]+1===e.runes[1]&&Wt.simpleFold(e.runes[0])===e.runes[1]&&Wt.simpleFold(e.runes[1])===e.runes[0]){if(this.maybeConcat(e.runes[0],this.flags|Je.FOLD_CASE))return null;e.op=ce.Op.LITERAL,e.runes=[e.runes[0]],e.flags=this.flags|Je.FOLD_CASE}else this.maybeConcat(-1,0);return this.stack.push(e),e}maybeConcat(e,t){const s=this.stack.length;if(s<2)return!1;const r=this.stack[s-1],i=this.stack[s-2];
29return r.op!==ce.Op.LITERAL||i.op!==ce.Op.LITERAL||(r.flags&Je.FOLD_CASE)!==(i.flags&Je.FOLD_CASE)?!1:(i.runes=Ot.concatRunes(i.runes,r.runes),e>=0?(r.runes=[e],r.flags=t,!0):(this.pop(),this.reuse(r),!1))}newLiteral(e,t){const s=this.newRegexp(ce.Op.LITERAL);return s.flags=t,(t&Je.FOLD_CASE)!==0&&(e=Ot.minFoldRune(e)),s.runes=[e],s}literal(e){this.push(this.newLiteral(e,this.flags))}op(e){const t=this.newRegexp(e);return t.flags=this.flags,this.push(t)}repeat(e,t,s,r,i,a){let l=this.flags;if((l&Je.PERL_X)!==0&&(i.more()&&i.lookingAt("?")&&(i.skip(1),l^=Je.NON_GREEDY),a!==-1))throw new Es(Ot.ERR_INVALID_REPEAT_OP,i.from(a));const c=this.stack.length;if(c===0)throw new Es(Ot.ERR_MISSING_REPEAT_ARGUMENT,i.from(r));const d=this.stack[c-1];if(ce.isPseudoOp(d.op))throw new Es(Ot.ERR_MISSING_REPEAT_ARGUMENT,i.from(r));const h=this.newRegexp(e);h.min=t,h.max=s,h.flags=l,h.subs=[d],this.stack[c-1]=h}concat(){this.maybeConcat(-1,0);const e=this.popToPseudo();return e.length===0?this.push(this.newRegexp(ce.Op.EMPTY_MATCH)):this.push(this.collapse(e,ce.Op.CONCAT))}alternate(){const e=this.popToPseudo();return e.length>0&&this.cleanAlt(e[e.length-1]),e.length===0?this.push(this.newRegexp(ce.Op.NO_MATCH)):this.push(this.collapse(e,ce.Op.ALTERNATE))}cleanAlt(e){e.op===ce.Op.CHAR_CLASS&&(e.runes=new Dr(e.runes).cleanClass().toArray(),e.runes.length===2&&e.runes[0]===0&&e.runes[1]===Wt.MAX_RUNE?(e.runes=null,e.op=ce.Op.ANY_CHAR):e.runes.length===4&&e.runes[0]===0&&e.runes[1]===Se.CODES.get(` 30`)-1&&e.runes[2]===Se.CODES.get(` 31`)+1&&e.runes[3]===Wt.MAX_RUNE&&(e.runes=null,e.op=ce.Op.ANY_CHAR_NOT_NL))}collapse(e,t){if(e.length===1)return e[0];let s=0;for(let l of e)s+=l.op===t?l.subs.length:1;let r=new Array(s).fill(null),i=0;for(let l of e)l.op===t?(r.splice(i,l.subs.length,...l.subs),i+=l.subs.length,this.reuse(l)):r[i++]=l;let a=this.newRegexp(t);if(a.subs=r,t===ce.Op.ALTERNATE&&(a.subs=this.factor(a.subs),a.subs.length===1)){const l=a;a=a.subs[0],this.reuse(l)}return a}factor(e){if(e.length<2)return e;let t=0,s=e.length,r=0,i=null,a=0,l=0,c=0;for(let h=0;h<=s;h++){let p=null,m=0,y=0;if(h<s){let x=e[t+h];if(x.op===ce.Op.CONCAT&&x.subs.length>0&&(x=x.subs[0]),x.op===ce.Op.LITERAL&&(p=x.runes,m=x.runes.length,y=x.flags&Je.FOLD_CASE),y===l){let w=0;for(;w<a&&w<m&&i[w]===p[w];)w++;if(w>0){a=w;continue}}}if(h!==c)if(h===c+1)e[r++]=e[t+c];else{const x=this.newRegexp(ce.Op.LITERAL);x.flags=l,x.runes=i.slice(0,a);for(let _=c;_<h;_++)e[t+_]=this.removeLeadingString(e[t+_],a);const w=this.collapse(e.slice(t+c,t+h),ce.Op.ALTERNATE),S=this.newRegexp(ce.Op.CONCAT);S.subs=[x,w],e[r++]=S}c=h,i=p,a=m,l=y}s=r,t=0,c=0,r=0;let d=null;for(let h=0;h<=s;h++){let p=null;if(!(h<s&&(p=Ot.leadingRegexp(e[t+h]),d!==null&&d.equals(p)&&(Ot.isCharClass(d)||d.op===ce.Op.REPEAT&&d.min===d.max&&Ot.isCharClass(d.subs[0]))))){if(h!==c)if(h===c+1)e[r++]=e[t+c];else{const m=d;for(let w=c;w<h;w++){const S=w!==c;e[t+w]=this.removeLeadingRegexp(e[t+w],S)}const y=this.collapse(e.slice(t+c,t+h),ce.Op.ALTERNATE),x=this.newRegexp(ce.Op.CONCAT);x.subs=[m,y],e[r++]=x}c=h,d=p}}s=r,t=0,c=0,r=0;for(let h=0;h<=s;h++)if(!(h<s&&Ot.isCharClass(e[t+h]))){if(h!==c)if(h===c+1)e[r++]=e[t+c];else{let p=c;for(let y=c+1;y<h;y++){const x=e[t+p],w=e[t+y];(x.op<w.op||x.op===w.op&&(x.runes!==null?x.runes.length:0)<(w.runes!==null?w.runes.length:0))&&(p=y)}const m=e[t+c];e[t+c]=e[t+p],e[t+p]=m;for(let y=c+1;y<h;y++)Ot.mergeCharClass(e[t+c],e[t+y]),this.reuse(e[t+y]);this.cleanAlt(e[t+c]),e[r++]=e[t+c]}h<s&&(e[r++]=e[t+h]),c=h+1}s=r,t=0,c=0,r=0;for(let h=0;h<s;++h)h+1<s&&e[t+h].op===ce.Op.EMPTY_MATCH&&e[t+h+1].op===ce.Op.EMPTY_MATCH||(e[r++]=e[t+h]);return s=r,t=0,e.slice(t,s)}removeLeadingString(e,t){if(e.op===ce.Op.CONCAT&&e.subs.length>0){const s=this.removeLeadingString(e.subs[0],t);if(e.subs[0]=s,s.op===ce.Op.EMPTY_MATCH)switch(this.reuse(s),e.subs.length){case 0:case 1:e.op=ce.Op.EMPTY_MATCH,e.subs=null;break;case 2:{const r=e;e=e.subs[1],this.reuse(r);break}default:e.subs=e.subs.slice(1,e.subs.length);break}return e}return e.op===ce.Op.LITERAL&&(e.runes=e.runes.slice(t,e.runes.length),e.runes.length===0&&(e.op=ce.Op.EMPTY_MATCH)),e}removeLeadingRegexp(e,t){if(e.op===ce.Op.CONCAT&&e.subs.length>0){switch(t&&this.reuse(e.subs[0]),e.subs=e.subs.slice(1,e.subs.length),e.subs.length){case 0:{e.op=ce.Op.EMPTY_MATCH,e.subs=ce.emptySubs();break}case 1:{const s=e;e=e.subs[0],this.reuse(s);break}}return e}return t&&this.reuse(e),this.newRegexp(ce.Op.EMPTY_MATCH)}parseInternal(){if((this.flags&Je.LITERAL)!==0)return Ot.literalRegexp(this.wholeRegexp,this.flags);let e=-1,t=-1,s=-1;const r=new IH(this.wholeRegexp);for(;r.more();){let a=-1;e:switch(r.peek()){case Se.CODES.get("("):if((this.flags&Je.PERL_X)!==0&&r.lookingAt("(?")){this.parsePerlFlags(r);break}this.op(ce.Op.LEFT_PAREN).cap=++this.numCap,r.skip(1);break;case Se.CODES.get("|"):this.parseVerticalBar(),r.skip(1);break;case Se.CODES.get(")"):this.parseRightParen(),r.skip(1);break;
31case Se.CODES.get("^"):(this.flags&Je.ONE_LINE)!==0?this.op(ce.Op.BEGIN_TEXT):this.op(ce.Op.BEGIN_LINE),r.skip(1);break;case Se.CODES.get("$"):(this.flags&Je.ONE_LINE)!==0?this.op(ce.Op.END_TEXT).flags|=Je.WAS_DOLLAR:this.op(ce.Op.END_LINE),r.skip(1);break;case Se.CODES.get("."):(this.flags&Je.DOT_NL)!==0?this.op(ce.Op.ANY_CHAR):this.op(ce.Op.ANY_CHAR_NOT_NL),r.skip(1);break;case Se.CODES.get("["):this.parseClass(r);break;case Se.CODES.get("*"):case Se.CODES.get("+"):case Se.CODES.get("?"):{a=r.pos();let l=null;switch(r.pop()){case Se.CODES.get("*"):l=ce.Op.STAR;break;case Se.CODES.get("+"):l=ce.Op.PLUS;break;case Se.CODES.get("?"):l=ce.Op.QUEST;break}this.repeat(l,t,s,a,r,e);break}case Se.CODES.get("{"):{a=r.pos();const l=Ot.parseRepeat(r);if(l<0){r.rewindTo(a),this.literal(r.pop());break}t=l>>16,s=(l&Wt.MAX_BMP)<<16>>16,this.repeat(ce.Op.REPEAT,t,s,a,r,e);break}case Se.CODES.get("\\"):{const l=r.pos();if(r.skip(1),(this.flags&Je.PERL_X)!==0&&r.more())switch(r.pop()){case Se.CODES.get("A"):this.op(ce.Op.BEGIN_TEXT);break e;case Se.CODES.get("b"):this.op(ce.Op.WORD_BOUNDARY);break e;case Se.CODES.get("B"):this.op(ce.Op.NO_WORD_BOUNDARY);break e;case Se.CODES.get("C"):throw new Es(Ot.ERR_INVALID_ESCAPE,"\\C");case Se.CODES.get("Q"):{let p=r.rest();const m=p.indexOf("\\E");m>=0&&(p=p.substring(0,m)),r.skipString(p),r.skipString("\\E");let y=0;for(;y<p.length;){const x=p.codePointAt(y);this.literal(x),y+=fn.charCount(x)}break e}case Se.CODES.get("z"):this.op(ce.Op.END_TEXT);break e;default:r.rewindTo(l);break}const c=this.newRegexp(ce.Op.CHAR_CLASS);if(c.flags=this.flags,r.lookingAt("\\p")||r.lookingAt("\\P")){const h=new Dr;if(this.parseUnicodeClass(r,h)){c.runes=h.toArray(),this.push(c);break e}}const d=new Dr;if(this.parsePerlClassEscape(r,d)){c.runes=d.toArray(),this.push(c);break e}r.rewindTo(l),this.reuse(c),this.literal(Ot.parseEscape(r));break}default:this.literal(r.pop());break}e=a}if(this.concat(),this.swapVerticalBar()&&this.pop(),this.alternate(),this.stack.length!==1)throw new Es(Ot.ERR_MISSING_PAREN,this.wholeRegexp);return this.stack[0].namedGroups=this.namedGroups,this.stack[0]}parsePerlFlags(e){const t=e.pos(),s=e.rest();if(s.startsWith("(?P<")||s.startsWith("(?<")){const l=s.charAt(2)==="P"?4:3,c=s.indexOf(">");if(c<0)throw new Es(Ot.ERR_INVALID_NAMED_CAPTURE,s);const d=s.substring(l,c);if(e.skipString(d),e.skip(l+1),!Ot.isValidCaptureName(d))throw new Es(Ot.ERR_INVALID_NAMED_CAPTURE,s.substring(0,c+1));const h=this.op(ce.Op.LEFT_PAREN);if(h.cap=++this.numCap,this.namedGroups[d])throw new Es(Ot.ERR_DUPLICATE_NAMED_CAPTURE,d);this.namedGroups[d]=this.numCap,h.name=d;return}e.skip(2);let r=this.flags,i=1,a=!1;e:for(;e.more();){const l=e.pop();switch(l){case Se.CODES.get("i"):r|=Je.FOLD_CASE,a=!0;break;case Se.CODES.get("m"):r&=-17,a=!0;break;case Se.CODES.get("s"):r|=Je.DOT_NL,a=!0;break;case Se.CODES.get("U"):r|=Je.NON_GREEDY,a=!0;break;case Se.CODES.get("-"):if(i<0)break e;i=-1,r=~r,a=!1;break;case Se.CODES.get(":"):case Se.CODES.get(")"):if(i<0){if(!a)break e;r=~r}l===Se.CODES.get(":")&&this.op(ce.Op.LEFT_PAREN),this.flags=r;return;default:break e}}throw new Es(Ot.ERR_INVALID_PERL_OP,e.from(t))}parseVerticalBar(){this.concat(),this.swapVerticalBar()||this.op(ce.Op.VERTICAL_BAR)}swapVerticalBar(){const e=this.stack.length;if(e>=3&&this.stack[e-2].op===ce.Op.VERTICAL_BAR&&Ot.isCharClass(this.stack[e-1])&&Ot.isCharClass(this.stack[e-3])){let t=this.stack[e-1],s=this.stack[e-3];if(t.op>s.op){const r=s;s=t,t=r,this.stack[e-3]=s}return Ot.mergeCharClass(s,t),this.reuse(t),this.pop(),!0}if(e>=2){const t=this.stack[e-1],s=this.stack[e-2];if(s.op===ce.Op.VERTICAL_BAR)return e>=3&&this.cleanAlt(this.stack[e-3]),this.stack[e-2]=t,this.stack[e-1]=s,!0}return!1}parseRightParen(){if(this.concat(),this.swapVerticalBar()&&this.pop(),this.alternate(),this.stack.length<2)throw new Es(Ot.ERR_INTERNAL_ERROR,"stack underflow");const t=this.pop(),s=this.pop();if(s.op!==ce.Op.LEFT_PAREN)throw new Es(Ot.ERR_MISSING_PAREN,this.wholeRegexp);this.flags=s.flags,s.cap===0?this.push(t):(s.op=ce.Op.CAPTURE,s.subs=[t],this.push(s))}parsePerlClassEscape(e,t){const s=e.pos();if((this.flags&Je.PERL_X)===0||!e.more()||e.pop()!==Se.CODES.get("\\")||!e.more())return!1;e.pop();const r=e.from(s),i=w8.has(r)?w8.get(r):null;return i===null?!1:(t.appendGroup(i,(this.flags&Je.FOLD_CASE)!==0),!0)}parseNamedClass(e,t){const s=e.rest(),r=s.indexOf(":]");if(r<0)return!1;const i=s.substring(0,r+2);e.skipString(i);const a=O8.has(i)?O8.get(i):null;
31if(a===null)throw new Es(Ot.ERR_INVALID_CHAR_RANGE,i);return t.appendGroup(a,(this.flags&Je.FOLD_CASE)!==0),!0}parseUnicodeClass(e,t){const s=e.pos();if((this.flags&Je.UNICODE_GROUPS)===0||!e.lookingAt("\\p")&&!e.lookingAt("\\P"))return!1;e.skip(1);let r=1,i=e.pop();if(i===Se.CODES.get("P")&&(r=-1),!e.more())throw e.rewindTo(s),new Es(Ot.ERR_INVALID_CHAR_RANGE,e.rest());i=e.pop();let a;if(i!==Se.CODES.get("{"))a=fn.runeToString(i);else{const h=e.rest(),p=h.indexOf("}");if(p<0)throw e.rewindTo(s),new Es(Ot.ERR_INVALID_CHAR_RANGE,e.rest());a=h.substring(0,p),e.skipString(a),e.skip(1)}a.length!==0&&a.codePointAt(0)===Se.CODES.get("^")&&(r=0-r,a=a.substring(1));const l=Ot.unicodeTable(a);if(l===null)throw new Es(Ot.ERR_INVALID_CHAR_RANGE,e.from(s));const c=l.first,d=l.second;if((this.flags&Je.FOLD_CASE)===0||d===null)t.appendTableWithSign(c,r);else{const h=new Dr().appendTable(c).appendTable(d).cleanClass().toArray();t.appendClassWithSign(h,r)}return!0}parseClass(e){const t=e.pos();e.skip(1);const s=this.newRegexp(ce.Op.CHAR_CLASS);s.flags=this.flags;const r=new Dr;let i=1;e.more()&&e.lookingAt("^")&&(i=-1,e.skip(1),(this.flags&Je.CLASS_NL)===0&&r.appendRange(Se.CODES.get(` 32`),Se.CODES.get(` 33`)));let a=!0;for(;!e.more()||e.peek()!==Se.CODES.get("]")||a;){if(e.more()&&e.lookingAt("-")&&(this.flags&Je.PERL_X)===0&&!a){const h=e.rest();if(h==="-"||!h.startsWith("-]"))throw e.rewindTo(t),new Es(Ot.ERR_INVALID_CHAR_RANGE,e.rest())}a=!1;const l=e.pos();if(e.lookingAt("[:")){if(this.parseNamedClass(e,r))continue;e.rewindTo(l)}if(this.parseUnicodeClass(e,r)||this.parsePerlClassEscape(e,r))continue;e.rewindTo(l);const c=Ot.parseClassChar(e,t);let d=c;if(e.more()&&e.lookingAt("-")){if(e.skip(1),e.more()&&e.lookingAt("]"))e.skip(-1);else if(d=Ot.parseClassChar(e,t),d<c)throw new Es(Ot.ERR_INVALID_CHAR_RANGE,e.from(l))}(this.flags&Je.FOLD_CASE)===0?r.appendRange(c,d):r.appendFoldedRange(c,d)}e.skip(1),r.cleanClass(),i<0&&r.negateClass(),s.runes=r.toArray(),this.push(s)}}class AH{constructor(){this.inst=null,this.cap=[]}}class M8{constructor(){this.sparse=[],this.densePcs=[],this.denseThreads=[],this.size=0}contains(e){const t=this.sparse[e];return t<this.size&&this.densePcs[t]===e}isEmpty(){return this.size===0}add(e){const t=this.size++;return this.sparse[e]=t,this.denseThreads[t]=null,this.densePcs[t]=e,t}clear(){this.sparse=[],this.densePcs=[],this.denseThreads=[],this.size=0}toString(){let e="{";for(let t=0;t<this.size;t++)t!==0&&(e+=", "),e+=this.densePcs[t];return e+="}",e}}class Uh{static fromRE2(e){const t=new Uh;return t.prog=e.prog,t.re2=e,t.q0=new M8(t.prog.numInst()),t.q1=new M8(t.prog.numInst()),t.pool=[],t.poolSize=0,t.matched=!1,t.matchcap=Array(t.prog.numCap<2?2:t.prog.numCap).fill(0),t.ncap=0,t}static fromMachine(e){const t=new Uh;return t.re2=e.re2,t.prog=e.prog,t.q0=e.q0,t.q1=e.q1,t.pool=e.pool,t.poolSize=e.poolSize,t.matched=e.matched,t.matchcap=e.matchcap,t.ncap=e.ncap,t}init(e){this.ncap=e,e>this.matchcap.length?this.initNewCap(e):this.resetCap(e)}resetCap(e){for(let t=0;t<this.poolSize;t++){const s=this.pool[t];s.cap=Array(e).fill(0)}}initNewCap(e){for(let t=0;t<this.poolSize;t++){const s=this.pool[t];s.cap=Array(e).fill(0)}this.matchcap=Array(e).fill(0)}submatches(){return this.ncap===0?fn.emptyInts():this.matchcap.slice(0,this.ncap)}alloc(e){let t;return this.poolSize>0?(this.poolSize--,t=this.pool[this.poolSize]):t=new AH,t.inst=e,t}freeQueue(e,t=0){const s=e.size-t,r=this.poolSize+s;this.pool.length<r&&(this.pool=this.pool.slice(0,Math.max(this.pool.length*2,r)));for(let i=t;i<e.size;i++){const a=e.denseThreads[i];a!==null&&(this.pool[this.poolSize]=a,this.poolSize++)}e.clear()}freeThread(e){this.pool.length<=this.poolSize&&(this.pool=this.pool.slice(0,this.pool.length*2)),this.pool[this.poolSize]=e,this.poolSize++}match(e,t,s){const r=this.re2.cond;if(r===fn.EMPTY_ALL||(s===Je.ANCHOR_START||s===Je.ANCHOR_BOTH)&&t!==0)return!1;this.matched=!1,this.matchcap=Array(this.prog.numCap).fill(-1);let i=this.q0,a=this.q1,l=e.step(t),c=l>>3,d=l&7,h=-1,p=0;l!==Lc.EOF()&&(l=e.step(t+d),h=l>>3,p=l&7);let m;for(t===0?m=fn.emptyOpContext(-1,c):m=e.context(t);;){if(i.isEmpty()){if((r&fn.EMPTY_BEGIN_TEXT)!==0&&t!==0||this.matched)break;if(this.re2.prefix.length!==0&&h!==this.re2.prefixRune&&e.canCheckPrefix()){const w=e.index(this.re2,t);if(w<0)break;t+=w,l=e.step(t),c=l>>3,d=l&7,l=e.step(t+d),h=l>>3,p=l&7}}!this.matched&&(t===0||s===Je.UNANCHORED)&&(this.ncap>0&&(this.matchcap[0]=t),this.add(i,this.prog.start,t,this.matchcap,m,null));const y=t+d;if(m=e.context(y),this.step(i,a,t,y,c,m,s,t===e.endPos()),d===0||this.ncap===0&&this.matched)break;t+=d,c=h,d=p,c!==-1&&(l=e.step(t+d),h=l>>3,p=l&7);const x=i;i=a,a=x}return this.freeQueue(a),this.matched}step(e,t,s,r,i,a,l,c){const d=this.re2.longest;for(let h=0;h<e.size;h++){let p=e.denseThreads[h];if(p===null)continue;if(d&&this.matched&&this.ncap>0&&this.matchcap[0]<p.cap[0]){this.freeThread(p);continue}const m=p.inst;let y=!1;switch(m.op){case Tt.MATCH:if(l===Je.ANCHOR_BOTH&&!c)break;this.ncap>
330&&(!d||!this.matched||this.matchcap[1]<s)&&(p.cap[1]=s,this.matchcap=p.cap.slice(0,this.ncap)),d||this.freeQueue(e,h+1),this.matched=!0;break;case Tt.RUNE:y=m.matchRune(i);break;case Tt.RUNE1:y=i===m.runes[0];break;case Tt.RUNE_ANY:y=!0;break;case Tt.RUNE_ANY_NOT_NL:y=i!==Se.CODES.get(` 34`);break;default:throw new Error("bad inst")}y&&(p=this.add(t,m.out,r,p.cap,a,p)),p!==null&&(this.freeThread(p),e.denseThreads[h]=null)}e.clear()}add(e,t,s,r,i,a){if(t===0||e.contains(t))return a;const l=e.add(t),c=this.prog.inst[t];switch(c.op){case Tt.FAIL:break;case Tt.ALT:case Tt.ALT_MATCH:a=this.add(e,c.out,s,r,i,a),a=this.add(e,c.arg,s,r,i,a);break;case Tt.EMPTY_WIDTH:(c.arg&~i)===0&&(a=this.add(e,c.out,s,r,i,a));break;case Tt.NOP:a=this.add(e,c.out,s,r,i,a);break;case Tt.CAPTURE:if(c.arg<this.ncap){const d=r[c.arg];r[c.arg]=s,this.add(e,c.out,s,r,i,null),r[c.arg]=d}else a=this.add(e,c.out,s,r,i,a);break;case Tt.MATCH:case Tt.RUNE:case Tt.RUNE1:case Tt.RUNE_ANY:case Tt.RUNE_ANY_NOT_NL:a===null?a=this.alloc(c):a.inst=c,this.ncap>0&&a.cap!==r&&(a.cap=r.slice(0,this.ncap)),e.denseThreads[l]=a,a=null;break;default:throw new Error("unhandled")}return a}}class CH{constructor(e){this.value=e}get(){return this.value}set(e){this.value=e}compareAndSet(e,t){return this.value===e?(this.value=t,!0):!1}}class Rc{static initTest(e){const t=Rc.compile(e),s=new Rc(t.expr,t.prog,t.numSubexp,t.longest);return s.cond=t.cond,s.prefix=t.prefix,s.prefixUTF8=t.prefixUTF8,s.prefixComplete=t.prefixComplete,s.prefixRune=t.prefixRune,s}static compile(e){return Rc.compileImpl(e,Je.PERL,!1)}static compilePOSIX(e){return Rc.compileImpl(e,Je.POSIX,!0)}static compileImpl(e,t,s){let r=Ot.parse(e,t);const i=r.maxCap();r=eo.simplify(r);const a=Ap.compileRegexp(r),l=new Rc(e,a,i,s),[c,d]=a.prefix();return l.prefixComplete=c,l.prefix=d,l.prefixUTF8=fn.stringToUtf8ByteArray(l.prefix),l.prefix.length>0&&(l.prefixRune=l.prefix.codePointAt(0)),l.namedGroups=r.namedGroups,l}static match(e,t){return Rc.compile(e).match(t)}constructor(e,t,s=0,r=0){this.expr=e,this.prog=t,this.numSubexp=s,this.longest=r,this.cond=t.startCond(),this.prefix=null,this.prefixUTF8=null,this.prefixComplete=!1,this.prefixRune=0,this.pooled=new CH}numberOfCapturingGroups(){return this.numSubexp}get(){let e;do e=this.pooled.get();while(e&&!this.pooled.compareAndSet(e,e.next));return e}reset(){this.pooled.set(null)}put(e,t){let s=this.pooled.get();do s=this.pooled.get(),!t&&s&&(e=Uh.fromMachine(e),t=!0),e.next!==s&&(e.next=s);while(!this.pooled.compareAndSet(s,e))}toString(){return this.expr}doExecute(e,t,s,r){let i=this.get(),a=!1;i?i.next!==null&&(i=Uh.fromMachine(i),a=!0):(i=Uh.fromRE2(this),a=!0),i.init(r);const l=i.match(e,t,s)?i.submatches():null;return this.put(i,a),l}match(e){return this.doExecute(Ts.fromUTF16(e),0,Je.UNANCHORED,0)!==null}matchWithGroup(e,t,s,r,i){return e instanceof Gl||(e=l1.utf16(e)),this.matchMachineInput(e,t,s,r,i)}matchMachineInput(e,t,s,r,i){if(t>s)return[!1,null];const a=e.isUTF16Encoding()?Ts.fromUTF16(e.asCharSequence(),0,s):Ts.fromUTF8(e.asBytes(),0,s),l=this.doExecute(a,t,r,2*i);return l===null?[!1,null]:[!0,l]}matchUTF8(e){return this.doExecute(Ts.fromUTF8(e),0,Je.UNANCHORED,0)!==null}replaceAll(e,t){return this.replaceAllFunc(e,()=>t,2*e.length+1)}replaceFirst(e,t){return this.replaceAllFunc(e,()=>t,1)}replaceAllFunc(e,t,s){let r=0,i=0,a="";const l=Ts.fromUTF16(e);let c=0;for(;i<=e.length;){const d=this.doExecute(l,i,Je.UNANCHORED,2);if(d===null||d.length===0)break;a+=e.substring(r,d[0]),(d[1]>r||d[0]===0)&&(a+=t(e.substring(d[0],d[1])),c++),r=d[1];const h=l.step(i)&7;if(i+h>d[1]?i+=h:i+1>d[1]?i++:i=d[1],c>=s)break}return a+=e.substring(r),a}pad(e){if(e===null)return null;let t=(1+this.numSubexp)*2;if(e.length<t){let s=new Array(t).fill(-1);for(let r=0;r<e.length;r++)s[r]=e[r];e=s}return e}allMatches(e,t,s=r=>r){let r=[];const i=e.endPos();t<0&&(t=i+1);let a=0,l=0,c=-1;for(;l<t&&a<=i;){const d=this.doExecute(e,a,Je.UNANCHORED,this.prog.numCap);if(d===null||d.length===0)break;let h=!0;if(d[1]===a){d[0]===c&&(h=!1);const p=e.step(a);p<0?a=i+1:a+=p&7}else a=d[1];c=d[1],h&&(r.push(s(this.pad(d))),l++)}return r}findUTF8(e){const t=this.doExecute(Ts.fromUTF8(e),0,Je.UNANCHORED,2);return t===null?null:e.slice(t[0],t[1])}findUTF8Index(e){const t=this.doExecute(Ts.fromUTF8(e),0,Je.UNANCHORED,2);return t===null?null:t.slice(0,2)}find(e){const t=this.doExecute(Ts.fromUTF16(e),0,Je.UNANCHORED,2);return t===null?"":e.substring(t[0],t[1])}findIndex(e){return this.doExecute(Ts.fromUTF16(e),0,Je.UNANCHORED,2)}findUTF8Submatch(e){const t=this.doExecute(Ts.fromUTF8(e),0,Je.UNANCHORED,this.prog.numCap);if(t===null)return null;const s=new Array(1+this.numSubexp).fill(null);for(let r=0;r<s.length;r++)2*r<t.length&&t[2*r]>=0&&(s[r]=e.slice(t[2*r],t[2*r+1]));return s}findUTF8SubmatchIndex(e){return this.pad(this.doExecute(Ts.fromUTF8(e),0,Je.UNANCHORED,this.prog.numCap))}findSubmatch(e){const t=this.doExecute(Ts.fromUTF16(e),0,Je.UNANCHORED,this.prog.numCap);if(t===null)return null;const s=new Array(1+this.numSubexp).fill(null);for(let r=0;r<s.length;r++)2*r<t.length&&t[2*r]>=0&&(s[r]=e.substring(t[2*r],t[2*r+1]));return s}findSubmatchIndex(e){return this.pad(this.doExecute(Ts.fromUTF16(e),0,Je.UNANCHORED,this.prog.numCap))}findAllUTF8(e,t){const s=this.allMatches(Ts.fromUTF8(e),t,r=>e.slice(r[0],r[1]));return s.length===0?null:s}findAllUTF8Index(e,t){const s=this.allMatches(Ts.fromUTF8(e),t,r=>r.slice(0,2));return s.length===0?null:s}findAll(e,t){const s=this.allMatches(Ts.fromUTF16(e),t,r=>e.substring(r[0],r[1]));return s.length===0?null:s}findAllIndex(e,t){const s=this.allMatches(Ts.fromUTF16(e),t,r=>r.slice(0,2));return s.length===0?null:s}findAllUTF8Submatch(e,t){const s=this.allMatches(Ts.fromUTF8(e),t,r=>
34{let i=new Array(r.length/2|0).fill(null);for(let a=0;a<i.length;a++)r[2*a]>=0&&(i[a]=e.slice(r[2*a],r[2*a+1]));return i});return s.length===0?null:s}findAllUTF8SubmatchIndex(e,t){const s=this.allMatches(Ts.fromUTF8(e),t);return s.length===0?null:s}findAllSubmatch(e,t){const s=this.allMatches(Ts.fromUTF16(e),t,r=>{let i=new Array(r.length/2|0).fill(null);for(let a=0;a<i.length;a++)r[2*a]>=0&&(i[a]=e.substring(r[2*a],r[2*a+1]));return i});return s.length===0?null:s}findAllSubmatchIndex(e,t){const s=this.allMatches(Ts.fromUTF16(e),t);return s.length===0?null:s}}class ba{static CASE_INSENSITIVE=1;static DOTALL=2;static MULTILINE=4;static DISABLE_UNICODE_GROUPS=8;static LONGEST_MATCH=16;static quote(e){return fn.quoteMeta(e)}static compile(e,t=0){let s=e;if((t&ba.CASE_INSENSITIVE)!==0&&(s=`(?i)${s}`),(t&ba.DOTALL)!==0&&(s=`(?s)${s}`),(t&ba.MULTILINE)!==0&&(s=`(?m)${s}`),(t&-32)!==0)throw new wH("Flags should only be a combination of MULTILINE, DOTALL, CASE_INSENSITIVE, DISABLE_UNICODE_GROUPS, LONGEST_MATCH");let r=Je.PERL;(t&ba.DISABLE_UNICODE_GROUPS)!==0&&(r&=-129);const i=new ba(e,t);return i.re2Input=Rc.compileImpl(s,r,(t&ba.LONGEST_MATCH)!==0),i}static matches(e,t){return ba.compile(e).matcher(t).matches()}static initTest(e,t,s){if(e==null)throw new Error("pattern is null");if(s==null)throw new Error("re2 is null");const r=new ba(e,t);return r.re2Input=s,r}constructor(e,t){this.patternInput=e,this.flagsInput=t}reset(){this.re2Input.reset()}flags(){return this.flagsInput}pattern(){return this.patternInput}re2(){return this.re2Input}matches(e){return this.matcher(e).matches()}matcher(e){return Array.isArray(e)&&(e=l1.utf8(e)),new SH(this,e)}split(e,t=0){const s=this.matcher(e),r=[];let i=0,a=0;for(;s.find();){if(a===0&&s.end()===0){a=s.end();continue}if(t>0&&r.length===t-1)break;if(a===s.start()){if(t===0){i+=1,a=s.end();continue}}else for(;i>0;)r.push(""),i-=1;r.push(s.substring(a,s.start())),a=s.end()}if(t===0&&a!==s.inputLength()){for(;i>0;)r.push(""),i-=1;r.push(s.substring(a,s.inputLength()))}return(t!==0||r.length===0)&&r.push(s.substring(a,s.inputLength())),r}toString(){return this.patternInput}groupCount(){return this.re2Input.numberOfCapturingGroups()}namedGroups(){return this.re2Input.namedGroups}equals(e){return this===e?!0:e===null||this.constructor!==e.constructor?!1:this.flagsInput===e.flagsInput&&this.patternInput===e.patternInput}}class jr{constructor(e){this.uid=e}isAuthenticated(){return this.uid!=null}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(e){return e.uid===this.uid}}jr.UNAUTHENTICATED=new jr(null),jr.GOOGLE_CREDENTIALS=new jr("google-credentials-uid"),jr.FIRST_PARTY=new jr("first-party-uid"),jr.MOCK_USER=new jr("mock-user");let bf="12.15.0";function kH(n){bf=n}const vd=new ux("@firebase/firestore");function vh(){return vd.logLevel}function Ze(n,...e){if(vd.logLevel<=on.DEBUG){const t=e.map(N4);vd.debug(`Firestore (${bf}): ${n}`,...t)}}function Kl(n,...e){if(vd.logLevel<=on.ERROR){const t=e.map(N4);vd.error(`Firestore (${bf}): ${n}`,...t)}}function fo(n,...e){if(vd.logLevel<=on.WARN){const t=e.map(N4);vd.warn(`Firestore (${bf}): ${n}`,...t)}}function N4(n){if(typeof n=="string")return n;try{return(function(t){return JSON.stringify(t)})(n)}catch{return n}}function _t(n,e,t){let s="Unexpected state";typeof e=="string"?s=e:t=e,Wk(n,s,t)}function Wk(n,e,t){let s=`FIRESTORE (${bf}) INTERNAL ASSERTION FAILED: ${e} (ID: ${n.toString(16)})`;if(t!==void 0)try{s+=" CONTEXT: "+JSON.stringify(t)}catch{s+=" CONTEXT: "+t}throw Kl(s),new Error(s)}function yt(n,e,t,s){let r="Unexpected state";typeof t=="string"?r=t:s=t,n||Wk(e,r,s)}function $t(n,e){return n}const Ce={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"};class Xe extends Ra{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}class Vl{constructor(){this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}}class Gk{constructor(e,t){this.user=t,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}}class RH{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable((()=>t(jr.UNAUTHENTICATED)))}shutdown(){}}class PH{constructor(e){this.token=e,this.changeListener=null}getToken(){return Promise.resolve(this.token)}invalidateToken(){}start(e,t){this.changeListener=t,e.enqueueRetryable((()=>t(this.token.user)))}shutdown(){this.changeListener=null}}class NH{constructor(e){this.t=e,this.currentUser=jr.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,t){yt(this.o===void 0,42304);let s=this.i;const r=c=>this.i!==s?(s=this.i,t(c)):Promise.resolve();let i=new Vl;this.o=()=>{this.i++,this.currentUser=this.u(),i.resolve(),i=new Vl,e.enqueueRetryable((()=>r(this.currentUser)))};const a=()=>{const c=i;e.enqueueRetryable((async()=>{await c.promise,await r(this.currentUser)}))},l=c=>{Ze("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=c,this.o&&(this.auth.addAuthTokenListener(this.o),a())};this.t.onInit((c=>l(c))),setTimeout((()=>
34{if(!this.auth){const c=this.t.getImmediate({optional:!0});c?l(c):(Ze("FirebaseAuthCredentialsProvider","Auth not yet detected"),i.resolve(),i=new Vl)}}),0),a()}getToken(){const e=this.i,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then((s=>this.i!==e?(Ze("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):s?(yt(typeof s.accessToken=="string",31837,{l:s}),new Gk(s.accessToken,this.currentUser)):null)):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&&this.o&&this.auth.removeAuthTokenListener(this.o),this.o=void 0}u(){const e=this.auth&&this.auth.getUid();return yt(e===null||typeof e=="string",2055,{h:e}),new jr(e)}}class LH{constructor(e,t,s){this.T=e,this.P=t,this.R=s,this.type="FirstParty",this.user=jr.FIRST_PARTY,this.I=new Map}A(){return this.R?this.R():null}get headers(){this.I.set("X-Goog-AuthUser",this.T);const e=this.A();return e&&this.I.set("Authorization",e),this.P&&this.I.set("X-Goog-Iam-Authorization-Token",this.P),this.I}}class DH{constructor(e,t,s){this.T=e,this.P=t,this.R=s}getToken(){return Promise.resolve(new LH(this.T,this.P,this.R))}start(e,t){e.enqueueRetryable((()=>t(jr.FIRST_PARTY)))}shutdown(){}invalidateToken(){}}class F8{constructor(e){this.value=e,this.type="AppCheck",this.headers=new Map,e&&e.length>0&&this.headers.set("x-firebase-appcheck",this.value)}}class jH{constructor(e,t){this.V=t,this.forceRefresh=!1,this.appCheck=null,this.m=null,this.p=null,Jn(e)&&e.settings.appCheckToken&&(this.p=e.settings.appCheckToken)}start(e,t){yt(this.o===void 0,3512);const s=i=>{i.error!=null&&Ze("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${i.error.message}`);const a=i.token!==this.m;return this.m=i.token,Ze("FirebaseAppCheckTokenProvider",`Received ${a?"new":"existing"} token.`),a?t(i.token):Promise.resolve()};this.o=i=>{e.enqueueRetryable((()=>s(i)))};const r=i=>{Ze("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=i,this.o&&this.appCheck.addTokenListener(this.o)};this.V.onInit((i=>r(i))),setTimeout((()=>{if(!this.appCheck){const i=this.V.getImmediate({optional:!0});i?r(i):Ze("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}}),0)}getToken(){if(this.p)return Promise.resolve(new F8(this.p));const e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then((t=>t?(yt(typeof t.token=="string",44558,{tokenResult:t}),this.m=t.token,new F8(t.token)):null)):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.o&&this.appCheck.removeTokenListener(this.o),this.o=void 0}}function OH(n){const e=typeof self<"u"&&(self.crypto||self.msCrypto),t=new Uint8Array(n);if(e&&typeof e.getRandomValues=="function")e.getRandomValues(t);else for(let s=0;s<n;s++)t[s]=Math.floor(256*Math.random());return t}class L4{static newId(){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t=62*Math.floor(4.129032258064516);let s="";for(;s.length<20;){const r=OH(40);for(let i=0;i<r.length;++i)s.length<20&&r[i]<t&&(s+=e.charAt(r[i]%62))}return s}}function sn(n,e){return n<e?-1:n>e?1:0}function Pb(n,e){const t=Math.min(n.length,e.length);for(let s=0;s<t;s++){const r=n.charAt(s),i=e.charAt(s);if(r!==i)return tv(r)===tv(i)?sn(r,i):tv(r)?1:-1}return sn(n.length,e.length)}const MH=55296,FH=57343;function tv(n){const e=n.charCodeAt(0);return e>=MH&&e<=FH}function qh(n,e,t){return n.length===e.length&&n.every(((s,r)=>t(s,e[r])))}const Vo="__name__";class Oo{constructor(e,t,s){t===void 0?t=0:t>e.length&&_t(637,{offset:t,range:e.length}),s===void 0?s=e.length-t:s>e.length-t&&_t(1746,{length:s,range:e.length-t}),this.segments=e,this.offset=t,this.len=s}get length(){return this.len}isEqual(e){return Oo.comparator(this,e)===0}child(e){const t=this.segments.slice(this.offset,this.limit());return e instanceof Oo?e.forEach((s=>{t.push(s)})):t.push(e),this.construct(t)}limit(){return this.offset+this.length}popFirst(e){return e=e===void 0?1:e,this.construct(this.segments,this.offset+e,this.length-e)}popLast(){return this.construct(this.segments,this.offset,this.length-1)}firstSegment(){return this.segments[this.offset]}lastSegment(){return this.get(this.length-1)}get(e){return this.segments[this.offset+e]}isEmpty(){return this.length===0}isPrefixOf(e){if(e.length<this.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}isImmediateParentOf(e){if(this.length+1!==e.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}forEach(e){for(let t=this.offset,s=this.limit();t<s;t++)e(this.segments[t])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(e,t){const s=Math.min(e.length,t.length);for(let r=0;r<s;r++){const i=Oo.compareSegments(e.get(r),t.get(r));if(i!==0)return i}return sn(e.length,t.length)}static compareSegments(e,t){const s=Oo.isNumericId(e),r=Oo.isNumericId(t);return s&&!r?-1:!s&&r?1:s&&r?Oo.extractNumericId(e).compare(Oo.extractNumericId(t)):Pb(e,t)}static isNumericId(e){return e.startsWith("__id")&&e.endsWith("__")}static extractNumericId(e){return Gc.fromString(e.substring(4,e.length-2))}}class bn extends Oo{construct(e,t,s){return new bn(e,t,s)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}toStringWithLeadingSlash(){return`/${this.canonicalString()}`}
34toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...e){const t=[];for(const s of e){if(s.indexOf("//")>=0)throw new Xe(Ce.INVALID_ARGUMENT,`Invalid segment (${s}). Paths must not contain // in them.`);t.push(...s.split("/").filter((r=>r.length>0)))}return new bn(t)}static emptyPath(){return new bn([])}}const UH=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class qs extends Oo{construct(e,t,s){return new qs(e,t,s)}static isValidIdentifier(e){return UH.test(e)}canonicalString(){return this.toArray().map((e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),qs.isValidIdentifier(e)||(e="`"+e+"`"),e))).join(".")}toString(){return this.canonicalString()}isKeyField(){return this.length===1&&this.get(0)===Vo}static keyField(){return new qs([Vo])}static fromServerFormat(e){const t=[];let s="",r=0;const i=()=>{if(s.length===0)throw new Xe(Ce.INVALID_ARGUMENT,`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);t.push(s),s=""};let a=!1;for(;r<e.length;){const l=e[r];if(l==="\\"){if(r+1===e.length)throw new Xe(Ce.INVALID_ARGUMENT,"Path has trailing escape character: "+e);const c=e[r+1];if(c!=="\\"&&c!=="."&&c!=="`")throw new Xe(Ce.INVALID_ARGUMENT,"Path has invalid escape sequence: "+e);s+=c,r+=2}else l==="`"?(a=!a,r++):l!=="."||a?(s+=l,r++):(i(),r++)}if(i(),a)throw new Xe(Ce.INVALID_ARGUMENT,"Unterminated ` in path: "+e);return new qs(t)}static emptyPath(){return new qs([])}}class bt{constructor(e){this.path=e}static fromPath(e){return new bt(bn.fromString(e))}static fromName(e){return new bt(bn.fromString(e).popFirst(5))}static empty(){return new bt(bn.emptyPath())}get collectionGroup(){return this.path.popLast().lastSegment()}hasCollectionId(e){return this.path.length>=2&&this.path.get(this.path.length-2)===e}getCollectionGroup(){return this.path.get(this.path.length-2)}getCollectionPath(){return this.path.popLast()}isEqual(e){return e!==null&&bn.comparator(this.path,e.path)===0}toString(){return this.path.toString()}static comparator(e,t){return bn.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new bt(new bn(e.slice()))}}function Kk(n,e,t){if(!t)throw new Xe(Ce.INVALID_ARGUMENT,`Function ${n}() cannot be called with an empty ${e}.`)}function VH(n,e,t,s){if(e===!0&&s===!0)throw new Xe(Ce.INVALID_ARGUMENT,`${n} and ${t} cannot be used together.`)}function U8(n){if(!bt.isDocumentKey(n))throw new Xe(Ce.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${n} has ${n.length}.`)}function V8(n){if(bt.isDocumentKey(n))throw new Xe(Ce.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${n} has ${n.length}.`)}function Pm(n){return typeof n=="object"&&n!==null&&(Object.getPrototypeOf(n)===Object.prototype||Object.getPrototypeOf(n)===null)}function Sx(n){if(n===void 0)return"undefined";if(n===null)return"null";if(typeof n=="string")return n.length>20&&(n=`${n.substring(0,20)}...`),JSON.stringify(n);if(typeof n=="number"||typeof n=="boolean")return""+n;if(typeof n=="object"){if(n instanceof Array)return"an array";{const e=(function(s){return s.constructor?s.constructor.name:null})(n);return e?`a custom ${e} object`:"an object"}}return typeof n=="function"?"a function":_t(12329,{type:typeof n})}function Ii(n,e){if("_delegate"in n&&(n=n._delegate),!(n instanceof e)){if(e.name===n.constructor.name)throw new Xe(Ce.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{const t=Sx(n);throw new Xe(Ce.INVALID_ARGUMENT,`Expected type '${e.name}', but it was: ${t}`)}}return n}function BH(n,e){if(e<=0)throw new Xe(Ce.INVALID_ARGUMENT,`Function ${n}() requires a positive number, but it was: ${e}.`)}function Ls(n,e){const t={typeString:n};return e&&(t.value=e),t}function Nm(n,e){if(!Pm(n))throw new Xe(Ce.INVALID_ARGUMENT,"JSON must be an object");let t;for(const s in e)if(e[s]){const r=e[s].typeString,i="value"in e[s]?{value:e[s].value}:void 0;if(!(s in n)){t=`JSON missing required field: '${s}'`;break}const a=n[s];if(r&&typeof a!==r){t=`JSON field '${s}' must be a ${r}.`;break}if(i!==void 0&&a!==i.value){t=`Expected '${s}' field to equal '${i.value}'`;break}}
vendor: 5,822 bytes, line 34
34if(t)throw new Xe(Ce.INVALID_ARGUMENT,t);return!0}const B8=-62135596800,z8=1e6;class $n{static now(){return $n.fromMillis(Date.now())}static fromDate(e){return $n.fromMillis(e.getTime())}static fromMillis(e){const t=Math.floor(e/1e3),s=Math.floor((e-1e3*t)*z8);return new $n(t,s)}constructor(e,t){if(this.seconds=e,this.nanoseconds=t,t<0)throw new Xe(Ce.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(t>=1e9)throw new Xe(Ce.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(e<B8)throw new Xe(Ce.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e);if(e>=253402300800)throw new Xe(Ce.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/z8}_compareTo(e){return this.seconds===e.seconds?sn(this.nanoseconds,e.nanoseconds):sn(this.seconds,e.seconds)}isEqual(e){return e.seconds===this.seconds&&e.nanoseconds===this.nanoseconds}toString(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}toJSON(){return{type:$n._jsonSchemaVersion,seconds:this.seconds,nanoseconds:this.nanoseconds}}static fromJSON(e){if(Nm(e,$n._jsonSchema))return new $n(e.seconds,e.nanoseconds)}valueOf(){const e=this.seconds-B8;return String(e).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}$n._jsonSchemaVersion="firestore/timestamp/1.0",$n._jsonSchema={type:Ls("string",$n._jsonSchemaVersion),seconds:Ls("number"),nanoseconds:Ls("number")};class Vt{static fromTimestamp(e){return new Vt(e)}static min(){return new Vt(new $n(0,0))}static max(){return new Vt(new $n(253402300799,999999999))}constructor(e){this.timestamp=e}compareTo(e){return this.timestamp._compareTo(e.timestamp)}isEqual(e){return this.timestamp.isEqual(e.timestamp)}toMicroseconds(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3}toString(){return"SnapshotVersion("+this.timestamp.toString()+")"}toTimestamp(){return this.timestamp}}const em=-1;function zH(n,e){const t=n.toTimestamp().seconds,s=n.toTimestamp().nanoseconds+1,r=Vt.fromTimestamp(s===1e9?new $n(t+1,0):new $n(t,s));return new Zc(r,bt.empty(),e)}function $H(n){return new Zc(n.readTime,n.key,em)}class Zc{constructor(e,t,s){this.readTime=e,this.documentKey=t,this.largestBatchId=s}static min(){return new Zc(Vt.min(),bt.empty(),em)}static max(){return new Zc(Vt.max(),bt.empty(),em)}}function HH(n,e){let t=n.readTime.compareTo(e.readTime);return t!==0?t:(t=bt.comparator(n.documentKey,e.documentKey),t!==0?t:sn(n.largestBatchId,e.largestBatchId))}const WH="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.";class GH{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach((e=>e()))}}async function wf(n){if(n.code!==Ce.FAILED_PRECONDITION||n.message!==WH)throw n;Ze("LocalStore","Unexpectedly lost primary lease")}class Pe{constructor(e){this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,e((t=>{this.isDone=!0,this.result=t,this.nextCallback&&this.nextCallback(t)}),(t=>{this.isDone=!0,this.error=t,this.catchCallback&&this.catchCallback(t)}))}catch(e){return this.next(void 0,e)}next(e,t){return this.callbackAttached&&_t(59440),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(t,this.error):this.wrapSuccess(e,this.result):new Pe(((s,r)=>{this.nextCallback=i=>{this.wrapSuccess(e,i).next(s,r)},this.catchCallback=i=>{this.wrapFailure(t,i).next(s,r)}}))}toPromise(){return new Promise(((e,t)=>{this.next(e,t)}))}wrapUserFunction(e){try{const t=e();return t instanceof Pe?t:Pe.resolve(t)}catch(t){return Pe.reject(t)}}wrapSuccess(e,t){return e?this.wrapUserFunction((()=>e(t))):Pe.resolve(t)}wrapFailure(e,t){return e?this.wrapUserFunction((()=>e(t))):Pe.reject(t)}static resolve(e){return new Pe(((t,s)=>{t(e)}))}static reject(e){return new Pe(((t,s)=>{s(e)}))}static waitFor(e){return new Pe(((t,s)=>{let r=0,i=0,a=!1;e.forEach((l=>{++r,l.next((()=>{++i,a&&i===r&&t()}),(c=>s(c)))})),a=!0,i===r&&t()}))}static or(e){let t=Pe.resolve(!1);for(const s of e)t=t.next((r=>r?Pe.resolve(r):s()));return t}static forEach(e,t){const s=[];return e.forEach(((r,i)=>{s.push(t.call(this,r,i))})),this.waitFor(s)}static mapArray(e,t){return new Pe(((s,r)=>{const i=e.length,a=new Array(i);let l=0;for(let c=0;c<i;c++){const d=c;t(e[d]).next((h=>{a[d]=h,++l,l===i&&s(a)}),(h=>r(h)))}}))}static doWhile(e,t){return new Pe(((s,r)=>{const i=()=>{e()===!0?t().next((()=>{i()}),r):s()};i()}))}}function KH(n){const e=n.match(/Android ([\d.]+)/i),t=e?e[1].split(".").slice(0,2).join("."):"-1";return Number(t)}function Sf(n){return n.name==="IndexedDbTransactionError"}class Ex{constructor(e,t){this.previousValue=e,t&&(t.sequenceNumberHandler=s=>this.ae(s),this.ue=s=>t.writeSequenceNumber(s))}ae(e){return this.previousValue=Math.max(e,this.previousValue),this.previousValue}next(){const e=++this.previousValue;return this.ue&&this.ue(e),e}}Ex.ce=-1;const D4=-1;function Tx(n){return n==null}function tm(n){return n===0&&1/n==-1/0}function qH(n){return typeof n=="number"&&Number.isInteger(n)&&!tm(n)&&n<=Number.MAX_SAFE_INTEGER&&n>=Number.MIN_SAFE_INTEGER}function YH(n){return typeof n=="string"}const qk="�";function QH(n){let e="";for(let t=0;t<n.length;t++)e.length>0&&(e=$8(e)),e=XH(n.get(t),e);return $8(e)}function XH(n,e){let t=e;const s=n.length;for(let r=0;r<s;r++){const i=n.charAt(r);switch(i){case"\0":t+="��";break;case qk:t+="��";break;default:t+=i}}return t}function $8(n){return n+qk+"�"}class Zn{constructor(e,t){this.comparator=e,this.root=t||yr.EMPTY}insert(e,t){return new Zn(this.comparator,this.root.insert(e,t,this.comparator).copy(null,null,yr.BLACK,null,
vendor: 4,548 bytes, line 34
34null))}remove(e){return new Zn(this.comparator,this.root.remove(e,this.comparator).copy(null,null,yr.BLACK,null,null))}get(e){let t=this.root;for(;!t.isEmpty();){const s=this.comparator(e,t.key);if(s===0)return t.value;s<0?t=t.left:s>0&&(t=t.right)}return null}indexOf(e){let t=0,s=this.root;for(;!s.isEmpty();){const r=this.comparator(e,s.key);if(r===0)return t+s.left.size;r<0?s=s.left:(t+=s.left.size+1,s=s.right)}return-1}isEmpty(){return this.root.isEmpty()}get size(){return this.root.size}minKey(){return this.root.minKey()}maxKey(){return this.root.maxKey()}inorderTraversal(e){return this.root.inorderTraversal(e)}forEach(e){this.inorderTraversal(((t,s)=>(e(t,s),!1)))}toString(){const e=[];return this.inorderTraversal(((t,s)=>(e.push(`${t}:${s}`),!1))),`{${e.join(", ")}}`}reverseTraversal(e){return this.root.reverseTraversal(e)}getIterator(){return new Gg(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new Gg(this.root,e,this.comparator,!1)}getReverseIterator(){return new Gg(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new Gg(this.root,e,this.comparator,!0)}}class Gg{constructor(e,t,s,r){this.isReverse=r,this.nodeStack=[];let i=1;for(;!e.isEmpty();)if(i=t?s(e.key,t):1,t&&r&&(i*=-1),i<0)e=this.isReverse?e.left:e.right;else{if(i===0){this.nodeStack.push(e);break}this.nodeStack.push(e),e=this.isReverse?e.right:e.left}}getNext(){let e=this.nodeStack.pop();const t={key:e.key,value:e.value};if(this.isReverse)for(e=e.left;!e.isEmpty();)this.nodeStack.push(e),e=e.right;else for(e=e.right;!e.isEmpty();)this.nodeStack.push(e),e=e.left;return t}hasNext(){return this.nodeStack.length>0}peek(){if(this.nodeStack.length===0)return null;const e=this.nodeStack[this.nodeStack.length-1];return{key:e.key,value:e.value}}}class yr{constructor(e,t,s,r,i){this.key=e,this.value=t,this.color=s??yr.RED,this.left=r??yr.EMPTY,this.right=i??yr.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,t,s,r,i){return new yr(e??this.key,t??this.value,s??this.color,r??this.left,i??this.right)}isEmpty(){return!1}inorderTraversal(e){return this.left.inorderTraversal(e)||e(this.key,this.value)||this.right.inorderTraversal(e)}reverseTraversal(e){return this.right.reverseTraversal(e)||e(this.key,this.value)||this.left.reverseTraversal(e)}min(){return this.left.isEmpty()?this:this.left.min()}minKey(){return this.min().key}maxKey(){return this.right.isEmpty()?this.key:this.right.maxKey()}insert(e,t,s){let r=this;const i=s(e,r.key);return r=i<0?r.copy(null,null,null,r.left.insert(e,t,s),null):i===0?r.copy(null,t,null,null,null):r.copy(null,null,null,null,r.right.insert(e,t,s)),r.fixUp()}removeMin(){if(this.left.isEmpty())return yr.EMPTY;let e=this;return e.left.isRed()||e.left.left.isRed()||(e=e.moveRedLeft()),e=e.copy(null,null,null,e.left.removeMin(),null),e.fixUp()}remove(e,t){let s,r=this;if(t(e,r.key)<0)r.left.isEmpty()||r.left.isRed()||r.left.left.isRed()||(r=r.moveRedLeft()),r=r.copy(null,null,null,r.left.remove(e,t),null);else{if(r.left.isRed()&&(r=r.rotateRight()),r.right.isEmpty()||r.right.isRed()||r.right.left.isRed()||(r=r.moveRedRight()),t(e,r.key)===0){if(r.right.isEmpty())return yr.EMPTY;s=r.right.min(),r=r.copy(s.key,s.value,null,null,r.right.removeMin())}r=r.copy(null,null,null,null,r.right.remove(e,t))}return r.fixUp()}isRed(){return this.color}fixUp(){let e=this;return e.right.isRed()&&!e.left.isRed()&&(e=e.rotateLeft()),e.left.isRed()&&e.left.left.isRed()&&(e=e.rotateRight()),e.left.isRed()&&e.right.isRed()&&(e=e.colorFlip()),e}moveRedLeft(){let e=this.colorFlip();return e.right.left.isRed()&&(e=e.copy(null,null,null,null,e.right.rotateRight()),e=e.rotateLeft(),e=e.colorFlip()),e}moveRedRight(){let e=this.colorFlip();return e.left.left.isRed()&&(e=e.rotateRight(),e=e.colorFlip()),e}rotateLeft(){const e=this.copy(null,null,yr.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){const e=this.copy(null,null,yr.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip(){const e=this.left.copy(null,null,!this.left.color,null,null),t=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,t)}checkMaxDepth(){const e=this.check();return Math.pow(2,e)<=this.size+1}check(){if(this.isRed()&&this.left.isRed())throw _t(43730,{key:this.key,value:this.value});if(this.right.isRed())throw _t(14113,{key:this.key,value:this.value});const e=this.left.check();if(e!==this.right.check())throw _t(27949);return e+(this.isRed()?0:1)}}yr.EMPTY=null,yr.RED=!0,yr.BLACK=!1;
34yr.EMPTY=new class{constructor(){this.size=0}get key(){throw _t(57766)}get value(){throw _t(16141)}get color(){throw _t(16727)}get left(){throw _t(29726)}get right(){throw _t(36894)}copy(e,t,s,r,i){return this}insert(e,t,s){return new yr(e,t)}remove(e,t){return this}isEmpty(){return!0}inorderTraversal(e){return!1}reverseTraversal(e){return!1}minKey(){return null}maxKey(){return null}isRed(){return!1}checkMaxDepth(){return!0}check(){return 0}};class js{constructor(e){this.comparator=e,this.data=new Zn(this.comparator)}has(e){return this.data.get(e)!==null}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(e){return this.data.indexOf(e)}forEach(e){this.data.inorderTraversal(((t,s)=>(e(t),!1)))}forEachInRange(e,t){const s=this.data.getIteratorFrom(e[0]);for(;s.hasNext();){const r=s.getNext();if(this.comparator(r.key,e[1])>=0)return;t(r.key)}}forEachWhile(e,t){let s;for(s=t!==void 0?this.data.getIteratorFrom(t):this.data.getIterator();s.hasNext();)if(!e(s.getNext().key))return}firstAfterOrEqual(e){const t=this.data.getIteratorFrom(e);return t.hasNext()?t.getNext().key:null}getIterator(){return new H8(this.data.getIterator())}getIteratorFrom(e){return new H8(this.data.getIteratorFrom(e))}add(e){return this.copy(this.data.remove(e).insert(e,!0))}delete(e){return this.has(e)?this.copy(this.data.remove(e)):this}isEmpty(){return this.data.isEmpty()}unionWith(e){let t=this;return t.size<e.size&&(t=e,e=this),e.forEach((s=>{t=t.add(s)})),t}isEqual(e){if(!(e instanceof js)||this.size!==e.size)return!1;const t=this.data.getIterator(),s=e.data.getIterator();for(;t.hasNext();){const r=t.getNext().key,i=s.getNext().key;if(this.comparator(r,i)!==0)return!1}return!0}toArray(){const e=[];return this.forEach((t=>{e.push(t)})),e}toString(){const e=[];return this.forEach((t=>e.push(t))),"SortedSet("+e.toString()+")"}copy(e){const t=new js(this.comparator);return t.data=e,t}}class H8{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}class Ji{constructor(e){this.fields=e,e.sort(qs.comparator)}static empty(){return new Ji([])}unionWith(e){let t=new js(qs.comparator);for(const s of this.fields)t=t.add(s);for(const s of e)t=t.add(s);return new Ji(t.toArray())}covers(e){for(const t of this.fields)if(t.isPrefixOf(e))return!0;return!1}isEqual(e){return qh(this.fields,e.fields,((t,s)=>t.isEqual(s)))}}function c1(n){let e=0;for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&e++;return e}function xu(n,e){for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&e(t,n[t])}function JH(n,e){const t=[];for(const s in n)Object.prototype.hasOwnProperty.call(n,s)&&t.push(e(n[s],s,n));return t}function Yk(n){for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e))return!1;return!0}class Qk extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}}class Os{constructor(e){this.binaryString=e}static fromBase64String(e){const t=(function(r){try{return atob(r)}catch(i){throw typeof DOMException<"u"&&i instanceof DOMException?new Qk("Invalid base64 string: "+i):i}})(e);return new Os(t)}static fromUint8Array(e){const t=(function(r){let i="";for(let a=0;a<r.length;++a)i+=String.fromCharCode(r[a]);return i})(e);return new Os(t)}[Symbol.iterator](){let e=0;return{next:()=>e<this.binaryString.length?{value:this.binaryString.charCodeAt(e++),done:!1}:{value:void 0,done:!0}}}toBase64(){return(function(t){return btoa(t)})(this.binaryString)}toUint8Array(){return(function(t){const s=new Uint8Array(t.length);for(let r=0;r<t.length;r++)s[r]=t.charCodeAt(r);return s})(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(e){return sn(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}}Os.EMPTY_BYTE_STRING=new Os("");const ZH=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function eu(n){if(yt(!!n,39018),typeof n=="string"){let e=0;const t=ZH.exec(n);if(yt(!!t,46558,{timestamp:n}),t[1]){let r=t[1];r=(r+"000000000").substr(0,9),e=Number(r)}const s=new Date(n);return{seconds:Math.floor(s.getTime()/1e3),nanos:e}}return{seconds:is(n.seconds),nanos:is(n.nanos)}}function is(n){return typeof n=="number"?n:typeof n=="string"?Number(n):0}function tu(n){return typeof n=="string"?Os.fromBase64String(n):Os.fromUint8Array(n)}const Xk="server_timestamp",Jk="__type__",Zk="__previous_value__",eR="__local_write_time__";function _x(n){return(n?.mapValue?.fields||{})[Jk]?.stringValue===Xk}function Lm(n){const e=n.mapValue.fields[Zk];return _x(e)?Lm(e):e}function Yh(n){const e=eu(n.mapValue.fields[eR].timestampValue);return new $n(e.seconds,e.nanos)}class eW{constructor(e,t,s,r,i,a,l,c,d,h,p){this.databaseId=e,this.appId=t,this.persistenceKey=s,this.host=r,this.ssl=i,this.forceLongPolling=a,this.autoDetectLongPolling=l,this.longPollingOptions=c,this.useFetchStreams=d,this.isUsingEmulator=h,this.apiKey=p}}const u1="(default)";class nm{constructor(e,t){this.projectId=e,this.database=t||u1}static empty(){return new nm("","")}get isDefaultDatabase(){return this.database===u1}isEqual(e){return e instanceof nm&&e.projectId===this.projectId&&e.database===this.database}}function tW(n,e){if(!Object.prototype.hasOwnProperty.apply(n.options,["projectId"]))throw new Xe(Ce.INVA
34LID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new nm(n.options.projectId,e)}const tR="__type__",nW="__max__",Kg={mapValue:{}},nR="__vector__",sm="value",Qh={nullValue:"NULL_VALUE"},ki={booleanValue:!0},ur={booleanValue:!1};function Ms(n){return"nullValue"in n?0:"booleanValue"in n?1:"integerValue"in n||"doubleValue"in n?2:"timestampValue"in n?3:"stringValue"in n?5:"bytesValue"in n?6:"referenceValue"in n?7:"geoPointValue"in n?8:"arrayValue"in n?9:"mapValue"in n?_x(n)?4:sW(n)?9007199254740991:d1(n)?10:11:_t(28295,{value:n})}function Ca(n,e,t){if(n===e)return!0;const s=Ms(n);if(s!==Ms(e))return!1;switch(s){case 0:case 9007199254740991:return!0;case 1:return n.booleanValue===e.booleanValue;case 4:return Yh(n).isEqual(Yh(e));case 3:return(function(i,a){if(typeof i.timestampValue=="string"&&typeof a.timestampValue=="string"&&i.timestampValue.length===a.timestampValue.length)return i.timestampValue===a.timestampValue;const l=eu(i.timestampValue),c=eu(a.timestampValue);return l.seconds===c.seconds&&l.nanos===c.nanos})(n,e);case 5:return n.stringValue===e.stringValue;case 6:return(function(i,a){return tu(i.bytesValue).isEqual(tu(a.bytesValue))})(n,e);case 7:return n.referenceValue===e.referenceValue;case 8:return(function(i,a){return is(i.geoPointValue.latitude)===is(a.geoPointValue.latitude)&&is(i.geoPointValue.longitude)===is(a.geoPointValue.longitude)})(n,e);case 2:return(function(i,a,l){if("integerValue"in i&&"integerValue"in a)return is(i.integerValue)===is(a.integerValue);let c,d;if("doubleValue"in i&&"doubleValue"in a)c=is(i.doubleValue),d=is(a.doubleValue);else{if(!l?.Ee)return!1;c=is(i.integerValue??i.doubleValue),d=is(a.integerValue??a.doubleValue)}return c===d?!!l?.he||tm(c)===tm(d):!!(l===void 0||l.Te)&&isNaN(c)&&isNaN(d)})(n,e,t);case 9:return qh(n.arrayValue.values||[],e.arrayValue.values||[],((r,i)=>Ca(r,i,t)));case 10:case 11:return(function(i,a,l){const c=i.mapValue.fields||{},d=a.mapValue.fields||{};if(c1(c)!==c1(d))return!1;for(const h in c)if(c.hasOwnProperty(h)&&(d[h]===void 0||!Ca(c[h],d[h],l)))return!1;return!0})(n,e,t);default:return _t(52216,{left:n})}}function rm(n,e){return(n.values||[]).find((t=>Ca(t,e)))!==void 0}function Ri(n,e){if(n===e)return 0;const t=Ms(n),s=Ms(e);if(t!==s)return sn(t,s);switch(t){case 0:case 9007199254740991:return 0;case 1:return sn(n.booleanValue,e.booleanValue);case 2:return(function(i,a){const l=is(i.integerValue||i.doubleValue),c=is(a.integerValue||a.doubleValue);return l<c?-1:l>c?1:l===c?0:isNaN(l)?isNaN(c)?0:-1:1})(n,e);case 3:return W8(n.timestampValue,e.timestampValue);case 4:return W8(Yh(n),Yh(e));case 5:return Pb(n.stringValue,e.stringValue);case 6:return(function(i,a){const l=tu(i),c=tu(a);return l.compareTo(c)})(n.bytesValue,e.bytesValue);case 7:return(function(i,a){const l=i.split("/"),c=a.split("/");for(let d=0;d<l.length&&d<c.length;d++){const h=sn(l[d],c[d]);if(h!==0)return h}return sn(l.length,c.length)})(n.referenceValue,e.referenceValue);case 8:return(function(i,a){const l=sn(is(i.latitude),is(a.latitude));return l!==0?l:sn(is(i.longitude),is(a.longitude))})(n.geoPointValue,e.geoPointValue);case 9:return G8(n.arrayValue,e.arrayValue);case 10:return(function(i,a){const l=i.fields||{},c=a.fields||{},d=l[sm]?.arrayValue,h=c[sm]?.arrayValue,p=sn(d?.values?.length||0,h?.values?.length||0);return p!==0?p:G8(d,h)})(n.mapValue,e.mapValue);case 11:return(function(i,a){if(i===Kg.mapValue&&a===Kg.mapValue)return 0;if(i===Kg.mapValue)return 1;if(a===Kg.mapValue)return-1;const l=i.fields||{},c=Object.keys(l),d=a.fields||{},h=Object.keys(d);c.sort(),h.sort();for(let p=0;p<c.length&&p<h.length;++p){const m=Pb(c[p],h[p]);if(m!==0)return m;const y=Ri(l[c[p]],d[h[p]]);if(y!==0)return y}return sn(c.length,h.length)})(n.mapValue,e.mapValue);default:throw _t(23264,{Pe:t})}}function W8(n,e){if(typeof n=="string"&&typeof e=="string"&&n.length===e.length)return sn(n,e);const t=eu(n),s=eu(e),r=sn(t.seconds,s.seconds);return r!==0?r:sn(t.nanos,s.nanos)}function G8(n,e){const t=n.values||[],s=e.values||[];for(let r=0;r<t.length&&r<s.length;++r){const i=Ri(t[r],s[r]);if(i!==void 0&&i!==0)return i}return sn(t.length,s.length)}function Xh(n){return Nb(n)}function Nb(n){return"nullValue"in n?"null":"booleanValue"in n?""+n.booleanValue:"integerValue"in n?""+n.integerValue:"doubleValue"in n?""+n.doubleValue:"timestampValue"in n?(function(t){const s=eu(t);return`time(${s.seconds},${s.nanos})`})(n.timestampValue):"stringValue"in n?n.stringValue:"bytesValue"in n?(function(t){return tu(t).toBase64()})(n.bytesValue):"referenceValue"in n?(function(t){return bt.fromName(t).toString()})(n.referenceValue):"geoPointValue"in n?(function(t){return`geo(${t.latitude},${t.longitude})`})(n.geoPointValue):"arrayValue"in n?(function(t){let s="[",r=!0;for(const i of t.values||[])r?r=!1:s+=",",s+=Nb(i);return s+"]"})(n.arrayValue):"mapValue"in n?(function(t){const s=Object.keys(t.fields||{}).sort();let r="{",i=!0;for(const a of s)i?i=!1:r+=",",r+=`${a}:${Nb(t.fields[a])}`;return r+"}"})(n.mapValue):_t(61005,{value:n})}function I0(n){switch(Ms(n)){case 0:case 1:return 4;case 2:return 8;case 3:case 8:return 16;case 4:const e=Lm(n);return e?16+I0(e):16;case 5:return 2*n.stringValue.length;case 6:return tu(n.bytesValue).approximateByteSize();case 7:return n.referenceValue.length;case 9:return(function(s){return(s.values||[]).reduce(((r,i)=>r+I0(i)),0)})(n.arrayValue);case 10:case 11:return(function(s){let r=0;
vendor: 2,482 bytes, line 34
34return xu(s.fields,((i,a)=>{r+=i.length+I0(a)})),r})(n.mapValue);default:throw _t(13486,{value:n})}}function K8(n,e){return{referenceValue:`projects/${n.projectId}/databases/${n.database}/documents/${e.path.canonicalString()}`}}function Bo(n){return!!n&&"integerValue"in n}function Zu(n){return!!n&&"doubleValue"in n}function nu(n){return Bo(n)||Zu(n)}function Jh(n){return!!n&&"arrayValue"in n}function Zi(n){return!!n&&"nullValue"in n}function Pi(n){return!!n&&"doubleValue"in n&&isNaN(Number(n.doubleValue))}function rd(n){return!!n&&"mapValue"in n}function d1(n){return(n?.mapValue?.fields||{})[tR]?.stringValue===nR}function Lb(n){return(n?.mapValue?.fields||{})[sm]?.arrayValue}function kp(n){if(n.geoPointValue)return{geoPointValue:{...n.geoPointValue}};if(n.timestampValue&&typeof n.timestampValue=="object")return{timestampValue:{...n.timestampValue}};if(n.mapValue){const e={mapValue:{fields:{}}};return xu(n.mapValue.fields,((t,s)=>e.mapValue.fields[t]=kp(s))),e}if(n.arrayValue){const e={arrayValue:{values:[]}};for(let t=0;t<(n.arrayValue.values||[]).length;++t)e.arrayValue.values[t]=kp(n.arrayValue.values[t]);return e}return{...n}}function sW(n){return(((n.mapValue||{}).fields||{}).__type__||{}).stringValue===nW}class Jr{constructor(e){this.value=e}static empty(){return new Jr({mapValue:{}})}field(e){if(e.isEmpty())return this.value;{let t=this.value;for(let s=0;s<e.length-1;++s)if(t=(t.mapValue.fields||{})[e.get(s)],!rd(t))return null;return t=(t.mapValue.fields||{})[e.lastSegment()],t||null}}set(e,t){this.getFieldsMap(e.popLast())[e.lastSegment()]=kp(t)}setAll(e){let t=qs.emptyPath(),s={},r=[];e.forEach(((a,l)=>{if(!t.isImmediateParentOf(l)){const c=this.getFieldsMap(t);this.applyChanges(c,s,r),s={},r=[],t=l.popLast()}a?s[l.lastSegment()]=kp(a):r.push(l.lastSegment())}));const i=this.getFieldsMap(t);this.applyChanges(i,s,r)}delete(e){const t=this.field(e.popLast());rd(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}isEqual(e){return Ca(this.value,e.value)}getFieldsMap(e){let t=this.value;t.mapValue.fields||(t.mapValue={fields:{}});for(let s=0;s<e.length;++s){let r=t.mapValue.fields[e.get(s)];rd(r)&&r.mapValue.fields||(r={mapValue:{fields:{}}},t.mapValue.fields[e.get(s)]=r),t=r}return t.mapValue.fields}applyChanges(e,t,s){xu(t,((r,i)=>e[r]=i));for(const r of s)delete e[r]}clone(){return new Jr(kp(this.value))}}function sR(n){const e=[];return xu(n.fields,((t,s)=>{const r=new qs([t]);if(rd(s)){const i=sR(s.mapValue).fields;
34if(i.length===0)e.push(r);else for(const a of i)e.push(r.child(a))}else e.push(r)})),new Ji(e)}function Ix(n,e){if(n.useProto3Json){if(isNaN(e))return{doubleValue:"NaN"};if(e===1/0)return{doubleValue:"Infinity"};if(e===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:tm(e)?"-0":e}}function j4(n){return{integerValue:""+n}}function Ax(n,e,t){return Number.isInteger(e)&&t?.preferIntegers||qH(e)?j4(e):Ix(n,e)}class Cx{constructor(){this._=void 0}}function rW(n,e,t){return n instanceof im?(function(r,i){const a={fields:{[Jk]:{stringValue:Xk},[eR]:{timestampValue:{seconds:r.seconds,nanos:r.nanoseconds}}}};return i&&_x(i)&&(i=Lm(i)),i&&(a.fields[Zk]=i),{mapValue:a}})(t,e):n instanceof Zh?iR(n,e):n instanceof ef?aR(n,e):n instanceof tf?(function(r,i){const a=rR(r,i),l=p1(a)+p1(r.Re);return Bo(a)&&Bo(r.Re)?j4(l):Ix(r.serializer,l)})(n,e):n instanceof h1?(function(r,i){return q8(r,i,Math.min)})(n,e):n instanceof f1?(function(r,i){return q8(r,i,Math.max)})(n,e):void 0}function iW(n,e,t){return n instanceof Zh?iR(n,e):n instanceof ef?aR(n,e):t}function rR(n,e){return n instanceof tf?nu(e)?e:{integerValue:0}:null}class im extends Cx{}class Zh extends Cx{constructor(e){super(),this.elements=e}}function iR(n,e){const t=oR(e);for(const s of n.elements)t.some((r=>Ca(r,s)))||t.push(s);return{arrayValue:{values:t}}}class ef extends Cx{constructor(e){super(),this.elements=e}}function aR(n,e){let t=oR(e);for(const s of n.elements)t=t.filter((r=>!Ca(r,s)));return{arrayValue:{values:t}}}class O4 extends Cx{constructor(e,t){super(),this.serializer=e,this.Re=t}}class tf extends O4{}class h1 extends O4{}class f1 extends O4{}function q8(n,e,t){if(!nu(e))return n.Re;const s=t(p1(e),p1(n.Re));return Bo(e)&&Bo(n.Re)?j4(s):Ix(n.serializer,s)}function p1(n){return is(n.integerValue||n.doubleValue)}function oR(n){return Jh(n)&&n.arrayValue.values?n.arrayValue.values.slice():[]}class kx{constructor(e,t){this.field=e,this.transform=t}}function aW(n,e){return n.field.isEqual(e.field)&&(function(s,r){return s instanceof Zh&&r instanceof Zh||s instanceof ef&&r instanceof ef?qh(s.elements,r.elements,Ca):s instanceof tf&&r instanceof tf||s instanceof h1&&r instanceof h1||s instanceof f1&&r instanceof f1?Ca(s.Re,r.Re):s instanceof im&&r instanceof im})(n.transform,e.transform)}class oW{constructor(e,t){this.version=e,this.transformResults=t}}class Ea{constructor(e,t){this.updateTime=e,this.exists=t}static none(){return new Ea}static exists(e){return new Ea(void 0,e)}static updateTime(e){return new Ea(e)}get isNone(){return this.updateTime===void 0&&this.exists===void 0}isEqual(e){return this.exists===e.exists&&(this.updateTime?!!e.updateTime&&this.updateTime.isEqual(e.updateTime):!e.updateTime)}}function A0(n,e){return n.updateTime!==void 0?e.isFoundDocument()&&e.version.isEqual(n.updateTime):n.exists===void 0||n.exists===e.isFoundDocument()}class Rx{}function lR(n,e){if(!n.hasLocalMutations||e&&e.fields.length===0)return null;if(e===null)return n.isNoDocument()?new M4(n.key,Ea.none()):new Dm(n.key,n.data,Ea.none());{const t=n.data,s=Jr.empty();let r=new js(qs.comparator);for(let i of e.fields)if(!r.has(i)){let a=t.field(i);a===null&&i.length>1&&(i=i.popLast(),a=t.field(i)),a===null?s.delete(i):s.set(i,a),r=r.add(i)}return new yu(n.key,s,new Ji(r.toArray()),Ea.none())}}function lW(n,e,t){n instanceof Dm?(function(r,i,a){const l=r.value.clone(),c=Q8(r.fieldTransforms,i,a.transformResults);l.setAll(c),i.convertToFoundDocument(a.version,l).setHasCommittedMutations()})(n,e,t):n instanceof yu?(function(r,i,a){if(!A0(r.precondition,i))return void i.convertToUnknownDocument(a.version);const l=Q8(r.fieldTransforms,i,a.transformResults),c=i.data;c.setAll(cR(r)),c.setAll(l),i.convertToFoundDocument(a.version,c).setHasCommittedMutations()})(n,e,t):(function(r,i,a){i.convertToNoDocument(a.version).setHasCommittedMutations()})(0,e,t)}function Rp(n,e,t,s){return n instanceof Dm?(function(i,a,l,c){if(!A0(i.precondition,a))return l;const d=i.value.clone(),h=X8(i.fieldTransforms,c,a);return d.setAll(h),a.convertToFoundDocument(a.version,d).setHasLocalMutations(),null}
34)(n,e,t,s):n instanceof yu?(function(i,a,l,c){if(!A0(i.precondition,a))return l;const d=X8(i.fieldTransforms,c,a),h=a.data;return h.setAll(cR(i)),h.setAll(d),a.convertToFoundDocument(a.version,h).setHasLocalMutations(),l===null?null:l.unionWith(i.fieldMask.fields).unionWith(i.fieldTransforms.map((p=>p.field)))})(n,e,t,s):(function(i,a,l){return A0(i.precondition,a)?(a.convertToNoDocument(a.version).setHasLocalMutations(),null):l})(n,e,t)}function cW(n,e){let t=null;for(const s of n.fieldTransforms){const r=e.data.field(s.field),i=rR(s.transform,r||null);i!=null&&(t===null&&(t=Jr.empty()),t.set(s.field,i))}return t||null}function Y8(n,e){return n.type===e.type&&!!n.key.isEqual(e.key)&&!!n.precondition.isEqual(e.precondition)&&!!(function(s,r){return s===void 0&&r===void 0||!(!s||!r)&&qh(s,r,((i,a)=>aW(i,a)))})(n.fieldTransforms,e.fieldTransforms)&&(n.type===0?n.value.isEqual(e.value):n.type!==1||n.data.isEqual(e.data)&&n.fieldMask.isEqual(e.fieldMask))}class Dm extends Rx{constructor(e,t,s,r=[]){super(),this.key=e,this.value=t,this.precondition=s,this.fieldTransforms=r,this.type=0}getFieldMask(){return null}}class yu extends Rx{constructor(e,t,s,r,i=[]){super(),this.key=e,this.data=t,this.fieldMask=s,this.precondition=r,this.fieldTransforms=i,this.type=1}getFieldMask(){return this.fieldMask}}function cR(n){const e=new Map;return n.fieldMask.fields.forEach((t=>{if(!t.isEmpty()){const s=n.data.field(t);e.set(t,s)}})),e}function Q8(n,e,t){const s=new Map;yt(n.length===t.length,32656,{Ie:t.length,Ae:n.length});for(let r=0;r<t.length;r++){const i=n[r],a=i.transform,l=e.data.field(i.field);s.set(i.field,iW(a,l,t[r]))}return s}function X8(n,e,t){const s=new Map;for(const r of n){const i=r.transform,a=t.data.field(r.field);s.set(r.field,rW(i,a,e))}return s}class M4 extends Rx{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}}class uW extends Rx{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}}class m1{constructor(e,t){this.position=e,this.inclusive=t}}function J8(n,e,t){let s=0;for(let r=0;r<n.position.length;r++){const i=e[r],a=n.position[r];if(i.field.isKeyField()?s=bt.comparator(bt.fromName(a.referenceValue),t.key):s=Ri(a,t.data.field(i.field)),i.dir==="desc"&&(s*=-1),s!==0)break}return s}function Z8(n,e){if(n===null)return e===null;if(e===null||n.inclusive!==e.inclusive||n.position.length!==e.position.length)return!1;for(let t=0;t<n.position.length;t++)if(!Ca(n.position[t],e.position[t]))return!1;return!0}class uR{}class Ns extends uR{constructor(e,t,s){super(),this.field=e,this.op=t,this.value=s}static create(e,t,s){return e.isKeyField()?t==="in"||t==="not-in"?this.createKeyFieldInFilter(e,t,s):new hW(e,t,s):t==="array-contains"?new mW(e,s):t==="in"?new gW(e,s):t==="not-in"?new xW(e,s):t==="array-contains-any"?new yW(e,s):new Ns(e,t,s)}static createKeyFieldInFilter(e,t,s){return t==="in"?new fW(e,s):new pW(e,s)}matches(e){const t=e.data.field(this.field);return this.op==="!="?t!==null&&t.nullValue===void 0&&this.matchesComparison(Ri(t,this.value)):t!==null&&Ms(this.value)===Ms(t)&&this.matchesComparison(Ri(t,this.value))}matchesComparison(e){switch(this.op){case"<":return e<0;case"<=":return e<=0;case"==":return e===0;case"!=":return e!==0;case">":return e>0;case">=":return e>=0;default:return _t(47266,{operator:this.op})}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class po extends uR{constructor(e,t){super(),this.filters=e,this.op=t,this.Ve=null}static create(e,t){return new po(e,t)}matches(e){return dR(this)?this.filters.find((t=>!t.matches(e)))===void 0:this.filters.find((t=>t.matches(e)))!==void 0}getFlattenedFilters(){return this.Ve!==null||(this.Ve=this.filters.reduce(((e,t)=>e.concat(t.getFlattenedFilters())),[])),this.Ve}getFilters(){return Object.assign([],this.filters)}}function dR(n){return n.op==="and"}function hR(n){return dW(n)&&dR(n)}function dW(n){for(const e of n.filters)if(e instanceof po)return!1;return!0}function Db(n){if(n instanceof Ns)return n.field.canonicalString()+n.op.toString()+Xh(n.value);if(hR(n))return n.filters.map((e=>Db(e))).join(",");{const e=n.filters.map((t=>Db(t))).join(",");return`${n.op}(${e})`}}function fR(n,e){return n instanceof Ns?(function(s,r){return r instanceof Ns&&s.op===r.op&&s.field.isEqual(r.field)&&Ca(s.value,r.value)})(n,e):n instanceof po?(function(s,r){return r instanceof po&&s.op===r.op&&s.filters.length===r.filters.length?s.filters.reduce(((i,a,l)=>i&&fR(a,r.filters[l])),!0):!1})(n,e):void _t(19439)}function pR(n){return n instanceof Ns?(function(t){return`${t.field.canonicalString()} ${t.op} ${Xh(t.value)}`})(n):n instanceof po?(function(t){return t.op.toString()+" {"+t.getFilters().map(pR).join(" ,")+"}"})(n):"Filter"}class hW extends Ns{constructor(e,t,s){super(e,t,s),this.key=bt.fromName(s.referenceValue)}matches(e){const t=bt.comparator(e.key,this.key);return this.matchesComparison(t)}}class fW extends Ns{constructor(e,t){super(e,"in",t),this.keys=mR("in",t)}matches(e){return this.keys.some((t=>t.isEqual(e.key)))}}class pW extends Ns{constructor(e,t){super(e,"not-in",t),this.keys=mR("not-in",t)}matches(e){return!this.keys.some((t=>t.isEqual(e.key)))}}function mR(n,e){return(e.arrayValue?.values||[]).map((t=>bt.fromName(t.referenceValue)))}class mW extends Ns{constructor(e,t){super(e,"array-contains",t)}matches(e){const t=e.data.field(this.field);return Jh(t)&&rm(t.arrayValue,this.value)}}class gW extends Ns{constructor(e,t){super(e,"in",t)}matches(e){const t=e.data.field(this.field);return t!==null&&rm(this.value.arrayValue,t)}}class xW extends Ns{constructor(e,t){super(e,"not-in",t)}matches(e){if(rm(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const t=e.data.field(this.field);return t!==null&&t.nullValue===void 0&&!rm(this.value.arrayValue,t)}}class yW extends Ns{constructor(e,t){super(e,"array-contains-any",t)}matches(e){const t=e.data.field(this.field);return!(!Jh(t)||!t.arrayValue.values)&&t.arrayValue.values.some((s=>rm(this.value.arrayValue,s)))}}class am{constructor(e,t="asc"){this.field=e,this.dir=t}}function vW(n,e){return n.dir===e.dir&&n.field.isEqual(e.field)}class Or{constructor(e,t,s,r,i,a,l){this.key=e,this.documentType=t,this.version=s,this.readTime=r,this.createTime=i,this.data=a,this.documentState=l}static newInvalidDocument(e){return new Or(e,0,Vt.min(),Vt.min(),Vt.min(),Jr.empty(),0)}static newFoundDocument(e,t,s,r){return new Or(e,1,t,Vt.min(),s,r,0)}static newNoDocument(e,t){return new Or(e,2,t,Vt.min(),Vt.min(),Jr.empty(),0)}static newUnknownDocument(e,t){return new Or(e,3,t,Vt.min(),Vt.min(),Jr.empty(),2)}convertToFoundDocument(e,t){return!this.createTime.isEqual(Vt.min())||this.documentType!==2&&this.documentType!==0||(this.createTime=e),this.version=e,this.documentType=1,this.data=t,this.documentState=0,this}convertToNoDocument(e){return this.version=e,this.documentType=2,this.data=Jr.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=Jr.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=Vt.min(),this}setReadTime(e){return this.readTime=e,this}get hasLocalMutations(){return this.documentState===1}get hasCommittedMutations(){return this.documentState===2}get hasPendingWrites(){return this.hasLocalMutations||this.hasCommittedMutations}isValidDocument(){return this.documentType!==0}isFoundDocument(){return this.documentType===1}isNoDocument(){return this.documentType===2}isUnknownDocument(){return this.documentType===3}isEqual(e){return e instanceof Or&&this.key.isEqual(e.key)&&this.version.isEqual(e.version)&&this.documentType===e.documentType&&this.documentState===e.documentState&&this.data.isEqual(e.data)}mutableCopy(){return new Or(this.key,this.documentType,this.version,this.readTime,this.createTime,this.data.clone(),this.documentState)}toString(){return`Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {createTime: ${this.createTime}}), {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`}}
34class bW{constructor(e,t=null,s=[],r=[],i=null,a=null,l=null){this.path=e,this.collectionGroup=t,this.orderBy=s,this.filters=r,this.limit=i,this.startAt=a,this.endAt=l,this.de=null}}function e5(n,e=null,t=[],s=[],r=null,i=null,a=null){return new bW(n,e,t,s,r,i,a)}function gR(n){const e=$t(n);if(e.de===null){let t=e.path.canonicalString();e.collectionGroup!==null&&(t+="|cg:"+e.collectionGroup),t+="|f:",t+=e.filters.map((s=>Db(s))).join(","),t+="|ob:",t+=e.orderBy.map((s=>(function(i){return i.field.canonicalString()+i.dir})(s))).join(","),Tx(e.limit)||(t+="|l:",t+=e.limit),e.startAt&&(t+="|lb:",t+=e.startAt.inclusive?"b:":"a:",t+=e.startAt.position.map((s=>Xh(s))).join(",")),e.endAt&&(t+="|ub:",t+=e.endAt.inclusive?"a:":"b:",t+=e.endAt.position.map((s=>Xh(s))).join(",")),e.de=t}return e.de}function xR(n,e){if(n.limit!==e.limit||n.orderBy.length!==e.orderBy.length)return!1;for(let t=0;t<n.orderBy.length;t++)if(!vW(n.orderBy[t],e.orderBy[t]))return!1;if(n.filters.length!==e.filters.length)return!1;for(let t=0;t<n.filters.length;t++)if(!fR(n.filters[t],e.filters[t]))return!1;return n.collectionGroup===e.collectionGroup&&!!n.path.isEqual(e.path)&&!!Z8(n.startAt,e.startAt)&&Z8(n.endAt,e.endAt)}function Qu(n){return!!n.isCorePipeline}function yR(n){return!!n.path&&bt.isDocumentKey(n.path)&&n.collectionGroup===null&&n.filters.length===0}class Ef{constructor(e,t=null,s=[],r=[],i=null,a="F",l=null,c=null){this.path=e,this.collectionGroup=t,this.explicitOrderBy=s,this.filters=r,this.limit=i,this.limitType=a,this.startAt=l,this.endAt=c,this.fe=null,this.me=null,this.pe=null,this.startAt,this.endAt}}function wW(n,e,t,s,r,i,a,l){return new Ef(n,e,t,s,r,i,a,l)}function Px(n){return new Ef(n)}function t5(n){return n.filters.length===0&&n.limit===null&&n.startAt==null&&n.endAt==null&&(n.explicitOrderBy.length===0||n.explicitOrderBy.length===1&&n.explicitOrderBy[0].field.isKeyField())}function SW(n){return bt.isDocumentKey(n.path)&&n.collectionGroup===null&&n.filters.length===0}function vR(n){return n.collectionGroup!==null}function Pp(n){const e=$t(n);if(e.fe===null){e.fe=[];const t=new Set;for(const i of e.explicitOrderBy)e.fe.push(i),t.add(i.field.canonicalString());const s=e.explicitOrderBy.length>0?e.explicitOrderBy[e.explicitOrderBy.length-1].dir:"asc";(function(a){let l=new js(qs.comparator);return a.filters.forEach((c=>{c.getFlattenedFilters().forEach((d=>{d.isInequality()&&(l=l.add(d.field))}))})),l})(e).forEach((i=>{t.has(i.canonicalString())||i.isKeyField()||e.fe.push(new am(i,s))})),t.has(qs.keyField().canonicalString())||e.fe.push(new am(qs.keyField(),s))}return e.fe}function Ho(n){const e=$t(n);return e.me||(e.me=EW(e,Pp(n))),e.me}function EW(n,e){if(n.limitType==="F")return e5(n.path,n.collectionGroup,e,n.filters,n.limit,n.startAt,n.endAt);{e=e.map((r=>{const i=r.dir==="desc"?"asc":"desc";return new am(r.field,i)}));const t=n.endAt?new m1(n.endAt.position,n.endAt.inclusive):null,s=n.startAt?new m1(n.startAt.position,n.startAt.inclusive):null;return e5(n.path,n.collectionGroup,e,n.filters,n.limit,t,s)}}function jb(n,e){const t=n.filters.concat([e]);return new Ef(n.path,n.collectionGroup,n.explicitOrderBy.slice(),t,n.limit,n.limitType,n.startAt,n.endAt)}function TW(n,e){const t=n.explicitOrderBy.concat([e]);return new Ef(n.path,n.collectionGroup,t,n.filters.slice(),n.limit,n.limitType,n.startAt,n.endAt)}function g1(n,e,t){return new Ef(n.path,n.collectionGroup,n.explicitOrderBy.slice(),n.filters.slice(),e,t,n.startAt,n.endAt)}function _W(n,e){return xR(Ho(n),Ho(e))&&n.limitType===e.limitType}function Np(n){return`Query(target=${(function(t){let s=t.path.canonicalString();return t.collectionGroup!==null&&(s+=" collectionGroup="+t.collectionGroup),t.filters.length>0&&(s+=`, filters: [${t.filters.map((r=>pR(r))).join(", ")}]`),Tx(t.limit)||(s+=", limit: "+t.limit),t.orderBy.length>0&&(s+=`, orderBy: [${t.orderBy.map((r=>(function(a){return`${a.field.canonicalString()} (${a.dir})`})(r))).join(", ")}]`),t.startAt&&(s+=", startAt: ",s+=t.startAt.inclusive?"b:":"a:",s+=t.startAt.position.map((r=>Xh(r))).join(",")),t.endAt&&(s+=", endAt: ",s+=t.endAt.inclusive?"a:":"b:",s+=t.endAt.position.map((r=>Xh(r))).join(",")),`Target(${s})`})(Ho(n))}; limitType=${n.limitType})`}
34function Nx(n,e){return e.isFoundDocument()&&(function(s,r){const i=r.key.path;return s.collectionGroup!==null?r.key.hasCollectionId(s.collectionGroup)&&s.path.isPrefixOf(i):bt.isDocumentKey(s.path)?s.path.isEqual(i):s.path.isImmediateParentOf(i)})(n,e)&&(function(s,r){for(const i of Pp(s))if(!i.field.isKeyField()&&r.data.field(i.field)===null)return!1;return!0})(n,e)&&(function(s,r){for(const i of s.filters)if(!i.matches(r))return!1;return!0})(n,e)&&(function(s,r){return!(s.startAt&&!(function(a,l,c){const d=J8(a,l,c);return a.inclusive?d<=0:d<0})(s.startAt,Pp(s),r)||s.endAt&&!(function(a,l,c){const d=J8(a,l,c);return a.inclusive?d>=0:d>0})(s.endAt,Pp(s),r))})(n,e)}function F4(n){return(e,t)=>{let s=!1;for(const r of Pp(n)){const i=IW(r,e,t);if(i!==0)return i;s=s||r.field.isKeyField()}return 0}}function IW(n,e,t){const s=n.field.isKeyField()?bt.comparator(e.key,t.key):(function(i,a,l){const c=a.data.field(i),d=l.data.field(i);return c!==null&&d!==null?Ri(c,d):_t(42886)})(n.field,e,t);switch(n.dir){case"asc":return s;case"desc":return-1*s;default:return _t(19790,{direction:n.dir})}}class AW{constructor(e,t){this.count=e,this.unchangedNames=t}}var ks,dn;function CW(n){switch(n){case Ce.OK:return _t(64938);case Ce.CANCELLED:case Ce.UNKNOWN:case Ce.DEADLINE_EXCEEDED:case Ce.RESOURCE_EXHAUSTED:case Ce.INTERNAL:case Ce.UNAVAILABLE:case Ce.UNAUTHENTICATED:return!1;case Ce.INVALID_ARGUMENT:case Ce.NOT_FOUND:case Ce.ALREADY_EXISTS:case Ce.PERMISSION_DENIED:case Ce.FAILED_PRECONDITION:case Ce.ABORTED:case Ce.OUT_OF_RANGE:case Ce.UNIMPLEMENTED:case Ce.DATA_LOSS:return!0;default:return _t(15467,{code:n})}}function bR(n){if(n===void 0)return Kl("GRPC error has no .code"),Ce.UNKNOWN;switch(n){case ks.OK:return Ce.OK;case ks.CANCELLED:return Ce.CANCELLED;case ks.UNKNOWN:return Ce.UNKNOWN;case ks.DEADLINE_EXCEEDED:return Ce.DEADLINE_EXCEEDED;case ks.RESOURCE_EXHAUSTED:return Ce.RESOURCE_EXHAUSTED;case ks.INTERNAL:return Ce.INTERNAL;case ks.UNAVAILABLE:return Ce.UNAVAILABLE;case ks.UNAUTHENTICATED:return Ce.UNAUTHENTICATED;case ks.INVALID_ARGUMENT:return Ce.INVALID_ARGUMENT;case ks.NOT_FOUND:return Ce.NOT_FOUND;case ks.ALREADY_EXISTS:return Ce.ALREADY_EXISTS;case ks.PERMISSION_DENIED:return Ce.PERMISSION_DENIED;case ks.FAILED_PRECONDITION:return Ce.FAILED_PRECONDITION;case ks.ABORTED:return Ce.ABORTED;case ks.OUT_OF_RANGE:return Ce.OUT_OF_RANGE;case ks.UNIMPLEMENTED:return Ce.UNIMPLEMENTED;case ks.DATA_LOSS:return Ce.DATA_LOSS;default:return _t(39323,{code:n})}}(dn=ks||(ks={}))[dn.OK=0]="OK",dn[dn.CANCELLED=1]="CANCELLED",dn[dn.UNKNOWN=2]="UNKNOWN",dn[dn.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",dn[dn.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",dn[dn.NOT_FOUND=5]="NOT_FOUND",dn[dn.ALREADY_EXISTS=6]="ALREADY_EXISTS",dn[dn.PERMISSION_DENIED=7]="PERMISSION_DENIED",dn[dn.UNAUTHENTICATED=16]="UNAUTHENTICATED",dn[dn.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",dn[dn.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",dn[dn.ABORTED=10]="ABORTED",dn[dn.OUT_OF_RANGE=11]="OUT_OF_RANGE",dn[dn.UNIMPLEMENTED=12]="UNIMPLEMENTED",dn[dn.INTERNAL=13]="INTERNAL",dn[dn.UNAVAILABLE=14]="UNAVAILABLE",dn[dn.DATA_LOSS=15]="DATA_LOSS";class Nd{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.innerSize=0}get(e){const t=this.mapKeyFn(e),s=this.inner[t];if(s!==void 0){for(const[r,i]of s)if(this.equalsFn(r,e))return i}}has(e){return this.get(e)!==void 0}set(e,t){const s=this.mapKeyFn(e),r=this.inner[s];if(r===void 0)return this.inner[s]=[[e,t]],void this.innerSize++;for(let i=0;i<r.length;i++)if(this.equalsFn(r[i][0],e))return void(r[i]=[e,t]);r.push([e,t]),this.innerSize++}delete(e){const t=this.mapKeyFn(e),s=this.inner[t];if(s===void 0)return!1;for(let r=0;r<s.length;r++)if(this.equalsFn(s[r][0],e))return s.length===1?delete this.inner[t]:s.splice(r,1),this.innerSize--,!0;return!1}forEach(e){xu(this.inner,((t,s)=>{for(const[r,i]of s)e(r,i)}))}isEmpty(){return Yk(this.inner)}size(){return this.innerSize}}const kW=new Zn(bt.comparator);function Ei(){return kW}const wR=new Zn(bt.comparator);function bh(...n){let e=wR;for(const t of n)e=e.insert(t.key,t);return e}function SR(n){let e=wR;
vendor: 9,494 bytes, line 34
34return n.forEach(((t,s)=>e=e.insert(t,s.overlayedDocument))),e}function Dc(){return Lp()}function ER(){return Lp()}function Lp(){return new Nd((n=>n.toString()),((n,e)=>n.isEqual(e)))}const RW=new Zn(bt.comparator),PW=new js(bt.comparator);function en(...n){let e=PW;for(const t of n)e=e.add(t);return e}const NW=new js(sn);function LW(){return NW}function DW(){return new TextEncoder}const jW=new Gc([4294967295,4294967295],0);function n5(n){const e=DW().encode(n),t=new Fk;return t.update(e),new Uint8Array(t.digest())}function s5(n){const e=new DataView(n.buffer),t=e.getUint32(0,!0),s=e.getUint32(4,!0),r=e.getUint32(8,!0),i=e.getUint32(12,!0);return[new Gc([t,s],0),new Gc([r,i],0)]}class U4{constructor(e,t,s){if(this.bitmap=e,this.padding=t,this.hashCount=s,t<0||t>=8)throw new yp(`Invalid padding: ${t}`);if(s<0)throw new yp(`Invalid hash count: ${s}`);if(e.length>0&&this.hashCount===0)throw new yp(`Invalid hash count: ${s}`);if(e.length===0&&t!==0)throw new yp(`Invalid padding when bitmap length is 0: ${t}`);this.ge=8*e.length-t,this.ye=Gc.fromNumber(this.ge)}we(e,t,s){let r=e.add(t.multiply(Gc.fromNumber(s)));return r.compare(jW)===1&&(r=new Gc([r.getBits(0),r.getBits(1)],0)),r.modulo(this.ye).toNumber()}be(e){return!!(this.bitmap[Math.floor(e/8)]&1<<e%8)}mightContain(e){if(this.ge===0)return!1;const t=n5(e),[s,r]=s5(t);for(let i=0;i<this.hashCount;i++){const a=this.we(s,r,i);if(!this.be(a))return!1}return!0}static create(e,t,s){const r=e%8==0?0:8-e%8,i=new Uint8Array(Math.ceil(e/8)),a=new U4(i,r,t);return s.forEach((l=>a.insert(l))),a}insert(e){if(this.ge===0)return;const t=n5(e),[s,r]=s5(t);for(let i=0;i<this.hashCount;i++){const a=this.we(s,r,i);this.ve(a)}}ve(e){const t=Math.floor(e/8),s=e%8;this.bitmap[t]|=1<<s}}class yp extends Error{constructor(){super(...arguments),this.name="BloomFilterError"}}class jm{constructor(e,t,s,r,i,a){this.snapshotVersion=e,this.targetChanges=t,this.targetMismatches=s,this.documentUpdates=r,this.augmentedDocumentUpdates=i,this.resolvedLimboDocuments=a}static createSynthesizedRemoteEventForCurrentChange(e,t,s){const r=new Map;return r.set(e,Om.createSynthesizedTargetChangeForCurrentChange(e,t,s)),new jm(Vt.min(),r,new Zn(sn),Ei(),Ei(),en())}}class Om{constructor(e,t,s,r,i){this.resumeToken=e,this.current=t,this.addedDocuments=s,this.modifiedDocuments=r,this.removedDocuments=i}static createSynthesizedTargetChangeForCurrentChange(e,t,s){return new Om(s,t,en(),en(),en())}}class C0{constructor(e,t,s,r){this.Se=e,this.removedTargetIds=t,this.key=s,this.De=r}}class TR{constructor(e,t){this.targetId=e,this.xe=t}}class _R{constructor(e,t,s=Os.EMPTY_BYTE_STRING,r=null){this.state=e,this.targetIds=t,this.resumeToken=s,this.cause=r}}class r5{constructor(e){this.targetId=e,this.Ce=0,this.Fe=i5(),this.Oe=Os.EMPTY_BYTE_STRING,this.Me=!1,this.Ne=!0}get current(){return this.Me}get resumeToken(){return this.Oe}get Le(){return this.Ce!==0}get Be(){return this.Ne}Ue(e){e.approximateByteSize()>0&&(this.Ne=!0,this.Oe=e)}ke(){let e=en(),t=en(),s=en();return this.Fe.forEach(((r,i)=>{switch(i){case 0:e=e.add(r);break;case 2:t=t.add(r);break;case 1:s=s.add(r);break;default:_t(38017,{changeType:i})}})),new Om(this.Oe,this.Me,e,t,s)}qe(){this.Ne=!1,this.Fe=i5()}$e(e,t){this.Ne=!0,this.Fe=this.Fe.insert(e,t)}Ke(e){this.Ne=!0,this.Fe=this.Fe.remove(e)}We(){this.Ce+=1}Qe(){this.Ce-=1,yt(this.Ce>=0,3241,{Ce:this.Ce,targetId:this.targetId})}Ge(){this.Ne=!0,this.Me=!0}}const ap="WatchChangeAggregator";class OW{constructor(e){this.ze=e,this.je=new Map,this.He=Ei(),this.Je=qg(),this.Ye=Ei(),this.Ze=qg(),this.Xe=new Zn(sn)}et(e){for(const t of e.Se)e.De&&e.De.isFoundDocument()?this.tt(t,e.De):this.nt(t,e.key,e.De);for(const t of e.removedTargetIds)this.nt(t,e.key,e.De)}rt(e){this.forEachTarget(e,(t=>{const s=this.je.get(t);if(s)switch(e.state){case 0:this.it(t)&&s.Ue(e.resumeToken);break;case 1:s.Qe(),s.Le||s.qe(),s.Ue(e.resumeToken);break;case 2:s.Qe(),s.Le||this.removeTarget(t);break;case 3:this.it(t)&&(s.Ge(),s.Ue(e.resumeToken));break;case 4:this.it(t)&&(this.st(t),s.Ue(e.resumeToken));break;default:_t(56790,{state:e.state})}else Ze(ap,`handleTargetChange received targetChange for untracked target ID (${t}) with state (${e.state})`)}))}forEachTarget(e,t){e.targetIds.length>0?e.targetIds.forEach(t):this.je.forEach(((s,r)=>{this.it(r)&&t(r)}))}_t(e){return Qu(e)?e.getPipelineSourceType()==="documents"&&e.getPipelineDocuments()?.length===1:yR(e)}ot(e){const t=e.targetId,s=e.xe.count,r=this.ut(t);if(r){const i=r.target;if(this._t(i))if(s===0){const a=new bt(Qu(i)?bn.fromString(i.getPipelineDocuments()[0]):i.path);this.nt(t,a,Or.newNoDocument(a,Vt.min()))}else yt(s===1,20013,"Single document existence filter with count: "+s);else{const a=this.ct(t);if(a!==s){const l=this.lt(e),c=l?this.Et(l,e,a):1;if(c!==0){this.st(t);const d=c===2?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch";this.Xe=this.Xe.insert(t,d)}}}}}lt(e){const t=e.xe.unchangedNames;if(!t||!t.bits)return null;const{bits:{bitmap:s="",padding:r=0},hashCount:i=0}=t;let a,l;try{a=tu(s).toUint8Array()}catch(c){if(c instanceof Qk)return fo("Decoding the base64 bloom filter in existence filter failed ("+c.message+"); ignoring the bloom filter and falling back to full re-query."),null;throw c}try{l=new U4(a,r,i)}catch(c){return fo(c instanceof yp?"BloomFilter error: ":"Applying bloom filter failed: ",c),null}return l.ge===0?null:l}Et(e,t,s){return t.xe.count===s-this.Pt(e,t.targetId)?0:2}Pt(e,t){const s=this.ze.getRemoteKeysForTarget(t);let r=0;return s.forEach((i=>{const a=this.ze.Tt(),l=`projects/${a.projectId}/databases/${a.database}/documents/${i.path.canonicalString()}`;e.mightContain(l)||(this.nt(t,i,null),r++)})),r}Rt(e){const t=new Map;this.je.forEach(((i,a)=>{const l=this.ut(a);if(l){if(i.current&&this._t(l.target)){const c=Qu(l.target)?bn.fromString(l.target.getPipelineDocuments()[0]):l.target.path,d=new bt(c);this.It(d).has(a)||this.At(a,d)||this.nt(a,d,Or.newNoDocument(d,e))}i.Be&&(t.set(a,i.ke()),i.qe())}}));let s=en();this.Ze.forEach(((i,a)=>{let l=!0;a.forEachWhile((c=>{const d=this.ut(c);return!d||d.purpose==="TargetPurposeLimboResolution"||(l=!1,!1)})),l&&(s=s.add(i))})),this.He.forEach(((i,a)=>a.setReadTime(e))),this.Ye.forEach(((i,a)=>a.setReadTime(e)));const r=new jm(e,t,this.Xe,this.He,this.Ye,s);return this.He=Ei(),this.Je=qg(),this.Ye=Ei(),this.Ze=qg(),this.Xe=new Zn(sn),r}tt(e,t){const s=this.je.get(e);if(!s||!this.it(e))return void Ze(ap,`addDocumentToTarget received document for unknown inactive target (${e})`);const r=this.At(e,t.key)?2:0;s.$e(t.key,r),Qu(this.ut(e).target)&&this.ut(e).target.getPipelineFlavor()!=="exact"?this.Ye=this.Ye.insert(t.key,t):this.He=this.He.insert(t.key,t),this.Je=this.Je.insert(t.key,this.It(t.key).add(e)),this.Ze=this.Ze.insert(t.key,this.Vt(t.key).add(e))}nt(e,t,s){const r=this.je.get(e);r&&this.it(e)?(this.At(e,t)?r.$e(t,1):r.Ke(t),this.Ze=this.Ze.insert(t,this.Vt(t).delete(e)),this.Ze=this.Ze.insert(t,this.Vt(t).add(e)),s&&(Qu(this.ut(e).target)&&this.ut(e).target.getPipelineFlavor()!=="exact"?this.Ye=this.Ye.insert(t,s):this.He=this.He.insert(t,s))):Ze(ap,`removeDocumentFromTarget received document for unknown or inactive target (${e})`)}removeTarget(e){this.je.delete(e)}ct(e){const t=this.je.get(e);if(!t)return 0;const s=t.ke();return this.ze.getRemoteKeysForTarget(e).size+s.addedDocuments.size-s.removedDocuments.size}We(e){let t=this.je.get(e);t||(Ze(ap,`recordPendingTargetRequest set up tracking for target ID ${e}`),t=new r5(e),this.je.set(e,t)),t.We()}Vt(e){let t=this.Ze.get(e);return t||(t=new js(sn),this.Ze=this.Ze.insert(e,t)),t}It(e){let t=this.Je.get(e);return t||(t=new js(sn),this.Je=this.Je.insert(e,t)),t}it(e){const t=this.ut(e)!==null;return t||Ze(ap,"Detected inactive target",e),t}ut(e){const t=this.je.get(e);return t===void 0||t.Le?null:this.ze.dt(e)}st(e){this.je.set(e,new r5(e)),this.ze.getRemoteKeysForTarget(e).forEach((t=>{this.nt(e,t,null)}))}At(e,t){return this.ze.getRemoteKeysForTarget(e).has(t)}}function qg(){return new Zn(bt.comparator)}function i5(){return new Zn(bt.comparator)}const MW={asc:"ASCENDING",desc:"DESCENDING"},FW={"<":"LESS_THAN","<=":"LESS_THAN_OR_EQUAL",">":"GREATER_THAN",">=":"GREATER_THAN_OR_EQUAL","==":"EQUAL","!=":"NOT_EQUAL","array-contains":"ARRAY_CONTAINS",in:"IN","not-in":"NOT_IN","array-contains-any":"ARRAY_CONTAINS_ANY"},UW={and:"AND",or:"OR"};class VW{constructor(e,t){this.databaseId=e,this.useProto3Json=t}}function Ob(n,e){return n.useProto3Json||Tx(e)?e:{value:e}}function x1(n,e){return n.useProto3Json?`${new Date(1e3*e.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+e.nanoseconds).slice(-9)}Z`:{seconds:""+e.seconds,nanos:e.nanoseconds}}function V4(n){const e=eu(n);return new $n(e.seconds,e.nanos)}function IR(n,e){return n.useProto3Json?e.toBase64():e.toUint8Array()}function k0(n,e){return x1(n,e.toTimestamp())}function Wo(n){return yt(!!n,49232),Vt.fromTimestamp(V4(n))}function B4(n,e){return Mb(n,e).canonicalString()}function Mb(n,e){const t=(function(r){return new bn(["projects",r.projectId,"databases",r.database])})(n).child("documents");return e===void 0?t:t.child(e)}function AR(n){const e=bn.fromString(n);return yt(NR(e),10190,{key:e.toString()}),e}function y1(n,e){return B4(n.databaseId,e.path)}function nv(n,e){const t=AR(e);if(t.get(1)!==n.databaseId.projectId)throw new Xe(Ce.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+t.get(1)+" vs "+n.databaseId.projectId);
34if(t.get(3)!==n.databaseId.database)throw new Xe(Ce.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+t.get(3)+" vs "+n.databaseId.database);return new bt(kR(t))}function CR(n,e){return B4(n.databaseId,e)}function BW(n){const e=AR(n);return e.length===4?bn.emptyPath():kR(e)}function Fb(n){return new bn(["projects",n.databaseId.projectId,"databases",n.databaseId.database]).canonicalString()}function kR(n){return yt(n.length>4&&n.get(4)==="documents",29091,{key:n.toString()}),n.popFirst(5)}function a5(n,e,t){return{name:y1(n,e),fields:t.value.mapValue.fields}}function zW(n,e){let t;if("targetChange"in e){e.targetChange;const s=(function(d){return d==="NO_CHANGE"?0:d==="ADD"?1:d==="REMOVE"?2:d==="CURRENT"?3:d==="RESET"?4:_t(39313,{state:d})})(e.targetChange.targetChangeType||"NO_CHANGE"),r=e.targetChange.targetIds||[],i=(function(d,h){return d.useProto3Json?(yt(h===void 0||typeof h=="string",58123),Os.fromBase64String(h||"")):(yt(h===void 0||h instanceof Buffer||h instanceof Uint8Array,16193),Os.fromUint8Array(h||new Uint8Array))})(n,e.targetChange.resumeToken),a=e.targetChange.cause,l=a&&(function(d){const h=d.code===void 0?Ce.UNKNOWN:bR(d.code);return new Xe(h,d.message||"")})(a);t=new _R(s,r,i,l||null)}else if("documentChange"in e){e.documentChange;const s=e.documentChange;s.document,s.document.name,s.document.updateTime;const r=nv(n,s.document.name),i=Wo(s.document.updateTime),a=s.document.createTime?Wo(s.document.createTime):Vt.min(),l=new Jr({mapValue:{fields:s.document.fields}}),c=Or.newFoundDocument(r,i,a,l),d=s.targetIds||[],h=s.removedTargetIds||[];t=new C0(d,h,c.key,c)}else if("documentDelete"in e){e.documentDelete;const s=e.documentDelete;s.document;const r=nv(n,s.document),i=s.readTime?Wo(s.readTime):Vt.min(),a=Or.newNoDocument(r,i),l=s.removedTargetIds||[];t=new C0([],l,a.key,a)}else if("documentRemove"in e){e.documentRemove;const s=e.documentRemove;s.document;const r=nv(n,s.document),i=s.removedTargetIds||[];t=new C0([],i,r,null)}else{if(!("filter"in e))return _t(11601,{ft:e});{e.filter;const s=e.filter;s.targetId;const{count:r=0,unchangedNames:i}=s,a=new AW(r,i),l=s.targetId;t=new TR(l,a)}}return t}function $W(n,e){let t;if(e instanceof Dm)t={update:a5(n,e.key,e.value)};else if(e instanceof M4)t={delete:y1(n,e.key)};else if(e instanceof yu)t={update:a5(n,e.key,e.data),updateMask:ZW(e.fieldMask)};else{if(!(e instanceof uW))return _t(16599,{gt:e.type});t={verify:y1(n,e.key)}}return e.fieldTransforms.length>0&&(t.updateTransforms=e.fieldTransforms.map((s=>(function(i,a){const l=a.transform;if(l instanceof im)return{fieldPath:a.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(l instanceof Zh)return{fieldPath:a.field.canonicalString(),appendMissingElements:{values:l.elements}};if(l instanceof ef)return{fieldPath:a.field.canonicalString(),removeAllFromArray:{values:l.elements}};if(l instanceof tf)return{fieldPath:a.field.canonicalString(),increment:l.Re};if(l instanceof h1)return{fieldPath:a.field.canonicalString(),minimum:l.Re};if(l instanceof f1)return{fieldPath:a.field.canonicalString(),maximum:l.Re};throw _t(20930,{transform:a.transform})})(0,s)))),e.precondition.isNone||(t.currentDocument=(function(r,i){return i.updateTime!==void 0?{updateTime:k0(r,i.updateTime)}:i.exists!==void 0?{exists:i.exists}:_t(27497)})(n,e.precondition)),t}function HW(n,e){return n&&n.length>0?(yt(e!==void 0,14353),n.map((t=>(function(r,i){let a=r.updateTime?Wo(r.updateTime):Wo(i);return a.isEqual(Vt.min())&&(a=Wo(i)),new oW(a,r.transformResults||[])})(t,e)))):[]}function WW(n,e){return{documents:[CR(n,e.path)]}}function GW(n,e){const t={structuredQuery:{}},s=e.path;let r;e.collectionGroup!==null?(r=s,t.structuredQuery.from=[{collectionId:e.collectionGroup,allDescendants:!0}]):(r=s.popLast(),t.structuredQuery.from=[{collectionId:s.lastSegment()}]),t.parent=CR(n,r);const i=(function(d){if(d.length!==0)return PR(po.create(d,"and"))})(e.filters);i&&(t.structuredQuery.where=i);const a=(function(d){if(d.length!==0)return d.map((h=>(function(m){return{field:wh(m.field),direction:QW(m.dir)}})(h)))})(e.orderBy);a&&(t.structuredQuery.orderBy=a);const l=Ob(n,e.limit);return l!==null&&(t.structuredQuery.limit=l),e.startAt&&(t.structuredQuery.startAt=(function(d){return{before:d.inclusive,values:d.position}})(e.startAt)),e.endAt&&(t.structuredQuery.endAt=(function(d){return{before:!d.inclusive,values:d.position}})(e.endAt)),{yt:t,parent:r}}function KW(n){let e=BW(n.parent);const t=n.structuredQuery,s=t.from?t.from.length:0;let r=null;if(s>0){yt(s===1,65062);const h=t.from[0];h.allDescendants?r=h.collectionId:e=e.child(h.collectionId)}let i=[];t.where&&(i=(function(p){const m=RR(p);return m instanceof po&&hR(m)?m.getFilters():[m]})(t.where));let a=[];t.orderBy&&(a=(function(p){return p.map((m=>(function(x){return new am(Sh(x.field),(function(S){switch(S){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}})(x.direction))})(m)))})(t.orderBy));let l=null;t.limit&&(l=(function(p){let m;return m=typeof p=="object"?p.value:p,Tx(m)?null:m})(t.limit));let c=null;t.startAt&&(c=(function(p){const m=!!p.before,y=p.values||[];return new m1(y,m)})(t.startAt));let d=null;return t.endAt&&(d=(function(p){const m=!p.before,y=p.values||[];return new m1(y,m)})(t.endAt)),wW(e,r,a,i,l,"F",c,d)}function qW(n,e){const t=(function(r){switch(r){case"TargetPurposeListen":return null;case"TargetPurposeExistenceFilterMismatch":return"existence-filter-mismatch";case"TargetPurposeExistenceFilterMismatchBloom":return"existence-filter-mismatch-bloom";case"TargetPurposeLimboResolution":return"limbo-document";default:return _t(28987,{purpose:r})}})(e.purpose);return t==null?null:{"goog-listen-tags":t}}function YW(n,e){return{structuredPipeline:{pipeline:{stages:e.stages.map((t=>t._toProto(n)))}}}}function RR(n){return n.unaryFilter!==void 0?(function(t){switch(t.unaryFilter.op){case"IS_NAN":const s=Sh(t.unaryFilter.field);return Ns.create(s,"==",{doubleValue:NaN});case"IS_NULL":const r=Sh(t.unaryFilter.field);return Ns.create(r,"==",{nullValue:"NULL_VALUE"});
34case"IS_NOT_NAN":const i=Sh(t.unaryFilter.field);return Ns.create(i,"!=",{doubleValue:NaN});case"IS_NOT_NULL":const a=Sh(t.unaryFilter.field);return Ns.create(a,"!=",{nullValue:"NULL_VALUE"});case"OPERATOR_UNSPECIFIED":return _t(61313);default:return _t(60726)}})(n):n.fieldFilter!==void 0?(function(t){return Ns.create(Sh(t.fieldFilter.field),(function(r){switch(r){case"EQUAL":return"==";case"NOT_EQUAL":return"!=";case"GREATER_THAN":return">";case"GREATER_THAN_OR_EQUAL":return">=";case"LESS_THAN":return"<";case"LESS_THAN_OR_EQUAL":return"<=";case"ARRAY_CONTAINS":return"array-contains";case"IN":return"in";case"NOT_IN":return"not-in";case"ARRAY_CONTAINS_ANY":return"array-contains-any";case"OPERATOR_UNSPECIFIED":return _t(58110);default:return _t(50506)}})(t.fieldFilter.op),t.fieldFilter.value)})(n):n.compositeFilter!==void 0?(function(t){return po.create(t.compositeFilter.filters.map((s=>RR(s))),(function(r){switch(r){case"AND":return"and";case"OR":return"or";default:return _t(1026)}})(t.compositeFilter.op))})(n):_t(30097,{filter:n})}function QW(n){return MW[n]}function XW(n){return FW[n]}function JW(n){return UW[n]}function wh(n){return{fieldPath:n.canonicalString()}}function Sh(n){return qs.fromServerFormat(n.fieldPath)}function PR(n){return n instanceof Ns?(function(t){if(t.op==="=="){if(Pi(t.value))return{unaryFilter:{field:wh(t.field),op:"IS_NAN"}};if(Zi(t.value))return{unaryFilter:{field:wh(t.field),op:"IS_NULL"}}}else if(t.op==="!="){if(Pi(t.value))return{unaryFilter:{field:wh(t.field),op:"IS_NOT_NAN"}};if(Zi(t.value))return{unaryFilter:{field:wh(t.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:wh(t.field),op:XW(t.op),value:t.value}}})(n):n instanceof po?(function(t){const s=t.getFilters().map((r=>PR(r)));return s.length===1?s[0]:{compositeFilter:{op:JW(t.op),filters:s}}})(n):_t(54877,{filter:n})}function ZW(n){const e=[];return n.fields.forEach((t=>e.push(t.canonicalString()))),{fieldPaths:e}}function NR(n){return n.length>=4&&n.get(0)==="projects"&&n.get(2)==="databases"}function LR(n){return!!n&&typeof n._toProto=="function"&&n._protoValueType==="ProtoValue"}function om(n,e){const t={fields:{}};return e.forEach(((s,r)=>{if(typeof r!="string")throw new Error(`Cannot encode map with non-string key: ${r}`);t.fields[r]=s._toProto(n)})),{mapValue:t}}function DR(n){return{stringValue:n}}function Lx(n){return new VW(n,!0)}class wa{constructor(e){this._byteString=e}static fromBase64String(e){try{return new wa(Os.fromBase64String(e))}catch(t){throw new Xe(Ce.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+t)}}static fromUint8Array(e){return new wa(Os.fromUint8Array(e))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+")"}isEqual(e){return this._byteString.isEqual(e._byteString)}toJSON(){return{type:wa._jsonSchemaVersion,bytes:this.toBase64()}}static fromJSON(e){if(Nm(e,wa._jsonSchema))return wa.fromBase64String(e.bytes)}}wa._jsonSchemaVersion="firestore/bytes/1.0",wa._jsonSchema={type:Ls("string",wa._jsonSchemaVersion),bytes:Ls("string")};class Dx{constructor(...e){for(let t=0;t<e.length;++t)if(e[t].length===0)throw new Xe(Ce.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new qs(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}}function eG(){return new Dx(Vo)}class Ld{constructor(e){this._methodName=e}}class Go{constructor(e,t){if(!isFinite(e)||e<-90||e>90)throw new Xe(Ce.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(t)||t<-180||t>180)throw new Xe(Ce.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+t);this._lat=e,this._long=t}get latitude(){return this._lat}get longitude(){return this._long}isEqual(e){return this._lat===e._lat&&this._long===e._long}_compareTo(e){return sn(this._lat,e._lat)||sn(this._long,e._long)}toJSON(){return{latitude:this._lat,longitude:this._long,type:Go._jsonSchemaVersion}}static fromJSON(e){if(Nm(e,Go._jsonSchema))return new Go(e.latitude,e.longitude)}}function jR(n){const e={};return n.timeoutSeconds!==void 0&&(e.timeoutSeconds=n.timeoutSeconds),e}Go._jsonSchemaVersion="firestore/geoPoint/1.0",Go._jsonSchema={type:Ls("string",Go._jsonSchemaVersion),latitude:Ls("number"),longitude:Ls("number")};class tG{bt(e){}shutdown(){}}const o5="ConnectivityMonitor";class l5{constructor(){this.vt=()=>this.St(),this.Dt=()=>this.xt(),this.Ct=[],this.Ft()}bt(e){this.Ct.push(e)}shutdown(){window.removeEventListener("online",this.vt),window.removeEventListener("offline",this.Dt)}Ft(){window.addEventListener("online",this.vt),window.addEventListener("offline",this.Dt)}St(){Ze(o5,"Network connectivity changed: AVAILABLE");for(const e of this.Ct)e(0)}xt(){Ze(o5,"Network connectivity changed: UNAVAILABLE");for(const e of this.Ct)e(1)}static C(){return typeof window<"u"&&window.addEventListener!==void 0&&window.removeEventListener!==void 0}}let Yg=null;function Ub(){return Yg===null?Yg=(function(){return 268435456+Math.round(2147483648*Math.random())})():Yg++,"0x"+Yg.toString(16)}const sv="RestConnection",nG={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregation
vendor: 4,426 bytes, line 34
34Query:"runAggregationQuery",ExecutePipeline:"executePipeline"};class sG{get Ot(){return!1}constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;const t=e.ssl?"https":"http",s=encodeURIComponent(this.databaseId.projectId),r=encodeURIComponent(this.databaseId.database);this.Mt=t+"://"+e.host,this.Nt=`projects/${s}/databases/${r}`,this.Lt=this.databaseId.database===u1?`project_id=${s}`:`project_id=${s}&database_id=${r}`}Bt(e,t,s,r,i){const a=Ub(),l=this.Ut(e,t.toUriEncodedString());Ze(sv,`Sending RPC '${e}' ${a}:`,l,s);const c={"google-cloud-resource-prefix":this.Nt,"x-goog-request-params":this.Lt};this.kt(c,r,i);const{host:d}=new URL(l),h=Cd(d);return this.qt(e,l,c,s,h).then((p=>(Ze(sv,`Received RPC '${e}' ${a}: `,p),p)),(p=>{throw fo(sv,`RPC '${e}' ${a} failed with error: `,p,"url: ",l,"request:",s),p}))}$t(e,t,s,r,i,a){return this.Bt(e,t,s,r,i)}kt(e,t,s){e["X-Goog-Api-Client"]=(function(){return"gl-js/ fire/"+bf})(),e["Content-Type"]="text/plain",this.databaseInfo.appId&&(e["X-Firebase-GMPID"]=this.databaseInfo.appId),t&&t.headers.forEach(((r,i)=>e[i]=r)),s&&s.headers.forEach(((r,i)=>e[i]=r))}Ut(e,t){const s=nG[e];let r=`${this.Mt}/v1/${t}:${s}`;return this.databaseInfo.apiKey&&(r=`${r}?key=${encodeURIComponent(this.databaseInfo.apiKey)}`),r}terminate(){}}class rG{constructor(e){this.Kt=e.Kt,this.Wt=e.Wt}Qt(e){this.Gt=e}zt(e){this.jt=e}Ht(e){this.Jt=e}onMessage(e){this.Yt=e}close(){this.Wt()}send(e){this.Kt(e)}Zt(){this.Gt()}Xt(){this.jt()}en(e){this.Jt(e)}tn(e){this.Yt(e)}}const Lr="WebChannelConnection",op=(n,e,t)=>{n.listen(e,(s=>{try{t(s)}catch(r){setTimeout((()=>{throw r}),0)}}))};class Vh extends sG{constructor(e){super(e),this.nn=[],this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams,this.longPollingOptions=e.longPollingOptions}static rn(){if(!Vh.sn){const e=zk();op(e,Bk.STAT_EVENT,(t=>{t.stat===Rb.PROXY?Ze(Lr,"STAT_EVENT: detected buffering proxy"):t.stat===Rb.NOPROXY&&Ze(Lr,"STAT_EVENT: detected no buffering proxy")})),Vh.sn=!0}}qt(e,t,s,r,i){const a=Ub();return new Promise(((l,c)=>{const d=new Uk;d.setWithCredentials(!0),d.listenOnce(Vk.COMPLETE,(()=>{try{switch(d.getLastErrorCode()){case _0.NO_ERROR:const p=d.getResponseJson();Ze(Lr,`XHR for RPC '${e}' ${a} received:`,JSON.stringify(p)),l(p);break;case _0.TIMEOUT:Ze(Lr,`RPC '${e}' ${a} timed out`),c(new Xe(Ce.DEADLINE_EXCEEDED,"Request time out"));break;case _0.HTTP_ERROR:const m=d.getStatus();if(Ze(Lr,`RPC '${e}' ${a} failed with status:`,m,"response text:",d.getResponseText()),m>0){let y=d.getResponseJson();Array.isArray(y)&&(y=y[0]);const x=y?.error;if(x&&x.status&&x.message){const w=(function(_){const L=_.toLowerCase().replace(/_/g,"-");return Object.values(Ce).indexOf(L)>=0?L:Ce.UNKNOWN})(x.status);c(new Xe(w,x.message))}else c(new Xe(Ce.UNKNOWN,"Server responded with status "+d.getStatus()))}else c(new Xe(Ce.UNAVAILABLE,"Connection failed."));break;default:_t(9055,{_n:e,streamId:a,an:d.getLastErrorCode(),un:d.getLastError()})}}finally{Ze(Lr,`RPC '${e}' ${a} completed.`)}}));const h=JSON.stringify(r);Ze(Lr,`RPC '${e}' ${a} sending request:`,r),d.send(t,"POST",h,s,15)}))}cn(e,t,s){const r=Ub(),i=[this.Mt,"/","google.firestore.v1.Firestore","/",e,"/channel"],a=this.createWebChannelTransport(),l={httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:`projects/${this.databaseId.projectId}/databases/${this.databaseId.database}`},sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling,detectBufferingProxy:this.autoDetectLongPolling},c=this.longPollingOptions.timeoutSeconds;c!==void 0&&(l.longPollingTimeout=Math.round(1e3*c)),this.useFetchStreams&&(l.useFetchStreams=!0),this.kt(l.initMessageHeaders,t,s),l.encodeInitMessageHeaders=!0;const d=i.join("");Ze(Lr,`Creating RPC '${e}' stream ${r}: ${d}`,l);const h=a.createWebChannel(d,l);this.En(h);let p=!1,m=!1;const y=new rG({Kt:x=>{m?Ze(Lr,`Not sending because RPC '${e}' stream ${r} is closed:`,x):(p||(Ze(Lr,`Opening RPC '${e}' stream ${r} transport.`),h.open(),p=!0),Ze(Lr,`RPC '${e}' stream ${r} sending:`,x),h.send(x))},Wt:()=>h.close()});return op(h,xp.EventType.OPEN,(()=>{m||(Ze(Lr,`RPC '${e}' stream ${r} transport opened.`),y.Zt())})),op(h,xp.EventType.CLOSE,(()=>{m||(m=!0,Ze(Lr,`RPC '${e}' stream ${r} transport closed`),y.en(),this.hn(h))}
34)),op(h,xp.EventType.ERROR,(x=>{m||(m=!0,fo(Lr,`RPC '${e}' stream ${r} transport errored. Name:`,x.name,"Message:",x.message),y.en(new Xe(Ce.UNAVAILABLE,"The operation could not be completed")))})),op(h,xp.EventType.MESSAGE,(x=>{if(!m){const w=x.data[0];yt(!!w,16349);const S=w,_=S?.error||S[0]?.error;if(_){Ze(Lr,`RPC '${e}' stream ${r} received error:`,_);const L=_.status;let R=(function(W){const I=ks[W];if(I!==void 0)return bR(I)})(L),M=_.message;L==="NOT_FOUND"&&M.includes("database")&&M.includes("does not exist")&&M.includes(this.databaseId.database)&&fo(`Database '${this.databaseId.database}' not found. Please check your project configuration.`),R===void 0&&(R=Ce.INTERNAL,M="Unknown error status: "+L+" with message "+_.message),m=!0,y.en(new Xe(R,M)),h.close()}else Ze(Lr,`RPC '${e}' stream ${r} received:`,w),y.tn(w)}})),Vh.rn(),setTimeout((()=>{y.Xt()}),0),y}terminate(){this.nn.forEach((e=>e.close())),this.nn=[]}En(e){this.nn.push(e)}hn(e){this.nn=this.nn.filter((t=>t===e))}kt(e,t,s){super.kt(e,t,s),this.databaseInfo.apiKey&&(e["x-goog-api-key"]=this.databaseInfo.apiKey)}createWebChannelTransport(){return $k()}}function iG(n){return new Vh(n)}Vh.sn=!1;class OR{constructor(e,t,s=1e3,r=1.5,i=6e4){this.Tn=e,this.timerId=t,this.Pn=s,this.Rn=r,this.In=i,this.An=0,this.Vn=null,this.dn=Date.now(),this.reset()}reset(){this.An=0}fn(){this.An=this.In}mn(e){this.cancel();const t=Math.floor(this.An+this.pn()),s=Math.max(0,Date.now()-this.dn),r=Math.max(0,t-s);r>0&&Ze("ExponentialBackoff",`Backing off for ${r} ms (base delay: ${this.An} ms, delay with jitter: ${t} ms, last attempt: ${s} ms ago)`),this.Vn=this.Tn.enqueueAfterDelay(this.timerId,r,(()=>(this.dn=Date.now(),e()))),this.An*=this.Rn,this.An<this.Pn&&(this.An=this.Pn),this.An>this.In&&(this.An=this.In)}gn(){this.Vn!==null&&(this.Vn.skipDelay(),this.Vn=null)}cancel(){this.Vn!==null&&(this.Vn.cancel(),this.Vn=null)}pn(){return(Math.random()-.5)*this.An}}const c5="PersistentStream";class MR{constructor(e,t,s,r,i,a,l,c){this.Tn=e,this.yn=s,this.wn=r,this.connection=i,this.authCredentialsProvider=a,this.appCheckCredentialsProvider=l,this.listener=c,this.state=0,this.bn=0,this.vn=null,this.Sn=null,this.stream=null,this.Dn=0,this.xn=new OR(e,t)}Cn(){return this.state===1||this.state===5||this.Fn()}Fn(){return this.state===2||this.state===3}start(){this.Dn=0,this.state!==4?this.auth():this.On()}async stop(){this.Cn()&&await this.close(0)}Mn(){this.state=0,this.xn.reset()}Nn(){this.Fn()&&this.vn===null&&(this.vn=this.Tn.enqueueAfterDelay(this.yn,6e4,(()=>this.Ln())))}Bn(e){this.Un(),this.stream.send(e)}async Ln(){if(this.Fn())return this.close(0)}Un(){this.vn&&(this.vn.cancel(),this.vn=null)}kn(){this.Sn&&(this.Sn.cancel(),this.Sn=null)}async close(e,t){this.Un(),this.kn(),this.xn.cancel(),this.bn++,e!==4?this.xn.reset():t&&t.code===Ce.RESOURCE_EXHAUSTED?(Kl(t.toString()),Kl("Using maximum backoff delay to prevent overloading the backend."),this.xn.fn()):t&&t.code===Ce.UNAUTHENTICATED&&this.state!==3&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),this.stream!==null&&(this.qn(),this.stream.close(),this.stream=null),this.state=e,await this.listener.Ht(t)}qn(){}auth(){this.state=1;const e=this.$n(this.bn),t=this.bn;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then((([s,r])=>{this.bn===t&&this.Kn(s,r)}),(s=>{e((()=>{const r=new Xe(Ce.UNKNOWN,"Fetching auth token failed: "+s.message);return this.Wn(r)}))}))}Kn(e,t){const s=this.$n(this.bn);this.stream=this.Qn(e,t),this.stream.Qt((()=>{s((()=>this.listener.Qt()))})),this.stream.zt((()=>{s((()=>(this.state=2,this.Sn=this.Tn.enqueueAfterDelay(this.wn,1e4,(()=>(this.Fn()&&(this.state=3),Promise.resolve()))),this.listener.zt())))})),this.stream.Ht((r=>{s((()=>this.Wn(r)))})),this.stream.onMessage((r=>{s((()=>++this.Dn==1?this.Gn(r):this.onNext(r)))}))}On(){this.state=5,this.xn.mn((async()=>{this.state=0,this.start()}))}Wn(e){return Ze(c5,`close with error: ${e}`),this.stream=null,this.close(4,e)}$n(e){return t=>{this.Tn.enqueueAndForget((()=>this.bn===e?t():(Ze(c5,"stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())))}}}class aG extends MR{constructor(e,t,s,r,i,a){super(e,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",t,s,r,a),this.serializer
34=i}Qn(e,t){return this.connection.cn("Listen",e,t)}Gn(e){return this.onNext(e)}onNext(e){this.xn.reset();const t=zW(this.serializer,e),s=(function(i){if(!("targetChange"in i))return Vt.min();const a=i.targetChange;return a.targetIds&&a.targetIds.length?Vt.min():a.readTime?Wo(a.readTime):Vt.min()})(e);return this.listener.zn(t,s)}jn(e){const t={};t.database=Fb(this.serializer),t.addTarget=(function(i,a){let l;const c=a.target;if(l=Qu(c)?{pipelineQuery:YW(i,c)}:yR(c)?{documents:WW(i,c)}:{query:GW(i,c).yt},l.targetId=a.targetId,a.resumeToken.approximateByteSize()>0){l.resumeToken=IR(i,a.resumeToken);const d=Ob(i,a.expectedCount);d!==null&&(l.expectedCount=d)}else if(a.snapshotVersion.compareTo(Vt.min())>0){l.readTime=x1(i,a.snapshotVersion.toTimestamp());const d=Ob(i,a.expectedCount);d!==null&&(l.expectedCount=d)}return l})(this.serializer,e);const s=qW(this.serializer,e);s&&(t.labels=s),this.Bn(t)}Hn(e){const t={};t.database=Fb(this.serializer),t.removeTarget=e,this.Bn(t)}}class oG extends MR{constructor(e,t,s,r,i,a){super(e,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",t,s,r,a),this.serializer=i}get Jn(){return this.Dn>0}start(){this.lastStreamToken=void 0,super.start()}qn(){this.Jn&&this.Yn([])}Qn(e,t){return this.connection.cn("Write",e,t)}Gn(e){return yt(!!e.streamToken,31322),this.lastStreamToken=e.streamToken,yt(!e.writeResults||e.writeResults.length===0,55816),this.listener.Zn()}onNext(e){yt(!!e.streamToken,12678),this.lastStreamToken=e.streamToken,this.xn.reset();const t=HW(e.writeResults,e.commitTime),s=Wo(e.commitTime);return this.listener.Xn(s,t)}er(){const e={};e.database=Fb(this.serializer),this.Bn(e)}Yn(e){const t={streamToken:this.lastStreamToken,writes:e.map((s=>$W(this.serializer,s)))};this.Bn(t)}}class lG{}class cG extends lG{constructor(e,t,s,r){super(),this.authCredentials=e,this.appCheckCredentials=t,this.connection=s,this.serializer=r,this.tr=!1}nr(){if(this.tr)throw new Xe(Ce.FAILED_PRECONDITION,"The client has already been terminated.")}Bt(e,t,s,r){return this.nr(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([i,a])=>this.connection.Bt(e,Mb(t,s),r,i,a))).catch((i=>{throw i.name==="FirebaseError"?(i.code===Ce.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),i):new Xe(Ce.UNKNOWN,i.toString())}))}$t(e,t,s,r,i){return this.nr(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([a,l])=>this.connection.$t(e,Mb(t,s),r,a,l,i))).catch((a=>{throw a.name==="FirebaseError"?(a.code===Ce.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),a):new Xe(Ce.UNKNOWN,a.toString())}))}terminate(){this.tr=!0,this.connection.terminate()}}function uG(n,e,t,s){return new cG(n,e,t,s)}const dG="ComponentProvider",u5=new Map;function hG(n,e,t,s,r){return new eW(n,e,t,r.host,r.ssl,r.experimentalForceLongPolling,r.experimentalAutoDetectLongPolling,jR(r.experimentalLongPollingOptions),r.useFetchStreams,r.isUsingEmulator,s)}const d5={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0},FR=41943040;class bi{static withCacheSize(e){return new bi(e,bi.DEFAULT_COLLECTION_PERCENTILE,bi.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}constructor(e,t,s){this.cacheSizeCollectionThreshold=e,this.percentileToCollect=t,this.maximumSequenceNumbersToCollect=s}}bi.DEFAULT_COLLECTION_PERCENTILE=10,bi.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,bi.DEFAULT=new bi(FR,bi.DEFAULT_COLLECTION_PERCENTILE,bi.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),bi.DISABLED=new bi(-1,0,0);const h5="LruGarbageCollector",fG=1048576;function f5([n,e],[t,s]){const r=sn(n,t);return r===0?sn(e,s):r}class pG{constructor(e){this.rr=e,this.buffer=new js(f5),this.ir=0}sr(){return++this.ir}_r(e){const t=[e,this.sr()];if(this.buffer.size<this.rr)this.buffer=this.buffer.add(t);else{const s=this.buffer.last();f5(t,s)<0&&(this.buffer=this.buffer.delete(s).add(t))}}get maxValue(){return this.buffer.last()[0]}}class mG{constructor(e,t,s){this.garbageCollector=e,this.asyncQueue=t,this.localStore=s,this.ar=null}start(){this.garbageCollector.params.cacheSizeCollectionThreshold!==-1&&this.ur(6e4)}stop(){this.ar&&(this.ar.cancel(),this.ar=null)}get started(){return this.ar!==null}ur(e){Ze(h5,`Garbage collection scheduled in ${e}ms`),this.ar=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",e,(async()=>{this.ar=null;try{await this.localStore.collectGarbage(this.garbageCollector)}catch(t){Sf(t)?Ze(h5,"Ignoring IndexedDB error during garbage collection: ",t):await wf(t)}await this.ur(3e5)}))}}class gG{constructor(e,t){this.cr=e,this.params=t}calculateTargetCount(e,t){return this.cr.lr(e).next((s=>Math.floor(t/100*s)))}nthSequenceNumber(e,t){if(t===0)return Pe.resolve(Ex.ce);const s=new pG(t);return this.cr.forEachTarget(e,(r=>s._r(r.sequenceNumber))).next((()=>this.cr.Er(e,(r=>s._r(r))))).next((()=>s.maxValue))}removeTargets(e,t,s){return this.cr.removeTargets(e,t,s)}removeOrphanedDocuments(e,t){return this.cr.removeOrphanedDocuments(e,t)}collect(e,t){return this.params.cacheSizeCollectionThreshold===-1?(Ze("LruGarbageCollector","Garbage collection skipped; disabled"),Pe.resolve(d5)):this.getCacheSize(e).next((s=>s<this.params.cacheSizeCollectionThreshold?(Ze("LruGarbageCollector",`Garbage collection skipped; Cache size ${s} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),d5):this.hr(e,t)))}getCacheSize(e){return this.cr.getCacheSize(e)}hr(e,t){let s,r,i,a,l,c,d;const h=Date.now();return this.calculateTargetCount(e,this.params.percentileToCollect).next((p=>(p>this.params.maximumSequenceNumbersToCollect?(Ze("LruGarbageCollector",`C
34apping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${p}`),r=this.params.maximumSequenceNumbersToCollect):r=p,a=Date.now(),this.nthSequenceNumber(e,r)))).next((p=>(s=p,l=Date.now(),this.removeTargets(e,s,t)))).next((p=>(i=p,c=Date.now(),this.removeOrphanedDocuments(e,s)))).next((p=>(d=Date.now(),vh()<=on.DEBUG&&Ze("LruGarbageCollector",`LRU Garbage Collection 35 Counted targets in ${a-h}ms 36 Determined least recently used ${r} in `+(l-a)+`ms 37 Removed ${i} targets in `+(c-l)+`ms 38 Removed ${p} documents in `+(d-c)+`ms 39Total Duration: ${d-h}ms`),Pe.resolve({didRun:!0,sequenceNumbersCollected:r,targetsRemoved:i,documentsRemoved:p}))))}}function xG(n,e){return new gG(n,e)}const UR="firestore.googleapis.com",p5=!0;class m5{constructor(e){if(e.host===void 0){if(e.ssl!==void 0)throw new Xe(Ce.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host=UR,this.ssl=p5}else this.host=e.host,this.ssl=e.ssl??p5;if(this.isUsingEmulator=e.emulatorOptions!==void 0,this.credentials=e.credentials,this.ignoreUndefinedProperties=!!e.ignoreUndefinedProperties,this.localCache=e.localCache,e.cacheSizeBytes===void 0)this.cacheSizeBytes=FR;else{if(e.cacheSizeBytes!==-1&&e.cacheSizeBytes<fG)throw new Xe(Ce.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}VH("experimentalForceLongPolling",e.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",e.experimentalAutoDetectLongPolling),this.experimentalForceLongPolling=!!e.experimentalForceLongPolling,this.experimentalForceLongPolling?this.experimentalAutoDetectLongPolling=!1:e.experimentalAutoDetectLongPolling===void 0?this.experimentalAutoDetectLongPolling=!0:this.experimentalAutoDetectLongPolling=!!e.experimentalAutoDetectLongPolling,this.experimentalLongPollingOptions=jR(e.experimentalLongPollingOptions??{}),(function(s){if(s.timeoutSeconds!==void 0){if(isNaN(s.timeoutSeconds))throw new Xe(Ce.INVALID_ARGUMENT,`invalid long polling timeout: ${s.timeoutSeconds} (must not be NaN)`);if(s.timeoutSeconds<5)throw new Xe(Ce.INVALID_ARGUMENT,`invalid long polling timeout: ${s.timeoutSeconds} (minimum allowed value is 5)`);if(s.timeoutSeconds>30)throw new Xe(Ce.INVALID_ARGUMENT,`invalid long polling timeout: ${s.timeoutSeconds} (maximum allowed value is 30)`)}})(this.experimentalLongPollingOptions),this.useFetchStreams=!!e.useFetchStreams}isEqual(e){return this.host===e.host&&this.ssl===e.ssl&&this.credentials===e.credentials&&this.cacheSizeBytes===e.cacheSizeBytes&&this.experimentalForceLongPolling===e.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===e.experimentalAutoDetectLongPolling&&(function(s,r){return s.timeoutSeconds===r.timeoutSeconds})(this.experimentalLongPollingOptions,e.experimentalLongPollingOptions)&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams}}class jx{constructor(e,t,s,r){this._authCredentials=e,this._appCheckCredentials=t,this._databaseId=s,this._app=r,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new m5({}),this._settingsFrozen=!1,this._emulatorOptions={},this._terminateTask="notTerminated"}get app(){if(!this._app)throw new Xe(Ce.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._app}get _initialized(){return this._settingsFrozen}get _terminated(){return this._terminateTask!=="notTerminated"}_setSettings(e){if(this._settingsFrozen)throw new Xe(Ce.FAILED_PRECONDITION,"Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.");this._settings=new m5(e),this._emulatorOptions=e.emulatorOptions||{},e.credentials!==void 0&&(this._authCredentials=(function(s){if(!s)return new RH;switch(s.type){case"firstParty":return new DH(s.sessionIndex||"0",s.iamToken||null,s.authTokenFactory||null);case"provider":return s.client;default:throw new Xe(Ce.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invali
39d credential type")}})(e.credentials))}_getSettings(){return this._settings}_getEmulatorOptions(){return this._emulatorOptions}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return this._terminateTask==="notTerminated"&&(this._terminateTask=this._terminate()),this._terminateTask}async _restart(){this._terminateTask==="notTerminated"?await this._terminate():this._terminateTask="notTerminated"}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return(function(t){const s=u5.get(t);s&&(Ze(dG,"Removing Datastore"),u5.delete(t),s.terminate())})(this),Promise.resolve()}}function yG(n,e,t,s={}){n=Ii(n,jx);const r=Cd(e),i=n._getSettings(),a={...i,emulatorOptions:n._getEmulatorOptions()},l=`${e}:${t}`;r&&c4(`https://${l}`),i.host!==UR&&i.host!==l&&fo("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used.");const c={...i,host:l,ssl:r,emulatorOptions:s};if(!qo(c,a)&&(n._setSettings(c),s.mockUserToken)){let d,h;if(typeof s.mockUserToken=="string")d=s.mockUserToken,h=jr.MOCK_USER;else{d=gC(s.mockUserToken,n._app?.options.projectId);const p=s.mockUserToken.sub||s.mockUserToken.user_id;if(!p)throw new Xe(Ce.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");h=new jr(p)}n._authCredentials=new PH(new Gk(d,h))}}class ec{constructor(e,t,s){this.converter=t,this._query=s,this.type="query",this.firestore=e}withConverter(e){return new ec(this.firestore,e,this._query)}}class as{constructor(e,t,s){this.converter=t,this._key=s,this.type="document",this.firestore=e}get _path(){return this._key.path}get id(){return this._key.path.lastSegment()}get path(){return this._key.path.canonicalString()}get parent(){return new Kc(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new as(this.firestore,e,this._key)}toJSON(){return{type:as._jsonSchemaVersion,referencePath:this._key.toString()}}static fromJSON(e,t,s){if(Nm(t,as._jsonSchema))return new as(e,s||null,new bt(bn.fromString(t.referencePath)))}}as._jsonSchemaVersion="firestore/documentReference/1.0",as._jsonSchema={type:Ls("string",as._jsonSchemaVersion),referencePath:Ls("string")};class Kc extends ec{constructor(e,t,s){super(e,t,Px(s)),this._path=s,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){const e=this._path.popLast();return e.isEmpty()?null:new as(this.firestore,null,new bt(e))}withConverter(e){return new Kc(this.firestore,e,this._path)}}function Ni(n,e,...t){if(n=wt(n),Kk("collection","path",e),n instanceof jx){const s=bn.fromString(e,...t);return V8(s),new Kc(n,null,s)}{if(!(n instanceof as||n instanceof Kc))throw new Xe(Ce.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const s=n._path.child(bn.fromString(e,...t));return V8(s),new Kc(n.firestore,null,s)}}function Gt(n,e,...t){if(n=wt(n),arguments.length===1&&(e=L4.newId()),Kk("doc","path",e),n instanceof jx){const s=bn.fromString(e,...t);return U8(s),new as(n,null,new bt(s))}{if(!(n instanceof as||n instanceof Kc))throw new Xe(Ce.INVALID_ARGUMENT,"Expected first argument to doc() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const s=n._path.child(bn.fromString(e,...t));return U8(s),new as(n.firestore,n instanceof Kc?n.converter:null,new bt(s))}}class Ai{constructor(e){this._values=(e||[]).map((t=>t))}toArray(){return this._values.map((e=>e))}isEqual(e){return(function(s,r){if(s.length!==r.length)return!1;for(let i=0;i<s.length;++i)if(s[i]!==r[i])return!1;return!0})(this._values,e._values)}toJSON(){return{type:Ai._jsonSchemaVersion,vectorValues:this._values}}static fromJSON(e){if(Nm(e,Ai._jsonSchema)){if(Array.isArray(e.vectorValues)&&e.vectorValues.every((t=>typeof t=="number")))return new Ai(e.vectorValues);throw new Xe(Ce.INVALID_ARGUMENT,"Expected 'vectorValues' field to be a number array")}}}Ai._jsonSchemaVersion="firestore/vectorValue/1.0",Ai._jsonSchema={type:Ls("string",Ai._jsonSchemaVersion),vectorValues:Ls("object")};const vG=/^__.*__$/;class bG{constructor(e,t,s){this.data=e,this.fieldMask=t,this.fieldTransforms=s}toMutation(e,t){return this.fieldMask!==null?new yu(e,this.data,this.fieldMask,t,this.fieldTransforms):new Dm(e,this.data,t,this.fieldTransforms)}}class VR{constructor(e,t,s){this.data=e,this.fieldMask=t,this.fieldTransforms=s}toMutation(e,t){return new yu(e,this.data,this.fieldMask,t,this.fieldTransforms)}}function BR(n){switch(n){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw _t(40011,{dataSource:n})}}class Ox{constructor(e,t,s,r,i,a){this.settings=e,this.databaseId=t,this.serializer
vendor: 4,722 bytes, line 39
39=s,this.ignoreUndefinedProperties=r,i===void 0&&this.validatePath(),this.fieldTransforms=i||[],this.fieldMask=a||[]}get path(){return this.settings.path}get dataSource(){return this.settings.dataSource}contextWith(e){return new Ox({...this.settings,...e},this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}childContextForField(e){const t=this.path?.child(e),s=this.contextWith({path:t,arrayElement:!1});return s.validatePathSegment(e),s}childContextForFieldPath(e){const t=this.path?.child(e),s=this.contextWith({path:t,arrayElement:!1});return s.validatePath(),s}childContextForArray(e){return this.contextWith({path:void 0,arrayElement:!0})}createError(e){return v1(e,this.settings.methodName,this.settings.hasConverter||!1,this.path,this.settings.targetDoc)}contains(e){return this.fieldMask.find((t=>e.isPrefixOf(t)))!==void 0||this.fieldTransforms.find((t=>e.isPrefixOf(t.field)))!==void 0}validatePath(){if(this.path)for(let e=0;e<this.path.length;e++)this.validatePathSegment(this.path.get(e))}validatePathSegment(e){if(e.length===0)throw this.createError("Document fields must not be empty");if(BR(this.dataSource)&&vG.test(e))throw this.createError('Document fields cannot begin and end with "__"')}}class wG{constructor(e,t,s){this.databaseId=e,this.ignoreUndefinedProperties=t,this.serializer=s||Lx(e)}createContext(e,t,s,r=!1){return new Ox({dataSource:e,methodName:t,targetDoc:s,path:qs.emptyPath(),arrayElement:!1,hasConverter:r},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}}function Mx(n){const e=n._freezeSettings(),t=Lx(n._databaseId);return new wG(n._databaseId,!!e.ignoreUndefinedProperties,t)}function zR(n,e,t,s,r,i={}){const a=n.createContext(i.merge||i.mergeFields?2:0,e,t,r);G4("Data must be an object, but it was:",a,s);const l=HR(s,a);let c,d;if(i.merge)c=new Ji(a.fieldMask),d=a.fieldTransforms;else if(i.mergeFields){const h=[];for(const p of i.mergeFields){const m=su(e,p,t);if(!a.contains(m))throw new Xe(Ce.INVALID_ARGUMENT,`Field '${m}' is specified in your field mask but missing from your input data.`);KR(h,m)||h.push(m)}c=new Ji(h),d=a.fieldTransforms.filter((p=>c.covers(p.field)))}else c=null,d=a.fieldTransforms;return new bG(new Jr(l),c,d)}class Fx extends Ld{_toFieldTransform(e){if(e.dataSource!==2)throw e.dataSource===1?e.createError(`${this._methodName}() can only appear at the top level of your update data`):e.createError(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return e.fieldMask.push(e.path),null}isEqual(e){return e instanceof Fx}}function $R(n,e,t){return new Ox({dataSource:3,targetDoc:e.settings.targetDoc,methodName:n._methodName,arrayElement:t},e.databaseId,e.serializer,e.ignoreUndefinedProperties)}class z4 extends Ld{_toFieldTransform(e){return new kx(e.path,new im)}isEqual(e){return e instanceof z4}}class $4 extends Ld{constructor(e,t){super(e),this.Tr=t}_toFieldTransform(e){const t=$R(this,e,!0),s=this.Tr.map((i=>Qo(i,t))),r=new Zh(s);return new kx(e.path,r)}isEqual(e){return e instanceof $4&&qo(this.Tr,e.Tr)}}class H4 extends Ld{constructor(e,t){super(e),this.Tr=t}_toFieldTransform(e){const t=$R(this,e,!0),s=this.Tr.map((i=>Qo(i,t))),r=new ef(s);return new kx(e.path,r)}isEqual(e){return e instanceof H4&&qo(this.Tr,e.Tr)}}class W4 extends Ld{constructor(e,t){super(e),this.Pr=t}_toFieldTransform(e){const t=new tf(e.serializer,Ax(e.serializer,this.Pr));return new kx(e.path,t)}isEqual(e){return e instanceof W4&&(this.Pr===e.Pr||Number.isNaN(this.Pr)&&Number.isNaN(e.Pr))}}function SG(n,e,t,s){const r=n.createContext(1,e,t);G4("Data must be an object, but it was:",r,s);const i=[],a=Jr.empty();xu(s,((c,d)=>{const h=GR(e,c,t);d=wt(d);const p=r.childContextForFieldPath(h);if(d instanceof Fx)i.push(h);else{const m=Qo(d,p);m!=null&&(i.push(h),a.set(h,m))}}));const l=new Ji(i);return new VR(a,l,r.fieldTransforms)}function EG(n,e,t,s,r,i){const a=n.createContext(1,e,t),l=[su(e,s,t)],c=[r];if(i.length%2!=0)throw new Xe(Ce.INVALID_ARGUMENT,`Function ${e}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let m=0;m<i.length;m+=2)l.push(su(e,i[m])),c.push(i[m+1]);const d=[],h=Jr.empty();for(let m=l.length-1;m>=0;--m)if(!KR(d,l[m])){const y=l[m];let x=c[m];x=wt(x);const w=a.childContextForFieldPath(y);if(x instanceof Fx)d.push(y);else{const S=Qo(x,w);S!=null&&(d.push(y),h.set(y,S))}}const p=new Ji(d);return new VR(h,p,a.fieldTransforms)}function TG(n,e,t,s=!1){return Qo(t,n.createContext(s?4:3,e))}function Qo(n,e,t){if(WR(n=wt(n)))return G4("Unsupported field value:",e,n),HR(n,e);if(n instanceof Ld)return(function(r,i){if(!BR(i.dataSource))throw i.createError(`${r._methodName}
39() can only be used with update() and set()`);if(!i.path)throw i.createError(`${r._methodName}() is not currently supported inside arrays`);const a=r._toFieldTransform(i);a&&i.fieldTransforms.push(a)})(n,e),null;if(n===void 0&&e.ignoreUndefinedProperties)return null;if(e.path&&e.fieldMask.push(e.path),n instanceof Array){if(e.settings.arrayElement&&e.dataSource!==4)throw e.createError("Nested arrays are not supported");return(function(r,i){const a=[];let l=0;for(const c of r){let d=Qo(c,i.childContextForArray(l));d==null&&(d={nullValue:"NULL_VALUE"}),a.push(d),l++}return{arrayValue:{values:a}}})(n,e)}return(function(r,i,a){if((r=wt(r))===null)return{nullValue:"NULL_VALUE"};if(typeof r=="number")return Ax(i.serializer,r,a);if(typeof r=="boolean")return{booleanValue:r};if(typeof r=="string")return{stringValue:r};if(r instanceof Date){const l=$n.fromDate(r);return{timestampValue:x1(i.serializer,l)}}if(r instanceof $n){const l=new $n(r.seconds,1e3*Math.floor(r.nanoseconds/1e3));return{timestampValue:x1(i.serializer,l)}}if(r instanceof Go)return{geoPointValue:{latitude:r.latitude,longitude:r.longitude}};if(r instanceof wa)return{bytesValue:IR(i.serializer,r._byteString)};if(r instanceof as){const l=i.databaseId,c=r.firestore._databaseId;if(!c.isEqual(l))throw i.createError(`Document reference is for database ${c.projectId}/${c.database} but should be for database ${l.projectId}/${l.database}`);return{referenceValue:B4(r.firestore._databaseId||i.databaseId,r._key.path)}}if(r instanceof Ai)return(function(c,d){const h=c instanceof Ai?c.toArray():c;return{mapValue:{fields:{[tR]:{stringValue:nR},[sm]:{arrayValue:{values:h.map((m=>{if(typeof m!="number")throw d.createError("VectorValues must only contain numeric values.");return Ix(d.serializer,m)}))}}}}}})(r,i);if(LR(r))return r._toProto(i.serializer);throw i.createError(`Unsupported field value: ${Sx(r)}`)})(n,e,t)}function HR(n,e){const t={};return Yk(n)?e.path&&e.path.length>0&&e.fieldMask.push(e.path):xu(n,((s,r)=>{const i=Qo(r,e.childContextForField(s));i!=null&&(t[s]=i)})),{mapValue:{fields:t}}}function WR(n){return!(typeof n!="object"||n===null||n instanceof Array||n instanceof Date||n instanceof $n||n instanceof Go||n instanceof wa||n instanceof as||n instanceof Ld||n instanceof Ai||LR(n))}function G4(n,e,t){if(!WR(t)||!Pm(t)){const s=Sx(t);throw s==="an object"?e.createError(n+" a custom object"):e.createError(n+" "+s)}}function su(n,e,t){if((e=wt(e))instanceof Dx)return e._internalPath;if(typeof e=="string")return GR(n,e);throw v1("Field path arguments must be of type string or ",n,!1,void 0,t)}const _G=new RegExp("[~\\*/\\[\\]]");function GR(n,e,t){if(e.search(_G)>=0)throw v1(`Invalid field path (${e}). Paths must not contain '~', '*', '/', '[', or ']'`,n,!1,void 0,t);try{return new Dx(...e.split("."))._internalPath}catch{throw v1(`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,n,!1,void 0,t)}}function v1(n,e,t,s,r){const i=s&&!s.isEmpty(),a=r!==void 0;let l=`Function ${e}() called with invalid data`;t&&(l+=" (via `toFirestore()`)"),l+=". ";let c="";return(i||a)&&(c+=" (found",i&&(c+=` in field ${s}`),a&&(c+=` in document ${r}`),c+=")"),new Xe(Ce.INVALID_ARGUMENT,l+n+c)}function KR(n,e){return n.some((t=>t.isEqual(e)))}function qR(n){return typeof n._readUserData=="function"}class Vr{constructor(e){this.optionDefinitions=e}_getKnownOptions(e,t){const s=Jr.empty();for(const r in this.optionDefinitions)if(this.optionDefinitions.hasOwnProperty(r)){const i=this.optionDefinitions[r];if(r in e){const a=e[r];let l;i.nestedOptions&&Pm(a)?l={mapValue:{fields:new Vr(i.nestedOptions).getOptionsProto(t,a)}}:a&&(l=Qo(a,t)??void 0),l&&s.set(qs.fromServerFormat(i.serverName),l)}}return s}getOptionsProto(e,t,s){const r=this._getKnownOptions(t,e);if(s){const i=new Map(JH(s,((a,l)=>[qs.fromServerFormat(l),a!==void 0?Qo(a,e):null])));r.setAll(i)}return r.value.mapValue.fields??{}}}function IG(n){return typeof n=="object"&&n!==null&&!!("nullValue"in n&&(n.nullValue===null||n.nullValue==="NULL_VALUE")||"booleanValue"in n&&(n.booleanValue===null||typeof n.booleanValue=="boolean")||"integerValue"in n&&(n.integerValue===null||typeof n.integerValue=="number"||typeof n.integerValue=="string")||"doubleValue"in n&&(n.doubleValue===null||typeof n.doubleValue=="number")||"timestampValue"in n&&(n.timestampValue===null||(function(t){return typeof t=="object"&&t!==null&&"seconds"in t&&(t.seconds===null||typeof t.seconds=="number"||typeof t.seconds=="str
39ing")&&"nanos"in t&&(t.nanos===null||typeof t.nanos=="number")})(n.timestampValue))||"stringValue"in n&&(n.stringValue===null||typeof n.stringValue=="string")||"bytesValue"in n&&(n.bytesValue===null||n.bytesValue instanceof Uint8Array)||"referenceValue"in n&&(n.referenceValue===null||typeof n.referenceValue=="string")||"geoPointValue"in n&&(n.geoPointValue===null||(function(t){return typeof t=="object"&&t!==null&&"latitude"in t&&(t.latitude===null||typeof t.latitude=="number")&&"longitude"in t&&(t.longitude===null||typeof t.longitude=="number")})(n.geoPointValue))||"arrayValue"in n&&(n.arrayValue===null||(function(t){return typeof t=="object"&&t!==null&&!(!("values"in t)||t.values!==null&&!Array.isArray(t.values))})(n.arrayValue))||"mapValue"in n&&(n.mapValue===null||(function(t){return typeof t=="object"&&t!==null&&!(!("fields"in t)||t.fields!==null&&!Pm(t.fields))})(n.mapValue))||"fieldReferenceValue"in n&&(n.fieldReferenceValue===null||typeof n.fieldReferenceValue=="string")||"functionValue"in n&&(n.functionValue===null||(function(t){return typeof t=="object"&&t!==null&&!(!("name"in t)||t.name!==null&&typeof t.name!="string"||!("args"in t)||t.args!==null&&!Array.isArray(t.args))})(n.functionValue))||"pipelineValue"in n&&(n.pipelineValue===null||(function(t){return typeof t=="object"&&t!==null&&!(!("stages"in t)||t.stages!==null&&!Array.isArray(t.stages))})(n.pipelineValue)))}function Ds(){return new z4("serverTimestamp")}function YR(...n){return new $4("arrayUnion",n)}function AG(...n){return new H4("arrayRemove",n)}function QR(n){return new W4("increment",n)}function CG(n){return new Ai(n)}function qe(n){let e;return n instanceof Dd?n:(e=Pm(n)?LG(n):n instanceof Array?DG(n):XR(n,void 0),e)}function rv(n){if(n instanceof Dd)return n;if(n instanceof Ai)return lm(n);if(Array.isArray(n))return lm(CG(n));throw new Error("Unsupported value: "+typeof n)}function K4(n){return YH(n)?R0(n):qe(n)}class Dd{constructor(){this._protoValueType="ProtoValue"}add(e){return new Ie("add",[this,qe(e)],"add")}asBoolean(){if(this instanceof ru)return this;if(this instanceof _f)return new ZR(this);if(this instanceof Tf)return new NG(this);if(this instanceof Ie)return new JR(this);throw new Xe("invalid-argument",`Conversion of type ${typeof this} to BooleanExpression not supported.`)}subtract(e){return new Ie("subtract",[this,qe(e)],"subtract")}multiply(e){return new Ie("multiply",[this,qe(e)],"multiply")}divide(e){return new Ie("divide",[this,qe(e)],"divide")}mod(e){return new Ie("mod",[this,qe(e)],"mod")}equal(e){return new Ie("equal",[this,qe(e)],"equal").asBoolean()}notEqual(e){return new Ie("not_equal",[this,qe(e)],"notEqual").asBoolean()}lessThan(e){return new Ie("less_than",[this,qe(e)],"lessThan").asBoolean()}lessThanOrEqual(e){return new Ie("less_than_or_equal",[this,qe(e)],"lessThanOrEqual").asBoolean()}greaterThan(e){return new Ie("greater_than",[this,qe(e)],"greaterThan").asBoolean()}greaterThanOrEqual(e){return new Ie("greater_than_or_equal",[this,qe(e)],"greaterThanOrEqual").asBoolean()}arrayConcat(e,...t){const s=[e,...t].map((r=>qe(r)));return new Ie("array_concat",[this,...s],"arrayConcat")}arrayContains(e){return new Ie("array_contains",[this,qe(e)],"arrayContains").asBoolean()}arrayContainsAll(e){const t=Array.isArray(e)?new vp(e.map(qe),"arrayContainsAll"):e;return new Ie("array_contains_all",[this,t],"arrayContainsAll").asBoolean()}arrayContainsAny(e){const t=Array.isArray(e)?new vp(e.map(qe),"arrayContainsAny"):e;return new Ie("array_contains_any",[this,t],"arrayContainsAny").asBoolean()}arrayReverse(){return new Ie("array_reverse",[this])}arrayLength(){return new Ie("array_length",[this],"arrayLength")}equalAny(e){const t=Array.isArray(e)?new vp(e.map(qe),"equalAny"):e;return new Ie("equal_any",[this,t],"equalAny").asBoolean()}notEqualAny(e){const t=Array.isArray(e)?new vp(e.map(qe),"notEqualAny"):e;return new Ie("not_equal_any",[this,t],"notEqualAny").asBoolean()}exists(){return new Ie("exists",[this],"exists").asBoolean()}charLength(){return new Ie("char_length",[this],"charLength")}like(e){return new Ie("like",[this,qe(e)],"like").asBoolean()}regexContains(e){return new Ie("regex_contains",[this,qe(e)],"regexContains").asBoolean()}regexFind(e){return new Ie("regex_find",[this,qe(e)],"regexFind")}regexFindAll(e){return new Ie("regex_find_all",[this,qe(e)],"regexFindAll")}regexMatch(e){return new Ie("regex_match",[this,qe(e)],"regexMatch").asBoolean()}stringContains(e){return new Ie("string_contains",[this,qe(e)],"stringContains").asBoolean()}startsWith(e){return new Ie("starts_with",[this,qe(e)],"startsWith").asBoolean()}endsWith(e){return new Ie("ends_with",[this,qe(e)],"endsWith").asBoolean()}toLower(){return new Ie("to_lower",[this],"toLower")}toUpper(){return new Ie("to_upper",[this],"toUpper")}trim(e){const t=[this];return e&&t.push(qe(e)),new Ie("trim",t,"trim")}ltrim(e){const t=[this];return e&&t.push(qe(e)),new Ie("ltrim",t,"ltrim")}rtrim(e){const t=[this];return e&&t.push(qe(e)),new Ie("rtrim",t,"rtrim")}type(){return new Ie("type",[this])}isType(e){return new Ie("is_type",[this,lm(e)],"isType").asBoolean()}stringConcat(e,...t){const s=[e,...t].map(qe);return new Ie("string_concat",[this,...s],"stringConcat")}stringIndexOf(e){return new Ie("string_index_of",[this,qe(e)],"stringIndexOf")}stringRepeat(e){return new Ie("string_repeat",[this,qe(e)],"stringRepeat")}stringReplaceAll(e,t){return new Ie("string_replace_all",[this,qe(e),qe(t)],"stringReplaceAll")}stringReplaceOne(e,t){return new Ie("string_replace_one",[this,qe(e),qe(t)],"stringReplaceOne")}concat(e,...t){const s=[e,...t].map(qe);return new Ie("concat",[this,...s],"concat")}reverse(){return new Ie("reverse",[this],"reverse")}arrayFilter(e,t){return new Ie("array_filter",[this,qe(e),t],"arrayFilter")}arrayTransform(e,t){return new Ie("array_transform",[this,qe(e),t],"arrayTransform")}arrayTransformWithIndex(e,t,s){return new Ie("array_transform",[this,qe(e),qe(t),s],"arrayTransformWithIndex")}arraySlice(e,t){const s=[this,qe(e)];return t!==void 0&&s.push(qe(t)),new Ie("array_slice",s,"arraySlice")}arrayFirst(){return new Ie("array_first",[this],"arrayFirst")}arrayFirstN(e){return new Ie("array_first_n",[this,qe(e)],"arrayFirstN")}arrayLast(){return new Ie("array_last",[this],"arrayLast")}arrayLastN(e){return new Ie("array_last_n",[this,qe(e)],"arrayLastN")}arrayMaximum(){return new Ie("maximum",[this],"arrayMaximum")}arrayMaximumN(e){return new Ie("maximum_n",[this,qe(e)],"arrayMaximumN")}arrayMinimum(){return new Ie("minimum",[this],"arrayMinimum")}arrayMinimumN(e){return new Ie("minimum_n",[this,qe(e)],"arrayMinimumN")}arrayIndexOf(e){return new Ie("array_index_of",[this,qe(e),qe("first")],"arrayIndexOf")}arrayLastIndexOf(e){return new Ie("array_index_of",[this,qe(e),qe("last")],"arrayLastIndexOf")}arrayIndexOfAll(e){return new Ie("array_index_of_all",[this,qe(e)],"arrayIndexOfAll")}byteLength(){return new Ie("byte_length",[this],"byteLength")}ceil(){return new Ie("ceil",[this])}floor(){return new Ie("floor",[this])}abs(){return new Ie("abs",[this])}exp(){return new Ie("exp",[this])}mapGet(e){return new Ie("map_get",[this,lm(e)],"mapGet")}mapSet(e,t,...s){const r=[this,qe(e),qe(t),...s.map(qe)];return new Ie("map_set",r,"mapSet")}mapKeys(){return new Ie("map_keys",[this],"mapKeys")}mapValues(){return new Ie("map_values",[this],"mapValues")}mapEntries(){return new Ie("map_entries",[this],"mapEntries")}getField(e){return new Ie("get_field",[this,qe(e)],"get_field")}count(){return Yi._create("count",[this],"count")}sum(){return Yi._create("sum",[this],"sum")}average(){return Yi._create("average",[this],"average")}minimum(){return Yi._create("minimum",[this],"minimum")}maximum(){return Yi._create("maximum",[this],"maximum")}first(){return Yi._create("first",[this],"first")}last(){return Yi._create("last",[this],"last")}arrayAgg(){return Yi._create("array_agg",[this],"arrayAgg")}arrayAggDistinct(){return Yi._create("array_agg_distinct",[this],"arrayAggDistinct")}countDistinct(){return Yi._create("count_distinct",[this],"countDistinct")}logicalMaximum(e,...t){const s=[e,...t];return new Ie("maximum",[this,...s.map(qe)],"logicalMaximum")}logicalMinimum(e,...t){const s=[e,...t];return new Ie("minimum",[this,...s.map(qe)],"minimum")}vectorLength(){return new Ie("vector_length",[this],"vectorLength")}cosineDistance(e){return new Ie("cosine_distance",[this,rv(e)],"cosineDistance")}dotProduct(e){return new Ie("dot_product",[this,rv(e)],"dotProduct")}euclideanDistance(e){return new Ie("euclidean_distance",[this,rv(e)],"euclideanDistance")}unixMicrosToTimestamp(){return new Ie("unix_micros_to_timestamp",[this],"unixMicrosToTimestamp")}timestampToUnixMicros(){return new Ie("timestamp_to_unix_micros",[this],"timestampToUnixMicros")}unixMillisToTimestamp(){return new Ie("unix_millis_to_timestamp",[this],"unixMillisToTimestamp")}timestampToUnixMillis(){return new Ie("timestamp_to_unix_millis",[this],"timestampToUnixMillis")}unixSecondsToTimestamp(){return new Ie("unix_seconds_to_timestamp",[this],"unixSecondsToTimestamp")}timestampToUnixSeconds(){return new Ie("timestamp_to_unix_seconds",[this],"timestampToUnixSeconds")}timestampAdd(e,t){return new Ie("timestamp_add",[this,qe(e),qe(t)],"timestampAdd")}timestampSubtract(e,t){return new Ie("timestamp_subtract",[this,qe(e),qe(t)],"timestampSubtract")}timestampDiff(e,t){return new Ie("timestamp_diff",[this,K4(e),qe(t)],"timestampDiff")}timestampExtract(e,t){const s=[this,qe(e)];return t&&s.push(qe(t)),new Ie("timestamp_extract",s,"timestampExtract")}documentId(){return new Ie("document_id",[this],"documentId")}parent(){return new Ie("parent",[this],"parent")}substring(e,t){const s=qe(e);return new Ie("substring",t===void 0?[this,s]:[this,s,qe(t)],"substring")}arrayGet(e){return new Ie("array_get",[this,qe(e)],"arrayGet")}isError(){return new Ie("is_error",[this],"isError").asBoolean()}ifError(e){const t=new Ie("if_error",[this,qe(e)],"ifError");return e instanceof ru?t.asBoolean():t}isAbsent(){return new Ie("is_absent",[this],"isAbsent").asBoolean()}mapRemove(e){return new Ie("map_remove",[this,qe(e)],"mapRemove")}mapMerge(e,...t){const s=qe(e),r=t.map(qe);return new Ie("map_merge",[this,s,...r],"mapMerge")}pow(e){return new Ie("pow",[this,qe(e)])}trunc(e){return e===void 0?new Ie("trunc",[this]):new Ie("trunc",[this,qe(e)],"trunc")}round(e){return e===void 0?new Ie("round",[this]):new Ie("round",[this,qe(e)],"round")}collectionId(){return new Ie("collection_id",[this])}length(){return new Ie("length",[this])}ln(){return new Ie("ln",[this])}sqrt(){return new Ie("sqrt",[this])}
39stringReverse(){return new Ie("string_reverse",[this])}ifAbsent(e){return new Ie("if_absent",[this,qe(e)],"ifAbsent")}ifNull(e){return new Ie("if_null",[this,qe(e)],"ifNull")}coalesce(e,...t){return new Ie("coalesce",[this,qe(e),...t.map(qe)],"coalesce")}join(e){return new Ie("join",[this,qe(e)],"join")}log10(){return new Ie("log10",[this])}arraySum(){return new Ie("sum",[this])}split(e){return new Ie("split",[this,qe(e)])}timestampTruncate(e,t){const s=[this,qe(e)];return t&&s.push(qe(t)),new Ie("timestamp_trunc",s)}ascending(){return jG(this)}descending(){return OG(this)}as(e){return new RG(this,e,"as")}}class Yi{constructor(e,t){this.name=e,this.params=t,this.exprType="AggregateFunction",this._protoValueType="ProtoValue"}static _create(e,t,s){const r=new Yi(e,t);return r._methodName=s,r}as(e){return new kG(this,e,"as")}_toProto(e){return{functionValue:{name:this.name,args:this.params.map((t=>t._toProto(e)))}}}_readUserData(e){e=this._methodName?e.contextWith({methodName:this._methodName}):e,this.params.forEach((t=>t._readUserData(e)))}}class kG{constructor(e,t,s){this.aggregate=e,this.alias=t,this._methodName=s}_readUserData(e){this.aggregate._readUserData(e)}}class RG{constructor(e,t,s){this.expr=e,this.alias=t,this._methodName=s,this.exprType="AliasedExpression",this.selectable=!0}_readUserData(e){this.expr._readUserData(e)}}class vp extends Dd{constructor(e,t){super(),this.Rr=e,this._methodName=t,this.expressionType="ListOfExpressions"}_toProto(e){return{arrayValue:{values:this.Rr.map((t=>t._toProto(e)))}}}_readUserData(e){this.Rr.forEach((t=>t._readUserData(e)))}}class Tf extends Dd{constructor(e,t){super(),this.fieldPath=e,this._methodName=t,this.expressionType="Field",this.selectable=!0}get _fieldPath(){return this.fieldPath}get fieldName(){return this.fieldPath.canonicalString()}get alias(){return this.fieldName}get expr(){return this}geoDistance(e){return new Ie("geo_distance",[this,qe(e)],"geoDistance")}_toProto(e){return{fieldReferenceValue:this.fieldPath.canonicalString()}}_readUserData(e){}}function R0(n){return PG(n,"field")}function PG(n,e){return new Tf(typeof n=="string"?Vo===n?eG()._internalPath:su("field",n):n._internalPath,e)}class _f extends Dd{constructor(e,t){super(),this.value=e,this._methodName=t,this.expressionType="Constant"}static _fromProto(e){const t=new _f(e,void 0);return t._protoValue=e,t}_toProto(e){return yt(this._protoValue!==void 0,237),this._protoValue}_getValue(){return this._protoValue}_readUserData(e){e=this._methodName?e.contextWith({methodName:this._methodName}):e,IG(this._protoValue)||(this._protoValue=Qo(this.value,e))}}function lm(n,e){return XR(n,"constant")}function XR(n,e){const t=new _f(n,e);return typeof n=="boolean"?new ZR(t):t}class Ie extends Dd{constructor(e,t,s,r){super(),this.name=e,this.params=t,this.expressionType="Function",this._optionsProto=void 0,s!==void 0&&(this._methodName=s),r!==void 0&&(this._options=r)}get _optionsUtil(){return new Vr({})}_toProto(e){const t={functionValue:{name:this.name,args:this.params.map((s=>s._toProto(e)))}};return this._optionsProto&&(t.functionValue.options=this._optionsProto),t}_readUserData(e){e=this._methodName?e.contextWith({methodName:this._methodName}):e,this.params.forEach((t=>t._readUserData(e))),this._options&&(this._optionsProto=this._optionsUtil.getOptionsProto(e,this._options))}}class ru extends Dd{get _methodName(){return this._expr._methodName}countIf(){return Yi._create("count_if",[this],"countIf")}not(){return new Ie("not",[this],"not").asBoolean()}conditional(e,t){return new Ie("conditional",[this,e,t],"conditional")}ifError(e){const t=qe(e),s=new Ie("if_error",[this,t],"ifError");return t instanceof ru?s.asBoolean():s}_toProto(e){return this._expr._toProto(e)}_readUserData(e){this._expr._readUserData(e)}}class JR extends ru{constructor(e){super(),this._expr=e,this.expressionType="Function"}}class ZR extends ru{constructor(e){super(),this._expr=e,this.expressionType="Constant"}_getValue(){return this._expr._getValue()}}class NG extends ru{constructor(e){super(),this._expr=e,this.expressionType="Field"}}function LG(n,e){const t=[];for(const s in n)if(Object.prototype.hasOwnProperty.call(n,s)){const r=n[s];t.push(lm(s)),t.push(qe(r))}return new Ie("map",t,"map")}function DG(n){return(function(t,s){return new Ie("array",t.map((r=>qe(r))),s)})(n,"array")}function jG(n){return new e9(K4(n),"ascending","ascending")}
vendor: 4,318 bytes, line 39
39function OG(n){return new e9(K4(n),"descending","descending")}class e9{constructor(e,t,s){this.expr=e,this.direction=t,this._methodName=s,this._protoValueType="ProtoValue"}_toProto(e){return{mapValue:{fields:{direction:DR(this.direction),expression:this.expr._toProto(e)}}}}_readUserData(e){this.expr._readUserData(e)}}class ra{constructor(e){this.optionsProto=void 0,{rawOptions:this.rawOptions,...this.knownOptions}=e}_readUserData(e){this.optionsProto=this._optionsUtil.getOptionsProto(e,this.knownOptions,this.rawOptions)}_toProto(e){return{name:this._name,options:this.optionsProto}}}class t9 extends ra{get _name(){return"add_fields"}get _optionsUtil(){return new Vr({})}constructor(e,t){super(t),this.fields=e}_toProto(e){return{...super._toProto(e),args:[om(e,this.fields)]}}_readUserData(e){super._readUserData(e),iu(this.fields,e)}}class n9 extends ra{get _name(){return"aggregate"}get _optionsUtil(){return new Vr({})}constructor(e,t,s){super(s),this.groups=e,this.accumulators=t}_toProto(e){return{...super._toProto(e),args:[om(e,this.accumulators),om(e,this.groups)]}}_readUserData(e){super._readUserData(e),iu(this.groups,e),iu(this.accumulators,e)}}class s9 extends ra{get _name(){return"distinct"}get _optionsUtil(){return new Vr({})}constructor(e,t){super(t),this.groups=e}_toProto(e){return{...super._toProto(e),args:[om(e,this.groups)]}}_readUserData(e){super._readUserData(e),iu(this.groups,e)}}class Ux extends ra{get _name(){return"collection"}get _optionsUtil(){return new Vr({forceIndex:{serverName:"force_index"}})}constructor(e,t){super(t),this.Vr=e.startsWith("/")?e:"/"+e}_toProto(e){return{...super._toProto(e),args:[{referenceValue:this.Vr}]}}_readUserData(e){super._readUserData(e)}}class Vx extends ra{get _name(){return"collection_group"}get _optionsUtil(){return new Vr({forceIndex:{serverName:"force_index"}})}constructor(e,t){super(t),this.collectionId=e}_toProto(e){return{...super._toProto(e),args:[{referenceValue:""},{stringValue:this.collectionId}]}}_readUserData(e){super._readUserData(e)}}class q4 extends ra{get _name(){return"database"}get _optionsUtil(){return new Vr({})}_toProto(e){return{...super._toProto(e)}}_readUserData(e){super._readUserData(e)}}class Y4 extends ra{get _name(){return"documents"}get _optionsUtil(){return new Vr({})}constructor(e,t){if(super(t),!e||e.length===0)throw new Xe(Ce.INVALID_ARGUMENT,"Empty document paths are not allowed in DocumentsSource");const s=e.map((i=>i.startsWith("/")?i:"/"+i)),r=new Set(s);if(r.size!==s.length)throw new Xe(Ce.INVALID_ARGUMENT,"Duplicate document paths are not allowed in DocumentsSource");this.dr=s,this.mr=r}_toProto(e){return{...super._toProto(e),args:this.dr.map((t=>({referenceValue:t})))}}_readUserData(e){super._readUserData(e)}}class Bx extends ra{get _name(){return"where"}get _optionsUtil(){return new Vr({})}constructor(e,t){super(t),this.condition=e}_toProto(e){return{...super._toProto(e),args:[this.condition._toProto(e)]}}_readUserData(e){super._readUserData(e),iu(this.condition,e)}}class bd extends ra{get _name(){return"limit"}get _optionsUtil(){return new Vr({})}constructor(e,t){yt(!isNaN(e)&&e!==1/0&&e!==-1/0,34860),super(t),this.limit=e}_toProto(e){return{...super._toProto(e),args:[Ax(e,this.limit)]}}}class g5 extends ra{get _name(){return"offset"}get _optionsUtil(){return new Vr({})}constructor(e,t){super(t),this.offset=e}_toProto(e){return{...super._toProto(e),args:[Ax(e,this.offset)]}}}class MG extends ra{get _name(){return"select"}get _optionsUtil(){return new Vr({})}constructor(e,t){super(t),this.selections=e}_toProto(e){return{...super._toProto(e),args:[om(e,this.selections)]}}_readUserData(e){super._readUserData(e),iu(this.selections,e)}}class jl extends ra{get _name(){return"sort"}get _optionsUtil(){return new Vr({})}constructor(e,t){super(t),this.orderings=e}_toProto(e){return{...super._toProto(e),args:this.orderings.map((t=>t._toProto(e)))}}_readUserData(e){super._readUserData(e),iu(this.orderings,e)}}class Q4 extends ra{get _name(){return"replace_with"}get _optionsUtil(){return new Vr({})}constructor(e,t){super(t),this.map=e}_toProto(e){return{...super._toProto(e),args:[this.map._toProto(e),DR(Q4.pr)]}}_readUserData(e){super._readUserData(e),iu(this.map,e)}}Q4.pr="full_replace";function iu(n,e){return qR(n)?n._readUserData(e):Array.isArray(n)?n.forEac
39h((t=>t._readUserData(e))):n instanceof Map?n.forEach((t=>t._readUserData(e))):Object.values(n).forEach((t=>t._readUserData(e))),n}class Qr{constructor(e,t,s){this.serializer=e,this.stages=t,this.listenOptions=s,this.isCorePipeline=!0}getPipelineCollection(){return zx(this)}getPipelineCollectionGroup(){return X4(this)}getPipelineCollectionId(){return FG(this)}getPipelineDocuments(){return Vb(this)}getPipelineFlavor(){return(function(t){let s="exact";return t.stages.forEach(((r,i)=>{r._name!==s9.name&&r._name!==n9.name||(s="keyless"),r._name===MG.name&&s==="exact"&&(s="augmented"),r._name===t9.name&&i<t.stages.length-1&&s==="exact"&&(s="augmented")})),s})(this)}getPipelineSourceType(){return qc(this)}}function qc(n){const e=n.stages[0];return e instanceof Ux||e instanceof Vx||e instanceof q4||e instanceof Y4?e._name:"unknown"}function zx(n){if(qc(n)==="collection")return n.stages[0].Vr}function X4(n){if(qc(n)==="collection_group")return n.stages[0].collectionId}function FG(n){switch(qc(n)){case"collection":return bn.fromString(zx(n)).lastSegment();case"collection_group":return X4(n);default:return}}function Vb(n){if(qc(n)==="documents")return n.stages[0].dr}class Dp{constructor(e,t,s,r){this._db=e,this.userDataReader=t,this._userDataWriter=s,this.stages=r}wr(e,t){const s=this.userDataReader.createContext(3,e);return qR(t)?t._readUserData(s):Array.isArray(t)?t.forEach((r=>r._readUserData(s))):t.forEach((r=>r._readUserData(s))),t}where(e){const t=this.stages.map((s=>s));return this.wr("where",e),t.push(new Bx(e,{})),new Dp(this._db,this.userDataReader,this._userDataWriter,t)}limit(e){const t=this.stages.map((s=>s));return t.push(new bd(e,{})),new Dp(this._db,this.userDataReader,this._userDataWriter,t)}sort(e,...t){const s=this.stages.map((r=>r));return"orderings"in e?s.push(new jl(this.wr("sort",e.orderings),{})):s.push(new jl(this.wr("sort",[e,...t]),{})),new Dp(this._db,this.userDataReader,this._userDataWriter,s)}br(e){return{pipeline:{stages:this.stages.map((t=>t._toProto(e)))}}}}class ie{constructor(e,t){this.type=e,this.value=t}static vr(){return new ie("ERROR",void 0)}static Sr(){return new ie("UNSET",void 0)}static Dr(){return new ie("NULL",Qh)}static newValue(e){return Zi(e)?new ie("NULL",Qh):(function(s){return!!s&&"booleanValue"in s})(e)?new ie("BOOLEAN",e):Bo(e)?new ie("INT",e):Zu(e)?new ie("DOUBLE",e):(function(s){return!!s&&"timestampValue"in s&&!!s.timestampValue})(e)?new ie("TIMESTAMP",e):(function(s){return!!s&&"stringValue"in s})(e)?new ie("STRING",e):(function(s){return!!s&&"bytesValue"in s})(e)?new ie("BYTES",e):e.referenceValue?new ie("REFERENCE",e):e.geoPointValue?new ie("GEO_POINT",e):Jh(e)?new ie("ARRAY",e):d1(e)?new ie("VECTOR",e):rd(e)?new ie("MAP",e):new ie("ERROR",void 0)}Cr(){return this.type==="ERROR"||this.type==="UNSET"}Fr(){return this.type==="NULL"}}function jp(n){if(!n.Cr())return n.value}function r9(n){return n instanceof ru?n._expr:n}function Pt(n){if((n=r9(n))instanceof Tf)return new UG(n);if(n instanceof _f)return new VG(n);if(n instanceof vp)return new BG(n);if(n instanceof Ie){if(n.name==="add")return new HG(n);if(n.name==="subtract")return new WG(n);if(n.name==="multiply")return new GG(n);if(n.name==="divide")return new KG(n);if(n.name==="mod")return new qG(n);if(n.name==="and")return new YG(n);if(n.name==="equal")return new oK(n);if(n.name==="not_equal")return new lK(n);if(n.name==="less_than")return new cK(n);if(n.name==="less_than_or_equal")return new uK(n);if(n.name==="greater_than")return new dK(n);if(n.name==="greater_than_or_equal")return new hK(n);if(n.name==="array_concat")return new fK(n);if(n.name==="array_reverse")return new pK(n);if(n.name==="array_contains")return new mK(n);if(n.name==="array_contains_all")return new gK(n);if(n.name==="array_contains_any")return new xK(n);if(n.name==="array_length")return new yK(n);if(n.name==="array_element")return new vK(n);if(n.name==="equal_any")return new i9(n);if(n.name==="not_equal_any")return new XG(n);if(n.name==="is_nan")return new JG(n);if(n.name==="is_not_nan")return new ZG(n);if(n.name==="is_null")return new eK(n);if(n.name==="is_not_null")return new tK(n);if(n.name==="is_error")return new nK(n);if(n.name==="exists")return new sK(n);if(n.name==="not")return new $x(n);if(n.name==="or")return new QG(n);if(n.name==="xor")return new J4(n);if(n.name==="conditional")return new rK(n);if(n.name==="maximum")return new iK(n);if(n.name==="minimum")return new aK(n);if(n.name==="reverse")return new bK(n);if(n.name==="replace_first")return new wK(n);if(n.name==="replace_all")return new SK(n);if(n.name==="char_length")return new EK(n);if(n.name==="byte_length")return new TK(n);if(n.name==="like")return new _K(n);if(n.name==="regex_contains")return new IK(n);if(n.name==="regex_match")return new AK(n);if(n.name==="string_contains")return new CK(n);if(n.name==="starts_with")return new kK(n);if(n.name==="ends_with")return new RK(n);if(n.name==="to_lower")return new PK(n);if(n.name==="to_upper")return new NK(n);if(n.name==="trim")return new LK(n);if(n.name==="string_concat")return new DK(n);if(n.name==="map_get")return new jK(n);if(n.name==="cosine_distance")return new OK(n);if(n.name==="dot_product")return new MK(n);if(n.name==="euclidean_distance")return new FK(n);if(n.name==="vector_length")return new UK(n);if(n.name==="unix_micros_to_timestamp")return new HK(n);if(n.name==="timestamp_to_unix_micros")return new KK(n);if(n.name==="unix_millis_to_timestamp")return new WK(n);if(n.name==="timestamp_to_unix_millis")return new qK(n);if(n.name==="unix_seconds_to_timestamp")return new GK(n);if(n.name==="timestamp_to_unix_seconds")return new YK(n);if(n.name==="timestamp_add")return new QK(n);if(n.name==="timestamp_subtract")return new XK(n)}throw new Error(`Unknown Expr : ${n}`)}class UG{constructor(e){this.expr=e}evaluate(e,t){if(this.expr.fieldName===Vo)return ie.newValue({referenceValue:y1(e.serializer,t.key)});if(this.expr.fieldName==="__update_time__")return ie.newValue({timestampValue:k0(e.serializer,t.version)});if(this.expr.fieldName==="__create_time__")return ie.newValue({timestampValue:k0(e.serializer,t.createTime)});const s=t.data.field(this.expr._fieldPath);return s?_x(s)?ie.newValue((function(i,a){if(i.serverTimestampBehavior==="estimate")return{timestampValue:k0(i.serializer,Vt.fromTimestamp(Yh(a)))};if(i.serverTimestampBehavior==="previous"){const l=Lm(a);if(l)return l}return{nullValue:"NULL_VALUE"}}
vendor: 16,384 bytes, line 39
39)(e,s)):ie.newValue(s):ie.Sr()}}class VG{constructor(e){this.expr=e}evaluate(e,t){return ie.newValue(this.expr._getValue())}}class BG{constructor(e){this.expr=e}evaluate(e,t){const s=this.expr.Rr.map((r=>Pt(r).evaluate(e,t)));return s.some((r=>r.Cr()))?ie.vr():ie.newValue({arrayValue:{values:s.map((r=>r.value))}})}}function wr(n){return Zu(n)?Number(n.doubleValue):Number(n.integerValue)}function Xo(n){return BigInt(n.integerValue)}const zG=BigInt("0x7fffffffffffffff"),$G=-BigInt("0x8000000000000000");class Mm{constructor(e){this.expr=e}evaluate(e,t){yt(this.expr.params.length>=2,24778);const s=Pt(this.expr.params[0]).evaluate(e,t),r=Pt(this.expr.params[1]).evaluate(e,t);let i=this.Or(s,r);for(const a of this.expr.params.slice(2)){const l=Pt(a).evaluate(e,t);i=this.Or(i,l)}return i}Or(e,t){if(e.Cr()||t.Cr())return ie.vr();if(e.Fr()||t.Fr())return ie.Dr();const s=e.value,r=t.value;if(!Zu(s)&&!Bo(s)||!Zu(r)&&!Bo(r))return ie.vr();if(Zu(s)||Zu(r)){const i=this.Mr(s,r);return i?ie.newValue(i):ie.vr()}if(Bo(s)&&Bo(r)){const i=this.Nr(s,r);return i===void 0?ie.vr():typeof i=="number"?ie.newValue({doubleValue:i}):i<$G||i>zG?ie.vr():ie.newValue({integerValue:`${i}`})}return ie.vr()}}function ql(n,e){return Ms(n)!==Ms(e)?"TYPE_MISMATCH":Pi(n)||Pi(e)?"NOT_EQ":Zi(n)&&Zi(e)?"EQ":Zi(n)||Zi(e)?"NULL":Jh(n)&&Jh(e)?(function(s,r){if(s.values?.length!==r.values?.length)return"NOT_EQ";let i=!1;for(let a=0;a<(s.values?.length??0);a++){const l=s.values[a],c=r.values[a];switch(ql(l,c)){case"EQ":break;case"NOT_EQ":case"TYPE_MISMATCH":return"NOT_EQ";case"NULL":i=!0;break;default:_t(44609,{Lr:l,Br:c})}}return i?"NULL":"EQ"})(n.arrayValue,e.arrayValue):d1(n)&&d1(e)||rd(n)&&rd(e)?(function(s,r){const i=s.fields||{},a=r.fields||{};if(c1(i)!==c1(a))return"NOT_EQ";let l=!1;for(const c in i)if(i.hasOwnProperty(c)){if(a[c]===void 0)return"NOT_EQ";switch(ql(i[c],a[c])){case"NOT_EQ":case"TYPE_MISMATCH":return"NOT_EQ";case"NULL":l=!0}}return l?"NULL":"EQ"})(n.mapValue,e.mapValue):(function(s,r){return Ca(s,r,{Te:!1,Ee:!0,he:!0})})(n,e)?"EQ":"NOT_EQ"}class HG extends Mm{Nr(e,t){return Xo(e)+Xo(t)}Mr(e,t){return{doubleValue:wr(e)+wr(t)}}}class WG extends Mm{constructor(e){super(e),this.expr=e}Nr(e,t){return Xo(e)-Xo(t)}Mr(e,t){return{doubleValue:wr(e)-wr(t)}}}class GG extends Mm{constructor(e){super(e),this.expr=e}Nr(e,t){return Xo(e)*Xo(t)}Mr(e,t){return{doubleValue:wr(e)*wr(t)}}}class KG extends Mm{constructor(e){super(e),this.expr=e}Nr(e,t){const s=Xo(t);if(s!==BigInt(0))return Xo(e)/s}Mr(e,t){const s=wr(t);return s===0?{doubleValue:tm(s)?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY}:{doubleValue:wr(e)/s}}}class qG extends Mm{constructor(e){super(e),this.expr=e}Nr(e,t){const s=Xo(t);if(s!==BigInt(0))return Xo(e)%s}Mr(e,t){const s=wr(t);if(s!==0)return{doubleValue:wr(e)%s}}}class YG{constructor(e){this.expr=e}evaluate(e,t){let s=!1,r=!1;for(const i of this.expr.params){const a=Pt(i).evaluate(e,t);switch(a.type){case"BOOLEAN":if(!a.value?.booleanValue)return ie.newValue(ur);break;case"NULL":r=!0;break;default:s=!0}}return s?ie.vr():r?ie.Dr():ie.newValue(ki)}}class $x{constructor(e){this.expr=e}evaluate(e,t){yt(this.expr.params.length===1,9634);const s=Pt(this.expr.params[0]).evaluate(e,t);switch(s.type){case"BOOLEAN":return ie.newValue({booleanValue:!s.value?.booleanValue});case"NULL":return ie.Dr();default:return ie.vr()}}}class QG{constructor(e){this.expr=e}evaluate(e,t){let s=!1,r=!1;for(const i of this.expr.params){const a=Pt(i).evaluate(e,t);switch(a.type){case"BOOLEAN":if(a.value?.booleanValue)return ie.newValue(ki);break;case"NULL":r=!0;break;default:s=!0}}return s?ie.vr():r?ie.Dr():ie.newValue(ur)}}class J4{constructor(e){this.expr=e}evaluate(e,t){let s=!1,r=!1;for(const i of this.expr.params){const a=Pt(i).evaluate(e,t);switch(a.type){case"BOOLEAN":s=J4.xor(s,!!a.value?.booleanValue);break;case"NULL":r=!0;break;default:return ie.vr()}}return r?ie.Dr():ie.newValue({booleanValue:s})}static xor(e,t){return(e||t)&&!(e&&t)}}class i9{constructor(e){this.expr=e}evaluate(e,t){yt(this.expr.params.length===2,55094);let s=!1;const r=Pt(this.expr.params[0]).evaluate(e,t);switch(r.type){case"NULL":s=!0;break;case"ERROR":case"UNSET":return ie.vr()}const i=Pt(this.expr.params[1]).evaluate(e,t);switch(i.type){case"ARRAY":break;case"NULL":s=!0;break;default:return ie.vr()}if(s)return ie.Dr();for(const a of i.value?.arrayValue?.values??[])switch(Zi(r.value)&&Zi(a)?"EQ":ql(r.value,a)){case"EQ":return ie.newValue(ki);case"NOT_EQ":case"TYPE_MISMATCH":break;case"NULL":s=!0;break;default:_t(44608,{value:r.value,candidate:a})}return s?ie.Dr():ie.newValue(ur)}}class XG{constructor(e){this.expr=e}evaluate(e,t){return new $x(new Ie("not",[new Ie("equal_any",this.expr.params)])).evaluate(e,t)}}class JG{constructor(e){this.expr=e}evaluate(e,t){yt(this.expr.params.length===1,23322);const s=Pt(this.expr.params[0]).evaluate(e,t);switch(s.type){case"INT":return ie.newValue(ur);case"DOUBLE":return ie.newValue({booleanValue:isNaN(wr(s.value))});case"NULL":return ie.Dr();default:return ie.vr()}}}class ZG{constructor(e){this.expr=e}evaluate(e,t){return yt(this.expr.params.length===1,50406),new $x(new Ie("not",[new Ie("is_nan",this.expr.params)])).evaluate(e,t)}}class eK{constructor(e){this.expr=e}evaluate(e,t){switch(yt(this.expr.params.length===1,23123),Pt(this.expr.params[0]).evaluate(e,t).type){case"NULL":return ie.newValue(ki);case"UNSET":case"ERROR":return ie.vr();default:return ie.newValue(ur)}}}class tK{constructor(e){this.expr=e}evaluate(e,t){return yt(this.expr.params.length===1,23167),new $x(new Ie("not",[new Ie("is_null",this.expr.params)])).evaluate(e,t)}}class nK{constructor(e){this.expr=e}evaluate(e,t){return yt(this.expr.params.length===1,5228),Pt(this.expr.params[0]).evaluate(e,t).type==="ERROR"?ie.newValue(ki):ie.newValue(ur)}}class sK{constructor(e){this.expr=e}evaluate(e,t){switch(yt(this.expr.params.length===1,6877),Pt(this.expr.params[0]).evaluate(e,t).type){case"ERROR":return ie.vr();case"UNSET":return ie.newValue(ur);default:return ie.newValue(ki)}}}class rK{constructor(e){this.expr=e}evaluate(e,t){yt(this.expr.params.length===3,11706);const s=Pt(this.expr.params[0]).evaluate(e,t);switch(s.type){case"BOOLEAN":return s.value?.booleanValue?Pt(this.expr.params[1]).evaluate(e,t):Pt(this.expr.params[2]).evaluate(e,t);case"NULL":return Pt(this.expr.params[2]).evaluate(e,t);default:return ie.vr()}}}class iK{constructor(e){this.expr=e}evaluate(e,t){const s=this.expr.params.map((i=>Pt(i).evaluate(e,t)));let r;for(const i of s)switch(i.type){case"ERROR":case"UNSET":case"NULL":continue;default:r=r===void 0||Ri(i.value,r.value)>0?i:r}return r===void 0?ie.Dr():r}}class aK{constructor(e){this.expr=e}evaluate(e,t){const s=this.expr.params.map((i=>Pt(i).evaluate(e,t)));let r;for(const i of s)switch(i.type){case"ERROR":case"UNSET":case"NULL":continue;default:r=r===void 0||Ri(i.value,r.value)<0?i:r}return r===void 0?ie.Dr():r}}class If{constructor(e){this.expr=e}evaluate(e,t){yt(this.expr.params.length===2,31033,`${this.expr.name}() function should have exactly 2 params`);const s=Pt(this.expr.params[0]).evaluate(e,t);switch(s.type){case"ERROR":case"UNSET":return ie.vr()}const r=Pt(this.expr.params[1]).evaluate(e,t);switch(r.type){case"ERROR":case"UNSET":return ie.vr()}return this.Ur(s,r)}}class oK extends If{constructor(e){super(e),this.expr=e}Ur(e,t){if(e.Fr()&&t.Fr())return ie.newValue(ki);if(e.Fr()||t.Fr()||Pi(e.value)||Pi(t.value)||Ms(e.value)!==Ms(t.value))return ie.newValue(ur);switch(ql(e.value,t.value)){case"EQ":return ie.newValue(ki);case"NOT_EQ":return ie.newValue(ur);case"NULL":return ie.Dr();default:_t(44615,{left:e,right:t})}}}class lK extends If{constructor(e){super(e),this.expr=e}Ur(e,t){switch(ql(e.value,t.value)){case"EQ":return ie.newValue(ur);case"NOT_EQ":case"TYPE_MISMATCH":return ie.newValue(ki);case"NULL":return ie.Dr();default:_t(44614,{left:e,right:t})}}}class cK extends If{constructor(e){super(e),this.expr=e}Ur(e,t){return Ms(e.value)!==Ms(t.value)||Pi(e.value)||Pi(t.value)?ie.newValue(ur):ie.newValue({booleanValue:Ri(e.value,t.value)<0})}}class uK extends If{constructor(e){super(e),this.expr=e}Ur(e,t){return Ms(e.value)!==Ms(t.value)||Pi(e.value)||Pi(t.value)?ie.newValue(ur):ql(e.value,t.value)==="EQ"?ie.newValue(ki):ie.newValue({booleanValue:Ri(e.value,t.value)<0})}}class dK extends If{constructor(e){super(e),this.expr=e}Ur(e,t){return Ms(e.value)!==Ms(t.value)||Pi(e.value)||Pi(t.value)?ie.newValue(ur):ie.newValue({booleanValue:Ri(e.value,t.value)>0})}}class hK extends If{constructor(e){super(e),this.expr=e}Ur(e,t){return Ms(e.value)!==Ms(t.value)||Pi(e.value)||Pi(t.value)?ie.newValue(ur):ql(e.value,t.value)==="EQ"?ie.newValue(ki):ie.newValue({booleanValue:Ri(e.value,t.value)>0})}}class fK{constructor(e){this.expr=e}evaluate(e,t){throw new Error("Unimplemented")}}class pK{constructor(e){this.expr=e}evaluate(e,t){yt(this.expr.params.length===1,216);const s=Pt(this.expr.params[0]).evaluate(e,t);switch(s.type){case"NULL":return ie.Dr();case"ARRAY":{const r=s.value.arrayValue?.values??[];return ie.newValue({arrayValue:{values:[...r].reverse()}})}default:return ie.vr()}}}class mK{constructor(e){this.expr=e}evaluate(e,t){return yt(this.expr.params.length===2,52884),new i9(new Ie("eq_any",[this.expr.params[1],this.expr.params[0]])).evaluate(e,t)}}class gK{constructor(e){this.expr=e}evaluate(e,t){yt(this.expr.params.length===2,1392);let s=!1;const r=Pt(this.expr.params[0]).evaluate(e,t);switch(r.type){case"ARRAY":break;case"NULL":s=!0;break;default:return ie.vr()}const i=Pt(this.expr.params[1]).evaluate(e,t);switch(i.type){case"ARRAY":break;case"NULL":s=!0;break;default:return ie.vr()}if(s)return ie.Dr();const a=i.value?.arrayValue?.values??[],l=r.value?.arrayValue?.values??[];for(const c of a){let d=!1;s=!1;for(const h of l){switch(Zi(c)&&Zi(h)?"EQ":ql(c,h)){case"EQ":d=!0;break;case"NOT_EQ":case"TYPE_MISMATCH":break;case"NULL":s=!0;break;default:_t(44613,{value:h,search:c})}if(d)break}if(!d)return ie.newValue(ur)}return ie.newValue(ki)}}class xK{constructor(e){this.expr=e}evaluate(e,t){yt(this.expr.params.length===2,2680);let s=!1;const r=Pt(this.expr.params[0]).evaluate(e,t);switch(r.type){case"ARRAY":break;case"NULL":s=!0;break;default:return ie.vr()}const i=Pt(this.expr.params[1]).evaluate(e,t);switch(i.type){case"ARRAY":break;case"NULL":s=!0;break;default:return ie.vr()}if(s)return ie.Dr();const a=i.value?.arrayValue?.values??[],l=r.value?.arrayValue?.values??[];for(const c of l)for(const d of a)switch(Zi(c)&&Zi(d)?"EQ":ql(c,d)){case"EQ":return ie.newValue(ki);case"NOT_EQ":case"TYPE_MISMATCH":break;case"NULL":s=!0;break;default:_t(44608,{value:c,search:d})}return s?ie.Dr():ie.newValue(ur)}}class yK{constructor(e){this.expr=e}evaluate(e,t){yt(this.expr.params.length===1,38605);const s=Pt(this.expr.params[0]).evaluate(e,t);switch(s.type){case"NULL":return ie.Dr();case"ARRAY":return ie.newValue({integerValue:`${s.value?.arrayValue?.values?.length??0}`});default:return ie.vr()}}}class vK{constructor(e){this.expr=e}evaluate(e,t){throw new Error("Unimplemented")}}class bK{constructor(e){this.expr=e}evaluate(e,t){yt(this.expr.params.length===1,1508);const s=Pt(this.expr.params[0]).evaluate(e,t);switch(s.type){case"NULL":return ie.Dr();case"BYTES":{const r=s.value?.bytesValue;if(typeof r=="string"){const i=Os.fromBase64String(r).toUint8Array();return i.reverse(),ie.newValue({bytesValue:Os.fromUint8Array(i).toBase64()})}return ie.newValue({bytesValue:new Uint8Array(r).reverse()})}case"STRING":{const r=s.value?.stringValue,i=new Intl.__PRIVATE_Segmenter(void 0,{granularity:"grapheme"}).segment(r),a=Array.from(i,(l=>l.segment)).reverse();return ie.newValue({stringValue:a.join("")})}default:return ie.vr()}}}class wK{constructor(e){this.expr=e}evaluate(e,t){throw new Error("Unimplemented")}}class SK{constructor(e){this.expr=e}evaluate(e,t){throw new Error("Unimplemented")}}class EK{constructor(e){this.expr=e}evaluate(e,t){yt(this.expr.params.length===1,19400);const s=Pt(this.expr.params[0]).evaluate(e,t);switch(s.type){case"NULL":return ie.Dr();case"STRING":{const r=(function(a){let l=0;for(let c=0;c<a.length;c++){const d=a.codePointAt(c);if(d===void 0)return;if(d<=65535)if(d>=55296&&d<=57343)if(d<=56319){const h=a.codePointAt(c+1);h!==void 0&&h>=56320&&h<=57343?(l+=1,c++):l+=1}else l+=1;else l+=1;else{if(!(d<=1114111))return;l+=1,c++}}return l})(s.value.stringValue);return r===void 0?ie.vr():ie.newValue({integerValue:r})}default:return ie.vr()}}}class TK{constructor(e){this.expr=e}evaluate(e,t){yt(this.expr.params.length===1,8486);const s=Pt(this.expr.params[0]).evaluate(e,t);switch(s.type){case"BYTES":{const r=s.value?.bytesValue;return typeof r=="string"?ie.newValue({integerValue:Os.fromBase64String(r).toUint8Array().length}):ie.newValue({integerValue:new Uint8Array(r).length})}case"STRING":{const r=(function(a){let l=0;for(let c=0;c<a.length;c++){const d=a.codePointAt(c);if(d===void 0)return;if(d>=55296&&d<=57343){if(!(d<=56319))return;{const h=a.codePointAt(c+1);if(h===void 0||!(h>=56320&&h<=57343))return;l+=4,c++}}else if(d<=127)l+=1;else if(d<=2047)l+=2;else if(d<=65535)l+=3;else{if(!(d<=1114111))return;l+=4,c++}}return l})(s.value?.stringValue);return r===void 0?ie.vr():ie.newValue({integerValue:r})}case"NULL":return ie.Dr();default:return ie.vr()}}}class Af{constructor(e){this.expr=e}evaluate(e,t){yt(this.expr.params.length===2,39773,`${this.expr.name}() function should have exactly two parameters`);let s=!1;const r=Pt(this.expr.params[0]).evaluate(e,t);switch(r.type){case"STRING":break;case"NULL":s=!0;break;default:return ie.vr()}const i=Pt(this.expr.params[1]).evaluate(e,t);switch(i.type){case"STRING":break;case"NULL":s=!0;break;default:return ie.vr()}return s?ie.Dr():this.kr(r.value?.stringValue,i.value?.stringValue)}}class _K extends Af{kr(e,t){try{const s=(function(a){let l="";for(let c=0;c<a.length;c++){const d=a.charAt(c);switch(d){case"_":l+=".";break;case"%":l+=".*";break;case"\\":case".":case"*":case"?":case"+":case"^":case"$":case"|":case"(":case")":case"[":case"]":case"{":case"}":l+="\\"+d;break;default:l+=d}}return"^"+l+"$"})(t),r=ba.compile(s);return ie.newValue({booleanValue:r.matches(e)})}catch(s){return fo(`Invalid LIKE pattern converted to regex: ${t}, returning error. Error: ${s}`),ie.vr()}}}class IK extends Af{kr(e,t){try{const s=ba.compile(t);return ie.newValue({booleanValue:s.matcher(e).find()})}catch{return fo(`Invalid regex pattern found in regex_contains: ${t}, returning error`),ie.vr()}}}class AK extends Af{kr(e,t){try{return ie.newValue({booleanValue:ba.compile(t).matches(e)})}catch{return fo(`Invalid regex pattern found in regex_match: ${t}, returning error`),ie.vr()}}}class CK extends Af{kr(e,t){return ie.newValue({booleanValue:e.includes(t)})}}class kK extends Af{kr(e,t){return ie.newValue({booleanValue:e.startsWith(t)})}}class RK extends Af{kr(e,t){return ie.newValue({booleanValue:e.endsWith(t)})}}class PK{constructor(e){this.expr=e}evaluate(e,t){yt(this.expr.params.length===1,29079);const s=Pt(this.expr.params[0]).evaluate(e,t);switch(s.type){case"STRING":return ie.newValue({stringValue:s.value?.stringValue?.toLowerCase()});case"NULL":return ie.Dr();default:return ie.vr()}}}class NK{constructor(e){this.expr=e}evaluate(e,t){yt(this.expr.params.length===1,60487);const s=Pt(this.expr.params[0]).evaluate(e,t);switch(s.type){case"STRING":return ie.newValue({stringValue:s.value?.stringValue?.toUpperCase()});case"NULL":return ie.Dr();default:return ie.vr()}}}class LK{constructor(e){this.expr=e}evaluate(e,t){yt(this.expr.params.length===1,28544);const s=Pt(this.expr.params[0]).evaluate(e,t);switch(s.type){case"STRING":return ie.newValue({stringValue:s.value?.stringValue?.trim()});case"NULL":return ie.Dr();default:return ie.vr()}}}class DK{constructor(e){this.expr=e}evaluate(e,t){const s=this.expr.params.map((a=>Pt(a).evaluate(e,t)));let r="",i=!1;for(const a of s)switch(a.type){case"STRING":r+=a.value.stringValue;break;case"NULL":i=!0;break;default:return ie.vr()}return i?ie.Dr():ie.newValue({stringValue:r})}}class jK{constructor(e){this.expr=e}evaluate(e,t){yt(this.expr.params.length===2,4483);const s=Pt(this.expr.params[0]).evaluate(e,t);switch(s.type){case"UNSET":return ie.Sr();case"MAP":break;default:return ie.vr()}const r=Pt(this.expr.params[1]).evaluate(e,t);if(r.type!=="STRING")return ie.vr();const i=s.value?.mapValue?.fields?.[r.value?.stringValue];return i===void 0?ie.
39Sr():ie.newValue(i)}}class Z4{constructor(e){this.expr=e}evaluate(e,t){yt(this.expr.params.length===2,25231,`${this.expr.name}() function should have exactly 2 params`);let s=!1;const r=Pt(this.expr.params[0]).evaluate(e,t);switch(r.type){case"VECTOR":break;case"NULL":s=!0;break;default:return ie.vr()}const i=Pt(this.expr.params[1]).evaluate(e,t);switch(i.type){case"VECTOR":break;case"NULL":s=!0;break;default:return ie.vr()}if(s)return ie.Dr();const a=Lb(r.value),l=Lb(i.value);if(a===void 0||l===void 0||a.values?.length!==l.values?.length)return ie.vr();const c=this.qr(a,l);return c===void 0||isNaN(c)?ie.vr():ie.newValue({doubleValue:c})}}class OK extends Z4{qr(e,t){const s=e?.values??[],r=t?.values??[];if(s.length===0)return;let i=0,a=0,l=0;for(let d=0;d<s.length;d++){if(!nu(s[d])||!nu(r[d]))return;const h=wr(s[d]),p=wr(r[d]);i+=h*p,a+=h*h,l+=p*p}const c=Math.sqrt(a)*Math.sqrt(l);if(c!==0)return 1-Math.max(-1,Math.min(1,i/c))}}class MK extends Z4{qr(e,t){const s=e?.values??[],r=t?.values??[];if(s.length===0)return 0;let i=0;for(let a=0;a<s.length;a++){if(!nu(s[a])||!nu(r[a]))return;i+=wr(s[a])*wr(r[a])}return i}}class FK extends Z4{qr(e,t){const s=e?.values??[],r=t?.values??[];if(s.length===0)return 0;let i=0;for(let a=0;a<s.length;a++){if(!nu(s[a])||!nu(r[a]))return;const l=wr(s[a]),c=wr(r[a]);i+=Math.pow(l-c,2)}return Math.sqrt(i)}}class UK{constructor(e){this.expr=e}evaluate(e,t){yt(this.expr.params.length===1,39044);const s=Pt(this.expr.params[0]).evaluate(e,t);switch(s.type){case"VECTOR":{const r=Lb(s.value);return ie.newValue({integerValue:r?.values?.length??0})}case"NULL":return ie.Dr();default:return ie.vr()}}}const cm=BigInt(-62135596800),um=BigInt(253402300799),b1=BigInt(1e3),Yc=BigInt(1e6),VK=cm*b1,BK=um*b1+BigInt(999),zK=cm*Yc,$K=um*Yc+BigInt(999999);function e6(n){return n>=zK&&n<=$K}function a9(n){return n>=cm&&n<=um}function dm(n,e){const t=BigInt(n);return!(t<cm||t>um)&&!(e<0||e>=1e9)&&(t!==cm||e===0)&&!(t===um&&e>999999999)}function o9(n,e){return e<0?{seconds:n-1,nanos:e+1e9}:{seconds:n,nanos:e}}function t6(n){return BigInt(n.seconds)*Yc+BigInt(Math.trunc(n.nanoseconds/1e3))}class n6{constructor(e){this.expr=e}evaluate(e,t){yt(this.expr.params.length===1,49262,`${this.expr.name}() function should have exactly one parameter`);const s=Pt(this.expr.params[0]).evaluate(e,t);switch(s.type){case"INT":return this.toTimestamp(BigInt(s.value.integerValue));case"NULL":return ie.Dr();default:return ie.vr()}}}class HK extends n6{toTimestamp(e){if(!e6(e))return ie.vr();let t=Number(e/Yc),s=Number(e%Yc*BigInt(1e3));const r=o9(t,s);return t=r.seconds,s=r.nanos,dm(t,s)?ie.newValue({timestampValue:{seconds:t,nanos:s}}):ie.vr()}}class WK extends n6{toTimestamp(e){if(!(function(a){return a>=VK&&a<=BK})(e))return ie.vr();let t=Number(e/b1),s=Number(e%b1*BigInt(1e6));const r=o9(t,s);return t=r.seconds,s=r.nanos,dm(t,s)?ie.newValue({timestampValue:{seconds:t,nanos:s}}):ie.vr()}}class GK extends n6{toTimestamp(e){if(!a9(e))return ie.vr();const t=Number(e);return ie.newValue({timestampValue:{seconds:t,nanos:0}})}}class s6{constructor(e){this.expr=e}evaluate(e,t){yt(this.expr.params.length===1,1265,`${this.expr.name}() function should have exactly one parameter`);const s=Pt(this.expr.params[0]).evaluate(e,t);switch(s.type){case"TIMESTAMP":break;case"NULL":return ie.Dr();default:return ie.vr()}const r=V4(s.value.timestampValue);return dm(r.seconds,r.nanoseconds)?this.$r(r):ie.vr()}}class KK extends s6{$r(e){const t=t6(e);return e6(t)?ie.newValue({integerValue:`${t.toString()}`}):ie.vr()}}class qK extends s6{$r(e){const t=t6(e),s=t/BigInt(1e3),r=t%BigInt(1e3);return s>BigInt(0)||r===BigInt(0)?ie.newValue({integerValue:s.toString()}):ie.newValue({integerValue:(s-BigInt(1)).toString()})}}class YK extends s6{$r(e){const t=BigInt(e.seconds);return a9(t)?ie.newValue({integerValue:t.toString()}):ie.vr()}}class l9{constructor(e){this.expr=e}evaluate(e,t){yt(this.expr.params.length===3,2775,`${this.expr.name}() function should have exactly 3 parameters`);let s=!1;const r=Pt(this.expr.params[0]).evaluate(e,t);switch(r.type){case"TIMESTAMP":break;case"NULL":s=!0;break;default:return ie.vr()}const i=Pt(this.expr.params[1]).evaluate(e,t);let a;switch(i.type){case"STRING":if(a=(function(L){switch(L){case"microsecond":return"microsecond";case"millisecond":return"millisecond";case"second":return"second";case"minute":return"minute";case"hour":return"hour";case"day":return"day";default:return}})(i.value.stringValue),a===void 0)return ie.vr();break;case"NULL":s=!0;break;default:return ie.vr()}const l=Pt(this.expr.params[2]).evaluate(e,t);switch(l.type){case"INT":break;case"NULL":s=!0;break;default:return ie.vr()}if(s)return ie.Dr();const c=BigInt(l.value.integerValue);let d;
vendor: 7,300 bytes, lines 39-42
39try{switch(a){case"microsecond":d=c;break;case"millisecond":d=c*BigInt(1e3);break;case"second":d=c*BigInt(1e6);break;case"minute":d=c*BigInt(6e7);break;case"hour":d=c*BigInt(36e8);break;case"day":d=c*BigInt(864e8);break;default:return ie.vr()}if(a!=="microsecond"&&c!==BigInt(0)&&d/c!==BigInt(this.Kr(a)))return ie.vr()}catch(_){return fo(`Error during timestamp arithmetic: ${_}`),ie.vr()}const h=V4(r.value.timestampValue);if(!dm(h.seconds,h.nanoseconds))return ie.vr();const p=t6(h),m=this.Wr(p,d);if(!e6(m))return ie.vr();const y=Number(m/Yc),x=m%Yc,w=Number((x<0?x+Yc:x)*BigInt(1e3)),S=x<0?y-1:y;return dm(S,w)?ie.newValue({timestampValue:{seconds:S,nanos:w}}):ie.vr()}Kr(e){switch(e){case"millisecond":return 1e3;case"second":return 1e6;case"minute":return 6e7;case"hour":return 36e8;case"day":return 864e8;default:return 1}}}class QK extends l9{Wr(e,t){return e+t}}class XK extends l9{Wr(e,t){return e-t}}function hm(n){if((n=r9(n))instanceof Tf)return`fld(${n.fieldName})`;if(n instanceof _f)return`cst(${(function(t){return t===null?"null":typeof t=="number"?t.toString():typeof t=="string"?`"${t}"`:t instanceof as?`ref(${t.path})`:t instanceof Ai?`vec(${JSON.stringify(t)})`:JSON.stringify(t)})(n.value)})`;if(n instanceof Ie)return`fn(${n.name},[${n.params.map(hm).join(",")}])`;if(n.expressionType==="ListOfExpressions")return`list([${n.Rr.map(hm).join(",")}])`;throw new Error(`Unrecognized expr ${JSON.stringify(n,null,2)}`)}function JK(n){if(n instanceof t9)return`${n._name}(${Qg(n.fields)})`;if(n instanceof n9){let e=`${n._name}(${Qg(n.accumulators)})`;return n.groups.size>0&&(e+=`grouping(${Qg(n.groups)})`),e}if(n instanceof s9)return`${n._name}(${Qg(n.groups)})`;if(n instanceof Ux)return`${n._name}(${n.Vr})`;if(n instanceof Vx)return`${n._name}(${n.collectionId})`;if(n instanceof q4)return`${n._name}()`;if(n instanceof Y4)return`${n._name}(${n.dr.sort()})`;if(n instanceof Bx)return`${n._name}(${hm(n.condition)})`;if(n instanceof bd)return`${n._name}(${n.limit})`;if(n instanceof jl)return`${n._name}(${(function(t){return t.map((s=>`${hm(s.expr)}${s.direction}`)).join(",")})(n.orderings)})`;throw new Error(`Unrecognized stage ${n._name}`)}function Qg(n){return`${Array.from(n.entries()).sort().map((([e,t])=>`${e}=${hm(t)}`)).join(",")}`}function Bl(n){return n.stages.map((e=>JK(e))).join("|")}function c9(n,e){return Bl(n)===Bl(e)}function Ys(n){return n instanceof Qr}function x5(n){return Ys(n)?Bl(n):Np(n)}function u9(n){return Ys(n)?Bl(n):(function(t){return`${gR(Ho(t))}|lt:${t.limitType}`})(n)}function Hx(n,e){return n instanceof Qr&&e instanceof Qr?c9(n,e):!(n instanceof Qr&&!(e instanceof Qr)||!(n instanceof Qr)&&e instanceof Qr)&&_W(n,e)}function d9(n){return Qu(n)?Bl(n):gR(n)}function h9(n,e){return n instanceof Qr&&e instanceof Qr?c9(n,e):!(n instanceof Qr&&!(e instanceof Qr)||!(n instanceof Qr)&&e instanceof Qr)&&xR(n,e)}function ZK(n,e){const t=(function(r){let i=!1;const a=[];for(const l of r)if(l instanceof jl)if(i=!0,l.orderings.some((c=>c.expr instanceof Tf&&c.expr.fieldName===Vo)))a.push(l);else{const c=l.orderings.map((d=>d));c.push(R0(Vo).ascending()),a.push(new jl(c,{}))}else l instanceof bd&&(i||(a.push(new jl([R0(Vo).ascending()],{})),i=!0)),a.push(l);return i||a.push(new jl([R0(Vo).ascending()],{})),a})(n.stages);if(n.userDataReader){const s=n.userDataReader.createContext(3,"toCorePipeline");t.forEach((r=>r._readUserData(s)))}return new Qr(n.userDataReader.serializer,t,e)}class eq{constructor(e,t,s,r){this.batchId=e,this.localWriteTime=t,this.baseMutations=s,this.mutations=r}applyToRemoteDocument(e,t){const s=t.mutationResults;for(let r=0;r<this.mutations.length;r++){const i=this.mutations[r];i.key.isEqual(e.key)&&lW(i,e,s[r])}}applyToLocalView(e,t){for(const s of this.baseMutations)s.key.isEqual(e.key)&&(t=Rp(s,e,t,this.localWriteTime));for(const s of this.mutations)s.key.isEqual(e.key)&&(t=Rp(s,e,t,this.localWriteTime));return t}applyToLocalDocumentSet(e,t){const s=ER();return this.mutations.forEach((r=>{const i=e.get(r.key),a=i.overlayedDocument;let l=this.applyToLocalView(a,i.mutatedFields);l=t.has(r.key)?null:l;const c=lR(a,l);c!==null&&s.set(r.key,c),a.isValidDocument()||a.convertToNoDocument(Vt.min())})),s}keys(){return this.mutations.reduce(((e,t)=>e.add(t.key)),en())}isEqual(e){return this.batchId===e.batchId&&qh(this.mutations,e.mutations,((t,s)=>Y8(t,s)))&&qh(this.baseMutations,e.baseMutations,((t,s)=>Y8(t,s)))}}class r6{constructor(e,t,s,r){this.batch=e,this.commitVersion=t,this.mutationResults=s,this.docVersions=r}static from(e,t,s){yt(e.mutations.length===s.length,58842,{Qr:e.mutations.length,Gr:s.length});let r=(function(){return RW})();const i=e.mutations;for(let a=0;a<i.length;a++)r=r.insert(i[a].key,s[a].version);return new r6(e,t,s,r)}}class tq{constructor(e,t){this.largestBatchId=e,this.mutation=t}getKey(){return this.mutation.key}isEqual(e){return e!==null&&this.mutation===e.mutation}toString(){return`Overlay{ 40 largestBatchId: ${this.largestBatchId}, 41 mutation: ${this.mutation.toString()} 42 }`}}class Ol{constructor(e,t,s,r,i=Vt.min(),a=Vt.min(),l=Os.EMPTY_BYTE_STRING,c=null){this.target=e,this.targetId=t,this.purpose=s,this.sequenceNumber=r,this.snapshotVersion=i,this.lastLimboFreeSnapshotVersion=a,this.resumeToken=l,this.expectedCount=c}withSequenceNumber(e){return new Ol(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(e,t){return new Ol(this.target,this.targetId,this.purpose,this.sequenceNumber,t,this.lastLimboFreeSnapshotVersion,e,null)}withExpectedCount(e){return new Ol(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,e)}withLastLimboFreeSnapshotVersion(e){return new Ol(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken,this.expectedCount)}}class nq{constructor(e){this.zr=e}}function sq(n){const e=KW({parent:n.parent,structuredQuery:n.structuredQuery});return n.limitType==="LAST"?g1(e,e.limit,"L"):e}class rq{constructor(){this.Hi=new iq}addToCollectionParentIndex(e,t){return this.Hi.add(t),Pe.resolve()}getCollectionParents(e,t){return Pe.resolve(this.Hi.getEntries(t))}addFieldIndex(e,t){return Pe.resolve()}deleteFieldIndex(e,t){return Pe.resolve()}deleteAllFieldIndexes(e){return Pe.resolve()}createTargetIndexes(e,t){return Pe.resolve()}getDocumentsMatchingTarget(e,t){return Pe.resolve(null)}getIndexType(e,t){return Pe.resolve(0)}getFieldIndexes(e,t){return Pe.resolve([])}getNextCollectionGroupToUpdate(e){return Pe.resolve(null)}getMinOffset(e,t){return Pe.resolve(Zc.min())}getMinOffsetFromCollectionGroup(e,t){return Pe.resolve(Zc.min())}updateCollectionGroup(e,t,s){return Pe.resolve()}updateIndexEntries(e,t){return Pe.resolve()}}class iq{constructor(){this.index={}}add(e){const t=e.lastSegment(),s=e.popLast(),r=this.index[t]||new js(bn.comparator),i=!r.has(s);return this.index[t]=r.add(s),i}has(e){const t=e.lastSegment(),s=e.popLast(),r=this.index[t];return r&&r.has(s)}getEntries(e){return(this.index[e]||new js(bn.comparator)).toArray()}}class au{constructor(e){this.Ds=e}next(){return this.Ds+=2,this.Ds}static xs(){return new au(0)}static Cs(){return new au(-1)}}function f9(n,e){let t=e;
42for(const s of n.stages)t=oq({serializer:n.serializer,serverTimestampBehavior:n.listenOptions?.serverTimestampBehavior},s,t);return t}function Wx(n,e){return f9(n,[e]).length>0}function aq(n,e){return Ys(n)?Wx(n,e):Nx(n,e)}function oq(n,e,t){if(e instanceof Ux)return(function(r,i,a){return a.filter((l=>l.isFoundDocument()&&`/${l.key.getCollectionPath().canonicalString()}`===i.Vr))})(0,e,t);if(e instanceof Bx)return(function(r,i,a){return a.filter((l=>{const c=jp(Pt(i.condition).evaluate(r,l));return c!==void 0&&Ca(c,ki)}))})(n,e,t);if(e instanceof Vx)return(function(r,i,a){return a.filter((l=>l.isFoundDocument()&&l.key.getCollectionPath().lastSegment()===i.collectionId))})(0,e,t);if(e instanceof q4)return(function(r,i,a){return a.filter((l=>l.isFoundDocument()))})(0,0,t);if(e instanceof Y4)return(function(r,i,a){return a.filter((l=>l.isFoundDocument()&&i.mr.has(l.key.path.toStringWithLeadingSlash())))})(0,e,t);if(e instanceof bd)return(function(r,i,a){return a.slice(0,i.limit)})(0,e,t);if(e instanceof jl)return(function(r,i,a){const l=i.orderings.map((c=>({ks:Pt(c.expr),direction:c.direction})));return[...a].sort(((c,d)=>{for(const{ks:h,direction:p}of l){const m=jp(h.evaluate(r,c)),y=jp(h.evaluate(r,d)),x=Ri(m??Qh,y??Qh);if(x!==0)return p==="ascending"?x:-x}return 0}))})(n,e,t);throw new Error(`Unknown stage: ${e._name}`)}function Bb(n){const e=(function(s){for(let r=s.stages.length-1;r>=0;r--){const i=s.stages[r];if(i instanceof jl)return i.orderings}throw new Error("Pipeline must contain at least one Sort stage")})(n);return(t,s)=>{for(const r of e){const i=jp(Pt(r.expr).evaluate({serializer:n.serializer},t)),a=jp(Pt(r.expr).evaluate({serializer:n.serializer},s)),l=Ri(i||Qh,a||Qh);if(l!==0)return r.direction==="ascending"?l:-l}return 0}}function iv(n){for(let e=n.stages.length-1;e>=0;e--){const t=n.stages[e];if(t instanceof bd)return{limit:t.limit}}}class lq{constructor(){this.changes=new Nd((e=>e.toString()),((e,t)=>e.isEqual(t))),this.changesApplied=!1}addEntry(e){this.assertNotApplied(),this.changes.set(e.key,e)}removeEntry(e,t){this.assertNotApplied(),this.changes.set(e,Or.newInvalidDocument(e).setReadTime(t))}getEntry(e,t){this.assertNotApplied();const s=this.changes.get(t);return s!==void 0?Pe.resolve(s):this.getFromCache(e,t)}getEntries(e,t){return this.getAllFromCache(e,t)}apply(e){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(e)}assertNotApplied(){}}class cq{constructor(e,t){this.overlayedDocument=e,this.mutatedFields=t}}class uq{constructor(e,t,s,r){this.remoteDocumentCache=e,this.mutationQueue=t,this.documentOverlayCache=s,this.indexManager=r}getDocument(e,t){let s=null;return this.documentOverlayCache.getOverlay(e,t).next((r=>(s=r,this.remoteDocumentCache.getEntry(e,t)))).next((r=>(s!==null&&Rp(s.mutation,r,Ji.empty(),$n.now()),r)))}getDocuments(e,t){return this.remoteDocumentCache.getEntries(e,t).next((s=>this.getLocalViewOfDocuments(e,s,en()).next((()=>s))))}getLocalViewOfDocuments(e,t,s=en()){const r=Dc();return this.populateOverlays(e,r,t).next((()=>this.computeViews(e,t,r,s).next((i=>{let a=bh();return i.forEach(((l,c)=>{a=a.insert(l,c.overlayedDocument)})),a}))))}getOverlayedDocuments(e,t){const s=Dc();return this.populateOverlays(e,s,t).next((()=>this.computeViews(e,t,s,en())))}populateOverlays(e,t,s){const r=[];return s.forEach((i=>{t.has(i)||r.push(i)})),this.documentOverlayCache.getOverlays(e,r).next((i=>{i.forEach(((a,l)=>{t.set(a,l)}))}))}computeViews(e,t,s,r){let i=Ei();const a=Lp(),l=(function(){return Lp()})();return t.forEach(((c,d)=>{const h=s.get(d.key);r.has(d.key)&&(h===void 0||h.mutation instanceof yu)?i=i.insert(d.key,d):h!==void 0?(a.set(d.key,h.mutation.getFieldMask()),Rp(h.mutation,d,h.mutation.getFieldMask(),$n.now())):a.set(d.key,Ji.empty())})),this.recalculateAndSaveOverlays(e,i).next((c=>(c.forEach(((d,h)=>a.set(d,h))),t.forEach(((d,h)=>l.set(d,new cq(h,a.get(d)??null)))),l)))}recalculateAndSaveOverlays(e,t){const s=Lp();let r=new Zn(((a,l)=>a-l)),i=en();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,t).next((a=>
vendor: 4,127 bytes, line 42
42{for(const l of a)l.keys().forEach((c=>{const d=t.get(c);if(d===null)return;let h=s.get(c)||Ji.empty();h=l.applyToLocalView(d,h),s.set(c,h);const p=(r.get(l.batchId)||en()).add(c);r=r.insert(l.batchId,p)}))})).next((()=>{const a=[],l=r.getReverseIterator();for(;l.hasNext();){const c=l.getNext(),d=c.key,h=c.value,p=ER();h.forEach((m=>{if(!i.has(m)){const y=lR(t.get(m),s.get(m));y!==null&&p.set(m,y),i=i.add(m)}})),a.push(this.documentOverlayCache.saveOverlays(e,d,p))}return Pe.waitFor(a)})).next((()=>s))}recalculateAndSaveOverlaysForDocumentKeys(e,t){return this.remoteDocumentCache.getEntries(e,t).next((s=>this.recalculateAndSaveOverlays(e,s)))}getDocumentsMatchingQuery(e,t,s,r){return Ys(t)?this.getDocumentsMatchingPipeline(e,t,s,r):SW(t)?this.getDocumentsMatchingDocumentQuery(e,t.path):vR(t)?this.getDocumentsMatchingCollectionGroupQuery(e,t,s,r):this.getDocumentsMatchingCollectionQuery(e,t,s,r)}getNextDocuments(e,t,s,r){return this.remoteDocumentCache.getAllFromCollectionGroup(e,t,s,r).next((i=>{const a=r-i.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(e,t,s.largestBatchId,r-i.size):Pe.resolve(Dc());let l=em,c=i;return a.next((d=>Pe.forEach(d,((h,p)=>(l<p.largestBatchId&&(l=p.largestBatchId),i.get(h)?Pe.resolve():this.remoteDocumentCache.getEntry(e,h).next((m=>{c=c.insert(h,m)}))))).next((()=>this.populateOverlays(e,d,i))).next((()=>this.computeViews(e,c,d,en()))).next((h=>({batchId:l,changes:SR(h)})))))}))}getDocumentsMatchingDocumentQuery(e,t){return this.getDocument(e,new bt(t)).next((s=>{let r=bh();return s.isFoundDocument()&&(r=r.insert(s.key,s)),r}))}getDocumentsMatchingCollectionGroupQuery(e,t,s,r){const i=t.collectionGroup;let a=bh();return this.indexManager.getCollectionParents(e,i).next((l=>Pe.forEach(l,(c=>{const d=(function(p,m){return new Ef(m,null,p.explicitOrderBy.slice(),p.filters.slice(),p.limit,p.limitType,p.startAt,p.endAt)})(t,c.child(i));return this.getDocumentsMatchingCollectionQuery(e,d,s,r).next((h=>{h.forEach(((p,m)=>{a=a.insert(p,m)}))}))})).next((()=>a))))}getDocumentsMatchingCollectionQuery(e,t,s,r){let i;return this.documentOverlayCache.getOverlaysForCollection(e,t.path,s.largestBatchId).next((a=>(i=a,this.remoteDocumentCache.getDocumentsMatchingQuery(e,t,s,i,r)))).next((a=>this.retrieveMatchingLocalDocuments(i,a,(l=>Nx(t,l)))))}getDocumentsMatchingPipeline(e,t,s,r){if(qc(t)==="collection_group"){const i=X4(t);let a=bh();return this.indexManager.getCollectionParents(e,i).next((l=>Pe.forEach(l,(c=>{const d=(function(p,m){const y=p.stages.map((x=>x instanceof Vx?new Ux(m.canonicalString(),{}):x));return new Qr(p.serializer,y)})(t,c.child(i));return this.getDocumentsMatchingPipeline(e,d,s,r).next((h=>{h.forEach(((p,m)=>{a=a.insert(p,m)}))}))})).next((()=>a))))}{let i;return this.getOverlaysForPipeline(e,t,s.largestBatchId).next((a=>{switch(i=a,qc(t)){case"collection":return this.remoteDocumentCache.getDocumentsMatchingQuery(e,t,s,i,r);case"documents":let l=en();for(const c of Vb(t))l=l.add(bt.fromPath(c));return this.remoteDocumentCache.getEntries(e,l);case"database":return this.remoteDocumentCache.getAllEntries(e);default:throw new Xe("invalid-argument",`Invalid pipeline source to execute offline: ${Bl(t)}`)}})).next((a=>this.retrieveMatchingLocalDocuments(i,a,(l=>Wx(t,l)))))}}retrieveMatchingLocalDocuments(e,t,s){e.forEach(((i,a)=>{const l=a.getKey();t.get(l)===null&&(t=t.insert(l,Or.newInvalidDocument(l)))}));let r=bh();return t.forEach(((i,a)=>{const l=e.get(i);l!==void 0&&Rp(l.mutation,a,Ji.empty(),$n.now()),s(a)&&(r=r.insert(i,a))})),r}getOverlaysForPipeline(e,t,s){switch(qc(t)){case"collection":return this.documentOverlayCache.getOverlaysForCollection(e,bn.fromString(zx(t)),s);case"collection_group":throw new Xe("invalid-argument",`Unexpected collection group pipeline: ${Bl(t)}`);case"documents":return this.documentOverlayCache.getOverlays(e,Vb(t).map((r=>bt.fromPath(r))));case"database":return this.documentOverlayCache.getAllOverlays(e,s);default:throw new Xe("invalid-argument",`Failed to get overlays for pipeline: ${Bl(t)}`)}}}class dq{constructor(e){this.serializer=e,this.Hs=new Map,this.Js=new Map}
42getBundleMetadata(e,t){return Pe.resolve(this.Hs.get(t))}saveBundleMetadata(e,t){return this.Hs.set(t.id,(function(r){return{id:r.id,version:r.version,createTime:Wo(r.createTime)}})(t)),Pe.resolve()}getNamedQuery(e,t){return Pe.resolve(this.Js.get(t))}saveNamedQuery(e,t){return this.Js.set(t.name,(function(r){return{name:r.name,query:sq(r.bundledQuery),readTime:Wo(r.readTime)}})(t)),Pe.resolve()}}class hq{constructor(){this.overlays=new Zn(bt.comparator),this.Ys=new Map}getOverlay(e,t){return Pe.resolve(this.overlays.get(t))}getOverlays(e,t){const s=Dc();return Pe.forEach(t,(r=>this.getOverlay(e,r).next((i=>{i!==null&&s.set(r,i)})))).next((()=>s))}getAllOverlays(e,t){const s=Dc();return this.overlays.forEach(((r,i)=>{i.largestBatchId>t&&s.set(r,i)})),Pe.resolve(s)}saveOverlays(e,t,s){return s.forEach(((r,i)=>{this.Hr(e,t,i)})),Pe.resolve()}removeOverlaysForBatchId(e,t,s){const r=this.Ys.get(s);return r!==void 0&&(r.forEach((i=>this.overlays=this.overlays.remove(i))),this.Ys.delete(s)),Pe.resolve()}getOverlaysForCollection(e,t,s){const r=Dc(),i=t.length+1,a=new bt(t.child("")),l=this.overlays.getIteratorFrom(a);for(;l.hasNext();){const c=l.getNext().value,d=c.getKey();if(!t.isPrefixOf(d.path))break;d.path.length===i&&c.largestBatchId>s&&r.set(c.getKey(),c)}return Pe.resolve(r)}getOverlaysForCollectionGroup(e,t,s,r){let i=new Zn(((d,h)=>d-h));const a=this.overlays.getIterator();for(;a.hasNext();){const d=a.getNext().value;if(d.getKey().getCollectionGroup()===t&&d.largestBatchId>s){let h=i.get(d.largestBatchId);h===null&&(h=Dc(),i=i.insert(d.largestBatchId,h)),h.set(d.getKey(),d)}}const l=Dc(),c=i.getIterator();for(;c.hasNext()&&(c.getNext().value.forEach(((d,h)=>l.set(d,h))),!(l.size()>=r)););return Pe.resolve(l)}Hr(e,t,s){const r=this.overlays.get(s.key);if(r!==null){const a=this.Ys.get(r.largestBatchId).delete(s.key);this.Ys.set(r.largestBatchId,a)}this.overlays=this.overlays.insert(s.key,new tq(t,s));let i=this.Ys.get(t);i===void 0&&(i=en(),this.Ys.set(t,i)),this.Ys.set(t,i.add(s.key))}}class fq{constructor(){this.sessionToken=Os.EMPTY_BYTE_STRING}getSessionToken(e){return Pe.resolve(this.sessionToken)}setSessionToken(e,t){return this.sessionToken=t,Pe.resolve()}}class i6{constructor(){this.Zs=new js(lr.Xs),this.e_=new js(lr.t_)}isEmpty(){return this.Zs.isEmpty()}addReference(e,t){const s=new lr(e,t);this.Zs=this.Zs.add(s),this.e_=this.e_.add(s)}n_(e,t){e.forEach((s=>this.addReference(s,t)))}removeReference(e,t){this.r_(new lr(e,t))}i_(e,t){e.forEach((s=>this.removeReference(s,t)))}s_(e){const t=new bt(new bn([])),s=new lr(t,e),r=new lr(t,e+1),i=[];return this.e_.forEachInRange([s,r],(a=>{this.r_(a),i.push(a.key)})),i}__(){this.Zs.forEach((e=>this.r_(e)))}r_(e){this.Zs=this.Zs.delete(e),this.e_=this.e_.delete(e)}o_(e){const t=new bt(new bn([])),s=new lr(t,e),r=new lr(t,e+1);let i=en();return this.e_.forEachInRange([s,r],(a=>{i=i.add(a.key)})),i}containsKey(e){const t=new lr(e,0),s=this.Zs.firstAfterOrEqual(t);return s!==null&&e.isEqual(s.key)}}class lr{constructor(e,t){this.key=e,this.a_=t}static Xs(e,t){return bt.comparator(e.key,t.key)||sn(e.a_,t.a_)}static t_(e,t){return sn(e.a_,t.a_)||bt.comparator(e.key,t.key)}}class pq{constructor(e,t){this.indexManager=e,this.referenceDelegate=t,this.mutationQueue=[],this.gs=1,this.u_=new js(lr.Xs)}checkEmpty(e){return Pe.resolve(this.mutationQueue.length===0)}addMutationBatch(e,t,s,r){const i=this.gs;this.gs++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];const a=new eq(i,t,s,r);this.mutationQueue.push(a);for(const l of r)this.u_=this.u_.add(new lr(l.key,i)),this.indexManager.addToCollectionParentIndex(e,l.key.path.popLast());return Pe.resolve(a)}lookupMutationBatch(e,t){return Pe.resolve(this.c_(t))}getNextMutationBatchAfterBatchId(e,t){const s=t+1,r=this.l_(s),i=r<0?0:r;return Pe.resolve(this.mutationQueue.length>i?this.mutationQueue[i]:null)}getHighestUnacknowledgedBatchId(){return Pe.resolve(this.mutationQueue.length===0?D4:this.gs-1)}getAllMutationBatches(e){return Pe.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){const s=new lr(t,0),r=new lr(t,Number.POSITIVE_INFINITY),i=[];return this.u_.forEachInRange([s,r],(a=>{const l=this.c_(a.a_);i.push(l)})),Pe.resolve(i)}getAllMutationBatchesAffectingDocumentKeys(e,t){let s=new js(sn);return t.forEach((r=>{const i=new lr(r,0),a=new lr(r,Number.POSITIVE_INFINITY);this.u_.forEachInRange([i,a],(l=>{s=s.add(l.a_)}))})),Pe.resolve(this.E_(s))}getAllMutationBatchesAffectingQuery(e,t){const s=t.path,r=s.length+1;let i=s;bt.isDocumentKey(i)||(i=i.child(""));const a=new lr(new bt(i),0);let l=new js(sn);return this.u_.forEachWhile((c=>{const d=c.key.path;return!!s.isPrefixOf(d)&&(d.length===r&&(l=l.add(c.a_)),!0)}),a),Pe.resolve(this.E_(l))}E_(e){const t=[];return e.forEach((s=>{const r=this.c_(s);r!==null&&t.push(r)})),t}removeMutationBatch(e,t){yt(this.h_(t.batchId,"removed")===0,55003),this.mutation
vendor: 6,906 bytes, line 42
42Queue.shift();let s=this.u_;return Pe.forEach(t.mutations,(r=>{const i=new lr(r.key,t.batchId);return s=s.delete(i),this.referenceDelegate.markPotentiallyOrphaned(e,r.key)})).next((()=>{this.u_=s}))}bs(e){}containsKey(e,t){const s=new lr(t,0),r=this.u_.firstAfterOrEqual(s);return Pe.resolve(t.isEqual(r&&r.key))}performConsistencyCheck(e){return this.mutationQueue.length,Pe.resolve()}h_(e,t){return this.l_(e)}l_(e){return this.mutationQueue.length===0?0:e-this.mutationQueue[0].batchId}c_(e){const t=this.l_(e);return t<0||t>=this.mutationQueue.length?null:this.mutationQueue[t]}}class mq{constructor(e){this.T_=e,this.docs=(function(){return new Zn(bt.comparator)})(),this.size=0}setIndexManager(e){this.indexManager=e}addEntry(e,t){const s=t.key,r=this.docs.get(s),i=r?r.size:0,a=this.T_(t);return this.docs=this.docs.insert(s,{document:t.mutableCopy(),size:a}),this.size+=a-i,this.indexManager.addToCollectionParentIndex(e,s.path.popLast())}removeEntry(e){const t=this.docs.get(e);t&&(this.docs=this.docs.remove(e),this.size-=t.size)}getEntry(e,t){const s=this.docs.get(t);return Pe.resolve(s?s.document.mutableCopy():Or.newInvalidDocument(t))}getEntries(e,t){let s=Ei();return t.forEach((r=>{const i=this.docs.get(r);s=s.insert(r,i?i.document.mutableCopy():Or.newInvalidDocument(r))})),Pe.resolve(s)}getAllEntries(e){let t=Ei();return this.docs.forEach(((s,r)=>{t=t.insert(s,r.document)})),Pe.resolve(t)}getDocumentsMatchingQuery(e,t,s,r){let i,a;Ys(t)?(i=bn.fromString(zx(t)),a=h=>Wx(t,h)):(i=t.path,a=h=>Nx(t,h));let l=Ei();const c=new bt(i.child("__id-9223372036854775808__")),d=this.docs.getIteratorFrom(c);for(;d.hasNext();){const{key:h,value:{document:p}}=d.getNext();if(!i.isPrefixOf(h.path))break;h.path.length>i.length+1||HH($H(p),s)<=0||(r.has(p.key)||a(p))&&(l=l.insert(p.key,p.mutableCopy()))}return Pe.resolve(l)}getAllFromCollectionGroup(e,t,s,r){_t(9500)}P_(e,t){return Pe.forEach(this.docs,(s=>t(s)))}newChangeBuffer(e){return new gq(this)}getSize(e){return Pe.resolve(this.size)}}class gq extends lq{constructor(e){super(),this.zs=e}applyChanges(e){const t=[];return this.changes.forEach(((s,r)=>{r.isValidDocument()?t.push(this.zs.addEntry(e,r)):this.zs.removeEntry(s)})),Pe.waitFor(t)}getFromCache(e,t){return this.zs.getEntry(e,t)}getAllFromCache(e,t){return this.zs.getEntries(e,t)}}class xq{constructor(e){this.persistence=e,this.R_=new Nd((t=>d9(t)),h9),this.lastRemoteSnapshotVersion=Vt.min(),this.highestTargetId=0,this.I_=0,this.A_=new i6,this.targetCount=0,this.V_=au.xs()}forEachTarget(e,t){return this.R_.forEach(((s,r)=>t(r))),Pe.resolve()}getLastRemoteSnapshotVersion(e){return Pe.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return Pe.resolve(this.I_)}allocateTargetId(e){return this.highestTargetId=this.V_.next(),Pe.resolve(this.highestTargetId)}setTargetsMetadata(e,t,s){return s&&(this.lastRemoteSnapshotVersion=s),t>this.I_&&(this.I_=t),Pe.resolve()}Ms(e){this.R_.set(e.target,e);const t=e.targetId;t>this.highestTargetId&&(this.V_=new au(t),this.highestTargetId=t),e.sequenceNumber>this.I_&&(this.I_=e.sequenceNumber)}addTargetData(e,t){return this.Ms(t),this.targetCount+=1,Pe.resolve()}updateTargetData(e,t){return this.Ms(t),Pe.resolve()}removeTargetData(e,t){return this.R_.delete(t.target),this.A_.s_(t.targetId),this.targetCount-=1,Pe.resolve()}removeTargets(e,t,s){let r=0;const i=[];return this.R_.forEach(((a,l)=>{l.sequenceNumber<=t&&s.get(l.targetId)===null&&(this.R_.delete(a),i.push(this.removeMatchingKeysForTargetId(e,l.targetId)),r++)})),Pe.waitFor(i).next((()=>r))}getTargetCount(e){return Pe.resolve(this.targetCount)}getTargetData(e,t){const s=this.R_.get(t)||null;return Pe.resolve(s)}addMatchingKeys(e,t,s){return this.A_.n_(t,s),Pe.resolve()}removeMatchingKeys(e,t,s){this.A_.i_(t,s);const r=this.persistence.referenceDelegate,i=[];return r&&t.forEach((a=>{i.push(r.markPotentiallyOrphaned(e,a))})),Pe.waitFor(i)}removeMatchingKeysForTargetId(e,t){return this.A_.s_(t),Pe.resolve()}getMatchingKeysForTargetId(e,t){const s=this.A_.o_(t);return Pe.resolve(s)}containsKey(e,t){return Pe.resolve(this.A_.containsKey(t))}}class p9{constructor(e,t){this.d_={},this.overlays={},this.f_=new Ex(0),this.m_=!1,this.m_=!0,this.p_=new fq,this.referenceDelegate=e(this),this.g_=new xq(this),this.indexManager=new rq,this.remoteDocumentCache=(function(r){return new mq(r)})((s=>this.referenceDelegate.y_(s))),this.serializer=new nq(t),this.w_=new dq(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.m_=!1,Promise.resolve()}get started(){return this.m_}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let t=this.overlays[e.toKey()];return t||(t=new hq,this.overlays[e.toKey()]=t),t}getMutationQueue(e,t){let s=this.d_[e.toKey()];return s||(s=new pq(t,this.referenceDelegate),this.d_[e.toKey()]=s),s}getGlobalsCache(){return this.p_}getTargetCache(){return this.g_}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.w_}runTransaction(e,t,s){Ze("MemoryPersistence","Starting transaction:",e);const r=new yq(this.f_.next());return this.referenceDelegate.b_(),s(r).next((i=>this.referenceDelegate.v_(r).next((()=>i)))).toPromise().then((i=>(r.raiseOnCommittedEvent(),i)))}S_(e,t){return Pe.or(Object.values(this.d_).map((s=>()=>s.containsKey(e,t))))}}class yq extends GH{constructor(e){super(),this.currentSequenceNumber=e}}class a6{constructor(e){this.persistence=e,this.D_=new i6,this.x_=null}static C_(e){return new a6(e)}get F_(){if(this.x_)return this.x_;throw _t(60996)}addReference(e,t,s){return this.D_.addReference(s,t),this.F_.delete(s.toString()),Pe.resolve()}removeReference(e,t,s){return this.D_.removeReference(s,t),this.F_.add(s.toString()),Pe.resolve()}markPotentiallyOrphaned(e,t){return this.F_.add(t.toString()),Pe.resolve()}removeTarget(e,t){this.D_.s_(t.targetId).forEach((r=>this.F_.add(r.toString())));const s=this.persistence.getTargetCache();return s.getMatchingKeysForTargetId(e,t.targetId).next((r=>{r.forEach((i=>this.F_.add(i.toString())))})).next((()=>s.removeTargetData(e,t)))}b_(){this.x_=new Set}v_(e){const t=this.persistence.getRemoteDocumentCache().newChangeBuffer();return Pe.forEach(this.F_,(s=>{const r=bt.fromPath(s);return this.O_(e,r).next((i=>{i||t.removeEntry(r,Vt.min())}))})).next((()=>(this.x_=null,t.apply(e))))}updateLimboDocument(e,t){return this.O_(e,t).next((s=>{s?this.F_.delete(t.toString()):this.F_.add(t.toString())}))}y_(e){return 0}O_(e,t){return Pe.or([()=>Pe.resolve(this.D_.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.S_(e,t)])}}class w1{constructor(e,t){this.persistence=e,this.M_=new Nd((s=>QH(s.path)),((s,r)=>s.isEqual(r))),this.garbageCollector=xG(this,t)}static C_(e,t){return new w1(e,t)}b_(){}v_(e){return Pe.resolve()}forEachTarget(e,t){return this.persistence.getTargetCache().forEac
42hTarget(e,t)}lr(e){const t=this.Ls(e);return this.persistence.getTargetCache().getTargetCount(e).next((s=>t.next((r=>s+r))))}Ls(e){let t=0;return this.Er(e,(s=>{t++})).next((()=>t))}Er(e,t){return Pe.forEach(this.M_,((s,r)=>this.Us(e,s,r).next((i=>i?Pe.resolve():t(r)))))}removeTargets(e,t,s){return this.persistence.getTargetCache().removeTargets(e,t,s)}removeOrphanedDocuments(e,t){let s=0;const r=this.persistence.getRemoteDocumentCache(),i=r.newChangeBuffer();return r.P_(e,(a=>this.Us(e,a,t).next((l=>{l||(s++,i.removeEntry(a,Vt.min()))})))).next((()=>i.apply(e))).next((()=>s))}markPotentiallyOrphaned(e,t){return this.M_.set(t,e.currentSequenceNumber),Pe.resolve()}removeTarget(e,t){const s=t.withSequenceNumber(e.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(e,s)}addReference(e,t,s){return this.M_.set(s,e.currentSequenceNumber),Pe.resolve()}removeReference(e,t,s){return this.M_.set(s,e.currentSequenceNumber),Pe.resolve()}updateLimboDocument(e,t){return this.M_.set(t,e.currentSequenceNumber),Pe.resolve()}y_(e){let t=e.key.toString().length;return e.isFoundDocument()&&(t+=I0(e.data.value)),t}Us(e,t,s){return Pe.or([()=>this.persistence.S_(e,t),()=>this.persistence.getTargetCache().containsKey(e,t),()=>{const r=this.M_.get(t);return Pe.resolve(r!==void 0&&r>s)}])}getCacheSize(e){return this.persistence.getRemoteDocumentCache().getSize(e)}}class o6{constructor(e,t,s,r){this.targetId=e,this.fromCache=t,this.wo=s,this.bo=r}static vo(e,t){let s=en(),r=en();for(const i of t.docChanges)switch(i.type){case 0:s=s.add(i.doc.key);break;case 1:r=r.add(i.doc.key)}return new o6(e,t.fromCache,s,r)}}function vq(n,e){return bt.comparator(n.key,e.key)}class bq{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(e){this._documentReadCount+=e}}class wq{constructor(){this.So=!1,this.Do=!1,this.xo=100,this.Co=(function(){return NU()?8:KH(Ur())>0?6:4})()}initialize(e,t){this.Fo=e,this.indexManager=t,this.So=!0}getDocumentsMatchingQuery(e,t,s,r){const i={result:null};return this.Oo(e,t).next((a=>{i.result=a})).next((()=>{if(!i.result)return this.Mo(e,t,r,s).next((a=>{i.result=a}))})).next((()=>{if(i.result)return;const a=new bq;return this.No(e,t,a).next((l=>{if(i.result=l,this.Do)return this.Lo(e,t,a,l.size)}))})).next((()=>i.result))}Lo(e,t,s,r){return Ys(t)?Pe.resolve():s.documentReadCount<this.xo?(vh()<=on.DEBUG&&Ze("QueryEngine","SDK will not create cache indexes for query:",Np(t),"since it only creates cache indexes for collection contains","more than or equal to",this.xo,"documents"),Pe.resolve()):(vh()<=on.DEBUG&&Ze("QueryEngine","Query:",Np(t),"scans",s.documentReadCount,"local documents and returns",r,"documents as results."),s.documentReadCount>this.Co*r?(vh()<=on.DEBUG&&Ze("QueryEngine","The SDK decides to create cache indexes for query:",Np(t),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(e,Ho(t))):Pe.resolve())}Oo(e,t){if(Ys(t))return Pe.resolve(null);let s=t;if(t5(s))return Pe.resolve(null);let r=Ho(s);return this.indexManager.getIndexType(e,r).next((i=>i===0?null:(s.limit!==null&&i===1&&(s=g1(s,null,"F"),r=Ho(s)),this.indexManager.getDocumentsMatchingTarget(e,r).next((a=>{const l=en(...a);return this.Fo.getDocuments(e,l).next((c=>this.indexManager.getMinOffset(e,r).next((d=>{const h=this.Bo(s,c);return this.Uo(s,h,l,d.readTime)?this.Oo(e,g1(s,null,"F")):this.ko(e,h,s,d)}))))})))))}Mo(e,t,s,r){return(Ys(t)?(function(a){for(const l of a.stages){if(l instanceof bd||l instanceof g5)return!1;if(l instanceof Bx){if(l.condition instanceof JR&&l.condition._expr.name==="exists"&&l.condition._expr.params[0]instanceof Tf&&l.condition._expr.params[0].fieldName===Vo)continue;return!1}}return!0})(t):t5(t))||r.isEqual(Vt.min())?Pe.resolve(null):this.Fo.getDocuments(e,s).next((i=>{const a=this.Bo(t,i);return this.Uo(t,a,s,r)?Pe.resolve(null):(vh()<=on.DEBUG&&Ze("QueryEngine","Re-using previous result from %s to execute query: %s",r.toString(),x5(t)),this.ko(e,a,t,zH(r,em)).next((l=>l)))}))}Bo(e,t){let s,r;return Ys(e)?(s=new js(vq),r=i=>Wx(e,i)):(s=new js(F4(e)),r=i=>Nx(e,i)),t.forEach(((i,a)=>{r(a)&&(s=s.add(a))})),s}Uo(e,t,s,r){if(Ys(e))return(function(l){return l.stages.some((c=>c instanceof bd||c instanceof g5))})(e);if(e.limit===null)return!1;if(s.size!==t.size)return!0;const i=e.limitType==="F"?t.last():t.first();return!!i&&(i.hasPendingWrites||i.version.compareTo(r)>0)}No(e,t,s){return vh()<=on.DEBUG&&Ze("QueryEngine","Using full collection scan to execute query:",x5(t)),this.Fo.getDocumentsMatchingQuery(e,t,Zc.min(),s)}ko(e,t,s,r){return this.Fo.getDocumentsMatchingQuery(e,s,r).next((i=>(t.forEach((a=>{i=i.insert(a.key,a)})),i)))}}const l6="LocalStore",Sq=3e8;class Eq{constructor(e,t,s,r){this.persistence=e,this.qo=t,this.serializer
42=r,this.$o=new Zn(sn),this.Ko=new Nd((i=>d9(i)),h9),this.Wo=new Map,this.Qo=e.getRemoteDocumentCache(),this.g_=e.getTargetCache(),this.w_=e.getBundleCache(),this.Go(s)}Go(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new uq(this.Qo,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.Qo.setIndexManager(this.indexManager),this.qo.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction("Collect garbage","readwrite-primary",(t=>e.collect(t,this.$o)))}}function Tq(n,e,t,s){return new Eq(n,e,t,s)}async function m9(n,e){const t=$t(n);return await t.persistence.runTransaction("Handle user change","readonly",(s=>{let r;return t.mutationQueue.getAllMutationBatches(s).next((i=>(r=i,t.Go(e),t.mutationQueue.getAllMutationBatches(s)))).next((i=>{const a=[],l=[];let c=en();for(const d of r){a.push(d.batchId);for(const h of d.mutations)c=c.add(h.key)}for(const d of i){l.push(d.batchId);for(const h of d.mutations)c=c.add(h.key)}return t.localDocuments.getDocuments(s,c).next((d=>({zo:d,removedBatchIds:a,addedBatchIds:l})))}))}))}function _q(n,e){const t=$t(n);return t.persistence.runTransaction("Acknowledge batch","readwrite-primary",(s=>{const r=e.batch.keys(),i=t.Qo.newChangeBuffer({trackRemovals:!0});return(function(l,c,d,h){const p=d.batch,m=p.keys();let y=Pe.resolve();return m.forEach((x=>{y=y.next((()=>h.getEntry(c,x))).next((w=>{const S=d.docVersions.get(x);yt(S!==null,48541),w.version.compareTo(S)<0&&(p.applyToRemoteDocument(w,d),w.isValidDocument()&&(w.setReadTime(d.commitVersion),h.addEntry(w)))}))})),y.next((()=>l.mutationQueue.removeMutationBatch(c,p)))})(t,s,e,i).next((()=>i.apply(s))).next((()=>t.mutationQueue.performConsistencyCheck(s))).next((()=>t.documentOverlayCache.removeOverlaysForBatchId(s,r,e.batch.batchId))).next((()=>t.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(s,(function(l){let c=en();for(let d=0;d<l.mutationResults.length;++d)l.mutationResults[d].transformResults.length>0&&(c=c.add(l.batch.mutations[d].key));return c})(e)))).next((()=>t.localDocuments.getDocuments(s,r)))}))}function g9(n){const e=$t(n);return e.persistence.runTransaction("Get last remote snapshot version","readonly",(t=>e.g_.getLastRemoteSnapshotVersion(t)))}function Iq(n,e){const t=$t(n),s=e.snapshotVersion;let r=t.$o;return t.persistence.runTransaction("Apply remote event","readwrite-primary",(i=>{const a=t.Qo.newChangeBuffer({trackRemovals:!0});r=t.$o;const l=[];
42e.targetChanges.forEach(((h,p)=>{const m=r.get(p);if(!m)return;l.push(t.g_.removeMatchingKeys(i,h.removedDocuments,p).next((()=>t.g_.addMatchingKeys(i,h.addedDocuments,p))));let y=m.withSequenceNumber(i.currentSequenceNumber);e.targetMismatches.get(p)!==null?y=y.withResumeToken(Os.EMPTY_BYTE_STRING,Vt.min()).withLastLimboFreeSnapshotVersion(Vt.min()):h.resumeToken.approximateByteSize()>0&&(y=y.withResumeToken(h.resumeToken,s)),r=r.insert(p,y),(function(w,S,_){return w.resumeToken.approximateByteSize()===0||S.snapshotVersion.toMicroseconds()-w.snapshotVersion.toMicroseconds()>=Sq?!0:_.addedDocuments.size+_.modifiedDocuments.size+_.removedDocuments.size>0})(m,y,h)&&l.push(t.g_.updateTargetData(i,y))}));let c=Ei(),d=en();if(e.documentUpdates.forEach((h=>{e.resolvedLimboDocuments.has(h)&&l.push(t.persistence.referenceDelegate.updateLimboDocument(i,h))})),l.push(Aq(i,a,e.documentUpdates).next((h=>{c=h.jo,d=h.Ho}))),!s.isEqual(Vt.min())){const h=t.g_.getLastRemoteSnapshotVersion(i).next((p=>t.g_.setTargetsMetadata(i,i.currentSequenceNumber,s)));l.push(h)}return Pe.waitFor(l).next((()=>a.apply(i))).next((()=>t.localDocuments.getLocalViewOfDocuments(i,c,d))).next((()=>c))})).then((i=>(t.$o=r,i)))}function Aq(n,e,t){let s=en(),r=en();return t.forEach((i=>s=s.add(i))),e.getEntries(n,s).next((i=>{let a=Ei();return t.forEach(((l,c)=>{const d=i.get(l);c.isFoundDocument()!==d.isFoundDocument()&&(r=r.add(l)),c.isNoDocument()&&c.version.isEqual(Vt.min())?(e.removeEntry(l,c.readTime),a=a.insert(l,c)):!d.isValidDocument()||c.version.compareTo(d.version)>0||c.version.compareTo(d.version)===0&&d.hasPendingWrites?(e.addEntry(c),a=a.insert(l,c)):Ze(l6,"Ignoring outdated watch update for ",l,". Current version:",d.version," Watch version:",c.version)})),{jo:a,Ho:r}}))}function Cq(n,e){const t=$t(n);return t.persistence.runTransaction("Get next mutation batch","readonly",(s=>(e===void 0&&(e=D4),t.mutationQueue.getNextMutationBatchAfterBatchId(s,e))))}function kq(n,e){const t=$t(n);return t.persistence.runTransaction("Allocate target","readwrite",(s=>{let r;return t.g_.getTargetData(s,e).next((i=>i?(r=i,Pe.resolve(r)):t.g_.allocateTargetId(s).next((a=>(r=new Ol(e,a,"TargetPurposeListen",s.currentSequenceNumber),t.g_.addTargetData(s,r).next((()=>r)))))))})).then((s=>{const r=t.$o.get(s.targetId);return(r===null||s.snapshotVersion.compareTo(r.snapshotVersion)>0)&&(t.$o=t.$o.insert(s.targetId,s),t.Ko.set(e,s.targetId)),s}))}async function zb(n,e,t){const s=$t(n),r=s.$o.get(e),i=t?"readwrite":"readwrite-primary";try{t||await s.persistence.runTransaction("Release target",i,(a=>s.persistence.referenceDelegate.removeTarget(a,r)))}catch(a){if(!Sf(a))throw a;Ze(l6,`Failed to update sequence numbers for target ${e}: ${a}`)}s.$o=s.$o.remove(e),s.Ko.delete(r.target)}function y5(n,e,t){const s=$t(n);let r=Vt.min(),i=en();return s.persistence.runTransaction("Execute query","readwrite",(a=>(function(c,d,h){const p=$t(c),m=p.Ko.get(h);return m!==void 0?Pe.resolve(p.$o.get(m)):p.g_.getTargetData(d,h)})(s,a,Ys(e)?e:Ho(e)).next((l=>{if(l)return r=l.lastLimboFreeSnapshotVersion,s.g_.getMatchingKeysForTargetId(a,l.targetId).next((c=>{i=c}))})).next((()=>s.qo.getDocumentsMatchingQuery(a,e,t?r:Vt.min(),t?i:en()))).next((l=>(Rq(s,l),{documents:l,Jo:i})))))}function Rq(n,e){e.forEach(((t,s)=>{const r=s.key.getCollectionGroup(),i=n.Wo.get(r)||Vt.min();s.readTime.compareTo(i)>0&&n.Wo.set(r,s.readTime)}))}class v5{constructor(){this.activeTargetIds=LW()}na(e){this.activeTargetIds=this.activeTargetIds.add(e)}ra(e){this.activeTargetIds=this.activeTargetIds.delete(e)}ta(){const e={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(e)}}class Pq{constructor(){this.Ua=new v5,this.ka={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}
42updateMutationState(e,t,s){}addLocalQueryTarget(e,t=!0){return t&&this.Ua.na(e),this.ka[e]||"not-current"}updateQueryState(e,t,s){this.ka[e]=t}removeLocalQueryTarget(e){this.Ua.ra(e)}isLocalQueryTarget(e){return this.Ua.activeTargetIds.has(e)}clearQueryState(e){delete this.ka[e]}getAllActiveQueryTargets(){return this.Ua.activeTargetIds}isActiveQueryTarget(e){return this.Ua.activeTargetIds.has(e)}start(){return this.Ua=new v5,Promise.resolve()}handleUserChange(e,t,s){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}}function av(){return typeof document<"u"?document:null}class Nq{constructor(e,t){this.asyncQueue=e,this.onlineStateHandler=t,this.state="Unknown",this.qa=0,this.$a=null,this.Ka=!0}Wa(){this.qa===0&&(this.Qa("Unknown"),this.$a=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,(()=>(this.$a=null,this.Ga("Backend didn't respond within 10 seconds."),this.Qa("Offline"),Promise.resolve()))))}za(e){this.state==="Online"?this.Qa("Unknown"):(this.qa++,this.qa>=1&&(this.ja(),this.Ga(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.Qa("Offline")))}set(e){this.ja(),this.qa=0,e==="Online"&&(this.Ka=!1),this.Qa(e)}Qa(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}Ga(e){const t=`Could not reach Cloud Firestore backend. ${e} 43This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.`;this.Ka?(Kl(t),this.Ka=!1):Ze("OnlineStateTracker",t)}ja(){this.$a!==null&&(this.$a.cancel(),this.$a=null)}}const Jo="RemoteStore";class Lq{constructor(e,t,s,r,i){this.localStore=e,this.datastore=t,this.asyncQueue=s,this.remoteSyncer={},this.Ha=[],this.Ja=new Map,this.Ya=new Map,this.Za=new Map,this.Xa=new au(1e3),this.eu=new au(1001),this.tu=new Set,this.nu=[],this.ru=i,this.ru.bt((a=>{s.enqueueAndForget((async()=>{jd(this)&&(Ze(Jo,"Restarting streams for network reachability change."),await(async function(c){const d=$t(c);d.tu.add(4),await Fm(d),d.iu.set("Unknown"),d.tu.delete(4),await Gx(d)})(this))}))})),this.iu=new Nq(s,r)}}async function Gx(n){if(jd(n))for(const e of n.nu)await e(!0)}async function Fm(n){for(const e of n.nu)await e(!1)}function $b(n,e){return n.Ya.get(e)||void 0}function x9(n,e){const t=$t(n),s=$b(t,e.targetId);if(s!==void 0&&t.Ja.has(s))return;const r=(function(l,c){const d=$b(l,c);d!==void 0&&l.Za.delete(d);const h=(function(m,y){return y%2!=0?m.eu.next():m.Xa.next()})(l,c);return l.Ya.set(c,h),l.Za.set(h,c),h})(t,e.targetId);Ze(Jo,"remoteStoreListen mapping SDK target ID to remote",e.targetId,r);const i=new Ol(e.target,r,e.purpose,e.sequenceNumber,e.snapshotVersion,e.lastLimboFreeSnapshotVersion,e.resumeToken);t.Ja.set(r,i),h6(t)?d6(t):Cf(t).Fn()&&u6(t,i)}function c6(n,e){const t=$t(n),s=Cf(t),r=$b(t,e);Ze(Jo,"remoteStoreUnlisten removing mapping of SDK target ID to remote",e,r),t.Ja.delete(r),t.Ya.delete(e),t.Za.delete(r),s.Fn()&&y9(t,r),t.Ja.size===0&&(s.Fn()?s.Nn():jd(t)&&t.iu.set("Unknown"))}function u6(n,e){if(n.su.We(e.targetId),e.resumeToken.approximateByteSize()>0||e.snapshotVersion.compareTo(Vt.min())>0){const t=n.Za.get(e.targetId);if(t===void 0)return void Ze(Jo,"SDK target ID not found for remote ID: "+e.targetId);const s=n.remoteSyncer.getRemoteKeysForTarget(t).size;e=e.withExpectedCount(s)}Cf(n).jn(e)}function y9(n,e){n.su.We(e),Cf(n).Hn(e)}function d6(n){n.su=new OW({getRemoteKeysForTarget:e=>{const t=n.Za.get(e);return t!==void 0?n.remoteSyncer.getRemoteKeysForTarget(t):en()},dt:e=>n.Ja.get(e)||null,Tt:()=>n.datastore.serializer.databaseId}),Cf(n).start(),n.iu.Wa()}function h6(n){return jd(n)&&!Cf(n).Cn()&&n.Ja.size>0}function jd(n){return $t(n).tu.size===0}function v9(n){n.su=void 0}async function Dq(n){n.iu.set("Online")}async function jq(n){n.Ja.forEach(((e,t)=>{u6(n,e)}))}async function Oq(n,e){v9(n),h6(n)?(n.iu.za(e),d6(n)):n.iu.set("Unknown")}async function Mq(n,e,t){if(n.iu.set("Online"),e instanceof _R&&e.state===2&&e.cause)try{await(async function(r,i){const a=i.cause;for(const l of i.targetIds){if(r.Ja.has(l)){const c=r.Za.get(l);c!==void 0&&(await r.remoteSyncer.rejectListen(c,a),r.Ya.delete(c),r.Za.delete(l)),r.Ja.delete(l)}r.su.removeTarget(l)}})(n,e)}catch(s){Ze(Jo,"Failed to remove targets %s: %s ",e.targetIds.join(","),s),await S1(n,s)}else if(e instanceof C0?n.su.et(e):e instanceof TR?n.su.ot(e):n.su.rt(e),!t.isEqual(Vt.min()))try{const s=await g9(n.localStore);t.compareTo(s)>=0&&await(function(i,a){const l=i.su.Rt(a);
43l.targetChanges.forEach(((d,h)=>{if(d.resumeToken.approximateByteSize()>0){const p=i.Ja.get(h);p&&i.Ja.set(h,p.withResumeToken(d.resumeToken,a))}})),l.targetMismatches.forEach(((d,h)=>{const p=i.Ja.get(d);if(!p)return;i.Ja.set(d,p.withResumeToken(Os.EMPTY_BYTE_STRING,p.snapshotVersion)),y9(i,d);const m=new Ol(p.target,d,h,p.sequenceNumber);u6(i,m)}));const c=(function(h,p){const m=new Map;p.targetChanges.forEach(((x,w)=>{const S=h.Za.get(w);S!==void 0&&m.set(S,x)}));let y=new Zn(sn);return p.targetMismatches.forEach(((x,w)=>{const S=h.Za.get(x);S!==void 0&&(y=y.insert(S,w))})),new jm(p.snapshotVersion,m,y,p.documentUpdates,p.augmentedDocumentUpdates,p.resolvedLimboDocuments)})(i,l);return i.remoteSyncer.applyRemoteEvent(c)})(n,t)}catch(s){Ze(Jo,"Failed to raise snapshot:",s),await S1(n,s)}}async function S1(n,e,t){if(!Sf(e))throw e;n.tu.add(1),await Fm(n),n.iu.set("Offline"),t||(t=()=>g9(n.localStore)),n.asyncQueue.enqueueRetryable((async()=>{Ze(Jo,"Retrying IndexedDB access"),await t(),n.tu.delete(1),await Gx(n)}))}function b9(n,e){return e().catch((t=>S1(n,t,e)))}async function Kx(n){const e=$t(n),t=ou(e);let s=e.Ha.length>0?e.Ha[e.Ha.length-1].batchId:D4;for(;Fq(e);)try{const r=await Cq(e.localStore,s);if(r===null){e.Ha.length===0&&t.Nn();break}s=r.batchId,Uq(e,r)}catch(r){await S1(e,r)}w9(e)&&S9(e)}function Fq(n){return jd(n)&&n.Ha.length<10}function Uq(n,e){n.Ha.push(e);const t=ou(n);t.Fn()&&t.Jn&&t.Yn(e.mutations)}function w9(n){return jd(n)&&!ou(n).Cn()&&n.Ha.length>0}function S9(n){ou(n).start()}async function Vq(n){ou(n).er()}async function Bq(n){const e=ou(n);for(const t of n.Ha)e.Yn(t.mutations)}async function zq(n,e,t){const s=n.Ha.shift(),r=r6.from(s,e,t);await b9(n,(()=>n.remoteSyncer.applySuccessfulWrite(r))),await Kx(n)}async function $q(n,e){e&&ou(n).Jn&&await(async function(s,r){if((function(a){return CW(a)&&a!==Ce.ABORTED})(r.code)){const i=s.Ha.shift();ou(s).Mn(),await b9(s,(()=>s.remoteSyncer.rejectFailedWrite(i.batchId,r))),await Kx(s)}})(n,e),w9(n)&&S9(n)}async function b5(n,e){const t=$t(n);t.asyncQueue.verifyOperationInProgress(),Ze(Jo,"RemoteStore received new credentials");const s=jd(t);t.tu.add(3),await Fm(t),s&&t.iu.set("Unknown"),await t.remoteSyncer.handleCredentialChange(e),t.tu.delete(3),await Gx(t)}async function Hq(n,e){const t=$t(n);e?(t.tu.delete(2),await Gx(t)):e||(t.tu.add(2),await Fm(t),t.iu.set("Unknown"))}function Cf(n){return n._u||(n._u=(function(t,s,r){const i=$t(t);return i.nr(),new aG(s,i.connection,i.authCredentials,i.appCheckCredentials,i.serializer,r)})(n.datastore,n.asyncQueue,{Qt:Dq.bind(null,n),zt:jq.bind(null,n),Ht:Oq.bind(null,n),zn:Mq.bind(null,n)}),n.nu.push((async e=>{e?(n._u.Mn(),h6(n)?d6(n):n.iu.set("Unknown")):(await n._u.stop(),v9(n))}))),n._u}function ou(n){return n.ou||(n.ou=(function(t,s,r){const i=$t(t);return i.nr(),new oG(s,i.connection,i.authCredentials,i.appCheckCredentials,i.serializer,r)})(n.datastore,n.asyncQueue,{Qt:()=>Promise.resolve(),zt:Vq.bind(null,n),Ht:$q.bind(null,n),Zn:Bq.bind(null,n),Xn:zq.bind(null,n)}),n.nu.push((async e=>{e?(n.ou.Mn(),await Kx(n)):(await n.ou.stop(),n.Ha.length>0&&(Ze(Jo,`Stopping write stream with ${n.Ha.length} pending writes`),n.Ha=[]))}))),n.ou}class f6{constructor(e,t,s,r,i){this.asyncQueue=e,this.timerId=t,this.targetTimeMs=s,this.op=r,this.removalCallback=i,this.deferred=new Vl,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch((a=>{}))}get promise(){return this.deferred.promise}static createAndSchedule(e,t,s,r,i){const a=Date.now()+s,l=new f6(e,t,a,r,i);return l.start(s),l}start(e){this.timerHandle=setTimeout((()=>this.handleDelayElapsed()),e)}skipDelay(){return this.handleDelayElapsed()}cancel(e){this.timerHandle!==null&&(this.clearTimeout(),this.deferred.reject(new Xe(Ce.CANCELLED,"Operation cancelled"+(e?": "+e:""))))}handleDelayElapsed(){this.asyncQueue.enqueueAndForget((()=>this.timerHandle!==null?(this.clearTimeout(),this.op().then((e=>this.deferred.resolve(e)))):Promise.resolve()))}clearTimeout(){this.timerHandle!==null&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}}function p6(n,e){if(Kl("AsyncQueue",`${e}: ${n}`),Sf(n))return new Xe(Ce.UNAVAILABLE,`${e}: ${n}`);throw n}
43class id{static emptySet(e){return new id(e.comparator)}constructor(e){this.comparator=e?(t,s)=>e(t,s)||bt.comparator(t.key,s.key):(t,s)=>bt.comparator(t.key,s.key),this.keyedMap=bh(),this.sortedSet=new Zn(this.comparator)}has(e){return this.keyedMap.get(e)!=null}get(e){return this.keyedMap.get(e)}first(){return this.sortedSet.minKey()}last(){return this.sortedSet.maxKey()}isEmpty(){return this.sortedSet.isEmpty()}indexOf(e){const t=this.keyedMap.get(e);return t?this.sortedSet.indexOf(t):-1}get size(){return this.sortedSet.size}forEach(e){this.sortedSet.inorderTraversal(((t,s)=>(e(t),!1)))}add(e){const t=this.delete(e.key);return t.copy(t.keyedMap.insert(e.key,e),t.sortedSet.insert(e,null))}delete(e){const t=this.get(e);return t?this.copy(this.keyedMap.remove(e),this.sortedSet.remove(t)):this}isEqual(e){if(!(e instanceof id)||this.size!==e.size)return!1;const t=this.sortedSet.getIterator(),s=e.sortedSet.getIterator();for(;t.hasNext();){const r=t.getNext().key,i=s.getNext().key;if(!r.isEqual(i))return!1}return!0}toString(){const e=[];return this.forEach((t=>{e.push(t.toString())})),e.length===0?"DocumentSet ()":`DocumentSet ( 44 `+e.join(` 45`)+` 46)`}copy(e,t){const s=new id;return s.comparator=this.comparator,s.keyedMap=e,s.sortedSet=t,s}}class w5{constructor(){this.au=new Zn(bt.comparator)}track(e){const t=e.doc.key,s=this.au.get(t);s?e.type!==0&&s.type===3?this.au=this.au.insert(t,e):e.type===3&&s.type!==1?this.au=this.au.insert(t,{type:s.type,doc:e.doc}):e.type===2&&s.type===2?this.au=this.au.insert(t,{type:2,doc:e.doc}):e.type===2&&s.type===0?this.au=this.au.insert(t,{type:0,doc:e.doc}):e.type===1&&s.type===0?this.au=this.au.remove(t):e.type===1&&s.type===2?this.au=this.au.insert(t,{type:1,doc:s.doc}):e.type===0&&s.type===1?this.au=this.au.insert(t,{type:2,doc:e.doc}):_t(63341,{ft:e,uu:s}):this.au=this.au.insert(t,e)}cu(){const e=[];return this.au.inorderTraversal(((t,s)=>{e.push(s)})),e}}class nf{constructor(e,t,s,r,i,a,l,c,d){this.query=e,this.docs=t,this.oldDocs=s,this.docChanges=r,this.mutatedKeys=i,this.fromCache=a,this.syncStateChanged=l,this.excludesMetadataChanges=c,this.hasCachedResults=d}static fromInitialDocuments(e,t,s,r,i){const a=[];return t.forEach((l=>{a.push({type:0,doc:l})})),new nf(e,t,id.emptySet(t),a,s,r,!0,!1,i)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(e){if(!(this.fromCache===e.fromCache&&this.hasCachedResults===e.hasCachedResults&&this.syncStateChanged===e.syncStateChanged&&this.mutatedKeys.isEqual(e.mutatedKeys)&&Hx(this.query,e.query)&&this.docs.isEqual(e.docs)&&this.oldDocs.isEqual(e.oldDocs)))return!1;const t=this.docChanges,s=e.docChanges;if(t.length!==s.length)return!1;for(let r=0;r<t.length;r++)if(t[r].type!==s[r].type||!t[r].doc.isEqual(s[r].doc))return!1;return!0}}class Wq{constructor(){this.lu=void 0,this.Eu=[]}hu(){return this.Eu.some((e=>e.Tu()))}}class Gq{constructor(){this.queries=S5(),this.onlineState="Unknown",this.Pu=new Set}terminate(){(function(t,s){const r=$t(t),i=r.queries;r.queries=S5(),i.forEach(((a,l)=>{for(const c of l.Eu)c.onError(s)}))})(this,new Xe(Ce.ABORTED,"Firestore shutting down"))}}function S5(){return new Nd((n=>u9(n)),Hx)}async function m6(n,e){const t=$t(n);let s=3;const r=e.query;let i=t.queries.get(r);i?!i.hu()&&e.Tu()&&(s=2):(i=new Wq,s=e.Tu()?0:1);try{switch(s){case 0:i.lu=await t.onListen(r,!0);break;case 1:i.lu=await t.onListen(r,!1);break;case 2:await t.onFirstRemoteStoreListen(r)}}catch(a){const l=p6(a,`Initialization of query '${Ys(e.query)?Bl(e.query):Np(e.query)}' failed`);return void e.onError(l)}t.queries.set(r,i),i.Eu.push(e),e.Ru(t.onlineState),i.lu&&e.Iu(i.lu)&&x6(t)}async function g6(n,e){const t=$t(n),s=e.query;let r=3;const i=t.queries.get(s);if(i){const a=i.Eu.indexOf(e);a>=0&&(i.Eu.splice(a,1),i.Eu.length===0?r=e.Tu()?0:1:!i.hu()&&e.Tu()&&(r=2))}switch(r){case 0:return t.queries.delete(s),t.onUnlisten(s,!0);case 1:return t.queries.delete(s),t.onUnlisten(s,!1);case 2:return t.onLastRemoteStoreUnlisten(s);default:return}}function Kq(n,e){const t=$t(n);let s=!1;for(const r of e){const i=r.query,a=t.queries.get(i);if(a){for(const l of a.Eu)l.Iu(r)&&(s=!0);a.lu=r}}s&&x6(t)}function qq(n,e,t){const s=$t(n),r=s.queries.get(e);if(r)for(const i of r.Eu)i.onError(t);s.queries.delete(e)}function x6(n){n.Pu.forEach((e=>{e.next()}))}var Hb;(function(n){n.Default="default",n.Cache="cache"})(Hb||(Hb={}));class y6{constructor(e,t,s){this.query=e,this.Au=t,this.Vu=!1,this.du=null,this.onlineState="Unknown",this.options=s||{}}Iu(e){if(!this.options.includeMetadataChanges){const s=[];for(const r of e.docChanges)r.type!==3&&s.push(r);e=new nf(e.query,e.docs,e.oldDocs,s,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let t=!1;return this.Vu?this.fu(e)&&(this.Au.next(e),t=!0):this.mu(e,this.onlineState)&&(this.pu(e),t=!0),this.du=e,t}onError(e){this.Au.error(e)}Ru(e){this.onlineState=e;let t=!1;return this.du&&!this.Vu&&this.mu(this.du,e)&&(this.pu(this.du),t=!0),t}mu(e,t){if(!e.fromCache||!this.Tu())return!0;const s=t!=="Offline";
46return(!this.options.waitForSyncWhenOnline||!s)&&(!e.docs.isEmpty()||e.hasCachedResults||t==="Offline")}fu(e){if(e.docChanges.length>0)return!0;const t=this.du&&this.du.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&this.options.includeMetadataChanges===!0}pu(e){e=nf.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.Vu=!0,this.Au.next(e)}Tu(){return this.options.source!==Hb.Cache}}class E9{constructor(e){this.key=e}}class T9{constructor(e){this.key=e}}class Yq{constructor(e,t){this.query=e,this.Ou=t,this.Mu=null,this.hasCachedResults=!1,this.current=!1,this.Nu=en(),this.mutatedKeys=en(),this.Lu=Ys(e)?Bb(e):F4(e),this.Bu=new id(this.Lu)}get Uu(){return this.Ou}ku(e,t){const s=t?t.qu:new w5,r=t?t.Bu:this.Bu;let i=t?t.mutatedKeys:this.mutatedKeys,a=r,l=!1;const[c,d]=this.$u(this.query,r);e.inorderTraversal(((p,m)=>{const y=r.get(p),x=aq(this.query,m)?m:null,w=!!y&&this.mutatedKeys.has(y.key),S=!!x&&(x.hasLocalMutations||this.mutatedKeys.has(x.key)&&x.hasCommittedMutations);let _=!1;y&&x?y.data.isEqual(x.data)?w!==S&&(s.track({type:3,doc:x}),_=!0):this.Ku(y,x)||(s.track({type:2,doc:x}),_=!0,(c&&this.Lu(x,c)>0||d&&this.Lu(x,d)<0)&&(l=!0)):!y&&x?(s.track({type:0,doc:x}),_=!0):y&&!x&&(s.track({type:1,doc:y}),_=!0,(c||d)&&(l=!0)),_&&(x?(a=a.add(x),i=S?i.add(p):i.delete(p)):(a=a.delete(p),i=i.delete(p)))}));const h=this.Wu(this.query);if(h)if(Ys(this.query)){const p=[];a.forEach((x=>p.push(x)));const m=f9(this.query,p);let y=new id(Bb(this.query));for(const x of m)y=y.add(x);a.forEach((x=>{y.has(x.key)||(i=i.delete(x.key),s.track({type:1,doc:x}))})),a=y}else{const p=this.Qu(this.query);for(;a.size>h;){const m=p==="F"?a.last():a.first();a=a.delete(m.key),i=i.delete(m.key),s.track({type:1,doc:m})}}return{Bu:a,qu:s,Uo:l,mutatedKeys:i}}Wu(e){return Ys(e)?iv(e)?.limit:e.limit||void 0}Qu(e){if(Ys(e)){const t=iv(e);return t&&t.limit<0?"L":"F"}return e.limitType}$u(e,t){if(Ys(e)){const s=iv(e)?.limit;return[t.size===s?t.last():null,null]}return[e.limitType==="F"&&t.size===this.Wu(this.query)?t.last():null,e.limitType==="L"&&t.size===this.Wu(this.query)?t.first():null]}Ku(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}applyChanges(e,t,s,r){const i=this.Bu;this.Bu=e.Bu,this.mutatedKeys=e.mutatedKeys;const a=e.qu.cu();a.sort(((h,p)=>(function(y,x){const w=S=>{switch(S){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return _t(20277,{ft:S})}};return w(y)-w(x)})(h.type,p.type)||this.Lu(h.doc,p.doc))),this.Gu(s),r=r??!1;const l=t&&!r?this.zu():[],c=this.Nu.size===0&&this.current&&!r?1:0,d=c!==this.Mu;return this.Mu=c,a.length!==0||d?{snapshot:new nf(this.query,e.Bu,i,a,e.mutatedKeys,c===0,d,!1,!!s&&s.resumeToken.approximateByteSize()>0),ju:l}:{ju:l}}Ru(e){return this.current&&e==="Offline"?(this.current=!1,this.applyChanges({Bu:this.Bu,qu:new w5,mutatedKeys:this.mutatedKeys,Uo:!1},!1)):{ju:[]}}Hu(e){return!this.Ou.has(e)&&!!this.Bu.has(e)&&!this.Bu.get(e).hasLocalMutations}Gu(e){e&&(e.addedDocuments.forEach((t=>this.Ou=this.Ou.add(t))),e.modifiedDocuments.forEach((t=>{})),e.removedDocuments.forEach((t=>this.Ou=this.Ou.delete(t))),this.current=e.current)}zu(){if(!this.current)return[];const e=this.Nu;this.Nu=en(),this.Bu.forEach((s=>{this.Hu(s.key)&&(this.Nu=this.Nu.add(s.key))}));const t=[];return e.forEach((s=>{this.Nu.has(s)||t.push(new T9(s))})),this.Nu.forEach((s=>{e.has(s)||t.push(new E9(s))})),t}Ju(e){this.Ou=e.Jo,this.Nu=en();const t=this.ku(e.documents);return this.applyChanges(t,!0)}Yu(){return nf.fromInitialDocuments(this.query,this.Bu,this.mutatedKeys,this.Mu===0,this.hasCachedResults)}}const v6="SyncEngine";class Qq{constructor(e,t,s){this.query=e,this.targetId=t,this.view=s}}class Xq{constructor(e){this.key=e,this.Zu=!1}}class Jq{constructor(e,t,s,r,i,a){this.localStore=e,this.remoteStore=t,this.eventManager=s,this.sharedClientState=r,this.currentUser=i,this.maxConcurrentLimboResolutions=a,this.Xu={},this.ec=new Nd((l=>u9(l)),Hx),this.tc=new Map,this.nc=new Set,this.rc=new Zn(bt.comparator),this.sc=new Map,this._c=new i6,this.oc={},this.ac=new Map,this.uc=au.Cs(),this.onlineState="Unknown",this.cc=void 0}get isPrimaryClient(){return this.cc===!0}}async function Zq(n,e,t=!0){const s=R9(n);let r;const i=s.ec.get(e);
46return i?(s.sharedClientState.addLocalQueryTarget(i.targetId),r=i.view.Yu()):r=await _9(s,e,t,!0),r}async function eY(n,e){const t=R9(n);await _9(t,e,!0,!1)}async function _9(n,e,t,s){const r=await kq(n.localStore,Ys(e)?e:Ho(e)),i=r.targetId,a=n.sharedClientState.addLocalQueryTarget(i,t);let l;return s&&(l=await tY(n,e,i,a==="current",r.resumeToken)),n.isPrimaryClient&&t&&x9(n.remoteStore,r),l}async function tY(n,e,t,s,r){n.lc=(p,m,y)=>(async function(w,S,_,L){let R=S.view.ku(_);R.Uo&&(R=await y5(w.localStore,S.query,!1).then((({documents:I})=>S.view.ku(I,R))));const M=L&&L.targetChanges.get(S.targetId),V=L&&L.targetMismatches.get(S.targetId)!=null,W=S.view.applyChanges(R,w.isPrimaryClient,M,V);return T5(w,S.targetId,W.ju),W.snapshot})(n,p,m,y);const i=await y5(n.localStore,e,!0),a=new Yq(e,i.Jo),l=a.ku(i.documents),c=Om.createSynthesizedTargetChangeForCurrentChange(t,s&&n.onlineState!=="Offline",r),d=a.applyChanges(l,n.isPrimaryClient,c);T5(n,t,d.ju);const h=new Qq(e,t,a);return n.ec.set(e,h),n.tc.has(t)?n.tc.get(t).push(e):n.tc.set(t,[e]),d.snapshot}async function nY(n,e,t){const s=$t(n),r=s.ec.get(e),i=s.tc.get(r.targetId);if(i.length>1)return s.tc.set(r.targetId,i.filter((a=>!Hx(a,e)))),void s.ec.delete(e);s.isPrimaryClient?(s.sharedClientState.removeLocalQueryTarget(r.targetId),s.sharedClientState.isActiveQueryTarget(r.targetId)||await zb(s.localStore,r.targetId,!1).then((()=>{s.sharedClientState.clearQueryState(r.targetId),t&&c6(s.remoteStore,r.targetId),Wb(s,r.targetId)})).catch(wf)):(Wb(s,r.targetId),await zb(s.localStore,r.targetId,!0))}async function sY(n,e){const t=$t(n),s=t.ec.get(e),r=t.tc.get(s.targetId);t.isPrimaryClient&&r.length===1&&(t.sharedClientState.removeLocalQueryTarget(s.targetId),c6(t.remoteStore,s.targetId))}async function rY(n,e,t){const s=dY(n);try{const r=await(function(a,l){const c=$t(a),d=$n.now(),h=l.reduce(((y,x)=>y.add(x.key)),en());let p,m;return c.persistence.runTransaction("Locally write mutations","readwrite",(y=>{let x=Ei(),w=en();return c.Qo.getEntries(y,h).next((S=>{x=S,x.forEach(((_,L)=>{L.isValidDocument()||(w=w.add(_))}))})).next((()=>c.localDocuments.getOverlayedDocuments(y,x))).next((S=>{p=S;const _=[];for(const L of l){const R=cW(L,p.get(L.key).overlayedDocument);R!=null&&_.push(new yu(L.key,R,sR(R.value.mapValue),Ea.exists(!0)))}return c.mutationQueue.addMutationBatch(y,d,_,l)})).next((S=>{m=S;const _=S.applyToLocalDocumentSet(p,w);return c.documentOverlayCache.saveOverlays(y,S.batchId,_)}))})).then((()=>({batchId:m.batchId,changes:SR(p)})))})(s.localStore,e);s.sharedClientState.addPendingMutation(r.batchId),(function(a,l,c){let d=a.oc[a.currentUser.toKey()];d||(d=new Zn(sn)),d=d.insert(l,c),a.oc[a.currentUser.toKey()]=d})(s,r.batchId,t),await Um(s,r.changes),await Kx(s.remoteStore)}catch(r){const i=p6(r,"Failed to persist write");t.reject(i)}}async function I9(n,e){const t=$t(n);try{const s=await Iq(t.localStore,e);
46e.targetChanges.forEach(((r,i)=>{const a=t.sc.get(i);a&&(yt(r.addedDocuments.size+r.modifiedDocuments.size+r.removedDocuments.size<=1,22616),r.addedDocuments.size>0?a.Zu=!0:r.modifiedDocuments.size>0?yt(a.Zu,14607):r.removedDocuments.size>0&&(yt(a.Zu,42227),a.Zu=!1))})),await Um(t,s,e)}catch(s){await wf(s)}}function E5(n,e,t){const s=$t(n);if(s.isPrimaryClient&&t===0||!s.isPrimaryClient&&t===1){const r=[];s.ec.forEach(((i,a)=>{const l=a.view.Ru(e);l.snapshot&&r.push(l.snapshot)})),(function(a,l){const c=$t(a);c.onlineState=l;let d=!1;c.queries.forEach(((h,p)=>{for(const m of p.Eu)m.Ru(l)&&(d=!0)})),d&&x6(c)})(s.eventManager,e),r.length&&s.Xu.zn(r),s.onlineState=e,s.isPrimaryClient&&s.sharedClientState.setOnlineState(e)}}async function iY(n,e,t){const s=$t(n);s.sharedClientState.updateQueryState(e,"rejected",t);const r=s.sc.get(e),i=r&&r.key;if(i){let a=new Zn(bt.comparator);a=a.insert(i,Or.newNoDocument(i,Vt.min()));const l=en().add(i),c=new jm(Vt.min(),new Map,new Zn(sn),a,Ei(),l);await I9(s,c),s.rc=s.rc.remove(i),s.sc.delete(e),b6(s)}else await zb(s.localStore,e,!1).then((()=>Wb(s,e,t))).catch(wf)}async function aY(n,e){const t=$t(n),s=e.batch.batchId;try{const r=await _q(t.localStore,e);C9(t,s,null),A9(t,s),t.sharedClientState.updateMutationState(s,"acknowledged"),await Um(t,r)}catch(r){await wf(r)}}async function oY(n,e,t){const s=$t(n);try{const r=await(function(a,l){const c=$t(a);return c.persistence.runTransaction("Reject batch","readwrite-primary",(d=>{let h;return c.mutationQueue.lookupMutationBatch(d,l).next((p=>
vendor: 4,101 bytes, line 46
46(yt(p!==null,37113),h=p.keys(),c.mutationQueue.removeMutationBatch(d,p)))).next((()=>c.mutationQueue.performConsistencyCheck(d))).next((()=>c.documentOverlayCache.removeOverlaysForBatchId(d,h,l))).next((()=>c.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(d,h))).next((()=>c.localDocuments.getDocuments(d,h)))}))})(s.localStore,e);C9(s,e,t),A9(s,e),s.sharedClientState.updateMutationState(e,"rejected",t),await Um(s,r)}catch(r){await wf(r)}}function A9(n,e){(n.ac.get(e)||[]).forEach((t=>{t.resolve()})),n.ac.delete(e)}function C9(n,e,t){const s=$t(n);let r=s.oc[s.currentUser.toKey()];if(r){const i=r.get(e);i&&(t?i.reject(t):i.resolve(),r=r.remove(e)),s.oc[s.currentUser.toKey()]=r}}function Wb(n,e,t=null){n.sharedClientState.removeLocalQueryTarget(e);for(const s of n.tc.get(e))n.ec.delete(s),t&&n.Xu.Ec(s,t);n.tc.delete(e),n.isPrimaryClient&&n._c.s_(e).forEach((s=>{n._c.containsKey(s)||k9(n,s)}))}function k9(n,e){n.nc.delete(e.path.canonicalString());const t=n.rc.get(e);t!==null&&(c6(n.remoteStore,t),n.rc=n.rc.remove(e),n.sc.delete(t),b6(n))}function T5(n,e,t){for(const s of t)s instanceof E9?(n._c.addReference(s.key,e),lY(n,s)):s instanceof T9?(Ze(v6,"Document no longer in limbo: "+s.key),n._c.removeReference(s.key,e),n._c.containsKey(s.key)||k9(n,s.key)):_t(19791,{hc:s})}function lY(n,e){const t=e.key,s=t.path.canonicalString();n.rc.get(t)||n.nc.has(s)||(Ze(v6,"New document in limbo: "+t),n.nc.add(s),b6(n))}function b6(n){for(;n.nc.size>0&&n.rc.size<n.maxConcurrentLimboResolutions;){const e=n.nc.values().next().value;n.nc.delete(e);const t=new bt(bn.fromString(e)),s=n.uc.next();n.sc.set(s,new Xq(t)),n.rc=n.rc.insert(t,s),x9(n.remoteStore,new Ol(Ho(Px(t.path)),s,"TargetPurposeLimboResolution",Ex.ce))}}async function Um(n,e,t){const s=$t(n),r=[],i=[],a=[];s.ec.isEmpty()||(s.ec.forEach(((l,c)=>{a.push(s.lc(c,e,t).then((d=>{if((d||t)&&s.isPrimaryClient){const h=d?!d.fromCache:t?.targetChanges.get(c.targetId)?.current;s.sharedClientState.updateQueryState(c.targetId,h?"current":"not-current")}if(d){r.push(d);const h=o6.vo(c.targetId,d);i.push(h)}})))})),await Promise.all(a),s.Xu.zn(r),await(async function(c,d){const h=$t(c);try{await h.persistence.runTransaction("notifyLocalViewChanges","readwrite",(p=>Pe.forEach(d,(m=>Pe.forEach(m.wo,(y=>h.persistence.referenceDelegate.addReference(p,m.targetId,y))).next((()=>Pe.forEach(m.bo,(y=>h.persistence.referenceDelegate.removeReference(p,m.targetId,y)))))))))}catch(p){if(!Sf(p))throw p;Ze(l6,"Failed to update sequence numbers: "+p)}for(const p of d){const m=p.targetId;if(!p.fromCache){const y=h.$o.get(m),x=y.snapshotVersion,w=y.withLastLimboFreeSnapshotVersion(x);h.$o=h.$o.insert(m,w)}}})(s.localStore,i))}async function cY(n,e){const t=$t(n);if(!t.currentUser.isEqual(e)){Ze(v6,"User change. New user:",e.toKey());const s=await m9(t.localStore,e);t.currentUser=e,(function(i,a){i.ac.forEach((l=>{l.forEach((c=>{c.reject(new Xe(Ce.CANCELLED,a))}))})),i.ac.clear()})(t,"'waitForPendingWrites' promise is rejected due to a user change."),t.sharedClientState.handleUserChange(e,s.removedBatchIds,s.addedBatchIds),await Um(t,s.zo)}}function uY(n,e){const t=$t(n),s=t.sc.get(e);if(s&&s.Zu)return en().add(s.key);{let r=en();const i=t.tc.get(e);if(!i)return r;for(const a of i??[]){const l=t.ec.get(a);r=r.unionWith(l.view.Uu)}return r}}function R9(n){const e=$t(n);return e.remoteStore.remoteSyncer.applyRemoteEvent=I9.bind(null,e),e.remoteStore.remoteSyncer.getRemoteKeysForTarget=uY.bind(null,e),e.remoteStore.remoteSyncer.rejectListen=iY.bind(null,e),e.Xu.zn=Kq.bind(null,e.eventManager),e.Xu.Ec=qq.bind(null,e.eventManager),e}function dY(n){const e=$t(n);return e.remoteStore.remoteSyncer.applySuccessfulWrite=aY.bind(null,e),e.remoteStore.remoteSyncer.rejectFailedWrite=oY.bind(null,e),e}class E1{constructor(){this.kind="memory",this.synchronizeTabs=!1}async initialize(e){this.serializer=Lx(e.databaseInfo.databaseId),this.sharedClientState=this.Rc(e),this.persistence=this.Ic(e),await this.persistence.start(),this.localStore=this.Ac(e),this.gcScheduler=this.Vc(e,this.localStore),this.indexBackfillerScheduler
46=this.dc(e,this.localStore)}Vc(e,t){return null}dc(e,t){return null}Ac(e){return Tq(this.persistence,new wq,e.initialUser,this.serializer)}Ic(e){return new p9(a6.C_,this.serializer)}Rc(e){return new Pq}async terminate(){this.gcScheduler?.stop(),this.indexBackfillerScheduler?.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}}E1.provider={build:()=>new E1};class hY extends E1{constructor(e){super(),this.cacheSizeBytes=e}Vc(e,t){yt(this.persistence.referenceDelegate instanceof w1,46915);const s=this.persistence.referenceDelegate.garbageCollector;return new mG(s,e.asyncQueue,t)}Ic(e){const t=this.cacheSizeBytes!==void 0?bi.withCacheSize(this.cacheSizeBytes):bi.DEFAULT;return new p9((s=>w1.C_(s,t)),this.serializer)}}class Gb{async initialize(e,t){this.localStore||(this.localStore=e.localStore,this.sharedClientState=e.sharedClientState,this.datastore=this.createDatastore(t),this.remoteStore=this.createRemoteStore(t),this.eventManager=this.createEventManager(t),this.syncEngine=this.createSyncEngine(t,!e.synchronizeTabs),this.sharedClientState.onlineStateHandler=s=>E5(this.syncEngine,s,1),this.remoteStore.remoteSyncer.handleCredentialChange=cY.bind(null,this.syncEngine),await Hq(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return(function(){return new Gq})()}createDatastore(e){const t=Lx(e.databaseInfo.databaseId),s=iG(e.databaseInfo);return uG(e.authCredentials,e.appCheckCredentials,s,t)}createRemoteStore(e){return(function(s,r,i,a,l){return new Lq(s,r,i,a,l)})(this.localStore,this.datastore,e.asyncQueue,(t=>E5(this.syncEngine,t,0)),(function(){return l5.C()?new l5:new tG})())}createSyncEngine(e,t){return(function(r,i,a,l,c,d,h){const p=new Jq(r,i,a,l,c,d);return h&&(p.cc=!0),p})(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,e.initialUser,e.maxConcurrentLimboResolutions,t)}async terminate(){await(async function(t){const s=$t(t);Ze(Jo,"RemoteStore shutting down."),s.tu.add(5),await Fm(s),s.ru.shutdown(),s.iu.set("Unknown")})(this.remoteStore),this.datastore?.terminate(),this.eventManager?.terminate()}}Gb.provider={build:()=>new Gb};class w6{constructor(e){this.observer=e,this.muted=!1}next(e){this.muted||this.observer.next&&this.mc(this.observer.next,e)}error(e){this.muted||(this.observer.error?this.mc(this.observer.error,e):Kl("Uncaught Error in snapshot listener:",e.toString()))}gc(){this.muted=!0}mc(e,t){setTimeout((()=>{this.muted||e(t)}),0)}}const lu="FirestoreClient";class fY{constructor(e,t,s,r,i){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=s,this._databaseInfo=r,this.user=jr.UNAUTHENTICATED,this.clientId=L4.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=i,this.authCredentials.start(s,(async a=>{Ze(lu,"Received user=",a.uid),await this.authCredentialListener(a),this.user=a})),this.appCheckCredentials.start(s,(a=>(Ze(lu,"Received new app check token=",a),this.appCheckCredentialListener(a,this.user))))}get configuration(){return{asyncQueue:this.asyncQueue,databaseInfo:this._databaseInfo,clientId:this.clientId,authCredentials:this.authCredentials,appCheckCredentials:this.appCheckCredentials,initialUser:this.user,maxConcurrentLimboResolutions:100}}setCredentialChangeListener(e){this.authCredentialListener=e}setAppCheckTokenChangeListener(e){this.appCheckCredentialListener=e}terminate(){this.asyncQueue.enterRestrictedMode();const e=new Vl;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted((async()=>{try{this._onlineComponents&&await this._onlineComponents.terminate(),this._offlineComponents&&await this._offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),e.resolve()}catch(t){const s=p6(t,"Failed to shutdown persistence");e.reject(s)}})),e.promise}}async function ov(n,e){n.asyncQueue.verifyOperationInProgress(),Ze(lu,"Initializing OfflineComponentProvider");const t=n.configuration;await e.initialize(t);let s=t.initialUser;n.setCredentialChangeListener((async r=>{s.isEqual(r)||(await m9(e.localStore,r),s=r)})),e.persistence.setDatabaseDeletedListener((()=>n.terminate())),n._offlineComponents=e}async function _5(n,e){n.asyncQueue.verifyOperationInProgress();const t=await pY(n);Ze(lu,"Initializing OnlineComponentProvider"),await e.initialize(t,n.configuration),n.setCredentialChangeListener((s=>b5(e.remoteStore,s))),n.setAppCheckTokenChangeListener(((s,r)=>b5(e.remoteStore,r))),n._onlineComponents=e}async function pY(n){if(!n._offlineComponents)if(n._uninitializedComponentsProvider){Ze(lu,"Using user provided OfflineComponentProvider");try{await ov(n,n._uninitializedComponentsProvider._offline)}catch(e){const t=e;if(!(function(r){return r.name==="FirebaseError"?r.code===Ce.FAILED_PRECONDITION||r.code===Ce.UNIMPLEMENT
46ED:!(typeof DOMException<"u"&&r instanceof DOMException)||r.code===22||r.code===20||r.code===11})(t))throw t;fo("Error using user provided cache. Falling back to memory cache: "+t),await ov(n,new E1)}}else Ze(lu,"Using default OfflineComponentProvider"),await ov(n,new hY(void 0));return n._offlineComponents}async function P9(n){return n._onlineComponents||(n._uninitializedComponentsProvider?(Ze(lu,"Using user provided OnlineComponentProvider"),await _5(n,n._uninitializedComponentsProvider._online)):(Ze(lu,"Using default OnlineComponentProvider"),await _5(n,new Gb))),n._onlineComponents}function mY(n){return P9(n).then((e=>e.syncEngine))}async function T1(n){const e=await P9(n),t=e.eventManager;return t.onListen=Zq.bind(null,e.syncEngine),t.onUnlisten=nY.bind(null,e.syncEngine),t.onFirstRemoteStoreListen=eY.bind(null,e.syncEngine),t.onLastRemoteStoreUnlisten=sY.bind(null,e.syncEngine),t}function gY(n,e,t,s){const r=new w6(s),i=new y6(e,r,t);return n.asyncQueue.enqueueAndForget((async()=>m6(await T1(n),i))),()=>{r.gc(),n.asyncQueue.enqueueAndForget((async()=>g6(await T1(n),i)))}}function xY(n,e,t={}){const s=new Vl;return n.asyncQueue.enqueueAndForget((async()=>(function(i,a,l,c,d){const h=new w6({next:m=>{h.gc(),a.enqueueAndForget((()=>g6(i,p)));const y=m.docs.has(l);!y&&m.fromCache?d.reject(new Xe(Ce.UNAVAILABLE,"Failed to get document because the client is offline.")):y&&m.fromCache&&c&&c.source==="server"?d.reject(new Xe(Ce.UNAVAILABLE,'Failed to get document from server. (However, this document does exist in the local cache. Run again without setting source to "server" to retrieve the cached document.)')):d.resolve(m)},error:m=>d.reject(m)}),p=new y6(Px(l.path),h,{includeMetadataChanges:!0,waitForSyncWhenOnline:!0});return m6(i,p)})(await T1(n),n.asyncQueue,e,t,s))),s.promise}function yY(n,e,t={}){const s=new Vl;return n.asyncQueue.enqueueAndForget((async()=>(function(i,a,l,c,d){const h=new w6({next:m=>{h.gc(),a.enqueueAndForget((()=>g6(i,p))),m.fromCache&&c.source==="server"?d.reject(new Xe(Ce.UNAVAILABLE,'Failed to get documents from server. (However, these documents may exist in the local cache. Run again without setting source to "server" to retrieve the cached documents.)')):d.resolve(m)},error:m=>d.reject(m)}),p=new y6(l instanceof Dp?ZK(l):l,h,{includeMetadataChanges:!0,waitForSyncWhenOnline:!0});return m6(i,p)})(await T1(n),n.asyncQueue,e,t,s))),s.promise}function vY(n,e){const t=new Vl;return n.asyncQueue.enqueueAndForget((async()=>rY(await mY(n),e,t))),t.promise}const I5="AsyncQueue";class A5{constructor(e=Promise.resolve()){this.qc=[],this.$c=!1,this.Kc=[],this.Wc=null,this.Qc=!1,this.Gc=!1,this.zc=[],this.xn=new OR(this,"async_queue_retry"),this.jc=()=>{const s=av();s&&Ze(I5,"Visibility state changed to "+s.visibilityState),this.xn.gn()},this.Hc=e;const t=av();t&&typeof t.addEventListener=="function"&&t.addEventListener("visibilitychange",this.jc)}get isShuttingDown(){return this.$c}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.Jc(),this.Yc(e)}enterRestrictedMode(e){if(!this.$c){this.$c=!0,this.Gc=e||!1;const t=av();t&&typeof t.removeEventListener=="function"&&t.removeEventListener("visibilitychange",this.jc)}}enqueue(e){if(this.Jc(),this.$c)return new Promise((()=>{}));const t=new Vl;return this.Yc((()=>this.$c&&this.Gc?Promise.resolve():(e().then(t.resolve,t.reject),t.promise))).then((()=>t.promise))}enqueueRetryable(e){this.enqueueAndForget((()=>(this.qc.push(e),this.Zc())))}async Zc(){if(this.qc.length!==0){try{await this.qc[0](),this.qc.shift(),this.xn.reset()}catch(e){if(!Sf(e))throw e;Ze(I5,"Operation failed with retryable error: "+e)}this.qc.length>0&&this.xn.mn((()=>this.Zc()))}}Yc(e){const t=this.Hc.then((()=>(this.Qc=!0,e().catch((s=>{throw this.Wc=s,this.Qc=!1,Kl("INTERNAL UNHANDLED ERROR: ",C5(s)),s})).then((s=>(this.Qc=!1,s))))));return this.Hc=t,t}enqueueAfterDelay(e,t,s){this.Jc(),this.zc.indexOf(e)>-1&&(t=0);const r=f6.createAndSchedule(this,e,t,s,(i=>this.Xc(i)));return this.Kc.push(r),r}Jc(){this.Wc&&_t(47125,{el:C5(this.Wc)})}verifyOperationInProgress(){}async tl(){let e;do e=this.Hc,await e;while(e!==this.Hc)}nl(e){for(const t of this.Kc)if(t.timerId===e)return!0;return!1}rl(e){return this.tl().then((()=>{this.Kc.sort(((t,s)=>t.targetTimeMs-s.targetTimeMs));for(const t of this.Kc)if(t.skipDelay(),e!=="all"&&t.timerId===e)break;return this.tl()}
46))}il(e){this.zc.push(e)}Xc(e){const t=this.Kc.indexOf(e);this.Kc.splice(t,1)}}function C5(n){let e=n.message||"";return n.stack&&(e=n.stack.includes(n.message)?n.stack:n.message+` 47`+n.stack),e}class Yl extends jx{constructor(e,t,s,r){super(e,t,s,r),this.type="firestore",this._queue=new A5,this._persistenceKey=r?.name||"[DEFAULT]"}async _terminate(){if(this._firestoreClient){const e=this._firestoreClient.terminate();this._queue=new A5(e),this._firestoreClient=void 0,await e}}}function k5(n,e){const t=typeof n=="object"?n:Im(),s=typeof n=="string"?n:u1,r=gu(t,"firestore").getImmediate({identifier:s});if(!r._initialized){const i=hC("firestore");i&&yG(r,...i)}return r}function qx(n){if(n._terminated)throw new Xe(Ce.FAILED_PRECONDITION,"The client has already been terminated.");return n._firestoreClient||bY(n),n._firestoreClient}function bY(n){const e=n._freezeSettings(),t=hG(n._databaseId,n._app?.options.appId||"",n._persistenceKey,n._app?.options.apiKey,e);n._componentsProvider||e.localCache?._offlineComponentProvider&&e.localCache?._onlineComponentProvider&&(n._componentsProvider={_offline:e.localCache._offlineComponentProvider,_online:e.localCache._onlineComponentProvider}),n._firestoreClient=new fY(n._authCredentials,n._appCheckCredentials,n._queue,t,n._componentsProvider&&(function(r){const i=r?._online.build();return{_offline:r?._offline.build(i),_online:i}})(n._componentsProvider))}class wY{convertValue(e,t="none"){switch(Ms(e)){case 0:return null;case 1:return e.booleanValue;case 2:return is(e.integerValue||e.doubleValue);case 3:return this.convertTimestamp(e.timestampValue);case 4:return this.convertServerTimestamp(e,t);case 5:return e.stringValue;case 6:return this.convertBytes(tu(e.bytesValue));case 7:return this.convertReference(e.referenceValue);case 8:return this.convertGeoPoint(e.geoPointValue);case 9:return this.convertArray(e.arrayValue,t);case 11:return this.convertObject(e.mapValue,t);case 10:return this.convertVectorValue(e.mapValue);default:throw _t(62114,{value:e})}}convertObject(e,t){return this.convertObjectMap(e.fields,t)}convertObjectMap(e,t="none"){const s={};return xu(e,((r,i)=>{s[r]=this.convertValue(i,t)})),s}convertVectorValue(e){const t=e.fields?.[sm].arrayValue?.values?.map((s=>is(s.doubleValue)));return new Ai(t)}convertGeoPoint(e){return new Go(is(e.latitude),is(e.longitude))}convertArray(e,t){return(e.values||[]).map((s=>this.convertValue(s,t)))}convertServerTimestamp(e,t){switch(t){case"previous":const s=Lm(e);return s==null?null:this.convertValue(s,t);case"estimate":return this.convertTimestamp(Yh(e));default:return null}}convertTimestamp(e){const t=eu(e);return new $n(t.seconds,t.nanos)}convertDocumentKey(e,t){const s=bn.fromString(e);yt(NR(s),9688,{name:e});const r=new nm(s.get(1),s.get(3)),i=new bt(s.popFirst(5));return r.isEqual(t)||Kl(`Document ${i} contains a document reference within a different database (${r.projectId}/${r.database}) which is not supported. It will be treated as a reference in the current database (${t.projectId}/${t.database}) instead.`),i}}class S6 extends wY{constructor(e){super(),this.firestore=e}convertBytes(e){return new wa(e)}convertReference(e){const t=this.convertDocumentKey(e,this.firestore._databaseId);return new as(this.firestore,null,t)}}const R5="@firebase/firestore",P5="4.16.0";function N5(n){return(function(t,s){if(typeof t!="object"||t===null)return!1;const r=t;for(const i of s)if(i in r&&typeof r[i]=="function")return!0;return!1})(n,["next","error","complete"])}class N9{constructor(e,t,s,r,i){this._firestore=e,this._userDataWriter=t,this._key=s,this._document=r,this._converter=i}get id(){return this._key.path.lastSegment()}get ref(){return new as(this._firestore,this._converter,this._key)}exists(){return this._document!==null}data(){if(this._document){if(this._converter){const e=new SY(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(e)}return this._userDataWriter.convertValue(this._document.data.value)}}_fieldsProto(){return this._document?.data.clone().value.mapValue.fields??void 0}get(e){if(this._document){const t=this._document.data.field(su("DocumentSnapshot.get",e));if(t!==null)return this._userDataWriter.convertValue(t)}}}class SY extends N9{data(){return super.data()}}function L9(n){if(n.limitType==="L"&&n.explicitOrderBy.length===0)throw new Xe(Ce.UNIMPLEMENT
47ED,"limitToLast() queries require specifying at least one orderBy() clause")}class E6{}class T6 extends E6{}function wd(n,e,...t){let s=[];e instanceof E6&&s.push(e),s=s.concat(t),(function(i){const a=i.filter((c=>c instanceof _6)).length,l=i.filter((c=>c instanceof Yx)).length;if(a>1||a>0&&l>0)throw new Xe(Ce.INVALID_ARGUMENT,"InvalidQuery. When using composite filters, you cannot use more than one filter at the top level. Consider nesting the multiple filters within an `and(...)` statement. For example: change `query(query, where(...), or(...))` to `query(query, and(where(...), or(...)))`.")})(s);for(const r of s)n=r._apply(n);return n}class Yx extends T6{constructor(e,t,s){super(),this._field=e,this._op=t,this._value=s,this.type="where"}static _create(e,t,s){return new Yx(e,t,s)}_apply(e){const t=this._parse(e);return D9(e._query,t),new ec(e.firestore,e.converter,jb(e._query,t))}_parse(e){const t=Mx(e.firestore);return(function(i,a,l,c,d,h,p){let m;if(d.isKeyField()){if(h==="array-contains"||h==="array-contains-any")throw new Xe(Ce.INVALID_ARGUMENT,`Invalid Query. You can't perform '${h}' queries on documentId().`);if(h==="in"||h==="not-in"){D5(p,h);const x=[];for(const w of p)x.push(L5(c,i,w));m={arrayValue:{values:x}}}else m=L5(c,i,p)}else h!=="in"&&h!=="not-in"&&h!=="array-contains-any"||D5(p,h),m=TG(l,a,p,h==="in"||h==="not-in");return Ns.create(d,h,m)})(e._query,"where",t,e.firestore._databaseId,this._field,this._op,this._value)}}function _1(n,e,t){const s=e,r=su("where",n);return Yx._create(r,s,t)}class _6 extends E6{constructor(e,t){super(),this.type=e,this._queryConstraints=t}static _create(e,t){return new _6(e,t)}_parse(e){const t=this._queryConstraints.map((s=>s._parse(e))).filter((s=>s.getFilters().length>0));return t.length===1?t[0]:po.create(t,this._getOperator())}_apply(e){const t=this._parse(e);return t.getFilters().length===0?e:((function(r,i){let a=r;const l=i.getFlattenedFilters();for(const c of l)D9(a,c),a=jb(a,c)})(e._query,t),new ec(e.firestore,e.converter,jb(e._query,t)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return this.type==="and"?"and":"or"}}class I6 extends T6{constructor(e,t){super(),this._field=e,this._direction=t,this.type="orderBy"}static _create(e,t){return new I6(e,t)}_apply(e){const t=(function(r,i,a){if(r.startAt!==null)throw new Xe(Ce.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(r.endAt!==null)throw new Xe(Ce.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");return new am(i,a)})(e._query,this._field,this._direction);return new ec(e.firestore,e.converter,TW(e._query,t))}}function A6(n,e="asc"){const t=e,s=su("orderBy",n);return I6._create(s,t)}class C6 extends T6{constructor(e,t,s){super(),this.type=e,this._limit=t,this._limitType=s}static _create(e,t,s){return new C6(e,t,s)}_apply(e){return new ec(e.firestore,e.converter,g1(e._query,this._limit,this._limitType))}}function k6(n){return BH("limit",n),C6._create("limit",n,"F")}function L5(n,e,t){if(typeof(t=wt(t))=="string"){if(t==="")throw new Xe(Ce.INVALID_ARGUMENT,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!vR(e)&&t.indexOf("/")!==-1)throw new Xe(Ce.INVALID_ARGUMENT,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${t}' contains a '/' character.`);const s=e.path.child(bn.fromString(t));if(!bt.isDocumentKey(s))throw new Xe(Ce.INVALID_ARGUMENT,`Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${s}' is not because it has an odd number of segments (${s.length}).`);return K8(n,new bt(s))}if(t instanceof as)return K8(n,t._key);throw new Xe(Ce.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${Sx(t)}.`)}function D5(n,e){if(!Array.isArray(n)||n.length===0)throw new Xe(Ce.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${e.toString()}' filters.`)}function D9(n,e){const t=(function(r,i){for(const a of r)for(const l of a.getFlattenedFilters())if(i.indexOf(l.op)>=0)return l.op;return null})(n.filters,(function(r){switch(r){case"!=":return["!=","not-in"];case"array-contains-any":case"in":return["not-in"];case"not-in":return["array-contains-any","in","not-in","!="];default:return[]}})(e.op));
47if(t!==null)throw t===e.op?new Xe(Ce.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${e.op.toString()}' filter.`):new Xe(Ce.INVALID_ARGUMENT,`Invalid query. You cannot use '${e.op.toString()}' filters with '${t.toString()}' filters.`)}function j9(n,e,t){let s;return s=n?t&&(t.merge||t.mergeFields)?n.toFirestore(e,t):n.toFirestore(e):e,s}class bp{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}}class ad extends N9{constructor(e,t,s,r,i,a){super(e,t,s,r,a),this._firestore=e,this._firestoreImpl=e,this.metadata=i}exists(){return super.exists()}data(e={}){if(this._document){if(this._converter){const t=new P0(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(t,e)}return this._userDataWriter.convertValue(this._document.data.value,e.serverTimestamps)}}get(e,t={}){if(this._document){const s=this._document.data.field(su("DocumentSnapshot.get",e));if(s!==null)return this._userDataWriter.convertValue(s,t.serverTimestamps)}}toJSON(){if(this.metadata.hasPendingWrites)throw new Xe(Ce.FAILED_PRECONDITION,"DocumentSnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");const e=this._document,t={};return t.type=ad._jsonSchemaVersion,t.bundle="",t.bundleSource="DocumentSnapshot",t.bundleName=this._key.toString(),!e||!e.isValidDocument()||!e.isFoundDocument()?t:(this._userDataWriter.convertObjectMap(e.data.value.mapValue.fields,"previous"),t.bundle=(this._firestore,this.ref.path,"NOT SUPPORTED"),t)}}ad._jsonSchemaVersion="firestore/documentSnapshot/1.0",ad._jsonSchema={type:Ls("string",ad._jsonSchemaVersion),bundleSource:Ls("string","DocumentSnapshot"),bundleName:Ls("string"),bundle:Ls("string")};class P0 extends ad{data(e={}){return super.data(e)}}class od{constructor(e,t,s,r){this._firestore=e,this._userDataWriter=t,this._snapshot=r,this.metadata=new bp(r.hasPendingWrites,r.fromCache),this.query=s}get docs(){const e=[];return this.forEach((t=>e.push(t))),e}get size(){return this._snapshot.docs.size}get empty(){return this.size===0}forEach(e,t){this._snapshot.docs.forEach((s=>{e.call(t,new P0(this._firestore,this._userDataWriter,s.key,s,new bp(this._snapshot.mutatedKeys.has(s.key),this._snapshot.fromCache),this.query.converter))}))}docChanges(e={}){const t=!!e.includeMetadataChanges;if(t&&this._snapshot.excludesMetadataChanges)throw new Xe(Ce.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===t||(this._cachedChanges=(function(r,i){if(r._snapshot.oldDocs.isEmpty()){let a=0;return r._snapshot.docChanges.map((l=>{Ys(r._snapshot.query)?Bb(r._snapshot.query):F4(r.query._query);const c=new P0(r._firestore,r._userDataWriter,l.doc.key,l.doc,new bp(r._snapshot.mutatedKeys.has(l.doc.key),r._snapshot.fromCache),r.query.converter);return l.doc,{type:"added",doc:c,oldIndex:-1,newIndex:a++}}))}{let a=r._snapshot.oldDocs;return r._snapshot.docChanges.filter((l=>i||l.type!==3)).map((l=>{const c=new P0(r._firestore,r._userDataWriter,l.doc.key,l.doc,new bp(r._snapshot.mutatedKeys.has(l.doc.key),r._snapshot.fromCache),r.query.converter);let d=-1,h=-1;return l.type!==0&&(d=a.indexOf(l.doc.key),a=a.delete(l.doc.key)),l.type!==1&&(a=a.add(l.doc),h=a.indexOf(l.doc.key)),{type:EY(l.type),doc:c,oldIndex:d,newIndex:h}}))}})(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}toJSON(){if(this.metadata.hasPendingWrites)throw new Xe(Ce.FAILED_PRECONDITION,"QuerySnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");const e={};e.type=od._jsonSchemaVersion,e.bundleSource="QuerySnapshot",e.bundleName=L4.newId(),this._firestore._databaseId.database,this._firestore._databaseId.projectId;const t=[],s=[],r=[];return this.docs.forEach((i=>{i._document!==null&&(t.push(i._document),s.push(this._userDataWriter.convertObjectMap(i._document.data.value.mapValue.fields,"previous")),r.push(i.ref.path))})),e.bundle=(this._firestore,this.query._query,e.bundleName,"NOT SUPPORTED"),e}}function EY(n){switch(n){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return _t(61501,{type:n})}}
47od._jsonSchemaVersion="firestore/querySnapshot/1.0",od._jsonSchema={type:Ls("string",od._jsonSchemaVersion),bundleSource:Ls("string","QuerySnapshot"),bundleName:Ls("string"),bundle:Ls("string")};function Sr(n){n=Ii(n,as);const e=Ii(n.firestore,Yl),t=qx(e);return xY(t,n._key).then((s=>M9(e,n,s)))}function cu(n){n=Ii(n,ec);const e=Ii(n.firestore,Yl),t=qx(e),s=new S6(e);return L9(n._query),yY(t,n._query).then((r=>new od(e,s,n,r)))}function Er(n,e,t){n=Ii(n,as);const s=Ii(n.firestore,Yl),r=j9(n.converter,e,t),i=Mx(s);return Qx(s,[zR(i,"setDoc",n._key,r,n.converter!==null,t).toMutation(n._key,Ea.none())])}function R6(n,e,t,...s){n=Ii(n,as);const r=Ii(n.firestore,Yl),i=Mx(r);let a;return a=typeof(e=wt(e))=="string"||e instanceof Dx?EG(i,"updateDoc",n._key,e,t,s):SG(i,"updateDoc",n._key,e),Qx(r,[a.toMutation(n._key,Ea.exists(!0))])}function I1(n){return Qx(Ii(n.firestore,Yl),[new M4(n._key,Ea.none())])}function O9(n,e){const t=Ii(n.firestore,Yl),s=Gt(n),r=j9(n.converter,e),i=Mx(n.firestore);return Qx(t,[zR(i,"addDoc",s._key,r,n.converter!==null,{}).toMutation(s._key,Ea.exists(!1))]).then((()=>s))}function Od(n,...e){n=wt(n);let t={includeMetadataChanges:!1,source:"default"},s=0;
47typeof e[s]!="object"||N5(e[s])||(t=e[s++]);const r={includeMetadataChanges:t.includeMetadataChanges,source:t.source};if(N5(e[s])){const d=e[s];e[s]=d.next?.bind(d),e[s+1]=d.error?.bind(d),e[s+2]=d.complete?.bind(d)}let i,a,l;if(n instanceof as)a=Ii(n.firestore,Yl),l=Px(n._key.path),i={next:d=>{e[s]&&e[s](M9(a,n,d))},error:e[s+1],complete:e[s+2]};else{const d=Ii(n,ec);a=Ii(d.firestore,Yl),l=d._query;const h=new S6(a);i={next:p=>{e[s]&&e[s](new od(a,h,d,p))},error:e[s+1],complete:e[s+2]},L9(n._query)}const c=qx(a);return gY(c,l,r,i)}function Qx(n,e){const t=qx(n);return vY(t,e)}function M9(n,e,t){const s=t.docs.get(e._key),r=new S6(n);return new ad(n,r,e._key,s,new bp(t.hasPendingWrites,t.fromCache),e.converter)}(function(e,t=!0){kH(kd),ho(new Ia("firestore",((s,{instanceIdentifier:r,options:i})=>{const a=s.getProvider("app").getImmediate(),l=new Yl(new NH(s.getProvider("auth-internal")),new jH(a,s.getProvider("app-check-internal")),tW(a,r),a);return i={useFetchStreams:t,...i},l._setSettings(i),l}),"PUBLIC").setMultipleInstances(!0)),_i(R5,P5,e),_i(R5,P5,"esm2020")})();
47const F9="firebasestorage.googleapis.com",U9="storageBucket",TY=120*1e3,_Y=600*1e3;class xs extends Ra{constructor(e,t,s=0){super(lv(e),`Firebase Storage: ${t} (${lv(e)})`),this.status_=s,this.customData={serverResponse:null},this._baseMessage=this.message,Object.setPrototypeOf(this,xs.prototype)}get status(){return this.status_}set status(e){this.status_=e}_codeEquals(e){return lv(e)===this.code}get serverResponse(){return this.customData.serverResponse}set serverResponse(e){this.customData.serverResponse=e,this.customData.serverResponse?this.message=`${this._baseMessage} 48${this.customData.serverResponse}`:this.message=this._baseMessage}}var ms;(function(n){n.UNKNOWN="unknown",n.OBJECT_NOT_FOUND="object-not-found",n.BUCKET_NOT_FOUND="bucket-not-found",n.PROJECT_NOT_FOUND="project-not-found",n.QUOTA_EXCEEDED="quota-exceeded",n.UNAUTHENTICATED="unauthenticated",n.UNAUTHORIZED="unauthorized",n.UNAUTHORIZED_APP="unauthorized-app",n.RETRY_LIMIT_EXCEEDED="retry-limit-exceeded",n.INVALID_CHECKSUM="invalid-checksum",n.CANCELED="canceled",n.INVALID_EVENT_NAME="invalid-event-name",n.INVALID_URL="invalid-url",n.INVALID_DEFAULT_BUCKET="invalid-default-bucket",n.NO_DEFAULT_BUCKET="no-default-bucket",n.CANNOT_SLICE_BLOB="cannot-slice-blob",n.SERVER_FILE_WRONG_SIZE="server-file-wrong-size",n.NO_DOWNLOAD_URL="no-download-url",n.INVALID_ARGUMENT="invalid-argument",n.INVALID_ARGUMENT_COUNT="invalid-argument-count",n.APP_DELETED="app-deleted",n.INVALID_ROOT_OPERATION="invalid-root-operation",n.INVALID_FORMAT="invalid-format",n.INTERNAL_ERROR="internal-error",n.UNSUPPORTED_ENVIRONMENT="unsupported-environment"})(ms||(ms={}));function lv(n){return"storage/"+n}function P6(){const n="An unknown error occurred, please check the error payload for server response.";return new xs(ms.UNKNOWN,n)}function IY(n){return new xs(ms.OBJECT_NOT_FOUND,"Object '"+n+"' does not exist.")}function AY(n){return new xs(ms.QUOTA_EXCEEDED,"Quota for bucket '"+n+"' exceeded, please view quota on https://firebase.google.com/pricing/.")}function CY(){const n="User is not authenticated, please authenticate using Firebase Authentication and try again.";return new xs(ms.UNAUTHENTICATED,n)}function kY(){return new xs(ms.UNAUTHORIZED_APP,"This app does not have permission to access Firebase Storage on this project.")}function RY(n){return new xs(ms.UNAUTHORIZED,"User does not have permission to access '"+n+"'.")}function PY(){return new xs(ms.RETRY_LIMIT_EXCEEDED,"Max retry time for operation exceeded, please try again.")}function NY(){return new xs(ms.CANCELED,"User canceled the upload/download.")}function LY(n){return new xs(ms.INVALID_URL,"Invalid URL '"+n+"'.")}function DY(n){return new xs(ms.INVALID_DEFAULT_BUCKET,"Invalid default bucket '"+n+"'.")}function jY(){return new xs(ms.NO_DEFAULT_BUCKET,"No default bucket found. Did you set the '"+U9+"' property when initializing the app?")}function OY(){return new xs(ms.CANNOT_SLICE_BLOB,"Cannot slice blob for upload. Please retry the upload.")}function MY(){return new xs(ms.NO_DOWNLOAD_URL,"The given file does not have any download URLs.")}function FY(n){return new xs(ms.UNSUPPORTED_ENVIRONMENT,`${n} is missing. Make sure to install the required polyfills. See https://firebase.google.com/docs/web/environments-js-sdk#polyfills for more information.`)}function Kb(n){return new xs(ms.INVALID_ARGUMENT,n)}function V9(){return new xs(ms.APP_DELETED,"The Firebase app was deleted.")}function UY(n){return new xs(ms.INVALID_ROOT_OPERATION,"The operation '"+n+"' cannot be performed on a root reference, create a non-root reference using child, such as .child('file.png').")}function Op(n,e){return new xs(ms.INVALID_FORMAT,"String does not match format '"+n+"': "+e)}function lp(n){throw new xs(ms.INTERNAL_ERROR,"Internal error: "+n)}class ea{constructor(e,t){this.bucket=e,this.path_=t}get path(){return this.path_}get isRoot(){return this.path.length===0}fullServerUrl(){const e=encodeURIComponent;return"/b/"+e(this.bucket)+"/o/"+e(this.path)}bucketOnlyServerUrl(){return"/b/"+encodeURIComponent(this.bucket)+"/o"}static makeFromBucketSpec(e,t){let s;try{s=ea.makeFromUrl(e,t)}catch{return new ea(e,"")}if(s.path==="")return s;throw DY(e)}static makeFromUrl(e,t){let s=null;
48const r="([A-Za-z0-9.\\-_]+)";function i(M){M.path.charAt(M.path.length-1)==="/"&&(M.path_=M.path_.slice(0,-1))}const a="(/(.*))?$",l=new RegExp("^gs://"+r+a,"i"),c={bucket:1,path:3};function d(M){M.path_=decodeURIComponent(M.path)}const h="v[A-Za-z0-9_]+",p=t.replace(/[.]/g,"\\."),m="(/([^?#]*).*)?$",y=new RegExp(`^https?://${p}/${h}/b/${r}/o${m}`,"i"),x={bucket:1,path:3},w=t===F9?"(?:storage.googleapis.com|storage.cloud.google.com)":t,S="([^?#]*)",_=new RegExp(`^https?://${w}/${r}/${S}`,"i"),R=[{regex:l,indices:c,postModify:i},{regex:y,indices:x,postModify:d},{regex:_,indices:{bucket:1,path:2},postModify:d}];for(let M=0;M<R.length;M++){const V=R[M],W=V.regex.exec(e);if(W){const I=W[V.indices.bucket];let k=W[V.indices.path];k||(k=""),s=new ea(I,k),V.postModify(s);break}}if(s==null)throw LY(e);return s}}class VY{constructor(e){this.promise_=Promise.reject(e)}getPromise(){return this.promise_}cancel(e=!1){}}function BY(n,e,t){let s=1,r=null,i=null,a=!1,l=0;function c(){return l===2}let d=!1;function h(...S){d||(d=!0,e.apply(null,S))}function p(S){r=setTimeout(()=>{r=null,n(y,c())},S)}function m(){i&&clearTimeout(i)}function y(S,..._){if(d){m();return}if(S){m(),h.call(null,S,..._);return}if(c()||a){m(),h.call(null,S,..._);return}s<64&&(s*=2);let R;l===1?(l=2,R=0):R=(s+Math.random())*1e3,p(R)}let x=!1;function w(S){x||(x=!0,m(),!d&&(r!==null?(S||(l=2),clearTimeout(r),p(0)):S||(l=1)))}return p(0),i=setTimeout(()=>{a=!0,w(!0)},t),w}function zY(n){n(!1)}function $Y(n){return n!==void 0}function HY(n){return typeof n=="object"&&!Array.isArray(n)}function N6(n){return typeof n=="string"||n instanceof String}function j5(n){return L6()&&n instanceof Blob}function L6(){return typeof Blob<"u"}function O5(n,e,t,s){if(s<e)throw Kb(`Invalid value for '${n}'. Expected ${e} or greater.`);if(s>t)throw Kb(`Invalid value for '${n}'. Expected ${t} or less.`)}function D6(n,e,t){let s=e;return t==null&&(s=`https://${e}`),`${t}://${s}/v0${n}`}function B9(n){const e=encodeURIComponent;let t="?";for(const s in n)if(n.hasOwnProperty(s)){const r=e(s)+"="+e(n[s]);t=t+r+"&"}return t=t.slice(0,-1),t}var ld;(function(n){n[n.NO_ERROR=0]="NO_ERROR",n[n.NETWORK_ERROR=1]="NETWORK_ERROR",n[n.ABORT=2]="ABORT"})(ld||(ld={}));function WY(n,e){const t=n>=500&&n<600,r=[408,429].indexOf(n)!==-1,i=e.indexOf(n)!==-1;return t||r||i}class GY{constructor(e,t,s,r,i,a,l,c,d,h,p,m=!0,y=!1){this.url_=e,this.method_=t,this.headers_=s,this.body_=r,this.successCodes_=i,this.additionalRetryCodes_=a,this.callback_=l,this.errorCallback_=c,this.timeout_=d,this.progressCallback_=h,this.connectionFactory_=p,this.retry=m,this.isUsingEmulator=y,this.pendingConnection_=null,this.backoffId_=null,this.canceled_=!1,this.appDelete_=!1,this.promise_=new Promise((x,w)=>{this.resolve_=x,this.reject_=w,this.start_()})}start_(){const e=(s,r)=>{if(r){s(!1,new Xg(!1,null,!0));return}const i=this.connectionFactory_();this.pendingConnection_=i;const a=l=>{const c=l.loaded,d=l.lengthComputable?l.total:-1;this.progressCallback_!==null&&this.progressCallback_(c,d)};this.progressCallback_!==null&&i.addUploadProgressListener(a),i.send(this.url_,this.method_,this.isUsingEmulator,this.body_,this.headers_).then(()=>{this.progressCallback_!==null&&i.removeUploadProgressListener(a),this.pendingConnection_=null;const l=i.getErrorCode()===ld.NO_ERROR,c=i.getStatus();if(!l||WY(c,this.additionalRetryCodes_)&&this.retry){const h=i.getErrorCode()===ld.ABORT;s(!1,new Xg(!1,null,h));return}const d=this.successCodes_.indexOf(c)!==-1;s(!0,new Xg(d,i))})},t=(s,r)=>{const i=this.resolve_,a=this.reject_,l=r.connection;if(r.wasSuccessCode)try{const c=this.callback_(l,l.getResponse());$Y(c)?i(c):i()}catch(c){a(c)}else if(l!==null){const c=P6();c.serverResponse=l.getErrorText(),this.errorCallback_?a(this.errorCallback_(l,c)):a(c)}else if(r.canceled){const c=this.appDelete_?V9():NY();a(c)}else{const c=PY();a(c)}};this.canceled_?t(!1,new Xg(!1,null,!0)):this.backoffId_=BY(e,t,this.timeout_)}getPromise(){return this.promise_}cancel(e){this.canceled_=!0,this.appDelete_=e||!1,this.backoffId_!==null&&zY(this.backoffId_),this.pendingConnection_!==null&&this.pendingConnection_.abort()}}class Xg{constructor(e,t,s){this.wasSuccessCode=e,this.connection=t,this.canceled=!!s}}function KY(n,e){e!==null&&e.length>0&&(n.Authorization="Firebase "+e)}function qY(n,e){n["X-Firebase-Storage-Version"]="webjs/"+(e??"AppManager")}
48function YY(n,e){e&&(n["X-Firebase-GMPID"]=e)}function QY(n,e){e!==null&&(n["X-Firebase-AppCheck"]=e)}function XY(n,e,t,s,r,i,a=!0,l=!1){const c=B9(n.urlParams),d=n.url+c,h=Object.assign({},n.headers);return YY(h,e),KY(h,t),qY(h,i),QY(h,s),new GY(d,n.method,h,n.body,n.successCodes,n.additionalRetryCodes,n.handler,n.errorHandler,n.timeout,n.progressCallback,r,a,l)}function JY(){return typeof BlobBuilder<"u"?BlobBuilder:typeof WebKitBlobBuilder<"u"?WebKitBlobBuilder:void 0}function ZY(...n){const e=JY();if(e!==void 0){const t=new e;for(let s=0;s<n.length;s++)t.append(n[s]);return t.getBlob()}else{if(L6())return new Blob(n);throw new xs(ms.UNSUPPORTED_ENVIRONMENT,"This browser doesn't seem to support creating Blobs")}}function eQ(n,e,t){return n.webkitSlice?n.webkitSlice(e,t):n.mozSlice?n.mozSlice(e,t):n.slice?n.slice(e,t):null}function tQ(n){if(typeof atob>"u")throw FY("base-64");return atob(n)}const zo={RAW:"raw",BASE64:"base64",BASE64URL:"base64url",DATA_URL:"data_url"};class cv{constructor(e,t){this.data=e,this.contentType=t||null}}function nQ(n,e){switch(n){case zo.RAW:return new cv(z9(e));case zo.BASE64:case zo.BASE64URL:return new cv($9(n,e));case zo.DATA_URL:return new cv(rQ(e),iQ(e))}throw P6()}function z9(n){const e=[];for(let t=0;t<n.length;t++){let s=n.charCodeAt(t);if(s<=127)e.push(s);else if(s<=2047)e.push(192|s>>6,128|s&63);else if((s&64512)===55296)if(!(t<n.length-1&&(n.charCodeAt(t+1)&64512)===56320))e.push(239,191,189);else{const i=s,a=n.charCodeAt(++t);s=65536|(i&1023)<<10|a&1023,e.push(240|s>>18,128|s>>12&63,128|s>>6&63,128|s&63)}else(s&64512)===56320?e.push(239,191,189):e.push(224|s>>12,128|s>>6&63,128|s&63)}return new Uint8Array(e)}function sQ(n){let e;try{e=decodeURIComponent(n)}catch{throw Op(zo.DATA_URL,"Malformed data URL.")}return z9(e)}function $9(n,e){switch(n){case zo.BASE64:{const r=e.indexOf("-")!==-1,i=e.indexOf("_")!==-1;if(r||i)throw Op(n,"Invalid character '"+(r?"-":"_")+"' found: is it base64url encoded?");break}case zo.BASE64URL:{const r=e.indexOf("+")!==-1,i=e.indexOf("/")!==-1;if(r||i)throw Op(n,"Invalid character '"+(r?"+":"/")+"' found: is it base64 encoded?");e=e.replace(/-/g,"+").replace(/_/g,"/");break}}let t;try{t=tQ(e)}catch(r){throw r.message.includes("polyfill")?r:Op(n,"Invalid character found")}const s=new Uint8Array(t.length);for(let r=0;r<t.length;r++)s[r]=t.charCodeAt(r);return s}class H9{constructor(e){this.base64=!1,this.contentType=null;const t=e.match(/^data:([^,]+)?,/);if(t===null)throw Op(zo.DATA_URL,"Must be formatted 'data:[<mediatype>][;base64],<data>");const s=t[1]||null;s!=null&&(this.base64=aQ(s,";base64"),this.contentType=this.base64?s.substring(0,s.length-7):s),this.rest=e.substring(e.indexOf(",")+1)}}function rQ(n){const e=new H9(n);return e.base64?$9(zo.BASE64,e.rest):sQ(e.rest)}function iQ(n){return new H9(n).contentType}function aQ(n,e){return n.length>=e.length?n.substring(n.length-e.length)===e:!1}class jc{constructor(e,t){let s=0,r="";j5(e)?(this.data_=e,s=e.size,r=e.type):e instanceof ArrayBuffer?(t?this.data_=new Uint8Array(e):(this.data_=new Uint8Array(e.byteLength),this.data_.set(new Uint8Array(e))),s=this.data_.length):e instanceof Uint8Array&&(t?this.data_=e:(this.data_=new Uint8Array(e.length),this.data_.set(e)),s=e.length),this.size_=s,this.type_=r}size(){return this.size_}type(){return this.type_}slice(e,t){if(j5(this.data_)){const s=this.data_,r=eQ(s,e,t);return r===null?null:new jc(r)}else{const s=new Uint8Array(this.data_.buffer,e,t-e);return new jc(s,!0)}}static getBlob(...e){if(L6()){const t=e.map(s=>s instanceof jc?s.data_:s);return new jc(ZY.apply(null,t))}else{const t=e.map(a=>N6(a)?nQ(zo.RAW,a).data:a.data_);let s=0;t.forEach(a=>{s+=a.byteLength});const r=new Uint8Array(s);let i=0;return t.forEach(a=>{for(let l=0;l<a.length;l++)r[i++]=a[l]}),new jc(r,!0)}}uploadData(){return this.data_}}function W9(n){let e;try{e=JSON.parse(n)}catch{return null}return HY(e)?e:null}function oQ(n){if(n.length===0)return null;const e=n.lastIndexOf("/");return e===-1?"":n.slice(0,e)}function lQ(n,e){const t=e.split("/").filter(s=>s.length>0).join("/");return n.length===0?t:n+"/"+t}function G9(n){const e=n.lastIndexOf("/",n.length-2);return e===-1?n:n.slice(e+1)}function cQ(n,e){return e}class qr{constructor(e,t,s,r){this.server=e,this.local=t||e,this.writable=!!s,this.xform=r||cQ}}let Jg=null;function uQ(n){return!N6(n)||n.length<2?n:G9(n)}function K9(){if(Jg)return Jg;const n=[];n.push(new qr("bucket")),n.push(new qr("generation")),n.push(new qr("metageneration")),n.push(new qr("name","fullPath",!0));function e(i,a){return uQ(a)}const t=new qr("name");t.xform=e,n.push(t);function s(i,a){return a!==void 0?Number(a):a}const r=new qr("size");return r.xform=s,n.push(r),n.push(new qr("timeCreated")),n.push(new qr("updated")),n.push(new qr("md5Hash",null,!0)),n.push(new qr("cacheControl",null,!0)),n.push(new qr("contentDisposition",null,!0)),n.push(new qr("contentEncoding",null,!0)),n.push(new qr("contentLanguage",null,!0)),n.push(new qr("contentType",null,!0)),n.push(new qr("metadata","customMetadata",!0)),Jg=n,Jg}function dQ(n,e){function t(){const s=n.bucket,r=n.fullPath,i=new ea(s,r);return e._makeStorageReference(i)}Object.defineProperty(n,"ref",{get:t})}function hQ(n,e,t){const s={};s.type="file";const r=t.length;for(let i=0;i<r;i++){const a=t[i];s[a.local]=a.xform(s,e[a.server])}return dQ(s,n),s}function q9(n,e,t){const s=W9(e);return s===null?null:hQ(n,s,t)}function fQ(n,e,t,s){const r=W9(e);
48if(r===null||!N6(r.downloadTokens))return null;const i=r.downloadTokens;if(i.length===0)return null;const a=encodeURIComponent;return i.split(",").map(d=>{const h=n.bucket,p=n.fullPath,m="/b/"+a(h)+"/o/"+a(p),y=D6(m,t,s),x=B9({alt:"media",token:d});return y+x})[0]}function pQ(n,e){const t={},s=e.length;for(let r=0;r<s;r++){const i=e[r];i.writable&&(t[i.server]=n[i.local])}return JSON.stringify(t)}class Y9{constructor(e,t,s,r){this.url=e,this.method=t,this.handler=s,this.timeout=r,this.urlParams={},this.headers={},this.body=null,this.errorHandler=null,this.progressCallback=null,this.successCodes=[200],this.additionalRetryCodes=[]}}function Q9(n){if(!n)throw P6()}function mQ(n,e){function t(s,r){const i=q9(n,r,e);return Q9(i!==null),i}return t}function gQ(n,e){function t(s,r){const i=q9(n,r,e);return Q9(i!==null),fQ(i,r,n.host,n._protocol)}return t}function X9(n){function e(t,s){let r;return t.getStatus()===401?t.getErrorText().includes("Firebase App Check token is invalid")?r=kY():r=CY():t.getStatus()===402?r=AY(n.bucket):t.getStatus()===403?r=RY(n.path):r=s,r.status=t.getStatus(),r.serverResponse=s.serverResponse,r}return e}function xQ(n){const e=X9(n);function t(s,r){let i=e(s,r);return s.getStatus()===404&&(i=IY(n.path)),i.serverResponse=r.serverResponse,i}return t}function yQ(n,e,t){const s=e.fullServerUrl(),r=D6(s,n.host,n._protocol),i="GET",a=n.maxOperationRetryTime,l=ne
48w Y9(r,i,gQ(n,t),a);return l.errorHandler=xQ(e),l}function vQ(n,e){return n&&n.contentType||e&&e.type()||"application/octet-stream"}function bQ(n,e,t){const s=Object.assign({},t);return s.fullPath=n.path,s.size=e.size(),s.contentType||(s.contentType=vQ(null,e)),s}function wQ(n,e,t,s,r){const i=e.bucketOnlyServerUrl(),a={"X-Goog-Upload-Protocol":"multipart"};function l(){let R="";for(let M=0;M<2;M++)R=R+Math.random().toString().slice(2);return R}const c=l();a["Content-Type"]="multipart/related; boundary="+c;const d=bQ(e,s,r),h=pQ(d,t),p="--"+c+`\r 49Content-Type: application/json; charset=utf-8\r 50\r 51`+h+`\r 52--`+c+`\r 53Content-Type: `+d.contentType+`\r 54\r 55`,m=`\r 56--`+c+"--",y=jc.getBlob(p,s,m);if(y===null)throw OY();const x={name:d.fullPath},w=D6(i,n.host,n._protocol),S="POST",_=n.maxUploadRetryTime,L=new Y9(w,S,mQ(n,t),_);return L.urlParams=x,L.headers=a,L.body=y.uploadData(),L.errorHandler=X9(e),L}class SQ{constructor(){this.sent_=!1,this.xhr_=new XMLHttpRequest,this.initXhr(),this.errorCode_=ld.NO_ERROR,this.sendPromise_=new Promise(e=>{this.xhr_.addEventListener("abort",()=>{this.errorCode_=ld.ABORT,e()}),this.xhr_.addEventListener("error",()=>{this.errorCode_=ld.NETWORK_ERROR,e()}),this.xhr_.addEventListener("load",()=>{e()})})}send(e,t,s,r,i){if(this.sent_)throw lp("cannot .send() more than once");if(Cd(e)&&s&&(this.xhr_.withCredentials=!0),this.sent_=!0,this.xhr_.open(t,e,!0),i!==void 0)for(const a in i)i.hasOwnProperty(a)&&this.xhr_.setRequestHeader(a,i[a].toString());return r!==void 0?this.xhr_.send(r):this.xhr_.send(),this.sendPromise_}getErrorCode(){if(!this.sent_)throw lp("cannot .getErrorCode() before sending");return this.errorCode_}getStatus(){if(!this.sent_)throw lp("cannot .getStatus() before sending");try{return this.xhr_.status}catch{return-1}}getResponse(){if(!this.sent_)throw lp("cannot .getResponse() before sending");return this.xhr_.response}getErrorText(){if(!this.sent_)throw lp("cannot .getErrorText() before sending");return this.xhr_.statusText}abort(){this.xhr_.abort()}getResponseHeader(e){return this.xhr_.getResponseHeader(e)}addUploadProgressListener(e){this.xhr_.upload!=null&&this.xhr_.upload.addEventListener("progress",e)}removeUploadProgressListener(e){this.xhr_.upload!=null&&this.xhr_.upload.removeEventListener("progress",e)}}class EQ extends SQ{initXhr(){this.xhr_.responseType="text"}}function J9(){return new EQ}class Sd{constructor(e,t){this._service=e,t instanceof ea?this._location=t:this._location=ea.makeFromUrl(t,e.host)}toString(){return"gs://"+this._location.bucket+"/"+this._location.path}_newRef(e,t){return new Sd(e,t)}get root(){const e=new ea(this._location.bucket,"");return this._newRef(this._service,e)}get bucket(){return this._location.bucket}get fullPath(){return this._location.path}get name(){return G9(this._location.path)}get storage(){return this._service}get parent(){const e=oQ(this._location.path);if(e===null)return null;const t=new ea(this._location.bucket,e);return new Sd(this._service,t)}_throwIfRoot(e){if(this._location.path==="")throw UY(e)}}function TQ(n,e,t){n._throwIfRoot("uploadBytes");const s=wQ(n.storage,n._location,K9(),new jc(e,!0),t);return n.storage.makeRequestWithTokens(s,J9).then(r=>({metadata:r,ref:n}))}function _Q(n){n._throwIfRoot("getDownloadURL");const e=yQ(n.storage,n._location,K9());return n.storage.makeRequestWithTokens(e,J9).then(t=>{if(t===null)throw MY();return t})}function IQ(n,e){const t=lQ(n._location.path,e),s=new ea(n._location.bucket,t);return new Sd(n.storage,s)}function AQ(n){return/^[A-Za-z]+:\/\//.test(n)}function CQ(n,e){return new Sd(n,e)}function Z9(n,e){if(n instanceof j6){const t=n;if(t._bucket==null)throw jY();const s=new Sd(t,t._bucket);return e!=null?Z9(s,e):s}else return e!==void 0?IQ(n,e):n}function kQ(n,e){if(e&&AQ(e)){if(n instanceof j6)return CQ(n,e);throw Kb("To use ref(service, url), the first argument must be a Storage instance.")}else return Z9(n,e)}function M5(n,e){const t=e?.[U9];return t==null?null:ea.makeFromBucketSpec(t,n)}function RQ(n,e,t,s={}){n.host=`${e}:${t}`;const r=Cd(e);r&&c4(`https://${n.host}/b`),n._isUsingEmulator=!0,n._protocol=r?"https":"http";const{mockUserToken:i}=s;i&&(n._overrideAuthToken=typeof i=="string"?i:gC(i,n.app.options.projectId))}class j6{constructor(e,t,s,r,i,a=!1){this.app=e,this._authProvider=t,this._appCheckProvider=s,this._url=r,this._firebaseVersion=i,this._isUsingEmulator=a,this._bucket=null,this._host=F9,this._protocol="https",this._appId=null,this._deleted=!1,this._maxOperationRetryTime=TY,this._maxUploadRetryTime=_Y,this._requests=new Set,r!=null?this._bucket=ea.makeFromBucketSpec(r,this._host):this._bucket=M5(this._host,this.app.options)}get host(){return this._host}set host(e){this._host=e,this._url!=null?this._bucket=ea.makeFromBucketSpec(this._url,e):this._bucket=M5(e,this.app.options)}get maxUploadRetryTime(){return this._maxUploadRetryTime}set maxUploadRetryTime(e){O5("time",0,Number.POSITIVE_INFINITY,e),this._maxUploadRetryTime=e}get maxOperationRetryTime(){return this._maxOperationRetryTime}set maxOperationRetryTime(e){O5("time",0,Number.POSITIVE_INFINITY,e),this._maxOperationRetryTime=e}async _getAuthToken(){if(this._overrideAuthToken)return this._overrideAuthToken;const e=this._authProvider.getImmediate({optional:!0});if(e){const t=await e.getToken();if(t!==null)return t.accessToken}return null}async _getAppCheckToken(){if(Jn(this.app)&&this.app.settings.appCheckToken)return this.app.settings.appCheckToken;const e=this._appCheckProvider.getImmediate({optional:!0});
56return e?(await e.getToken()).token:null}_delete(){return this._deleted||(this._deleted=!0,this._requests.forEach(e=>e.cancel()),this._requests.clear()),Promise.resolve()}_makeStorageReference(e){return new Sd(this,e)}_makeRequest(e,t,s,r,i=!0){if(this._deleted)return new VY(V9());{const a=XY(e,this._appId,s,r,t,this._firebaseVersion,i,this._isUsingEmulator);return this._requests.add(a),a.getPromise().then(()=>this._requests.delete(a),()=>this._requests.delete(a)),a}}async makeRequestWithTokens(e,t){const[s,r]=await Promise.all([this._getAuthToken(),this._getAppCheckToken()]);return this._makeRequest(e,t,s,r).getPromise()}}const F5="@firebase/storage",U5="0.14.3";const eP="storage";function PQ(n,e,t){return n=wt(n),TQ(n,e,t)}function NQ(n){return n=wt(n),_Q(n)}function LQ(n,e){return n=wt(n),kQ(n,e)}function V5(n=Im(),e){n=wt(n);const s=gu(n,eP).getImmediate({identifier:e}),r=hC("storage");return r&&DQ(s,...r),s}function DQ(n,e,t,s={}){RQ(n,e,t,s)}function jQ(n,{instanceIdentifier:e}){const t=n.getProvider("app").getImmediate(),s=n.getProvider("auth-internal"),r=n.getProvider("app-check-internal");return new j6(t,s,r,e,kd)}function OQ(){ho(new Ia(eP,jQ,"PUBLIC").setMultipleInstances(!0)),_i(F5,U5,""),_i(F5,U5,"esm2020")}OQ();const MQ=(n,e)=>e.some(t=>n instanceof t);let B5,z5;function FQ(){return B5||(B5=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function UQ(){return z5||(z5=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const tP=new WeakMap,qb=new WeakMap,nP=new WeakMap,uv=new WeakMap,O6=new WeakMap;function VQ(n){const e=new Promise((t,s)=>{const r=()=>{n.removeEventListener("success",i),n.removeEventListener("error",a)},i=()=>{t(Qc(n.result)),r()},a=()=>{s(n.error),r()};n.addEventListener("success",i),n.addEventListener("error",a)});return e.then(t=>{t instanceof IDBCursor&&tP.set(t,n)}).catch(()=>{}),O6.set(e,n),e}function BQ(n){if(qb.has(n))return;const e=new Promise((t,s)=>{const r=()=>{n.removeEventListener("complete",i),n.removeEventListener("error",a),n.removeEventListener("abort",a)},i=()=>{t(),r()},a=()=>{s(n.error||new DOMException("AbortError","AbortError")),r()};n.addEventListener("complete",i),n.addEventListener("error",a),n.addEventListener("abort",a)});qb.set(n,e)}let Yb={get(n,e,t){if(n instanceof IDBTransaction){if(e==="done")return qb.get(n);if(e==="objectStoreNames")return n.objectStoreNames||nP.get(n);if(e==="store")return t.objectStoreNames[1]?void 0:t.objectStore(t.objectStoreNames[0])}return Qc(n[e])},set(n,e,t){return n[e]=t,!0},has(n,e){return n instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in n}};function zQ(n){Yb=n(Yb)}function $Q(n){return n===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...t){const s=n.call(dv(this),e,...t);return nP.set(s,e.sort?e.sort():[e]),Qc(s)}:UQ().includes(n)?function(...e){return n.apply(dv(this),e),Qc(tP.get(this))}:function(...e){return Qc(n.apply(dv(this),e))}}function HQ(n){return typeof n=="function"?$Q(n):(n instanceof IDBTransaction&&BQ(n),MQ(n,FQ())?new Proxy(n,Yb):n)}function Qc(n){if(n instanceof IDBRequest)return VQ(n);if(uv.has(n))return uv.get(n);const e=HQ(n);return e!==n&&(uv.set(n,e),O6.set(e,n)),e}const dv=n=>O6.get(n);function WQ(n,e,{blocked:t,upgrade:s,blocking:r,terminated:i}={}){const a=indexedDB.open(n,e),l=Qc(a);return s&&a.addEventListener("upgradeneeded",c=>{s(Qc(a.result),c.oldVersion,c.newVersion,Qc(a.transaction),c)}),t&&a.addEventListener("blocked",c=>t(c.oldVersion,c.newVersion,c)),l.then(c=>{i&&c.addEventListener("close",()=>i()),r&&c.addEventListener("versionchange",d=>r(d.oldVersion,d.newVersion,d))}).catch(()=>{}),l}const GQ=["get","getKey","getAll","getAllKeys","count"],KQ=["put","add","delete","clear"],hv=new Map;function $5(n,e){if(!(n instanceof IDBDatabase&&!(e in n)&&typeof e=="string"))return;if(hv.get(e))return hv.get(e);const t=e.replace(/FromIndex$/,""),s=e!==t,r=KQ.includes(t);if(!(t in(s?IDBIndex:IDBObjectStore).prototype)||!(r||GQ.includes(t)))return;const i=async function(a,...l){const c=this.transaction(a,r?"readwrite":"readonly");let d=c.store;
56return s&&(d=d.index(l.shift())),(await Promise.all([d[t](...l),r&&c.done]))[0]};return hv.set(e,i),i}zQ(n=>({...n,get:(e,t,s)=>$5(e,t)||n.get(e,t,s),has:(e,t)=>!!$5(e,t)||n.has(e,t)}));const sP="@firebase/installations",M6="0.6.22";const rP=1e4,iP=`w:${M6}`,aP="FIS_v2",qQ="https://firebaseinstallations.googleapis.com/v1",YQ=3600*1e3,QQ="installations",XQ="Installations";const JQ={"missing-app-config-values":'Missing App configuration value: "{$valueName}"',"not-registered":"Firebase Installation is not registered.","installation-not-found":"Firebase Installation not found.","request-failed":'{$requestName} request failed with error "{$serverCode} {$serverStatus}: {$serverMessage}"',"app-offline":"Could not process request. Application offline.","delete-pending-registration":"Can't delete installation while there is a pending registration request."},Ed=new Ad(QQ,XQ,JQ);function oP(n){return n instanceof Ra&&n.code.includes("request-failed")}function lP({projectId:n}){return`${qQ}/projects/${n}/installations`}function cP(n){return{token:n.token,requestStatus:2,expiresIn:eX(n.expiresIn),creationTime:Date.now()}}async function uP(n,e){const s=(await e.json()).error;return Ed.create("request-failed",{requestName:n,serverCode:s.code,serverMessage:s.message,serverStatus:s.status})}function dP({apiKey:n}){return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":n})}function ZQ(n,{refreshToken:e}){const t=dP(n);return t.append("Authorization",tX(e)),t}async function hP(n){const e=await n();return e.status>=500&&e.status<600?n():e}function eX(n){return Number(n.replace("s","000"))}function tX(n){return`${aP} ${n}`}async function nX({appConfig:n,heartbeatServiceProvider:e},{fid:t}){const s=lP(n),r=dP(n),i=e.getImmediate({optional:!0});if(i){const d=await i.getHeartbeatsHeader();d&&r.append("x-firebase-client",d)}const a={fid:t,authVersion:aP,appId:n.appId,sdkVersion:iP},l={method:"POST",headers:r,body:JSON.stringify(a)},c=await hP(()=>fetch(s,l));if(c.ok){const d=await c.json();return{fid:d.fid||t,registrationStatus:2,refreshToken:d.refreshToken,authToken:cP(d.authToken)}}else throw await uP("Create Installation",c)}function fP(n){return new Promise(e=>{setTimeout(e,n)})}function sX(n){return btoa(String.fromCharCode(...n)).replace(/\+/g,"-").replace(/\//g,"_")}const rX=/^[cdef][\w-]{21}$/,Qb="";function iX(){try{const n=new Uint8Array(17);(self.crypto||self.msCrypto).getRandomValues(n),n[0]=112+n[0]%16;const t=aX(n);return rX.test(t)?t:Qb}catch{return Qb}}function aX(n){return sX(n).substr(0,22)}function Xx(n){return`${n.appName}!${n.appId}`}const pP=new Map;function mP(n,e){const t=Xx(n);gP(t,e),oX(t,e)}function gP(n,e){const t=pP.get(n);if(t)for(const s of t)s(e)}function oX(n,e){const t=lX();t&&t.postMessage({key:n,fid:e}),cX()}let ed=null;function lX(){return!ed&&"BroadcastChannel"in self&&(ed=new BroadcastChannel("[Firebase] FID Change"),ed.onmessage=n=>{gP(n.data.key,n.data.fid)}),ed}function cX(){pP.size===0&&ed&&(ed.close(),ed=null)}const uX="firebase-installations-database",dX=1,Td="firebase-installations-store";let fv=null;function F6(){return fv||(fv=WQ(uX,dX,{upgrade:(n,e)=>{e===0&&n.createObjectStore(Td)}})),fv}async function A1(n,e){const t=Xx(n),r=(await F6()).transaction(Td,"readwrite"),i=r.objectStore(Td),a=await i.get(t);return await i.put(e,t),await r.done,(!a||a.fid!==e.fid)&&mP(n,e.fid),e}async function xP(n){const e=Xx(n),s=(await F6()).transaction(Td,"readwrite");await s.objectStore(Td).delete(e),await s.done}async function Jx(n,e){const t=Xx(n),r=(await F6()).transaction(Td,"readwrite"),i=r.objectStore(Td),a=await i.get(t),l=e(a);return l===void 0?await i.delete(t):await i.put(l,t),await r.done,l&&(!a||a.fid!==l.fid)&&mP(n,l.fid),l}async function U6(n){let e;const t=await Jx(n.appConfig,s=>{const r=hX(s),i=fX(n,r);return e=i.registrationPromise,i.installationEntry});return t.fid===Qb?{installationEntry:await e}:{installationEntry:t,registrationPromise:e}}function hX(n){const e=n||{fid:iX(),registrationStatus:0};return yP(e)}function fX(n,e){if(e.registrationStatus===0){if(!navigator.onLine){const r=Promise.reject(Ed.create("app-offline"));return{installationEntry:e,registrationPromise:r}}const t={fid:e.fid,registrationStatus:1,registrationTime:Date.now()},s=pX(n,t);return{installationEntry:t,registrationPromise:s}}else return e.registrationStatus===1?{installationEntry:e,registrationPromise:mX(n)}:{installationEntry:e}}async function pX(n,e){try{const t=await nX(n,e);return A1(n.appConfig,t)}catch(t){throw oP(t)&&t.customData.serverCode===409?await xP(n.appConfig):await A1(n.appConfig,{fid:e.fid,registrationStatus:0}),t}}async function mX(n){let e=await H5(n.appConfig);for(;e.registrationStatus===1;)await fP(100),e=await H5(n.appConfig);if(e.registrationStatus===0){const{installationEntry:t,registrationPromise:s}=await U6(n);return s||t}return e}function H5(n){return Jx(n,e=>{if(!e)throw Ed.create("installation-not-found");return yP(e)})}function yP(n){return gX(n)?{fid:n.fid,registrationStatus:0}:n}function gX(n){return n.registrationStatus===1&&n.registrationTime+rP<Date.now()}async function xX({appConfig:n,heartbeatServiceProvider:e},t){const s=yX(n,t),r=ZQ(n,t),i=e.getImmediate({optional:!0});if(i){const d=await i.getHeartbeatsHeader();d&&r.append("x-firebase-client",d)}const a={installation:{sdkVersion:iP,appId:n.appId}},l={method:"POST",headers:r,body:JSON.stringify(a)},c=await hP(()=>fetch(s,l));if(c.ok){const d=await c.json();return cP(d)}else throw await uP("Generate Auth Token",c)}function yX(n,{fid:e}){return`${lP(n)}/${e}/authTokens:generate`}async function V6(n,e=!1){let t;const s=await Jx(n.appConfig,i=>{if(!vP(i))throw Ed.create("not-registered");const a=i.authToken;if(!e&&wX(a))return i;if(a.requestStatus===1)return t=vX(n,e),i;{if(!navigator.onLine)throw Ed.create("app-offline");const l=EX(i);return t=bX(n,l),l}});return t?await t:s.authToken}async function vX(n,e){let t=await W5(n.appConfig);for(;t.authToken.requestStatus===1;)await fP(100),t=await W5(n.appConfig);const s=t.authToken;return s.requestStatus===0?V6(n,e):s}function W5(n){return Jx(n,e=>{if(!vP(e))throw Ed.create("not-registered");const t=e.authToken;return TX(t)?{...e,authToken:{requestStatus:0}}:e})}async function bX(n,e){try{const t=await xX(n,e),s={...e,authToken:t};return await A1(n.appConfig,s),t}catch(t){if(oP(t)&&(t.customData.serverCode===401||t.customData.serverCode===404))await xP(n.appConfig);else{const s={...e,authToken:{requestStatus:0}};await A1(n.appConfig,s)}throw t}}function vP(n){return n!==void 0&&n.registrationStatus===2}function wX(n){return n.requestStatus===2&&!SX(n)}function SX(n){const e=Date.now();return e<n.creationTime||n.creationTime+n.expiresIn<e+YQ}function EX(n){const e={requestStatus:1,requestTime:Date.now()};return{...n,authToken:e}}function TX(n){return n.requestStatus===1&&n.requestTime+rP<Date.now()}async function _X(n){const e=n,{installationEntry:t,registrationPromise:s}=await U6(e);return s?s.catch(console.error):V6(e).catch(console.error),t.fid}async function IX(n,e=!1){const t=n;return await AX(t),(await V6(t,e)).token}async function AX(n){const{registrationPromise:e}=await U6(n);e&&await e}function CX(n){if(!n||!n.options)throw pv("App Configuration");if(!n.name)throw pv("App Name");const e=["projectId","apiKey","appId"];for(const t of e)if(!n.options[t])throw pv(t);return{appName:n.name,projectId:n.options.projectId,apiKey:n.options.apiKey,appId:n.options.appId}}function pv(n){return Ed.create("missing-app-config-values",{valueName:n})}const bP="installations",kX="installations-internal",RX=n=>{const e=n.getProvider("app").getImmediate(),t=CX(e),s=gu(e,"heartbeat");return{app:e,appConfig:t,heartbeatServiceProvider:s,_delete:()=>Promise.resolve()}},PX=n=>{const e=n.getProvider("app").getImmediate(),t=gu(e,bP).getImmediate();return{getId:()=>_X(t),getToken:r=>IX(t,r)}};function NX(){ho(new Ia(bP,RX,"PUBLIC")),ho(new Ia(kX,PX,"PRIVATE"))}NX();_i(sP,M6);_i(sP,M6,"esm2020");const C1="analytics",LX="firebase_id",DX="origin",jX=60*1e3,OX="https://firebase.googleapis.com/v1alpha/projects/-/apps/{app-id}/webConfig",B6="https://www.googletagmanager.com/gtag/js";const ri=new ux("@firebase/analytics");const MX={"already-exists":"A Firebase Analytics instance with the appId {$id} already exists. Only one Firebase Analytics instance can be created for each appId.","already-initialized":"initializeAnalytics() cannot be called again with different options than those it was initially called with. It can be called again with the same options to return the existing instance, or getAnalytics() can be used to get a reference to the already-initialized instance.","already-initialized-settings":"Firebase Analytics has already been initialized.settings() must be called before initializing any Analytics instanceor it will have no effect.","interop-component-reg-failed":"Firebase Analytics Interop Component failed to instantiate: {$reason}
56","invalid-analytics-context":"Firebase Analytics is not supported in this environment. Wrap initialization of analytics in analytics.isSupported() to prevent initialization in unsupported environments. Details: {$errorInfo}","indexeddb-unavailable":"IndexedDB unavailable or restricted in this environment. Wrap initialization of analytics in analytics.isSupported() to prevent initialization in unsupported environments. Details: {$errorInfo}","fetch-throttle":"The config fetch request timed out while in an exponential backoff state. Unix timestamp in milliseconds when fetch request throttling ends: {$throttleEndTimeMillis}.","config-fetch-failed":"Dynamic config fetch failed: [{$httpStatus}] {$responseMessage}","no-api-key":'The "apiKey" field is empty in the local Firebase config. Firebase Analytics requires this field tocontain a valid API key.',"no-app-id":'The "appId" field is empty in the local Firebase config. Firebase Analytics requires this field tocontain a valid app ID.',"no-client-id":'The "client_id" field is empty.',"invalid-gtag-resource":"Trusted Types detected an invalid gtag resource: {$gtagURL}."},ta=new Ad("analytics","Analytics",MX);function FX(n){if(!n.startsWith(B6)){const e=ta.create("invalid-gtag-resource",{gtagURL:n});return ri.warn(e.message),""}return n}function wP(n){return Promise.all(n.map(e=>e.catch(t=>t)))}function UX(n,e){let t;return window.trustedTypes&&(t=window.trustedTypes.createPolicy(n,e)),t}function VX(n,e){const t=UX("firebase-js-sdk-policy",{createScriptURL:FX}),s=document.createElement("script"),r=`${B6}?l=${n}&id=${e}`;s.src=t?t?.createScriptURL(r):r,s.async=!0,document.head.appendChild(s)}function BX(n){let e=[];return Array.isArray(window[n])?e=window[n]:window[n]=e,e}async function zX(n,e,t,s,r,i){const a=s[r];try{if(a)await e[a];else{const c=(await wP(t)).find(d=>d.measurementId===r);c&&await e[c.appId]}}catch(l){ri.error(l)}n("config",r,i)}async function $X(n,e,t,s,r){try{let i=[];if(r&&r.send_to){let a=r.send_to;Array.isArray(a)||(a=[a]);const l=await wP(t);for(const c of a){const d=l.find(p=>p.measurementId===c),h=d&&e[d.appId];if(h)i.push(h);else{i=[];break}}}i.length===0&&(i=Object.values(e)),await Promise.all(i),n("event",s,r||{})}catch(i){ri.error(i)}}function HX(n,e,t,s){async function r(i,...a){try{if(i==="event"){const[l,c]=a;await $X(n,e,t,l,c)}else if(i==="config"){const[l,c]=a;await zX(n,e,t,s,l,c)}else if(i==="consent"){const[l,c]=a;n("consent",l,c)}else if(i==="get"){const[l,c,d]=a;n("get",l,c,d)}else if(i==="set"){const[l]=a;n("set",l)}else n(i,...a)}catch(l){ri.error(l)}}return r}function WX(n,e,t,s,r){let i=function(...a){window[s].push(arguments)};return window[r]&&typeof window[r]=="function"&&(i=window[r]),window[r]=HX(i,n,e,t),{gtagCore:i,wrappedGtag:window[r]}}function GX(n){const e=window.document.getElementsByTagName("script");for(const t of Object.values(e))if(t.src&&t.src.includes(B6)&&t.src.includes(n))return t;return null}const KX=30,qX=1e3;class YX{constructor(e={},t=qX){this.throttleMetadata=e,this.intervalMillis=t}getThrottleMetadata(e){return this.throttleMetadata[e]}setThrottleMetadata(e,t){this.throttleMetadata[e]=t}deleteThrottleMetadata(e){delete this.throttleMetadata[e]}}const SP=new YX;function QX(n){return new Headers({Accept:"application/json","x-goog-api-key":n})}async function XX(n){const{appId:e,apiKey:t}=n,s={method:"GET",headers:QX(t)},r=OX.replace("{app-id}",e),i=await fetch(r,s);if(i.status!==200&&i.status!==304){let a="";try{const l=await i.json();l.error?.message&&(a=l.error.message)}catch{}throw ta.create("config-fetch-failed",{httpStatus:i.status,responseMessage:a})}return i.json()}async function JX(n,e=SP,t){const{appId:s,apiKey:r,measurementId:i}=n.options;if(!s)throw ta.create("no-app-id");if(!r){if(i)return{measurementId:i,appId:s};throw ta.create("no-api-key")}const a=e.getThrottleMetadata(s)||{backoffCount:0,throttleEndTimeMillis:Date.now()},l=new tJ;return setTimeout(async()=>{l.abort()},jX),EP({appId:s,apiKey:r,measurementId:i},a,l,e)}async function EP(n,{throttleEndTimeMillis:e,backoffCount:t},s,r=SP){const{appId:i,measurementId:a}=n;try{await ZX(s,e)}catch(l){if(a)return ri.warn(`Timed out fetching this Firebase app's measurement ID from the server. Falling back to the measurement ID ${a} provided in the "measurementId" field in the local Firebase config. [${l?.message}
56]`),{appId:i,measurementId:a};throw l}try{const l=await XX(n);return r.deleteThrottleMetadata(i),l}catch(l){const c=l;if(!eJ(c)){if(r.deleteThrottleMetadata(i),a)return ri.warn(`Failed to fetch this Firebase app's measurement ID from the server. Falling back to the measurement ID ${a} provided in the "measurementId" field in the local Firebase config. [${c?.message}]`),{appId:i,measurementId:a};throw l}const d=Number(c?.customData?.httpStatus)===503?UT(t,r.intervalMillis,KX):UT(t,r.intervalMillis),h={throttleEndTimeMillis:Date.now()+d,backoffCount:t+1};return r.setThrottleMetadata(i,h),ri.debug(`Calling attemptFetch again in ${d} millis`),EP(n,h,s,r)}}function ZX(n,e){return new Promise((t,s)=>{const r=Math.max(e-Date.now(),0),i=setTimeout(t,r);n.addEventListener(()=>{clearTimeout(i),s(ta.create("fetch-throttle",{throttleEndTimeMillis:e}))})})}function eJ(n){if(!(n instanceof Ra)||!n.customData)return!1;const e=Number(n.customData.httpStatus);return e===429||e===500||e===503||e===504}class tJ{constructor(){this.listeners=[]}addEventListener(e){this.listeners.push(e)}abort(){this.listeners.forEach(e=>e())}}async function nJ(n,e,t,s,r){if(r&&r.global){n("event",t,s);return}else{const i=await e,a={...s,send_to:i};n("event",t,a)}}async function sJ(n,e,t,s){if(s&&s.global){const r={};for(const i of Object.keys(t))r[`user_properties.${i}`]=t[i];return n("set",r),Promise.resolve()}else{const r=await e;n("config",r,{update:!0,user_properties:t})}}async function rJ(){if(yC())try{await vC()}catch(n){return ri.warn(ta.create("indexeddb-unavailable",{errorInfo:n?.toString()}).message),!1}else return ri.warn(ta.create("indexeddb-unavailable",{errorInfo:"IndexedDB is not available in this environment."}).message),!1;return!0}async function iJ(n,e,t,s,r,i,a){const l=JX(n);l.then(m=>{t[m.measurementId]=m.appId,n.options.measurementId&&m.measurementId!==n.options.measurementId&&ri.warn(`The measurement ID in the local Firebase config (${n.options.measurementId}) does not match the measurement ID fetched from the server (${m.measurementId}). To ensure analytics events are always sent to the correct Analytics property, update the measurement ID field in the local config or remove it from the local config.`)}).catch(m=>ri.error(m)),e.push(l);const c=rJ().then(m=>{if(m)return s.getId()}),[d,h]=await Promise.all([l,c]);GX(i)||VX(i,d.measurementId),r("js",new Date);const p=a?.config??{};return p[DX]="firebase",p.update=!0,h!=null&&(p[LX]=h),r("config",d.measurementId,p),d.measurementId}class aJ{constructor(e){this.app=e}_delete(){return delete Bh[this.app.options.appId],Promise.resolve()}}let Bh={},G5=[];const K5={};let mv="dataLayer",oJ="gtag",q5,z6,Y5=!1;function lJ(){const n=[];if(xC()&&n.push("This is a browser extension environment."),LU()||n.push("Cookies are not available."),n.length>0){const e=n.map((s,r)=>`(${r+1}) ${s}`).join(" "),t=ta.create("invalid-analytics-context",{errorInfo:e});ri.warn(t.message)}}function cJ(n,e,t){lJ();const s=n.options.appId;if(!s)throw ta.create("no-app-id");if(!n.options.apiKey)if(n.options.measurementId)ri.warn(`The "apiKey" field is empty in the local Firebase config. This is needed to fetch the latest measurement ID for this Firebase app. Falling back to the measurement ID ${n.options.measurementId} provided in the "measurementId" field in the local Firebase config.`);else throw ta.create("no-api-key");if(Bh[s]!=null)throw ta.create("already-exists",{id:s});if(!Y5){BX(mv);const{wrappedGtag:i,gtagCore:a}=WX(Bh,G5,K5,mv,oJ);z6=i,q5=a,Y5=!0}return Bh[s]=iJ(n,G5,K5,e,q5,mv,t),new aJ(n)}function uJ(n=Im()){n=wt(n);const e=gu(n,C1);return e.isInitialized()?e.getImmediate():dJ(n)}function dJ(n,e={}){const t=gu(n,C1);if(t.isInitialized()){const r=t.getImmediate();if(qo(e,t.getOptions()))return r;throw ta.create("already-initialized")}return t.initialize({options:e})}function hJ(n,e,t){n=wt(n),sJ(z6,Bh[n.app.options.appId],e,t).catch(s=>ri.error(s))}function $6(n,e,t,s){n=wt(n),nJ(z6,Bh[n.app.options.appId],e,t,s).catch(r=>ri.error(r))}const Q5="@firebase/analytics",X5="0.10.22";function fJ(){ho(new Ia(C1,(e,{options:t})=>{const s=e.getProvider("app").getImmediate(),r=e.getProvider("installations-internal").getImmediate();return cJ(s,r,t)},"PUBLIC")),ho(new Ia("analytics-internal",n,"PRIVATE")),_i(Q5,X5),_i(Q5,X5,"esm2020");function n(e){try{const t=e.getProvider(C1).getImmediate();return{logEvent:(s,r,i)=>
56$6(t,s,r,i),setUserProperties:(s,r)=>hJ(t,s,r)}}catch(t){throw ta.create("interop-component-reg-failed",{reason:t})}}}fJ();var sf;(function(n){n.Unimplemented="UNIMPLEMENTED",n.Unavailable="UNAVAILABLE"})(sf||(sf={}));class gv extends Error{constructor(e,t,s){super(e),this.message=e,this.code=t,this.data=s}}const pJ=n=>{var e,t;return n?.androidBridge?"android":!((t=(e=n?.webkit)===null||e===void 0?void 0:e.messageHandlers)===null||t===void 0)&&t.bridge?"ios":"web"},mJ=n=>{const e=n.CapacitorCustomPlatform||null,t=n.Capacitor||{},s=t.Plugins=t.Plugins||{},r=()=>e!==null?e.name:pJ(n),i=()=>r()!=="web",a=p=>{const m=d.get(p);return!!(m?.platforms.has(r())||l(p))},l=p=>{var m;return(m=t.PluginHeaders)===null||m===void 0?void 0:m.find(y=>y.name===p)},c=p=>n.console.error(p),d=new Map,h=(p,m={})=>{const y=d.get(p);if(y)return y.proxy;const x=r(),w=l(p);let S;const _=async()=>(!S&&x in m?S=typeof m[x]=="function"?S=await m[x]():S=m[x]:e!==null&&!S&&"web"in m&&(S=typeof m.web=="function"?S=await m.web():S=m.web),S),L=(k,P)=>{var N,F;if(w){const z=w?.methods.find(U=>P===U.name);if(z)return z.rtype==="promise"?U=>t.nativePromise(p,P.toString(),U):(U,fe)=>t.nativeCallback(p,P.toString(),U,fe);if(k)return(N=k[P])===null||N===void 0?void 0:N.bind(k)}else{if(k)return(F=k[P])===null||F===void 0?void 0:F.bind(k);throw new gv(`"${p}" plugin is not implemented on ${x}`,sf.Unimplemented)}},R=k=>{let P;const N=(...F)=>{const z=_().then(U=>{const fe=L(U,k);if(fe){const oe=fe(...F);return P=oe?.remove,oe}else throw new gv(`"${p}.${k}()" is not implemented on ${x}`,sf.Unimplemented)});return k==="addListener"&&(z.remove=async()=>P()),z};return N.toString=()=>`${k.toString()}() { [capacitor code] }`,Object.defineProperty(N,"name",{value:k,writable:!1,configurable:!1}),N},M=R("addListener"),V=R("removeListener"),W=(k,P)=>{const N=M({eventName:k},P),F=async()=>{const U=await N;V({eventName:k,callbackId:U},P)},z=new Promise(U=>N.then(()=>U({remove:F})));return z.remove=async()=>{await F()},z},I=new Proxy({},{get(k,P){switch(P){case"$$typeof":return;case"toJSON":return()=>({});case"addListener":return w?W:M;case"removeListener":return V;default:return R(P)}}});return s[p]=I,d.set(p,{name:p,proxy:I,platforms:new Set([...Object.keys(m),...w?[x]:[]])}),I};return t.convertFileSrc||(t.convertFileSrc=p=>p),t.getPlatform=r,t.handleError=c,t.isNativePlatform=i,t.isPluginAvailable=a,t.registerPlugin=h,t.Exception=gv,t.DEBUG=!!t.DEBUG,t.isLoggingEnabled=!!t.isLoggingEnabled,t},gJ=n=>n.Capacitor=mJ(n),Zr=gJ(typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}),sl=Zr.registerPlugin;class TP{constructor(){this.listeners={},this.retainedEventArguments={},this.windowListeners={}}addListener(e,t){let s=!1;this.listeners[e]||(this.listeners[e]=[],s=!0),this.listeners[e].push(t);const i=this.windowListeners[e];i&&!i.registered&&this.addWindowListener(i),s&&this.sendRetainedArgumentsForEvent(e);const a=async()=>this.removeListener(e,t);return Promise.resolve({remove:a})}async removeAllListeners(){this.listeners={};for(const e in this.windowListeners)this.removeWindowListener(this.windowListeners[e]);this.windowListeners={}}notifyListeners(e,t,s){const r=this.listeners[e];if(!r){if(s){let i=this.retainedEventArguments[e];i||(i=[]),i.push(t),this.retainedEventArguments[e]=i}return}r.forEach(i=>i(t))}hasListeners(e){var t;return!!(!((t=this.listeners[e])===null||t===void 0)&&t.length)}registerWindowListener(e,t){this.windowListeners[t]={registered:!1,windowEventName:e,pluginEventName:t,handler:s=>{this.notifyListeners(t,s)}}}unimplemented(e="not implemented"){return new Zr.Exception(e,sf.Unimplemented)}unavailable(e="not available"){return new Zr.Exception(e,sf.Unavailable)}async removeListener(e,t){const s=this.listeners[e];if(!s)return;const r=s.indexOf(t);this.listeners[e].splice(r,1),this.listeners[e].length||this.removeWindowListener(this.windowListeners[e])}addWindowListener(e){window.addEventListener(e.windowEventName,e.handler),e.registered=!0}removeWindowListener(e){e&&(window.removeEventListener(e.windowEventName,e.handler),e.registered=!1)}sendRetainedArgumentsForEvent(e){const t=this.retainedEventArguments[e];t&&(delete this.retainedEventArguments[e],t.forEach(s=>{this.notifyListeners(e,s)}))}}const J5=n=>
56encodeURIComponent(n).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape),Z5=n=>n.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent);class xJ extends TP{async getCookies(){const e=document.cookie,t={};return e.split(";").forEach(s=>{if(s.length<=0)return;let[r,i]=s.replace(/=/,"CAP_COOKIE").split("CAP_COOKIE");r=Z5(r).trim(),i=Z5(i).trim(),t[r]=i}),t}async setCookie(e){try{const t=J5(e.key),s=J5(e.value),r=e.expires?`; expires=${e.expires.replace("expires=","")}`:"",i=(e.path||"/").replace("path=",""),a=e.url!=null&&e.url.length>0?`domain=${e.url}`:"";document.cookie=`${t}=${s||""}${r}; path=${i}; ${a};`}catch(t){return Promise.reject(t)}}async deleteCookie(e){try{document.cookie=`${e.key}=; Max-Age=0`}catch(t){return Promise.reject(t)}}async clearCookies(){try{const e=document.cookie.split(";")||[];for(const t of e)document.cookie=t.replace(/^ +/,"").replace(/=.*/,`=;expires=${new Date().toUTCString()};path=/`)}catch(e){return Promise.reject(e)}}async clearAllCookies(){try{await this.clearCookies()}catch(e){return Promise.reject(e)}}}sl("CapacitorCookies",{web:()=>new xJ});const yJ=async n=>new Promise((e,t)=>{const s=new FileReader;s.onload=()=>{const r=s.result;e(r.indexOf(",")>=0?r.split(",")[1]:r)},s.onerror=r=>t(r),s.readAsDataURL(n)}),vJ=(n={})=>{const e=Object.keys(n);return Object.keys(n).map(r=>r.toLocaleLowerCase()).reduce((r,i,a)=>(r[i]=n[e[a]],r),{})},bJ=(n,e=!0)=>n?Object.entries(n).reduce((s,r)=>{const[i,a]=r;let l,c;return Array.isArray(a)?(c="",a.forEach(d=>{l=e?encodeURIComponent(d):d,c+=`${i}=${l}&`}),c.slice(0,-1)):(l=e?encodeURIComponent(a):a,c=`${i}=${l}`),`${s}&${c}`},"").substr(1):null,wJ=(n,e={})=>{const t=Object.assign({method:n.method||"GET",headers:n.headers},e),r=vJ(n.headers)["content-type"]||"";
56if(typeof n.data=="string")t.body=n.data;else if(r.includes("application/x-www-form-urlencoded")){const i=new URLSearchParams;for(const[a,l]of Object.entries(n.data||{}))i.set(a,l);t.body=i.toString()}else if(r.includes("multipart/form-data")||n.data instanceof FormData){const i=new FormData;if(n.data instanceof FormData)n.data.forEach((l,c)=>{i.append(c,l)});else for(const l of Object.keys(n.data))i.append(l,n.data[l]);t.body=i;const a=new Headers(t.headers);a.delete("content-type"),t.headers=a}else(r.includes("application/json")||typeof n.data=="object")&&(t.body=JSON.stringify(n.data));return t};class SJ extends TP{async request(e){const t=wJ(e,e.webFetchExtra),s=bJ(e.params,e.shouldEncodeUrlParams),r=s?`${e.url}?${s}`:e.url,i=await fetch(r,t),a=i.headers.get("content-type")||"";let{responseType:l="text"}=i.ok?e:{};a.includes("application/json")&&(l="json");let c,d;switch(l){case"arraybuffer":case"blob":d=await i.blob(),c=await yJ(d);break;case"json":c=await i.json();break;default:c=await i.text()}const h={};return i.headers.forEach((p,m)=>{h[m]=p}),{data:c,headers:h,status:i.status,url:i.url}}async get(e){return this.request(Object.assign(Object.assign({},e),{method:"GET"}))}async post(e){return this.request(Object.assign(Object.assign({},e),{method:"POST"}))}async put(e){return this.request(Object.assign(Object.assign({},e),{method:"PUT"}))}async patch(e){return this.request(Object.assign(Object.assign({},e),{method:"PATCH"}))}async delete(e){return this.request(Object.assign(Object.assign({},e),{method:"DELETE"}))}}const EJ=sl("CapacitorHttp",{web:()=>new SJ}),H6=sl("SocialLogin",{web:()=>ps(()=>import("./web-Bv0tzHvW.js"),[]).then(n=>new n.SocialLoginWeb)}),e_={apiKey:"AIzaSyCWTiwkXtJZk3ZIOeJ8EosaGVh9ONK0DNQ",authDomain:"chronictv-baffe.firebaseapp.com",projectId:"chronictv-baffe",storageBucket:"chronictv-baffe.firebasestorage.app",messagingSenderId:"1044709116948",appId:"1:1044709116948:web:505b5acbef6d437421ab01",measurementId:"G-W25NNQN2M3"};let Ki=null,It=null,je=null,Oc=null,Ml=null,t_=!1;const _P=async()=>{if(t_)return;if(Zr.isNativePlatform())try{await H6.initialize({google:{webClientId:"1044709116948-jbkep7pgfhuvs7otmfmumm29ln8lkh24.apps.googleusercontent.com",iOSClientId:"1044709116948-i5l7v97ob9h140anmqt7a4p9ff9kiikr.apps.googleusercontent.com"}}),t_=!0}catch{}},vu=()=>{if(Ki&&It&&je)return{app:Ki,auth:It,db:je,storage:Oc,analytics:Ml};if(!e_.apiKey)return null;try{return Ki=d4(e_),It=yd(Ki),je=k5(Ki),Oc=V5(Ki),typeof window<"u"&&(Ml=uJ(Ki)),_P(),{app:Ki,auth:It,db:je,storage:Oc,analytics:Ml}}catch(n){return n?.code==="app/duplicate-app"?(Ki=Im(),It=yd(Ki),je=k5(Ki),Oc=V5(Ki),{app:Ki,auth:It,db:je,storage:Oc,analytics:Ml}):null}},Vm=async()=>{if(!It)throw new Error("Firebase not initialized. Please refresh the page and try again.");if(Zr.isNativePlatform()){await _P();const t=await H6.login({provider:"google",options:{scopes:["profile","email"]}});t?.result,t?.result?.credential;const s=t?.result?.credential?.idToken||t?.credential?.idToken||t?.result?.idToken||t?.idToken;if(s){const r=Si.credential(s),i=await vf(It,r);
56if(!It.currentUser)throw new Error("Sign-in succeeded but session not established. Please try again.");return await uu(i.user.uid,{displayName:i.user.displayName||"",email:i.user.email||""}),_d(i.user.uid),i.user}else{const r="No idToken received from Google sign-in";throw new Error(r)}}else{const e=new Si;e.addScope("profile"),e.addScope("email");try{const t=await k4(It,e);return await uu(t.user.uid,{displayName:t.user.displayName||"",email:t.user.email||""}),_d(t.user.uid),t.user}catch(t){throw t.code==="auth/popup-closed-by-user"?new Error("Sign-in was cancelled. Please try again."):t.code==="auth/popup-blocked"?new Error("Pop-up was blocked by your browser. Please allow pop-ups for this site and try again."):t.code==="auth/cancelled-popup-request"?new Error("Sign-in was cancelled. Please try again."):new Error(t.message||"Google sign-in failed. Please try again.")}}},Zx=async()=>{if(!It)throw new Error("Firebase not initialized. Please refresh the page and try again.");if(Zr.isNativePlatform())try{const t=await H6.login({provider:"apple",options:{scopes:["name","email"]}}),s=t?.result?.credential?.idToken||t?.credential?.idToken||t?.result?.idToken||t?.idToken;if(s){const{OAuthProvider:r}=await ps(async()=>{const{OAuthProvider:c}=await Promise.resolve().then(()=>kb);return{OAuthProvider:c}},void 0),a=new r("apple.com").credential({idToken:s}),l=await vf(It,a);return await uu(l.user.uid,{displayName:l.user.displayName||"",email:l.user.email||""}),_d(l.user.uid),l.user}else throw new Error("No idToken received from Apple sign-in")}catch(e){throw new Error(e?.message||"Apple sign-in failed. Please try again.")}else{const{OAuthProvider:e}=await ps(async()=>{const{OAuthProvider:s}=await Promise.resolve().then(()=>kb);return{OAuthProvider:s}},void 0),t=new e("apple.com");t.addScope("name"),t.addScope("email");try{const s=await k4(It,t);return await uu(s.user.uid,{displayName:s.user.displayName||"",email:s.user.email||""}),_d(s.user.uid),s.user}catch(s){throw s.code==="auth/popup-closed-by-user"?new Error("Sign-in was cancelled. Please try again."):s.code==="auth/popup-blocked"?new Error("Pop-up was blocked by your browser. Please allow pop-ups for this site and try again."):s.code==="auth/cancelled-popup-request"?new Error("Sign-in was cancelled. Please try again."):new Error(s.message||"Apple sign-in failed. Please try again.")}}},k1=async()=>{if(It)try{await hk(It)}catch{}},IP=async()=>{if(!It)throw new Error("Firebase not initialized");const n=new Si;n.addScope("profile"),n.addScope("email"),await kk(It,n)},ey=async()=>{if(!It)return null;try{const n=await Rk(It);return n?.user?n.user:null}catch{return null}},TJ=async()=>{if(!It||!It.currentUser)return{success:!1,error:"Not signed in"};try{const n=new Si;return n.addScope("profile"),n.addScope("email"),await Ik(It.currentUser,n),{success:!0}}catch(n){const e=n?.code||"";let t="Failed to link Google account";return e==="auth/credential-already-in-use"?t="This Google account is already linked to another user":e==="auth/provider-already-linked"?t="A Google account is already linked to this account":e==="auth/popup-blocked"?t="Pop-up was blocked. Please allow pop-ups and try again.":e==="auth/popup-closed-by-user"&&(t="Linking was cancelled"),{success:!1,error:t}}},_J=async()=>{if(!It||!It.currentUser)return{success:!1,error:"Not signed in"};try{return await ek(It.currentUser,"google.com"),{success:!0}}catch(n){const e=n?.code||"";let t="Failed to unlink Google account";return e==="auth/no-such-provider"&&(t="No Google account is linked"),{success:!1,error:t}}},IJ=n=>n.providerData.some(e=>e.providerId==="google.com"),AJ=n=>{let e=0;for(let t=0;t<n.length;t++){const s=n.charCodeAt(t);e=(e<<5)-e+s,e=e&e}return Math.abs(e).toString(36).substring(0,6)},uu=async(n,e)=>{if(je)try{const t=Gt(je,"users",n),s=await Sr(t),r=s.exists()?s.data():{},i={};if(e?.email&&!r.email&&(i.email=e.email),e?.displayName&&!r.displayName&&(i.displayName=e.displayName),e?.firstName)i.firstName=e.firstName;else if(!r.firstName){const a=r.displayName||e?.displayName||"";if(a){const l=a.trim().split(" ");l.length>=1&&l[0]&&(i.firstName=l[0]),l.length>=2&&(i.lastName=l.slice(1).join(" "))}}e?.lastName&&!r.lastName&&(i.lastName=e.lastName),e?.phoneNumber?i.phoneNumber=e.phoneNumber:r.phoneNumber||(i.phoneNumber=""),(!r.subscription||!r.subscription.authorizeNetSubscriptionId)&&(i.subscription={status:r.subscription?.status||"none",tier:r.subscription?.tier||"cultured",planName:r.subscription?.planName||"Cultured (Free)",priceAmount:r.subscription?.priceAmount||0,authorizeNetSubscriptionId:r.subscription?.authorizeNetSubscriptionId||"",authorizeNetCustomerProfileId:r.subscription?.authorizeNetCustomerProfileId||"",authorizeNetPaymentProfileId:r.subscription?.authorizeNetPaymentProfileId||"",lastRenewalDate:r.subscription?.lastRenewalDate||null,nextBillingDate:r.subscription?.nextBillingDate||null,createdAt:r.subscription?.createdAt||Ds(),updatedAt:Ds()}),r.billingAddress||(i.billingAddress={street:"",city:"",state:"",zipCode:"",country:"United States",updatedAt:Ds()}),r.paymentMethods||(i.paymentMethods=[]),r.createdAt||(i.createdAt=Ds()),Object.keys(i).length>0&&await Er(t,i,{merge:!0})}catch{}},CJ=async n=>{if(!je)return"";try{const e=Gt(je,"users",n),t=await Sr(e);if(!t.exists())return"";const s=t.data();return s.firstName?s.lastName?`${s.firstName} ${s.lastName}`:s.firstName:s.displayName||""}catch{return""}},AP=async n=>{if(!je)return null;try{const e=Gt(je,"users",n),t=await Sr(e);if(!t.exists())return null;const s=t.data();return{firstName:s.firstName||"",lastName:s.lastName||"",phoneNumber:s.phoneNumber||"",displayName:s.displayName||"",email:s.email||""}}catch{return null}},CP=async(n,e)=>{if(!je||!It)throw new Error("Firebase not initialized");try{const t=Gt(je,"users",n);await Er(t,{...e,updatedAt:Ds()},{merge:!0}),e.displayName&&It.currentUser&&await S4(It.currentUser,{displayName:e.displayName})}catch(t){throw t}},kP=async(n,e)=>{if(!It||!It.currentUser)return{success:!1,error:"Not signed in"};try{const t=It.currentUser,s=nl.credential(t.email,n);await px(t,s);const{updatePassword:r}=await ps(async()=>{const{updatePassword:i}=await Promise.resolve().then(()=>kb);return{updatePassword:i}},void 0);return await r(t,e),{success:!0}}catch(t){return t.code==="auth/wrong-password"?{success:!1,error:"Current password is incorrect"}:t.code==="auth/weak-password"?{success:!1,error:"New password is too weak"}:t.code==="auth/requires-recent-login"?{success:!1,error:"Please sign out and sign back in, then try again"}:{success:!1,error:t.message||"Failed to change password"}}},W6=async n=>{if(!je)return"";try{const e=Gt(je,"users",n.uid),t=await Sr(e);if(t.exists()&&t.data()?.membershipProofId)return t.data().membershipProofId;const s=(n.displayName||"Member").split(" ")[0].replace(/[^a-zA-Z]/g,""),r=AJ(n.uid),i=`${s}${r}`;return await Er(e,{membershipProofId:i,displayName:n.displayName,email:n.email},{merge:!0}),i}catch{return""}},kJ=async n=>{if(!je)return null;try{const e=Ni(je,"users"),t=wd(e,_1("membershipProofId","==",n),k6(1)),s=await cu(t);if(s.empty)return null;const r=s.docs[0].data();return{displayName:r.displayName||"Member",email:r.email||"",tier:r.subscription?.tier||"cultured",status:r.subscription?.status||"none",lastRenewalDate:r.subscription?.lastRenewalDate?.toDate()||null,nextBillingDate:r.subscription?.nextBillingDate?.toDate()||null,photoIdUrl:r.photoIdUrl||null}}catch{return null}},kf=async(n,e,t,s,r)=>{if(!It)return{user:null,error:"Firebase not initialized"};try{const i=await ak(It,n,e),a=t&&s?`${t} ${s}`:t||"";return a&&i.user&&await S4(i.user,{displayName:a}),await uu(i.user.uid,{firstName:t,lastName:s,phoneNumber:r,displayName:a,email:n}),_d(i.user.uid),{user:i.user,error:null}}catch(i){return{user:null,error:i?.code==="auth/email-already-in-use"?"Email already in use":i?.code==="auth/weak-password"?"Password too weak (min 6 characters)":i?.message||"Sign up failed"}}},Rf=async(n,e)=>{if(!It)return{user:null,error:"Firebase not initialized"};try{const t=await ok(It,n,e);return await uu(t.user.uid,{displayName:t.user.displayName||"",email:t.user.email||""}),_d(t.user.uid),{user:t.user,error:null}}catch(t){return{user:null,error:t?.code==="auth/user-not-found"||t?.code==="auth/wrong-password"?"Invalid email or password":t?.code==="auth/invalid-email"?"Invalid email address":t?.message||"Sign in failed"}}},Pf=async n=>{if(!It)return{success:!1,error:"Firebase not initialized"};try{return await rk(It,n),{success:!0,error:null}}catch(e){return{success:!1,error:e?.code==="auth/user-not-found"?"No account found with this email":e?.message||"Failed to send reset email"}}},Md=n=>It?Rd(It,n):(n(null),()=>{}),RP=async n=>{if(!je||!n.length)return[];try{return(await Promise.all(n.map(t=>Sr(Gt(je,"archive_content",t))))).filter(t=>t.exists()).map(t=>t.data())}catch{return[]}},RJ=async n=>{if(!je)return!1;try{const e=Gt(je,"archive_content",n.identifier);return await Er(e,{...n,addedAt:Ds()},{merge:!0}),!0}catch{return!1}},PJ=()=>{const n=navigator.userAgent.toLowerCase();return n.includes("roku")?"Roku":n.includes("android tv")||n.includes("googletv")?"Android T
56V":n.includes("fire tv")||n.includes("silk")?"Amazon Fire TV":n.includes("smarttv")||n.includes("smart-tv")?"Smart TV":n.includes("ipad")?"iPad":n.includes("iphone")?"iPhone":n.includes("android")&&n.includes("mobile")?"Android Phone":n.includes("android")?"Android Tablet":n.includes("macintosh")||n.includes("mac os")?"Mac":n.includes("windows")?"Windows PC":n.includes("linux")?"Linux PC":"Unknown Device"},NJ=()=>{const n=navigator.userAgent;return n.includes("Firefox")?"Firefox":n.includes("SamsungBrowser")?"Samsung Browser":n.includes("Opera")||n.includes("OPR")?"Opera":n.includes("Edg")?"Edge":n.includes("Chrome")?"Chrome":n.includes("Safari")?"Safari":"Unknown Browser"},LJ=()=>{const n=navigator.userAgent.toLowerCase();return n.includes("roku")?"Roku OS":n.includes("android")?"Android":n.includes("iphone")||n.includes("ipad")?"iOS":n.includes("mac os")||n.includes("macintosh")?"macOS":n.includes("windows")?"Windows":n.includes("linux")?"Linux":"Unknown"},DJ=()=>{let n=localStorage.getItem("chronictv_device_id");if(n)return n;const e=Date.now().toString(36),t=Math.random().toString(36).substring(2,8);return n=`dev_${e}_${t}`,localStorage.setItem("chronictv_device_id",n),n},jJ=async()=>{try{return(await(await fetch("/api/client-ip")).json()).ip||"Unknown"}catch{return"Unknown"}},_d=async n=>{if(je)try{const e=DJ(),t=await jJ(),s=navigator.userAgent,r=PJ(),i=LJ(),a=NJ(),l=Gt(je,"users",n,"connectedDevices",e),c=await Sr(l),d={deviceId:e,ipAddress:t,userAgent:s,deviceType:r,platform:i,browser:a,lastActiveAt:Ds()};c.exists()||(d.firstSeenAt=Ds()),await Er(l,d,{merge:!0})}catch{}},OJ=async n=>{if(!je)return[];try{const e=Ni(je,"users",n,"connectedDevices"),t=wd(e,A6("lastActiveAt","desc"));return(await cu(t)).docs.map(r=>({...r.data(),lastActiveAt:r.data().lastActiveAt?.toDate()||new Date,firstSeenAt:r.data().firstSeenAt?.toDate()||new Date}))}catch{return[]}},MJ=async(n,e)=>{if(!je)return!1;try{return await I1(Gt(je,"users",n,"connectedDevices",e)),!0}catch{return!1}}
56,PP=async(n,e)=>{if(je)try{const t=Gt(je,"users",n,"watchHistory",e.videoId);await Er(t,{...e,watchedAt:Ds(),updatedAt:Ds()},{merge:!0})}catch{}},fm=async(n,e=20)=>{if(!je)return[];try{const t=Ni(je,"users",n,"watchHistory"),s=wd(t,A6("watchedAt","desc"),k6(e));return(await cu(s)).docs.map(i=>({...i.data(),watchedAt:i.data().watchedAt?.toDate()||new Date}))}catch{return[]}},Xb=async n=>{if(!je)return[];try{const e=Ni(je,"users",n,"watchHistory"),t=wd(e,_1("completed","==",!1),A6("watchedAt","desc"),k6(10));return(await cu(t)).docs.map(r=>({...r.data(),watchedAt:r.data().watchedAt?.toDate()||new Date}))}catch{return[]}},NP=async()=>{if(!je)return{};try{const n=Gt(je,"content_organization","show_tags"),e=await Sr(n);return e.exists()?e.data():{}}catch{return{}}},FJ=(n,e,t)=>{Ml&&$6(Ml,"video_view",{video_id:n,video_title:e,show_name:t||"Unknown"})},UJ=(n,e)=>{Ml&&$6(Ml,"video_complete",{video_id:n,video_title:e})},Jb=async n=>{if(!It||!It.currentUser)return{success:!1,error:"No user logged in"};try{const e=It.currentUser;if(je)try{const t=Ni(je,"users",e.uid,"watchHistory"),s=await cu(wd(t));for(const r of s.docs)await I1(Gt(je,"users",e.uid,"watchHistory",r.id));await I1(Gt(je,"users",e.uid))}catch{}return await fk(e),{success:!0,error:null}}catch(e){return e?.code==="auth/requires-recent-login"?{success:!1,error:"For security, please sign out and sign back in, then try again.",requiresReauth:!0}:{success:!1,error:e?.message||"Failed to delete account"}}},VJ=async n=>{if(!It||!It.currentUser)return{success:!1,error:"No user logged in"};try{const e=It.currentUser;if(e.providerData.find(r=>r.providerId==="password")&&e.email){const r=nl.credential(e.email,n);return await px(e,r),{success:!0,error:null}}if(e.providerData.find(r=>r.providerId==="google.com")){const r=new Si;return await _k(e,r),{success:!0,error:null}}return{success:!1,error:"Unknown authentication provider"}}catch(e){return{success:!1,error:e?.message||"Reauthentication failed"}}},R1=async(n,e)=>{if(!je)return{success:!1,error:"Firestore not available"};try{const t=Gt(je,"users",n);return await Er(t,{billingAddress:{...e,updatedAt:Ds()}},{merge:!0}),{success:!0,error:null}}catch(t){return{success:!1,error:t?.message||"Failed to save billing address"}}},Bm=async n=>{if(!je)return null;try{const e=Gt(je,"users",n),t=await Sr(e);if(t.exists()&&t.data()?.billingAddress){const s=t.data().billingAddress;return{street:s.street||"",city:s.city||"",state:s.state||"",zipCode:s.zipCode||"",country:s.country||"United States",updatedAt:s.updatedAt?.toDate()}}return null}catch{return null}},zm=async n=>{if(!je)return{status:"none",planName:"Free",tier:"cultured"};try{const e=Gt(je,"users",n),t=await Sr(e);if(t.exists()){const s=t.data();if(s?.adminGrantedPremier===!0)return{status:"active",planName:"Premier (Admin Granted)",tier:"premier",priceAmount:0};if(s?.subscription){const r=s.subscription;return{status:r.status||"none",planName:r.planName||"Free",tier:r.tier||"cultured",priceAmount:r.priceAmount,authorizeNetSubscriptionId:r.authorizeNetSubscriptionId,authorizeNetCustomerProfileId:r.authorizeNetCustomerProfileId,authorizeNetPaymentProfileId:r.authorizeNetPaymentProfileId,currentPeriodEnd:r.currentPeriodEnd?.toDate(),lastRenewalDate:r.lastRenewalDate?.toDate(),nextBillingDate:r.nextBillingDate?.toDate(),createdAt:r.createdAt?.toDate(),updatedAt:r.updatedAt?.toDate()}}}return{status:"none",planName:"Free",tier:"cultured"}}catch{return{status:"none",planName:"Free",tier:"cultured"}}},cd=async n=>{if(!je)return[];try{const e=Gt(je,"users",n),t=await Sr(e);return t.exists()&&t.data()?.paymentMethods?t.data().paymentMethods:[]}catch{return[]}},LP=async(n,e)=>{if(!je)return{success:!1,error:"Firestore not available",paymentMethodId:null};if(e.cardLast4&&e.cardLast4.length>4)return{success:!1,error:"Cannot store full card numbers",paymentMethodId:null};try{const t=`pm_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,s=Gt(je,"users",n),r=await Sr(s),i=r.exists()&&r.data()?.paymentMethods?r.data().paymentMethods:[],a=i.length===0?!0:e.isDefault,l=a?i.map(d=>({...d,isDefault:!1})):i,c={id:t,cardLast4:e.cardLast4,cardBrand:e.cardBrand,expirationMonth:e.expirationMonth,expirationYear:e.expirationYear,isDefault:a,authorizeNetCustomerProfileId:e.authorizeNetCustomerProfileId,authorizeNetPaymentProfileId:e.authorizeNetPaymentProfileId,createdAt:new Date};return await Er(s,{paymentMethods:[...l,c]},{merge:!0}),{success:!0,error:null,paymentMethodId:t}}catch(t){return{success:!1,error:t?.message||"Failed to save payment method",paymentMethodId:null}}},G6=async(n,e)=>{if(!je)return{success:!1,error:"Firestore not available"};try{const t=Gt(je,"users",n);return await Er(t,{subscription:{...e,updatedAt:Ds()}},{merge:!0}),{success:!0,error:null}}catch(t){return{success:!1,error:t?.message||"Failed to save subscription info"}}},K6=async n=>{if(!je)return{success:!1,error:"Firestore not available"};try{const e=Gt(je,"users",n);return await Er(e,{billingDisclaimer:{acknowledged:!0,acknowledgedAt:Ds(),disclaimerText:'I understand that charges will appear from "HiveStaffing" on my statement. I acknowledge that disputing this subscription charge will result in the loss of Partner discount benef
56its.'}},{merge:!0}),{success:!0,error:null}}catch(e){return{success:!1,error:e?.message||"Failed to save disclaimer acknowledgment"}}},pm=async(n,e)=>{if(!Oc||!je)return{success:!1,error:"Firebase not initialized",url:null};try{const t=Date.now(),s=e.name.split(".").pop()||"jpg",r=`photo-ids/${n}/${t}.${s}`,i=LQ(Oc,r);await PQ(i,e);const a=await NQ(i),l=Gt(je,"users",n),c=await Sr(l),d=c.exists()?c.data()?.photoIdUrl:null,h={photoIdUrl:a,photoIdUpdatedAt:Ds()};return d&&(h.photoIdHistory=YR({url:d,archivedAt:new Date().toISOString()})),await Er(l,h,{merge:!0}),{success:!0,error:null,url:a}}catch(t){return{success:!1,error:t?.message||"Failed to upload photo ID",url:null}}},q6=async n=>{if(!je)return null;try{const e=Gt(je,"users",n),t=await Sr(e);return t.exists()&&t.data()?.photoIdUrl?t.data().photoIdUrl:null}catch{return null}},Y6=async n=>{if(!je)return{success:!1,error:"Firebase not initialized"};try{const e=Gt(je,"users",n);return await Er(e,{photoIdConsent:{agreed:!0,agreedAt:Ds(),message:"I understand that Chronic Brands and Chronic Lounge requires my ID to keep all of its members safe, and without ID I may be denied entry."}},{merge:!0}),{success:!0,error:null}}catch(e){return{success:!1,error:e?.message||"Failed to save consent"}}},Q6=async n=>{if(!je)return!1;try{const e=Gt(je,"users",n),t=await Sr(e);return!!(t.exists()&&t.data()?.photoIdConsent?.agreed)}catch{return!1}},DP=async()=>{if(!je)return[];try{const n=Ni(je,"users"),e=await cu(n),t=[];return e.forEach(s=>{const r=s.data();let i="cultured";(r.subscription?.tier==="premier"||r.membershipProofId)&&(i="premier");let a="";r.createdAt&&(r.createdAt.toDate?a=r.createdAt.toDate().toISOString():typeof r.createdAt=="string"&&(a=r.createdAt)),t.push({id:s.id,displayName:r.displayName||r.name||"Unknown",email:r.email||"",tier:i,createdAt:a,premierDate:r.subscription?.startDate||void 0,photoIdUrl:r.photoIdUrl||void 0})}),t.sort((s,r)=>new Date(r.createdAt).getTime()-new Date(s.createdAt).getTime()),t}catch{return[]}},BJ=async()=>{const n=await DP(),e=new Date,t=new Date(e.getFullYear(),e.getMonth(),1);return{totalMembers:n.length,premierMembers:n.filter(s=>s.tier==="premier").length,newMembersThisMonth:n.filter(s=>new Date(s.createdAt)>=t).length}};async function zJ(n){if(!je||n.includes(" ")||/^[a-zA-Z\s]+$/.test(n))return n;try{const e=Gt(je,"brands",n),t=await Sr(e);if(t.exists()){const s=t.data();return s.name||s.brandName||n}}catch{}return n}async function jP(n){if(!je)return null;try{const e=Ni(je,"admin_portal_users"),t=wd(e,_1("email","==",n.toLowerCase())),s=await cu(t);if(s.empty)return null;const r=s.docs[0].data(),i=s.docs[0].id,a=[];r.brandName&&a.push(r.brandName),Array.isArray(r.assignedBrands)&&a.push(...r.assignedBrands),Array.isArray(r.brands)&&a.push(...r.brands);try{const c=Ni(je,"creator_brands"),d=wd(c,_1("creatorId","==",i));(await cu(d)).docs.forEach(p=>{const m=p.data();m.brandId&&a.push(m.brandId),m.brandName&&a.push(m.brandName)})}catch{}const l=[];for(const c of a)if(c){const d=await zJ(c);l.includes(d)||l.push(d)}return{email:r.email,brandName:l[0]||r.displayName||"",brandNames:l,isCreator:r.userLevel===2||r.userLevel===3}}catch{return null}}async function OP(n,e){if(!je)return{success:!1,error:"Firestore not initialized"};try{const t=Gt(je,"liveStreams",n);return await Er(t,{isLive:!0,startedAt:new Date,viewerCount:0,streamTitle:e||"Live Stream"}),{success:!0}}catch(t){return{success:!1,error:t.message}}}async function MP(n){if(!je)return{success:!1,error:"Firestore not initialized"};try{const e=Gt(je,"liveStreams",n);return await Er(e,{isLive:!1,startedAt:null,viewerCount:0,streamTitle:""}),{success:!0}}catch(e){return{success:!1,error:e.message}}}async function $J(n){if(!je)return null;try{const e=Gt(je,"liveStreams",n),t=await Sr(e);if(!t.exists())return null;const s=t.data();return{isLive:s.isLive||!1,startedAt:s.startedAt?.toDate?.()||null,viewerCount:s.viewerCount||0,streamTitle:s.streamTitle||"",liveStreamUrl:s.liveStreamUrl||null}}catch{return null}}function FP(n,e){if(!je)return e(null),()=>{};const t=Gt(je,"liveStreams",n);return Od(t,s=>{if(!s.exists())e(null);else{const r=s.data();e({isLive:r.isLive||!1,startedAt:r.startedAt?.toDate?.()||null,viewerCount:r.viewerCount||0,streamTitle:r.streamTitle||"",liveStreamUrl:r.liveStreamUrl||null})}},s=>{e(null)})}async function UP(n){if(je)try{const e=Gt(je,"liveStreams",n);await R6(e,{viewerCount:QR(1)})}catch{}}async function VP(n){if(je)try{const e=Gt(je,"liveStreams",n);await R6(e,{viewerCount:QR(-1)})}catch{}}const BP=async(n,e)=>{if(!je)return!1;try{const t=Gt(je,"liveStreams",n,"viewers",e);return await Er(t,{status:"waiting",createdAt:Ds()}),!0}catch{return!1}},zP=async(n,e,t)=>{if(!je)return!1;try{const s=Gt(je,"liveStreams",n,"viewers",e);return await Er(s,{offer:JSON.stringify(t),status:"offer_sent",updatedAt:Ds()},{merge:!0}),!0}catch{return!1}},$P=async(n,e,t)=>{if(!je)return!1;try{const s=Gt(je,"liveStreams",n,"viewers",e);return await Er(s,{answer:JSON.stringify(t),status:"connected",updatedAt:Ds()},{merge:!0}),!0}catch{return!1}},HP=(n,e,t)=>{if(!je)return()=>{};const s=Gt(je,"liveStreams",n,"viewers",e);return Od(s,r=>{r.exists()&&r.data()?.offer?t(JSON.parse(r.data().offer)):t(null)})},WP=(n,e)=>{if(!je)return()=>{};const t=Ni(je,"liveStreams",n,"viewers");return Od(t,s=>
56{s.docChanges().forEach(r=>{r.type==="added"&&e(r.doc.id,r.doc.data()?.status||"waiting")})})},GP=(n,e,t)=>{if(!je)return()=>{};const s=Gt(je,"liveStreams",n,"viewers",e);return Od(s,r=>{r.exists()&&r.data()?.answer&&t(JSON.parse(r.data().answer))})},KP=async(n,e,t)=>{if(!je)return;const s=Ni(je,"liveStreams",n,"viewers",e,"creatorCandidates");await O9(s,{candidate:JSON.stringify(t),createdAt:Ds()})},qP=async(n,e,t)=>{if(!je)return;const s=Ni(je,"liveStreams",n,"viewers",e,"viewerCandidates");await O9(s,{candidate:JSON.stringify(t),createdAt:Ds()})},YP=(n,e,t)=>{if(!je)return()=>{};const s=Ni(je,"liveStreams",n,"viewers",e,"creatorCandidates");return Od(s,r=>{r.docChanges().forEach(i=>{i.type==="added"&&i.doc.data()?.candidate&&t(JSON.parse(i.doc.data().candidate))})})},QP=(n,e,t)=>{if(!je)return()=>{};const s=Ni(je,"liveStreams",n,"viewers",e,"viewerCandidates");return Od(s,r=>{r.docChanges().forEach(i=>{i.type==="added"&&i.doc.data()?.candidate&&t(JSON.parse(i.doc.data().candidate))})})},XP=async(n,e)=>{je&&await I1(Gt(je,"liveStreams",n,"viewers",e))},JP=()=>`viewer_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,ZP=n=>{if(!je)return n(new Set),()=>{};const e=Ni(je,"liveStreams");return Od(e,t=>{const s=new Set;t.docs.forEach(r=>{r.data().isLive&&s.add(r.id)}),n(s)},t=>{n(new Set)})},HJ=Object.freeze(Object.defineProperty({__proto__:null,addCreatorIceCandidate:KP,addViewerIceCandidate:qP,get analytics(){return Ml},get auth(){return It},changeUserPassword:kP,checkGoogleRedirectResult:ey,get db(){return je},decrementLiveViewers:VP,deleteUserAccount:Jb,endLiveStream:MP,generateViewerId:JP,getAllMembersFromFirebase:DP,getArchiveItems:RP,getBillingAddress:Bm,getConnectedDevices:OJ,getContinueWatching:Xb,getCreatorProfile:jP,getFirebaseAnalytics:BJ,getLiveStatus:$J,getMembershipByProofId:kJ,getMembershipProofId:W6,getPaymentMethods:cd,getPhotoIdUrl:q6,getShowTags:NP,getSubscriptionInfo:zm,getUserDisplayName:CJ,getUserProfile:AP,getWatchHistory:fm,hasLinkedGoogleAccount:IJ,hasPhotoIdConsent:Q6,incrementLiveViewers:UP,initializeFirebase:vu,initializeUserData:uu,linkGoogleAccount:TJ,onAuthChange:Md,reauthenticateUser:VJ,registerViewer:BP,removeConnectedDevice:MJ,removeViewer:XP,resetPassword:Pf,saveArchiveItem:RJ,saveBillingAddress:R1,saveBillingDisclaimer:K6,savePaymentMethod:LP,savePhotoIdConsent:Y6,saveSubscriptionInfo:G6,saveWatchProgress:PP,setAnswerFromViewer:$P,setOfferForViewer:zP,signInWithApple:Zx,signInWithEmail:Rf,signInWithGoogle:Vm,signInWithGoogleRedirect:IP,signOutUser:k1,signUpWithEmail:kf,startLiveStream:OP,get storage(){return Oc},subscribeLiveStatus:FP,subscribeToAllLiveStreams:ZP,subscribeToCreatorIceCandidates:YP,subscribeToNewViewers:WP,subscribeToViewerAnswer:GP,subscribeToViewerIceCandidates:QP,subscribeToViewerOffer:HP,trackConnectedDevice:_d,trackVideoComplete:UJ,trackVideoView:FJ,unlinkGoogleAccount:_J,updateUserProfile:CP,uploadPhotoId:pm},Symbol.toStringTag,{value:"Module"})),eN=T.createContext(null);function WJ({children:n}){const[e,t]=T.useState({items:[],total:0}),[s,r]=T.useState(!0),[i,a]=T.useState(null);T.useEffect(()=>{if(!It){r(!1);return}const y=Rd(It,x=>{a(x),x?l(x):(t({items:[],total:0}),r(!1))});return()=>y()},[]);const l=async y=>{try{r(!0);const x=await y.getIdToken(),w=await fetch(`/api/cart/${y.uid}`,{headers:{Authorization:`Bearer ${x}`}});if(w.ok){const S=await w.json();t({items:S.items||[],total:S.total||0})}}catch{}finally{r(!1)}},c=async()=>{i&&await l(i)},d=async y=>{if(i)try{const x=await i.getIdToken();(await fetch(`/api/cart/${i.uid}/add`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${x}`},body:JSON.stringify({productId:y.productId,productName:y.productName,price:y.price,quantity:y.quantity||1,imageUrl:y.imageUrl,category:y.category,duration:y.duration,scheduledDate:y.scheduledDate,scheduledStartTime:y.scheduledStartTime,scheduledEndTime:y.scheduledEndTime,discountQty:y.discountQty,discountPrice:y.discountPrice})})).ok&&await l(i)}catch{}},h=async y=>{if(i)try{const x=await i.getIdToken();(await fetch(`/api/cart/${i.uid}/item/${y}`,{method:"DELETE",headers:{Authorization:`Bearer ${x}`}})).ok&&await l(i)}catch{}},p=async(y,x)=>
56{if(i)try{const w=await i.getIdToken();(await fetch(`/api/cart/${i.uid}/item/${y}`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${w}`},body:JSON.stringify({quantity:x})})).ok&&await l(i)}catch{}},m=async()=>{if(i)try{const y=await i.getIdToken();(await fetch(`/api/cart/${i.uid}`,{method:"DELETE",headers:{Authorization:`Bearer ${y}`}})).ok&&t({items:[],total:0})}catch{}};return o.jsx(eN.Provider,{value:{cart:e,isLoading:s,user:i,addToCart:d,removeFromCart:h,updateQuantity:p,clearCart:m,refreshCart:c},children:n})}function ty(){const n=T.useContext(eN);if(!n)throw new Error("useCart must be used within a CartProvider");return n}const n_=[{href:"/",label:"Home"},{href:"/brands",label:"Brands"},{href:"/shop",label:"Shop"},{href:"/membership",label:"Membership"},{href:"/about",label:"About"}];function N0({children:n}){const[e,t]=T.useState(!1),[s,r]=T.useState({}),i=Te=>r(pt=>({...pt,[Te]:!pt[Te]})),[a,l]=T.useState(!1),c=[{name:"Apple",icon:o4,url:"https://apps.apple.com/us/app/chronic-tv/id6757710156",color:"#fff",bg:"#000"},{name:"Google Play",icon:a4,url:"https://play.google.com/store/apps/details?id=com.chronictv2.app&pcampaignid=web_share",color:"#fff",bg:"#0f9d58"},{name:"Xbox",icon:hf,url:"https://apps.microsoft.com/detail/9p3w2zd0kb50?hl=en-us&gl=us&ocid=pdpshare",color:"#fff",bg:"#107c10"},{name:"Roku",icon:i4,url:"https://channelstore.roku.com/details/484ddc36cb4236b7a260cf6dd37459bb:557787d977c35a2d06a4cb75856abd21/chronic-tv",color:"#fff",bg:"#6f1ab1"},{name:"Website",icon:oo,url:"https://chronicbrandsusa.com/chronic-tv",color:"#fff",bg:"#1a1a1a"}],[d]=Xl(),{cart:h}=ty(),p=h.items.reduce((Te,pt)=>Te+pt.quantity,0),[m,y]=T.useState(null),[x,w]=T.useState(!1),[S,_]=T.useState("signin"),[L,R]=T.useState(""),[M,V]=T.useState(""),[W,I]=T.useState(""),[k,P]=T.useState(""),[N,F]=T.useState(""),[z,U]=T.useState(!1),[fe,oe]=T.useState(""),[X,Q]=T.useState(!1),[G,Y]=T.useState(!1),[ee,H]=T.useState(!1),[K,pe]=T.useState(""),[Fe,_e]=T.useState(!1),[ze,Ye]=T.useState(""),[tt,lt]=T.useState(!1),[ut,cn]=T.useState("cultured"),[ke,Ue]=T.useState([]),[rt,Ct]=T.useState(!1),[at,ft]=T.useState(!1),[Nt,At]=T.useState(!1),[ot,Yt]=T.useState(!1),[zt,wn]=T.useState(null),[Dt,Ee]=T.useState(!1),[He,le]=T.useState(""),[ne,J]=T.useState(!1),[De,Le]=T.useState(null),[Lt,Qe]=T.useState(!1),[it,Cn]=T.useState(!1),[Mn,Gn]=T.useState(!1),[ii,ai]=T.useState(!1),[Fs,os]=T.useState(!1),[vn,ln]=T.useState(null),[Qs,Tr]=T.useState(null),[hr,Na]=T.useState(null),[Xs,oi]=T.useState(!1),[_r,es]=T.useState(!1),[Ir,Ar]=T.useState([]),[Re,St]=T.useState(null),[Un,Vn]=T.useState(!1),[La,Br]=T.useState([]),[Da,Rn]=T.useState(!1);return T.useEffect(()=>{const Te=()=>Ee(!0);return window.addEventListener("open-proof-modal",Te),()=>window.removeEventListener("open-proof-modal",Te)},[]),T.useEffect(()=>{if(Dt||x||tt){const pt=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=pt}}},[Dt,x,tt]),T.useEffect(()=>{vu(),ey().catch(pt=>{});const Te=Md(async pt=>{if(y(pt),pt){const ys=await zm(pt.uid);cn(ys?.tier||"cultured"),Tr(ys?.lastRenewalDate||null),Na(ys?.nextBillingDate||null);const fr=await q6(pt.uid);Le(fr);const zr=await Q6(pt.uid);ai(zr);const ja=await W6(pt);le(ja)}else le(""),Le(null),ai(!1),Tr(null),Na(null)});return()=>Te()},[]),T.useEffect(()=>{window.scrollTo(0,0)},[d]),o.jsxs("div",{className:"min-h-screen bg-black text-white",children:[o.jsxs("header",{className:"fixed top-0 left-0 right-0 z-50 bg-black border-b border-white/10",children:[o.jsx("div",{className:"max-w-7xl mx-auto px-2 sm:px-4 md:px-6",children:o.jsxs("div",{className:"flex items-center justify-between h-16 md:h-20",children:[o.jsxs(Et,{href:"/",className:"flex items-center flex-shrink-0 md:hidden",children:[o.jsx(Is,{size:"base",color:"#4ade80",suffix:" Brands",suffixColor:"#ffffff"}),o.jsx("span",{className:"bg-white rounded-sm flex-shrink-0",style:{marginLeft:"-2px"},children:o.jsx("img",{src:OT,alt:"USA",className:"h-4 w-auto block"})})]}),o.jsxs(Et,{href:"/",className:"hidden md:flex items-center flex-shrink-0",children:[o.jsx(Is,{size:"3xl",color:"#4ade80",suffix:" Brands",suffixColor:"#ffffff",className:"text-2xl lg:text-3xl font-bold"}),o.jsx("span",{className:"bg-white rounded-sm flex-shrink-0",style:{marginLeft:"-4px"},children:o.jsx("img",{src:OT,alt:"USA",className:"h-6 w-auto block"})})]}),o.jsxs("nav",{className:"hidden md:flex items-center gap-3 lg:gap-6","data-testid":"nav-desktop",children:[n_.map(Te=>o.jsx(Et,{href:Te.href,className:`text-xs lg:text-sm font-medium uppercase tracking-wide transition-colors hover:text-[hsl(142,76%,45%)] whitespace-nowrap ${d===Te.href?"text-[hsl(142,76%,45%)]":"text-white/80"}`,"data-testid":`nav-link-${Te.label.toLowerCase().replace(" ","-")}`,children:Te.label},Te.href)),o.jsx(Et,{href:"/chronic-tv",className:"ml-1 lg:ml-2 transition-transform hover:scale-105 flex-shrink-0","data-testid":"nav-link-chronic-tv-logo",children:o.jsx("img",{src:"/assets/ChronicTVlogo2b.png",alt:"Chronic TV",className:"h-8 lg:h-10 w-auto"})}),m&&o.jsxs("button",{onClick:()=>Ee(!0),className:"hidden md:flex ml-2 lg:ml-3 relative items-center gap-1.5 px-3 py-1.5 rounded-lg text-black text-xs font-bold whitespace-nowrap flex-shrink-0",style:{background:"#ffd700",animation:"proofFlash 1.4s ease-in-out infinite"},"data-testid":"nav-proof-of-discount",children:[o.jsx(Yu,{size:14}),o.jsx("span",{className:"hidden lg:inline",children:"Proof of Discount"})]}),o.jsxs(Et,{href:"/cart",className:"ml-2 lg:ml-3 relative p-2 hover:bg-white/10 rounded-lg transition-colors","data-testid":"nav-link-cart",children:[o.jsx(Fl,{size:20,className:"text-white"}),p>0&&o.jsx("span",{className:"absolute -top-1 -right-1 w-5 h-5 bg-[#4ade80] text-black text-xs font-bold rounded-full flex items-center justify-center",children:p})]}),o.jsx("button",{onClick:()=>w(!0),className:"ml-2 lg:ml-3 w-8 h-8 lg:w-9 lg:h-9 rounded-full bg-[#4ade80] flex items-center justify-center overflow-hidden hover:scale-105 transition-transform flex-shrink-0",title:m?`Signed in as ${m.displayName||m.email}`:"Sign in","data-testid":"button-user-profile",children:m?.photoURL?o.jsx("img",{src:m.photoURL,alt:"Profile",className:"w-full h-full object-cover"}):o.jsx(jh,{size:18,className:"text-black"})})]}),o.jsxs("div",{className:"md:hidden flex items-center gap-1 flex-shrink-0 ml-auto",children:[m&&o.jsx("button",{onClick:()=>Ee(!0),className:"flex items-center justify-center rounded text-black font-bold flex-shrink-0",style:{background:"#ffd700",animation:"proofFlash 1.4s ease-in-out infinite",width:"28px",height:"28px",padding:"3px"},"data-testid":"mobile-proof-button",title:"Get Proof of Discount",children:o.jsx(Yu,{size:20})}),o.jsx("button",{className:"p-2 min-w-11 min-h-11 text-white flex-shrink-0","aria-label":e?"Close navigation menu":"Open navigation menu",onClick:()=>t(!e),"data-testid":"mobile-menu-toggle",children:e?o.jsx(Mr,{size:24}):o.jsx($7,{size:24})})]})]})}),e&&o.jsx("div",{className:"md:hidden bg-zinc-900 backdrop-blur-md border-t border-[#4ade80]/30 shadow-lg shadow-black/50",children:o.jsxs("nav",{className:"flex flex-col py-4","data-testid":"nav-mobile",children:[n_.map(Te=>o.jsx(Et,{href:Te.href,className:`px-6 py-3 text-lg font-medium transition-colors ${d===Te.href?"text-[hsl(142,76%,45%)] bg-white/5":"text-white/80 hover:text-white hover:bg-white/5"}`,onClick:()=>t(!1),"data-testid":`nav-mobile-link-${Te.label.toLowerCase().replace(" ","-")}`,children:Te.label},Te.href)),o.jsxs(Et,{href:"/chronic-tv",className:"px-6 py-3 flex items-center gap-3",onClick:()=>t(!1),"data-testid":"nav-mobile-link-chronic-tv-logo",children:[o.jsx("img",{src:"/assets/ChronicTVlogo2b.png",alt:"Chronic TV",className:"h-8 w-auto"}),o.jsx("span",{className:"text-lg font-medium text-white/80",children:"Watch Now"})]}),o.jsxs(Et,{href:"/cart",className:`px-6 py-3 flex items-center gap-3 text-lg font-medium transition-colors ${d==="/cart"?"text-[hsl(142,76%,45%)] bg-white/5":"text-white/80 hover:text-white hover:bg-white/5"}`,onClick:()=>t(!1),"data-testid":"nav-mobile-link-cart",children:[o.jsx(Fl,{size:20}),"Cart",p>0&&o.jsx("span",{className:"ml-auto bg-[#4ade80] text-black text-xs font-bold px-2 py-0.5 rounded-full",children:p})]}),o.jsxs("div",{className:"mx-4 mt-3 pt-3 border-t border-white/10 flex flex-col gap-3",children:[m&&o.jsxs("button",{onClick:()=>{t(!1),Ee(!0)},className:"w-full flex items-center justify-center gap-2 px-4 py-3 rounded-xl font-bold text-black text-base",style:{background:"#ffd700",animation:"proofFlash 1.4s ease-in-out infinite"},"data-testid":"mobile-menu-proof-button",children:[o.jsx(Yu,{size:20}),"Get Proof of Discount"]}),o.jsxs("button",{onClick:()=>{t(!1),w(!0)},className:"w-full flex items-center gap-3 px-2 py-3 rounded-xl bg-[#4ade80]/10 border border-[#4ade80]/30 text-[#4ade80] font-medium text-lg transition-colors hover:bg-[#4ade80]/20",children:[m?.photoURL?o.jsx("img",{src:m.photoURL,alt:"Profile",className:"w-8 h-8 rounded-full object-cover"}):o.jsx("div",{className:"w-8 h-8 rounded-full bg-[#4ade80] flex items-center justify-center",children:o.jsx(jh,{size:16,className:"text-black"})}),m?"My Account":"Sign In / Join"]})]})]})})]}),o.jsx("main",{className:"pt-16 md:pt-20",children:n}),o.jsx("footer",{className:"bg-[hsl(0,0%,5%)] border-t border-white/10 py-12 md:py-16",children:o.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6",children:[o.jsxs("div",{className:"text-center mb-10",children:[o.jsx("h3",{className:"text-2xl font-bold mb-3",children:o.jsx(Is,{size:"2xl",color:"#4ade80",suffix:" Brands"})}),o.jsx("p",{className:"text-white/60 max-w-lg mx-auto",children:"Empowering Oklahoma's cannabis community through media, events, services, and advocacy since 2018."}),o.jsxs("div",{className:"flex items-center justify-center gap-2 mt-6 flex-wrap",children:[o.jsxs(Et,{href:"/ArtistDevelopment",className:"flex-1 min-w-0 max-w-[140px] flex items-center justify-center gap-1.5 px-3 py-2.5 rounded-xl border border-[#4ade80]/40 bg-[#4ade80]/10 text-[#4ade80] text-xs font-semibold whitespace-nowrap hover:bg-[#4ade80]/20 transition-colors",children:[o.jsx("span",{children:"ðµ"})," Artist Dev"]}),o.jsxs(Et,{href:"/vendor",className:"flex-1 min-w-0 max-w-[140px] flex items-center justify-center gap-1.5 px-3 py-2.5 rounded-xl border border-[hsl(45,93%,47%)]/40 bg-[hsl(45,93%,47%)]/10 text-[hsl(45,93%,47%)] text-xs font-semibold whitespace-nowrap hover:bg-[hsl(45,93%,47%)]/20 transition-colors",children:[o.jsx("span",{children:"ðª"})," Vendor Portal"]}),o.jsxs("a",{href:"https://cbpublishing.live/",target:"_blank",rel:"noopener noreferrer",className:"flex-1 min-w-0 max-w-[140px] flex items-center justify-center gap-1.5 px-3 py-2.5 rounded-xl border border-purple-400/40 bg-purple-400/10 text-purple-300 text-xs font-semibold whitespace-nowrap hover:bg-purple-400/20 transition-colors",children:[o.jsx("span",{children:"ð"})," CB Publishing"]})]})]}),o.jsxs("div",{className:"border-t border-white/10 pt-2 flex flex-col md:flex-row md:divide-x md:divide-white/10",children:[o.jsxs("div",{className:"flex-1 border-b border-white/10 md:border-b-0 md:px-6 first:md:pl-0 last:md:pr-0",children:[o.jsxs("button",{className:"w-full flex items-center justify-between py-3 cursor-pointer",onClick:()=>i("quick"),children:[o.jsx("h4",{className:"text-[hsl(45,93%,47%)] font-semibold uppercase tracking-wide text-sm",children:"Qu
56ick Links"}),o.jsx(ao,{size:16,className:`text-white/40 transition-transform ${s.quick?"rotate-180":""}`})]}),s.quick&&o.jsxs("ul",{className:"grid grid-cols-2 gap-x-4 gap-y-3 pb-4",children:[o.jsx("li",{children:o.jsx(Et,{href:"/",className:"text-white/60 hover:text-[hsl(142,76%,45%)] transition-colors text-sm",children:"Home"})}),o.jsx("li",{children:o.jsx(Et,{href:"/brands",className:"text-white/60 hover:text-[hsl(142,76%,45%)] transition-colors text-sm",children:"Brands"})}),o.jsx("li",{children:o.jsx(Et,{href:"/shop",className:"text-white/60 hover:text-[hsl(142,76%,45%)] transition-colors text-sm",children:"Shop"})}),o.jsx("li",{children:o.jsx(Et,{href:"/membership",className:"text-white/60 hover:text-[hsl(142,76%,45%)] transition-colors text-sm","data-testid":"footer-membership-link",children:"Membership"})}),o.jsx("li",{children:o.jsx(Et,{href:"/about",className:"text-white/60 hover:text-[hsl(142,76%,45%)] transition-colors text-sm",children:"About"})}),o.jsx("li",{children:o.jsx(Et,{href:"/contact",className:"text-white/60 hover:text-[hsl(142,76%,45%)] transition-colors text-sm","data-testid":"footer-contact-link",children:"Contact"})}),o.jsx("li",{children:o.jsx("a",{href:"https://cbpublishing.live/",target:"_blank",rel:"noopener noreferrer",className:"text-white/60 hover:text-[hsl(142,76%,45%)] transition-colors text-sm",children:"CB Publishing"})}),o.jsx("li",{children:o.jsx("button",{onClick:()=>l(!0),className:"text-white/60 hover:text-[hsl(142,76%,45%)] transition-colors text-sm bg-transparent border-none p-0 cursor-pointer text-left",children:"Get the App"})}),m&&o.jsx("li",{children:o.jsx(Et,{href:"/orders",className:"text-white/60 hover:text-[hsl(142,76%,45%)] transition-colors text-sm","data-testid":"footer-purchase-history-link",children:"Purchase History"})})]})]}),o.jsxs("div",{className:"flex-1 border-b border-white/10 md:border-b-0 md:px-6",children:[o.jsxs("button",{className:"w-full flex items-center justify-between py-3 cursor-pointer",onClick:()=>i("services"),children:[o.jsx("h4",{className:"text-[hsl(45,93%,47%)] font-semibold uppercase tracking-wide text-sm",children:"Services"}),o.jsx(ao,{size:16,className:`text-white/40 transition-transform ${s.services?"rotate-180":""}`})]}),s.services&&o.jsxs("ul",{className:"grid grid-cols-2 gap-x-4 gap-y-3 pb-4",children:[o.jsx("li",{children:o.jsx(Et,{href:"/adminportal",className:"text-white/60 hover:text-[hsl(142,76%,45%)] transition-colors text-sm","data-testid":"footer-creator-portal-link",children:"Creator Portal"})}),o.jsx("li",{children:o.jsx(Et,{href:"/vendor",className:"text-white/60 hover:text-[hsl(142,76%,45%)] transition-colors text-sm",children:"Vendor Portal"})}),o.jsx("li",{children:o.jsx(Et,{href:"/activate-chronictv",className:"text-white/60 hover:text-[hsl(142,76%,45%)] transition-colors text-sm","data-testid":"footer-activate-tv-link",children:"Activate ChronicTV"})}),o.jsx("li",{children:o.jsx(Et,{href:"/chronic-games",className:"text-white/60 hover:text-[hsl(142,76%,45%)] transition-colors text-sm","data-testid":"footer-chronic-games-link",children:"Chronic Games"})}),o.jsx("li",{children:o.jsx(Et,{href:"/ArtistDevelopment",className:"text-white/60 hover:text-[hsl(142,76%,45%)] transition-colors text-sm",children:"Artist Development"})})]})]}),o.jsxs("div",{className:"flex-1 md:px-6",children:[o.jsxs("button",{className:"w-full flex items-center justify-between py-3 cursor-pointer",onClick:()=>i("legal"),children:[o.jsx("h4",{className:"text-[hsl(45,93%,47%)] font-semibold uppercase tracking-wide text-sm",children:"Legal"}),o.jsx(ao,{size:16,className:`text-white/40 transition-transform ${s.legal?"rotate-180":""}`})]}),s.legal&&o.jsxs("ul",{className:"grid grid-cols-2 gap-x-4 gap-y-3 pb-4",children:[o.jsx("li",{children:o.jsx(Et,{href:"/user-safety",className:"text-white/60 hover:text-[hsl(142,76%,45%)] transition-colors text-sm","data-testid":"footer-user-safety-link",children:"User Safety"})}),o.jsx("li",{children:o.jsx(Et,{href:"/terms-of-service",className:"text-white/60 hover:text-[hsl(142,76%,45%)] transition-colors text-sm","data-testid":"footer-terms-link",children:"Terms"})}),o.jsx("li",{children:o.jsx(Et,{href:"/privacy-policy",className:"text-white/60 hover:text-[hsl(142,76%,45%)] transition-colors text-sm","data-testid":"footer-privacy-link",children:"Privacy Policy"})}),o.jsx("li",{children:o.jsx(Et,{href:"/contentwaiver",className:"text-white/60 hover:text-[hsl(142,76%,45%)] transition-colors text-sm","data-testid":"footer-content-waiver-link",children:"Content Waiver"})})]})]})]}),o.jsxs("div",{className:"mt-10 pt-6 border-t border-white/10 text-center text-white/40 text-sm space-y-1",children:[o.jsxs("p",{children:["© ",new Date().getFullYear()," ",o.jsx(Is,{suffix:" Brands USA",size:"sm",color:"#9ca3af"}),". All rights reserved."]}),o.jsxs("p",{children:["Website Created by ",o.jsx("a",{href:"https://oraginalconcepts.com",target:"_blank",rel:"noopener noreferrer",className:"text-[#4ade80] hover:text-[#86efac] transition-colors",children:"Oraginal Concepts"})]})]})]})}),a&&o.jsx("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-[4000] p-5",onClick:Te=>{Te.target===Te.currentTarget&&l(!1)},children:o.jsxs("div",{className:"bg-[#111] rounded-2xl border border-[#333] p-7 w-full max-w-[400px]",children:[o.jsxs("div",{className:"flex justify-between items-center mb-2",children:[o.jsx("h2",{className:"text-white text-xl font-bold m-0",children:"Get ChronicTV"}),o.jsx("button",{onClick:()=>l(!1),className:"bg-transparent border-none text-white/60 cursor-pointer hover:text-white",children:o.jsx(Mr,{size:22})})]}),o.jsx("p",{className:"text-white/50 text-sm mb-6",children:"Available on your favorite platforms"}),o.jsx("div",{className:"flex flex-col gap-3",children:c.map(Te=>{const pt=Te.icon;return o.jsxs("a",{href:Te.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-4 px-5 py-4 rounded-xl no-underline border border-white/10 transition-opacity hover:opacity-80",style:{background:Te.bg,color:Te.color},children:[o.jsx(pt,{size:22}),o.jsxs("div",{children:[o.jsx("div",{className:"text-xs opacity-70 mb-0.5",children:"Download on"}),o.jsx("div",{className:"text-[15px] font-semibold",children:Te.name})]})]},Te.name)})})]})}),x&&o.jsx("div",{className:"fixed inset-0 bg-black/85 flex items-center justify-center z-[3000] p-5",onClick:Te=>{Te.target===Te.currentTarget&&w(!1)},children:o.jsxs("div",{className:"bg-[#1a1a1a] rounded-2xl w-full max-w-[380px] max-h-[90vh] overflow-auto border border-[#333]",children:[o.jsxs("div",{className:"flex justify-between items-center p-5 border-b border-[#333]",children:[o.jsx("h2",{className:"m-0 text-xl text-white",children:m?"My Account":S==="signin"?"Sign In":S==="signup"?"Create Account":"Reset Password"}),o.jsx("button",{onClick:()=>w(!1),className:"bg-transparent border-none text-[#888] text-2xl cursor-pointer p-1","data-testid":"button-close-account-menu",children:"Ã"})]}),o.jsxs("div",{className:"p-5",children:[G&&o.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[o.jsx("div",{className:"w-16 h-16 rounded-full bg-[#4ade80]/20 flex items-center justify-center mb-4",children:o.jsx("svg",{className:"w-8 h-8 text-[#4ade80]",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),o.jsx("h3",{className:"text-white text-xl font-bold mb-2",children:"Account Created!"}),o.jsx("p",{className:"text-[#888] text-sm",children:"Welcome to Chronic Brands USA. You're now signed in."})]}),!G&&m?o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-4 mb-6 p-4 bg-[#2a2a2a] rounded-xl",children:[o.jsx("div",{className:"w-[60px] h-[60px] rounded-full overflow-hidden bg-[#4ade80] flex items-center justify-center",children:m.photoURL?o.jsx("img",{src:m.photoURL,alt:"",className:"w-full h-full object-cover"}):o.jsx(jh,{size:28,className:"text-white"})}),o.jsxs("div",{children:[o.jsx("p",{className:"m-0 text-white font-bold text-base",children:m.displayName||"User"}),o.jsx("p",{className:"m-0 mt-1 text-[#888] text-sm",children:m.email})]})]}),o.jsxs("div",{className:"flex flex-col gap-2",children:[o.jsxs("button",{onClick:()=>{w(!1),window.location.href="/my-account"},className:"bg-[#2a2a2a] border-none rounded-lg py-3.5 px-4 text-white text-[15px] cursor-pointer text-left flex items-center gap-3 hover:bg-[#333] transition-colors","data-testid":"button-edit-account",children:[o.jsx(r4,{size:18}),"Edit Account"]}),o.jsx("button",{onClick:async()=>{lt(!0),w(!1);try{const pt=await(await fetch("/api/partner-brands")).json();pt.success&&pt.data&&Ue(pt.data)}catch{}},className:"bg-[#2a2a2a] border-none rounded-lg py-3.5 px-4 text-white text-[15px] cursor-pointer text-left flex items-center gap-3 hover:bg-[#333] transition-colors","data-testid":"button-manage-subscription",children:"ðº Manage Subscription"}),o.jsx("button",{onClick:async()=>
56{if(w(!1),es(!0),oi(!0),m){const[Te,pt]=await Promise.all([Bm(m.uid),cd(m.uid)]);Te&&St(Te),Ar(pt)}es(!1)},className:"bg-[#2a2a2a] border-none rounded-lg py-3.5 px-4 text-white text-[15px] cursor-pointer text-left flex items-center gap-3 hover:bg-[#333] transition-colors","data-testid":"button-billing-info",children:"ð³ Billing Information"}),o.jsx("button",{onClick:async()=>{if(m){Rn(!0),Vn(!0),w(!1);const Te=await fm(m.uid,50);Br(Te),Rn(!1)}},className:"bg-[#2a2a2a] border-none rounded-lg py-3.5 px-4 text-white text-[15px] cursor-pointer text-left flex items-center gap-3 hover:bg-[#333] transition-colors","data-testid":"button-watch-history",children:"ðº Watch History"}),o.jsxs("button",{onClick:()=>{w(!1),Ee(!0)},className:"bg-[#2a2a2a] border-2 border-[#ffd700]/40 rounded-lg py-3.5 px-4 text-[#ffd700] text-[15px] cursor-pointer text-left flex items-center gap-3 hover:bg-[#333] hover:border-[#ffd700]/60 transition-colors","data-testid":"button-proof-of-discount-menu",children:[o.jsx(Yu,{size:18}),"Get Proof of Discount"]}),o.jsx("div",{className:"h-2"}),o.jsx("button",{onClick:async()=>{await k1(),w(!1)},className:"bg-transparent border border-[#ff4444] rounded-lg py-3.5 px-4 text-[#ff4444] text-[15px] cursor-pointer text-center hover:bg-[#ff4444]/10 transition-colors","data-testid":"button-sign-out",children:"Sign Out"}),o.jsx("button",{onClick:()=>{_e(!0),w(!1)},className:"bg-transparent border border-[#666] rounded-lg py-3.5 px-4 text-[#888] text-sm cursor-pointer text-center mt-1 hover:bg-white/5 transition-colors","data-testid":"button-deactivate-account",children:"Delete ChronicTV Account"})]})]}):o.jsxs("div",{children:[fe&&o.jsx("div",{className:"bg-[#ff4444]/10 border border-[#ff4444] rounded-lg p-3 mb-4 text-[#ff4444] text-sm",children:fe}),S==="reset"?o.jsxs("form",{onSubmit:async Te=>{Te.preventDefault(),Q(!0),oe("");const pt=await Pf(L);Q(!1),pt.success?(oe(""),alert("Password reset email sent! Check your inbox."),_("signin")):oe(pt.error||"Failed to send reset email")},children:[o.jsx("input",{type:"email",placeholder:"Email address",value:L,onChange:Te=>R(Te.target.value),required:!0,className:"w-full p-3.5 rounded-lg border border-[#444] bg-[#2a2a2a] text-white text-[15px] mb-3 box-border","data-testid":"input-reset-email"}),o.jsx("button",{type:"submit",disabled:X,className:"w-full p-3.5 rounded-lg border-none bg-[#4ade80] text-black text-[15px] font-bold cursor-pointer disabled:opacity-70 disabled:cursor-wait","data-testid":"button-send-reset",children:X?"Sending...":"Send Reset Link"}),o.jsx("button",{type:"button",onClick:()=>_("signin"),className:"w-full p-3 mt-3 bg-transparent border-none text-[#4ade80] text-sm cursor-pointer",children:"Back to Sign In"})]}):o.jsxs("form",{onSubmit:async Te=>{if(Te.preventDefault(),Q(!0),oe(""),S==="signup"){if(!z){oe("Please accept the Terms & Conditions"),Q(!1);return}const pt=L,ys=W,fr=await kf(L,M,W,k,N);fr.error?oe(fr.error):(R(""),V(""),I(""),P(""),F(""),U(!1),w(!1),pe(ys),H(!0),fetch("/api/auth/welcome-email",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:pt,firstName:ys})}).catch(()=>{}),setTimeout(()=>H(!1),7e3))}else{const pt=await Rf(L,M);pt.error?oe(pt.error):(w(!1),R(""),V(""))}Q(!1)},children:[S==="signup"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex gap-3 mb-3",children:[o.jsx("input",{type:"text",placeholder:"First name",value:W,onChange:Te=>I(Te.target.value),className:"flex-1 min-w-0 p-3.5 rounded-lg border border-[#444] bg-[#2a2a2a] text-white text-[15px] box-border","data-testid":"input-auth-first-name"}),o.jsx("input",{type:"text",placeholder:"Last name",value:k,onChange:Te=>P(Te.target.value),className:"flex-1 min-w-0 p-3.5 rounded-lg border border-[#444] bg-[#2a2a2a] text-white text-[15px] box-border","data-testid":"input-auth-last-name"})]}),o.jsx("input",{type:"tel",placeholder:"Phone number",value:N,onChange:Te=>F(Te.target.value),className:"w-full p-3.5 rounded-lg border border-[#444] bg-[#2a2a2a] text-white text-[15px] mb-3 box-border","data-testid":"input-auth-phone"})]}),o.jsx("input",{type:"email",placeholder:"Email address",value:L,onChange:Te=>R(Te.target.value),required:!0,className:"w-full p-3.5 rounded-lg border border-[#444] bg-[#2a2a2a] text-white text-[15px] mb-3 box-border","data-testid":"input-auth-email"}),o.jsx("input",{type:"password",placeholder:"Password",value:M,onChange:Te=>V(Te.target.value),required:!0,className:"w-full p-3.5 rounded-lg border border-[#444] bg-[#2a2a2a] text-white text-[15px] mb-3 box-border","data-testid":"input-auth-password"}),S==="signup"&&o.jsxs("label",{className:"flex items-start gap-3 mb-4 cursor-pointer select-none",children:[o.jsx("input",{type:"checkbox",checked:z,onChange:Te=>U(Te.target.checked),className:"w-5 h-5 mt-0.5 accent-[#4ade80] cursor-pointer flex-shrink-0","data-testid":"input-auth-terms"}),o.jsxs("span",{className:"text-[#aaa] text-sm leading-relaxed",children:["I agree to the ",o.jsx("a",{href:"/terms",target:"_blank",rel:"noopener noreferrer",className:"text-[#4ade80] underline hover:text-[#3cb371]",children:"Terms & Conditions"})," of Chronic Brands USA"]})]}),S==="signup"&&!z&&o.jsx("p",{className:"text-[#888] text-xs text-center mb-3",children:"Please check the box above to continue"}),o.jsx("button",{type:"submit",disabled:X||S==="signup"&&!z,className:"w-full p-3.5 rounded-lg border-none bg-[#4ade80] text-black text-[15px] font-bold cursor-pointer disabled:opacity-60 disabled:cursor-not-allowed","data-testid":"button-auth-submit",children:X?"Creating account...":S==="signup"?"Create Account":"Sign In"}),S==="signin"&&o.jsx("button",{type:"button",onClick:()=>_("reset"),className:"w-full p-2 mt-2 bg-transparent border-none text-[#888] text-sm cursor-pointer hover:text-white",children:"Forgot password?"}),o.jsxs("div",{className:"flex items-center gap-4 my-4",children:[o.jsx("div",{className:"flex-1 h-px bg-[#444]"}),o.jsx("span",{className:"text-[#666] text-sm",children:"or"}),o.jsx("div",{className:"flex-1 h-px bg-[#444]"})]}),o.jsxs("button",{type:"button",onClick:async()=>{Q(!0),oe("");try{await Vm(),w(!1)}catch(Te){oe(Te?.message||"Failed to sign in with Google")}Q(!1)},disabled:X,className:"w-full p-3.5 rounded-lg border-none bg-white text-black text-[15px] font-medium cursor-pointer flex items-center justify-center gap-2 hover:bg-gray-100 disabled:opacity-70","data-testid":"button-google-signin",children:[o.jsxs("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",children:[o.jsx("path",{fill:"#4285F4",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"}),o.jsx("path",{fill:"#34A853",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),o.jsx("path",{fill:"#FBBC05",d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"}),o.jsx("path",{fill:"#EA4335",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})]}),"Continue with Google"]}),o.jsxs("button",{type:"button",onClick:async()=>{Q(!0),oe("");try{await Zx(),w(!1)}catch(Te){oe(Te?.message||"Failed to sign in with Apple")}Q(!1)},disabled:X,className:"w-full p-3.5 mt-3 rounded-lg border border-[#444] bg-black text-white text-[15px] font-medium cursor-pointer flex items-center justify-center gap-2 hover:bg-[#1a1a1a] disabled:opacity-70","data-testid":"button-apple-signin",children:[o.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"
56currentColor",children:o.jsx("path",{d:"M17.05 20.28c-.98.95-2.05.8-3.08.35-1.09-.46-2.09-.48-3.24 0-1.44.62-2.2.44-3.06-.35C2.79 15.25 3.51 7.59 9.05 7.31c1.35.07 2.29.74 3.08.8 1.18-.24 2.31-.93 3.57-.84 1.51.12 2.65.72 3.4 1.8-3.12 1.87-2.38 5.98.48 7.13-.57 1.5-1.31 2.99-2.54 4.09l.01-.01zM12.03 7.25c-.15-2.23 1.66-4.07 3.74-4.25.29 2.58-2.34 4.5-3.74 4.25z"})}),"Continue with Apple"]}),o.jsx("p",{className:"text-[#888] text-sm mt-4 text-center",children:S==="signin"?o.jsxs(o.Fragment,{children:["Don't have an account? ",o.jsx("button",{type:"button",onClick:()=>_("signup"),className:"text-[#4ade80] bg-transparent border-none cursor-pointer hover:underline",children:"Sign up"})]}):o.jsxs(o.Fragment,{children:["Already have an account? ",o.jsx("button",{type:"button",onClick:()=>_("signin"),className:"text-[#4ade80] bg-transparent border-none cursor-pointer hover:underline",children:"Sign in"})]})})]})]})]})]})}),Fe&&o.jsx("div",{className:"fixed inset-0 bg-black/85 flex items-center justify-center z-[3100] p-5",onClick:Te=>{Te.target===Te.currentTarget&&_e(!1)},children:o.jsxs("div",{className:"bg-[#1a1a1a] rounded-2xl w-full max-w-[400px] border border-[#333] p-6",children:[o.jsx("h2",{className:"text-xl text-white mb-4",children:"Delete ChronicTV Account"}),o.jsx("p",{className:"text-[#888] text-sm mb-4",children:"This will permanently delete your ChronicTV account and all associated data. This action cannot be undone."}),o.jsxs("p",{className:"text-white text-sm mb-4",children:["Type ",o.jsx("strong",{children:"DELETE"})," to confirm:"]}),o.jsx("input",{type:"text",value:ze,onChange:Te=>Ye(Te.target.value),className:"w-full p-3 rounded-lg border border-[#444] bg-[#2a2a2a] text-white text-sm mb-4 box-border",placeholder:"Type DELETE","data-testid":"input-deactivate-confirm"}),o.jsxs("div",{className:"flex gap-3",children:[o.jsx("button",{onClick:()=>{_e(!1),Ye("")},className:"flex-1 py-3 rounded-lg border border-[#444] bg-transparent text-white cursor-pointer hover:bg-white/5",children:"Cancel"}),o.jsx("button",{onClick:async()=>{if(ze==="DELETE"&&m)try{await fetch("/api/users/deactivate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({firebaseUid:m.uid})}),await k1(),_e(!1),Ye("")}catch{}},disabled:ze!=="DELETE",className:"flex-1 py-3 rounded-lg border-none bg-[#ff4444] text-white font-bold cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed","data-testid":"button-confirm-deactivate",children:"Delete"})]})]})}),tt&&o.jsx("div",{className:"fixed inset-0 bg-black/85 z-[3000] flex justify-center items-start pt-[60px] overflow-y-auto",onClick:()=>lt(!1),children:o.jsxs("div",{className:"bg-[#1e1e1e] rounded-xl w-[90%] max-w-[400px] overflow-hidden",onClick:Te=>Te.stopPropagation(),children:[o.jsxs("div",{className:"flex justify-between items-center p-5 border-b border-[#333]",children:[o.jsx("h2",{className:"text-white m-0 text-xl font-bold",children:"Manage Subscription"}),o.jsx("button",{onClick:()=>lt(!1),className:"bg-transparent border-none text-[#888] text-2xl cursor-pointer","data-testid":"button-close-subscription",children:"Ã"})]}),o.jsxs("div",{className:"p-5",children:[o.jsxs("div",{className:`bg-[#2a2a2a] rounded-xl p-5 mb-4 border-2 ${ut==="cultured"?"border-[#4ade80]":"border-[#444]"}`,children:[o.jsxs("div",{className:"flex justify-between items-start mb-3",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"text-white m-0 text-xl font-bold",children:"Cultured"}),o.jsx("p",{className:"text-[#4ade80] m-0 mt-1 text-sm font-bold",children:"FREE"})]}),ut==="cultured"&&o.jsx("span",{className:"bg-[#4ade80] text-black py-1.5 px-3.5 rounded-full text-xs font-bold",children:"Active"})]}),o.jsx("p",{className:"text-[#888] m-0 text-sm leading-relaxed",children:'Free version - watch all there is to offer without the benefits of "Premier"'})]}),o.jsxs("div",{className:`bg-[#2a2a2a] rounded-xl p-5 mb-4 border-2 ${ut==="premier"?"border-[#ffd700]":"border-[#444]"}`,children:[o.jsxs("div",{className:"flex justify-between items-start mb-3",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"text-[#ffd700] m-0 text-xl font-bold",children:"â Premier"}),o.jsx("p",{className:"text-[#ffd700] m-0 mt-1 text-sm font-bold",children:"$10/month"})]}),ut==="premier"&&o.jsx("span",{className:"bg-[#ffd700] text-black py-1.5 px-3.5 rounded-full text-xs font-bold",children:"Active"})]}
56),o.jsx("p",{className:"text-[#ccc] m-0 mb-4 text-sm leading-relaxed",children:"Gain exclusive event info, as well as Brand Partner Discounts"}),o.jsxs("div",{className:"bg-[#1e1e1e] rounded-lg p-3",children:[o.jsxs("div",{className:"flex justify-between items-center mb-3",children:[o.jsx("h4",{className:"text-[#ffd700] m-0 text-sm",children:"ð¤ Partner Memberships"}),ut!=="premier"&&o.jsx("span",{className:"bg-black/60 py-1 px-2.5 rounded-xl text-[10px] text-[#ffd700] font-bold",children:"ð Upgrade to unlock"})]}),ke.length>0?o.jsx("div",{className:`flex flex-col gap-2.5 ${ut==="premier"?"":"opacity-70 pointer-events-none"}`,children:ke.map((Te,pt)=>o.jsxs("a",{href:Te.referralLink,target:"_blank",rel:"noopener noreferrer",className:"block p-2.5 bg-[#2a2a2a] rounded-md no-underline","data-testid":`partner-link-${pt}`,children:[o.jsxs("div",{className:"flex justify-between items-start",children:[o.jsx("p",{className:"text-white m-0 text-sm font-medium",children:Te.brandName}),o.jsx("span",{className:"text-[#4ade80] text-sm ml-2",children:"â"})]}),Te.shortInfo&&o.jsx("p",{className:"text-[#888] m-0 mt-1 text-[11px]",children:Te.shortInfo}),Te.discount&&o.jsx("div",{className:"mt-2 p-1.5 bg-[#4ade80]/20 rounded border-l-2 border-[#4ade80]",children:o.jsxs("p",{className:"text-[#4ade80] m-0 text-[11px] font-medium",children:["ð ",Te.discount]})})]},pt))}):o.jsx("p",{className:"text-[#666] m-0 text-xs italic",children:"Loading partner discounts..."})]}),zt&&o.jsx("p",{className:"text-[#ff4444] text-xs m-0 mt-3 text-center",children:zt}),ut!=="premier"&&o.jsxs("div",{className:"mt-4 p-3 bg-[#ffd700]/10 border border-[#ffd700] rounded-lg space-y-3",children:[o.jsxs("label",{className:"flex items-start gap-2.5 cursor-pointer select-none",children:[o.jsx("input",{type:"checkbox",checked:at,onChange:Te=>ft(Te.target.checked),className:"w-[18px] h-[18px] mt-0.5 accent-[#4ade80] cursor-pointer","data-testid":"checkbox-membership-understood"}),o.jsxs("span",{className:"text-[#ccc] text-[11px] leading-relaxed",children:["I have read and understand how the ",o.jsx("a",{href:"/membership",target:"_blank",className:"text-[#4ade80] underline hover:text-[#3cb371]",children:"Chronic Brands membership"})," works."]})]}),o.jsxs("label",{className:"flex items-start gap-2.5 cursor-pointer select-none",children:[o.jsx("input",{type:"checkbox",checked:rt,onChange:Te=>Ct(Te.target.checked),className:"w-[18px] h-[18px] mt-0.5 accent-[#4ade80] cursor-pointer","data-testid":"checkbox-billing-disclaimer"}),o.jsxs("span",{className:"text-[#ccc] text-[11px] leading-relaxed",children:["I understand that charges will appear from ",o.jsx("strong",{className:"text-[#ffd700]",children:'"HiveStaffing"'})," on my bank statement. I acknowledge that disputing this subscription charge will result in the ",o.jsx("strong",{className:"text-[#ff6b6b]",children:"loss of Partner discount benefits"}),"."]})]}),o.jsxs("label",{className:"flex items-start gap-2.5 cursor-pointer select-none",children:[o.jsx("input",{type:"checkbox",checked:Nt,onChange:Te=>At(Te.target.checked),className:"w-[18px] h-[18px] mt-0.5 accent-[#4ade80] cursor-pointer","data-testid":"checkbox-id-requirement"}),o.jsxs("span",{className:"text-[#ccc] text-[11px] leading-relaxed",children:["I understand that without a valid ID matching the name on this account, ",o.jsx("strong",{className:"text-[#ff6b6b]",children:"Brand rebate may be refused by the retailer"}),"."]})]})]}),o.jsx("button",{onClick:async()=>{if(!m){wn("Please sign in to upgrade");return}await K6(m.uid),Yt(!0),wn(null);try{const Te=await cd(m.uid);if(Te.length===0){wn("Please add a payment method in Billing Information first"),Yt(!1);return}const pt=await m.getIdToken(),fr=await(await fetch("/api/payments/create-subscription",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${pt}`},body:JSON.stringify({firebaseUid:m.uid,paymentProfileId:Te[0].authorizeNetPaymentProfileId,customerProfileId:Te[0].authorizeNetCustomerProfileId,subscriptionProductId:"premier-membership"})})).json();if(fr.success){const zr=new Date,ja=new Date(zr.getTime()+720*60*60*1e3);await G6(m.uid,{status:"active",planName:"Premier",tier:"premier",priceAmount:10,authorizeNetSubscriptionId:fr.subscriptionId,authorizeNetCustomerProfileId:Te[0].authorizeNetCustomerProfileId,authorizeNetPaymentProfileId:Te[0].authorizeNetPaymentProfileId,lastRenewalDate:zr,nextBillingDate:ja,createdAt:zr}),cn("premier"),wn(null)}else wn(fr.error||"Failed to create subscription")}catch{wn("Failed to process subscription")}Yt(!1)},disabled:ot||ut==="premier"||!rt||!at||!Nt,className:`w-full p-3 mt-3 rounded-lg border-none text-sm font-bold cursor-pointer ${ut==="premier"?"bg-[#4ade80] text-black":rt&&at&&Nt?"bg-[#ffd700] text-black":"bg-[#555] text-[#888] cursor-not-allowed"} ${ot?"opacity-70 cursor-wait":""}`,"data-testid":"button-upgrade-premier",children:ot?"Processing...":ut==="premier"?"â Premier Active":"Upgrade to Premier - $10/month"}),o.jsxs("button",{onClick:()=>Ee(!0),className:`w-full p-3 mt-3 rounded-lg bg-transparent text-sm font-bold cursor-pointer flex items-center justify-center gap-2 border-2 ${ut==="premier"?"border-[#ffd700] text-[#ffd700]":"border-[#4ade80] text-[#4ade80]"}`,"data-testid":"button-proof-of-discount",children:[o.jsx(Yu,{size:18}),"Get Proof of Discount"]})]}),o.jsx("p",{className:"text-[#666] text-xs text-center m-0",children:"Questions? Contact [email protected]"})]})]})}),Dt&&m&&o.jsx("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0,0,0,0.9)",zIndex:4e3,display:"flex",justifyContent:"center",alignItems:"center",padding:"20px"},onClick:()=>Ee(!1),children:o.jsxs("div",{style:{background:"#1a1a1a",borderRadius:"16px",width:"100%",maxWidth:"360px",maxHeight:"90vh",overflowY:"auto",WebkitOverflowScrolling:"touch"},onClick:Te=>Te.stopPropagation(),children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"12px 16px",borderBottom:"1px solid #333"},children:[o.jsx("h2",{style:{color:"#ffd700",margin:0,fontSize:"16px",fontWeight:"bold"},children:"ð« Proof of Discount"}),o.jsx("button",{onClick:()=>Ee(!1),style:{background:"none",border:"none",color:"#888",fontSize:"24px",cursor:"pointer"},"data-testid":"button-close-proof",children:"Ã"})]}),o.jsx("div",{style:{animation:"proofBannerFlash 1s ease-in-out infinite",background:"#ffd700",textAlign:"center",fontWeight:"bold",color:"#000",fontSize:"13px",letterSpacing:"0.02em",padding:"9px 16px"},children:"ð¨ SHOW THIS AT THE DOOR AND AT THE COUNTER"}),o.jsxs("div",{style:{padding:"12px 16px",textAlign:"center"},children:[o.jsx("p",{style:{color:"#ccc",fontSize:"12px",marginBottom:"10px",marginTop:0},children:ut==="premier"?"Show this QR code to any partner to verify your Premier membership and receive your discount.":"Show this QR code to verify your membership status."}),o.jsx("div",{style:{background:"#f5f0e6",padding:"10px",borderRadius:"10px",display:"inline-block",marginBottom:"10px",border:ut==="premier"?"3px solid #4ade80":"3px solid #888"},children:o.jsx(l4,{value:`https://chronicbrandsusa.com/${He}/MembershipStatus`,size:150,level:"H",includeMargin:!1,bgColor:"#f5f0e6",fgColor:"#000000",imageSettings:{src:"/assets/ChronicTVlogo2b.png",height:38,width:58,excavate:!0}})}),o.jsxs("div",{style:{background:"#2a2a2a",borderRadius:"8px",padding:"10px",marginBottom:"10px",textAlign:"left"},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"5px"},children:[o.jsx("span",{style:{color:"#888",fontSize:"11px"},children:"Name"}),o.jsx("span",{style:{color:"#fff",fontSize:"11px",fontWeight:"bold"},children:m.displayName||"Member"})]}),o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"5px"},children:[o.jsx("span",{style:{color:"#888",fontSize:"11px"},children:"Email"}),o.jsx("span",{style:{color:"#fff",fontSize:"11px"},children:m.email})]}),o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:ut==="premier"&&hr?"5px":"0"},children:[o.jsx("span",{style:{color:"#888",fontSize:"11px"},children:"Status"}),o.jsx("span",{style:{color:ut==="premier"?"#4ade80":"#ffd700",fontSize:"11px",fontWeight:"bold"},children:ut==="premier"?"â Premier Active":"â Cultured Free Active"})]}),ut==="premier"&&hr&&o.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[o.jsx("span",{style:{color:"#888",fontSize:"11px"},children:"Next Renewal"}),o.jsx("span",{style:{color:"#4ade80",fontSize:"11px"},children:hr.toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})})]}),ut!=="premier"&&Qs&&o.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[o.jsx("span",{style:{color:"#888",fontSize:"11px"},children:"Last Premier"}),o.jsx("span",{style:{color:"#888",fontSize:"11px"},children:Qs.toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})})]})]}),o.jsxs("div",{style:{background:"#2a2a2a",borderRadius:"8px",padding:"10px",marginBottom:"10px"},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"8px"},children:[o.jsx("span",{style:{color:"#ccc",fontSize:"12px",fontWeight:600},children:"State Issued ID"}),o.jsxs("label",{style:{background:"#4ade80",color:"black",padding:"5px 10px",borderRadius:"6px",fontSize:"10px",fontWeight:"bold",cursor:Lt?"wait":"pointer",opacity:Lt?.7:1,flexShrink:0},children:[o.jsx("input",{type:"file",accept:"image/*",style:{display:"none"},disabled:Lt,onChange:async Te=>{const pt=Te.target.files?.[0];if(pt&&m){if(!ii){ln(pt),Gn(!0),Te.target.value="";return}Qe(!0);const ys=await pm(m.uid,pt);ys.success&&ys.url&&Le(ys.url),Qe(!1)}},"data-testid":"input-photo-id"}),Lt?"Uploading...":De?"Update ID":"Upload ID"]})]}),o.jsx("p",{style:{color:"#888",fontSize:"11px",margin:"0 0 6px 0",lineHeight:"1.6"},children:"Your ID is used to verify your identity and ensure our events are safe for everyone. This allows staff to confirm membership and assist in any emergency situations."}),o.jsx("p",{style:{color:"#888",fontSize:"11px",margin:"0 0 6px 0",lineHeight:"1.6"},children:"A Medical Marijuana (MMJ) license is also accepted as an alternative form of ID."}),o.jsx("a",{href:"https://www.chronicdocs.com/CHRONICLOUNGE",target:"_blank",rel:"noopener noreferrer",style:{color:"#4ade80",fontSize:"11px",textDecoration:"underline",cursor:"pointer"},children:"Don't have a MMJ license?"}),De&&o.jsxs("div",{onClick:()=>
56Cn(!it),style:{position:"relative",cursor:"pointer",borderRadius:"8px",overflow:"hidden"},"data-testid":"photo-id-container",children:[o.jsx("img",{src:De,alt:"Photo ID",style:{width:"100%",maxHeight:"120px",objectFit:"contain",borderRadius:"8px",filter:it?"none":"blur(12px)",transition:"filter 0.3s ease"}}),!it&&o.jsx("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",background:"rgba(0,0,0,0.7)",padding:"6px 12px",borderRadius:"8px",color:"white",fontSize:"11px",fontWeight:"bold"},children:"ð Tap to reveal"})]})]}),o.jsxs("div",{style:{display:"flex",gap:"8px"},children:[o.jsxs("button",{onClick:async()=>{const Te=`https://chronicbrandsusa.com/${He}/MembershipStatus`;try{await navigator.clipboard.writeText(Te),J(!0),setTimeout(()=>J(!1),2e3)}catch{}},style:{flex:1,padding:"10px",borderRadius:"8px",border:"none",background:ne?"#4ade80":"#333",color:ne?"black":"white",fontSize:"12px",fontWeight:"bold",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"5px"},"data-testid":"button-copy-proof",children:[o.jsx(Dh,{size:14}),ne?"Copied!":"Copy Link"]}),o.jsxs("button",{onClick:async()=>{const Te=`https://chronicbrandsusa.com/${He}/MembershipStatus`;if(navigator.share)try{await navigator.share({title:"Chronic Brands Membership",text:`Verify my membership: ${m.displayName||"Member"}`,url:Te})}catch{}else await navigator.clipboard.writeText(Te),J(!0),setTimeout(()=>J(!1),2e3)},style:{flex:1,padding:"10px",borderRadius:"8px",border:"none",background:"#ffd700",color:"black",fontSize:"12px",fontWeight:"bold",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"5px"},"data-testid":"button-share-proof",children:[o.jsx(Jc,{size:14}),"Share"]})]})]})]})}),Mn&&o.jsx("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0,0,0,0.9)",zIndex:5e3,display:"flex",justifyContent:"center",alignItems:"center",padding:"20px"},onClick:()=>{Gn(!1),ln(null),os(!1)},children:o.jsxs("div",{style:{background:"#1e1e1e",borderRadius:"12px",width:"100%",maxWidth:"400px",overflow:"hidden"},onClick:Te=>Te.stopPropagation(),children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"20px",borderBottom:"1px solid #333"},children:[o.jsx("h2",{style:{color:"#4ade80",margin:0,fontSize:"18px",fontWeight:"bold"},children:"ID Verification Consent"}),o.jsx("button",{onClick:()=>{Gn(!1),ln(null),os(!1)},style:{background:"none",border:"none",color:"#888",fontSize:"24px",cursor:"pointer"},"data-testid":"button-close-consent",children:"Ã"})]}),o.jsxs("div",{style:{padding:"20px"},children:[o.jsx("p",{style:{color:"#fff",fontSize:"14px",lineHeight:"1.7",margin:"0 0 20px 0",textAlign:"left"},children:"I understand that Chronic Brands and Chronic Lounge requires my ID to keep all of its members safe, and without ID I may be denied entry."}),o.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"12px",cursor:"pointer",padding:"12px",background:"#2a2a2a",borderRadius:"8px",marginBottom:"20px"},children:[o.jsx("input",{type:"checkbox",checked:Fs,onChange:Te=>os(Te.target.checked),style:{width:"20px",height:"20px",accentColor:"#4ade80",marginTop:"2px",flexShrink:0},"data-testid":"checkbox-id-consent"}),o.jsx("span",{style:{color:"#888",fontSize:"13px",lineHeight:"1.5"},children:"I agree and consent to providing my photo ID for membership verification purposes"})]}),o.jsxs("div",{style:{display:"flex",gap:"12px"},children:[o.jsx("button",{onClick:()=>{Gn(!1),ln(null),os(!1)},style:{flex:1,padding:"14px",borderRadius:"8px",border:"1px solid #444",background:"transparent",color:"white",fontSize:"14px",cursor:"pointer"},"data-testid":"button-cancel-consent",children:"Cancel"}),o.jsx("button",{onClick:async()=>{if(!Fs||!m||!vn)return;if((await Y6(m.uid)).success){ai(!0),Gn(!1),Qe(!0);const pt=await pm(m.uid,vn);pt.success&&pt.url&&Le(pt.url),Qe(!1),ln(null),os(!1)}},disabled:!Fs,style:{flex:1,padding:"14px",borderRadius:"8px",border:"none",background:Fs?"#4ade80":"#333",color:Fs?"black":"#666",fontSize:"14px",fontWeight:"bold",cursor:Fs?"pointer":"not-allowed"},"data-testid":"button-confirm-consent",children:"I Agree"})]})]})]})}),Xs&&o.jsx("div",{className:"fixed inset-0 bg-black/85 z-[3000] flex justify-center items-start pt-[60px] overflow-y-auto",onClick:()=>oi(!1),children:o.jsxs("div",{className:"bg-[#1e1e1e] rounded-xl w-[90%] max-w-[400px] overflow-hidden",onClick:Te=>Te.stopPropagation(),children:[o.jsxs("div",{className:"flex justify-between items-center p-5 border-b border-[#333]",children:[o.jsx("h2",{className:"text-white m-0 text-xl font-bold",children:"Billing Information"}),o.jsx("button",{onClick:()=>oi(!1),className:"bg-transparent border-none text-[#888] text-2xl cursor-pointer",children:"Ã"})]}),o.jsx("div",{className:"p-5",children:_r?o.jsx("p",{className:"text-[#888] text-center",children:"Loading billing information..."}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"mb-4",children:[o.jsx("h3",{className:"text-white text-base font-bold mb-2",children:"Payment Methods"}),Ir.length>0?Ir.map((Te,pt)=>o.jsxs("div",{className:"bg-[#2a2a2a] rounded-lg p-3 mb-2",children:[o.jsxs("p",{className:"text-white m-0 text-sm",children:["ð³ â¢â¢â¢â¢ ",Te.lastFour||"****"]}),o.jsx("p",{className:"text-[#888] m-0 mt-1 text-xs",children:Te.cardType||"Card"})]},pt)):o.jsx("p",{className:"text-[#888] text-sm",children:"No payment methods on file"})]}),Re&&o.jsxs("div",{children:[o.jsx("h3",{className:"text-white text-base font-bold mb-2",children:"Billing Address"}),o.jsxs("div",{className:"bg-[#2a2a2a] rounded-lg p-3",children:[o.jsx("p",{className:"text-white m-0 text-sm",children:Re.address}),o.jsxs("p",{className:"text-[#888] m-0 mt-1 text-xs",children:[Re.city,", ",Re.state," ",Re.zip]})]})]})]})})]})}),Un&&o.jsx("div",{className:"fixed inset-0 bg-black/85 z-[3000] flex justify-center items-start pt-[60px] overflow-y-auto",onClick:()=>Vn(!1),children:o.jsxs("div",{className:"bg-[#1e1e1e] rounded-xl w-[90%] max-w-[500px] overflow-hidden",onClick:Te=>Te.stopPropagation(),children:[o.jsxs("div",{className:"flex justify-between items-center p-5 border-b border-[#333]",children:[o.jsx("h2",{className:"text-white m-0 text-xl font-bold",children:"Watch History"}),o.jsx("button",{onClick:()=>Vn(!1),className:"bg-transparent border-none text-[#888] text-2xl cursor-pointer",children:"Ã"})]}),o.jsx("div",{className:"p-5 max-h-[60vh] overflow-y-auto",children:Da?o.jsx("p",{className:"text-[#888] text-center",children:"Loading watch history..."}):La.length>0?o.jsx("div",{className:"flex flex-col gap-3",children:La.map((Te,pt)=>o.jsxs("div",{className:"flex gap-3 bg-[#2a2a2a] rounded-lg p-3",children:[Te.thumbnailUrl&&o.jsx("img",{src:Te.thumbnailUrl,alt:"",className:"w-20 h-12 object-cover rounded"}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"text-white m-0 text-sm font-medium truncate",children:Te.videoTitle}),o.jsx("p",{className:"text-[#888] m-0 mt-1 text-xs",children:Te.showName||"ChronicTV"}),o.jsx("p",{className:"text-[#666] m-0 mt-1 text-[11px]",children:Te.watchedAt?new Date(Te.watchedAt).toLocaleDateString():""})]})]},pt))}):o.jsx("p",{className:"text-[#888] text-center",children:"No watch history yet"})})]})}),ee&&o.jsxs("div",{onClick:()=>H(!1),className:"fixed inset-0 z-[99999] bg-black/90 flex flex-col items-center justify-center p-6 cursor-pointer",children:[o.jsxs("div",{className:"bg-gradient-to-br from-[#111] to-[#1a1a1a] border border-[#4ade80]/30 rounded-2xl p-12 max-w-md w-full text-center shadow-[0_0_60px_rgba(74,222,128,0.15)]",children:[o.jsx("div",{className:"w-20 h-20 rounded-full bg-[#4ade80]/15 flex items-center justify-center mx-auto mb-6",children:o.jsx("svg",{className:"w-10 h-10 text-[#4ade80]",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),o.jsx("div",{className:"text-xs text-[#4ade80] font-semibold tracking-widest uppercase mb-3",children:"Welcome to"}),o.jsx("div",{className:"text-3xl font-black text-white mb-2",children:"Chronic Brands USA"}),K&&o.jsxs("div",{className:"text-xl text-[#4ade80] font-bold mb-4",children:["Hey ",K,"! ð"]}),o.jsx("p",{className:"text-[#ccc] text-base leading-relaxed mb-2",children:"Your account is ready. A welcome email is on its way to your inbox."}),o.jsx("p",{className:"text-[#666] text-sm mb-8",children:"Tap anywhere to continue"}),o.jsx("div",{className:"w-full h-[3px] bg-[#222] rounded-full overflow-hidden",children:o.jsx("div",{className:"h-full bg-[#4ade80] rounded-full",style:{animation:"welcomeProgress 7s linear forwards"}})})]}),o.jsx("style",{children:` 57 @keyframes welcomeProgress { 58 from { width: 100%; } 59 to { width: 0%; } 60 } 61 `})]}),o.jsx(rF,{endpoint:m?"/api/gizmo/member/chat":"/api/gizmo/public/chat",getToken:m?()=>m.getIdToken():void 0,surfaceName:"website"})]})}const GJ="/assets/CarriChronicBGR2_1766089054669-aqTkK0vp.png";function X6({brandName:n,size:e="base",color:t,suffixColor:s,className:r=""}){if(!n.toLowerCase().includes("chronic"))return o.jsx("span",{className:r,children:n});const i=n.toLowerCase().indexOf("chronic"),a=n.slice(0,i),l=n.slice(i+7);return o.jsxs("span",{className:`inline-flex items-center ${r}`,children:[a&&o.jsx("span",{style:{color:t},children:a}),o.jsx(Is,{size:e,color:t,suffix:l,suffixColor:t})]})}function KJ(n){return n.includes("drive.google.com")?`/api/drive-thumbnail?url=${encodeURIComponent(n)}`:n}function s_(n,e){const t=e.startAngle*Math.PI/180,s=Math.cos(t)*n.radiusX,r=-Math.sin(t)*n.radiusY,i=n.tiltZ*Math.PI/180;return s*Math.sin(i)+r*Math.cos(i)<0}function qJ({categories:n,centerX:e="50%",centerY:t="50%",offsetX:s=0}){const r=T.useRef(new Map),i=T.useMemo(()=>{const d=n.map(m=>({...m,thumbnailUrl:m.thumbnailUrl||m.logoUrl})).filter(m=>
61m.thumbnailUrl&&m.thumbnailUrl.trim()),h=[{tiltZ:-8,radiusX:360,radiusY:145,duration:34,direction:1},{tiltZ:10,radiusX:410,radiusY:170,duration:42,direction:-1},{tiltZ:-15,radiusX:320,radiusY:125,duration:38,direction:1}],p=Math.ceil(d.length/h.length);return h.map((m,y)=>({...m,ringIndex:y,shows:d.slice(y*p,(y+1)*p).map((x,w,S)=>({...x,size:42+w%3*6,startAngle:w/S.length*360}))})).filter(m=>m.shows.length>0)},[n]);if(T.useEffect(()=>{if(!i.length)return;let d=0;const h=performance.now(),p=m=>{const y=(m-h)/1e3;i.forEach(x=>{x.shows.forEach(w=>{const S=r.current.get(w.name);if(!S)return;const _=y/x.duration*x.direction,L=(w.startAngle+_*360)*Math.PI/180,R=Math.cos(L)*x.radiusX,M=-Math.sin(L)*x.radiusY,V=x.tiltZ*Math.PI/180,W=R*Math.cos(V)-M*Math.sin(V),I=R*Math.sin(V)+M*Math.cos(V);S.style.transform=`translate3d(${W-w.size/2}px, ${I-w.size/2}px, 0)`,S.style.zIndex=String(Math.round(1e3-I))})}),d=requestAnimationFrame(p)};return d=requestAnimationFrame(p),()=>cancelAnimationFrame(d)},[i]),!i.length)return null;const a=i.flatMap(d=>d.shows.filter(h=>!s_(d,h))),l=i.flatMap(d=>d.shows.filter(h=>s_(d,h))),c=d=>o.jsx("div",{ref:h=>{h?r.current.set(d.name,h):r.current.delete(d.name)},className:"absolute pointer-events-none",style:{width:d.size,height:d.size,borderRadius:"50%",overflow:"hidden",background:"#080808",border:"1px solid rgba(255,255,255,0.35)",boxShadow:"inset -8px -8px 12px rgba(0,0,0,0.72), 0 0 12px rgba(74,222,128,0.35)",willChange:"transform"},children:o.jsx("img",{src:d.thumbnailUrl?KJ(d.thumbnailUrl):"",alt:d.name,style:{display:"block",width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%",background:"#080808"}})},d.name);return o.jsxs("div",{className:"absolute inset-0 pointer-events-none overflow-visible",style:{left:s,right:-s},children:[i.map(d=>o.jsx("div",{className:"absolute pointer-events-none",style:{left:e,top:t,width:`${d.radiusX*2}px`,height:`${d.radiusY*2}px`,transform:`translate(-50%, -50%) rotateZ(${d.tiltZ}deg)`,borderRadius:"50%",border:"1px solid rgba(74, 222, 128, 0.14)",boxShadow:"0 0 10px rgba(74, 222, 128, 0.08)",zIndex:0}},d.ringIndex)),o.jsx("div",{className:"absolute inset-0 pointer-events-none",style:{left:e,top:t,width:1,height:1,zIndex:1},children:a.map(c)}),o.jsx("div",{className:"absolute inset-0 pointer-events-none",style:{left:e,top:t,width:1,height:1,zIndex:20},children:l.map(c)})]})}function YJ(){const{data:n}=gn({queryKey:["/api/startup-bundle"]}),{data:e}=gn({queryKey:["/api/website-brands"],staleTime:0,refetchOnMount:"always"}),t=Array.isArray(e)?e:[],s=n?.categories||[],r=T.useMemo(()=>t.map(R=>{const M=R.brandName.toLowerCase().replace(/\s+/g,""),V=s.find(W=>W.name.toLowerCase().replace(/\s+/g,"")===M);return{...R,logoUrl:V?.thumbnailUrl||R.logoUrl||"",summary:V?.summaryContent||V?.description||R.brandFunnel||""}}),[e,s]),i=T.useMemo(()=>[...r.filter(R=>R.logoUrl).map(R=>({name:R.brandName,thumbnailUrl:R.logoUrl})),...s.filter(R=>R.thumbnailUrl).filter(R=>!r.some(M=>M.brandName.toLowerCase().replace(/\s+/g,"")===R.name.toLowerCase().replace(/\s+/g,""))).map(R=>({name:R.name,thumbnailUrl:R.thumbnailUrl}))],[r,s]),[a,l]=T.useState(0),[c,d]=T.useState(!1),h=T.useRef(null),p=T.useRef(null),m=()=>{l(R=>(R-1+r.length)%r.length)},y=()=>{l(R=>(R+1)%r.length)},x=R=>{h.current=R.touches[0].clientX},w=R=>{p.current=R.touches[0].clientX},S=()=>{if(h.current===null||p.current===null)return;const R=h.current-p.current;Math.abs(R)>50&&(R>0?y():m()),h.current=null,p.current=null};T.useEffect(()=>{if(r.length===0||c)return;const R=setInterval(()=>{l(M=>(M+1)%r.length)},1e4);return()=>clearInterval(R)},[r.length,c]);const _=r[a],L=R=>R?R.includes("drive.google.com")?`/api/drive-thumbnail?url=${encodeURIComponent(R)}`:R:"";return o.jsx("div",{className:"bg-black",children:o.jsxs("section",{className:"relative flex min-h-[calc(100dvh-4rem)] flex-col items-center overflow-hidden",children:[o.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-[hsl(142,76%,15%)]/20 via-black/60 to-black"}),o.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top_right,_var(--tw-gradient-stops))] from-[hsl(142,76%,45%)]/8 via-trans
61parent to-transparent"}),o.jsxs("div",{className:"relative z-10 w-full flex-1 flex flex-col items-center justify-start pt-4",children:[o.jsxs("div",{className:"relative flex min-h-[clamp(520px,60vh,680px)] w-full max-w-[1200px] items-center justify-center overflow-visible",children:[o.jsxs("div",{className:"absolute pointer-events-none",style:{zIndex:0,left:"-60%",right:"-60%",top:"-40%",bottom:"-40%",overflow:"visible"},children:[o.jsx("style",{children:` 62 @keyframes nebula-pulse { 63 0%, 100% { opacity: 0.85; transform: scale(1); } 64 50% { opacity: 1; transform: scale(1.08); } 65 } 66 @keyframes nebula-drift { 67 0%, 100% { transform: translateY(0px) rotate(0deg); opacity: 0.8; } 68 50% { transform: translateY(-22px) rotate(4deg); opacity: 1; } 69 } 70 @keyframes star-twinkle { 71 0%, 100% { opacity: 0.15; transform: scale(0.7); } 72 40% { opacity: 1; transform: scale(1.4); } 73 60% { opacity: 0.9; transform: scale(1.2); } 74 } 75 @keyframes star-twinkle-slow { 76 0%, 100% { opacity: 0.3; transform: scale(0.8); } 77 50% { opacity: 1; transform: scale(1.3); } 78 } 79 @keyframes star-flash { 80 0%, 85%, 100% { opacity: 0.1; } 81 90% { opacity: 1; } 82 } 83 @keyframes dust-drift { 84 0%, 100% { transform: translate(-50%,-50%) rotate(0deg); opacity: 0.6; } 85 50% { transform: translate(-50%,-50%) rotate(6deg); opacity: 0.9; } 86 } 87 `}),o.jsx("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"800px",height:"600px",background:"radial-gradient(ellipse at 45% 55%, rgba(140,50,230,0.85) 0%, rgba(100,30,190,0.65) 25%, rgba(60,15,130,0.35) 55%, transparent 80%)",borderRadius:"50%",filter:"blur(22px)",animation:"nebula-pulse 8s ease-in-out infinite"}}),o.jsx("div",{style:{position:"absolute",top:"42%",left:"28%",transform:"translate(-50%, -50%)",width:"580px",height:"420px",background:"radial-gradient(ellipse at center, rgba(40,120,255,0.7) 0%, rgba(20,70,200,0.45) 40%, transparent 80%)",borderRadius:"50%",filter:"blur(28px)",animation:"nebula-pulse 11s ease-in-out infinite 2s"}}),o.jsx("div",{style:{position:"absolute",top:"28%",left:"68%",transform:"translate(-50%, -50%)",width:"440px",height:"340px",background:"radial-gradient(ellipse at center, rgba(230,60,200,0.75) 0%, rgba(180,30,150,0.5) 40%, transparent 80%)",borderRadius:"50%",filter:"blur(24px)",animation:"nebula-drift 14s ease-in-out infinite"}}),o.jsx("div",{style:{position:"absolute",top:"72%",left:"58%",transform:"translate(-50%, -50%)",width:"460px",height:"240px",background:"radial-gradient(ellipse at center, rgba(0,220,200,0.55) 0%, rgba(0,160,140,0.3) 50%, transparent 85%)",borderRadius:"50%",filter:"blur(30px)",animation:"nebula-pulse 10s ease-in-out infinite 4s"}}),o.jsx("div",{style:{position:"absolute",top:"60%",left:"18%",transform:"translate(-50%, -50%)",width:"300px",height:"220px",background:"radial-gradient(ellipse at center, rgba(255,160,30,0.45) 0%, rgba(200,100,10,0.2) 55%, transparent 90%)",borderRadius:"50%",filter:"blur(26px)",animation:"nebula-drift 18s ease-in-out infinite 3s"}}),o.jsx("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%) rotate(-25deg)",width:"900px",height:"120px",background:"linear-gradient(90deg, transparent 0%, rgba(180,100,255,0.18) 20%, rgba(100,60,220,0.28) 50%, rgba(200,80,180,0.18) 80%, transparent 100%)",filter:"blur(16px)",animation:"dust-drift 20s ease-in-out infinite"}}),[["-45%","12%",1.8,2.1,"#fff"],["-30%","35%",1.2,4.3,"#cce"],["-55%","55%",2.2,1.5,"#fff"],["-20%","8%",1,6.2,"#ffd"],["-38%","-5%",1.6,3.8,"#adf"],["-15%","48%",1.3,7.1,"#fff"],["-50%","70%",.9,5,"#fca"],["-60%","30%",2,2.8,"#fff"],["-25%","62%",1.4,1.2,"#cef"],["10%","-30%",1.7,4.7,"#fff"],["25%","-20%",1,6.5,"#ddf"],["5%","-45%",2.3,3.1,"#fff"],["40%","-35%",1.5,8,"#ffd"],["55%","-18%",1.1,2.4,"#fff"],["70%","-28%",1.9,5.5,"#aff"],["85%","5%",1.3,1.8,"#fff"],["92%","20%",.8,7.2,"#fca"],["78%","40%",2.1,3.4,"#fff"],["65%","58%",1.2,6.8,"#ddf"],["80%","65%",1.6,4.1,"#fff"],["90%","50%",1,2,"#cef"],["72%","78%",1.4,5.3,"#fff"],["55%","85%",1.8,1.1,"#ffd"],["40%","75%",1.1,7.6,"#fff"],["22%","80%",2,3.9,"#adf"],["8%","72%",1.5,6,"#fff"],["15%","55%",.9,4.5,"#fca"],["30%","48%",1.7,2.7,"#fff"],["48%","35%",1.2,8.4,"#fff"],["60%","28%",2.4,1.9,"#ddf"],["-5%","25%",1,5.8,"#fff"],["-18%","15%",1.8,3.3,"#cce"],["-35%","22%",1.3,7,"#fff"],["18%","10%",1.6,4.2,"#aff"],["35%","5%",.9,6.7,"#fff"],["50%","15%",2,2.2,"#ffd"],["-8%","-15%",1.4,5.1,"#fff"],["-28%","-22%",1.1,1.6,"#fff"],["42%","-8%",1.7,3.7,"#cef"],["62%","-42%",1.3,7.9,"#fff"],["15%","-55%",2.2,2.3,"#fff"],["-12%","-38%",.8,5.6,"#fca"],["28%","-48%",1.5,4,"#ddf"],["-42%","-30%",1.9,1.3,"#fff"],["-58%","-12%",1,6.4,"#adf"],["95%","35%",1.6,3.2,"#fff"],["-65%","48%",2.1,2.6,"#fff"],["-22%","82%",1.2,7.3,"#ffd"],["52%","-55%",1.8,4.8,"#fff"],["38%","92%",1,1.7,"#fff"],["-48%","88%",1.5,5.9,"#cef"],["82%","-15%",2.3,3.5,"#fff"],["-32%","-48%",1.1,6.1,"#fff"],["68%","88%",1.7,2.9,"#aff"],["-62%","15%",.9,4.4,"#fca"],["12%","-62%",2,7.8,"#fff"],["88%","8
870%",1.4,1.4,"#ddf"],["45%","-62%",1.3,5.2,"#fff"],["-18%","92%",1.6,3,"#fff"],["22%","-72%",1.1,6.3,"#cce"]].map(([R,M,V,W,I],k)=>o.jsx("div",{style:{position:"absolute",left:R,top:M,width:`${V*2.5}px`,height:`${V*2.5}px`,borderRadius:"50%",background:I,boxShadow:V>1.6?`0 0 ${V*4}px ${V*2}px ${I}88`:"none",animation:k%5===0?`star-flash ${4+k%3}s ease-in-out infinite ${W}s`:k%3===0?`star-twinkle-slow ${5+k%4}s ease-in-out infinite ${W}s`:`star-twinkle ${2.5+k%3*.8}s ease-in-out infinite ${W}s`}},k)),[["20%","30%"],["-35%","50%"],["65%","20%"],["55%","70%"],["-10%","-20%"]].map(([R,M],V)=>Array.from({length:8}).map((W,I)=>{const k=I*37%60-30,P=I*53%60-30,N=.5+I%3*.4;return o.jsx("div",{style:{position:"absolute",left:`calc(${R} + ${k}px)`,top:`calc(${M} + ${P}px)`,width:`${N*2}px`,height:`${N*2}px`,borderRadius:"50%",background:I%2===0?"#fff":"#ccf",animation:`star-twinkle ${2+I*.6}s ease-in-out infinite ${I*.9}s`}},`c${V}-${I}`)})),o.jsx("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"380px",height:"500px",background:"radial-gradient(ellipse at 50% 60%, rgba(130,70,240,0.5) 0%, rgba(80,40,180,0.25) 45%, transparent 75%)",borderRadius:"50%",filter:"blur(18px)",animation:"nebula-pulse 6s ease-in-out infinite 1s"}})]}),o.jsx(qJ,{categories:i,centerX:"50%",centerY:"50%",offsetX:0}),o.jsx("img",{src:GJ,alt:"Carri Chronic",style:{height:"clamp(360px, 60vh, 680px)",width:"auto",maxWidth:"78vw",objectFit:"contain",position:"relative",zIndex:10},"data-testid":"carri-chronic-image"}),o.jsx("div",{className:"absolute",style:{top:"15%",left:"39%",transform:"translate(-50%, -50%)",width:"8.5%",aspectRatio:"1"},onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),"data-testid":"globe-container",children:o.jsx(Et,{href:_?`/${_.brandName.replace(/\s+/g,"")}`:"/brands",children:o.jsxs("div",{className:"w-full h-full rounded-full bg-white overflow-hidden transition-transform duration-300 hover:scale-110 cursor-pointer relative",style:{boxShadow:` 88 0 8px 20px rgba(0, 0, 0, 0.6), 89 0 0 25px rgba(255, 255, 255, 0.5), 90 0 0 50px rgba(74, 222, 128, 0.3), 91 inset 0 -15px 25px rgba(0, 0, 0, 0.6), 92 inset 0 8px 15px rgba(255, 255, 255, 0.25) 93 `},children:[_?.logoUrl?o.jsx("img",{src:_.logoUrl.includes("drive.google.com")?`/api/drive-thumbnail?url=${encodeURIComponent(_.logoUrl)}`:_.logoUrl,alt:_.brandName,className:"w-full h-full object-cover transition-all duration-500 rounded-full"}):o.jsx("div",{className:"w-6 h-6 border-2 border-gray-400 border-t-transparent rounded-full animate-spin"}),o.jsx("div",{className:"absolute pointer-events-none",style:{top:"8%",left:"15%",width:"35%",height:"25%",borderRadius:"50%",background:"radial-gradient(ellipse at center, rgba(255, 255, 255, 0.75) 0%, rgba(255, 255, 255, 0.35) 40%, transparent 70%)",filter:"blur(2px)"}}),o.jsx("div",{className:"absolute pointer-events-none",style:{top:"5%",left:"25%",width:"15%",height:"12%",borderRadius:"50%",background:"rgba(255, 255, 255, 0.95)",filter:"blur(1px)"}}),o.jsx("div",{className:"absolute inset-0 rounded-full pointer-events-none",style:{background:"radial-gradient(circle at 50% 50%, transparent 0%, transparent 50%, rgba(0, 0, 0, 0.5) 80%, rgba(0, 0, 0, 0.75) 100%)"}}),o.jsx("div",{className:"absolute pointer-events-none",style:{bottom:"5%",left:"10%",right:"10%",height:"30%",borderRadius:"50%",background:"linear-gradient(to top, rgba(0, 0, 0, 0.5) 0%, transparent 100%)"}})]})})})]}),_&&o.jsxs("div",{className:"mt-4 text-center max-w-2xl px-6","data-testid":"brand-summary",onTouchStart:x,onTouchMove:w,onTouchEnd:S,children:[o.jsx("h3",{className:"text-2xl md:text-3xl font-bold mb-2 transition-all duration-500",style:{color:_.primaryColor||"#4ade80"},children:o.jsx(X6,{brandName:_.brandName,size:"2xl",color:_.primaryColor||"#4ade80"})}),o.jsx("p",{className:"text-white/80 text-sm md:text-base leading-relaxed transition-all duration-500 mb-4",children:_.summary}),o.jsx(Et,{href:`/${_.brandName.replace(/\s+/g,"")}`,children:o.jsx("button",{className:"px-6 py-3 rounded-full font-bold transition-all hover:scale-105",style:{background:_.primaryColor||"#4ade80",color:"black"},"data-testid":"find-out-more-button",children:"Find Out More"})})]})]}),r.length>0&&o.jsxs("div",{className:"flex items-center gap-3 z-20 mt-2 mb-2 px-3",children:[o.jsx("button",{onClick:m,className:"min-h-11 min-w-11 p-2 rounded-full bg-white/10 hover:bg-white/20 transition-all","data-testid":"brand-prev-button",children:o.jsx(md,{className:"w-5 h-5 text-white"})}),o.jsx("div",{className:"flex gap-2",children:r.map((R,M)=>o.jsx("button",{onClick:()=>l(M),"aria-label":`Show brand ${M+1}`,className:`relative min-h-11 overflow-hidden rounded-full border border-white/20 bg-white/10 p-0 transition-all ${M===a?"h-12 w-12 border-white/60 ring-2 ring-white/30":"h-10 w-10 opacity-70 hover:opacity-100"}`,style:M===a?{backgroundColor:R.primaryColor||"#4ade80"}:void 0,"data-testid":`brand-indicator-${M}`,children:R.logoUrl?o.jsx("img",{src:L(R.logoUrl),alt:"",className:"h-full w-full rounded-full object-cover",loading:"lazy"}):o.jsx("span",{className:"flex h-full w-full items-center justify-center text-xs font-bold text-white",children:R.brandName.slice(0,1)})},M))}),o.jsx("button",{onClick:y,className:"min-h-11 min-w-11 p-2 rounded-full bg-white/10 hover:bg-white/20 transition-all","data-testid":"brand-next-button",children:o.jsx(Uc,{className:"w-5 h-5 text-white"})})]})]})})}function QJ({show:n=!0}){return n?o.jsxs("div",{className:"fixed inset-0 pointer-events-none z-[9999]",children:[[10,20,30,40,50,60,70,80,90].map(e=>o.jsx("div",{className:"absolute top-0 bottom-0 w-px bg-red-500/30",style:{left:`${e}%`},children:o.jsxs("span",{className:"absolute top-2 -translate-x-1/2 text-red-500 text-xs bg-black/80 px-1",children:[e,"%"]})},`v-${e}`)),[10,20,30,40,50,60,70,80,90].map(e=>o.jsx("div",{className:"absolute left-0 right-0 h-px bg-blue-500/30",style:{to
93p:`${e}%`},children:o.jsxs("span",{className:"absolute left-2 -translate-y-1/2 text-blue-500 text-xs bg-black/80 px-1",children:[e,"%"]})},`h-${e}`)),o.jsx("div",{className:"absolute left-1/2 top-0 bottom-0 w-px bg-yellow-500/50"}),o.jsx("div",{className:"absolute top-1/2 left-0 right-0 h-px bg-yellow-500/50"})]}):null}const XJ=[{icon:wF,title:"Empowerment",description:"We believe in empowering patients, businesses, and communities to thrive in the cannabis industry."},{icon:xh,title:"Quality",description:"From our media content to our services, we maintain the highest standards of professionalism."},{icon:ff,title:"Community",description:"Building connections and fostering a supportive network for cannabis advocates and entrepreneurs."},{icon:UF,title:"Innovation",description:"Pioneering new ways to serve and support Oklahoma's evolving cannabis landscape."}],JJ=[{year:"2018",title:"The Beginning",description:"State Question 788 passes in Oklahoma, legalizing medical marijuana. Carri and Wallace Lawrence see an opportunity to serve the community."},{year:"2019",title:"Building the Foundation",description:"Launch of Chronic Docs telemedicine service, helping hundreds of thousands of Oklahomans get their MMJ cards."},{year:"2020",title:"Expanding Services",description:"Chronic Studios, Chronic Security, and Chronic Staffing join the family of brands, creating a full-service ecosystem."},{year:"2021",title:"Chronic Palooza",description:"The first Chronic Palooza event brings together thousands of cannabis enthusiasts for education and celebration."},{year:"2022",title:"Chronic Lounge Opens",description:"Oklahoma's premier members-only 420-friendly venue opens in OKC, housing studios for Chronic TV."},{year:"2023-Present",title:"Chronic TV Launch",description:"The streaming network launches, bringing original cannabis culture content to viewers everywhere."}];function ZJ(){const{data:n}=gn({queryKey:["/api/website-asset-url/About Main Image"]}),e=n?.url?`/api/drive-thumbnail?url=${encodeURIComponent(n.url)}`:null;return o.jsxs("div",{className:"min-h-screen bg-black",children:[o.jsx(QJ,{show:!1}),o.jsxs("section",{className:"relative py-24 md:py-32 px-4 overflow-hidden",children:[o.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-[hsl(142,76%,15%)]/20 to-black"}),o.jsxs("div",{className:"relative max-w-7xl mx-auto text-center",children:[o.jsxs("h1",{className:"text-4xl md:text-6xl font-bold mb-6 relative z-10 flex items-center justify-center gap-4","data-testid":"about-title",children:[o.jsx("span",{className:"text-white",children:"About"}),o.jsx(Is,{suffix:" Brands",size:"4xl",color:"#4ade80",style:{marginTop:"2%"}})]}),o.jsx("p",{className:"text-xl text-white/70 max-w-3xl mx-auto",children:"The story of how a passion for cannabis culture became Oklahoma's premier cannabis services empire"})]})]}),o.jsx("section",{className:"py-20 px-4 bg-[hsl(0,0%,5%)]",children:o.jsx("div",{className:"max-w-7xl mx-auto",children:o.jsxs("div",{className:"grid md:grid-cols-2 gap-12 items-center",children:[o.jsxs("div",{children:[o.jsx("h2",{className:"text-3xl md:text-4xl font-bold mb-6",children:o.jsx("span",{className:"text-[hsl(45,93%,47%)]",children:"Our Founders"})}),o.jsxs("p",{className:"text-white/70 text-lg leading-relaxed mb-0",children:[o.jsxs("strong",{className:"text-[hsl(142,76%,45%)]",children:['Carri "',o.jsx(Is,{size:"lg",color:"#4ade80"}),'" Lawrence']})," is the primary visionary and public face of ",o.jsx(Is,{suffix:" Brands",size:"lg",color:"#4ade80"}),". With expertise in sales, marketing, events, media, and advocacy for cannabis reform, she has been instrumental in shaping Oklahoma's medical marijuana landscape."]}),o.jsxs("p",{className:"text-white/70 text-lg leading-relaxed mb-0",children:[o.jsxs("strong",{className:"text-[hsl(142,76%,45%)]",children:['Wallace "Wally ',o.jsx(Is,{size:"lg",color:"#4ade80"}),'" Lawrence']})," brings operational expertise and business acumen to the organization. Together, they've built an empire that serves hundreds of thousands of Oklahomans."]}),o.jsx("p",{className:"text-white/70 text-lg leading-relaxed",children:"Since the passage of State Question 788 in 2018, C
93arri and Wallace have been deeply involved in Oklahoma's medical marijuana scene, advocating for patients' rights and building services that the community needs."})]}),o.jsx("div",{className:"relative",children:e?o.jsx("div",{className:"aspect-square rounded-2xl overflow-hidden border border-[hsl(142,76%,45%)]/30",children:o.jsx("img",{src:e,alt:"Carri and Wallace Lawrence - Chronic Brands Founders",className:"w-full h-full object-cover","data-testid":"about-main-image"})}):o.jsx("div",{className:"aspect-square rounded-2xl bg-gradient-to-br from-[hsl(142,76%,25%)] to-[hsl(142,76%,15%)] flex items-center justify-center border border-[hsl(142,76%,45%)]/30",children:o.jsxs("div",{className:"text-center p-8",children:[o.jsx("div",{className:"text-6xl mb-4",children:"ð¿"}),o.jsx("p",{className:"text-white/80 text-lg italic",children:'"Premium Culture, Content, and Creativity"'}),o.jsxs("p",{className:"text-[hsl(45,93%,47%)] mt-4 font-semibold",children:["- ",o.jsx(Is,{suffix:" Brands",size:"base",color:"#eab308"})]})]})})})]})})}),o.jsx("section",{className:"py-20 px-4 bg-black",children:o.jsxs("div",{className:"max-w-7xl mx-auto",children:[o.jsx("div",{className:"text-center mb-12",children:o.jsxs("h2",{className:"text-3xl md:text-4xl font-bold mb-4",children:[o.jsx("span",{className:"text-white",children:"Our "}),o.jsx("span",{className:"text-[hsl(142,76%,45%)]",children:"Values"})]})}),o.jsx("div",{className:"grid md:grid-cols-2 lg:grid-cols-4 gap-6",children:XJ.map(t=>{const s=t.icon;return o.jsxs("div",{className:"bg-[hsl(0,0%,8%)] rounded-xl p-6 border border-white/10 hover:border-[hsl(45,93%,47%)] transition-colors",children:[o.jsx("div",{className:"w-12 h-12 rounded-lg bg-[hsl(142,76%,45%)] flex items-center justify-center mb-4",children:o.jsx(s,{size:24,className:"text-black"})}),o.jsx("h3",{className:"text-xl font-bold text-white mb-2",children:t.title}),o.jsx("p",{className:"text-white/60 text-sm",children:t.description})]},t.title)})})]})}),o.jsx("section",{className:"py-20 px-4 bg-[hsl(0,0%,5%)]",children:o.jsxs("div",{className:"max-w-4xl mx-auto",children:[o.jsx("div",{className:"text-center mb-12",children:o.jsxs("h2",{className:"text-3xl md:text-4xl font-bold mb-4",children:[o.jsx("span",{className:"text-white",children:"Our "}),o.jsx("span",{className:"text-[hsl(45,93%,47%)]",children:"Journey"})]})}),o.jsxs("div",{className:"relative",children:[o.jsx("div",{className:"absolute left-4 md:left-1/2 top-0 bottom-0 w-0.5 bg-gradient-to-b from-[hsl(142,76%,45%)] via-[hsl(45,93%,47%)] to-[hsl(142,76%,45%)]"}),o.jsx("div",{className:"space-y-12",children:JJ.map((t,s)=>o.jsxs("div",{className:`relative flex items-start gap-8 ${s%2===0?"md:flex-row":"md:flex-row-reverse"}`,children:[o.jsx("div",{className:`flex-1 ${s%2===0?"md:text-right":"md:text-left"} pl-12 md:pl-0`,children:o.jsxs("div",{className:"bg-[hsl(0,0%,8%)] rounded-xl p-6 border border-white/10",children:[o.jsx("span",{className:"text-[hsl(45,93%,47%)] font-bold text-lg",children:t.year}),o.jsx("h3",{className:"text-xl font-bold text-white mt-1 mb-2",children:t.title}),o.jsx("p",{className:"text-white/60",children:t.description})]})}),o.jsx("div",{className:"absolute left-4 md:left-1/2 md:-translate-x-1/2 w-4 h-4 rounded-full bg-[hsl(142,76%,45%)] border-4 border-black"}),o.jsx("div",{className:"hidden md:block flex-1"})]},t.year))})]})]})}),o.jsx("section",{className:"py-20 px-4 bg-gradient-to-b from-black to-[hsl(0,0%,5%)]",children:o.jsxs("div",{className:"max-w-4xl mx-auto text-center",children:[o.jsxs("h2",{className:"text-3xl md:text-4xl font-bold mb-6 flex items-center justify-center gap-3",children:[o.jsx("span",{className:"text-white",children:"Experience"}),o.jsx("img",{src:"/assets/ChronicTVlogo2b.png",alt:"Chronic TV",className:"h-16 w-auto"})]}),o.jsx("p",{className:"text-white/60 text-lg mb-8 max-w-2xl mx-auto",children:"Dive into our streaming platform featuring original cannabis culture content, live events, and exclusive programming."}),o.jsxs(Et,{href:"/chronic-tv",className:"inline-flex items-center gap-2 bg-[hsl(142,76%,45%)] text-black px-8 py-4 rounded-full font-bold text-lg hover:bg-[hsl(142,76%,55%)] transition-colors","data-testid":"cta-watch-chronic-tv",children:[o.jsx(Bc,{size:20}),"Watch Now"]})]})})]})}function eZ(n){try{const e=new URL(n),t=e.hostname.replace(/^www\./,"").toLowerCase();
93if(t==="youtu.be"){const s=e.pathname.split("/").filter(Boolean)[0];return s?`https://www.youtube.com/embed/${encodeURIComponent(s)}?autoplay=1&mute=1&loop=1&playlist=${encodeURIComponent(s)}&controls=0&playsinline=1&rel=0`:null}if(t==="youtube.com"||t==="youtube-nocookie.com"){const s=e.searchParams.get("v")||e.pathname.match(/\/(?:embed|shorts)\/([^/?]+)/)?.[1];return s?`https://www.youtube-nocookie.com/embed/${encodeURIComponent(s)}?autoplay=1&mute=1&loop=1&playlist=${encodeURIComponent(s)}&controls=0&playsinline=1&rel=0`:null}if(t==="vimeo.com"||t==="player.vimeo.com"){const s=e.pathname.match(/\/(?:video\/)?(\d+)/)?.[1];return s?`https://player.vimeo.com/video/${s}?autoplay=1&muted=1&loop=1&controls=0&background=1&playsinline=1`:null}}catch{return null}return null}function tN({url:n,mediaType:e,alt:t,className:s=""}){const[r,i]=T.useState(!1);if(T.useEffect(()=>{i(!1)},[n]),!n?.trim())return null;const a=n.trim();if(r)return null;const l=eZ(a);return l?o.jsx("iframe",{src:l,title:t,className:`pointer-events-none absolute inset-0 h-full w-full border-0 ${s}`,allow:"autoplay; fullscreen","aria-hidden":"true",onError:()=>i(!0)}):e==="video"||/\.(?:mp4|webm|ogg|mov)(?:$|[?#])/i.test(a)?o.jsx("video",{src:a,className:`absolute inset-0 h-full w-full object-cover ${s}`,autoPlay:!0,muted:!0,loop:!0,playsInline:!0,controls:!1,"aria-label":t,onError:()=>i(!0)}):o.jsx("img",{src:a,alt:t,className:`absolute inset-0 h-full w-full object-cover ${s}`,onError:()=>i(!0)})}const r_={"Chronic News Classics":["Breaking cannabis industry news","In-depth investigative reports","Legislative updates and policy analysis","Community spotlight stories"],"Chronic Studios":["Full-service video production","Professional lighting and sound","Post-production editing","Brand commercial creation"],"Chronic TMZ with Carri Chronic":["Celebrity cannabis culture coverage","Exclusive interviews and reveals","Entertainment industry insights","Behind-the-scenes access"],"Chronic Reviews":["Honest product evaluations","Strain reviews and ratings","Dispensary spotlights","Consumer buying guides"],"Chronic Cuties":["Lifestyle and fashion content","Brand ambassador features","Photo and video shoots","Social media collaborations"],"Chronic Sports Talk":["Cannabis and athletics coverage","Athlete wellness discussions","Sports industry cannabis news","Live commentary and analysis"],"Chronic Palooza":["Cannabis festival coverage","Live event broadcasting","Vendor and brand showcases","Community celebration events"],"In The Streets with CarriChronic":["Street-level interviews","Community voice platform","Real people, real stories","Oklahoma neighborhood features"],"Chronic Docs":["Medical marijuana evaluations","Licensed physician consultations","Fast and affordable appointments","Renewal and new patient services"],"OlyLife Oklahoma":["Terahertz wellness technology","Pain relief and recovery","Cellular regeneration devices","Holistic health solutions"],"Sacred Wellness Assocation":["Wellness community network","Holistic health education","Member support and resources","Spiritual wellness practices"]};function tZ(){const{data:n,isLoading:e}=gn({queryKey:["/api/website-brands"],staleTime:0,refetchOnMount:"always"}),{data:t,isLoading:s}=gn({queryKey:["/api/startup-bundle"]}),{data:r}=gn({queryKey:["/api/site-settings"]}),i=t?.categories||[],a=Array.isArray(n)?n:[],l=c=>{const d=c.brandName.toLowerCase().replace(/\s+/g,""),h=i.find(p=>p.name.toLowerCase().replace(/\s+/g,"")===d);return{...c,matchingCategory:h,categoryThumbnail:h?.thumbnailUrl||"",summary:h?.summaryContent||h?.description||"",hasChronicTVChannel:!!h}};return e||s?o.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:o.jsx("div",{className:"animate-pulse text-white/60",children:"Loading brands..."})}):o.jsxs("div",{className:"min-h-screen bg-black",children:[o.jsxs("section",{className:"relative py-24 md:py-32 px-4 overflow-hidden",children:[o.jsx(tN,{url:r?.brandsHeroMediaUrl,mediaType:r?.brandsHeroMediaType,alt:"Our Brands hero"}),o.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-[hsl(45,93%,20%)]/20 to-black"}),r?.brandsHeroMediaUrl&&o.jsx("div",{className:"absolute inset-0 bg-black/45"}),o.jsxs("div",{className:"relative max-w-7xl mx-auto text-center",children:[o.jsxs("h1",{className:"text-4xl md:text-6xl font-bold mb-6","data-testid":"brands-title",children:[o.jsx("span",{className:"text-white",children:"Our "}),o.jsx("span",{className:"text-[hsl(142,76%,45%)]",children:"Brands"})]}),o.jsx("p",{className:"text-xl text-white/70 max-w-3xl mx-auto",children:"A comprehensive ecosystem of services empowering Oklahoma's cannabis
93industry"})]})]}),o.jsx("section",{className:"py-12 px-4 bg-[hsl(0,0%,5%)]",children:o.jsx("div",{className:"max-w-7xl mx-auto",children:o.jsx("div",{className:"space-y-16",children:a.map((c,d)=>{const h=l(c),p=d%2===0,m=c.primaryColor||"#4ade80",y=c.secondaryImageUrl&&c.secondaryImageUrl.trim()!=="",x=c.logoUrl&&c.logoUrl.trim()!=="";return o.jsxs("div",{id:c.brandName.toLowerCase().replace(/\s+/g,"-"),className:`flex flex-col ${p?"lg:flex-row":"lg:flex-row-reverse"} gap-8 lg:gap-12 items-center scroll-mt-24`,"data-testid":`brand-section-${c.brandName}`,children:[o.jsxs("div",{className:"flex-1",children:[o.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[o.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center overflow-hidden",children:y?o.jsx("img",{src:`/api/drive-thumbnail?url=${encodeURIComponent(c.secondaryImageUrl)}`,alt:c.brandName,className:"w-full h-full object-contain"}):o.jsx("div",{className:"w-full h-full bg-white flex items-center justify-center",children:o.jsx(ET,{size:32,style:{color:m}})})}),o.jsx("div",{children:o.jsx("h2",{className:"text-2xl md:text-3xl font-bold text-white",children:o.jsx(X6,{brandName:c.brandName,size:"2xl",color:m})})})]}),o.jsx("p",{className:"text-white/70 text-lg leading-relaxed mb-4",children:h.summary}),r_[c.brandName]&&o.jsx("ul",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2 mb-6",children:r_[c.brandName].map((w,S)=>o.jsxs("li",{className:"flex items-center gap-2 text-white/80",children:[o.jsx(_a,{size:16,style:{color:m},className:"flex-shrink-0"}),o.jsx("span",{className:"text-sm",children:w})]},S))}),o.jsxs("div",{className:"flex flex-wrap gap-4",children:[c.brandFunnel?o.jsxs("a",{href:c.brandFunnel,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 px-6 py-3 rounded-full font-bold transition-all hover:scale-105",style:{backgroundColor:m,color:"black"},"data-testid":`schedule-${c.brandName}`,children:[o.jsx(Xc,{size:18}),"Get Merch / Schedule Appointment"]}):o.jsxs(Et,{href:`/shop?brand=${encodeURIComponent(c.brandName)}`,className:"inline-flex items-center gap-2 px-6 py-3 rounded-full font-bold transition-all hover:scale-105",style:{backgroundColor:m,color:"black"},"data-testid":`schedule-${c.brandName}`,children:[o.jsx(Xc,{size:18}),"Get Merch / Schedule Appointment"]}),h.hasChronicTVChannel&&o.jsxs(Et,{href:`/chronic-tv/${(h.matchingCategory?.name||c.brandName).toLowerCase().replace(/\s+/g,"-")}`,className:"inline-flex items-center gap-2 px-6 py-3 rounded-full font-bold transition-all hover:scale-105 bg-white/10 hover:bg-white/20",children:[o.jsx("span",{className:"text-white",children:"Watch on"}),o.jsx("img",{src:"/assets/ChronicTVlogo2b.png",alt:"ChronicTV",className:"h-10 w-auto"})]}),o.jsxs(Et,{href:`/${c.brandName.replace(/\s+/g,"")}`,className:"inline-flex items-center gap-2 px-6 py-3 rounded-full font-bold transition-all hover:scale-105 border-2 text-white hover:bg-white/10",style:{borderColor:m},"data-testid":`findmore-${c.brandName}`,children:["Find Out More",o.jsx(lF,{size:18})]})]})]}),o.jsx("div",{className:"flex-1 w-full",children:o.jsx(Et,{href:`/${c.brandName.replace(/\s+/g,"")}`,children:o.jsx("div",{className:"aspect-video rounded-2xl flex items-center justify-center border overflow-hidden cursor-pointer hover:scale-[1.02] transition-transform bg-white",style:{borderColor:`${m}30`},children:h.categoryThumbnail?o.jsx("img",{src:`/api/drive-thumbnail?url=${encodeURIComponent(h.categoryThumbnail)}&v=${btoa(h.categoryThumbnail).slice(-12)}`,alt:c.brandName,className:"w-full h-full object-contain"}):x?o.jsx("img",{src:`/api/drive-thumbnail?url=${encodeURIComponent(c.logoUrl)}`,alt:c.brandName,className:"h-full object-contain"}):y?o.jsx("img",{src:`/api/drive-thumbnail?url=${encodeURIComponent(c.secondaryImageUrl)}`,alt:c.brandName,className:"max-w-[60%] max-h-[60%] object-contain"}):o.jsx(ET,{size:100,style:{color:m},className:"opacity-50"})})})})]},c.brandName)})})})}),o.jsx("section",{className:"py-20 px-4 bg-gradient-to-b from-[hsl(0,0%,5%)] to-black",children:o.jsxs("div",{className:"max-w-4xl mx-auto text-center",children:[o.jsxs("h2",{className:"text-3xl md:text-4xl font-bold mb-6",children:[o.jsx("span",{className:"text-white",children:"Ready to "}),o.jsx("span",{className:"text-[hsl(142,76%,45%)]",children:"Connect?"})]}),o.jsxs("p",{className:"text-white/60 text-lg mb-8 max-w-2xl mx-auto",children:["Whether you need our services or want to partner with ",o.jsx(Is,{suffix:" Brands",size:"lg",color:"#4ade80"}),", we'd love to hear from you."]}),o.jsx(Et,{href:"/about",className:"inline-flex items-center gap-2 bg-[hsl(45,93%,47%)] text-black px-8 py-4 rounded-full font-bold text-lg hover:bg-[hsl(45,93%,57%)] transition-colors","data-testid":"cta-contact-us",children:"Get In Touch"})]})})]})}const nZ=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],sZ=["January","February","March","April","May","June","July","August","September","October","November","December"];function rZ({isOpen:n,onClose:e,onSlotSelected:t,productName:s,duration:r=60}){const[i,a]=T.useState(new Date),[l,c]=T.useState(null),[d,h]=T.useState(null),{data:p=[]}=gn({queryKey:["/api/availability"],enabled:n}),{data:m,isLoading:y}=gn({queryKey:["/api/calendar/available-slots",l,r],queryFn:async()=>l?(await fetch(`/api/calendar/available-slots?date=${l}&duration=${r}`)).json():{slots:[]},enabled:!!l&&n});if(T.useEffect(()=>{n||(c(null),h(null))},[n]),!n)return null;const x=P=>{const N=P.getFullYear(),F=P.getMonth(),z=new Date(N,F,1),U=new Date(N,F+1,
930),fe=[];for(let oe=0;oe<z.getDay();oe++)fe.push(null);for(let oe=1;oe<=U.getDate();oe++)fe.push(new Date(N,F,oe));return fe},w=P=>{const N=new Date;if(N.setHours(0,0,0,0),P<N)return!1;const F=P.getDay();return p.find(U=>U.dayOfWeek===F)?.isAvailable||!1},S=P=>{if(!w(P))return;const N=P.toISOString().split("T")[0];c(N),h(null)},_=P=>{P.available&&h(P)},L=()=>{d&&t({date:d.date,startTime:d.startTime,endTime:d.endTime})},R=()=>{a(new Date(i.getFullYear(),i.getMonth()-1)),c(null),h(null)},M=()=>{a(new Date(i.getFullYear(),i.getMonth()+1)),c(null),h(null)},V=x(i),W=m?.slots||[],I=P=>{const[N,F]=P.split(":").map(Number),z=N>=12?"PM":"AM";return`${N%12||12}:${String(F).padStart(2,"0")} ${z}`},k=P=>new Date(P+"T00:00:00").toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric"});return o.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:o.jsxs("div",{className:"bg-zinc-900 border border-zinc-700 rounded-2xl max-w-lg w-full max-h-[90vh] overflow-hidden",children:[o.jsxs("div",{className:"p-4 border-b border-zinc-800 flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("h2",{className:"text-lg font-bold text-white",children:"Select Date & Time"}),o.jsx("p",{className:"text-zinc-400 text-sm",children:s})]}),o.jsx("button",{onClick:e,className:"p-2 hover:bg-zinc-800 rounded-lg transition-colors",children:o.jsx(Mr,{className:"w-5 h-5 text-zinc-400"})})]}),o.jsxs("div",{className:"p-4 overflow-y-auto max-h-[calc(90vh-140px)]",children:[o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsx("button",{onClick:R,className:"p-2 hover:bg-zinc-800 rounded-lg transition-colors",children:o.jsx(md,{className:"w-5 h-5 text-zinc-400"})}),o.jsxs("h3",{className:"text-white font-semibold",children:[sZ[i.getMonth()]," ",i.getFullYear()]}),o.jsx("button",{onClick:M,className:"p-2 hover:bg-zinc-800 rounded-lg transition-colors",children:o.jsx(Uc,{className:"w-5 h-5 text-zinc-400"})})]}),o.jsx("div",{className:"grid grid-cols-7 gap-1 mb-2",children:nZ.map(P=>o.jsx("div",{className:"text-center text-xs text-zinc-500 py-2",children:P},P))}),o.jsx("div",{className:"grid grid-cols-7 gap-1 mb-6",children:V.map((P,N)=>o.jsx("div",{className:"aspect-square",children:P&&o.jsx("button",{onClick:()=>S(P),disabled:!w(P),className:`w-full h-full rounded-lg text-sm font-medium transition-colors 94 ${l===P.toISOString().split("T")[0]?"bg-green-500 text-black":w(P)?"bg-zinc-800 text-white hover:bg-zinc-700":"bg-zinc-900 text-zinc-600 cursor-not-allowed"}`,children:P.getDate()})},N))}),l&&o.jsxs("div",{className:"border-t border-zinc-800 pt-4",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[o.jsx(Xc,{className:"w-4 h-4 text-green-400"}),o.jsx("span",{className:"text-white font-medium",children:k(l)})]}),y?o.jsx("div",{className:"flex justify-center py-8",children:o.jsx("div",{className:"animate-spin w-6 h-6 border-2 border-green-500 border-t-transparent rounded-full"})}):m?.blocked?o.jsx("p",{className:"text-zinc-400 text-center py-6",children:"This date is blocked."}):m?.unavailable?o.jsx("p",{className:"text-zinc-400 text-center py-6",children:"Not available on this day."}):W.length===0?o.jsx("p",{className:"text-zinc-400 text-center py-6",children:"No available slots for this date."}):o.jsx("div",{className:"grid grid-cols-3 gap-2",children:W.map((P,N)=>o.jsxs("button",{onClick:()=>_(P),disabled:!P.available,className:`p-3 rounded-lg text-sm font-medium transition-colors flex items-center justify-center gap-1 95 ${d?.startTime===P.startTime&&d?.date===P.date?"bg-green-500 text-black":P.available?"bg-zinc-800 text-white hover:bg-zinc-700":"bg-zinc-900 text-zinc-600 cursor-not-allowed line-through"}`,children:[o.jsx(uo,{className:"w-3 h-3"}),I(P.startTime)]},N))})]})]}),o.jsx("div",{className:"p-4 border-t border-zinc-800",children:o.jsx("button",{onClick:L,disabled:!d,className:`w-full py-3 rounded-xl font-semibold transition-colors 96 ${d?"bg-green-500 text-black hover:bg-green-400":"bg-zinc-800 text-zinc-500 cursor-not-allowed"}`,children:d?`Continue with ${I(d.startTime)}`:"Select a time slot"})})]})})}const iZ=()=>{const n=typeof window<"u"&&"Capacitor"in window,e=typeof window<"u"?window.location.protocol:"unknown",t=typeof window<"u"?window.location.hostname:"unknown",s=t.
96includes("replit.dev")||t.includes("repl.co"),r=t.includes("onrender.com")||t.includes("chronicbrandsusa")||t.includes("chronictvfinal");return s||r?"":n&&e==="file:"?"https://chronicbrandsusa.onrender.com":""},i_=iZ(),lo=n=>{if(!n)return"";const e=n.startsWith("/")?n:`/${n}`;return i_?`${i_}${e}`:e},Eh=n=>{if(!n)return"";if(n.startsWith("http"))return n;const e=window.Capacitor,t=typeof window<"u"?window.location.hostname:"",s=t.includes("replit.dev")||t.includes("repl.co"),r=t.includes("onrender.com");return e&&!s&&!r&&n.includes("/api/category/")?`https://chronicbrandsusa.onrender.com${n}`:lo(n)},aZ=(n,e,t)=>{},a_=(n,e,t)=>{},oZ=(n,e,t)=>{e.name},P1=async(n,e={})=>{const t=lo(n),s=Date.now();aZ(t,e.method||"GET");try{if(lZ&&!t.startsWith("/")){const i={url:t,method:e.method||"GET",headers:e.headers||{},data:e.body?JSON.parse(e.body):void 0},a=await EJ.request(i),l=new Response(JSON.stringify(a.data),{status:a.status,statusText:a.status.toString(),headers:new Headers(a.headers)});return a_(t,l,s),l}const r=await fetch(t,{...e,headers:{"Content-Type":"application/json",...e.headers}});return a_(t,r,s),r}catch(r){throw oZ(t,r),r}},lZ=typeof window<"u"&&"Capacitor"in window,cZ=[{icon:yb,title:"Proprietary Shuffle Mix",desc:"Our algorithm rotates every show in the network daily â no two days are ever the same broadcast."},{icon:fF,title:"On-Demand + Live Premiers",desc:"Dedicated premiere time slots alongside a full on-demand library for your audience."},{icon:Jc,title:"Unified Content Library",desc:"Affiliates can link their YouTube and other platforms â everything appears as one seamless library."},{icon:ff,title:"75+ Social Media Pages",desc:"Chronic Brands manages over 75 social media pages actively pushing network content."},{icon:GF,title:"Full In-House Team",desc:"Studio engineers, video editors, logo makers, website & app developers, and Empire distribution all under one roof."},{icon:n4,title:"Live Streaming & PPV",desc:"Direct live streaming and pay-per-view event support rolling out soon.",soon:!0}];function uZ(){const[n,e]=T.useState(null);return o.jsx("div",{className:"px-6 py-5 grid grid-cols-1 sm:grid-cols-2 gap-1",children:cZ.map((t,s)=>o.jsxs("div",{children:[o.jsxs("button",{onClick:()=>e(n===s?null:s),className:"w-full flex items-center gap-3 py-2.5 text-left group",children:[o.jsx("div",{className:"p-2 bg-green-500/10 rounded-lg shrink-0",children:o.jsx(t.icon,{className:"w-4 h-4 text-green-400"})}),o.jsxs("p",{className:"text-sm font-semibold text-white flex-1 flex items-center gap-2",children:[t.title,t.soon&&o.jsx("span",{className:"text-[10px] font-bold text-yellow-400 bg-yellow-400/10 px-1.5 py-0.5 rounded-full",children:"Soon"})]}),o.jsx("svg",{className:`h-4 w-4 text-zinc-500 shrink-0 transition-transform duration-200 ${n===s?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),n===s&&o.jsx("p",{className:"text-xs text-zinc-500 leading-relaxed pb-2 pl-11",children:t.desc})]},t.title))})}function o_({defaultTab:n="shop"}){const{cart:e,user:t,addToCart:s}=ty(),[,r]=Xl(),[i,a]=T.useState(null),[l,c]=T.useState(null),[d,h]=T.useState(!1),[p,m]=T.useState(!1),[y,x]=T.useState(null),[w,S]=T.useState(null),[_,L]=T.useState(null),[R,M]=T.useState(n),[V,W]=T.useState("signin"),[I,k]=T.useState(""),[P,N]=T.useState(""),[F,z]=T.useState(""),[U,fe]=T.useState(!1),[oe,X]=T.useState({}),[Q,G]=T.useState(""),[Y,ee]=T.useState(!1),[H,K]=T.useState(""),[pe,Fe]=T.useState(!1),[_e,ze]=T.useState(!1),[Ye,tt]=T.useState(null),[lt,ut]=T.useState({}),{data:cn}=gn({queryKey:["/api/member-count"]});T.useEffect(()=>{const De=new URLSearchParams(window.location.search).get("brand");De&&L(De)},[]),T.useEffect(()=>{const De=new URLSearchParams(window.location.search).get("addItem");if(!De||!t)return;const Le=window.location.pathname;window.history.replaceState({},"",Le),fetch("/api/purchase-items").then(Lt=>Lt.json()).then(Lt=>{const Qe=Lt.find(it=>String(it.id)===String(De)&&it.isActive);Qe&&(s({productId:Qe.id,productName:Qe.name,price:Qe.price,imageUrl:Qe.imageUrl,category:Qe.category,duration:Qe.duration,discountQty:Qe.discountQty,discountPrice:Qe.discountPrice,hasSalesTax:Qe.hasSalesTax,salesTaxPercent:Qe.salesTaxPercent,hasProcessingFee:Qe.hasProcessingFee,processingFee:Qe.processingFee,quantity:1}),S(`${Qe.name} added to your cart!`),setTimeout(()=>S(null),4e3))}).catch(()=>{})},[t]);const{data:ke=[],isLoading:Ue}=gn({queryKey:["/api/purchase-items"]}),{data:rt=[]}=gn({queryKey:["/api/admin/native-brands"]}),{data:Ct}=gn({queryKey:["/api/admin/site-settings"]}),at=T.useMemo(()=>{const J={};return rt.forEach(De=>{J[De.name.toLowerCase()]=De.id}),J},[rt]),ft=T.useMemo(()=>{const J={};return rt.forEach(De=>{J[De.id]=De.name}),J},[rt]),Nt=T.useMemo(()=>{let J=ke.filter(De=>De.isActive!==!1);if(_){const De=at[_.toLowerCase()];De?J=J.filter(Le=>Le.brandId===De):J=J.filter(Le=>Le.brandId?ft[Le.brandId]?.toLowerCase()===_.toLowerCase():!1)}return _||(J=R==="network"?J.filter(De=>De.category==="network"):J.filter(De=>De.category!=="network")),J},[ke,_,at,ft,R]),At=()=>{L(null),window.history.pushState({},"","/shop")},ot=J=>oe[J]||1,Yt=(J,De)=>{X(Le=>{const Lt=Le[J]||1,Qe=Math.max(1,Math.min(99,Lt+De));return{...Le,[J]:Qe}}
96)},zt=async J=>{if(!t){m(!0);return}if(J.category==="service"&&J.duration)a(J),h(!0);else if(J.inventoryVariations&&J.inventoryVariations.length>0||J.variations&&J.variations.length>0)tt(J),ut({});else{x(J.id);const De=ot(J.id);await s({productId:J.id,productName:J.name,price:J.price,imageUrl:J.imageUrl,category:J.category,discountQty:J.discountQty,discountPrice:J.discountPrice,hasSalesTax:J.hasSalesTax,salesTaxPercent:J.salesTaxPercent,hasProcessingFee:J.hasProcessingFee,processingFee:J.processingFee,quantity:De}),x(null),S(J.name),X(Le=>({...Le,[J.id]:1})),setTimeout(()=>S(null),2e3)}},wn=async()=>{if(!Ye)return;const J=Ye;if(!(J.inventoryVariations&&J.inventoryVariations.length>0?J.inventoryVariations.map(it=>it.name):(J.variations||[]).map(it=>it.name)).every(it=>lt[it]))return;const Lt=Object.entries(lt).map(([it,Cn])=>`${it}: ${Cn}`).join(", ");tt(null),x(J.id);const Qe=ot(J.id);await s({productId:`${J.id}__${Object.values(lt).join("_")}`,productName:`${J.name} (${Lt})`,price:J.price,imageUrl:J.imageUrl,category:J.category,discountQty:J.discountQty,discountPrice:J.discountPrice,hasSalesTax:J.hasSalesTax,salesTaxPercent:J.salesTaxPercent,hasProcessingFee:J.hasProcessingFee,processingFee:J.processingFee,quantity:Qe,selectedVariations:lt}),x(null),S(J.name),X(it=>({...it,[J.id]:1})),setTimeout(()=>S(null),2e3)},Dt=async J=>{!i||!t||(h(!1),x(i.id),await s({productId:i.id,productName:i.name,price:i.price,imageUrl:i.imageUrl,category:i.category,duration:i.duration,scheduledDate:J.date,scheduledStartTime:J.startTime,scheduledEndTime:J.endTime,hasSalesTax:i.hasSalesTax,salesTaxPercent:i.salesTaxPercent,hasProcessingFee:i.hasProcessingFee,processingFee:i.processingFee}),x(null),S(i.name),a(null),setTimeout(()=>S(null),2e3))},Ee=async()=>{if(Q.trim()){ee(!0),K(""),Fe(!1);try{const De=await(await fetch(lo("/api/promo-codes/validate"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:Q.trim()})})).json();De.valid?(Fe(!0),K("Promo code valid! First month free.")):K(De.message||"Invalid promo code")}catch{K("Failed to validate code")}finally{ee(!1)}}},He=async()=>{if(!t){m(!0);return}ze(!0);const J=Ct?.premierMembershipPrice||10,De=Ct?.premierMembershipTitle||"Premier Membership";await s({productId:"premier-membership",productName:De,price:pe?0:J,category:"membership",quantity:1,isPremierMembership:!0,promoCodeApplied:pe?Q:void 0,originalPrice:pe?J:void 0}),ze(!1),S(De),G(""),Fe(!1),K(""),setTimeout(()=>S(null),2e3)},le=e.items.reduce((J,De)=>J+De.quantity,0),ne=Ct?.premierMembershipEnabled!==!1&&!_;return o.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-black via-zinc-900 to-black",children:[o.jsxs("div",{className:"max-w-7xl mx-auto px-4 py-16",children:[o.jsxs("div",{className:"flex items-center justify-between mb-8",children:[o.jsxs("div",{children:[o.jsx("h1",{className:"text-3xl md:text-4xl font-bold text-white",children:_?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-green-500",children:_})," Shop"]}):o.jsxs(o.Fragment,{children:["Shop & ",o.jsx("span",{className:"text-green-500",children:"Services"})]})}),o.jsx("p",{className:"text-zinc-400 mt-2",children:_?`Browse ${_} merchandise and products.`:"Browse our products and services."})]}),o.jsx(Et,{href:"/cart",children:o.jsxs("button",{className:"relative flex items-center gap-2 px-4 py-2 bg-green-600 hover:bg-green-700 text-white rounded-lg font-semibold transition-colors",children:[o.jsx(Fl,{className:"w-5 h-5"}),o.jsx("span",{className:"hidden sm:inline",children:"Cart"}),le>0&&o.jsx("span",{className:"absolute -top-2 -right-2 w-5 h-5 bg-white text-green-600 rounded-full text-xs font-bold flex items-center justify-center",children:le})]})})]}),_&&o.jsx("div",{className:"mb-8 flex justify-center",children:o.jsxs("button",{onClick:At,className:"inline-flex items-center gap-2 px-4 py-2 bg-zinc-800 hover:bg-zinc-700 border border-zinc-700 rounded-full text-sm text-white transition-colors",children:[o.jsx(vF,{className:"w-4 h-4"}),"Showing: ",_,o.jsx(Mr,{className:"w-4 h-4 ml-1"})]})}),!_&&o.jsxs("div",{className:"flex gap-2 border-b border-zinc-800 mb
96-8",children:[o.jsx("button",{onClick:()=>{M("shop"),r("/shop")},className:`px-5 py-2.5 text-sm font-medium border-b-2 transition-colors -mb-px ${R==="shop"?"border-green-500 text-green-400":"border-transparent text-zinc-400 hover:text-white"}`,children:"Shop & Services"}),o.jsxs("button",{onClick:()=>{M("network"),r("/ChronicTV-Network-Shop")},className:`px-5 py-2.5 text-sm font-medium border-b-2 transition-colors -mb-px flex items-center gap-2 ${R==="network"?"border-green-500 text-green-400":"border-transparent text-zinc-400 hover:text-white"}`,children:[o.jsx("span",{className:"text-base leading-none",children:"ðº"}),"Chronic TV Network"]})]}),w&&o.jsxs("div",{className:"fixed top-24 left-1/2 -translate-x-1/2 z-50 bg-green-600 text-white px-6 py-3 rounded-lg shadow-lg flex items-center gap-2 animate-fade-in",children:[o.jsx(_a,{className:"w-5 h-5"}),w," added to cart!"]}),ne&&o.jsxs("div",{className:"mb-10 relative overflow-hidden rounded-2xl border-2 border-green-500 bg-gradient-to-br from-green-900/30 via-zinc-900 to-green-900/20",children:[o.jsx("div",{className:"absolute top-0 right-0 w-64 h-64 bg-green-500/10 rounded-full blur-3xl -mr-32 -mt-32"}),o.jsx("div",{className:"absolute bottom-0 left-0 w-48 h-48 bg-green-500/10 rounded-full blur-3xl -ml-24 -mb-24"}),o.jsxs("div",{className:"relative p-6 md:p-8",children:[o.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[o.jsx("div",{className:"p-3 bg-green-500/20 rounded-xl",children:o.jsx(mF,{className:"w-8 h-8 text-green-400"})}),o.jsxs("div",{children:[o.jsx("span",{className:"text-xs uppercase tracking-wider text-green-400 font-semibold",children:"Featured"}),o.jsx("h2",{className:"text-2xl md:text-3xl font-bold text-white",children:Ct?.premierMembershipTitle||"Premier Membership"})]})]}),o.jsx("p",{className:"text-zinc-300 text-lg mb-6 max-w-2xl",children:Ct?.premierMembershipDescription||"Get exclusive access to all content, partner discounts, and premium features!"}),o.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-end gap-6",children:[o.jsxs("div",{className:"flex-1",children:[o.jsx("div",{className:"flex items-baseline gap-2 mb-4",children:pe?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-4xl font-bold text-green-400",children:"$0"}),o.jsxs("span",{className:"text-xl text-zinc-500 line-through",children:["$",Ct?.premierMembershipPrice||10]}),o.jsx("span",{className:"text-green-400 text-sm",children:"First month FREE!"})]}):o.jsxs(o.Fragment,{children:[o.jsxs("span",{className:"text-4xl font-bold text-green-400",children:["$",Ct?.premierMembershipPrice||10]}),o.jsx("span",{className:"text-zinc-400",children:"/month"})]})}),o.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[o.jsxs("div",{className:"flex-1 relative",children:[o.jsx(t4,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-zinc-500"}),o.jsx("input",{type:"text",value:Q,onChange:J=>{G(J.target.value.toUpperCase()),K(""),Fe(!1)},placeholder:"Have a promo code?",className:"w-full pl-10 pr-4 py-3 bg-zinc-800/80 border border-zinc-700 rounded-xl text-white placeholder-zinc-500 focus:outline-none focus:border-green-500 transition-colors"})]}),o.jsxs("button",{onClick:Ee,disabled:!Q.trim()||Y,className:"px-5 py-3 bg-zinc-700 hover:bg-zinc-600 disabled:bg-zinc-800 disabled:text-zinc-500 text-white rounded-xl font-medium transition-colors flex items-center justify-center gap-2",children:[Y?o.jsx(Nn,{className:"w-4 h-4 animate-spin"}):o.jsx(ox,{className:"w-4 h-4"}),"Apply"]})]}),H&&o.jsx("p",{className:`mt-2 text-sm ${pe?"text-green-400":"text-red-400"}`,children:H})]}),o.jsx("button",{onClick:He,disabled:_e,className:"px-8 py-4 bg-green-600 hover:bg-green-500 disabled:bg-green-800 text-white rounded-xl font-bold text-lg transition-all duration-300 shadow-lg shadow-green-500/20 hover:shadow-green-500/40 flex items-center justify-center gap-3",children:_e?o.jsxs(o.Fragment,{children:[o.jsx(Nn,{className:"w-5 h-5 animate-spin"}),"Adding..."]}):o.jsxs(o.Fragment,{children:[o.jsx(Fl,{className:"w-5 h-5"}),"Add to Cart"]})})]}),o.jsx("p",{className:"mt-4 text-sm text-zinc-500",children:"Credit/Debit card payment only. Secure checkout powered by Authorize.net."})]})]}),Ue?o.jsx("div",{className:"flex justify-center py-20",children:o.jsx("div",{className:"animate-spin w-8 h-8 border-4 border-green-500 border-t-transparent roun
96ded-full"})}):Nt.length===0?o.jsxs("div",{className:"text-center py-20",children:[o.jsx(X0,{className:"w-16 h-16 text-zinc-600 mx-auto mb-4"}),o.jsx("p",{className:"text-zinc-400 text-lg mb-4",children:_?`No products found for "${_}".`:"No products available at this time."}),_&&o.jsx("button",{onClick:At,className:"inline-flex items-center gap-2 px-4 py-2 bg-green-600 hover:bg-green-700 text-white rounded-lg transition-colors",children:"View All Products"})]}):R==="network"&&!_?(()=>{const J=Nt.filter(Le=>Le.isSetupFee),De=Nt.filter(Le=>!Le.isSetupFee);return o.jsxs("div",{className:"space-y-10",children:[o.jsxs("div",{className:"flex items-center gap-4 p-5 bg-zinc-900/60 border border-zinc-800 rounded-2xl",children:[o.jsx("div",{className:"p-3 bg-green-500/15 rounded-xl shrink-0",children:o.jsx(oo,{className:"w-8 h-8 text-green-400"})}),o.jsxs("div",{children:[o.jsx("h2",{className:"text-xl font-bold text-white mb-1",children:"Your Own Channel on Chronic TV"}),o.jsx("p",{className:"text-zinc-400 text-sm leading-relaxed",children:"Get a fully branded, dedicated show on the Chronic TV Network with daily playlist rotation, dedicated storage, and monthly hosting. Start with a one-time setup bundle, then keep your channel live with a low monthly rate."})]})]}),o.jsxs("div",{className:"flex flex-col sm:flex-row items-center gap-6 p-6 bg-green-500/5 border border-green-500/20 rounded-2xl",children:[o.jsx("div",{className:"flex-shrink-0 flex items-center justify-center w-16 h-16 rounded-full bg-green-500/10 border border-green-500/20",children:o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",stroke:"#4ade80",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"}),o.jsx("path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}),o.jsx("line",{x1:"12",x2:"12",y1:"19",y2:"22"})]})}),o.jsxs("div",{className:"flex-1 text-center sm:text-left",children:[o.jsx("div",{className:"inline-flex items-center gap-1.5 bg-green-500/10 border border-green-500/25 text-green-400 px-2.5 py-0.5 rounded-full text-xs font-semibold uppercase tracking-wider mb-2",children:"ChronicTV Network"}),o.jsx("h3",{className:"text-base font-bold text-white mb-1",children:"Want to Be on the Show?"}),o.jsx("p",{className:"text-zinc-400 text-sm leading-relaxed",children:"Members can apply to be a guest on any ChronicTV channel. Pick your show, share your socials, and the creator will reach out if you're selected."})]}),o.jsx("button",{onClick:()=>r("/guest-signup"),className:"shrink-0 inline-flex items-center gap-2 bg-green-400 hover:bg-green-300 text-black px-5 py-2.5 rounded-full font-bold text-sm transition-colors cursor-pointer",children:"Apply to Be a Guest"})]}),o.jsxs("div",{className:"rounded-2xl border border-zinc-800 bg-zinc-900/40 overflow-hidden",children:[o.jsxs("div",{className:"px-6 py-5 border-b border-zinc-800",children:[o.jsx("h3",{className:"text-lg font-bold text-white mb-1",children:"Why Chronic TV?"}),o.jsxs("p",{className:"text-zinc-400 text-sm",children:["A full distribution network built for culture creators â not just a streaming app.",cn&&cn.count>0&&o.jsxs("span",{className:"ml-1 text-[#4ade80] font-semibold",children:[cn.count.toLocaleString()," members and growing."]})]})]}),o.jsxs("div",{className:"px-6 py-5 border-b border-zinc-800",children:[o.jsx("p",{className:"text-xs uppercase tracking-widest text-zinc-500 font-semibold mb-4",children:"Available On"}),o.jsxs("div",{className:"flex flex-wrap gap-3",children:[[{label:"Google Play",sub:"Android & Smart TVs",icon:a4,bg:"#0f9d58",url:"https://play.google.com/store/apps/details?id=com.chronictv2.app&pcampaignid=web_share"},{label:"Apple",sub:"iPhone & Apple TV",icon:o4,bg:"#1c1c1e",url:"https://apps.apple.com/us/app/chronic-tv/id6757710156"},{label:"Roku",sub:"Roku Devices",icon:i4,bg:"#6f1ab1",url:"https://channelstore.roku.com/details/484ddc36cb4236b7a260cf6dd37459bb:557787d977c35a2d06a4cb75856abd21/chronic-tv"},{label:"Xbox",sub:"Microsoft Store",icon:hf,bg:"#107c10",url:"https://apps.microsoft.com/detail/9p3w2zd0kb50?hl=en-u
96s&gl=us&ocid=pdpshare"}].map(Le=>o.jsxs("a",{href:Le.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2.5 px-4 py-2.5 rounded-xl border border-zinc-700 hover:border-green-500/50 transition-all bg-zinc-800/60 hover:bg-zinc-800 group",children:[o.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center shrink-0",style:{background:Le.bg},children:o.jsx(Le.icon,{size:14,color:"#fff"})}),o.jsxs("div",{children:[o.jsx("p",{className:"text-white text-xs font-semibold leading-tight group-hover:text-green-400 transition-colors",children:Le.label}),o.jsx("p",{className:"text-zinc-500 text-[10px] leading-tight",children:Le.sub})]})]},Le.label)),["Amazon Fire","PlayStation"].map(Le=>o.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-2.5 rounded-xl border border-zinc-800 bg-zinc-900/40 opacity-60",children:[o.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center shrink-0 bg-zinc-700",children:o.jsx(oo,{size:12,color:"#888"})}),o.jsxs("div",{children:[o.jsx("p",{className:"text-zinc-400 text-xs font-semibold leading-tight",children:Le}),o.jsx("p",{className:"text-zinc-600 text-[10px] leading-tight",children:"Coming Soon"})]})]},Le))]})]}),o.jsx(uZ,{})]}),J.length>0&&o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm uppercase tracking-widest text-zinc-500 font-semibold mb-4",children:"Startup Bundles"}),o.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:J.map((Le,Lt)=>{const Qe=Le.description.split("·").map(Cn=>Cn.trim()).filter(Boolean),it=Lt===1;return o.jsxs("div",{className:`relative rounded-2xl border-2 overflow-hidden transition-all duration-300 ${it?"border-green-500 bg-gradient-to-b from-green-900/20 to-zinc-900":"border-zinc-700 bg-zinc-900/80 hover:border-zinc-500"}`,children:[it&&o.jsx("div",{className:"absolute top-0 left-0 right-0 flex justify-center",children:o.jsxs("span",{className:"bg-green-500 text-black text-xs font-bold px-4 py-1 rounded-b-lg flex items-center gap-1",children:[o.jsx(H7,{className:"w-3 h-3"})," MOST POPULAR"]})}),o.jsxs("div",{className:`p-6 ${it?"pt-9":""}`,children:[o.jsx("h3",{className:"text-xl font-bold text-white mb-1",children:Le.name}),o.jsxs("div",{className:"mt-4 mb-1",children:[o.jsxs("div",{className:"flex items-baseline gap-2 flex-wrap",children:[o.jsxs("span",{className:"text-lg font-medium text-zinc-500 line-through",children:["$",(Number(Le.price)*2).toFixed(0)]}),o.jsx("span",{className:"text-xs font-bold text-red-400 bg-red-400/10 px-2 py-0.5 rounded-full",children:"50% OFF"})]}),o.jsxs("div",{className:"flex items-baseline gap-2 mt-1",children:[o.jsxs("span",{className:"text-4xl font-extrabold text-green-400",children:["$",Number(Le.price).toFixed(0)]}),o.jsx("span",{className:"text-zinc-400 text-sm",children:"one-time setup"})]}),Le.recurringPrice&&o.jsxs("p",{className:"text-zinc-300 text-sm mt-1",children:["then ",o.jsxs("span",{className:"text-white font-semibold",children:["$",Number(Le.recurringPrice).toFixed(0),"/month"]})," to keep your channel live"]})]}),o.jsx("ul",{className:"mt-5 space-y-2.5 mb-6",children:Qe.map((Cn,Mn)=>o.jsxs("li",{className:"flex items-start gap-2.5 text-sm text-zinc-300",children:[o.jsx(_a,{className:"w-4 h-4 text-green-400 shrink-0 mt-0.5"}),Cn]},Mn))}),o.jsxs("button",{onClick:()=>zt(Le),disabled:y===Le.id,className:`w-full py-3 rounded-xl font-bold text-sm transition-all flex items-center justify-center gap-2 ${it?"bg-green-500 hover:bg-green-400 text-black shadow-lg shadow-green-500/30":"bg-zinc-700 hover:bg-zinc-600 text-white"}`,children:[y===Le.id?o.jsx(Nn,{className:"w-4 h-4 animate-spin"}):o.jsx(q7,{className:"w-4 h-4"}),"Get Started"]}),o.jsx("p",{className:"text-xs text-zinc-600 mt-3 text-center",children:"* Scheduled upon request after purchase"})]})]},Le.id)})})]}),De.length>0&&o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm uppercase tracking-widest text-zinc-500 font-semibold mb-4",children:"Add-Ons"}),o.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:De.map(Le=>o.jsxs("div",{className:"flex items-center justify-between gap-4 p-5 bg-zinc-900/80 border border-zinc-800 hover:border-zinc-600 rounded-2xl transition-all",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"p-2 bg-zinc-800 rounded-lg",children:Le.name.toLowerCase().includes("engineer")?o.jsx(U7,{className:"w-5 h-5 text-zinc-300"}):o.jsx(V7,{className:"w-5 h-5 text-zinc-300"})}),o.jsxs("div",{children:[o.jsx("p",{className:"font-semibold text-white text-sm",children:Le.name}),o.jsx("p",{className:"text-zinc-500 text-xs mt-0.5",children:Le.name.toLowerCase().includes("premier")&&Le.name.toLowerCase().includes("engineer")?"One-time per-edit service. Priority handling, advanced formatting, multi-format support, and dedicated upload co
96ordination.":Le.name.toLowerCase().includes("engineer")?"One-time per-edit service. Includes video processing, formatting, and upload coordination for your channel.":Le.description.split("·")[0].trim()})]})]}),o.jsxs("div",{className:"text-right shrink-0",children:[o.jsxs("p",{className:"text-xl font-bold text-green-400",children:["$",Number(Le.price).toFixed(0),o.jsx("span",{className:"text-sm font-normal text-zinc-400",children:Le.name.toLowerCase().includes("engineer")?"/per edit":"/mo"})]}),o.jsxs("button",{onClick:()=>zt(Le),disabled:y===Le.id,className:"mt-2 px-4 py-1.5 bg-zinc-700 hover:bg-zinc-600 text-white text-xs font-semibold rounded-lg transition-colors flex items-center gap-1",children:[y===Le.id?o.jsx(Nn,{className:"w-3 h-3 animate-spin"}):o.jsx(b0,{className:"w-3 h-3"}),"Add"]})]})]},Le.id))})]})]})})():o.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:Nt.map(J=>o.jsxs("div",{className:"bg-zinc-900/80 border border-zinc-800 rounded-2xl overflow-hidden hover:border-green-500/50 transition-all duration-300 group",children:[J.imageUrl&&o.jsx("div",{className:"aspect-video bg-zinc-800 overflow-hidden cursor-pointer",onClick:()=>c(J),children:o.jsx("img",{src:J.imageUrl,alt:J.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"})}),o.jsxs("div",{className:"p-6",children:[o.jsxs("div",{className:"flex items-start justify-between mb-3",children:[o.jsx("h3",{className:"text-xl font-semibold text-white group-hover:text-green-400 transition-colors cursor-pointer hover:text-green-400",onClick:()=>c(J),children:J.name}),o.jsx("span",{className:`text-xs uppercase tracking-wider px-2 py-1 rounded ${J.category==="service"?"text-blue-400 bg-blue-500/20":"text-purple-400 bg-purple-500/20"}`,children:J.category==="service"?"Service":"Product"})]}),o.jsx("p",{className:"text-zinc-400 text-sm mb-4 line-clamp-3",children:J.description}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsxs("span",{className:"text-2xl font-bold text-green-400",children:["$",Number(J.price).toFixed(2)]}),J.duration&&o.jsxs("div",{className:"flex items-center gap-1 text-zinc-500 text-sm mt-1",children:[o.jsx(uo,{className:"w-4 h-4"}),J.duration>=60?`${Math.floor(J.duration/60)}h ${J.duration%60>0?`${J.duration%60}m`:""}`:`${J.duration} min`]}),J.isSetupFee&&J.recurringPrice&&o.jsxs("div",{className:"text-xs text-zinc-400 mt-1",children:["Setup fee â then $",Number(J.recurringPrice).toFixed(2),"/mo after 30 days"]}),J.category!=="service"&&J.discountQty&&J.discountPrice&&o.jsxs("div",{className:"text-xs text-green-400 mt-1",children:["Buy ",J.discountQty," and get a Gizmo Deal!"]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[J.category!=="service"&&o.jsxs("div",{className:"flex items-center bg-zinc-800 rounded-lg border border-zinc-600",children:[o.jsx("button",{onClick:()=>Yt(J.id,-1),disabled:ot(J.id)<=1,className:"p-2 hover:bg-zinc-700 rounded-l-lg transition-colors disabled:opacity-50",children:o.jsx(RF,{className:"w-4 h-4 text-white"})}),o.jsx("span",{className:"w-10 text-center text-white font-semibold",children:ot(J.id)}),o.jsx("button",{onClick:()=>Yt(J.id,1),className:"p-2 hover:bg-zinc-700 rounded-r-lg transition-colors",children:o.jsx(b0,{className:"w-4 h-4 text-white"})})]}),o.jsxs("button",{onClick:()=>zt(J),disabled:y===J.id,className:"bg-green-500 hover:bg-green-600 disabled:bg-green-700 text-black font-semibold px-4 py-2.5 rounded-lg transition-colors flex items-center gap-2",children:[y===J.id?o.jsx(Nn,{className:"w-4 h-4 animate-spin"}):o.jsx(b0,{className:"w-4 h-4"}),J.category==="service"?"Book":"Add"]})]})]})]})]},J.id))})]}),l&&o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/70 backdrop-blur-sm",onClick:J=>{J.target===J.currentTarget&&c(null)},children:o.jsxs("div",{className:"bg-zinc-900 border border-zinc-700 rounded-2xl w-full max-w-lg max-h-[90vh] overflow-y-auto shadow-2xl",children:[o.jsxs("div",{className:"flex items-start justify-between p-5 border-b border-zinc-800",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("span",{className:`text-xs uppercase tracking-wider px-2 py-1 rounded ${l.category==="service"?"text-blue-400 bg-blue-500/20":l.category==="network"?"text-green-400 bg-green-500/20":"text-purple-400 bg-purple-500/20"}`,children:l.category==="service"?"Service":l.category==="network"?"Chronic TV":"Product"}),o.jsx("h2",{className:"text-lg font-bold text-white",children:l.name})]}),o.jsx("button",{onClick:()=>c(null),className:"p-1.5 rounded-lg hover:bg-zinc-800 text-zinc-400 hover:text-white transition-colors shrink-0",children:o.jsx(Mr,{className:"w-5 h-5"})})]}),l.imageUrl&&o.jsx("div",{className:"aspect-video bg-zinc-800 overflow-hidden",children:o.jsx("img",{src:l.imageUrl,alt:l.name,className:"w-full h-full object-cover"})}),o.jsxs("div",{className:"p-5 space-y-4",children:[o.jsx("div",{children:o.jsx("p",{className:"text-zinc-300 text-sm leading-relaxed whitespace-pre-wrap",children:l.description})}),o.jsxs("div",{className:"bg-zinc-800/60 rounded-xl p-4 space-y-2",children:[o.jsxs("div",{className:"flex items-baseline gap-2",children:[o.jsxs("span",{className:"text-3xl font-bold text-green-400",children:["$",Number(l.price).toFixed(2)]}),l.isSetupFee&&o.jsx("span",{className:"text-sm text-zinc-400",children:"setup fee"})]}),l.isSetupFee&&l.recurringPrice&&o.jsxs("p",{className:"text-sm text-zinc-400",children:["Then ",o.jsxs("span",{className:"text-white font-semibold",children:["$",Number(l.recurringPrice).toFixed(2),"/mo"]})," starting 30 days after purchase"]}),l.duration&&o.jsxs("div",{className:"flex items-center gap-1.5 text-zinc-400 text-sm",children:[o.jsx(uo,{className:"w-4 h-4"}),l.duration>=60?`${Math.floor(l.duration/60)}h ${l.duration%60>0?`${l.duration%60}m`:""}`:`${l.duration} min`]}),l.hasSalesTax&&l.salesTaxPercent&&o.jsxs("p",{className:"text-xs text-zinc-500",children:["+",l.salesTaxPercent,"% sales tax ($",(Number(l.price)*l.salesTaxPercent/100).toFixed(2),")"]}),l.hasProcessingFee&&l.processingFee&&o.jsxs("p",{className:"text-xs text-zinc-500",children:["+$",Number(l.processingFee).toFixed(2)," processing/shipping fee"]}),l.category!=="service"&&l.discountQty&&l.discountPrice&&o.jsxs("p",{className:"text-xs text-green-400",children:["Buy ",l.discountQty," for $",Number(l.discountPrice).toFixed(2)," â Gizmo Deal!"]})]}),o.jsxs("button",{onClick:()=>{c(null),zt(l)},disabled:y===l.id,className:"w-full bg-green-500 hover:bg-green-600 disabled:bg-green-700 text-black font-bold py-3 rounded-xl transition-colors flex items-center justify-center gap-2",children:[y===l.id?o.jsx(Nn,{className:"w-5 h-5 animate-spin"}):o.jsx(Fl,{className:"w-5 h-5"}),l.category==="service"?"Book This Service":"Add to Cart"]})]})]})}),i&&o.jsx(rZ,{isOpen:d,onClose:()=>{h(!1),a(null)},onSlotSelected:Dt,productName:i.name,duration:i.duration}),Ye&&(()=>{const J=Ye.inventoryVariations&&Ye.inventoryVariations.length>0,De=J?Ye.inventoryVariations.map(Qe=>({name:Qe.name,options:Qe.options.map(it=>({label:it.label,stock:it.stock}))})):(Ye.variations||[]).map(Qe=>({name:Qe.name,options:Qe.options.map(it=>({label:it,stock:-1}))})),Le=De.every(Qe=>lt[Qe.name]),Lt=De.some(Qe=>{const it=Qe.options.find(Cn=>Cn.label===lt[Qe.name]);return it&&it.stock===0});return o.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:o.jsxs("div",{className:"bg-zinc-900 border border-zinc-700 rounded-2xl max-w-md w-full p-6",children:[o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsx("h2",{className:"text-lg font-bold text-white",children:"Select Options"}),o.jsx("button",{onClick:()=>tt(null),className:"p-2 hover:bg-zinc-800 rounded-lg transition-colors",children:o.jsx(Mr,{className:"w-5 h-5 text-zinc-400"})})]}),o.jsx("p",{className:"text-zinc-400 text-sm mb-5",children:Ye.name}),o.jsx("div",{className:"space-y-5",children:De.map(Qe=>o.jsxs("div",{children:[o.jsx("p",{className:"text-sm font-medium text-zinc-300 mb-2",children:Qe.name}),o.jsx("div",{className:"flex flex-wrap gap-2",children:Qe.options.map(it=>{const Cn=J&&it.stock===0,Mn=lt[Qe.name]===it.label;return o.jsxs("button",{type:"button",disabled:Cn,onClick:()=>!Cn&&ut(Gn=>({...Gn,[Qe.name]:it.label})),className:`relative px-4 py-2 rounded-lg text-sm border transition-colors ${Cn?"opacity-40 cursor-not-allowed bg-zinc-900 border-zinc-700 text-zinc-500":Mn?"bg-green-600 border-green-600 text-white":"bg-zinc-800 border-zinc-600 text-zinc-300 hover:border-green-500"}`,children:[it.label,Cn&&o.jsx("span",{className:"ml-1.5 text-[10px] text-red-400",children:"Sold Out"}),J&&it.stock>0&&it.stock<=5&&o.jsxs("span",{className:"ml-1.5 text-[10px] text-amber-400",children:[it.stock," left"]})]},it.label)})})]},Qe.name))}),o.jsx("button",{onClick:wn,disabled:!Le||Lt,className:"mt-6 w-full py-3 bg-green-600 hover:bg-green-700 disabled:opacity-40 disabled:cursor-not-allowed text-white font-semibold rounded-xl transition-colors",children:"Add to Cart"})]})})})(),p&&o.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:o.jsxs("div",{className:"bg-zinc-900 border border-zinc-700 rounded-2xl max-w-md w-full p-6",children:[o.jsxs("div",{className:"flex items-center justify-between mb-6",children:[o.jsx("h2",{className:"text-xl font-bold text-white",children:V==="signin"?"Sign In":V==="signup"?"Create Account":"Reset Password"}),o.jsx("button",{onClick:()=>{m(!1),W("signin"),k(""),N(""),z("")},className:"p-2 hover:bg-zinc-800 rounded-lg transition-colors",children:o.jsx(Mr,{className:"w-5 h-5"})})]}),F&&o.jsx("div",{className:"mb-4 p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-red-400 text-sm",children:F}),V==="reset"?o.jsxs("div",{className:"space-y-4",children:[o.jsx("input",{type:"email",placeholder:"Email address",value:I,onChange:J=>k(J.target.value),className:"w-full px-4 py-3 bg-zinc-800 border border-zinc-700 rounded-lg text-white placeholder-zinc-500 focus:outline-none focus:border-green-500"}),o.jsx("button",{onClick:async()=>{fe(!0),z("");try{await Pf(I),z("Password reset email sent! Check your inbox."),setTimeout(()=>W("signin"),3e3)}catch(J){z(J.message||"Failed to send reset email")}fe(!1)},disabled:U,className:"w-full py-3 bg-green-500 hover:bg-green-600 disabled:bg-green-700 text-black font-semibold rounded-lg transition-colors",children:U?"Sending...":"Send Reset Email"}),o.jsx("button",{onClick:()=>W("signin"),className:"w-full text-zinc-400 hover:text-white text-sm",children:"Back to Sign In"})]}):o.jsxs("div",{className:"space-y-4",children:[o.jsx("input",{type:"email",placeholder:"Email address",value:I,onChange:J=>k(J.target.value),className:"w-full px-4 py-3 bg-zinc-800 border border-zinc-700 rounded-lg text-white placeholder-zinc-500 focus:outline-none focus:border-green-500"}),o.jsx("input",{type:"password",placeholder:"Password",value:P,onChange:J=>N(J.target.value),className:"w-full px-4 py-3 bg-zinc-800 border border-zinc-700 rounded-lg text-white placeholder-zinc-500 focus:outline-none focus:border-green-500"}),o.jsx("button",{onClick:async()=>{fe(!0),z("");try{V==="signup"?await kf(I,P,"","",""):await Rf(I,P),m(!1),k(""),N("")}catch(J){z(J.message||"Authentication failed")}fe(!1)},disabled:U,className:"w-full py-3 bg-green-500 hover:bg-green-600 disabled:bg-green-700 text-black font-semibold rounded-lg transition-colors",children:U?"Loa
96ding...":V==="signup"?"Create Account":"Sign In"}),V==="signin"&&o.jsx("button",{onClick:()=>W("reset"),className:"w-full text-zinc-400 hover:text-white text-sm",children:"Forgot password?"}),o.jsxs("div",{className:"flex items-center gap-3 my-4",children:[o.jsx("div",{className:"flex-1 h-px bg-zinc-700"}),o.jsx("span",{className:"text-zinc-500 text-sm",children:"or"}),o.jsx("div",{className:"flex-1 h-px bg-zinc-700"})]}),o.jsxs("button",{onClick:async()=>{try{await Vm(),m(!1)}catch{}},className:"w-full flex items-center justify-center gap-3 px-4 py-3 bg-white hover:bg-gray-100 text-gray-800 rounded-lg font-medium transition-colors",children:[o.jsxs("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",children:[o.jsx("path",{fill:"#4285F4",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"}),o.jsx("path",{fill:"#34A853",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),o.jsx("path",{fill:"#FBBC05",d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"}),o.jsx("path",{fill:"#EA4335",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})]}),"Continue with Google"]}),o.jsxs("button",{onClick:async()=>{try{await Zx(),m(!1)}catch{}},className:"w-full flex items-center justify-center gap-3 px-4 py-3 bg-black border border-zinc-600 hover:bg-zinc-800 text-white rounded-lg font-medium transition-colors",children:[o.jsx("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{d:"M17.05 20.28c-.98.95-2.05.8-3.08.35-1.09-.46-2.09-.48-3.24 0-1.44.62-2.2.44-3.06-.35C2.79 15.25 3.51 7.59 9.05 7.31c1.35.07 2.29.74 3.08.8 1.18-.24 2.31-.93 3.57-.84 1.51.12 2.65.72 3.4 1.8-3.12 1.87-2.38 5.98.48 7.13-.57 1.5-1.31 2.99-2.54 4.09l.01-.01zM12.03 7.25c-.15-2.23 1.66-4.07 3.74-4.25.29 2.58-2.34 4.5-3.74 4.25z"})}),"Continue with Apple"]}),o.jsx("div",{className:"text-center pt-2",children:V==="signin"?o.jsxs("p",{className:"text-zinc-400 text-sm",children:["Don't have an account?"," ",o.jsx("button",{onClick:()=>W("signup"),className:"text-green-500 hover:text-green-400 font-medium",children:"Sign up"})]}):o.jsxs("p",{className:"text-zinc-400 text-sm",children:["Already have an account?"," ",o.jsx("button",{onClick:()=>W("signin"),className:"text-green-500 hover:text-green-400 font-medium",children:"Sign in"})]})})]})]})})]})}async function l_(n,e){const t=n.filter(s=>s.promoCodeApplied);for(const s of t)try{await fetch("/api/promo-codes/redeem",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},body:JSON.stringify({code:s.promoCodeApplied})})}catch{}}async function dZ(n){const t=await(await fetch("/api/payments/config")).json();if(!t.configured)throw new Error("Payment processing is not configured yet. Please contact support.");const s=t.environment==="production"?"https://js.authorize.net/v1/Accept.js":"https://jstest.authorize.net/v1/Accept.js";if(window.Accept||await new Promise((i,a)=>{const l=document.createElement("script");l.src=s,l.onload=()=>i(),l.onerror=()=>a(new Error("Failed to load payment system")),document.head.appendChild(l)}),typeof window.Accept?.dispatchData!="function")throw new Error("Payment system failed to initialize. Please refresh and try again.");const r=await new Promise(i=>{window.Accept.dispatchData({authData:{clientKey:t.publicClientKey,apiLoginID:t.apiLoginId},cardData:{cardNumber:n.cardNumber,month:n.expMonth,year:n.expYear,cardCode:n.cvv}},i)});if(r.messages?.resultCode==="Error")throw new Error(r.messages.message[0]?.text||"Card validation failed");return r.opaqueData}function hZ(){const{cart:n,isLoading:e,user:t,removeFromCart:s,clearCart:r}=ty(),[i,a]=T.useState("cart"),[l,c]=T.useState(null),[d,h]=T.useState(null),[p,m]=T.useState(""),[y,x]=T.useState(null),[w,S]=T.useState(null),[_,L]=T.useState(!1),[R,M]=T.useState(null),V=T.useRef(null),W=T.useRef(null),[I,k]=T.useState({fullName:t?.displayName||"",street:"",city:"",state:"",zipCode:"",phone:""}),[P,N]=T.useState(!1),[F,z]=T.useState(!0),[U,fe]=T.useState(!0),[oe,X]=T.useState({street:"",city:"",state:"",zipCode:""}),[Q,G]=T.useState({cardNumber:"",expMonth:"",expYear:"",cvv:""}),[Y,ee]=T.useState(!1),[H,K]=T.useState(null),pe=n.items.some(ke=>ke.category==="product"),_e=(()=>{let ke=0,Ue=0,rt=0;
96return n.items.forEach(Ct=>{const ft=Ct.discountQty&&Ct.discountPrice&&Ct.quantity===Ct.discountQty?Ct.discountPrice??Ct.price*Ct.quantity:Ct.price*Ct.quantity;ke+=ft,Ct.hasSalesTax&&Ct.salesTaxPercent&&(Ue+=ft*Ct.salesTaxPercent/100),Ct.hasProcessingFee&&Ct.processingFee&&(rt+=Ct.processingFee)}),{subtotal:ke,totalTax:Ue,totalProcessingFees:rt,grandTotal:ke+Ue+rt}})();T.useEffect(()=>{(async()=>{if(t&&i==="shipping"&&!P){const Ue=await Bm(t.uid);Ue&&k(rt=>({fullName:rt.fullName||t.displayName||"",street:Ue.street||rt.street,city:Ue.city||rt.city,state:Ue.state||rt.state,zipCode:Ue.zipCode||rt.zipCode,phone:rt.phone})),N(!0)}})()},[t,i,P]);const{data:ze=[]}=gn({queryKey:["/api/payment-methods"]}),Ye=ze.filter(ke=>ke.isActive),tt=(ke,Ue,rt)=>{const Ct=new Date(ke+"T00:00:00"),at=ft=>{const[Nt,At]=ft.split(":").map(Number),ot=Nt>=12?"PM":"AM";return`${Nt%12||12}:${String(At).padStart(2,"0")} ${ot}`};return`${Ct.toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric"})} at ${at(Ue)} - ${at(rt)}`},lt=ke=>{const Ue=ke.target.files?.[0];if(Ue){x(Ue);const rt=new FileReader;rt.onloadend=()=>{S(rt.result)}
96,rt.readAsDataURL(Ue)}},ut=ke=>{if(h(ke),!ke.paymentLink)a("cardEntry");else{let Ue=ke.paymentLink;if(!Ue.startsWith("http")){const rt=ke.provider.toLowerCase(),Ct=Ue.replace(/^[@$]/,"");rt==="cashapp"||rt==="cash_app"?Ue=`https://cash.app/$${Ct}`:rt==="venmo"?Ue=`https://venmo.com/u/${Ct}`:rt==="chime"?Ue=`https://chime.com/pay/${Ct}`:Ue=`https://${Ue}`}window.open(Ue,"_blank"),a("verification")}},cn=async()=>{if(!t||!p||!y||!d){M({type:"error",text:"Please provide transaction ID and receipt screenshot"});return}L(!0),M(null);try{const ke=await t.getIdToken(),Ue=new FormData;Ue.append("receipt",y),Ue.append("transactionId",p),Ue.append("userId",t.uid),Ue.append("customerEmail",t.email||""),Ue.append("customerName",t.displayName||""),Ue.append("paymentMethod",d.displayName||d.provider),Ue.append("items",JSON.stringify(n.items)),Ue.append("total",_e.grandTotal.toString()),Ue.append("subtotal",_e.subtotal.toString()),Ue.append("taxAmount",_e.totalTax.toString()),Ue.append("processingFees",_e.totalProcessingFees.toString()),pe&&Ue.append("shippingAddress",JSON.stringify(I));const rt=await fetch("/api/orders/submit-with-proof",{method:"POST",headers:{Authorization:`Bearer ${ke}`},body:Ue});if(rt.ok)M({type:"success",text:"Order submitted! Check your email for confirmation."}),await l_(n.items,ke),pe&&I.street&&await R1(t.uid,{street:I.street,city:I.city,state:I.state,zipCode:I.zipCode,country:"United States"}),await r(),setTimeout(()=>{window.location.href="/orders"},2e3);else{const Ct=await rt.json();M({type:"error",text:Ct.message||"Failed to submit order"})}}catch{M({type:"error",text:"Failed to submit order. Please try again."})}finally{L(!1)}};return t?e?o.jsx("div",{className:"min-h-screen bg-gradient-to-b from-black via-zinc-900 to-black flex items-center justify-center",children:o.jsx(Nn,{className:"w-8 h-8 animate-spin text-green-500"})}):o.jsx("div",{className:"min-h-screen bg-gradient-to-b from-black via-zinc-900 to-black",children:o.jsxs("div",{className:"max-w-4xl mx-auto px-4 py-16",children:[o.jsxs("h1",{className:"text-3xl md:text-4xl font-bold text-white mb-8 flex items-center gap-3",children:[o.jsx(Fl,{className:"w-8 h-8 text-green-500"}),i==="cart"&&"Your Cart",i==="shipping"&&"Shipping Address",i==="payment"&&"Select Payment Method",i==="cardEntry"&&"Enter Card Details",i==="verification"&&"Verify Payment",i==="confirmation"&&"Order Confirmed!"]}),n.items.length===0&&i==="cart"?o.jsxs("div",{className:"text-center py-20 bg-zinc-800/30 rounded-2xl border border-zinc-700",children:[o.jsx(Fl,{className:"w-16 h-16 text-zinc-600 mx-auto mb-4"}),o.jsx("h2",{className:"text-xl font-semibold text-white mb-2",children:"Your cart is empty"}),o.jsx("p",{className:"text-zinc-400 mb-6",children:"Browse our shop to add products and services."}),o.jsx(Et,{href:"/shop",children:o.jsx("button",{className:"px-6 py-3 bg-green-600 hover:bg-green-700 text-white rounded-lg font-semibold transition-colors",children:"Browse Shop"})})]}):o.jsxs("div",{className:"space-y-6",children:[i==="cart"&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"space-y-4",children:n.items.map((ke,Ue)=>{const rt=ke.discountQty&&ke.discountPrice&&ke.quantity===ke.discountQty,Ct=ke.price*ke.quantity,at=rt?ke.discountPrice??Ct:Ct,ft=Ct-at;return o.jsxs("div",{className:"bg-zinc-800/50 rounded-xl border border-zinc-700 p-4 flex items-start gap-4",children:[ke.imageUrl&&o.jsx("img",{src:ke.imageUrl,alt:ke.productName,className:"w-20 h-20 object-cover rounded-lg"}),o.jsxs("div",{className:"flex-1",children:[o.jsx("h3",{className:"text-white font-semibold",children:ke.productName}),ke.scheduledDate&&ke.scheduledStartTime&&ke.scheduledEndTime&&o.jsxs("p",{className:"text-green-400 text-sm mt-1 flex items-center gap-1",children:[o.jsx(Xc,{className:"w-4 h-4"}),tt(ke.scheduledDate,ke.scheduledStartTime,ke.scheduledEndTime)]}),ke.duration&&o.jsxs("p",{className:"text-zinc-400 text-sm flex items-center gap-1",children:[o.jsx(uo,{className:"w-4 h-4"}),ke.duration," minutes"]}),o.jsx("div",{className:"mt-2",children:rt?o.jsxs("div",{children:[o.jsxs("p",{className:"text-zinc-500 line-through text-sm",children:["$",Ct.toFixed(2)]}),o.jsxs("p",{className:"text-green-400 font-bold",children:["$",at.toFixed(2)]}),o.jsxs("p",{className:"text-xs text-green-500",children:["Secret Bundle Deal! You save $",ft.toFixed(2)]})]}):o.jsxs("p",{className:"text-green-400 font-bold",children:["$",ke.price.toFixed(2)," Ã ",ke.quantity]})})]}),o.jsx("button",{onClick:()=>s(ke.productId),className:"p-2 text-zinc-400 hover:text-red-400 transition-colors",children:o.jsx(Kp,{className:"w-5 h-5"})})]},`${ke.productId}-${Ue}`)})}),o.jsxs("div",{className:"bg-zinc-800/50 rounded-xl border border-zinc-700 p-6",children:[o.jsxs("div",{className:"flex justify-between items-center mb-2",children:[o.jsx("span",{className:"text-zinc-400",children:"Subtotal"}),o.jsxs("span",{className:"text-white font-semibold",children:["$",_e.subtotal.toFixed(2)]})]}),_e.totalTax>0&&o.jsxs("div",{className:"flex justify-between items-center mb-2",children:[o.jsx("span",{className:"text-zinc-400",children:"Sales Tax"}),o.jsxs("span",{className:"text-white",children:["$",_e.totalTax.toFixed(2)]})]}),_e.totalProcessingFees>0&&o.jsxs("div",{className:"flex justify-between items-center mb-2",children:[o.jsx("span",{className:"text-zinc-400",children:"Processing/Shipping"}),o.jsxs("span",{className:"text-white",children:["$",_e.totalProcessingFees.toFixed(2)]})]}),o.jsx("div",{className:"border-t border-zinc-700 my-3"}),o.jsxs("div",{className:"flex justify-between items-center text-xl font-bold",children:[o.jsx("span",{className:"text-white",children:"Total"}),o.jsxs("span",{className:"text-green-400",children:["$",_e.grandTotal.toFixed(2)]})]})]}),o.jsx("div",{className:"bg-zinc-800/30 rounded-xl border border-zinc-600 p-4",children:o.jsxs("p",{className:"text-zinc-300 text-sm",children:["Secure checkout powered by ",o.jsx("strong",{className:"text-white",children:"Authorize.net"}),". Credit/debit card payment only."]})}),o.jsx("button",{onClick:()=>a(pe?"shipping":"payment"),className:"w-full py-4 bg-green-600 hover:bg-green-700 text-white rounded-xl font-bold text-lg transition-colors",children:pe?"Enter Shipping Address":"Proceed to Payment"})]}),i==="shipping"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"bg-zinc-800/50 rounded-xl border border-zinc-700 p-6 space-y-4",children:[o.jsx("p",{className:"text-zinc-300 mb-2",children:"Enter your shipping address for product delivery:"}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-zinc-400 mb-1",children:"Full Name *"}),o.jsx("input",{type:"text",value:I.fullName,onChange:ke=>k(Ue=>({...Ue,fullName:ke.target.value})),className:"w-full px-4 py-3 bg-zinc-800 border border-zinc-600 rounded-lg text-white focus:outline-none focus:border-green-500",placeholder:"John Doe"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-zinc-400 mb-1",children:"Street Address *"}),o.jsx("input",{type:"text",value:I.street,onChange:ke=>k(Ue=>({...Ue,street:ke.target.value})),className:"w-full px-4 py-3 bg-zinc-800 border border-zinc-600 rounded-lg text-white focus:outline-none focus:border-green-500",placeholder:"123 Main St, Apt 4"})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-zinc-400 mb-1",children:"City *"}),o.jsx("input",{type:"text",value:I.city,onChange:ke=>k(Ue=>({...Ue,city:ke.target.value})),className:"w-full px-4 py-3 bg-zinc-800 border border-zinc-600 rounded-lg text-white focus:outline-none focus:border-green-500",placeholder:"Los Angeles"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-zinc-400 mb-1",children:"State *"}),o.jsx("input",{type:"text",value:I.state,onChange:ke=>k(Ue=>({...Ue,state:ke.target.value})),className:"w-full px-4 py-3 bg-zinc-800 border border-zinc-600 rounded-lg text-white focus:outline-none focus:border-green-500",placeholder:"CA"})]})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-zinc-400 mb-1",children:"ZIP Co
96de *"}),o.jsx("input",{type:"text",value:I.zipCode,onChange:ke=>k(Ue=>({...Ue,zipCode:ke.target.value})),className:"w-full px-4 py-3 bg-zinc-800 border border-zinc-600 rounded-lg text-white focus:outline-none focus:border-green-500",placeholder:"90001"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-zinc-400 mb-1",children:"Phone Number *"}),o.jsx("input",{type:"tel",value:I.phone,onChange:ke=>k(Ue=>({...Ue,phone:ke.target.value})),className:"w-full px-4 py-3 bg-zinc-800 border border-zinc-600 rounded-lg text-white focus:outline-none focus:border-green-500",placeholder:"(555) 123-4567"})]})]})]}),o.jsxs("label",{className:"flex items-center gap-3 mt-4 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:F,onChange:ke=>z(ke.target.checked),className:"w-5 h-5 accent-green-500 rounded"}),o.jsx("span",{className:"text-white",children:"Save as my default address"})]}),o.jsxs("div",{className:"flex gap-3 mt-4",children:[o.jsx("button",{onClick:()=>a("cart"),className:"flex-1 py-3 bg-zinc-700 hover:bg-zinc-600 text-white rounded-xl transition-colors",children:"â Back to Cart"}),o.jsx("button",{onClick:async()=>{F&&t&&I.street&&await R1(t.uid,{street:I.street,city:I.city,state:I.state,zipCode:I.zipCode,country:"United States"}),a("payment")},disabled:!I.fullName||!I.street||!I.city||!I.state||!I.zipCode||!I.phone,className:"flex-1 py-3 bg-green-600 hover:bg-green-700 text-white rounded-xl font-bold transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:"Proceed to Payment â"})]})]}),i==="payment"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"bg-zinc-800/50 rounded-xl border border-zinc-700 p-6 mb-4",children:[o.jsx("p",{className:"text-zinc-400 mb-2",children:"Order Total"}),o.jsxs("p",{className:"text-3xl font-bold text-green-400",children:["$",_e.grandTotal.toFixed(2)]}),(_e.totalTax>0||_e.totalProcessingFees>0)&&o.jsxs("p",{className:"text-zinc-500 text-xs mt-1",children:["(Subtotal: $",_e.subtotal.toFixed(2),_e.totalTax>0&&` + Tax: $${_e.totalTax.toFixed(2)}`,_e.totalProcessingFees>0&&` + Processing: $${_e.totalProcessingFees.toFixed(2)}`,")"]}),o.jsxs("p",{className:"text-zinc-500 text-sm mt-2",children:["Confirmation will be sent to: ",o.jsx("span",{className:"text-white",children:t.email})]})]}),o.jsx("p",{className:"text-zinc-300 mb-4",children:"Select your payment method. A new window will open to complete payment."}),o.jsx("div",{className:"grid gap-3",children:Ye.map(ke=>o.jsxs("button",{onClick:()=>ut(ke),className:"w-full p-4 bg-zinc-800 hover:bg-zinc-700 border border-zinc-600 rounded-xl text-left transition-colors flex items-center justify-between",children:[o.jsx("span",{className:"text-white font-semibold",children:ke.displayName||ke.provider}),o.jsx("span",{className:"text-green-400 text-sm",children:"Pay Now â"})]},ke.id))}),o.jsx("button",{onClick:()=>a(pe?"shipping":"cart"),className:"w-full py-3 bg-zinc-700 hover:bg-zinc-600 text-white rounded-xl transition-colors mt-4",children:"â Back"})]}),i==="cardEntry"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"bg-zinc-800/50 rounded-xl border border-zinc-700 p-6 mb-4",children:[o.jsx("p",{className:"text-zinc-400 mb-2",children:"Order Total"}),o.jsxs("p",{className:"text-3xl font-bold text-green-400",children:["$",_e.grandTotal.toFixed(2)]}),(_e.totalTax>0||_e.totalProcessingFees>0)&&o.jsxs("p",{className:"text-zinc-500 text-xs mt-1",children:["(Subtotal: $",_e.subtotal.toFixed(2),_e.totalTax>0&&` + Tax: $${_e.totalTax.toFixed(2)}`,_e.totalProcessingFees>0&&` + Processing: $${_e.totalProcessingFees.toFixed(2)}`,")"]})]}),o.jsxs("div",{className:"bg-zinc-800/50 rounded-xl border border-zinc-700 p-6 space-y-4",children:[o.jsx("h3",{className:"text-lg font-semibold text-white mb-4",children:"Card Information"}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-zinc-400 mb-1",children:"Card Number *"}),o.jsx("input",{type:"text",value:Q.cardNumber,onChange:ke=>{const Ue=ke.target.value.replace(/\D/g,"").slice(0,16);G(rt=>({...rt,cardNumber:Ue}))},className:"w-full px-4 py-3 bg-zinc-800 border border-zinc-600 rounded-lg text-white focus:outline-none focus:border-green-500",placeholder:"1234 5678 9012 3456"})]}),o.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-zinc-400 mb-1",children:"Exp Month *"}),o.jsx("input",{type:"text",value:Q.expMonth,onChange:ke=>{const Ue=ke.target.value.replace(/\D/g,"").slice(0,2);G(rt=>({...rt,expMonth:Ue}))},className:"w-full px-4 py-3 bg-zinc-800 border border-zinc-600 rounded-lg text-white focus:outline-none focus:border-green-500",placeholder:"MM"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-zinc-400 mb-1",children:"Exp Year *"}),o.jsx("input",{type:"text",value:Q.expYear,onChange:ke=>{const Ue=ke.target.value.replace(/\D/g,"").slice(0,4);G(rt=>({...rt,expYear:Ue}))},className:"w-full px-4 py-3 bg-zinc-800 border border-zinc-600 rounded-lg text-white focus:outline-none focus:border-green-500",placeholder:"YYYY"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-zinc-400 mb-1",children:"CVV *"}),o.jsx("input",{type:"text",value:Q.cvv,onChange:ke=>{const Ue=ke.target.value.replace(/\D/g,"").slice(0,4);G(rt=>({...rt,cvv:Ue}))},className:"w-full px-4 py-3 bg-zinc-800 border border-zinc-600 rounded-lg text-white focus:outline-none focus:border-green-500",placeholder:"123"})]})]})]}),o.jsxs("div",{className:"bg-zinc-800/50 rounded-xl border border-zinc-700 p-6 mt-4 space-y-4",children:[o.jsx("h3",{className:"text-lg font-semibold text-white",children:"Billing Address"}),pe&&o.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:U,onChange:ke=>fe(ke.target.checked),className:"w-5 h-5 accent-green-500 rounded"}),o.jsx("span",{className:"text-white",children:"Same as shipping address"})]}
96),(!pe||!U)&&o.jsxs("div",{className:"space-y-4 mt-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-zinc-400 mb-1",children:"Street Address *"}),o.jsx("input",{type:"text",value:oe.street,onChange:ke=>X(Ue=>({...Ue,street:ke.target.value})),className:"w-full px-4 py-3 bg-zinc-800 border border-zinc-600 rounded-lg text-white focus:outline-none focus:border-green-500",placeholder:"123 Main St"})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-zinc-400 mb-1",children:"City *"}),o.jsx("input",{type:"text",value:oe.city,onChange:ke=>X(Ue=>({...Ue,city:ke.target.value})),className:"w-full px-4 py-3 bg-zinc-800 border border-zinc-600 rounded-lg text-white focus:outline-none focus:border-green-500",placeholder:"City"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-zinc-400 mb-1",children:"State *"}),o.jsx("input",{type:"text",value:oe.state,onChange:ke=>X(Ue=>({...Ue,state:ke.target.value})),className:"w-full px-4 py-3 bg-zinc-800 border border-zinc-600 rounded-lg text-white focus:outline-none focus:border-green-500",placeholder:"CA"})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-zinc-400 mb-1",children:"ZIP Code *"}),o.jsx("input",{type:"text",value:oe.zipCode,onChange:ke=>X(Ue=>({...Ue,zipCode:ke.target.value})),className:"w-full px-4 py-3 bg-zinc-800 border border-zinc-600 rounded-lg text-white focus:outline-none focus:border-green-500",placeholder:"90001"})]})]})]}),H&&o.jsxs("div",{className:"p-4 bg-red-500/10 border border-red-500/30 rounded-lg text-red-400 flex items-center gap-2 mt-4",children:[o.jsx(Lh,{className:"w-5 h-5"}),H]}),o.jsxs("div",{className:"flex gap-3 mt-4",children:[o.jsx("button",{onClick:()=>a("payment"),className:"flex-1 py-3 bg-zinc-700 hover:bg-zinc-600 text-white rounded-xl transition-colors",children:"â Back"}),o.jsx("button",{onClick:async()=>{ee(!0),K(null);try{const ke=await t.getIdToken(),Ue=U&&pe?{street:I.street,city:I.city,state:I.state,zipCode:I.zipCode}:oe,rt=await dZ(Q);W.current||(W.current=crypto.randomUUID());const at=await(await fetch("/api/process-card-payment",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ke}`},body:JSON.stringify({opaqueData:{dataDescriptor:rt.dataDescriptor,dataValue:rt.dataValue},billingAddress:Ue,shippingAddress:I,idempotencyKey:W.current})})).json();at.success?(await l_(n.items,ke),r(),c(at.transactionId||"ORDER"),a("confirmation")):K(at.message||"Payment failed. Please try again.")}catch{K("Payment processing failed. Please try again.")}finally{ee(!1)}},disabled:!Q.cardNumber||!Q.expMonth||!Q.expYear||!Q.cvv||Y||(!pe||!U)&&(!oe.street||!oe.city||!oe.state||!oe.zipCode),className:"flex-1 py-3 bg-green-600 hover:bg-green-700 text-white rounded-xl font-bold transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2",children:Y?o.jsxs(o.Fragment,{children:[o.jsx(Nn,{className:"w-5 h-5 animate-spin"}),"Processing..."]}):`Pay $${n.total.toFixed(2)}`})]})]}),i==="verification"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"bg-green-500/10 border border-green-500/30 rounded-xl p-4 mb-4",children:[o.jsxs("p",{className:"text-green-400 font-semibold flex items-center gap-2",children:[o.jsx(Vc,{className:"w-5 h-5"}),"Complete your payment in the opened window"]}),o.jsx("p",{className:"text-zinc-400 text-sm mt-2",children:"After paying, upload your receipt screenshot and enter the transaction ID below."})]}),o.jsxs("div",{className:"bg-zinc-800/50 rounded-xl border border-zinc-700 p-6 space-y-6",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-white font-semibold mb-2",children:"Transaction ID *"}),o.jsx("input",{type:"text",value:p,onChange:ke=>m(ke.target.value),placeholder:"Enter transaction/confirmation ID from your payment",className:"w-full px-4 py-3 bg-zinc-900 border border-zinc-600 rounded-lg text-white focus:outline-none focus:border-green-500"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-white font-semibold mb-2",children:"Payment Receipt Screenshot *"}),o.jsx("input",{type:"file",ref:V,onChange:lt,accept:"image/*",className:"hidden"}),w?o.jsxs("div",{className:"relative",children:[o.jsx("img",{src:w,alt:"Receipt",className:"w-full max-h-64 object-contain rounded-lg border border-zinc-600"}),o.jsx("button",{onClick:()=>{x(null),S(null),V.current&&(V.current.value="")},className:"absolute top-2 right-2 p-2 bg-red-500 rounded-full text-white hover:bg-red-600",children:o.jsx(Mr,{className:"w-4 h-4"})})]}):o.jsxs("button",{onClick:()=>V.current?.click(),className:"w-full py-8 border-2 border-dashed border-zinc-600 rounded-xl hover:border-green-500 transition-colors flex flex-col items-center gap-2",children:[o.jsx($F,{className:"w-8 h-8 text-zinc-400"}),o.jsx("span",{className:"text-zinc-400",children:"Click to upload receipt screenshot"})]})]}),R&&o.jsxs("div",{className:`p-4 rounded-lg flex items-center gap-2 ${R.type==="success"?"bg-green-500/10 border border-green-500/30 text-green-400":"bg-red-500/10 border border-red-500/30 text-red-400"}`,children:[R.type==="success"?o.jsx(Vc,{className:"w-5 h-5"}):o.jsx(Lh,{className:"w-5 h-5"}),R.text]}),o.jsx("button",{onClick:cn,disabled:!p||!y||_,className:"w-full py-4 bg-green-600 hover:bg-green-700 disabled:bg-zinc-600 disabled:cursor-not-allowed text-white rounded-xl font-bold text-lg transition-colors flex items-center justify-center gap-2",children:_?o.jsxs(o.Fragment,{children:[o.jsx(Nn,{className:"w-5 h-5 animate-spin"}),"Submitting..."]}):"Complete Order"})]}),o.jsx("button",{onClick:()=>a("payment"),className:"w-full py-3 bg-zinc-700 hover:bg-zinc-600 text-white rounded-xl transition-colors",children:"â Choose Different Payment Method"})]}),i==="confirmation"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"bg-green-500/10 border border-green-500/30 rounded-xl p-6 mb-6 text-center",children:[o.jsx(Vc,{className:"w-16 h-16 text-green-500 mx-auto mb-4"}),o.jsx("h2",{className:"text-2xl font-bold text-white mb-2",children:"Thank You For Your Order!"}),o.jsxs("p",{className:"text-zinc-300",children:["Order ID: ",o.jsx("span",{className:"text-green-400 font-mono",children:l})]})]}),o.jsxs("div",{className:"bg-zinc-800/50 rounded-xl border border-zinc-700 p-6 space-y-4",children:[o.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[o.jsx(Lh,{className:"w-5 h-5 text-yellow-500"}),"Important Information"]}),o.jsxs("div",{className:"space-y-4 text-zinc-300",children:[o.jsxs("div",{className:"bg-zinc-900/50 rounded-lg p-4 border border-zinc-700",children:[o.jsx("p",{className:"font-semibold text-white mb-2",children:"Check Your Email"}),o.jsxs("p",{children:["Please check your email for a purchase confirmation from ",o.jsx("span",{className:"text-green-400 font-semibold",children:"Gizmo"}),". This email contains your order details and receipt."]})]}),o.jsxs("div",{className:"bg-yellow-500/10 rounded-lg p-4 border border-yellow-500/30",children:[o.jsx("p",{className:"font-semibold text-yellow-400 mb-2",children:"About Your Card Statement"}),o.jsxs("p",{children:["The charge on your card statement will appear from ",o.jsx("span",{className:"text-white font-semibold",children:'"Hives"'})," or ",o.jsx("span",{className:"text-white font-semibold",children:'"Hive Staffing"'}),". This is our payment processing company."]})]}),o.jsxs("div",{className:"bg-red-500/10 rounded-lg p-4 border border-red-500/30",children:[o.jsx("p",{className:"font-semibold text-red-400 mb-2",children:"Do Not Dispute This Charge"}),o.jsxs("p",{children:["Please ",o.jsx("span",{className:"text-white font-semibold",children:"do not dispute"})," this charge with your bank. Disputing may disrupt your product delivery and delay your order."]})]})]})]}),o.jsx(Et,{href:"/shop",children:o.jsx("button",{className:"w-full py-4 bg-green-600 hover:bg-green-700 text-white rounded-xl font-bold text-lg transition-colors mt-6",children:"Continue Shopping"})}),o.jsx(Et,{href:"/my-account",children:o.jsx("button",{className:"w-full py-3 bg-zinc-700 hover:bg-zinc-600 text-white rounded-xl transition-colors mt-3",children:"View My Orders"})})]})]})]})}):o.jsx("div",{className:"min-h-screen bg-gradient-to-b from-black via-zinc-900 to-black",children:o.jsx("div",{className:"max-w-4xl mx-auto px-4 py-16",children:o.jsxs("div",{className:"text-center py-20",children:[o.jsx(Fl,{className:"w-16 h-16 text-zinc-600 mx-auto mb-4"}),o.jsx("h2",{className:"text-2xl font-bold text-white mb-4",children:"Sign in to view your cart"}),o.jsx("p",{className:"text-zinc-400 mb-6",children:"You need to be signed in to add items to your cart and make purchases."}),o.jsx("p",{className:"text-zinc-500 text-sm",children:"Click the profile icon in the header to sign in or create an account."})]})})})}const nN=6048e5,fZ=864e5,c_=Symbol.for("constructDateFrom");function du(n,e){return typeof n=="function"?n(e):n&&typeof n=="object"&&c_ in n?n[c_](e):n instanceof Date?new n.constructor(e):new Date(e)}function mo(n,e){return du(e||n,n)}let pZ={};function ny(){return pZ}function mm(n,e){const t=ny(),s=e?.weekStartsOn??e?.locale?.options?.weekStartsOn??t.weekStartsOn??t.locale?.options?.weekStartsOn??0,r=mo(n,e?.in),i=r.getDay(),a=(i<s?7:0)+i-s;return r.setDate(r.getDate()-a),r.setHours(0,0,0,0),r}function N1(n,e){return mm(n,{...e,weekStartsOn:1}
96)}function sN(n,e){const t=mo(n,e?.in),s=t.getFullYear(),r=du(t,0);r.setFullYear(s+1,0,4),r.setHours(0,0,0,0);const i=N1(r),a=du(t,0);a.setFullYear(s,0,4),a.setHours(0,0,0,0);const l=N1(a);return t.getTime()>=i.getTime()?s+1:t.getTime()>=l.getTime()?s:s-1}function u_(n){const e=mo(n),t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return t.setUTCFullYear(e.getFullYear()),+n-+t}function mZ(n,...e){const t=du.bind(null,e.find(s=>typeof s=="object"));return e.map(t)}function d_(n,e){const t=mo(n,e?.in);return t.setHours(0,0,0,0),t}function gZ(n,e,t){const[s,r]=mZ(t?.in,n,e),i=d_(s),a=d_(r),l=+i-u_(i),c=+a-u_(a);return Math.round((l-c)/fZ)}function xZ(n,e){const t=sN(n,e),s=du(n,0);return s.setFullYear(t,0,4),s.setHours(0,0,0,0),N1(s)}function yZ(n){return n instanceof Date||typeof n=="object"&&Object.prototype.toString.call(n)==="[object Date]"}function vZ(n){return!(!yZ(n)&&typeof n!="number"||isNaN(+mo(n)))}function bZ(n,e){const t=mo(n,e?.in);return t.setFullYear(t.getFullYear(),0,1),t.setHours(0,0,0,0),t}const wZ={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},SZ=(n,e,t)=>{let s;const r=wZ[n];return typeof r=="string"?s=r:e===1?s=r.one:s=r.other.replace("{{count}}",e.toString()),t?.addSuffix?t.comparison&&t.comparison>0?"in "+s:s+" ago":s};function xv(n){return(e={})=>{const t=e.width?String(e.width):n.defaultWidth;return n.formats[t]||n.formats[n.defaultWidth]}}const EZ={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},TZ={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},_Z={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},IZ={date:xv({formats:EZ,defaultWidth:"full"}),time:xv({formats:TZ,defaultWidth:"full"}),dateTime:xv({formats:_Z,defaultWidth:"full"})},AZ={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},CZ=(n,e,t,s)=>AZ[n];function cp(n){return(e,t)=>{const s=t?.context?String(t.context):"standalone";let r;if(s==="formatting"&&n.formattingValues){const a=n.defaultFormattingWidth||n.defaultWidth,l=t?.width?String(t.width):a;r=n.formattingValues[l]||n.formattingValues[a]}else{const a=n.defaultWidth,l=t?.width?String(t.width):n.defaultWidth;r=n.values[l]||n.values[a]}const i=n.argumentCallback?n.argumentCallback(e):e;return r[i]}}const kZ={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},RZ={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},PZ={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},NZ={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},LZ={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},DZ={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},jZ=(n,e)=>{const t=Number(n),s=t%100;if(s>20||s<10)switch(s%10){case 1:return t+"st";case 2:return t+"nd";case 3:return t+"rd"}return t+"th"},OZ={ordinalNumber:jZ,era:cp({values:kZ,defaultWidth:"wide"}),quarter:cp({values:RZ,defaultWidth:"wide",argumentCallback:n=>n-1}),month:cp({values:PZ,defaultWidth:"wide"}),day:cp({values:NZ,defaultWidth:"wide"}),dayPeriod:cp({values:LZ,defaultWidth:"wide",formattingValues:DZ,defaultFormattingWidth:"wide"})};function up(n){return(e,t={})=>{const s=t.width,r=s&&n.matchPatterns[s]||n.matchPatterns[n.defaultMatchWidth],i=e.match(r);if(!i)return null;const a=i[0],l=s&&n.parsePatterns[s]||n.parsePatterns[n.defaultParseWidth],c=Array.isArray(l)?FZ(l,p=>p.test(a)):MZ(l,p=>p.test(a));let d;d=n.valueCallback?n.valueCallback(c):c,d=t.valueCallback?t.valueCallback(d):d;const h=e.slice(a.length);return{value:d,rest:h}}}function MZ(n,e){for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t)&&e(n[t]))return t}function FZ(n,e){for(let t=0;t<n.length;t++)if(e(n[t]))return t}function UZ(n){return(e,t={})=>{const s=e.match(n.matchPattern);if(!s)return null;const r=s[0],i=e.match(n.parsePattern);if(!i)return null;let a=n.valueCallback?n.valueCallback(i[0]):i[0];a=t.valueCallback?t.valueCallback(a):a;const l=e.slice(r.length);return{value:a,rest:l}}}const VZ=/^(\d+)(th|st|nd|rd)?/i,BZ=/\d+/i,zZ={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},$Z={any:[/^b/i,/^(a|c)/i]},HZ={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},WZ={any:[/1/i,/2/i,/3/i,/4/i]},GZ={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},KZ={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},qZ={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},YZ={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},QZ={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},XZ={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},JZ={ordinalNumber:UZ({matchPattern:VZ,parsePattern:BZ,valueCallback:n=>parseInt(n,10)}),era:up({matchPatterns:zZ,defaultMatchWidth:"wide",parsePatterns:$Z,defaultParseWidth:"any"}),quarter:up({matchPatterns:HZ,defaultMatchWidth:"wide",parsePatterns:WZ,defaultParseWidth:"any",valueCallback:n=>n+1}),month:up({matchPatterns:GZ,defaultMatchWidth:"wide",parsePatterns:KZ,defaultParseWidth:"any"}),day:up({matchPatterns:qZ,defaultMatchWidth:"wide",parsePatterns:YZ,defaultParseWidth:"any"}),dayPeriod:up({matchPatterns:QZ,defaultMatchWidth:"any",parsePatterns:XZ,defaultParseWidth:"any"})},ZZ={code:"en-US",formatDistance:SZ,formatLong:IZ,formatRelative:CZ,localize:OZ,match:JZ,options:{weekStartsOn:0,firstWeekContainsDate:1}};function eee(n,e){const t=mo(n,e?.in);return gZ(t,bZ(t))+1}function tee(n,e){const t=mo(n,e?.in),s=+N1(t)-+xZ(t);return Math.round(s/nN)+1}function rN(n,e){const t=mo(n,e?.in),s=t.getFullYear(),r=ny(),i=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,a=du(e?.in||n,0);a.setFullYear(s+1,0,i),a.setHours(0,0,0,0);const l=mm(a,e),c=du(e?.in||n,0);c.setFullYear(s,0,i),c.setHours(0,0,0,0);const d=mm(c,e);return+t>=+l?s+1:+t>=+d?s:s-1}function nee(n,e){const t=ny(),s=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??t.firstWeekContainsDate??t.locale?.options?.firstWeekContainsDate??1,r=rN(n,e),i=du(e?.in||n,0);return i.setFullYear(r,0,s),i.setHours(0,0,0,0),mm(i,e)}function see(n,e){const t=mo(n,e?.in),s=+mm(t,e)-+nee(t,e);return Math.round(s/nN)+1}function _n(n,e){const t=n<0?"-":"",s=Math.abs(n).toString().padStart(e,"0");return t+s}const Ac={y(n,e){const t=n.getFullYear(),s=t>0?t:1-t;return _n(e==="yy"?s%100:s,e.length)},M(n,e){const t=n.getMonth();return e==="M"?String(t+1):_n(t+1,2)},d(n,e){return _n(n.getDate(),e.length)},a(n,e){const t=n.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return t.toUpperCase();case"aaa":return t;case"aaaaa":return t[0];default:return t==="am"?"a.m.":"p.m."}},h(n,e){return _n(n.getHours()%12||12,e.length)},H(n,e){return _n(n.getHours(),e.length)},m(n,e){return _n(n.getMinutes(),e.length)}
96,s(n,e){return _n(n.getSeconds(),e.length)},S(n,e){const t=e.length,s=n.getMilliseconds(),r=Math.trunc(s*Math.pow(10,t-3));return _n(r,e.length)}},ch={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},h_={G:function(n,e,t){const s=n.getFullYear()>0?1:0;switch(e){case"G":case"GG":case"GGG":return t.era(s,{width:"abbreviated"});case"GGGGG":return t.era(s,{width:"narrow"});default:return t.era(s,{width:"wide"})}},y:function(n,e,t){if(e==="yo"){const s=n.getFullYear(),r=s>0?s:1-s;return t.ordinalNumber(r,{unit:"year"})}return Ac.y(n,e)},Y:function(n,e,t,s){const r=rN(n,s),i=r>0?r:1-r;if(e==="YY"){const a=i%100;return _n(a,2)}return e==="Yo"?t.ordinalNumber(i,{unit:"year"}):_n(i,e.length)},R:function(n,e){const t=sN(n);return _n(t,e.length)},u:function(n,e){const t=n.getFullYear();return _n(t,e.length)},Q:function(n,e,t){const s=Math.ceil((n.getMonth()+1)/3);switch(e){case"Q":return String(s);case"QQ":return _n(s,2);case"Qo":return t.ordinalNumber(s,{unit:"quarter"});case"QQQ":return t.quarter(s,{width:"abbreviated",context:"formatting"});case"QQQQQ":return t.quarter(s,{width:"narrow",context:"formatting"});default:return t.quarter(s,{width:"wide",context:"formatting"})}},q:function(n,e,t){const s=Math.ceil((n.getMonth()+1)/3);switch(e){case"q":return String(s);case"qq":return _n(s,2);case"qo":return t.ordinalNumber(s,{unit:"quarter"});case"qqq":return t.quarter(s,{width:"abbreviated",context:"standalone"});case"qqqqq":return t.quarter(s,{width:"narrow",context:"standalone"});default:return t.quarter(s,{width:"wide",context:"standalone"})}},M:function(n,e,t){const s=n.getMonth();switch(e){case"M":case"MM":return Ac.M(n,e);case"Mo":return t.ordinalNumber(s+1,{unit:"month"});case"MMM":return t.month(s,{width:"abbreviated",context:"formatting"});case"MMMMM":return t.month(s,{width:"narrow",context:"formatting"});default:return t.month(s,{width:"wide",context:"formatting"})}},L:function(n,e,t){const s=n.getMonth();switch(e){case"L":return String(s+1);case"LL":return _n(s+1,2);case"Lo":return t.ordinalNumber(s+1,{unit:"month"});case"LLL":return t.month(s,{width:"abbreviated",context:"standalone"});case"LLLLL":return t.month(s,{width:"narrow",context:"standalone"});default:return t.month(s,{width:"wide",context:"standalone"})}},w:function(n,e,t,s){const r=see(n,s);return e==="wo"?t.ordinalNumber(r,{unit:"week"}):_n(r,e.length)},I:function(n,e,t){const s=tee(n);return e==="Io"?t.ordinalNumber(s,{unit:"week"}):_n(s,e.length)},d:function(n,e,t){return e==="do"?t.ordinalNumber(n.getDate(),{unit:"date"}):Ac.d(n,e)},D:function(n,e,t){const s=eee(n);return e==="Do"?t.ordinalNumber(s,{unit:"dayOfYear"}):_n(s,e.length)},E:function(n,e,t){const s=n.getDay();switch(e){case"E":case"EE":case"EEE":return t.day(s,{width:"abbreviated",context:"formatting"});case"EEEEE":return t.day(s,{width:"narrow",context:"formatting"});case"EEEEEE":return t.day(s,{width:"short",context:"formatting"});default:return t.day(s,{width:"wide",context:"formatting"})}},e:function(n,e,t,s){const r=n.getDay(),i=(r-s.weekStartsOn+8)%7||7;switch(e){case"e":return String(i);case"ee":return _n(i,2);case"eo":return t.ordinalNumber(i,{unit:"day"});case"eee":return t.day(r,{width:"abbreviated",context:"formatting"});case"eeeee":return t.day(r,{width:"narrow",context:"formatting"});case"eeeeee":return t.day(r,{width:"short",context:"formatting"});default:return t.day(r,{width:"wide",context:"formatting"})}},c:function(n,e,t,s){const r=n.getDay(),i=(r-s.weekStartsOn+8)%7||7;switch(e){case"c":return String(i);case"cc":return _n(i,e.length);case"co":return t.ordinalNumber(i,{unit:"day"});case"ccc":return t.day(r,{width:"abbreviated",context:"standalone"});case"ccccc":return t.day(r,{width:"narrow",context:"standalone"});case"cccccc":return t.day(r,{width:"short",context:"standalone"});default:return t.day(r,{width:"wide",context:"standalone"})}},i:function(n,e,t){const s=n.getDay(),r=s===0?7:s;switch(e){case"i":return String(r);case"ii":return _n(r,e.length);case"io":return t.ordinalNumber(r,{unit:"day"});case"iii":return t.day(s,{width:"abbreviated",context:"formatting"});case"iiiii":return t.day(s,{width:"narrow",context:"formatting"});case"iiiiii":return t.day(s,{width:"short",context:"formatting"});default:return t.day(s,{width:"wide",context:"formatting"})}},a:function(n,e,t){const r=n.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return t.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"aaa":return t.dayPeriod(r,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return t.dayPeriod(r,{width:"narrow",context:"formatting"});default:return t.dayPeriod(r,{width:"wide",context:"formatting"})}},b:function(n,e,t){const s=n.getHours();let r;switch(s===12?r=ch.noon:s===0?r=ch.midnight:r=s/12>
96=1?"pm":"am",e){case"b":case"bb":return t.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"bbb":return t.dayPeriod(r,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return t.dayPeriod(r,{width:"narrow",context:"formatting"});default:return t.dayPeriod(r,{width:"wide",context:"formatting"})}},B:function(n,e,t){const s=n.getHours();let r;switch(s>=17?r=ch.evening:s>=12?r=ch.afternoon:s>=4?r=ch.morning:r=ch.night,e){case"B":case"BB":case"BBB":return t.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"BBBBB":return t.dayPeriod(r,{width:"narrow",context:"formatting"});default:return t.dayPeriod(r,{width:"wide",context:"formatting"})}},h:function(n,e,t){if(e==="ho"){let s=n.getHours()%12;return s===0&&(s=12),t.ordinalNumber(s,{unit:"hour"})}return Ac.h(n,e)},H:function(n,e,t){return e==="Ho"?t.ordinalNumber(n.getHours(),{unit:"hour"}):Ac.H(n,e)},K:function(n,e,t){const s=n.getHours()%12;return e==="Ko"?t.ordinalNumber(s,{unit:"hour"}):_n(s,e.length)},k:function(n,e,t){let s=n.getHours();return s===0&&(s=24),e==="ko"?t.ordinalNumber(s,{unit:"hour"}):_n(s,e.length)},m:function(n,e,t){return e==="mo"?t.ordinalNumber(n.getMinutes(),{unit:"minute"}):Ac.m(n,e)},s:function(n,e,t){return e==="so"?t.ordinalNumber(n.getSeconds(),{unit:"second"}):Ac.s(n,e)},S:function(n,e){return Ac.S(n,e)},X:function(n,e,t){const s=n.getTimezoneOffset();if(s===0)return"Z";switch(e){case"X":return p_(s);case"XXXX":case"XX":return Gu(s);default:return Gu(s,":")}},x:function(n,e,t){const s=n.getTimezoneOffset();switch(e){case"x":return p_(s);case"xxxx":case"xx":return Gu(s);default:return Gu(s,":")}},O:function(n,e,t){const s=n.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+f_(s,":");default:return"GMT"+Gu(s,":")}},z:function(n,e,t){const s=n.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+f_(s,":");default:return"GMT"+Gu(s,":")}},t:function(n,e,t){const s=Math.trunc(+n/1e3);return _n(s,e.length)},T:function(n,e,t){return _n(+n,e.length)}};function f_(n,e=""){const t=n>0?"-":"+",s=Math.abs(n),r=Math.trunc(s/60),i=s%60;return i===0?t+String(r):t+String(r)+e+_n(i,2)}function p_(n,e){return n%60===0?(n>0?"-":"+")+_n(Math.abs(n)/60,2):Gu(n,e)}function Gu(n,e=""){const t=n>0?"-":"+",s=Math.abs(n),r=_n(Math.trunc(s/60),2),i=_n(s%60,2);return t+r+e+i}const m_=(n,e)=>{switch(n){case"P":return e.date({width:"short"});case"PP":return e.date({width:"medium"});case"PPP":return e.date({width:"long"});default:return e.date({width:"full"})}},iN=(n,e)=>{switch(n){case"p":return e.time({width:"short"});case"pp":return e.time({width:"medium"});case"ppp":return e.time({width:"long"});default:return e.time({width:"full"})}},ree=(n,e)=>{const t=n.match(/(P+)(p+)?/)||[],s=t[1],r=t[2];if(!r)return m_(n,e);let i;switch(s){case"P":i=e.dateTime({width:"short"});break;case"PP":i=e.dateTime({width:"medium"});break;case"PPP":i=e.dateTime({width:"long"});break;default:i=e.dateTime({width:"full"});break}return i.replace("{{date}}",m_(s,e)).replace("{{time}}",iN(r,e))},iee={p:iN,P:ree},aee=/^D+$/,oee=/^Y+$/,lee=["D","DD","YY","YYYY"];function cee(n){return aee.test(n)}function uee(n){return oee.test(n)}function dee(n,e,t){const s=hee(n,e,t);if(lee.includes(n))throw new RangeError(s)}function hee(n,e,t){const s=n[0]==="Y"?"years":"days of the month";return`Use \`${n.toLowerCase()}\` instead of \`${n}\` (in \`${e}\`) for formatting ${s} to the input \`${t}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const fee=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,pee=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,mee=/^'([^]*?)'?$/,gee=/''/g,xee=/[a-zA-Z]/;function yee(n,e,t){const s=ny(),r=s.locale??ZZ,i=s.firstWeekContainsDate??s.locale?.options?.firstWeekContainsDate??1,a=s.weekStartsOn??s.locale?.options?.weekStartsOn??0,l=mo(n,t?.in);if(!vZ(l))throw new RangeError("Invalid time value");let c=e.match(pee).map(h=>{const p=h[0];if(p==="p"||p==="P"){const m=iee[p];return m(h,r.formatLong)}return h}).join("").match(fee).map(h=>{if(h==="''")return{isToken:!1,value:"'"};const p=h[0];if(p==="'")return{isToken:!1,value:vee(h)};if(h_[p])return{isToken:!0,value:h};
96if(p.match(xee))throw new RangeError("Format string contains an unescaped latin alphabet character `"+p+"`");return{isToken:!1,value:h}});r.localize.preprocessor&&(c=r.localize.preprocessor(l,c));const d={firstWeekContainsDate:i,weekStartsOn:a,locale:r};return c.map(h=>{if(!h.isToken)return h.value;const p=h.value;(uee(p)||cee(p))&&dee(p,e,String(n));const m=h_[p[0]];return m(l,p,r.localize,d)}).join("")}function vee(n){const e=n.match(mee);return e?e[1].replace(gee,"'"):n}function bee(n){switch(n){case"pending":return o.jsx(uo,{className:"w-4 h-4 text-yellow-500"});case"processing":return o.jsx(gd,{className:"w-4 h-4 text-blue-500"});case"shipped":return o.jsx(W7,{className:"w-4 h-4 text-purple-500"});case"delivered":return o.jsx(Vc,{className:"w-4 h-4 text-green-500"});case"cancelled":return o.jsx(ax,{className:"w-4 h-4 text-red-500"});default:return o.jsx(uo,{className:"w-4 h-4 text-gray-500"})}}function wee(n){switch(n){case"pending":return"bg-yellow-500/20 text-yellow-400 border-yellow-500/30";case"processing":return"bg-blue-500/20 text-blue-400 border-blue-500/30";case"shipped":return"bg-purple-500/20 text-purple-400 border-purple-500/30";case"delivered":return"bg-green-500/20 text-green-400 border-green-500/30";case"cancelled":return"bg-red-500/20 text-red-400 border-red-500/30";default:return"bg-gray-500/20 text-gray-400 border-gray-500/30"}}function See(n){switch(n){case"completed":return"text-green-400";
96case"pending":return"text-yellow-400";case"failed":return"text-red-400";case"refunded":return"text-blue-400";default:return"text-gray-400"}}function Eee({order:n}){const[e,t]=T.useState(!1);return o.jsxs("div",{className:"bg-gray-900/60 border border-gray-700/50 rounded-xl overflow-hidden",children:[o.jsx("div",{className:"p-4 cursor-pointer hover:bg-gray-800/50 transition-colors",onClick:()=>t(!e),children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsx("div",{className:"w-12 h-12 bg-green-500/20 rounded-lg flex items-center justify-center",children:o.jsx(gd,{className:"w-6 h-6 text-green-400"})}),o.jsxs("div",{children:[o.jsxs("p",{className:"text-white font-medium",children:["Order #",n.id.slice(-8).toUpperCase()]}),o.jsx("p",{className:"text-gray-400 text-sm",children:yee(new Date(n.createdAt),"MMM d, yyyy 'at' h:mm a")})]})]}),o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsxs("div",{className:`px-3 py-1 rounded-full border text-sm flex items-center gap-2 ${wee(n.orderStatus)}`,children:[bee(n.orderStatus),o.jsx("span",{className:"capitalize",children:n.orderStatus})]}),o.jsxs("p",{className:"text-white font-bold",children:["$",n.total.toFixed(2)]}),e?o.jsx(ix,{className:"w-5 h-5 text-gray-400"}):o.jsx(ao,{className:"w-5 h-5 text-gray-400"})]})]})}),e&&o.jsx("div",{className:"border-t border-gray-700/50 p-4 space-y-4",children:o.jsxs("div",{className:"grid md:grid-cols-2 gap-4",children:[o.jsxs("div",{children:[o.jsx("h4",{className:"text-gray-400 text-sm mb-2",children:"Items"}),o.jsx("div",{className:"space-y-2",children:n.items.map((s,r)=>o.jsxs("div",{className:"flex items-center gap-3",children:[s.imageUrl?o.jsx("img",{src:s.imageUrl,alt:s.productName,className:"w-10 h-10 rounded-lg object-cover"}):o.jsx("div",{className:"w-10 h-10 bg-gray-700 rounded-lg flex items-center justify-center",children:o.jsx(gd,{className:"w-5 h-5 text-gray-400"})}),o.jsxs("div",{className:"flex-1",children:[o.jsx("p",{className:"text-white text-sm",children:s.productName}),o.jsxs("p",{className:"text-gray-400 text-xs",children:["Qty: ",s.quantity," Ã $",s.price.toFixed(2)]})]}),o.jsxs("p",{className:"text-white text-sm",children:["$",(s.price*s.quantity).toFixed(2)]})]},r))})]}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{children:[o.jsx("h4",{className:"text-gray-400 text-sm mb-1",children:"Payment"}),o.jsx("p",{className:"text-white",children:n.paymentMethod}),o.jsx("p",{className:`text-sm capitalize ${See(n.paymentStatus)}`,children:n.paymentStatus})]}),n.shippingAddress&&o.jsxs("div",{children:[o.jsx("h4",{className:"text-gray-400 text-sm mb-1",children:"Shipping Address"}),o.jsx("p",{className:"text-white text-sm",children:n.shippingAddress.name}),o.jsx("p",{className:"text-gray-400 text-sm",children:n.shippingAddress.address}),o.jsxs("p",{className:"text-gray-400 text-sm",children:[n.shippingAddress.city,", ",n.shippingAddress.state," ",n.shippingAddress.zip]})]}),o.jsxs("div",{className:"pt-2 border-t border-gray-700/50",children:[o.jsxs("div",{className:"flex justify-between text-sm",children:[o.jsx("span",{className:"text-gray-400",children:"Subtotal"}),o.jsxs("span",{className:"text-white",children:["$",n.subtotal.toFixed(2)]})]}),o.jsxs("div",{className:"flex justify-between text-sm",children:[o.jsx("span",{className:"text-gray-400",children:"Tax"}),o.jsxs("span",{className:"text-white",children:["$",n.tax.toFixed(2)]})]}),o.jsxs("div",{className:"flex justify-between text-sm font-bold mt-1",children:[o.jsx("span",{className:"text-white",children:"Total"}),o.jsxs("span",{className:"text-green-400",children:["$",n.total.toFixed(2)]})]})]})]})]})})]})}function Tee(){const[n,e]=T.useState(null),[t,s]=T.useState(!0);T.useEffect(()=>{const a=yd(),l=Rd(a,c=>{e(c),s(!1)});return()=>l()},[]);const{data:r=[],isLoading:i}=gn({queryKey:["/api/orders/user",n?.uid],queryFn:async()=>{if(!n?.uid)return[];const a=await fetch(lo(`/api/orders/user/${n.uid}`));if(!a.ok)throw new Error("Failed to fetch orders");return a.json()},enabled:!!n?.uid});return t?o.jsx(N0,{children:o.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:o.jsx("div",{className:"animate-spin w-8 h-8 border-2 border-green-500 border-t-transparent roun
96ded-full"})})}):n?o.jsx(N0,{children:o.jsx("div",{className:"min-h-screen bg-black pt-24 px-4 pb-12",children:o.jsxs("div",{className:"max-w-4xl mx-auto",children:[o.jsxs("div",{className:"mb-8",children:[o.jsx("h1",{className:"text-3xl font-bold text-white mb-2",children:"Order History"}),o.jsx("p",{className:"text-gray-400",children:"View and track all your past purchases"})]}),i?o.jsx("div",{className:"flex items-center justify-center py-20",children:o.jsx("div",{className:"animate-spin w-8 h-8 border-2 border-green-500 border-t-transparent rounded-full"})}):r.length===0?o.jsxs("div",{className:"text-center py-20",children:[o.jsx(gd,{className:"w-16 h-16 text-gray-600 mx-auto mb-4"}),o.jsx("h2",{className:"text-xl font-bold text-white mb-2",children:"No orders yet"}),o.jsx("p",{className:"text-gray-400 mb-6",children:"When you make a purchase, your orders will appear here"}),o.jsx("a",{href:"/shop",className:"inline-flex items-center gap-2 px-6 py-3 bg-green-500 hover:bg-green-600 text-white font-medium rounded-lg transition-colors",children:"Browse Shop"})]}):o.jsx("div",{className:"space-y-4",children:r.map(a=>o.jsx(Eee,{order:a},a.id))})]})})}):o.jsx(N0,{children:o.jsx("div",{className:"min-h-screen bg-black pt-24 px-4",children:o.jsxs("div",{className:"max-w-2xl mx-auto text-center py-20",children:[o.jsx(gd,{className:"w-16 h-16 text-gray-600 mx-auto mb-4"}),o.jsx("h2",{className:"text-2xl font-bold text-white mb-2",children:"Sign in to view your orders"}),o.jsx("p",{className:"text-gray-400 mb-6",children:"Please sign in to access your order history"}),o.jsx("a",{href:"/login",className:"inline-flex items-center gap-2 px-6 py-3 bg-green-500 hover:bg-green-600 text-white font-medium rounded-lg transition-colors",children:"Sign In"})]})})})}function _ee(){return o.jsxs("div",{className:"min-h-screen bg-black",children:[o.jsxs("section",{className:"relative py-24 md:py-32 px-4 overflow-hidden",children:[o.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-[hsl(142,76%,15%)]/20 to-black"}),o.jsxs("div",{className:"relative max-w-7xl mx-auto text-center",children:[o.jsxs("h1",{className:"text-4xl md:text-6xl font-bold mb-6","data-testid":"contact-title",children:[o.jsx("span",{className:"text-white",children:"Contact "}),o.jsx("span",{className:"text-[hsl(142,76%,45%)]",children:"Us"})]}),o.jsx("p",{className:"text-xl text-white/70 max-w-3xl mx-auto",children:"Have questions or want to work with us? We'd love to hear from you."})]})]}),o.jsx("section",{className:"py-12 px-4 bg-[hsl(0,0%,5%)]",children:o.jsxs("div",{className:"max-w-7xl mx-auto",children:[o.jsxs("div",{className:"grid md:grid-cols-2 gap-8",children:[o.jsxs("div",{className:"bg-[hsl(0,0%,8%)] rounded-2xl p-8 border border-white/10",children:[o.jsx("h2",{className:"text-2xl font-bold text-white mb-6",children:"Get in Touch"}),o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"flex items-start gap-4",children:[o.jsx("div",{className:"p-3 rounded-lg bg-[hsl(142,76%,45%)]",children:o.jsx(z7,{size:20,className:"text-black"})}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-white font-semibold mb-1",children:"Location"}),o.jsx("p",{className:"text-white/60",children:"Oklahoma City, Oklahoma"}),o.jsx("p",{className:"text-white/60",children:o.jsx(Is,{suffix:" Lounge & Studios",size:"base",color:"#4ade80"})})]})]}),o.jsxs("div",{className:"flex items-start gap-4",children:[o.jsx("div",{className:"p-3 rounded-lg bg-[hsl(45,93%,47%)]",children:o.jsx(xb,{size:20,className:"text-black"})}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-white font-semibold mb-1",children:"Email"}),o.jsx("p",{className:"text-white/60",children:"[email protected]"})]})]}),o.jsxs("div",{className:"flex items-start gap-4",children:[o.jsx("div",{className:"p-3 rounded-lg bg-[hsl(142,76%,45%)]",children:o.jsx(LF,{size:20,className:"text-black"})}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-white font-semibold mb-1",children:"Phone"}),o.jsx("p",{className:"text-white/60",children:"Contact via website form"})]})]})]})]}),o.jsxs("div",{className:"bg-gradient-to-br from-[hsl(142,76%,25%)] to-[hsl(142,76%,15%)] rounded-2xl p-8 border border-[hsl(142,76%,45%)]/30 flex flex-col",children:[o.jsxs("h2",{className:"text-2xl font-bold text-white mb-4",children:["Visit ",o.jsx(Is,{suffix:" Lounge",size:"2xl",color:"#4ade80"})]}),o.jsxs("p",{className:"text-white/80 mb-6 flex-1",children:["Our members-only venue in Oklahoma City houses the ",o.jsx(Is,{suffix:" TV",size:"base",color:"#4ade80"})," studios and hosts regular community events. Interested in becoming a member?"]}),o.jsx("button",{className:"bg-white/20 hover:bg-white/30 text-white px-6 py-3 rounded-lg font-semibold transition-colors","data-testid":"button-learn-more",onClick:()=>window.location.href="/membership",children:"Learn About Membership"})]})]}),o.jsx("div",{className:"mt-8",children:o.jsxs("a",{href:"https://www.facebook.com/chroniclounge",target:"_blank",rel:"noopener noreferrer",className:"w-full bg-[hsl(142,76%,45%)] text-black px-6 py-4 rounded-lg font-bold text-lg hover:bg-[hsl(142,76%,55%)] transition-colors flex items-center justify-center gap-2","data-testid":"button-message-us",children:[o.jsx(s4,{size:20}),"Message Us"]})}),o.jsxs("div",{className:"mt-8 bg-[hsl(0,0%,8%)] rounded-2xl p-8 border border-white/10",children:[o.jsx("h2",{className:"text-2xl font-bold text-white mb-4",children:"Business Inquiries"}),o.jsxs("p",{className:"text-white/60 mb-4",children:["Looking to partner with ",o.jsx(Is,{suffix:" Brands",size:"base",color:"#4ade80"})," or interested in our services for your cannabis business? We offer:"]}),o.jsxs("ul",{className:"space-y-2 text-white/60",children:[o.jsxs("li",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[hsl(45,93%,47%)]"}),"Advertising on ",o.jsx(Is,{suffix:" TV",size:"sm",color:"#4ade80"})]}),o.jsxs("li",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[hsl(45,93%,47%)]"}),"Event sponsorship opportunities"]}),o.jsxs("li",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[hsl(45,93%,47%)]"}),"Content production services"]}),o.jsxs("li",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[hsl(45,93%,47%)]"}),"Security and staffing solutions"]})]})]})]})})]})}const zh=n=>n.replace(/^['"]?PT\d{1,2}(am|pm)['"]?\s+/i,"").trim(),yv=n=>{try{const e=new Date(n);return isNaN(e.getTime())?n:e.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0,timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone})}catch{return n}},aN=n=>{if(typeof n=="number")return n;const e=String(n),t=e.match(/(\d+)h/),s=e.match(/(\d+)m/),r=t?parseInt(t[1],10):0,i=s?parseInt(s[1],10):0;if(r>0||i>0)return r*60+i;const a=parseFloat(e);return isNaN(a)?0:a},Iee=n=>{const e=aN(n);if(e===0)return String(n);const t=Math.floor(e/60),s=Math.round(e%60);return t>0?s>0?`${t}h ${s}m`:`${t}h`:`${s}m`},Aee=(n,e)=>{try{const t=new Date(n),s=aN(e);return new Date(t.getTime()+s*60*1e3).toISOString()}catch{return n}},J6=n=>{const e=zh(n.title||""),t=n.scheduledStartTime||n.startTime||n.scheduledTime||"",s=n.scheduledEndTime||n.endTime||"",r=yv(t),i=yv(s||Aee(t,n.duration||0)),a=Iee(n.duration||0);return{id:n.id||e,title:e,startTime:r,endTime:i,duration:a,thumbnailUrl:n.thumbnailUrl||"",videoUrl:n.videoUrl||n.embedUrl||"",embedUrl:n.embedUrl||n.videoUrl||"",channelName:n.channelName||"ChronicTV",status:n.status||(n.isCurrentlyPlaying?"LIVE NOW":""),isCurrentlyPlaying:n.isCurrentlyPlaying||n.status==="LIVE NOW",scheduledTime:t}},Cee=(n=[])=>n.slice(0,5).map(J6),kee=(n=[])=>n.slice(1,5).map(J6),Ree=(n=[])=>n.map(J6);function oN(){if(typeof window>"u")return"web";const n=window.Capacitor?.getPlatform?.();return n==="ios"||n==="android"?n:"web"}function vv(){return oN()!=="web"?!0:typeof navigator>"u"?!1:navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1||/Android|iPhone|iPad|iPod|Mobile/i.test(navigator.userAgent)}function g_({video:n,broadcastTiming:e,onBack:t,onVideoEnd:s,onNearEnd:r}
96){const i=T.useRef(null),a=T.useRef(!1),l=T.useRef(!vv()),c=T.useRef(null),d=T.useRef(null),h=T.useRef(null),p=T.useRef(null),m=T.useRef(null),y=T.useRef(null),[x,w]=T.useState(""),[S,_]=T.useState(!1),[L,R]=T.useState(()=>!vv()),[M,V]=T.useState(!1),[W,I]=T.useState(!0),[k,P]=T.useState(!0),[N,F]=T.useState(0),[z,U]=T.useState(0),[fe,oe]=T.useState(!1),[X,Q]=T.useState(()=>typeof window<"u"?localStorage.getItem("chronicTvCaptionsEnabled")==="true":!1),[G,Y]=T.useState(!1),[ee,H]=T.useState(null),[K,pe]=T.useState("hls"),[Fe,_e]=T.useState(!1),[ze,Ye]=T.useState(null),[tt,lt]=T.useState(!1),[ut,cn]=T.useState(0),ke=T.useRef(0),[Ue,rt]=T.useState(!1),[Ct,at]=T.useState(!1),ft=T.useCallback(()=>{if(ke.current>=1){Ye("Playback source expired. Falling back to the Vimeo player."),_e(!1),H(null),Y(!1);return}ke.current+=1,cn(Ee=>Ee+1)},[]),Nt=T.useCallback(()=>{m.current&&clearTimeout(m.current);const Ee=setTimeout(()=>{I(!1)},4e3);m.current=Ee},[]);T.useEffect(()=>{if(n&&n.id){const Ee=`${n.id}-player`;if(x!==Ee){w(Ee),_(!1),lt(!1),rt(!1),a.current=!1,c.current=null,at(!1),ke.current=0;const He=n.title||n.customTitle||n.extractedTitle||n.name||"Unknown Video";zh(He);const ne=(n.vimeoUrl||n.video_url||n.url||n.videoUrl||n.embedUrl||"").includes("vimeo.com");oe(ne&&!!!e)}}},[n?.id,x]),T.useEffect(()=>{const Ee=oN(),He=Ee==="android"||Ee==="ios",le=new AbortController;d.current&&(d.current.pause(),d.current.removeAttribute("src"),d.current.load()),h.current&&(h.current.destroy(),h.current=null),Y(!1),H(null),lt(!1);const ne=n?.vimeoUrl||n?.videoUrl||n?.embedUrl||"",J=ne.includes("vimeo.com")||/^\d+$/.test(n?.id||""),De=!!e;if(J&&n?.id&&(He||!De)){_e(!0),Ye(null);let Le=n.id;if(ne.includes("vimeo.com")){const Qe=ne.match(/vimeo\.com\/(?:video\/)?(\d+)/);Qe&&(Le=Qe[1])}const Lt=He?"https://chronicbrandsusa.onrender.com":"";performance.now(),fetch(`${Lt}/api/video/${Le}/play`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({deviceId:He?`capacitor-${Ee}`:"web",forceRefresh:ke.current>0,refreshToken:ke.current>0?c.current:void 0}),signal:le.signal}).then(Qe=>{if(!Qe.ok)throw new Error(`Failed to resolve playback source: ${Qe.status}`);return Qe.json()}).then(Qe=>{H(Qe.streamUrl),pe(Qe.streamType||"hls"),c.current=Qe.refreshToken||null,Y(!0),_e(!1)}).catch(Qe=>{Qe?.name!=="AbortError"&&(Ye(Qe.message),Y(!1),_e(!1))})}else Y(!1),H(null),pe("hls");return()=>{le.abort(),h.current&&(h.current.destroy(),h.current=null)}},[n?.id,n?.vimeoUrl,n?.videoUrl,n?.embedUrl,e,ut]),T.useEffect(()=>{if(!G||!ee||!d.current)return;const Ee=d.current;let He=!1;h.current&&(h.current.destroy(),h.current=null);const le=()=>{He||Ee.play().catch(J=>{})};return(async()=>{if(K==="progressive"){Ee.src=ee,Ee.load(),le();return}if(K==="hls"&&Ee.canPlayType("application/vnd.apple.mpegurl")){Ee.src=ee,Ee.load(),le();return}if(K!=="hls"){Ye("This stream format is not supported on this device"),Y(!1);return}try{const{default:J}=await ps(async()=>{const{default:Lt}=await Promise.resolve().then(()=>_ie);return{default:Lt}},void 0);if(He)return;if(!J.isSupported())throw new Error("HLS playback is not supported");const De=new J({enableWorker:!0,lowLatencyMode:!1,startLevel:-1,abrEwmaDefaultEstimate:15e5,maxBufferLength:30,maxMaxBufferLength:60,maxBufferSize:60*1e3*1e3,backBufferLength:30,maxBufferHole:.3,highBufferWatchdogPeriod:1,nudgeOffset:.1,nudgeMaxRetry:8,fragLoadingMaxRetry:8,fragLoadingRetryDelay:300,fragLoadingMaxRetryTimeout:4e3,manifestLoadingMaxRetry:5,manifestLoadingRetryDelay:500,levelLoadingMaxRetry:5,levelLoadingRetryDelay:500,capLevelToPlayerSize:!0,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7});De.loadSource(ee),De.attachMedia(Ee),De.on(J.Events.MANIFEST_PARSED,le);let Le=0;De.on(J.Events.ERROR,(Lt,Qe)=>{if(Qe.fatal)if(Qe.type===J.ErrorTypes.NETWORK_ERROR){const it=Number(Qe.response?.code||0);it===401||it===403||Le>=2?ft():(Le+=1,De.startLoad())}else Qe.type===J.ErrorTypes.MEDIA_ERROR?De.recoverMediaError():(Ye(`Playback error: ${Qe.details}`),Y(!1))}),h.current=De}catch{if(He)return;Ye("HLS playback not supported"),Y(!1)}})(),()=>{He=!0,h.current&&(h.current.destroy(),h.current=null),Ee.removeAttribute("src"),Ee.load()}},[G,ee,K,ft]),T.useEffect(()=>{if(!G||!d.current)return;const Ee=d.current,He=()=>{F(Ee.currentTime),U(Ee.duration||0)},le=()=>{P(!0),lt(!0)},ne=()=>P(!1),J=()=>{P(!1),s&&s()},De=()=>{U(Ee.duration||0)};return Ee.addEventListener("timeupdate",He),Ee.addEventListener("play",le),Ee.addEventListener("pause",ne),Ee.addEventListener("ended",J),Ee.addEventListener("loadedmetadata",De),()=>{Ee.removeEventListener("timeupdate",He),Ee.removeEventListener("play",le),Ee.removeEventListener("pause",ne),Ee.removeEventListener("ended",J),Ee.removeEventListener("loadedmetadata",De)}},[G,s]),T.useEffect(()=>{const Ee=He=>{if(He.detail.pauseVideo&&k)if(P(!1),G&&d.current)d.current.pause();else{const le=i.current;if(le&&le.contentWindow)try{le.contentWindow.postMessage({method:"pause"},"*")}catch{}}};return window.addEventListener("app-background",Ee),()=>window.removeEventListener("app-background",Ee)},[k,G]);const At=T.useCallback(()=>
96{if(!e)return 0;if(e.scheduledStartSeconds!==void 0){const Ee=new Date,He=new Date(Date.UTC(Ee.getUTCFullYear(),Ee.getUTCMonth(),Ee.getUTCDate(),0,0,0,0)),le=Math.floor((Ee.getTime()-He.getTime())/1e3),ne=Math.max(0,le-e.scheduledStartSeconds),J=n?.duration||n?.accurateDurationMinutes*60||0;return J>0?Math.min(ne,Math.max(0,J-1)):ne}return e.elapsedSeconds},[e,n?.duration,n?.accurateDurationMinutes]);T.useEffect(()=>{const Ee=y.current!==null&&y.current!==X;if(y.current=X,n&&e&&x&&(!S||Ee)){const ne=setTimeout(()=>{try{const J=At();if(G&&d.current){d.current.currentTime=J,_(!0);return}const De=i.current;if(De&&De.contentWindow){const Le={method:"setCurrentTime",value:J};De.contentWindow.postMessage(Le,"*"),_(!0)}}catch{}},G?1e3:2e3);return()=>clearTimeout(ne)}},[n?.id,e?.elapsedSeconds,x,X,At,G]);const ot=T.useCallback(async()=>{try{screen.orientation&&"lock"in screen.orientation&&await screen.orientation.lock("landscape")}catch{}},[]),Yt=T.useCallback(async()=>{try{screen.orientation&&"unlock"in screen.orientation&&screen.orientation.unlock()}catch{}},[]);if(T.useEffect(()=>{const Ee=()=>{const J=!!document.fullscreenElement;V(J),J?ot():Yt(),I(!0),Nt()},He=()=>{I(!0),Nt()},le=p.current;return le&&(le.addEventListener("mousemove",He,{passive:!0}),le.addEventListener("click",He),le.addEventListener("touchstart",He,{passive:!0}),le.addEventListener("touchmove",He,{passive:!0}),le.addEventListener("touchend",He,{passive:!0}),le.addEventListener("pointerdown",He,{passive:!0}),le.addEventListener("pointermove",He,{passive:!0})),document.addEventListener("fullscreenchange",Ee),document.addEventListener("keydown",He),Nt(),()=>{le&&(le.removeEventListener("mousemove",He),le.removeEventListener("click",He),le.removeEventListener("touchstart",He),le.removeEventListener("touchmove",He),le.removeEventListener("touchend",He),le.removeEventListener("pointerdown",He),le.removeEventListener("pointermove",He)),document.removeEventListener("fullscreenchange",Ee),document.removeEventListener("keydown",He),m.current&&clearTimeout(m.current)}},[Nt]),T.useEffect(()=>{if(n&&x){const Ee=n.duration||(n.extractedDuration?parseInt(n.extractedDuration):0)||3600;U(Ee),F(0),P(!0)}},[n,x]),T.useEffect(()=>{let Ee;return k&&z>0&&N>0&&(Ee=setInterval(()=>{N>=z-2&&(P(!1),s&&s())},2e3)),()=>{Ee&&clearInterval(Ee)}},[k,z,N,s]),T.useEffect(()=>{if(!e||!e.scheduledStartSeconds||!n?.duration)return;const Ee=n.duration||n.accurateDurationMinutes*60||0;if(Ee<=0)return;let He,le=!1;const ne=()=>{if(le)return;const J=new Date,De=new Date(Date.UTC(J.getUTCFullYear(),J.getUTCMonth(),J.getUTCDate(),0,0,0,0)),Le=Math.floor((J.getTime()-De.getTime())/1e3),Lt=e.scheduledStartSeconds+Ee;Le>=Lt-3&&(le=!0,P(!1),s&&s())};return He=setInterval(ne,3e3),ne(),()=>{He&&clearInterval(He)}},[e?.scheduledStartSeconds,n?.duration,n?.accurateDurationMinutes,s]),T.useEffect(()=>{k&&z>0&&N>0&&!Ct&&r&&N>=z-7&&N<z-2&&(at(!0),r())},[k,z,N,Ct,r]),T.useEffect(()=>{l.current=L},[L]),T.useEffect(()=>{if(L)return;const Ee=()=>{if(!L){if(d.current){d.current.muted=!1,d.current.volume=1,d.current.play().catch(()=>{}),R(!0);return}if(i.current&&i.current.contentWindow)try{if(!a.current)return;const le={method:"setVolume",value:1};i.current.contentWindow.postMessage(le,"https://player.vimeo.com"),R(!0)}catch{}}},He=["click","touchstart","keydown"];return He.forEach(le=>{document.addEventListener(le,Ee,{passive:!0})}),()=>{He.forEach(le=>{document.removeEventListener(le,Ee)})}},[L]),T.useEffect(()=>{const He=setTimeout(()=>{const le=i.current;if(le&&le.contentWindow)try{X?le.contentWindow.postMessage({method:"enableTextTrack",value:{language:"en",kind:"captions"}},"*"):le.contentWindow.postMessage({method:"disableTextTrack"},"*"),localStorage.setItem("chronicTvCaptionsEnabled",X?"true":"false")}catch{}},1500);return()=>clearTimeout(He)},[X,x]),T.useEffect(()=>{const Ee=ne=>{if(ne.origin!=="https://player.vimeo.com"||ne.source!==i.current?.contentWindow)return;const J=ne.data,De=()=>{a.current=!0,rt(!0)};J.event==="ready"&&De(),J.event==="timeupdate"&&(F(J.data.seconds),U(J.data.duration),a.current||De()),J.event==="play"&&(P(!0),a.current||De()),J.event==="pause"&&P(!1),J.event==="ended"&&(P(!1),s&&s()),J.method==="getDuration"&&U(J.value)};window.addEventListener("message",Ee);const He=setTimeout(()=>{const ne=i.current;ne&&ne.contentWindow&&(ne.contentWindow.postMessage({method:"setVolume",value:l.current?1:0},"https://player.vimeo.com"),ne.contentWindow.postMessage({method:"getDuration"},"*"),ne.contentWindow.postMessage({method:"addEventListener",value:"timeupdate"},"*"),ne.contentWindow.postMessage({method:"addEventListener",value:"play"},"*"),ne.contentWindow.postMessage({method:"addEventListener",value:"pause"},"*"),ne.contentWindow.postMessage({method:"addEventListener",value:"ended"},"*"),ne.contentWindow.postMessage({method:"addEventListener",value:"ready"},"*"))},1e3),le=setTimeout(()=>{Ue||rt(!0)},5e3);return()=>{window.removeEventListener("message",Ee),clearTimeout(He),clearTimeout(le)}},[x,s,Ue]),!n)return o.jsx("div",{ref:p,style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"#1f2937",aspectRatio:"16/9"},children:o.jsx("p",{style:{color:"#9ca3af"},children:"Loading video..."})});
96const zt=!!e,wn=()=>{let Ee="";const He=vv();if(zt?Ee=n.videoUrl||n.embedUrl||n.vimeoUrl||"":n.embedUrl&&n.embedUrl.includes("youtube.com/embed/")?Ee=n.embedUrl.replace("youtube.com","youtube-nocookie.com"):n.embedUrl&&n.embedUrl.startsWith("/embed/youtube-")?Ee=typeof window<"u"&&"Capacitor"in window&&window.Capacitor?.isNativePlatform?.()?`https://chronicbrandsusa.onrender.com${n.embedUrl}`:n.embedUrl:Ee=n.vimeoUrl||n.videoUrl||n.embedUrl||n.sourceUrl||"",!Ee)return"";if(Ee.includes("/hls.m3u8")||Ee.includes("/play/"))try{const le=Ee.match(/\/play\/([a-f0-9-]+)\/hls\.m3u8/);if(le){const ne=le[1];Ee=`https://player.vimeo.com/video/${n.id||ne}`}else Ee=`https://player.vimeo.com/video/${n.id}`}catch{Ee=`https://player.vimeo.com/video/${n.id}`}try{const le=new URL(Ee);if(zt)le.searchParams.set("controls","0"),le.searchParams.set("autoplay","1"),le.searchParams.set("muted",He?"1":"0"),le.searchParams.set("title","0"),le.searchParams.set("byline","0"),le.searchParams.set("portrait","0"),le.searchParams.set("dnt","1"),le.searchParams.set("playsinline","1"),le.searchParams.set("background","0"),le.searchParams.set("loop","0"),le.searchParams.set("autopause","0"),le.searchParams.set("preload","metadata"),le.searchParams.set("responsive","1"),le.searchParams.set("speed","1"),le.searchParams.set("pip","0"),le.searchParams.set("keyboard","0"),le.searchParams.set("transparent","0"),le.searchParams.set("color","000000"),X&&le.searchParams.set("texttrack","en");else{if(le.hostname.includes("vimeo.com")){if(le.hostname==="vimeo.com"){const Le=le.pathname.split("/").filter(Boolean)[0];Le&&/^\d+$/.test(Le)&&(le.hostname="player.vimeo.com",le.pathname=`/video/${Le}`)}else le.hostname.includes("player.vimeo.com");le.searchParams.set("controls","1"),le.searchParams.set("title","0"),le.searchParams.set("byline","0"),le.searchParams.set("portrait","0"),le.searchParams.set("dnt","1"),le.searchParams.set("playsinline","1"),le.searchParams.set("background","0"),le.searchParams.set("loop","0"),le.searchParams.set("pip","1"),le.searchParams.set("sidedock","0"),le.searchParams.set("badge","0"),le.searchParams.set("speed","0"),le.searchParams.set("keyboard","0"),le.searchParams.set("preload","metadata"),le.searchParams.set("responsive","1"),le.searchParams.set("transparent","0"),le.searchParams.set("color","4ade80")}else le.searchParams.set("controls","1"),le.hostname.includes("youtube.com")&&(le.searchParams.set("rel","0"),le.searchParams.set("modestbranding","1"),le.searchParams.set("playsinline","1"),le.searchParams.set("iv_load_policy","3"),le.searchParams.set("autoplay","1"));le.hostname.includes("youtube.com")||(le.searchParams.set("autoplay","1"),le.searchParams.set("muted",He?"1":"0"),le.searchParams.set("autopause","0"))}return le.toString()}catch{return Ee}},Dt=T.useMemo(()=>wn(),[n?.id,n?.videoUrl,n?.embedUrl,zt,fe,X]);return!zt&&!Dt?o.jsxs("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",background:"linear-gradient(135deg, #2a2a2a 0%, #1a1a1a 100%)",color:"#4CAF50",fontSize:"18px",fontWeight:"bold",flexDirection:"column",gap:"12px",border:"2px dashed #4CAF50",borderRadius:"8px"},children:[o.jsx("div",{style:{fontSize:"48px"},children:"ð¬"}),o.jsx("div",{children:zh(n.customTitle||n.extractedTitle||n.title||"Movie")}),o.jsx("div",{style:{fontSize:"14px",color:"#888",textAlign:"center",maxWidth:"300px"},children:"This movie will be available when proper streaming links are configured"}),o.jsx("div",{style:{fontSize:"12px",color:"#666",textAlign:"center",backgroundColor:"rgba(76, 175, 80, 0.1)",padding:"8px 12px",borderRadius:"4px",marginTop:"8px"},children:'ð Content Manager: Update URL in Google Drive "ChronicTV Movies" document'})]}):o.jsxs("div",{ref:p,style:{position:"relative",width:"100%",height:zt?"100%":"0",paddingBottom:zt?"0":"56.25%",backgroundColor:"#000",overflow:"hidden",WebkitTapHighlightColor:"transparent",touchAction:"auto"},children:[G&&ee&&o.jsx("video",{ref:d,playsInline:!0,autoPlay:!0,muted:!L,preload:"metadata",controls:!zt,onError:ft,style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",objectFit:"contain",backgroundColor:"#000",zIndex:1},"data-testid":"native-video-player"},`native-${x}`),(Fe||G&&ee&&!tt)&&o.jsxs("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",backgroundColor:"#000",zIndex:2,backgroundImage:n.thumbnailUrl?`url(${n.thumbnailUrl})`:"none",backgroundSize:"cover",backgroundPosition:"center"},children:[o.jsx("div",{style:{position:"absolute",inset:0,backgroundColor:"rgba(0, 0, 0, 0.6)"}}),o.jsxs("div",{style:{position:"relative",zIndex:1,textAlign:"center"},children:[o.jsx("img",{src:"/assets/ChronicTVlogo2b.png",alt:"ChronicTV",style:{width:"120px",height:"auto",marginBottom:"16
96px"},onError:Ee=>{Ee.target.style.display="none"}}),o.jsxs("div",{style:{color:"#4ade80",fontSize:"14px",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:[o.jsx("div",{style:{width:"16px",height:"16px",border:"2px solid #4ade80",borderTopColor:"transparent",borderRadius:"50%",animation:"spin 1s linear infinite"}}),"Loading..."]})]})]}),ze&&!G&&o.jsx("div",{style:{display:"none"}}),!G&&!Fe&&o.jsx("iframe",{ref:i,src:Dt,title:zh(n.customTitle||n.extractedTitle||n.title||""),allow:"autoplay; fullscreen; picture-in-picture; encrypted-media",allowFullScreen:!0,referrerPolicy:"strict-origin-when-cross-origin",style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",border:"none",zIndex:1},"data-testid":"iframe-video-player"},x),!G&&!Fe&&!Ue&&o.jsxs("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",backgroundColor:"#000",zIndex:3,backgroundImage:n.thumbnailUrl?`url(${n.thumbnailUrl})`:"none",backgroundSize:"cover",backgroundPosition:"center"},children:[o.jsx("div",{style:{position:"absolute",inset:0,backgroundColor:"rgba(0, 0, 0, 0.6)"}}),o.jsxs("div",{style:{position:"relative",zIndex:1,textAlign:"center"},children:[o.jsx("img",{src:"/assets/ChronicTVlogo2b.png",alt:"ChronicTV",style:{width:"120px",height:"auto",marginBottom:"16px"},onError:Ee=>{Ee.target.style.display="none"}}),o.jsxs("div",{style:{color:"#4ade80",fontSize:"14px",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:[o.jsx("div",{style:{width:"16px",height:"16px",border:"2px solid #4ade80",borderTopColor:"transparent",borderRadius:"50%",animation:"spin 1s linear infinite"}}),"Loading..."]})]})]}),t&&!zt&&o.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",opacity:!fe||W?1:0,transition:"opacity 0.3s ease"},children:o.jsx("button",{onClick:Ee=>{Ee.preventDefault(),Ee.stopPropagation(),t()},onTouchStart:Ee=>{Ee.preventDefault(),Ee.stopPropagation();const He=Ee.target;He.style.opacity="1",He.style.transform="scale(1.1)"},onTouchEnd:Ee=>{Ee.preventDefault(),Ee.stopPropagation();const He=Ee.target;He.style.opacity="0.9",He.style.transform="scale(1)",setTimeout(()=>{t()},100)},style:{position:"absolute",top:Dt?.includes("youtube.com")?"60px":"16px",left:"16px",backgroundColor:"rgba(0, 0, 0, 0.7)",border:"none",borderRadius:"50%",color:"white",padding:"12px",cursor:"pointer",pointerEvents:"auto",zIndex:2e3,opacity:.9,transition:"all 0.2s ease",display:"flex",alignItems:"center",justifyContent:"center",touchAction:"manipulation",WebkitTapHighlightColor:"transparent",userSelect:"none",WebkitUserSelect:"none"},onMouseEnter:Ee=>{const He=Ee.target;He.style.opacity="1",He.style.transform="scale(1.1)"},onMouseLeave:Ee=>{const He=Ee.target;He.style.opacity="0.9",He.style.transform="scale(1)"},children:o.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:o.jsx("path",{d:"M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"})})})}),zt&&o.jsx("button",{"data-testid":"button-cc-toggle",onClick:()=>{Q(!X)},style:{position:"absolute",bottom:"16px",left:"16px",backgroundColor:"rgba(0, 0, 0, 0.5)",border:"none",borderRadius:"4px",color:X?"#4ade80":"white",padding:"8px",cursor:"pointer",pointerEvents:"auto",opacity:.8,transition:"all 0.3s ease",zIndex:1001},onMouseEnter:Ee=>Ee.target.style.opacity="1",onMouseLeave:Ee=>Ee.target.style.opacity="0.8",children:o.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),o.jsx("text",{x:"6",y:"15",fontSize:"8",fill:"currentColor",stroke:"none",fontFamily:"Arial",fontWeight:"bold",children:"CC"})]})}),zt&&o.jsx("button",{onClick:async()=>{if(p.current)try{M?(await document.exitFullscreen(),t&&zt&&t()):await p.current.requestFullscreen()}catch{}},style:{position:"absolute",bottom:"16px",right:"16px",backgroundColor:"rgba(0, 0, 0, 0.5)",border:"none",borderRadius:M?"50%":"4px",color:"white",padding:M?"12px":"8px",cursor:"pointer",pointerEvents:"auto",opacity:.8,transition:"all 0.3s ease",zIndex:1001},onMouseEnter:Ee=>Ee.target.style.opacity="1",onMouseLeave:Ee=>Ee.target.style.opacity="0.8",children:M?o.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"
96currentColor",children:o.jsx("path",{d:"M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z"})}):o.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor",children:o.jsx("path",{d:"M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"})})})]})}const Uu=10;function Pee(n){if(!n)return"";try{const e=n?.toDate?n.toDate():new Date(n._seconds?n._seconds*1e3:n),t=Math.floor((Date.now()-e.getTime())/1e3);return t<60?"just now":t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:t<604800?`${Math.floor(t/86400)}d ago`:t<2592e3?`${Math.floor(t/604800)}w ago`:e.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return""}}function Nee(n){return n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}K`:String(n)}function x_({photoUrl:n,name:e,size:t=36}){const s=(e||"M")[0].toUpperCase();if(n)return o.jsx("img",{src:n,alt:e,style:{width:t,height:t,borderRadius:"50%",flexShrink:0,objectFit:"cover"}});const r=["#4ade80","#60a5fa","#f472b6","#fb923c","#a78bfa","#34d399"],i=s.charCodeAt(0)%r.length;return o.jsx("div",{style:{width:t,height:t,borderRadius:"50%",background:r[i]+"33",border:`1.5px solid ${r[i]}55`,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",fontSize:Math.floor(t*.38),fontWeight:"700",color:r[i]},children:s})}function Lee({videoId:n,firebaseUser:e,onSignInPrompt:t}){const[s,r]=T.useState([]),[i,a]=T.useState({likes:0,dislikes:0}),[l,c]=T.useState(null),[d,h]=T.useState(!0),[p,m]=T.useState(!1),[y,x]=T.useState(!1),[w,S]=T.useState(""),[_,L]=T.useState(!1),[R,M]=T.useState(null),[V,W]=T.useState(Uu),I=T.useCallback(async()=>{if(!e)return null;try{return await e.getIdToken()}catch{return null}},[e]),k=T.useCallback(async(Q,G={})=>{const Y=await I();return Y?fetch(Q,{...G,headers:{"Content-Type":"application/json",Authorization:`Bearer ${Y}`,...G.headers||{}}}):null},[I]),P=T.useCallback(async()=>{if(!e){h(!1);return}h(!0);try{const Q=await k(`/api/videos/${n}/comments?limit=100`);if(!Q||!Q.ok)throw new Error("Failed");const G=await Q.json();r(G.comments||[]),a(G.reactions||{likes:0,dislikes:0}),c(G.userReaction||null)}catch{M("Could not load comments.")}finally{h(!1)}},[n,e,k]);T.useEffect(()=>{W(Uu),S(""),L(!1),M(null),P()},[P]);async function N(Q){if(!e){t();return}if(!y){x(!0);try{const G=await k(`/api/videos/${n}/react`,{method:"POST",body:JSON.stringify({reaction:Q})});if(!G||!G.ok)return;const Y=await G.json();a({likes:Y.likes,dislikes:Y.dislikes}),c(Y.userReaction)}finally{x(!1)}}}async function F(){if(!e){t();return}const Q=w.trim();if(!(!Q||p)){m(!0),M(null);try{const G=await k(`/api/videos/${n}/comments`,{method:"POST",body:JSON.stringify({text:Q})});if(!G)return;if(!G.ok){const ee=await G.json();M(ee.error||"Failed to post comment.");return}const Y=await G.json();r(ee=>[Y.comment,...ee]),S(""),L(!1),W(ee=>Math.max(ee,Uu))}finally{m(!1)}}}async function z(Q){(await k(`/api/videos/${n}/comments/${Q}`,{method:"DELETE"}))?.ok&&r(Y=>Y.filter(ee=>ee.id!==Q))}const U=1e3-w.length,fe=U<0,oe=s.slice(0,V),X=s.length-V;return o.jsxs("div",{children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",paddingBottom:"20px",borderBottom:"1px solid rgba(255,255,255,0.08)",marginBottom:"24px"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",background:"rgba(255,255,255,0.08)",borderRadius:"20px",overflow:"hidden"},children:[o.jsxs("button",{onClick:()=>N("like"),disabled:y,title:e?"Like":"Sign in to like",style:{display:"flex",alignItems:"center",gap:"6px",padding:"8px 16px",border:"none",background:l==="like"?"rgba(74,222,128,0.25)":"transparent",color:l==="like"?"#4ade80":"#e0e0e0",cursor:y?"default":"pointer",fontSize:"14px",fontWeight:"600",transition:"all 0.15s",borderRight:"1px solid rgba(255,255,255,0.1)"},children:[o.jsx(BF,{size:16,fill:l==="like"?"#4ade80":"none",strokeWidth:1.5}),Nee(i.likes)]}),o.jsx("button",{onClick:()=>N("dislike"),disabled:y,title:e?"Dislike":"Sign in to dislike",style:{display:"flex",alignItems:"center",gap:"6px",padding:"8px 14px",border:"none",background:l==="dislike"?"rgba(248,113,113,0.15)":"transparent",color:l==="dislike"?"#f87171":"#aaa",cursor:y?"default":"pointer",fontSize:"14px",fontWeight:"600",transition:"all 0.15s"},children:o.jsx(VF,{size:16,fill:l==="dislike"?"#f87171":"none",strokeWidth:1.5})})]}),!e&&o.jsx("span",{style:{fontSize:"12px",color:"#555",marginLeft:"4px"},children:"Sign in to react"})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",marginBottom:"20px"},children:[o.jsx(_T,{size:18,color:"#4ade80"}),o.jsx("h3",{style:{fontSize:"16px",fontWeight:"700",color:"white",margin:0},children:s.length>0?`${s.length} Comment${s.length!==1?"s":""}`:"Comments"})]}),!e&&o.jsxs("button",{onClick:t,style:{width:"100%",background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:"12px",padding:"18px",display:"flex",alignItems:"center",justifyContent:"center",gap:"10px",color:"#888",cursor:"pointer",fontSize:"14px",marginBottom:"20px",transition:"background 0.15s"},onMouseEnter:Q=>Q.currentTarget.style.background="rgba(255,255,255,0.07)",onMouseLeave:Q=>Q.currentTarget.style.background="rgba(255,255,255,0.04)",children:[o.jsx(Gh,{size:15,color:"#4ade80"}),"Sign in to view and post comments"]}),e&&o.jsxs("div",{style:{display:"flex",gap:"12px",marginBottom:"24px",alignItems:"flex-start"},children:[o.jsx(x_,{photoUrl:e.photoURL,name:e.displayName||e.email||"M",size:38}),o.jsxs("div",{style:{flex:1},children:[o.jsx("textarea",{value:w,onChange:Q=>S(Q.target.value),onFocus:()=>L(!0),onKeyDown:Q=>{Q.key==="Enter"&&(Q.ctrlKey||Q.metaKey)&&F()},placeholder:"Add a commentâ¦",maxLength:1050,rows:_?3:1,style:{width:"100%",background:"transparent",border:"none",borderBottom:`2px solid ${_?"#4ade80":"rgba(255,255,255,0.2)"}`,borderRadius:0,padding:"6px 0",color:"white",fontSize:"14px",resize:"none",outline:"none",boxSizing:"border-box",lineHeight:1.5,fontFamily:"inherit",transition:"border-color 0.2s, rows 0.2s"}}),_&&o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:"10px"},children:[o.jsx("span",{style:{fontSize:"12px",color:fe?"#f87171":"#555"},children:U<200?`${U} chars left`:""}),o.jsxs("div",{style:{display:"flex",gap:"8px"},children:[o.jsx("button",{onClick:()=>{L(!1),S("")},style:{background:"transparent",border:"none",borderRadius:"20px",padding:"8px 16px",color:"#aaa",cursor:"pointer",fontSize:"13px",fontWeight:"600"},children:"Cancel"}),o.jsxs("button",{onClick:F,disabled:p||!w.trim()||fe,style:{display:"flex",alignItems:"center",gap:"6px",background:p||!w.trim()||fe?"rgba(74,222,128,0.25)":"#4ade80",border:"none",borderRadius:"20px",padding:"8px 18px",color:p||!w.trim()||fe?"#4ade80":"#000",cursor:p||
96!w.trim()||fe?"default":"pointer",fontSize:"13px",fontWeight:"700",transition:"all 0.15s"},children:[p?o.jsx(Nn,{size:13,className:"animate-spin"}):o.jsx(s4,{size:13}),p?"Postingâ¦":"Comment"]})]})]}),R&&o.jsx("p",{style:{fontSize:"13px",color:"#f87171",marginTop:"8px"},children:R})]})]}),d&&e&&o.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"32px 0"},children:o.jsx(Nn,{size:22,color:"#4ade80",className:"animate-spin"})}),!d&&e&&s.length===0&&o.jsxs("div",{style:{textAlign:"center",padding:"32px 0"},children:[o.jsx(_T,{size:32,color:"#333",style:{marginBottom:"12px"}}),o.jsx("p",{style:{color:"#555",fontSize:"14px",margin:0},children:"No comments yet. Be the first!"})]}),!d&&oe.map(Q=>o.jsxs("div",{style:{display:"flex",gap:"12px",marginBottom:"20px",alignItems:"flex-start"},children:[o.jsx(x_,{photoUrl:Q.photoUrl,name:Q.displayName,size:36}),o.jsxs("div",{style:{flex:1,minWidth:0},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"4px",flexWrap:"wrap"},children:[o.jsx("span",{style:{fontSize:"13px",fontWeight:"600",color:"#e8e8e8"},children:Q.displayName}),o.jsx("span",{style:{fontSize:"12px",color:"#4a4a4a"},children:Pee(Q.createdAt)})]}),o.jsx("p",{style:{fontSize:"14px",color:"#c8c8c8",margin:0,lineHeight:1.65,wordBreak:"break-word",whiteSpace:"pre-wrap"},children:Q.text})]}),e&&Q.userId===e.uid&&o.jsx("button",{onClick:()=>z(Q.id),title:"Delete",style:{background:"none",border:"none",cursor:"pointer",padding:"4px 2px",color:"#3a3a3a",flexShrink:0,transition:"color 0.15s"},onMouseEnter:G=>G.currentTarget.style.color="#f87171",onMouseLeave:G=>G.currentTarget.style.color="#3a3a3a",children:o.jsx(Kp,{size:14})})]},Q.id)),!d&&X>0&&o.jsxs("button",{onClick:()=>W(Q=>Q+Uu),style:{width:"100%",background:"transparent",border:"1px solid rgba(255,255,255,0.1)",borderRadius:"8px",padding:"12px",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",color:"#4ade80",cursor:"pointer",fontSize:"13px",fontWeight:"600",marginTop:"4px",marginBottom:"8px",transition:"background 0.15s"},onMouseEnter:Q=>Q.currentTarget.style.background="rgba(74,222,128,0.07)",onMouseLeave:Q=>Q.currentTarget.style.background="transparent",children:[o.jsx(ao,{size:16}),"Show ",Math.min(X,Uu)," more comment",Math.min(X,Uu)!==1?"s":"",X>Uu?` (${X} remaining)`:""]})]})}function Dee({logoUrl:n}){const t=typeof window<"u"&&"Capacitor"in window?"https://chronicbrandsusa.onrender.com/assets/ChronicTV2_splash.png":lo("/assets/ChronicTV2_splash.png"),[s,r]=Tn.useState(!1);return o.jsxs("div",{style:{minHeight:"100vh",backgroundColor:"#000000",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},children:[o.jsxs("div",{style:{position:"relative",marginBottom:"40px"},children:[o.jsx("img",{src:n||t,alt:"ChronicTV Logo",style:{width:"320px",height:"auto",objectFit:"contain",borderRadius:"8px",boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)",display:s?"none":"block"},onError:i=>{const a=i.target;a.src!==t?a.src=t:r(!0)}}),s&&o.jsx("div",{style:{width:"320px",height:"180px",backgroundColor:"#1a1a1a",border:"2px solid #4ade80",borderRadius:"8px",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"},children:o.jsx("h1",{style:{color:"#4ade80",fontSize:"28px",fontWeight:"bold",margin:0,textAlign:"center",fontFamily:"system-ui, -apple-system, sans-serif"},children:"ChronicTV"})})]}),o.jsx("div",{children:o.jsx("p",{style:{color:"#ffffff",fontSize:"18px",fontWeight:"500",textAlign:"center",margin:0},children:"Premium Culture, Content, and Creativity"})})]})}const jee=n=>`/api/audio-stream/${n.id}`;function Oee({album:n,onClose:e}){const[t,s]=T.useState(!1),[r,i]=T.useState(0),[a,l]=T.useState(0),[c,d]=T.useState(0),[h,p]=T.useState(!1),[m,y]=T.useState("off"),[x,w]=T.useState(!1),S=T.useRef(null),_=T.useRef(null),L=T.useRef(null),R=T.useRef(null),[M,V]=T.useState(!1),W=n.tracks[r],I=()=>{y(m==="off"?"all":m==="all"?"one":"off")},k=()=>{if(x){const K=n.tracks.map((pe,Fe)=>Fe).filter(pe=>pe!==r);return K.length===0?m!=="off"?0:null:K[Math.floor(Math.random()*K.length)]}return r<n.tracks.length-1?r+1:m==="all"?0:null};T.useEffect(()=>{if(S.current&&W?.id){const K=jee(W);S.current.src=K,S.current.load(),t&&S.current.play().catch(pe=>{})}},[r,W?.id]),T.useEffect(()=>{if(_.current&&r>=0){const K=_.current.querySelector(`[data-track-index="${r}"]`);K&&K.scrollIntoView({behavior:"smooth",block:"center"})}},[r]),T.useEffect(()=>{if(n.youtubePlaylistId&&n.tracks.length>0){if(window.YT&&window.YT.Player){V(!0);return}if(!document.getElementById("youtube-iframe-api")){const K=document.createElement("script");K.id="youtube-iframe-api",K.src="https://www.youtube.com/iframe_api",document.head.appendChild(K)}window.onYouTubeIframeAPIReady=()=>{V(!0)}}},[n.youtubePlaylistId,n.tracks.length]),T.useEffect(()=>{if(!M||!n.youtubePlaylistId||n.tracks.length===0||!W?.audioUrl?.startsWith("youtube:"))return;const K=W.audioUrl.replace("youtube:",""),pe=_e=>{if(_e.data===window.YT.PlayerState.ENDED)if(m==="one")L.current?.seekTo(0),L.current?.playVideo();else{const ze=k();ze!==null&&i(ze)}else _e.data===window.YT.PlayerState.PLAYING?s(!0):_e.data===window.YT.PlayerState.PAUSED&&s(!1)};L.current&&(L.current.destroy(),L.current=null);const Fe=setTimeout(()=>
96{R.current&&window.YT?.Player&&(L.current=new window.YT.Player(R.current,{videoId:K,playerVars:{autoplay:1,rel:0,playsinline:1,modestbranding:1},events:{onStateChange:pe}}))},100);return()=>{clearTimeout(Fe),L.current&&(L.current.destroy(),L.current=null)}},[M,r,W?.audioUrl,m,x]);const P=()=>{L.current&&(t?L.current.pauseVideo():L.current.playVideo())},N=()=>{const K=k();K!==null&&i(K)},F=()=>{r>0?i(r-1):m==="all"&&i(n.tracks.length-1)};T.useEffect(()=>("mediaSession"in navigator&&W&&(navigator.mediaSession.metadata=new MediaMetadata({title:W.title,artist:n.name,album:n.name,artwork:n.coverUrl?[{src:n.coverUrl,sizes:"512x512",type:"image/png"}]:[]}),navigator.mediaSession.setActionHandler("play",()=>{S.current?.play(),s(!0)}),navigator.mediaSession.setActionHandler("pause",()=>{S.current?.pause(),s(!1)}),navigator.mediaSession.setActionHandler("previoustrack",()=>{fe()}),navigator.mediaSession.setActionHandler("nexttrack",()=>{U()}),navigator.mediaSession.setActionHandler("seekto",K=>{S.current&&K.seekTime!==void 0&&(S.current.currentTime=K.seekTime,l(K.seekTime))})),()=>{"mediaSession"in navigator&&(navigator.mediaSession.setActionHandler("play",null),navigator.mediaSession.setActionHandler("pause",null),navigator.mediaSession.setActionHandler("previoustrack",null),navigator.mediaSession.setActionHandler("nexttrack",null),navigator.mediaSession.setActionHandler("seekto",null))}),[W,n]),T.useEffect(()=>{"mediaSession"in navigator&&(navigator.mediaSession.playbackState=t?"playing":"paused")},[t]),T.useEffect(()=>{if("mediaSession"in navigator&&"setPositionState"in navigator.mediaSession&&c>0)try{navigator.mediaSession.setPositionState({duration:c,playbackRate:1,position:a})}catch{}},[a,c]);const z=()=>{S.current&&(t?S.current.pause():S.current.play().catch(console.error),s(!t))},U=()=>{const K=k();K!==null&&i(K)},fe=()=>{r>0?i(r-1):m==="all"&&i(n.tracks.length-1)},oe=K=>{i(K),s(!0)},X=K=>{const pe=Math.floor(K/60),Fe=Math.floor(K%60);return`${pe}:${Fe.toString().padStart(2,"0")}`},Q=()=>{S.current&&(l(S.current.currentTime),d(S.current.duration||0))},G=()=>{if(S.current&&W){const K=S.current.duration;d(K||0),W.durationSeconds===0&&K>0&&fetch(`/api/audio-tracks/${W.id}/duration`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({durationSeconds:K})}).catch(pe=>{})}},Y=K=>{const pe=parseFloat(K.target.value);S.current&&(S.current.currentTime=pe,l(pe))},ee=async()=>{try{const K=n.name.replace(/\s+/g,"-").toLowerCase(),pe=`${window.location.origin}/album/${encodeURIComponent(K)}/${n.id}`;navigator.share?await navigator.share({title:`${n.name} - ChronicTV`,text:`Listen to ${n.name} on ChronicTV`,url:pe}):(await navigator.clipboard.writeText(pe),alert("Link copied to clipboard!"))}catch{}},H=()=>{if(m==="one"){S.current&&(S.current.currentTime=0,S.current.play().catch(console.error));return}const K=k();K!==null?i(K):s(!1)};return o.jsxs("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"linear-gradient(180deg, #1a1a1a 0%, #0a0a0a 100%)",zIndex:9999,display:"flex",flexDirection:"column",color:"white",paddingTop:"env(safe-area-inset-top, 0px)",paddingBottom:"env(safe-area-inset-bottom, 0px)",paddingLeft:"env(safe-area-inset-left, 0px)",paddingRight:"env(safe-area-inset-right, 0px)",overflow:"hidden"},"data-testid":"audio-player-modal",children:[o.jsx("audio",{ref:S,onTimeUpdate:Q,onLoadedMetadata:G,onEnded:H,onPlay:()=>s(!0),onPause:()=>s(!1)}),o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"12px 16px",borderBottom:"1px solid #333",flexShrink:0},children:[o.jsx("button",{onClick:e,style:{background:"transparent",border:"none",color:"white",cursor:"pointer",padding:"8px",display:"flex",alignItems:"center",justifyContent:"center"},"data-testid":"button-close-player",children:o.jsx(Mr,{size:22})}),o.jsx("h2",{style:{fontSize:"14px",fontWeight:"bold",margin:0,textAlign:"center",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",padding:"0 8px"},children:n.name}),o.jsx("button",{onClick:ee,style:{background:"transparent",border:"none",color:"white",cursor:"pointer",padding:"8px",display:"flex",alignItems:"center",justifyContent:"center"},"data-testid":"button-share",children:o.jsx(Jc,{size:22})})]}),n.youtubePlaylistId&&n.tracks.length>0?o.jsxs("div",{style:{display:"flex",flexDirection:"column",flex:1,overflow:"hidden",minHeight:0},children:[o.jsxs("div",{style:{flexShrink:0,padding:"16px",background:"#151515"},children:[o.jsx("div",{style:{width:"100%",aspectRatio:"16/9",maxHeight:"200px",borderRadius:"12px",overflow:"hidden",background:"#000",marginBottom:"12px"},children:W?.audioUrl?.startsWith("youtube:")&&M?o.jsx("div",{ref:R,style:{width:"100%",height:"100%"},"data-testid":"youtube-video-embed"}):o.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",background:n.coverUrl?`url(${n.coverUrl}) center/cover`:"#222"},children:o.jsx(Bc,{size:48,color:"#fff"})})}),o.jsx("h3",{style:{fontSize:"14px",fontWeight:"bold",margin:"0 0 4px 0",color:"#ff0000",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:W?.title||"Select a track"}),o.jsxs("p",{style:{fontSize:"12px",color:"#888",margin:"0 0 12px 0"},children:["Track ",r+1," of ",n.tracks.length," ⢠YouTube Music"]}),o.jsxs("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",gap:"16px",paddingBottom:"8px"},children:[o.jsx("button",{onClick:()=>w(!x),style:{background:"transparent",border:"none",color:x?"#ff0000":"#666",cursor:"pointer",padding:"8px",display:"flex",alignItems:"center",justifyContent:"center"},"data-testid":"button-yt-shuffle",title:x?"Shuffle On":"Shuffle Off",children:o.jsx(yb,{size:20})}),o.jsx("button",{onClick:F,disabled:r===0&&m!=="all",style:{background:"transparent",border:"none",color:r===0&&m!=="all"?"#444":"white",cursor:r===0&&m!=="all"?"not-allowed":"pointer",padding:"8px",display:"flex",alignItems:"center",justifyContent:"center"},"data-testid":"button-yt-previous",children:o.jsx(RT,{size:24})}),o.jsx("button",{onClick:P,style:{background:"#ff0000",border:"none",borderRadius:"50%",width:"48px",height:"48px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",flexShrink:0},"data-testid":"button-yt-play-pause",children:t?o.jsx(IT,{size:24,color:"white"}):o.jsx(Bc,{size:24,color:"white",style:{marginLeft:"2px"}})}),o.jsx("button",{onClick:N,disabled:r===n.tracks.length-1&&m==="off"&&!x,style:{background:"transparent",border:"none",color:r===n.tracks.length-1&&m==="off"&&!x?"#444":"white",cursor:r===n.tracks.length-1&&m==="off"&&!x?"not-allowed":"pointer",padding:"8px",display:"flex",alignItems:"center",justifyContent:"center"},"data-testid":"button-yt-next",children:o.jsx(PT,{size:24})}),o.jsx("button",{onClick:I,style:{background:"transparent",border:"none",color:m!=="off"?"#ff0000":"#666",cursor:"pointer",padding:"8px",display:"flex",alignItems:"center",justifyContent:"center"}
96,"data-testid":"button-yt-repeat",title:m==="off"?"Repeat Off":m==="all"?"Repeat All":"Repeat One",children:m==="one"?o.jsx(AT,{size:20}):o.jsx(CT,{size:20})})]})]}),o.jsxs("div",{ref:_,style:{flex:1,overflowY:"auto",WebkitOverflowScrolling:"touch",minHeight:0},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"12px 16px 8px",position:"sticky",top:0,background:"linear-gradient(180deg, #0a0a0a 0%, rgba(10,10,10,0.95) 100%)",zIndex:1},children:[o.jsx("h4",{style:{fontSize:"13px",fontWeight:"bold",margin:0,color:"#888"},children:"Tracks"}),o.jsxs("span",{style:{fontSize:"12px",color:"#666"},children:[n.tracks.length," songs"]})]}),n.tracks.map((K,pe)=>o.jsxs("div",{"data-track-index":pe,onClick:()=>oe(pe),style:{display:"flex",alignItems:"center",padding:"14px 16px",cursor:"pointer",background:pe===r?"rgba(255, 0, 0, 0.12)":"transparent",borderLeft:pe===r?"3px solid #ff0000":"3px solid transparent",transition:"background 0.15s"},"data-testid":`youtube-track-item-${K.id}`,children:[o.jsx("span",{style:{width:"28px",color:pe===r?"#ff0000":"#666",fontSize:"13px",flexShrink:0},children:pe===r&&t?"â¶":K.trackNumber}),o.jsx("div",{style:{flex:1,overflow:"hidden",marginRight:"8px"},children:o.jsx("p",{style:{margin:0,fontSize:"14px",color:pe===r?"#ff0000":"white",fontWeight:pe===r?"600":"normal",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:K.title})})]},K.id)),o.jsx("div",{style:{height:"20px"}})]})]}):n.youtubePlaylistId?n.youtubePlaylistId.startsWith("OLAK")||n.youtubePlaylistId.startsWith("PL")?o.jsxs("div",{style:{display:"flex",flexDirection:"column",flex:1,overflow:"hidden",padding:"16px"},children:[o.jsx("div",{style:{width:"100%",aspectRatio:"16/9",maxHeight:"calc(100vh - 150px)",borderRadius:"12px",overflow:"hidden",background:"#000"},children:o.jsx("iframe",{src:`https://www.youtube.com/embed/videoseries?list=${n.youtubePlaylistId}&autoplay=0`,width:"100%",height:"100%",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,referrerPolicy:"strict-origin-when-cross-origin",style:{border:"none",borderRadius:"12px"},"data-testid":"youtube-embed"})}),o.jsx("p",{style:{color:"#888",fontSize:"13px",textAlign:"center",marginTop:"16px"},children:"Playing from YouTube Music"})]}):o.jsxs("div",{style:{display:"flex",flexDirection:"column",flex:1,overflow:"hidden",padding:"16px",alignItems:"center",justifyContent:"center"},children:[o.jsx("div",{style:{width:"200px",height:"200px",borderRadius:"12px",background:n.coverUrl?`url(${n.coverUrl}) center/cover`:"linear-gradient(135deg, #ff0000 0%, #cc0000 100%)",boxShadow:"0 8px 24px rgba(0,0,0,0.5)",marginBottom:"24px"}}),o.jsx("h3",{style:{fontSize:"20px",fontWeight:"bold",marginBottom:"8px",textAlign:"center"},children:n.name}),o.jsx("p",{style:{color:"#888",fontSize:"14px",marginBottom:"32px",textAlign:"center"},children:"YouTube Music Playlist"}),o.jsxs("a",{href:`https://music.youtube.com/playlist?list=${n.youtubePlaylistId}`,target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:"12px",background:"#ff0000",color:"white",padding:"16px 32px",borderRadius:"30px",textDecoration:"none",fontWeight:"bold",fontSize:"16px",boxShadow:"0 4px 12px rgba(255,0,0,0.3)"},"data-testid":"button-open-youtube-music",children:[o.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:o.jsx("path",{d:"M12 0C5.376 0 0 5.376 0 12s5.376 12 12 12 12-5.376 12-12S18.624 0 12 0zm0 19.104c-3.924 0-7.104-3.18-7.104-7.104S8.076 4.896 12 4.896s7.104 3.18 7.104 7.104-3.18 7.104-7.104 7.104zm0-13.332c-3.432 0-6.228 2.796-6.228 6.228S8.568 18.228 12 18.228s6.228-2.796 6.228-6.228S15.432 5.772 12 5.772zM9.684 15.54V8.46L15.816 12l-6.132 3.54z"})}),"Listen on YouTube Music"]})]}):o.jsxs("div",{style:{display:"flex",flexDirection:"column",flex:1,overflow:"hidden",minHeight:0},children:[o.jsxs("div",{style:{flexShrink:0,padding:h?"12px 16px":"16px",borderBottom:"1px solid #333",background:"#151515"},children:[!h&&o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"16px",marginBottom:"12px"},children:[o.jsx("div",{style:{width:"80px",height:"80px",borderRadius:"8px",background:n.coverUrl?`url(${n.coverUrl}) center/cover`:"linear-gradient(135deg, #4ade80 0%, #22c55e 100%)",boxShadow:"0 4px 12px rgba(0,0,0,0.4)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},"data-testid":"img-album-cover",children:!n.coverUrl&&o.jsx(K7,{size:32,color:"rgba(0,0,0,0.3)"})}),o.jsxs("div",{style:{flex:1,overflow:"hidden"},children:[o.jsx("h3",{style:{fontSize:"16px",fontWeight:"bold",margin:"0 0 4px 0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},"data-testid":"text-track-title",children:W?.title||"No Track Selected"}),o.jsxs("p",{style:{fontSize:"13px",color:"#888",margin:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:["Track ",r+1," of ",n.tracks.length]})]})]}),h&&o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[o.jsx("div",{style:{width:"40px",height:"40px",borderRadius:"4px",background:n.coverUrl?`url(${n.coverUrl}) center/cover`:"linear-gradient(135deg, #4ade80 0%, #22c55e 100%)",flexShrink:0}}),o.jsx("div",{style:{flex:1,overflow:"hidden"},children:o.jsx("p",{style:{fontSize:"14px",fontWeight:"bold",margin:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"#4ade80"},children:W?.title||"No Track"})})]}),o.jsxs("div",{style:{marginBottom:"8px"},children:[o.jsx("input",{type:"range",min:"0",max:c||100,value:a,onChange:Y,style:{width:"100%",height:"4px",appearance:"none",background:`linear-gradient(to right, #4ade80 ${a/(c||1)*100}%, #333 ${a/(c||1)*100}%)`,borderRadius:"2px",cursor:"pointer",WebkitAppearance:"none"},"data-testid":"input-seek"}),o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:"11px",color:"#666",marginTop:"4px"},children:[o.jsx("span",{children:X(a)}),o.jsx("span",{children:X(c)})]})]}),o.jsxs("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",gap:"16px"},children:[o.jsx("button",{onClick:()=>w(!x),style:{background:"transparent",border:"none",color:x?"#4ade80":"#666",cursor:"pointer",padding:"8px",display:"flex",alignItems:"center",justifyContent:"center"},"data-testid":"button-shuffle",title:x?"Shuffle On":"Shuffle Off",children:o.jsx(yb,{size:20})}),o.jsx("button",{onClick:fe,disabled:r===0&&m!=="all",style:{background:"transparent",border:"none",color:r===0&&m!=="all"?"#444":"white",cursor:r===0&&m!=="all"?"not-allowed":"pointer",padding:"8px",display:"flex",alignItems:"center",justifyContent:"center"},"data-testid":"button-previous",children:o.jsx(RT,{size:24})}),o.jsx("button",{onClick:z,style:{background:"#4ade80",border:"none",borderRadius:"50%",width:"48px",height:"48px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",flexShrink:0},"data-testid":"button-play-pause",children:t?o.jsx(IT,{size:24,color:"black"}):o.jsx(Bc,{size:24,color:"black",style:{marginLeft:"2px"}})}),o.jsx("button",{onClick:U,disabled:r===n.tracks.length-1&&m==="off"&&!x,style:{background:"transparent",border:"none",color:r===n.tracks.length-1&&m==="off"&&!x?"#444":"white",cursor:r===n.tracks.length-1&&m==="off"&&!x?"not-allowed":"pointer",padding:"8px",display:"flex",alignItems:"center",justifyContent:"center"},"data-testid":"button-next",children:o.jsx(PT,{size:24})}),o.jsx("button",{onClick:I,style:{background:"transparent",border:"none",color:m!=="off"?"#4ade80":"#666",cursor:"pointer",padding:"8px",display:"flex",alignItems:"center",justifyContent:"center"}
96,"data-testid":"button-repeat",title:m==="off"?"Repeat Off":m==="all"?"Repeat All":"Repeat One",children:m==="one"?o.jsx(AT,{size:20}):o.jsx(CT,{size:20})})]}),o.jsxs("button",{onClick:()=>p(!h),style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"4px",background:"transparent",border:"none",color:"#666",fontSize:"11px",cursor:"pointer",padding:"8px",margin:"8px auto 0",width:"100%"},children:[o.jsx(ao,{size:16,style:{transform:h?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s"}}),h?"Show Player":"Show More Tracks"]})]}),o.jsxs("div",{ref:_,style:{flex:1,overflowY:"auto",WebkitOverflowScrolling:"touch",minHeight:0},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"12px 16px 8px",position:"sticky",top:0,background:"linear-gradient(180deg, #0a0a0a 0%, rgba(10,10,10,0.95) 100%)",zIndex:1},children:[o.jsx("h4",{style:{fontSize:"13px",fontWeight:"bold",margin:0,color:"#888"},children:"Tracks"}),o.jsxs("span",{style:{fontSize:"12px",color:"#666"},children:[n.tracks.length," songs"]})]}),n.tracks.map((K,pe)=>o.jsxs("div",{"data-track-index":pe,onClick:()=>oe(pe),style:{display:"flex",alignItems:"center",padding:"14px 16px",cursor:"pointer",background:pe===r?"rgba(74, 222, 128, 0.12)":"transparent",borderLeft:pe===r?"3px solid #4ade80":"3px solid transparent",transition:"background 0.15s"},"data-testid":`track-item-${K.id}`,children:[o.jsx("span",{style:{width:"28px",color:pe===r?"#4ade80":"#666",fontSize:"13px",flexShrink:0},children:pe===r&&t?"â¶":K.trackNumber}),o.jsx("div",{style:{flex:1,overflow:"hidden",marginRight:"8px"},children:o.jsx("p",{style:{margin:0,fontSize:"14px",color:pe===r?"#4ade80":"white",fontWeight:pe===r?"600":"normal",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:K.title})}),o.jsx("span",{style:{color:K.durationSeconds>0?"#888":"#444",fontSize:"12px",flexShrink:0},children:K.durationSeconds>0?X(K.durationSeconds):"â"})]},K.id)),o.jsx("div",{style:{height:"20px"}})]})]})]})}const y_={iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun1.l.google.com:19302"}]};function Mee({showName:n,isCreator:e,liveStatus:t,onClose:s}){const[r,i]=T.useState(t?.isLive||!1),[a,l]=T.useState(""),[c,d]=T.useState(!0),[h,p]=T.useState(!0),[m,y]=T.useState(null),[x,w]=T.useState(null),[S,_]=T.useState(!1),[L,R]=T.useState(""),M=T.useRef(null),V=T.useRef(null),W=T.useRef(null),I=T.useRef(new Map),k=T.useRef([]),P=T.useCallback(()=>{k.current.forEach(Q=>Q()),k.current=[],I.current.forEach(Q=>Q.close()),I.current.clear(),W.current&&(XP(n,W.current),W.current=null),m&&m.getTracks().forEach(Q=>Q.stop())},[n,m]),N=async()=>{try{w(null);const Q=await navigator.mediaDevices.getUserMedia({video:!0,audio:!0});return y(Q),M.current&&(M.current.srcObject=Q),Q}catch(Q){return w(Q.message||"Could not access camera"),null}},F=T.useCallback(async(Q,G)=>{const Y=new RTCPeerConnection(y_);I.current.set(Q,Y),G.getTracks().forEach(pe=>{Y.addTrack(pe,G)}),Y.onicecandidate=pe=>{pe.candidate&&KP(n,Q,pe.candidate.toJSON())},Y.onconnectionstatechange=()=>{};const ee=await Y.createOffer();await Y.setLocalDescription(ee),await zP(n,Q,ee);const H=GP(n,Q,async pe=>{pe&&Y.signalingState==="have-local-offer"&&await Y.setRemoteDescription(new RTCSessionDescription(pe))});k.current.push(H);const K=QP(n,Q,async pe=>{Y.remoteDescription&&await Y.addIceCandidate(new RTCIceCandidate(pe))});k.current.push(K)},[n]),z=T.useCallback(async()=>{const Q=JP();W.current=Q,R("Connecting to stream..."),await BP(n,Q),await UP(n);const G=HP(n,Q,async Y=>{if(!Y)return;R("Establishing connection...");const ee=new RTCPeerConnection(y_);I.current.set("creator",ee),ee.ontrack=pe=>{V.current&&pe.streams[0]&&(V.current.srcObject=pe.streams[0],R(""))},ee.onicecandidate=pe=>{pe.candidate&&qP(n,Q,pe.candidate.toJSON())},ee.onconnectionstatechange=()=>{ee.connectionState==="connected"?R(""):ee.connectionState==="failed"&&R("Connection failed. Try refreshing.")},await ee.setRemoteDescription(new RTCSessionDescription(Y));const H=await ee.createAnswer();await ee.setLocalDescription(H),await $P(n,Q,H);const K=YP(n,Q,async pe=>{ee.remoteDescription&&await ee.addIceCandidate(new RTCIceCandidate(pe))});k.current.push(K)});k.current.push(G)},[n]);T.useEffect(()=>(e&&!r&&N(),!e&&t?.isLive&&z(),()=>{P(),!e&&t?.isLive&&VP(n)}),[e,n,t?.isLive]),T.useEffect(()=>{t?.isLive!==void 0&&i(t.isLive)},[t?.isLive]);const U=()=>
96{if(m){const Q=m.getVideoTracks()[0];Q&&(Q.enabled=!Q.enabled,d(Q.enabled))}},fe=()=>{if(m){const Q=m.getAudioTracks()[0];Q&&(Q.enabled=!Q.enabled,p(Q.enabled))}},oe=async()=>{_(!0);let Q=m;if(Q||(Q=await N()),!Q){_(!1);return}const G=await OP(n,a||"Live Stream");if(G.success){i(!0);const Y=WP(n,(ee,H)=>{H==="waiting"&&Q&&F(ee,Q)});k.current.push(Y)}else alert("Failed to start stream: "+G.error);_(!1)},X=async()=>{P();const Q=await MP(n);Q.success?(i(!1),s()):alert("Failed to end stream: "+Q.error)};return o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/90",onClick:s,children:o.jsxs("div",{className:"relative w-full max-w-4xl mx-4 bg-zinc-900 rounded-xl overflow-hidden",onClick:Q=>Q.stopPropagation(),children:[o.jsx("button",{onClick:s,className:"absolute top-4 right-4 z-10 p-2 bg-black/50 hover:bg-black/70 rounded-full text-white transition-colors",children:o.jsx(Mr,{className:"w-6 h-6"})}),o.jsxs("div",{className:"aspect-video bg-black relative",children:[e?o.jsxs(o.Fragment,{children:[o.jsx("video",{ref:M,autoPlay:!0,muted:!0,playsInline:!0,className:`w-full h-full object-cover ${c?"":"opacity-0"}`}),!c&&o.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-zinc-800",children:o.jsx(Bg,{className:"w-16 h-16 text-zinc-500"})}),x&&o.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-zinc-800 text-center p-4",children:[o.jsx(Bg,{className:"w-16 h-16 text-red-500 mb-4"}),o.jsx("p",{className:"text-red-400 mb-2",children:"Camera Error"}),o.jsx("p",{className:"text-zinc-400 text-sm",children:x}),o.jsx("button",{onClick:N,className:"mt-4 px-4 py-2 bg-green-600 hover:bg-green-700 text-white rounded-lg",children:"Try Again"})]})]}):t?.isLive?o.jsxs(o.Fragment,{children:[o.jsx("video",{ref:V,autoPlay:!0,playsInline:!0,className:"w-full h-full object-cover"}),L&&o.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-black/80",children:[o.jsx("div",{className:"w-12 h-12 border-4 border-green-500 border-t-transparent rounded-full animate-spin mb-4"}),o.jsx("p",{className:"text-white",children:L})]})]}):o.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center bg-zinc-800",children:[o.jsx(Bg,{className:"w-16 h-16 text-zinc-500 mb-4"}),o.jsx("p",{className:"text-zinc-400",children:"Stream is offline"})]}),r&&o.jsxs("div",{className:"absolute top-4 left-4 flex items-center gap-2",children:[o.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-red-600 rounded-full text-white text-sm font-bold",children:[o.jsx("div",{className:"w-2 h-2 bg-white rounded-full animate-pulse"}),"LIVE"]}),t&&o.jsxs("div",{className:"flex items-center gap-1 px-3 py-1.5 bg-black/50 rounded-full text-white text-sm",children:[o.jsx(ff,{className:"w-4 h-4"}),t.viewerCount]})]})]}),o.jsxs("div",{className:"p-6",children:[e&&!r&&o.jsxs("div",{className:"mb-4",children:[o.jsx("label",{className:"block text-sm font-medium text-zinc-400 mb-2",children:"Stream Title"}),o.jsx("input",{type:"text",value:a,onChange:Q=>l(Q.target.value),placeholder:"What are you streaming today?",className:"w-full px-4 py-3 bg-zinc-800 border border-zinc-700 rounded-lg text-white focus:outline-none focus:border-green-500"})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[e&&o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("button",{onClick:U,className:`p-3 rounded-full transition-colors ${c?"bg-zinc-700 hover:bg-zinc-600 text-white":"bg-red-600 hover:bg-red-700 text-white"}`,children:c?o.jsx(G7,{className:"w-5 h-5"}):o.jsx(Bg,{className:"w-5 h-5"})}),o.jsx("button",{onClick:fe,className:`p-3 rounded-full transition-colors ${h?"bg-zinc-700 hover:bg-zinc-600 text-white":"bg-red-600 hover:bg-red-700 text-white"}`,children:h?o.jsx(CF,{className:"w-5 h-5"}):o.jsx(AF,{className:"w-5 h-5"})})]}),o.jsx("div",{className:"flex items-center gap-3 ml-auto",children:e?r?o.jsx("button",{onClick:X,className:"px-6 py-3 bg-red-600 hover:bg-red-700 text-white font-bold rounded-lg transition-colors",children:"End Stream"}):o.jsx("button",{onClick:oe,disabled:S||!!x,className:"px-6 py-3 bg-green-600 hover:bg-green-700 text-white font-bold rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2",children:S?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}),"Starting..."]}):o.jsxs(o.Fragment,{children:[o.jsx(n4,{className:"w-5 h-5"}),"Go Live"]})}):o.jsx("button",{onClick:s,className:"px-6 py-3 bg-zinc-700 hover:bg-zinc-600 text-white font-bold rounded-lg transition-colors",children:"Close"})})]})]})]})})}const et=Number.isFinite||function(n){return typeof n=="number"&&isFinite(n)},Fee=Number.isSafeInteger||function(n){return typeof n=="number"&&Math.abs(n)<=Uee},Uee=Number.MAX_SAFE_INTEGER||9007199254740991;
96let xt=(function(n){return n.NETWORK_ERROR="networkError",n.MEDIA_ERROR="mediaError",n.KEY_SYSTEM_ERROR="keySystemError",n.MUX_ERROR="muxError",n.OTHER_ERROR="otherError",n})({}),he=(function(n){return n.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",n.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",n.KEY_SYSTEM_NO_SESSION="keySystemNoSession",n.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",n.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",n.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",n.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",n.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",n.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",n.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",n.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR="keySystemDestroyMediaKeysError",n.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR="keySystemDestroyCloseSessionError",n.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR="keySystemDestroyRemoveSessionError",n.MANIFEST_LOAD_ERROR="manifestLoadError",n.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",n.MANIFEST_PARSING_ERROR="manifestParsingError",n.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",n.LEVEL_EMPTY_ERROR="levelEmptyError",n.LEVEL_LOAD_ERROR="levelLoadError",n.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",n.LEVEL_PARSING_ERROR="levelParsingError",n.LEVEL_SWITCH_ERROR="levelSwitchError",n.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",n.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",n.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",n.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",n.FRAG_LOAD_ERROR="fragLoadError",n.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",n.FRAG_DECRYPT_ERROR="fragDecryptError",n.FRAG_PARSING_ERROR="fragParsingError",n.FRAG_GAP="fragGap",n.REMUX_ALLOC_ERROR="remuxAllocError",n.KEY_LOAD_ERROR="keyLoadError",n.KEY_LOAD_TIMEOUT="keyLoadTimeOut",n.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",n.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",n.BUFFER_APPEND_ERROR="bufferAppendError",n.BUFFER_APPENDING_ERROR="bufferAppendingError",n.BUFFER_STALLED_ERROR="bufferStalledError",n.BUFFER_FULL_ERROR="bufferFullError",n.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",n.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",n.ASSET_LIST_LOAD_ERROR="assetListLoadError",n.ASSET_LIST_LOAD_TIMEOUT="assetListLoadTimeout",n.ASSET_LIST_PARSING_ERROR="assetListParsingError",n.INTERSTITIAL_ASSET_ITEM_ERROR="interstitialAssetItemError",n.INTERNAL_EXCEPTION="internalException",n.INTERNAL_ABORTED="aborted",n.ATTACH_MEDIA_ERROR="attachMediaError",n.UNKNOWN="unknown",n})({}),j=(function(n){return n.MEDIA_ATTACHING="hlsMediaAttaching",n.MEDIA_ATTACHED="hlsMediaAttached",n.MEDIA_DETACHING="hlsMediaDetaching",n.MEDIA_DETACHED="hlsMediaDetached",n.MEDIA_ENDED="hlsMediaEnded",n.STALL_RESOLVED="hlsStallResolved",n.BUFFER_RESET="hlsBufferReset",n.BUFFER_CODECS="hlsBufferCodecs",n.BUFFER_CREATED="hlsBufferCreated",n.BUFFER_APPENDING="hlsBufferAppending",n.BUFFER_APPENDED="hlsBufferAppended",n.BUFFER_EOS="hlsBufferEos",n.BUFFERED_TO_END="hlsBufferedToEnd",n.BUFFER_FLUSHING="hlsBufferFlushing",n.BUFFER_FLUSHED="hlsBufferFlushed",n.MANIFEST_LOADING="hlsManifestLoading",n.MANIFEST_LOADED="hlsManifestLoaded",n.MANIFEST_PARSED="hlsManifestParsed",n.LEVEL_SWITCHING="hlsLevelSwitching",n.LEVEL_SWITCHED="hlsLevelSwitched",n.LEVEL_LOADING="hlsLevelLoading",n.LEVEL_LOADED="hlsLevelLoaded",n.LEVEL_UPDATED="hlsLevelUpdated",n.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",n.LEVELS_UPDATED="hlsLevelsUpdated",n.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",n.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",n.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",n.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",n.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",n.AUDIO_TRACK_UPDATED="hlsAudioTrackUpdated",n.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",n.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",n.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",n.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",n.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",n.SUBTITLE_TRACK_UPDATED="hlsSubtitleTrackUpdated",n.SUBTITLE_FRAG_PROCESSED="hl
96sSubtitleFragProcessed",n.CUES_PARSED="hlsCuesParsed",n.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",n.INIT_PTS_FOUND="hlsInitPtsFound",n.FRAG_LOADING="hlsFragLoading",n.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",n.FRAG_LOADED="hlsFragLoaded",n.FRAG_DECRYPTED="hlsFragDecrypted",n.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",n.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",n.FRAG_PARSING_METADATA="hlsFragParsingMetadata",n.FRAG_PARSED="hlsFragParsed",n.FRAG_BUFFERED="hlsFragBuffered",n.FRAG_CHANGED="hlsFragChanged",n.FPS_DROP="hlsFpsDrop",n.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",n.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",n.ERROR="hlsError",n.DESTROYING="hlsDestroying",n.KEY_LOADING="hlsKeyLoading",n.KEY_LOADED="hlsKeyLoaded",n.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",n.BACK_BUFFER_REACHED="hlsBackBufferReached",n.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",n.ASSET_LIST_LOADING="hlsAssetListLoading",n.ASSET_LIST_LOADED="hlsAssetListLoaded",n.INTERSTITIALS_UPDATED="hlsInterstitialsUpdated",n.INTERSTITIALS_BUFFERED_TO_BOUNDARY="hlsInterstitialsBufferedToBoundary",n.INTERSTITIAL_ASSET_PLAYER_CREATED="hlsInterstitialAssetPlayerCreated",n.INTERSTITIAL_STARTED="hlsInterstitialStarted",n.INTERSTITIAL_ASSET_STARTED="hlsInterstitialAssetStarted",n.INTERSTITIAL_ASSET_ENDED="hlsInterstitialAssetEnded",n.INTERSTITIAL_ASSET_ERROR="hlsInterstitialAssetError",n.INTERSTITIAL_ENDED="hlsInterstitialEnded",n.INTERSTITIALS_PRIMARY_RESUMED="hlsInterstitialsPrimaryResumed",n.PLAYOUT_LIMIT_REACHED="hlsPlayoutLimitReached",n.EVENT_CUE_ENTER="hlsEventCueEnter",n})({});var Zt={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},st={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};class uh{constructor(e,t=0,s=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_=s}sample(e,t){const s=Math.pow(this.alpha_,e);this.estimate_=t*(1-s)+s*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 Vee{constructor(e,t,s,r=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_=s,this.minWeight_=.001,this.minDelayMs_=50,this.slow_
vendor: 3,679 bytes, line 96
96=new uh(e),this.fast_=new uh(t),this.defaultTTFB_=r,this.ttfb_=new uh(e)}update(e,t){const{slow_:s,fast_:r,ttfb_:i}=this;s.halfLife!==e&&(this.slow_=new uh(e,s.getEstimate(),s.getTotalWeight())),r.halfLife!==t&&(this.fast_=new uh(t,r.getEstimate(),r.getTotalWeight())),i.halfLife!==e&&(this.ttfb_=new uh(e,i.getEstimate(),i.getTotalWeight()))}sample(e,t){e=Math.max(e,this.minDelayMs_);const s=8*t,r=e/1e3,i=s/r;this.fast_.sample(r,i),this.slow_.sample(r,i)}sampleTTFB(e){const t=e/1e3,s=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(s,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 Bee(n,e,t){return(e=$ee(e))in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function kn(){return kn=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var s in t)({}).hasOwnProperty.call(t,s)&&(n[s]=t[s])}return n},kn.apply(null,arguments)}function v_(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(n);e&&(s=s.filter(function(r){return Object.getOwnPropertyDescriptor(n,r).enumerable})),t.push.apply(t,s)}return t}function In(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?v_(Object(t),!0).forEach(function(s){Bee(n,s,t[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):v_(Object(t)).forEach(function(s){Object.defineProperty(n,s,Object.getOwnPropertyDescriptor(t,s))})}return n}function zee(n,e){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var s=t.call(n,e);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}function $ee(n){var e=zee(n,"string");return typeof e=="symbol"?e:e+""}class Pa{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 s=`[${e}]:`;this.trace=Pc,this.debug=t.debug.bind(null,s),this.log=t.log.bind(null,s),this.warn=t.warn.bind(null,s),this.info=t.info.bind(null,s),this.error=t.error.bind(null,s)}}const Pc=function(){},Hee={trace:Pc,debug:Pc,log:Pc,warn:Pc,info:Pc,error:Pc};function Zb(){return kn({},Hee)}function Wee(n,e){const t=self.console[n];return t?t.bind(self.console,`${e?"["+e+"] ":""}[${n}] >`):Pc}function b_(n,e,t){return e[n]?e[n].bind(e):Wee(n,t)}const ew=Zb();function Gee(n,e,t){const s=Zb();if(typeof console=="object"&&n===!0||typeof n=="object"){const r=["debug","log","info","warn","error"];r.forEach(i=>{s[i]=b_(i,n,t)});try{s.log(`Debug logs enabled for "${e}" in hls.js version 1.6.16`)}catch{return Zb()}r.forEach(i=>{ew[i]=b_(i,n)})}else kn(ew,s);return s}const An=ew;function Ql(n=!0){return typeof self>"u"?void 0:(n||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function Kee(n){return typeof self<"u"&&n===self.ManagedMediaSource}function lN(n,e){const t=Object.keys(n),s=Object.keys(e),r=t.length,i=s.length;return!r||!i||r===i&&!t.some(a=>s.indexOf(a)===-1)}function na(n,e=!1){if(typeof TextDecoder<"u"){const d=new TextDecoder("utf-8").decode(n);if(e){const h=d.indexOf("\0");return h!==-1?d.substring(0,h):d}return d.replace(/\0/g,"")}const t=n.length;let s,r,i,a="",l=0;for(;l<t;){if(s=n[l++],s===0&&e)return a;
vendor: 5,515 bytes, line 96
96if(s===0||s===3)continue;switch(s>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:a+=String.fromCharCode(s);break;case 12:case 13:r=n[l++],a+=String.fromCharCode((s&31)<<6|r&63);break;case 14:r=n[l++],i=n[l++],a+=String.fromCharCode((s&15)<<12|(r&63)<<6|(i&63)<<0);break}}return a}function vr(n){let e="";for(let t=0;t<n.length;t++){let s=n[t].toString(16);s.length<2&&(s="0"+s),e+=s}return e}function cN(n){return Uint8Array.from(n.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}function qee(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var bv={exports:{}},w_;function Yee(){return w_||(w_=1,(function(n,e){(function(t){var s=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,r=/^(?=([^\/?#]*))\1([^]*)$/,i=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,l={buildAbsoluteURL:function(c,d,h){if(h=h||{},c=c.trim(),d=d.trim(),!d){if(!h.alwaysNormalize)return c;var p=l.parseURL(c);if(!p)throw new Error("Error trying to parse base URL.");return p.path=l.normalizePath(p.path),l.buildURLFromParts(p)}var m=l.parseURL(d);if(!m)throw new Error("Error trying to parse relative URL.");if(m.scheme)return h.alwaysNormalize?(m.path=l.normalizePath(m.path),l.buildURLFromParts(m)):d;var y=l.parseURL(c);if(!y)throw new Error("Error trying to parse base URL.");if(!y.netLoc&&y.path&&y.path[0]!=="/"){var x=r.exec(y.path);y.netLoc=x[1],y.path=x[2]}y.netLoc&&!y.path&&(y.path="/");var w={scheme:y.scheme,netLoc:m.netLoc,path:null,params:m.params,query:m.query,fragment:m.fragment};if(!m.netLoc&&(w.netLoc=y.netLoc,m.path[0]!=="/"))if(!m.path)w.path=y.path,m.params||(w.params=y.params,m.query||(w.query=y.query));else{var S=y.path,_=S.substring(0,S.lastIndexOf("/")+1)+m.path;w.path=l.normalizePath(_)}return w.path===null&&(w.path=h.alwaysNormalize?l.normalizePath(m.path):m.path),l.buildURLFromParts(w)},parseURL:function(c){var d=s.exec(c);return d?{scheme:d[1]||"",netLoc:d[2]||"",path:d[3]||"",params:d[4]||"",query:d[5]||"",fragment:d[6]||""}:null},normalizePath:function(c){for(c=c.split("").reverse().join("").replace(i,"");c.length!==(c=c.replace(a,"")).length;);return c.split("").reverse().join("")},buildURLFromParts:function(c){return c.scheme+c.netLoc+c.path+c.params+c.query+c.fragment}};n.exports=l})()})(bv)),bv.exports}var Z6=Yee();class sy{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 Ln={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};class eS{constructor(e){this._byteRange=null,this._url=null,this._stats=null,this._streams=null,this.base=void 0,this.relurl=void 0,typeof e=="string"&&(e={url:e}),this.base=e,Qee(this,"stats")}setByteRange(e,t){const s=e.split("@",2);let r;s.length===1?r=t?.byteRangeEndOffset||0:r=parseInt(s[1]),this._byteRange=[r,parseInt(s[0])+r]}get baseurl(){return this.base.url}get byteRange(){return this._byteRange===null?[]:this._byteRange}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get elementaryStreams(){return this._streams===null&&(this._streams={[Ln.AUDIO]:null,[Ln.VIDEO]:null,[Ln.AUDIOVIDEO]:null}),this._streams}set elementaryStreams(e){this._streams=e}get hasStats(){return this._stats!==null}get hasStreams(){return this._streams!==null}get stats(){return this._stats===null&&(this._stats=new sy),this._stats}set stats(e){this._stats=e}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Z6.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}clearElementaryStreamInfo(){const{elementaryStreams:e}=this;e[Ln.AUDIO]=null,e[Ln.VIDEO]=null,e[Ln.AUDIOVIDEO]=null}}function _s(n){return n.sn!=="initSegment"}class L0 extends eS{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(et(e)&&et(t))return t-e}return null}get bitrate(){return this.byteLength?this.byteLength*8/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(!((e=this._decryptdata)!=null&&e.keyId)){const s=Object.keys(t);if(s.length===1){const r=this._decryptdata=t[s[0]]||null;r&&(this._decryptdata=r.getDecryptData(this.sn,t))}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null)return null;const e=et(this.duration)?this.duration:0;return this.programDateTime+e*1e3}get encrypted(){var e;if((e=this._decryptdata)!=null&&e.encrypted)return!0;
vendor: 4,071 bytes, line 96
96if(this.levelkeys){var t;const s=Object.keys(this.levelkeys),r=s.length;if(r>1||r===1&&(t=this.levelkeys[s[0]])!=null&&t.encrypted)return!0}return!1}get programDateTime(){return this._programDateTime===null&&this.rawProgramDateTime&&(this.programDateTime=Date.parse(this.rawProgramDateTime)),this._programDateTime}set programDateTime(e){if(!et(e)){this._programDateTime=this.rawProgramDateTime=null;return}this._programDateTime=e}get ref(){return _s(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 s;const r=t[e];r&&!((s=this._decryptdata)!=null&&s.keyId)&&(this._decryptdata=r.getDecryptData(this.sn,t))}}abortRequests(){var e,t;(e=this.loader)==null||e.abort(),(t=this.keyLoader)==null||t.abort()}setElementaryStreamInfo(e,t,s,r,i,a=!1){const{elementaryStreams:l}=this,c=l[e];if(!c){l[e]={startPTS:t,endPTS:s,startDTS:r,endDTS:i,partial:a};return}c.startPTS=Math.min(c.startPTS,t),c.endPTS=Math.max(c.endPTS,s),c.startDTS=Math.min(c.startDTS,r),c.endDTS=Math.max(c.endDTS,i)}}class uN extends eS{constructor(e,t,s,r,i){super(s),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=r;const a=e.enumeratedString("BYTERANGE");a&&this.setByteRange(a,i),i&&(this.fragOffset=i.fragOffset+i.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 dN(n,e){const t=Object.getPrototypeOf(n);if(t){const s=Object.getOwnPropertyDescriptor(t,e);return s||dN(t,e)}}function Qee(n,e){const t=dN(n,e);t&&(t.enumerable=!0,Object.defineProperty(n,e,t))}const S_=Math.pow(2,32)-1,Xee=[].push,hN={video:1,audio:2,id3:3,text:4};function Hs(n){return String.fromCharCode.apply(null,n)}function fN(n,e){const t=n[e]<<8|n[e+1];return t<0?65536+t:t}function Mt(n,e){const t=pN(n,e);return t<0?4294967296+t:t}function E_(n,e){let t=Mt(n,e);return t*=Math.pow(2,32),t+=Mt(n,e+4),t}function pN(n,e){return n[e]<<24|n[e+1]<<16|n[e+2]<<8|n[e+3]}function Jee(n){const e=n.byteLength;for(let t=0;t<e;){const s=Mt(n,t);if(s>8&&n[t+4]===109&&n[t+5]===111&&n[t+6]===111&&n[t+7]===102)return!0;t=s>1?t+s:e}return!1}function qt(n,e){const t=[];if(!e.length)return t;const s=n.byteLength;for(let r=0;r<s;){const i=Mt(n,r),a=Hs(n.subarray(r+4,r+8)),l=i>1?r+i:s;if(a===e[0])if(e.length===1)t.push(n.subarray(r+8,l));else{const c=qt(n.subarray(r+8,l),e.slice(1));c.length&&Xee.apply(t,c)}r=l}return t}function Zee(n){const e=[],t=n[0];let s=8;const r=Mt(n,s);s+=4;let i=0,a=0;t===0?(i=Mt(n,s),a=Mt(n,s+4),s+=8):(i=E_(n,s),a=E_(n,s+8),s+=16),s+=2;let l=n.length+a;const c=fN(n,s);s+=2;for(let d=0;d<c;d++){let h=s;const p=Mt(n,h);h+=4;const m=p&2147483647;if((p&2147483648)>>>31===1)return An.warn("SIDX has hierarchical references (not supported)"),null;const x=Mt(n,h);h+=4,e.push({referenceSize:m,subsegmentDuration:x,info:{duration:x/r,start:l,end:l+m-1}}),l+=m,h+=4,s=h}return{earliestPresentationTime:i,timescale:r,version:t,referencesCount:c,references:e}}function mN(n){const e=[],t=qt(n,["moov","trak"]);for(let r=0;r<t.length;r++){const i=t[r],a=qt(i,["tkhd"])[0];if(a){let l=a[0];const c=Mt(a,l===0?12:20),d=qt(i,["mdia","mdhd"])[0];if(d){l=d[0];const h=Mt(d,l===0?12:20),p=qt(i,["mdia","hdlr"])[0];if(p){const m=Hs(p.subarray(8,12)),y={soun:Ln.AUDIO,vide:Ln.VIDEO}[m],x=qt(i,["mdia","minf","stbl","stsd"])[0],w=ete(x);y?(e[c]={timescale:h,type:y,stsd:w},e[y]=In({timescale:h,id:c},w)):e[c]={timescale:h,type:m,stsd:w}}}}}return qt(n,["moov","mvex","trex"]).forEach(r=>{const i=Mt(r,4),a=e[i];
96a&&(a.default={duration:Mt(r,12),flags:Mt(r,20)})}),e}function ete(n){const e=n.subarray(8),t=e.subarray(86),s=Hs(e.subarray(4,8));let r=s,i;const a=s==="enca"||s==="encv";if(a){const d=qt(e,[s])[0].subarray(s==="enca"?28:78);qt(d,["sinf"]).forEach(p=>{const m=qt(p,["schm"])[0];if(m){const y=Hs(m.subarray(4,8));if(y==="cbcs"||y==="cenc"){const x=qt(p,["frma"])[0];x&&(r=Hs(x))}}})}const l=r;switch(r){case"avc1":case"avc2":case"avc3":case"avc4":{const c=qt(t,["avcC"])[0];c&&c.length>3&&(r+="."+e0(c[1])+e0(c[2])+e0(c[3]),i=Zg(l==="avc1"?"dva1":"dvav",t));break}case"mp4a":{const c=qt(e,[s])[0],d=qt(c.subarray(28),["esds"])[0];if(d&&d.length>7){let h=4;if(d[h++]!==3)break;h=wv(d,h),h+=2;const p=d[h++];if(p&128&&(h+=2),p&64&&(h+=d[h++]),d[h++]!==4)break;h=wv(d,h);const m=d[h++];if(m===64)r+="."+e0(m);else break;if(h+=12,d[h++]!==5)break;h=wv(d,h);const y=d[h++];let x=(y&248)>>3;x===31&&(x+=1+((y&7)<<3)+((d[h]&224)>>5)),r+="."+x}break}case"hvc1":case"hev1":{const c=qt(t,["hvcC"])[0];if(c&&c.length>12){const d=c[1],h=["","A","B","C"][d>>6],p=d&31,m=Mt(c,2),y=(d&32)>>5?"H":"L",x=c[12],w=c.subarray(6,12);r+="."+h+p,r+="."+tte(m).toString(16).toUpperCase(),r+="."+y+x;let S="";for(let _=w.length;_--;){const L=w[_];(L||S)&&(S="."+L.toString(16).toUpperCase()+S)}r+=S}i=Zg(l=="hev1"?"dvhe":"dvh1",t);break}case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":{r=Zg(r,t)||r;break}case"vp09":{const c=qt(t,["vpcC"])[0];if(c&&c.length>6){const d=c[4],h=c[5],p=c[6]>>4&15;r+="."+Do(d)+"."+Do(h)+"."+Do(p)}break}case"av01":{const c=qt(t,["av1C"])[0];if(c&&c.length>2){const d=c[1]>>>5,h=c[1]&31,p=c[2]>>>7?"H":"M",m=(c[2]&64)>>6,y=(c[2]&32)>>5,x=d===2&&m?y?12:10:m?10:8,w=(c[2]&16)>>4,S=(c[2]&8)>>3,_=(c[2]&4)>>2,L=c[2]&3;r+="."+d+"."+Do(h)+p+"."+Do(x)+"."+w+"."+S+_+L+"."+Do(1)+"."+Do(1)+"."+Do(1)+"."+0,i=Zg("dav1",t)}break}}return{codec:r,encrypted:a,supplemental:i}}function Zg(n,e){const t=qt(e,["dvvC"]),s=t.length?t[0]:qt(e,["dvcC"])[0];if(s){const r=s[2]>>1&127,i=s[2]<<5&32|s[3]>>3&31;return n+"."+Do(r)+"."+Do(i)}}function tte(n){let e=0;for(let t=0;t<32;t++)e|=(n>>t&1)<<31-t;return e>>>0}function wv(n,e){const t=e+5;for(;n[e++]&128&&e<t;);return e}function e0(n){return("0"+n.toString(16).toUpperCase()).slice(-2)}function Do(n){return(n<10?"0":"")+n}function nte(n,e){if(!n||!e)return;const t=e.keyId;t&&e.isCommonEncryption&&gN(n,(s,r)=>{const i=s.subarray(8,24);i.some(a=>a!==0)||(An.log(`[eme] Patching keyId in 'enc${r?"a":"v"}>sinf>>tenc' box: ${vr(i)} -> ${vr(t)}`),s.set(t,8))})}function ste(n){const e=[];return gN(n,t=>e.push(t.subarray(8,24))),e}function gN(n,e){qt(n,["moov","trak"]).forEach(s=>{const r=qt(s,["mdia","minf","stbl","stsd"])[0];if(!r)return;const i=r.subarray(8);let a=qt(i,["enca"]);const l=a.length>0;l||(a=qt(i,["encv"])),a.forEach(c=>{const d=l?c.subarray(28):c.subarray(78);qt(d,["sinf"]).forEach(p=>{const m=xN(p);m&&e(m,l)})})})}function xN(n){const e=qt(n,["schm"])[0];if(e){const t=Hs(e.subarray(4,8));if(t==="cbcs"||t==="cenc"){const s=qt(n,["schi","tenc"])[0];if(s)return s}}}function rte(n,e,t){const s={},r=qt(n,["moof","traf"]);for(let i=0;i<r.length;i++){const a=r[i],l=qt(a,["tfhd"])[0],c=Mt(l,4),d=e[c];if(!d)continue;s[c]||(s[c]={start:NaN,duration:0,sampleCount:0,timescale:d.timescale,type:d.type});const h=s[c],p=qt(a,["tfdt"])[0];if(p){const R=p[0];let M=Mt(p,4);R===1&&(M===S_?t.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"):(M*=S_+1,M+=Mt(p,8))),et(M)&&(!et(h.start)||M<h.start)&&(h.start=M)}const m=d.default,y=Mt(l,0)|m?.flags;let x=m?.duration||0;y&8&&(y&2?x=Mt(l,12):x=Mt(l,8));const w=qt(a,["trun"]);let S=h.start||0,_=0,L=x;for(let R=0;R<w.length;R++){const M=w[R],V=Mt(M,4),W=h.sampleCount;h.sampleCount+=V;const I=M[3]&1,k=M[3]&4,P=M[2]&1,N=M[2]&2,F=M[2]&4,z=M[2]&8;let U=8,fe=V;for(I&&(U+=4),k&&V&&(!(M[U+1]&1)&&h.keyFrameIndex===void 0&&(h.keyFrameIndex=W),U+=4,P?(L=Mt(M,U),U+=4):L=x,N&&(U+=4),z&&(U+=4),S+=L,_+=L,fe--);fe--;)P?(L=Mt(M,U),U+=4):L=x,N&&(U+=4),F&&(M[U+1]&1||h.keyFrameIndex===void 0&&(h.keyFrameIndex=h.sampleCount-(fe+1),h.keyFrameStart=S),U+=4),z&&(U+=4),S+=L,_+=L;!_&&x&&(_+=x*V)}h.duration+=_}if(!Object.keys(s).some(i=>s[i].duration)){let i=1/0,a=0;const l=qt(n,["sidx"]);for(let c=0;c<l.length;c++){const d=Zee(l[c]);if(d!=null&&d.references){i=Math.min(i,d.earliestPresentationTime/d.timescale);const h=d.references.reduce((p,m)=>p+m.info.duration||0,0);a=Math.max(a,h+d.earliestPresentationTime/d.timescale)}}
vendor: 4,428 bytes, line 96
96a&&et(a)&&Object.keys(s).forEach(c=>{s[c].duration||(s[c].duration=a*s[c].timescale-s[c].start)})}return s}function ite(n){const e={valid:null,remainder:null},t=qt(n,["moof"]);if(t.length<2)return e.remainder=n,e;const s=t[t.length-1];return e.valid=n.slice(0,s.byteOffset-8),e.remainder=n.slice(s.byteOffset-8),e}function ka(n,e){const t=new Uint8Array(n.length+e.length);return t.set(n),t.set(e,n.length),t}function T_(n,e){const t=[],s=e.samples,r=e.timescale,i=e.id;let a=!1;return qt(s,["moof"]).map(c=>{const d=c.byteOffset-8;qt(c,["traf"]).map(p=>{const m=qt(p,["tfdt"]).map(y=>{const x=y[0];let w=Mt(y,4);return x===1&&(w*=Math.pow(2,32),w+=Mt(y,8)),w/r})[0];return m!==void 0&&(n=m),qt(p,["tfhd"]).map(y=>{const x=Mt(y,4),w=Mt(y,0)&16777215,S=(w&1)!==0,_=(w&2)!==0,L=(w&8)!==0;let R=0;const M=(w&16)!==0;let V=0;const W=(w&32)!==0;let I=8;x===i&&(S&&(I+=8),_&&(I+=4),L&&(R=Mt(y,I),I+=4),M&&(V=Mt(y,I),I+=4),W&&(I+=4),e.type==="video"&&(a=ry(e.codec)),qt(p,["trun"]).map(k=>{const P=k[0],N=Mt(k,0)&16777215,F=(N&1)!==0;let z=0;const U=(N&4)!==0,fe=(N&256)!==0;let oe=0;const X=(N&512)!==0;let Q=0;const G=(N&1024)!==0,Y=(N&2048)!==0;let ee=0;const H=Mt(k,4);let K=8;F&&(z=Mt(k,K),K+=4),U&&(K+=4);let pe=z+d;for(let Fe=0;Fe<H;Fe++){if(fe?(oe=Mt(k,K),K+=4):oe=R,X?(Q=Mt(k,K),K+=4):Q=V,G&&(K+=4),Y&&(P===0?ee=Mt(k,K):ee=pN(k,K),K+=4),e.type===Ln.VIDEO){let _e=0;for(;_e<Q;){const ze=Mt(s,pe);if(pe+=4,ate(a,s[pe])){const Ye=s.subarray(pe,pe+ze);tS(Ye,a?2:1,n+ee/r,t)}pe+=ze,_e+=ze+4}}n+=oe/r}}))})})}),t}function ry(n){if(!n)return!1;const e=n.substring(0,4);return e==="hvc1"||e==="hev1"||e==="dvh1"||e==="dvhe"}function ate(n,e){if(n){const t=e>>1&63;return t===39||t===40}else return(e&31)===6}function tS(n,e,t,s){const r=yN(n);let i=0;i+=e;let a=0,l=0,c=0;for(;i<r.length;){a=0;do{if(i>=r.length)break;c=r[i++],a+=c}while(c===255);l=0;do{if(i>=r.length)break;c=r[i++],l+=c}while(c===255);const d=r.length-i;let h=i;if(l<d)i+=l;else if(l>d){An.error(`Malformed SEI payload. ${l} is too small, only ${d} bytes left to parse.`);break}if(a===4){if(r[h++]===181){const m=fN(r,h);if(h+=2,m===49){const y=Mt(r,h);if(h+=4,y===1195456820){const x=r[h++];if(x===3){const w=r[h++],S=31&w,_=64&w,L=_?2+S*3:0,R=new Uint8Array(L);if(_){R[0]=w;for(let M=1;M<L;M++)R[M]=r[h++]}s.push({type:x,payloadType:a,pts:t,bytes:R})}}}}}else if(a===5&&l>16){const p=[];for(let x=0;x<16;x++){const w=r[h++].toString(16);p.push(w.length==1?"0"+w:w),(x===3||x===5||x===7||x===9)&&p.push("-")}const m=l-16,y=new Uint8Array(m);for(let x=0;x<m;x++)y[x]=r[h++];s.push({payloadType:a,pts:t,uuid:p.join(""),userData:na(y),userDataBytes:y})}}}function yN(n){const e=n.byteLength,t=[];let s=1;for(;s<e-2;)n[s]===0&&n[s+1]===0&&n[s+2]===3?(t.push(s+2),s+=2):s++;if(t.length===0)return n;const r=e-t.length,i=new Uint8Array(r);let a=0;for(s=0;s<r;a++,s++)a===t[0]&&(a++,t.shift()),i[s]=n[a];return i}function ote(n){const e=n[0];let t="",s="",r=0,i=0,a=0,l=0,c=0,d=0;if(e===0){for(;Hs(n.subarray(d,d+1))!=="\0";)t+=Hs(n.subarray(d,d+1)),d+=1;for(t+=Hs(n.subarray(d,d+1)),d+=1;Hs(n.subarray(d,d+1))!=="\0";)s+=Hs(n.subarray(d,d+1)),d+=1;s+=Hs(n.subarray(d,d+1)),d+=1,r=Mt(n,12),i=Mt(n,16),l=Mt(n,20),c=Mt(n,24),d=28}else if(e===1){d+=4,r=Mt(n,d),d+=4;const p=Mt(n,d);d+=4;const m=Mt(n,d);for(d+=4,a=2**32*p+m,Fee(a)||(a=Number.MAX_SAFE_INTEGER,An.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),l=Mt(n,d),d+=4,c=Mt(n,d),d+=4;Hs(n.subarray(d,d+1))!=="\0";)t+=Hs(n.subarray(d,d+1)),d+=1;for(t+=Hs(n.subarray(d,d+1)),d+=1;Hs(n.subarray(d,d+1))!=="\0";)s+=Hs(n.subarray(d,d+1)),d+=1;s+=Hs(n.subarray(d,d+1)),d+=1}const h=n.subarray(d,n.byteLength);return{schemeIdUri:t,value:s,timeScale:r,presentationTime:a,presentationTimeDelta:i,eventDuration:l,id:c,payload:h}}function lte(n,...e){const t=e.length;let s=8,r=t;for(;r--;)s+=e[r].byteLength;const i=new Uint8Array(s);for(i[0]=s>>24&255,i[1]=s>>16&255,i[2]=s>>8&255,i[3]=s&255,i.set(n,4),r=0,s=8;r<t;r++)i.set(e[r],s),s+=e[r].byteLength;return i}function cte(n,e,t){if(n.byteLength!==16)throw new RangeError("Invalid system id");let s,r;s=0,r=new Uint8Array;let i;s>0?(i=new Uint8Array(4),e.length>0&&new DataView(i.buffer).setUint32(0,e.length,!1)):i=new Uint8Array;const a=new Uint8Array(4);return t.byteLength>0&&new DataView(a.buffer).setUint32(0,t.byteLength,!1),lte([112,115,115,104],new Uint8Array([s,0,0,0]),n,i,r,a,t)}function ute(n){const e=[];
vendor: 11,221 bytes, line 96
96if(n instanceof ArrayBuffer){const t=n.byteLength;let s=0;for(;s+32<t;){const r=new DataView(n,s),i=dte(r);e.push(i),s+=i.size}}return e}function dte(n){const e=n.getUint32(0),t=n.byteOffset,s=n.byteLength;if(s<e)return{offset:t,size:s};if(n.getUint32(4)!==1886614376)return{offset:t,size:e};const i=n.getUint32(8)>>>24;if(i!==0&&i!==1)return{offset:t,size:e};const a=n.buffer,l=vr(new Uint8Array(a,t+12,16));let c=null,d=null,h=0;if(i===0)h=28;else{const m=n.getUint32(28);if(!m||s<32+m*16)return{offset:t,size:e};c=[];for(let y=0;y<m;y++)c.push(new Uint8Array(a,t+32+y*16,16));h=32+m*16}if(!h)return{offset:t,size:e};const p=n.getUint32(h);return e-32<p?{offset:t,size:e}:(d=new Uint8Array(a,t+h+4,p),{version:i,systemId:l,kids:c,data:d,offset:t,size:e})}const vN=()=>/\(Windows.+Firefox\//i.test(navigator.userAgent),rf={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 nS(n,e){const t=rf[e];return!!t&&!!t[n.slice(0,4)]}function gm(n,e,t=!0){return!n.split(",").some(s=>!sS(s,e,t))}function sS(n,e,t=!0){var s;const r=Ql(t);return(s=r?.isTypeSupported(xm(n,e)))!=null?s:!1}function xm(n,e){return`${e}/mp4;codecs=${n}`}function __(n){if(n){const e=n.substring(0,4);return rf.video[e]}return 2}function L1(n){const e=vN();return n.split(",").reduce((t,s)=>{const i=e&&ry(s)?9:rf.video[s];return i?(i*2+t)/(t?3:2):(rf.audio[s]+t)/(t?2:1)},0)}const Sv={};function hte(n,e=!0){if(Sv[n])return Sv[n];const t={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[n];for(let r=0;r<t.length;r++){var s;if(sS(t[r],"audio",e))return Sv[n]=t[r],t[r];if(t[r]==="mp3"&&(s=Ql(e))!=null&&s.isTypeSupported("audio/mpeg"))return""}return n}const fte=/flac|opus|mp4a\.40\.34/i;function D1(n,e=!0){return n.replace(fte,t=>hte(t.toLowerCase(),e))}function pte(n,e){const t=[];if(n){const s=n.split(",");for(let r=0;r<s.length;r++)nS(s[r],"video")||t.push(s[r])}return e&&t.push(e),t.join(",")}function D0(n,e){if(n&&(n.length>4||["ac-3","ec-3","alac","fLaC","Opus"].indexOf(n)!==-1)&&(I_(n,"audio")||I_(n,"video")))return n;if(e){const t=e.split(",");if(t.length>1){if(n){for(let s=t.length;s--;)if(t[s].substring(0,4)===n.substring(0,4))return t[s]}return t[0]}}return e||n}function I_(n,e){return nS(n,e)&&sS(n,e)}function mte(n){const e=n.split(",");for(let t=0;t<e.length;t++){const s=e[t].split(".");s.length>2&&s[0]==="avc1"&&(e[t]=`avc1.${parseInt(s[1]).toString(16)}${("000"+parseInt(s[2]).toString(16)).slice(-4)}`)}return e.join(",")}function gte(n){if(n.startsWith("av01.")){const e=n.split("."),t=["0","111","01","01","01","0"];for(let s=e.length;s>4&&s<10;s++)e[s]=t[s-4];return e.join(".")}return n}function A_(n){const e=Ql(n)||{isTypeSupported:()=>!1};return{mpeg:e.isTypeSupported("audio/mpeg"),mp3:e.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:e.isTypeSupported('audio/mp4; codecs="ac-3"')}}function tw(n){return n.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}const xte={supported:!0,powerEfficient:!0,smooth:!0},yte={supported:!1,smooth:!1,powerEfficient:!1},bN={supported:!0,configurations:[],decodingInfoResults:[xte]};function wN(n,e){return{supported:!1,configurations:e,decodingInfoResults:[yte],error:n}}function vte(n,e,t,s,r,i){const a=n.videoCodec,l=n.audioCodec?n.audioGroups:null,c=i?.audioCodec,d=i?.channels,h=d?parseInt(d):c?1/0:2;let p=null;if(l!=null&&l.length)try{l.length===1&&l[0]?p=e.groups[l[0]].channels:p=l.reduce((m,y)=>{if(y){const x=e.groups[y];if(!x)throw new Error(`Audio track group ${y} not found`);Object.keys(x.channels).forEach(w=>{m[w]=(m[w]||0)+x.channels[w]})}return m},{2:0})}catch{return!0}return a!==void 0&&(a.split(",").some(m=>ry(m))||n.width>1920&&n.height>1088||n.height>1920&&n.width>1088||n.frameRate>Math.max(s,30)||n.videoRange!=="SDR"&&n.videoRange!==t||n.bitrate>Math.max(r,8e6))||!!p&&et(h)&&Object.keys(p).some(m=>parseInt(m)>h)}function SN(n,e,t,s={}){const r=n.videoCodec;if(!r&&!n.audioCodec||!t)return Promise.resolve(bN);const i=[],a=bte(n),l=a.length,c=wte(n,e,l>0),d=c.length;for(let h=l||1*d||1;h--;){const p={type:"media-source"};if(l&&(p.video=a[h%l]),d){p.audio=c[h%d];const m=p.audio.bitrate;p.video&&m&&(p.video.bitrate-=m)}i.push(p)}if(r){const h=navigator.userAgent;if(r.split(",").some(p=>ry(p))&&vN())return Promise.resolve(wN(new Error(`Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent string: (${h})`),i))}return Promise.all(i.map(h=>{const p=Ete(h);return s[p]||(s[p]=t.decodingInfo(h))})).then(h=>({supported:!h.some(p=>!p.supported),configurations:i,decodingInfoResults:h})).catch(h=>({supported:!1,configurations:i,decodingInfoResults:[],error:h}))}function bte(n){var e;const t=(e=n.videoCodec)==null?void 0:e.split(","),s=EN(n),r=n.width||640,i=n.height||480,a=n.frameRate||30,l=n.videoRange.toLowerCase();return t?t.map(c=>{const d={contentType:xm(gte(c),"video"),width:r,height:i,bitrate:s,framerate:a};return l!=="sdr"&&(d.transferFunction=l),d}):[]}function wte(n,e,t){var s;const r=(s=n.audioCodec)==null?void 0:s.split(","),i=EN(n);return r&&n.audioGroups?n.audioGroups.reduce((a,l)=>{var c;const d=l?(c=e.groups[l])==null?void 0:c.tracks:null;return d?d.reduce((h,p)=>{if(p.groupId===l){const m=parseFloat(p.channels||"");r.forEach(y=>{const x={contentType:xm(y,"audio"),bitrate:t?Ste(y,i):i};m&&(x.channels=""+m),h.push(x)})}return h},a):a},[]):[]}function Ste(n,e){if(e<=1)return 1;let t=128e3;return n==="ec-3"?t=768e3:n==="ac-3"&&(t=64e4),Math.min(e/2,t)}function EN(n){return Math.ceil(Math.max(n.bitrate*.9,n.averageBitrate)/1e3)*1e3||1}function Ete(n){let e="";const{audio:t,video:s}=n;if(s){const r=tw(s.contentType);e+=`${r}_r${s.height}x${s.width}f${Math.ceil(s.framerate)}${s.transferFunction||"sd"}_${Math.ceil(s.bitrate/1e5)}`}if(t){const r=tw(t.contentType);e+=`${s?"_":""}${r}_c${t.channels}`}return e}const nw=["NONE","TYPE-0","TYPE-1",null];function Tte(n){return nw.indexOf(n)>-1}const j1=["SDR","PQ","HLG"];function _te(n){return!!n&&j1.indexOf(n)>-1}var Mp={No:"",Yes:"YES",v2:"v2"};function C_(n){const{canSkipUntil:e,canSkipDateRanges:t,age:s}=n,r=s<e/2;return e&&r?t?Mp.v2:Mp.Yes:Mp.No}class sw{constructor(e,t,s){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=s}addDirectives(e){const t=new self.URL(e);return this.msn!==void 0&&t.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}}class af{constructor(e){if(this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.supplemental=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.frameRate=e.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=e.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.codecSet=[e.videoCodec,e.audioCodec].filter(s=>!!s).map(s=>s.substring(0,4)).join(","),"supplemental"in e){var t;this.supplemental=e.supplemental;const s=(t=e.supplemental)==null?void 0:t.videoCodec;s&&s!==e.videoCodec&&(this.codecSet+=`,${s.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 k_(this._audioGroups,e)}hasSubtitleGroup(e){return k_(this._subtitleGroups,e)}get audioGroups(){return this._audioGroups}get subtitleGroups(){return this._subtitleGroups}addGroupId(e,t){if(t){if(e==="audio"){let s=this._audioGroups;s||(s=this._audioGroups=[]),s.indexOf(t)===-1&&s.push(t)}else if(e==="text"){let s=this._subtitleGroups;s||(s=this._subtitleGroups=[]),s.indexOf(t)===-1&&s.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(e=this.audioGroups)==null?void 0:e[0]}get textGroupId(){var e;return(e=this.subtitleGroups)==null?void 0:e[0]}addFallback(){}}function k_(n,e){return!e||!n?!1:n.indexOf(e)!==-1}function Ite(){if(typeof matchMedia=="function"){const n=matchMedia("(dynamic-range: high)"),e=matchMedia("bad query");if(n.media!==e.media)return n.matches===!0}return!1}function Ate(n,e){let t=!1,s=[];if(n&&(t=n!=="SDR",s=[n]),e){s=e.allowedVideoRanges||j1.slice(0);const r=s.join("")!=="SDR"&&!e.videoCodec;t=e.preferHDR!==void 0?e.preferHDR:r&&Ite(),t||(s=["SDR"])}return{preferHDR:t,allowedVideoRanges:s}}const Cte=n=>{const e=new WeakSet;return(t,s)=>{if(n&&(s=n(t,s)),typeof s=="object"&&s!==null){if(e.has(s))return;e.add(s)}return s}},jn=(n,e)=>JSON.stringify(n,Cte(e));function kte(n,e,t,s,r){const i=Object.keys(n),a=s?.channels,l=s?.audioCodec,c=r?.videoCodec,d=a&&parseInt(a)===2;let h=!1,p=!1,m=1/0,y=1/0,x=1/0,w=1/0,S=0,_=[];const{preferHDR:L,allowedVideoRanges:R}=Ate(e,r);for(let k=i.length;k--;){const P=n[i[k]];h||(h=P.channels[2]>0),m=Math.min(m,P.minHeight),y=Math.min(y,P.minFramerate),x=Math.min(x,P.minBitrate),R.filter(F=>P.videoRanges[F]>0).length>0&&(p=!0)}m=et(m)?m:0,y=et(y)?y:0;const M=Math.max(1080,m),V=Math.max(30,y);x=et(x)?x:t,t=Math.max(x,t),p||(e=void 0);const W=i.length>1;return{codecSet:i.reduce((k,P)=>{const N=n[P];if(P===k)return k;if(_=p?R.filter(F=>N.videoRanges[F]>0):[],W){if(N.minBitrate>t)return Ro(P,`min bitrate of ${N.minBitrate} > current estimate of ${t}`),k;if(!N.hasDefaultAudio)return Ro(P,"no renditions with default or auto-select sound found"),k;if(l&&P.indexOf(l.substring(0,4))%5!==0)return Ro(P,`audio codec preference "${l}" not found`),k;if(a&&!d){if(!N.channels[a])return Ro(P,`no renditions with ${a} channel sound found (channels options: ${Object.keys(N.channels)})`),k}else if((!l||d)&&h&&N.channels[2]===0)return Ro(P,"no renditions with stereo sound found"),k;if(N.minHeight>M)return Ro(P,`min resolution of ${N.minHeight} > maximum of ${M}`),k;if(N.minFramerate>V)return Ro(P,`min framerate of ${N.minFramerate} > maximum of ${V}`),k;
vendor: 11,970 bytes, lines 96-106
96if(!_.some(F=>N.videoRanges[F]>0))return Ro(P,`no variants with VIDEO-RANGE of ${jn(_)} found`),k;if(c&&P.indexOf(c.substring(0,4))%5!==0)return Ro(P,`video codec preference "${c}" not found`),k;if(N.maxScore<S)return Ro(P,`max score of ${N.maxScore} < selected max of ${S}`),k}return k&&(L1(P)>=L1(k)||N.fragmentError>n[k].fragmentError)?k:(w=N.minIndex,S=N.maxScore,P)},void 0),videoRanges:_,preferHDR:L,minFramerate:y,minBitrate:x,minIndex:w}}function Ro(n,e){An.log(`[abr] start candidates with "${n}" ignored because ${e}`)}function TN(n){return n.reduce((e,t)=>{let s=e.groups[t.groupId];s||(s=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),s.tracks.push(t);const r=t.channels||"2";return s.channels[r]=(s.channels[r]||0)+1,s.hasDefault=s.hasDefault||t.default,s.hasAutoSelect=s.hasAutoSelect||t.autoselect,s.hasDefault&&(e.hasDefaultAudio=!0),s.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function Rte(n,e,t,s){return n.slice(t,s+1).reduce((r,i,a)=>{if(!i.codecSet)return r;const l=i.audioGroups;let c=r[i.codecSet];c||(r[i.codecSet]=c={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:a,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!l,fragmentError:0}),c.minBitrate=Math.min(c.minBitrate,i.bitrate);const d=Math.min(i.height,i.width);return c.minHeight=Math.min(c.minHeight,d),c.minFramerate=Math.min(c.minFramerate,i.frameRate),c.minIndex=Math.min(c.minIndex,a),c.maxScore=Math.max(c.maxScore,i.score),c.fragmentError+=i.fragmentError,c.videoRanges[i.videoRange]=(c.videoRanges[i.videoRange]||0)+1,l&&l.forEach(h=>{if(!h)return;const p=e.groups[h];p&&(c.hasDefaultAudio=c.hasDefaultAudio||e.hasDefaultAudio?p.hasDefault:p.hasAutoSelect||!e.hasDefaultAudio&&!e.hasAutoSelectAudio,Object.keys(p.channels).forEach(m=>{c.channels[m]=(c.channels[m]||0)+p.channels[m]}))}),r},{})}function R_(n){if(!n)return n;const{lang:e,assocLang:t,characteristics:s,channels:r,audioCodec:i}=n;return{lang:e,assocLang:t,characteristics:s,channels:r,audioCodec:i}}function $o(n,e,t){if("attrs"in n){const s=e.indexOf(n);if(s!==-1)return s}for(let s=0;s<e.length;s++){const r=e[s];if(ud(n,r,t))return s}return-1}function ud(n,e,t){const{groupId:s,name:r,lang:i,assocLang:a,default:l}=n,c=n.forced;return(s===void 0||e.groupId===s)&&(r===void 0||e.name===r)&&(i===void 0||Pte(i,e.lang))&&(i===void 0||e.assocLang===a)&&(l===void 0||e.default===l)&&(c===void 0||e.forced===c)&&(!("characteristics"in n)||Nte(n.characteristics||"",e.characteristics))&&(t===void 0||t(n,e))}function Pte(n,e="--"){return n.length===e.length?n===e:n.startsWith(e)||e.startsWith(n)}function Nte(n,e=""){const t=n.split(","),s=e.split(",");return t.length===s.length&&!t.some(r=>s.indexOf(r)===-1)}function Ku(n,e){const{audioCodec:t,channels:s}=n;return(t===void 0||(e.audioCodec||"").substring(0,4)===t.substring(0,4))&&(s===void 0||s===(e.channels||"2"))}function Lte(n,e,t,s,r){const i=e[s],l=e.reduce((m,y,x)=>{const w=y.uri;return(m[w]||(m[w]=[])).push(x),m},{})[i.uri];l.length>1&&(s=Math.max.apply(Math,l));const c=i.videoRange,d=i.frameRate,h=i.codecSet.substring(0,4),p=P_(e,s,m=>{if(m.videoRange!==c||m.frameRate!==d||m.codecSet.substring(0,4)!==h)return!1;const y=m.audioGroups,x=t.filter(w=>!y||y.indexOf(w.groupId)!==-1);return $o(n,x,r)>-1});return p>-1?p:P_(e,s,m=>{const y=m.audioGroups,x=t.filter(w=>!y||y.indexOf(w.groupId)!==-1);return $o(n,x,r)>-1})}function P_(n,e,t){for(let s=e;s>-1;s--)if(t(n[s]))return s;for(let s=e+1;s<n.length;s++)if(t(n[s]))return s;return-1}function O1(n,e){var t;return!!n&&n!==((t=e.loadLevelObj)==null?void 0:t.uri)}class _N extends Pa{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=t=>{var s;const{fragCurrent:r,partCurrent:i,hls:a}=this,{autoLevelEnabled:l,media:c}=a;if(!r||!c)return;const d=performance.now(),h=i?i.stats:r.stats,p=i?i.duration:r.duration,m=d-h.loading.start,y=a.minAutoLevel,x=r.level,w=this._nextAutoLevel;if(h.aborted||h.loaded&&h.loaded===h.total||x<=y){this.clearTimer(),this._nextAutoLevel=-1;return}if(!l)return;const S=w>-1&&w!==x,_=!!t||S;if(!_&&(c.paused||!c.playbackRate||!c.readyState))return;const L=a.mainForwardBufferInfo;if(!_&&L===null)return;const R=this.bwEstimator.getEstimateTTFB(),M=Math.abs(c.playbackRate);if(m<=Math.max(R,1e3*(p/(M*2))))return;const V=L?L.len/M:0,W=h.loading.first?h.loading.first-h.loading.start:-1,I=h.loaded&&W>-1,k=this.getBwEstimate(),P=a.levels,N=P[x],F=Math.max(h.loaded,Math.round(p*(r.bitrate||N.averageBitrate)/8));let z=I?m-W:m;z<1&&I&&(z=Math.min(m,h.loaded*8/k));const U=I?h.loaded*1e3/z:0,fe=R/1e3,oe=U?(F-h.loaded)/U:F*8/k+fe;if(oe<=V)return;const X=U?U*8:k,Q=((s=t?.details||this.hls.latestLevelDetails)==null?void 0:s.live)===!0,G=this.hls.config.abrBandWidthUpFactor;let Y=Number.POSITIVE_INFINITY,ee;for(ee=x-1;ee>y;ee--){const Fe=P[ee].maxBitrate,_e=!P[ee].details||Q;if(Y=this.getTimeToLoadFrag(fe,X,p*Fe,_e),Y<Math.min(V,p+fe))break}if(Y>=oe||Y>p*10)return;I?this.bwEstimator.sample(m-Math.min(R,W),h.loaded):this.bwEstimator.sampleTTFB(m);const H=P[ee].maxBitrate;this.getBwEstimate()*G>H&&this.resetEstimator(H);const K=this.findBestLevel(H,y,ee,0,V,1,1);K>-1&&(ee=K),this.warn(`Fragment ${r.sn}${i?" part "+i.index:""} of level ${x} is loading too slowly; 97 Fragment duration: ${r.duration.toFixed(3)} 98 Time to underbuffer: ${V.toFixed(3)} s 99 Estimated load time for current fragment: ${oe.toFixed(3)} s 100 Estimated load time for down switch fragment: ${Y.toFixed(3)} s 101 TTFB estimate: ${W|0} ms 102 Current BW estimate: ${et(k)?k|0:"Unknown"} bps 103 New BW estimate: ${this.getBwEstimate()|0} bps 104 Switching to level ${ee} @ ${H|0} bps`),a.nextLoadLevel=a.nextAutoLevel=ee,this.clearTimer();const pe=()=>{if(this.clearTimer(),this.fragCurrent===r&&this.hls.loadLevel===ee&&ee>0){const Fe=this.getStarvationDelay();if(this.warn(`Aborting inflight request ${ee>0?"and switching down":""} 105 Fragment duration: ${r.duration.toFixed(3)} s 106 Time to underbuffer: ${Fe.toFixed(3)} s`),r.abortRequests(),this.fragCurrent=this.partCurrent=null,ee>y){let _e=this.findBestLevel(this.hls.levels[y].bitrate,y,ee,0,Fe,1,1);_e===-1&&(_e=y),this.hls.nextLoadLevel=this.hls.nextAutoLevel=_e,this.resetEstimator(this.hls.levels[_e].bitrate)}}};S||oe>Y*2?pe():this.timer=self.setInterval(pe,Y*1e3),a.trigger(j.FRAG_LOAD_EMERGENCY_ABORTED,{frag:r,part:i,stats:h})},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 Vee(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){const{hls:e}=this;e.on(j.MANIFEST_LOADING,this.onManifestLoading,this),e.on(j.FRAG_LOADING,this.onFragLoading,this),e.on(j.FRAG_LOADED,this.onFragLoaded,this),e.on(j.FRAG_BUFFERED,this.onFragBuffered,this),e.on(j.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(j.LEVEL_LOADED,this.onLevelLoaded,this),e.on(j.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(j.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(j.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e&&(e.off(j.MANIFEST_LOADING,this.onManifestLoading,this),e.off(j.FRAG_LOADING,this.onFragLoading,this),e.off(j.FRAG_LOADED,this.onFragLoaded,this),e.off(j.FRAG_BUFFERED,this.onFragBuffered,this),e.off(j.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(j.LEVEL_LOADED,this.onLevelLoaded,this),e.off(j.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(j.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(j.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 s=t.frag;if(!this.ignoreFragment(s)){if(!s.bitrateTest){var r;this.fragCurrent=s,this.partCurrent=(r=t.part)!=null?r: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 he.BUFFER_ADD_CODEC_ERROR:case he.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case he.FRAG_LOAD_TIMEOUT:{const s=t.frag,{fragCurrent:r,partCurrent:i}=this;if(s&&r&&s.sn===r.sn&&s.level===r.level){const a=performance.now(),l=i?i.stats:s.stats,c=a-l.loading.start,d=l.loading.first?l.loading.first-l.loading.start:-1;if(l.loaded&&d>-1){const p=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(c-Math.min(p,d),l.loaded)}else this.bwEstimator.sampleTTFB(c)}break}}}getTimeToLoadFrag(e,t,s,r){const i=e+s/t,a=r?e+this.lastLevelLoadSec:0;return i+a}onLevelLoaded(e,t){const s=this.hls.config,{loading:r}=t.stats,i=r.end-r.first;et(i)&&(this.lastLevelLoadSec=i/1e3),t.details.live?this.bwEstimator.update(s.abrEwmaSlowLive,s.abrEwmaFastLive):this.bwEstimator.update(s.abrEwmaSlowVoD,s.abrEwmaFastVoD),this.timer>-1&&this._abandonRulesCheck(t.levelInfo)}onFragLoaded(e,{frag:t,part:s}){const r=s?s.stats:t.stats;if(t.type===st.MAIN&&this.bwEstimator.sampleTTFB(r.loading.first-r.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),t.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){const i=s?s.duration:t.duration,a=this.hls.levels[t.level],l=(a.loaded?a.loaded.bytes:0)+r.loaded,c=(a.loaded?a.loaded.duration:0)+i;a.loaded={bytes:l,duration:c},a.realBitrate=Math.round(8*l/c)}if(t.bitrateTest){const i={stats:r,frag:t,part:s,id:t.type};this.onFragBuffered(j.FRAG_BUFFERED,i),t.bitrateTest=!1}else this.lastLoadedFragLevel=t.level}}onFragBuffered(e,t){const{frag:s,part:r}=t,i=r!=null&&r.stats.loaded?r.stats:s.stats;if(i.aborted||this.ignoreFragment(s))return;const a=i.parsing.end-i.loading.start-Math.min(i.loading.first-i.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(a,i.loaded),i.bwEstimate=this.getBwEstimate(),s.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==st.MAIN||e.sn==="initSegment"}clearTimer(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}get firstAutoLevel(){const{maxAutoLevel:e,minAutoLevel:t}=this.hls,s=this.getBwEstimate(),r=this.hls.config.maxStarvationDelay,i=this.findBestLevel(s,t,e,0,r,1,1);if(i>-1)return i;const a=this.hls.firstLevel,l=Math.min(Math.max(a,t),e);return this.warn(`Could not find best starting auto level. Defaulting to first in playlist ${a} clamped to ${l}`),l}get forcedAutoLevel(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}get nextAutoLevel(){const e=this.forcedAutoLevel,s=this.bwEstimator.canEstimate(),r=this.lastLoadedFragLevel>-1;if(e!==-1&&(!s||!r||this.nextAutoLevelKey===this.getAutoLevelKey()))return e;const i=s&&r?this.getNextABRAutoLevel():this.firstAutoLevel;if(e!==-1){const a=this.hls.levels;if(a.length>Math.max(e,i)&&a[e].loadError<=a[i].loadError)return e}return this._nextAutoLevel=i,this.nextAutoLevelKey=this.getAutoLevelKey(),i}getAutoLevelKey(){return`${this.getBwEstimate()}
106_${this.getStarvationDelay().toFixed(2)}`}getNextABRAutoLevel(){const{fragCurrent:e,partCurrent:t,hls:s}=this;if(s.levels.length<=1)return s.loadLevel;const{maxAutoLevel:r,config:i,minAutoLevel:a}=s,l=t?t.duration:e?e.duration:0,c=this.getBwEstimate(),d=this.getStarvationDelay();let h=i.abrBandWidthFactor,p=i.abrBandWidthUpFactor;if(d){const S=this.findBestLevel(c,a,r,d,0,h,p);if(S>=0)return this.rebufferNotice=-1,S}let m=l?Math.min(l,i.maxStarvationDelay):i.maxStarvationDelay;if(!d){const S=this.bitrateTestDelay;S&&(m=(l?Math.min(l,i.maxLoadingDelay):i.maxLoadingDelay)-S,this.info(`bitrate test took ${Math.round(1e3*S)}ms, set first fragment max fetchDuration to ${Math.round(1e3*m)} ms`),h=p=1)}const y=this.findBestLevel(c,a,r,d,m,h,p);if(this.rebufferNotice!==y&&(this.rebufferNotice=y,this.info(`${d?"rebuffering expected":"buffer is empty"}, optimal quality level ${y}`)),y>-1)return y;const x=s.levels[a],w=s.loadLevelObj;return w&&x?.bitrate<w.bitrate?a:s.loadLevel}getStarvationDelay(){const e=this.hls,t=e.media;if(!t)return 1/0;const s=t&&t.playbackRate!==0?Math.abs(t.playbackRate):1,r=e.mainForwardBufferInfo;return(r?r.len:0)/s}getBwEstimate(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}findBestLevel(e,t,s,r,i,a,l){var c;const d=r+i,h=this.lastLoadedFragLevel,p=h===-1?this.hls.firstLevel:h,{fragCurrent:m,partCurrent:y}=this,{levels:x,allAudioTracks:w,loadLevel:S,config:_}=this.hls;if(x.length===1)return 0;const L=x[p],R=!!((c=this.hls.latestLevelDetails)!=null&&c.live),M=S===-1||h===-1;let V,W="SDR",I=L?.frameRate||0;const{audioPreference:k,videoPreference:P}=_,N=this.audioTracksByGroup||(this.audioTracksByGroup=TN(w));let F=-1;if(M){if(this.firstSelection!==-1)return this.firstSelection;const X=this.codecTiers||(this.codecTiers=Rte(x,N,t,s)),Q=kte(X,W,e,k,P),{codecSet:G,videoRanges:Y,minFramerate:ee,minBitrate:H,minIndex:K,preferHDR:pe}=Q;F=K,V=G,W=pe?Y[Y.length-1]:Y[0],I=ee,e=Math.max(e,H),this.log(`picked start tier ${jn(Q)}`)}else V=L?.codecSet,W=L?.videoRange;const z=y?y.duration:m?m.duration:0,U=this.bwEstimator.getEstimateTTFB()/1e3,fe=[];for(let X=s;X>=t;X--){var oe;const Q=x[X],G=X>p;if(!Q)continue;if(_.useMediaCapabilities&&!Q.supportedResult&&!Q.supportedPromise){const _e=navigator.mediaCapabilities;typeof _e?.decodingInfo=="function"&&vte(Q,N,W,I,e,k)?(Q.supportedPromise=SN(Q,N,_e,this.supportedCache),Q.supportedPromise.then(ze=>{if(!this.hls)return;Q.supportedResult=ze;const Ye=this.hls.levels,tt=Ye.indexOf(Q);ze.error?this.warn(`MediaCapabilities decodingInfo error: "${ze.error}" for level ${tt} ${jn(ze)}`):ze.supported?ze.decodingInfoResults.some(lt=>lt.smooth===!1||lt.powerEfficient===!1)&&this.log(`MediaCapabilities decodingInfo for level ${tt} not smooth or powerEfficient: ${jn(ze)}`):(this.warn(`Unsupported MediaCapabilities decodingInfo result for level ${tt} ${jn(ze)}`),tt>-1&&Ye.length>1&&(this.log(`Removing unsupported level ${tt}`),this.hls.removeLevel(tt),this.hls.loadLevel===-1&&(this.hls.nextLoadLevel=0)))}).catch(ze=>{this.warn(`Error handling MediaCapabilities decodingInfo: ${ze}`)})):Q.supportedResult=bN}if((V&&Q.codecSet!==V||W&&Q.videoRange!==W||G&&I>Q.frameRate||!G&&I>0&&I<Q.frameRate||(oe=Q.supportedResult)!=null&&(oe=oe.decodingInfoResults)!=null&&oe.some(_e=>_e.smooth===!1))&&(!M||X!==F)){fe.push(X);continue}const Y=Q.details,ee=(y?Y?.partTarget:Y?.averagetargetduration)||z;let H;G?H=l*e:H=a*e;const K=z&&r>=z*2&&i===0?Q.averageBitrate:Q.maxBitrate,pe=this.getTimeToLoadFrag(U,H,K*ee,Y===void 0);if(H>=K&&(X===h||Q.loadError===0&&Q.fragmentError===0)&&(pe<=U||!et(pe)||R&&!this.bitrateTestDelay||pe<d)){const _e=this.forcedAutoLevel;return X!==S&&(_e===-1||_e!==S)&&(fe.length&&this.trace(`Skipped level(s) ${fe.join(",")} of ${s} max with CODECS and VIDEO-RANGE:"${x[fe[0]].codecs}" ${x[fe[0]].videoRange}; not compatible with "${V}" ${W}`),this.info(`switch candidate:${p}->${X} adjustedbw(${Math.round(H)})-bitrate=${Math.round(H-K)} ttfb:${U.toFixed(1)} avgDuration:${ee.toFixed(1)} maxFetchDuration:${d.toFixed(1)} fetchDuration:${pe.toFixed(1)}
106 firstSelection:${M} codecSet:${Q.codecSet} videoRange:${Q.videoRange} hls.loadLevel:${S}`)),M&&(this.firstSelection=X),X}}return-1}set nextAutoLevel(e){const t=this.deriveNextAutoLevel(e);this._nextAutoLevel!==t&&(this.nextAutoLevelKey="",this._nextAutoLevel=t)}deriveNextAutoLevel(e){const{maxAutoLevel:t,minAutoLevel:s}=this.hls;return Math.min(Math.max(e,s),t)}}const IN={search:function(n,e){let t=0,s=n.length-1,r=null,i=null;for(;t<=s;){r=(t+s)/2|0,i=n[r];const a=e(i);if(a>0)t=r+1;else if(a<0)s=r-1;else return i}return null}};function Dte(n,e,t){if(e===null||!Array.isArray(n)||!n.length||!et(e))return null;const s=n[0].programDateTime;if(e<(s||0))return null;const r=n[n.length-1].endProgramDateTime;if(e>=(r||0))return null;for(let i=0;i<n.length;++i){const a=n[i];if(Ote(e,t,a))return a}return null}function Id(n,e,t=0,s=0,r=.005){let i=null;if(n){i=e[1+n.sn-e[0].sn]||null;const l=n.endDTS-t;l>0&&l<15e-7&&(t+=15e-7),i&&n.level!==i.level&&i.end<=n.end&&(i=e[2+n.sn-e[0].sn]||null)}else t===0&&e[0].start===0&&(i=e[0]);if(i&&((!n||n.level===i.level)&&N_(t,s,i)===0||jte(i,n,Math.min(r,s))))return i;const a=IN.search(e,N_.bind(null,t,s));return a&&(a!==n||!i)?a:i}function jte(n,e,t){if(e&&e.start===0&&e.level<n.level&&(e.endPTS||0)>0){const s=e.tagList.reduce((r,i)=>(i[0]==="INF"&&(r+=parseFloat(i[1])),r),t);return n.start<=s}return!1}function N_(n=0,e=0,t){if(t.start<=n&&t.start+t.duration>n)return 0;const s=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0));return t.start+t.duration-s<=n?1:t.start-s>n&&t.start?-1:0}function Ote(n,e,t){const s=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0))*1e3;return(t.endProgramDateTime||0)-s>n}function AN(n,e,t){if(n&&n.startCC<=e&&n.endCC>=e){let s=n.fragments;const{fragmentHint:r}=n;r&&(s=s.concat(r));let i;return IN.search(s,a=>a.cc<e?1:a.cc>e?-1:(i=a,a.end<=t?1:a.start>t?-1:0)),i||null}return null}function M1(n){switch(n.details){case he.FRAG_LOAD_TIMEOUT:case he.KEY_LOAD_TIMEOUT:case he.LEVEL_LOAD_TIMEOUT:case he.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function CN(n){return n.details.startsWith("key")}function kN(n){return CN(n)&&!!n.frag&&!n.frag.decryptdata}function L_(n,e){const t=M1(e);return n.default[`${t?"timeout":"error"}Retry`]}function rS(n,e){const t=n.backoff==="linear"?1:Math.pow(2,e);return Math.min(t*n.retryDelayMs,n.maxRetryDelayMs)}function D_(n){return In(In({},n),{errorRetry:null,timeoutRetry:null})}function F1(n,e,t,s){if(!n)return!1;const r=s?.code,i=e<n.maxNumRetry&&(Mte(r)||!!t);return n.shouldRetry?n.shouldRetry(n,e,t,s,i):i}function Mte(n){return rw(n)||!!n&&(n<400||n>499)}function rw(n){return n===0&&navigator.onLine===!1}var Ws={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},vi={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,MoveAllAlternatesMatchingKey:4,SwitchToSDR:8};class RN extends Pa{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(j.ERROR,this.onError,this),e.on(j.MANIFEST_LOADING,this.onManifestLoading,this),e.on(j.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const e=this.hls;e&&(e.off(j.ERROR,this.onError,this),e.off(j.ERROR,this.onErrorOut,this),e.off(j.MANIFEST_LOADING,this.onManifestLoading,this),e.off(j.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null}startLoad(e){}stopLoad(){this.playlistError=0}getVariantLevelIndex(e){return e?.type===st.MAIN?e.level:this.getVariantIndex()}getVariantIndex(){var e;const t=this.hls,s=t.currentLevel;return(e=t.loadLevelObj)!=null&&e.details||s===-1?t.loadLevel:s}variantHasKey(e,t){if(e){var s;if((s=e.details)!=null&&s.hasKey(t))return!0;const r=e.audioGroups;if(r)return this.hls.allAudioTracks.filter(a=>r.indexOf(a.groupId)>=0).some(a=>{var l;return(l=a.details)==null?void 0:l.hasKey(t)})}return!1}onManifestLoading(){this.playlistError=0}onLevelUpdated(){this.playlistError=0}onError(e,t){var s;if(t.fatal)return;const r=this.hls,i=t.context;switch(t.details){case he.FRAG_LOAD_ERROR:case he.FRAG_LOAD_TIMEOUT:case he.KEY_LOAD_ERROR:case he.KEY_LOAD_TIMEOUT:t.errorAction=this.getFragRetryOrSwitchAction(t);return;case he.FRAG_PARSING_ERROR:if((s=t.frag)!=null&&s.gap){t.errorAction=$h();return}case he.FRAG_GAP:case he.FRAG_DECRYPT_ERROR:{t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=Ws.SendAlternateToPenaltyBox;return}case he.LEVEL_EMPTY_ERROR:case he.LEVEL_PARSING_ERROR:{var a;const c=t.parent===st.MAIN?t.level:r.loadLevel;t.details===he.LEVEL_EMPTY_ERROR&&((a=t.context)!=null&&(a=a.levelDetails)!=null&&a.live)?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,c):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,c))}return;case he.LEVEL_LOAD_ERROR:case he.LEVEL_LOAD_TIMEOUT:typeof i?.level=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,i.level));return;case he.AUDIO_TRACK_LOAD_ERROR:case he.AUDIO_TRACK_LOAD_TIMEOUT:case he.SUBTITLE_LOAD_ERROR:case he.SUBTITLE_TRACK_LOAD_TIMEOUT:if(i){const c=r.loadLevelObj;if(c&&(i.type===Zt.AUDIO_TRACK&&c.hasAudioGroup(i.groupId)||i.type===Zt.SUBTITLE_TRACK&&c.hasSubtitleGroup(i.groupId))){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,r.loadLevel),t.errorAction.action=Ws.SendAlternateToPenaltyBox,t.errorAction.flags=vi.MoveAllAlternatesMatchingHost;return}}return;case he.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:t.errorAction={action:Ws.SendAlternateToPenaltyBox,flags:vi.MoveAllAlternatesMatchingHDCP};return;case he.KEY_SYSTEM_SESSION_UPDATE_FAILED:case he.KEY_SYSTEM_STATUS_INTERNAL_ERROR:case he.KEY_SYSTEM_NO_SESSION:t.errorAction={action:Ws.SendAlternateToPenaltyBox,flags:vi.MoveAllAlternatesMatchingKey};return;
106case he.BUFFER_ADD_CODEC_ERROR:case he.REMUX_ALLOC_ERROR:case he.BUFFER_APPEND_ERROR:if(!t.errorAction){var l;t.errorAction=this.getLevelSwitchAction(t,(l=t.level)!=null?l:r.loadLevel)}return;case he.INTERNAL_EXCEPTION:case he.BUFFER_APPENDING_ERROR:case he.BUFFER_FULL_ERROR:case he.LEVEL_SWITCH_ERROR:case he.BUFFER_STALLED_ERROR:case he.BUFFER_SEEK_OVER_HOLE:case he.BUFFER_NUDGE_ON_STALL:t.errorAction=$h();return}t.type===xt.KEY_SYSTEM_ERROR&&(t.levelRetry=!1,t.errorAction=$h())}getPlaylistRetryOrSwitchAction(e,t){const s=this.hls,r=L_(s.config.playlistLoadPolicy,e),i=this.playlistError++;if(F1(r,i,M1(e),e.response))return{action:Ws.RetryRequest,flags:vi.None,retryConfig:r,retryCount:i};const l=this.getLevelSwitchAction(e,t);return r&&(l.retryConfig=r,l.retryCount=i),l}getFragRetryOrSwitchAction(e){const t=this.hls,s=this.getVariantLevelIndex(e.frag),r=t.levels[s],{fragLoadPolicy:i,keyLoadPolicy:a}=t.config,l=L_(CN(e)?a:i,e),c=t.levels.reduce((h,p)=>h+p.fragmentError,0);if(r&&(e.details!==he.FRAG_GAP&&r.fragmentError++,!kN(e)&&F1(l,c,M1(e),e.response)))return{action:Ws.RetryRequest,flags:vi.None,retryConfig:l,retryCount:c};const d=this.getLevelSwitchAction(e,s);return l&&(d.retryConfig=l,d.retryCount=c),d}getLevelSwitchAction(e,t){const s=this.hls;t==null&&(t=s.loadLevel);const r=this.hls.levels[t];if(r){var i,a;const d=e.details;r.loadError++,d===he.BUFFER_APPEND_ERROR&&r.fragmentError++;let h=-1;const{levels:p,loadLevel:m,minAutoLevel:y,maxAutoLevel:x}=s;!s.autoLevelEnabled&&!s.config.preserveManualLevelOnError&&(s.loadLevel=-1);const w=(i=e.frag)==null?void 0:i.type,_=(w===st.AUDIO&&d===he.FRAG_PARSING_ERROR||e.sourceBufferName==="audio"&&(d===he.BUFFER_ADD_CODEC_ERROR||d===he.BUFFER_APPEND_ERROR))&&p.some(({audioCodec:W})=>r.audioCodec!==W),R=e.sourceBufferName==="video"&&(d===he.BUFFER_ADD_CODEC_ERROR||d===he.BUFFER_APPEND_ERROR)&&p.some(({codecSet:W,audioCodec:I})=>r.codecSet!==W&&r.audioCodec===I),{type:M,groupId:V}=(a=e.context)!=null?a:{};for(let W=p.length;W--;){const I=(W+m)%p.length;if(I!==m&&I>=y&&I<=x&&p[I].loadError===0){var l,c;const k=p[I];if(d===he.FRAG_GAP&&w===st.MAIN&&e.frag){const P=p[I].details;if(P){const N=Id(e.frag,P.fragments,e.frag.start);if(N!=null&&N.gap)continue}}else{if(M===Zt.AUDIO_TRACK&&k.hasAudioGroup(V)||M===Zt.SUBTITLE_TRACK&&k.hasSubtitleGroup(V))continue;if(w===st.AUDIO&&(l=r.audioGroups)!=null&&l.some(P=>k.hasAudioGroup(P))||w===st.SUBTITLE&&(c=r.subtitleGroups)!=null&&c.some(P=>k.hasSubtitleGroup(P))||_&&r.audioCodec===k.audioCodec||R&&r.codecSet===k.codecSet||!_&&r.codecSet!==k.codecSet)continue}h=I;break}}if(h>-1&&s.loadLevel!==h)return e.levelRetry=!0,this.playlistError=0,{action:Ws.SendAlternateToPenaltyBox,flags:vi.None,nextAutoLevel:h}}return{action:Ws.SendAlternateToPenaltyBox,flags:vi.MoveAllAlternatesMatchingHost}}onErrorOut(e,t){var s;switch((s=t.errorAction)==null?void 0:s.action){case Ws.DoNothing:break;case Ws.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),!t.errorAction.resolved&&t.details!==he.FRAG_GAP?t.fatal=!0:/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());break;case Ws.RetryRequest:break}if(t.fatal){this.hls.stopLoad();return}}sendAlternateToPenaltyBox(e){const t=this.hls,s=e.errorAction;if(!s)return;const{flags:r}=s,i=s.nextAutoLevel;switch(r){case vi.None:this.switchLevel(e,i);break;case vi.MoveAllAlternatesMatchingHDCP:{const c=this.getVariantLevelIndex(e.frag),d=t.levels[c],h=d?.attrs["HDCP-LEVEL"];if(s.hdcpLevel=h,h==="NONE")this.warn("HDCP policy resticted output with HDCP-LEVEL=NONE");else if(h){t.maxHdcpLevel=nw[nw.indexOf(h)-1],s.resolved=!0,this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}}case vi.MoveAllAlternatesMatchingKey:{const c=e.decryptdata;if(c){const d=this.hls.levels,h=d.length;for(let m=h;m--;)if(this.variantHasKey(d[m],c)){var a,l;this.log(`Banned key found in level ${m} (${d[m].bitrate}bps) or audio group "${(a=d[m].audioGroups)==null?void 0:a.join(",")}" (${(l=e.frag)==null?void 0:l.type} fragment) ${vr(c.keyId||[])}`),d[m].fragmentError++,d[m].loadError++,this.log(`Removing level ${m} with key error (${e.error})`),this.hls.removeLevel(m)}const p=e.frag;if(this.hls.levels.length<h)s.resolved=!0;else if(p&&p.type!==st.MAIN){const m=p.decryptdata;m&&!c.matches(m)&&(s.resolved=!0)}}break}}s.resolved||this.switchLevel(e,i)}switchLevel(e,t){if(t!==void 0&&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===he.BUFFER_ADD_CODEC_ERROR&&e.mimeType&&e.sourceBufferName!=="audiovideo")){const s=tw(e.mimeType),r=this.hls.levels;for(let i=r.length;i--;)r[i][`${e.sourceBufferName}Codec`]===s&&(this.log(`Removing level ${i} for ${e.details} ("${s}" not supported)`),this.hls.removeLevel(i))}}}function $h(n){const e={action:Ws.DoNothing,flags:vi.None};return n&&(e.resolved=!0),e}var Gs={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};class Fte{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(j.MANIFEST_LOADING,this.onManifestLoading,this),e.on(j.BUFFER_APPENDED,this.onBufferAppended,this),e.on(j.FRAG_BUFFERED,this.onFragBuffered,this),e.on(j.FRAG_LOADED,this.onFragLoaded,this))}_unregisterListeners(){const{hls:e}=this;e&&(e.off(j.MANIFEST_LOADING,this.onManifestLoading,this),e.off(j.BUFFER_APPENDED,this.onBufferAppended,this),e.off(j.FRAG_BUFFERED,this.onFragBuffered,this),e.off(j.FRAG_LOADED,this.onFragLoaded,this))}destroy(){this._unregisterListeners(),this.hls=this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){const s=this.activePartLists[t];if(s)for(let r=s.length;r--;){const i=s[r];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,s){const{fragments:r}=this,i=Object.keys(r);for(let a=i.length;a--;){const l=r[i[a]];if(l?.body.type===t&&(!s||l.buffered)){const c=l.body;if(c.start<=e&&e<=c.end)return c}}return null}detectEvictedFragments(e,t,s,r,i){this.timeRanges&&(this.timeRanges[e]=t);const a=r?.fragment.sn||-1;
vendor: 24,117 bytes, line 106
106Object.keys(this.fragments).forEach(l=>{const c=this.fragments[l];if(!c||a>=c.body.sn)return;if(!c.buffered&&(!c.loaded||i)){c.body.type===s&&this.removeFragment(c.body);return}const d=c.range[e];if(d){if(d.time.length===0){this.removeFragment(c.body);return}d.time.some(h=>{const p=!this.isTimeBuffered(h.startPTS,h.endPTS,t);return p&&this.removeFragment(c.body),p})}})}detectPartialFragments(e){const t=this.timeRanges;if(!t||e.frag.sn==="initSegment")return;const s=e.frag,r=dh(s),i=this.fragments[r];if(!i||i.buffered&&s.gap)return;const a=!s.relurl;Object.keys(t).forEach(l=>{const c=s.elementaryStreams[l];if(!c)return;const d=t[l],h=a||c.partial===!0;i.range[l]=this.getBufferedTimes(s,e.part,h,d)}),i.loaded=null,Object.keys(i.range).length?(this.bufferedEnd(i,s),t0(i)||this.removeParts(s.sn-1,s.type)):this.removeFragment(i.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 s=this.activePartLists[t];s&&(this.activePartLists[t]=j_(s,r=>r.fragment.sn>=e))}fragBuffered(e,t){const s=dh(e);let r=this.fragments[s];!r&&t&&(r=this.fragments[s]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),r&&(r.loaded=null,this.bufferedEnd(r,e))}getBufferedTimes(e,t,s,r){const i={time:[],partial:s},a=e.start,l=e.end,c=e.minEndPTS||l,d=e.maxStartPTS||a;for(let h=0;h<r.length;h++){const p=r.start(h)-this.bufferPadding,m=r.end(h)+this.bufferPadding;if(d>=p&&c<=m){i.time.push({startPTS:Math.max(a,r.start(h)),endPTS:Math.min(l,r.end(h))});break}else if(a<m&&l>p){const y=Math.max(a,r.start(h)),x=Math.min(l,r.end(h));x>y&&(i.partial=!0,i.time.push({startPTS:y,endPTS:x}))}else if(l<=p)break}return i}getPartialFragment(e){let t=null,s,r,i,a=0;const{bufferPadding:l,fragments:c}=this;return Object.keys(c).forEach(d=>{const h=c[d];h&&t0(h)&&(r=h.body.start-l,i=h.body.end+l,e>=r&&e<=i&&(s=Math.min(e-r,i-e),a<=s&&(t=h.body,a=s)))}),t}isEndListAppended(e){const t=this.endListFragments[e];return t!==void 0&&(t.buffered||t0(t))}getState(e){const t=dh(e),s=this.fragments[t];return s?s.buffered?t0(s)?Gs.PARTIAL:Gs.OK:Gs.APPENDING:Gs.NOT_LOADED}isTimeBuffered(e,t,s){let r,i;for(let a=0;a<s.length;a++){if(r=s.start(a)-this.bufferPadding,i=s.end(a)+this.bufferPadding,e>=r&&t<=i)return!0;if(t<=r)return!1}return!1}onManifestLoading(){this.removeAllFragments()}onFragLoaded(e,t){if(t.frag.sn==="initSegment"||t.frag.bitrateTest)return;const s=t.frag,r=t.part?null:t,i=dh(s);this.fragments[i]={body:s,appendedPTS:null,loaded:r,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){const{frag:s,part:r,timeRanges:i,type:a}=t;if(s.sn==="initSegment")return;const l=s.type;if(r){let d=this.activePartLists[l];d||(this.activePartLists[l]=d=[]),d.push(r)}this.timeRanges=i;const c=i[a];this.detectEvictedFragments(a,c,l,r)}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){const t=dh(e);return!!this.fragments[t]}hasFragments(e){const{fragments:t}=this,s=Object.keys(t);if(!e)return s.length>0;for(let r=s.length;r--;){const i=t[s[r]];if(i?.body.type===e)return!0}return!1}hasParts(e){var t;return!!((t=this.activePartLists[e])!=null&&t.length)}removeFragmentsInRange(e,t,s,r,i){r&&!this.hasGaps||Object.keys(this.fragments).forEach(a=>{const l=this.fragments[a];if(!l)return;const c=l.body;c.type!==s||r&&!c.gap||c.start<t&&c.end>e&&(l.buffered||i)&&this.removeFragment(c)})}removeFragment(e){const t=dh(e);e.clearElementaryStreamInfo();const s=this.activePartLists[e.type];if(s){const r=e.sn;this.activePartLists[e.type]=j_(s,i=>i.fragment.sn!==r)}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=(e=this.hls)==null||(e=e.latestLevelDetails)==null?void 0:e.partList;t&&t.forEach(s=>s.clearElementaryStreamInfo())}}function t0(n){var e,t,s;return n.buffered&&!!(n.body.gap||(e=n.range.video)!=null&&e.partial||(t=n.range.audio)!=null&&t.partial||(s=n.range.audiovideo)!=null&&s.partial)}function dh(n){return`${n.type}_${n.level}_${n.sn}`}function j_(n,e){return n.filter(t=>{const s=e(t);return s||t.clearElementaryStreamInfo(),s})}var hu={cbc:0,ctr:1};class Ute{constructor(e,t,s){this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=e,this.aesIV=t,this.aesMode=s}decrypt(e,t){switch(this.aesMode){case hu.cbc:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e);case hu.ctr:return this.subtle.decrypt({name:"AES-CTR",counter:this.aesIV,length:64},t,e);default:throw new Error(`[AESCrypto] invalid aes mode ${this.aesMode}`)}}}function Vte(n){const e=n.byteLength,t=e&&new DataView(n.buffer).getUint8(e-1);return t?n.slice(0,e-t):n}class Bte{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),s=new Uint32Array(4);for(let r=0;r<4;r++)s[r]=t.getUint32(r*4);return s}initTable(){const e=this.sBox,t=this.invSBox,s=this.subMix,r=s[0],i=s[1],a=s[2],l=s[3],c=this.invSubMix,d=c[0],h=c[1],p=c[2],m=c[3],y=new Uint32Array(256);let x=0,w=0,S=0;for(S=0;S<256;S++)S<128?y[S]=S<<1:y[S]=S<<1^283;for(S=0;S<256;S++){let _=w^w<<1^w<<2^w<<3^w<<4;_=_>>>8^_&255^99,e[x]=_,t[_]=x;const L=y[x],R=y[L],M=y[R];let V=y[_]*257^_*16843008;r[x]=V<<24|V>>>8,i[x]=V<<16|V>>>16,a[x]=V<<8|V>>>24,l[x]=V,V=M*16843009^R*65537^L*257^x*16843008,d[_]=V<<24|V>>>8,h[_]=V<<16|V>>>16,p[_]=V<<8|V>>>24,m[_]=V,x?(x=L^y[y[y[M^L]]],w^=y[y[w]]):x=w=1}}expandKey(e){const t=this.uint8ArrayToUint32Array_(e);let s=!0,r=0;for(;r<t.length&&s;)s=t[r]===this.key[r],r++;if(s)return;this.key=t;const i=this.keySize=t.length;if(i!==4&&i!==6&&i!==8)throw new Error("Invalid aes key size="+i);const a=this.ksRows=(i+6+1)*4;let l,c;const d=this.keySchedule=new Uint32Array(a),h=this.invKeySchedule=new Uint32Array(a),p=this.sBox,m=this.rcon,y=this.invSubMix,x=y[0],w=y[1],S=y[2],_=y[3];let L,R;for(l=0;l<a;l++){if(l<i){L=d[l]=t[l];continue}R=L,l%i===0?(R=R<<8|R>>>24,R=p[R>>>24]<<24|p[R>>>16&255]<<16|p[R>>>8&255]<<8|p[R&255],R^=m[l/i|0]<<24):i>6&&l%i===4&&(R=p[R>>>24]<<24|p[R>>>16&255]<<16|p[R>>>8&255]<<8|p[R&255]),d[l]=L=(d[l-i]^R)>>>0}for(c=0;c<a;c++)l=a-c,c&3?R=d[l]:R=d[l-4],c<4||l<=4?h[c]=R:h[c]=x[p[R>>>24]]^w[p[R>>>16&255]]^S[p[R>>>8&255]]^_[p[R&255]],h[c]=h[c]>>>0}networkToHostOrderSwap(e){return e<<24|(e&65280)<<8|(e&16711680)>>8|e>>>24}decrypt(e,t,s){const r=this.keySize+6,i=this.invKeySchedule,a=this.invSBox,l=this.invSubMix,c=l[0],d=l[1],h=l[2],p=l[3],m=this.uint8ArrayToUint32Array_(s);let y=m[0],x=m[1],w=m[2],S=m[3];const _=new Int32Array(e),L=new Int32Array(_.length);let R,M,V,W,I,k,P,N,F,z,U,fe,oe,X;const Q=this.networkToHostOrderSwap;for(;t<_.length;){for(F=Q(_[t]),z=Q(_[t+1]),U=Q(_[t+2]),fe=Q(_[t+3]),I=F^i[0],k=fe^i[1],P=U^i[2],N=z^i[3],oe=4,X=1;X<r;X++)R=c[I>>>24]^d[k>>16&255]^h[P>>8&255]^p[N&255]^i[oe],M=c[k>>>24]^d[P>>16&255]^h[N>>8&255]^p[I&255]^i[oe+1],V=c[P>>>24]^d[N>>16&255]^h[I>>8&255]^p[k&255]^i[oe+2],W=c[N>>>24]^d[I>>16&255]^h[k>>8&255]^p[P&255]^i[oe+3],I=R,k=M,P=V,N=W,oe=oe+4;R=a[I>>>24]<<24^a[k>>16&255]<<16^a[P>>8&255]<<8^a[N&255]^i[oe],M=a[k>>>24]<<24^a[P>>16&255]<<16^a[N>>8&255]<<8^a[I&255]^i[oe+1],V=a[P>>>24]<<24^a[N>>16&255]<<16^a[I>>8&255]<<8^a[k&255]^i[oe+2],W=a[N>>>24]<<24^a[I>>16&255]<<16^a[k>>8&255]<<8^a[P&255]^i[oe+3],L[t]=Q(R^y),L[t+1]=Q(W^x),L[t+2]=Q(V^w),L[t+3]=Q(M^S),y=F,x=z,w=U,S=fe,t=t+4}return L.buffer}}class zte{constructor(e,t,s){this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=e,this.key=t,this.aesMode=s}expandKey(){const e=$te(this.aesMode);return this.subtle.importKey("raw",this.key,{name:e},!1,["encrypt","decrypt"])}}function $te(n){switch(n){case hu.cbc:return"AES-CBC";case hu.ctr:return"AES-CTR";default:throw new Error(`[FastAESKey] invalid aes mode ${n}`)}}const Hte=16;class iS{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 s=self.crypto;s&&(this.subtle=s.subtle||s.webkitSubtle)}catch{}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 s=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?Vte(s):s}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,s,r){return this.useSoftware?new Promise((i,a)=>{const l=ArrayBuffer.isView(e)?e:new Uint8Array(e);this.softwareDecrypt(l,t,s,r);const c=this.flush();c?i(c.buffer):a(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,s,r)}softwareDecrypt(e,t,s,r){const{currentIV:i,currentResult:a,remainderData:l}=this;if(r!==hu.cbc||t.byteLength!==16)return An.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),l&&(e=ka(l,e),this.remainderData=null);const c=this.getValidChunk(e);if(!c.length)return null;i&&(s=i);let d=this.softwareDecrypter;d||(d=this.softwareDecrypter=new Bte),d.expandKey(t);const h=a;return this.currentResult=d.decrypt(c.buffer,0,s),this.currentIV=c.slice(-16).buffer,h||null}webCryptoDecrypt(e,t,s,r){if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,s,r));this.key=t,this.fastAesKey=new zte(this.subtle,t,r)}return this.fastAesKey.expandKey().then(i=>this.subtle?(this.logOnce("WebCrypto AES decrypt"),new Ute(this.subtle,new Uint8Array(s),r).decrypt(e.buffer,i)):Promise.reject(new Error("web crypto not initialized"))).catch(i=>(An.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${i.name}: ${i.message}`),this.onWebCryptoError(e,t,s,r)))}onWebCryptoError(e,t,s,r){const i=this.enableSoftwareAES;if(i){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,s,r);const a=this.flush();if(a)return a.buffer}throw new Error("WebCrypto"+(i?" and softwareDecrypt":"")+": failed to decrypt data")}getValidChunk(e){let t=e;const s=e.length-e.length%Hte;return s!==e.length&&(t=e.slice(0,s),this.remainderData=e.slice(s)),t}logOnce(e){this.logEnabled&&(An.log(`[decrypter]: ${e}`),this.logEnabled=!1)}}const O_=Math.pow(2,17);class Wte{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 s=e.url;if(!s)return Promise.reject(new Al({type:xt.NETWORK_ERROR,details:he.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error(`Fragment does not have a ${s?"part list":"url"}`),networkDetails:null}));this.abort();const r=this.config,i=r.fLoader,a=r.loader;return new Promise((l,c)=>{if(this.loader&&this.loader.destroy(),e.gap)if(e.tagList.some(x=>x[0]==="GAP")){c(F_(e));return}else e.gap=!1;const d=this.loader=i?new i(r):new a(r),h=M_(e);e.loader=d;const p=D_(r.fragLoadPolicy.default),m={loadPolicy:p,timeout:p.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:O_};e.stats=d.stats;const y={onSuccess:(x,w,S,_)=>{this.resetLoader(e,d);let L=x.data;S.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(L.slice(0,16)),L=L.slice(16)),l({frag:e,part:null,payload:L,networkDetails:_})},onError:(x,w,S,_)=>{this.resetLoader(e,d),c(new Al({type:xt.NETWORK_ERROR,details:he.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:In({url:s,data:void 0},x),error:new Error(`HTTP Error ${x.code} ${x.text}`),networkDetails:S,stats:_}))},onAbort:(x,w,S)=>{this.resetLoader(e,d),c(new Al({type:xt.NETWORK_ERROR,details:he.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:S,stats:x}))},onTimeout:(x,w,S)=>{this.resetLoader(e,d),c(new Al({type:xt.NETWORK_ERROR,details:he.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${m.timeout}ms`),networkDetails:S,stats:x}))}};t&&(y.onProgress=(x,w,S,_)=>t({frag:e,part:null,payload:S,networkDetails:_})),d.load(h,m,y)})}loadPart(e,t,s){this.abort();const r=this.config,i=r.fLoader,a=r.loader;return new Promise((l,c)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap){c(F_(e,t));return}const d=this.loader=i?new i(r):new a(r),h=M_(e,t);e.loader=d;const p=D_(r.fragLoadPolicy.default),m={loadPolicy:p,timeout:p.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:O_};t.stats=d.stats,d.load(h,m,{onSuccess:(y,x,w,S)=>{this.resetLoader(e,d),this.updateStatsFromPart(e,t);const _={frag:e,part:t,payload:y.data,networkDetails:S};s(_),l(_)},onError:(y,x,w,S)=>{this.resetLoader(e,d),c(new Al({type:xt.NETWORK_ERROR,details:he.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:In({url:h.url,data:void 0},y),error:new Error(`HTTP Error ${y.code} ${y.text}`),networkDetails:w,stats:S}))},onAbort:(y,x,w)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,d),c(new Al({type:xt.NETWORK_ERROR,details:he.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:w,stats:y}))},onTimeout:(y,x,w)=>{this.resetLoader(e,d),c(new Al({type:xt.NETWORK_ERROR,details:he.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${m.timeout}ms`),networkDetails:w,stats:y}))}})})}updateStatsFromPart(e,t){const s=e.stats,r=t.stats,i=r.total;if(s.loaded+=r.loaded,i){const c=Math.round(e.duration/t.duration),d=Math.min(Math.round(s.loaded/i),c),p=(c-d)*Math.round(s.loaded/d);s.total=s.loaded+p}else s.total=Math.max(s.loaded,s.total);const a=s.loading,l=r.loading;a.start?a.first+=l.first-l.start:(a.start=l.start,a.first=l.first),a.end=l.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}function M_(n,e=null){const t=e||n,s={frag:n,part:e,responseType:"arraybuffer",url:t.url,headers:{},rangeStart:0,rangeEnd:0},r=t.byteRangeStartOffset,i=t.byteRangeEndOffset;if(et(r)&&et(i)){var a;let l=r,c=i;if(n.sn==="initSegment"&&Gte((a=n.decryptdata)==null?void 0:a.method)){const d=i-r;d%16&&(c=i+(16-d%16)),r!==0&&(s.resetIV=!0,l=r-16)}s.rangeStart=l,s.rangeEnd=c}return s}function F_(n,e){const t=new Error(`GAP ${n.gap?"tag":"attribute"} found`),s={type:xt.MEDIA_ERROR,details:he.FRAG_GAP,fatal:!1,frag:n,error:t,networkDetails:null};return e&&(s.part=e),(e||n).stats.aborted=!0,new Al(s)}function Gte(n){return n==="AES-128"||n==="AES-256"}class Al extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class PN extends Pa{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?!1:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)}clearInterval(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1}clearNextTick(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1}tick(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}class iy{constructor(e,t,s,r=0,i=-1,a=!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=n0(),this.buffering={audio:n0(),video:n0(),audiovideo:n0()},this.level=e,this.sn=t,this.id=s,this.size=r,this.part=i,this.partial=a}}function n0(){return{start:0,executeStart:0,executeEnd:0,end:0}}const U_={length:0,start:()=>0,end:()=>0};class Bt{static isBuffered(e,t){if(e){const s=Bt.getBuffered(e);for(let r=s.length;r--;)if(t>=s.start(r)&&t<=s.end(r))return!0}return!1}static bufferedRanges(e){if(e){const t=Bt.getBuffered(e);return Bt.timeRangesToArray(t)}return[]}static timeRangesToArray(e){const t=[];for(let s=0;s<e.length;s++)t.push({start:e.start(s),end:e.end(s)});return t}static bufferInfo(e,t,s){if(e){const r=Bt.bufferedRanges(e);if(r.length)return Bt.bufferedInfo(r,t,s)}return{len:0,start:t,end:t,bufferedIndex:-1}}static bufferedInfo(e,t,s){t=Math.max(0,t),e.length>1&&e.sort((h,p)=>h.start-p.start||p.end-h.end);let r=-1,i=[];if(s)for(let h=0;h<e.length;h++){t>=e[h].start&&t<=e[h].end&&(r=h);const p=i.length;if(p){const m=i[p-1].end;e[h].start-m<s?e[h].end>m&&(i[p-1].end=e[h].end):i.push(e[h])}else i.push(e[h])}else i=e;let a=0,l,c=t,d=t;for(let h=0;h<i.length;h++){const p=i[h].start,m=i[h].end;if(r===-1&&t>=p&&t<=m&&(r=h),t+s>=p&&t<m)c=p,d=m,a=d-t;else if(t+s<p){l=p;break}}return{len:a,start:c||0,end:d||0,nextStart:l,buffered:e,bufferedIndex:r}}static getBuffered(e){try{return e.buffered||U_}catch(t){return An.log("failed to get media.buffered",t),U_}}}const NN=/\{\$([a-zA-Z0-9-_]+)\}/g;function V_(n){return NN.test(n)}function iw(n,e){if(n.variableList!==null||n.hasVariableRefs){const t=n.variableList;return e.replace(NN,s=>{const r=s.substring(2,s.length-1),i=t?.[r];return i===void 0?(n.playlistParsingError||(n.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${r}"`)),s):i})}return e}function B_(n,e,t){let s=n.variableList;s||(n.variableList=s={});let r,i;if("QUERYPARAM"in e){r=e.QUERYPARAM;try{const a=new self.URL(t).searchParams;if(a.has(r))i=a.get(r);else throw new Error(`"${r}" does not match any query parameter in URI: "${t}"`)}catch(a){n.playlistParsingError||(n.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${a.message}`))}}else r=e.NAME,i=e.VALUE;r in s?n.playlistParsingError||(n.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${r}"`)):s[r]=i||""}function Kte(n,e,t){const s=e.IMPORT;if(t&&s in t){let r=n.variableList;r||(n.variableList=r={}),r[s]=t[s]}else n.playlistParsingError||(n.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${s}"`))}const qte=/^(\d+)x(\d+)$/,z_=/(.+?)=(".*?"|.*?)(?:,|$)/g;class Qn{constructor(e,t){typeof e=="string"&&(e=Qn.parseAttrList(e,t)),kn(this,e)}get clientAttrs(){return Object.keys(this).filter(e=>e.substring(0,2)==="X-")}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=(t.length&1?"0":"")+t;const s=new Uint8Array(t.length/2);for(let r=0;r<t.length/2;r++)s[r]=parseInt(t.slice(r*2,r*2+2),16);return s}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 s=this[e];return s?parseFloat(s):t}enumeratedString(e){return this[e]}enumeratedStringList(e,t){const s=this[e];return(s?s.split(/[ ,]+/):[]).reduce((r,i)=>(r[i.toLowerCase()]=!0,r),t)}bool(e){return this[e]==="YES"}decimalResolution(e){const t=qte.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e,t){let s;const r={};for(z_.lastIndex=0;(s=z_.exec(e))!==null;){const a=s[1].trim();let l=s[2];const c=l.indexOf('"')===0&&l.lastIndexOf('"')===l.length-1;let d=!1;if(c)l=l.slice(1,-1);else switch(a){case"IV":case"SCTE35-CMD":case"SCTE35-IN":case"SCTE35-OUT":d=!0}if(t&&(c||d))l=iw(t,l);else if(!d&&!c)switch(a){case"CLOSED-CAPTIONS":if(l==="NONE")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":An.warn(`${e}: attribute ${a} is missing quotes`)}r[a]=l}return r}}const Yte="com.apple.hls.interstitial";function Qte(n){return n!=="ID"&&n!=="CLASS"&&n!=="CUE"&&n!=="START-DATE"&&n!=="DURATION"&&n!=="END-DATE"&&n!=="END-ON-NEXT"}function Xte(n){return n==="SCTE35-OUT"||n==="SCTE35-IN"||n==="SCTE35-CMD"}class aS{constructor(e,t,s=0){var r;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=t?.tagAnchor||null,this.tagOrder=(r=t?.tagOrder)!=null?r:s,t){const i=t.attr;for(const a in i)if(Object.prototype.hasOwnProperty.call(e,a)&&e[a]!==i[a]){An.warn(`DATERANGE tag attribute: "${a}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=a;break}e=kn(new Qn({}),i,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 i=t?.endDate||new Date(this.attr["END-DATE"]);et(i.getTime())&&(this._endDate=i)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get cue(){const e=this._cue;return e===void 0?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 e===null||e.programDateTime===null?(An.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 t!==null?this._dateAtEnd=new Date(this._startDate.getTime()+t*1e3):null}get duration(){if("DURATION"in this.attr){const e=this.attr.decimalFloatingPoint("DURATION");if(et(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 this.class===Yte}get isValid(){return!!this.id&&!this._badValueForSameId&&et(this.startDate.getTime())&&(this.duration===null||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)}}const Jte=10;class LN{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.drift
vendor: 4,544 bytes, line 106
106StartTime=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){this.advanced=!0,this.updated=!0;return}const t=this.lastPartSn-e.lastPartSn,s=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!s||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||t===0&&s>0,this.updated||this.advanced?this.misses=Math.floor(e.misses*.6):this.misses=e.misses+1}hasKey(e){return this.encryptedFragments.some(t=>{let s=t.decryptdata;return s||(t.setKeyFormat(e.keyFormat),s=t.decryptdata),!!s&&e.matches(s)})}get hasProgramDateTime(){return this.fragments.length?et(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||Jte}get drift(){const e=this.driftEndTime-this.driftStartTime;return e>0?(this.driftEnd-this.driftStart)*1e3/e:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var e;return(e=this.partList)!=null&&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(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].index:-1}get maxPartIndex(){const e=this.partList;if(e){const t=this.lastPartIndex;if(t!==-1){for(let s=e.length;s--;)if(e[s].index>t)return e[s].index;return t}}return 0}get lastPartSn(){var e;return(e=this.partList)!=null&&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 U1(n,e){return n.length===e.length?!n.some((t,s)=>t!==e[s]):!1}function $_(n,e){return!n&&!e?!0:!n||!e?!1:U1(n,e)}function Hh(n){return n==="AES-128"||n==="AES-256"||n==="AES-256-CTR"}function oS(n){switch(n){case"AES-128":case"AES-256":return hu.cbc;case"AES-256-CTR":return hu.ctr;default:throw new Error(`invalid full segment method ${n}`)}}function lS(n){return Uint8Array.from(atob(n),e=>e.charCodeAt(0))}function aw(n){return Uint8Array.from(unescape(encodeURIComponent(n)),e=>e.charCodeAt(0))}function Zte(n){const e=aw(n).subarray(0,16),t=new Uint8Array(16);return t.set(e,16-e.length),t}function DN(n){const e=function(s,r,i){const a=s[r];s[r]=s[i],s[i]=a};e(n,0,3),e(n,1,2),e(n,4,5),e(n,6,7)}function jN(n){const e=n.split(":");let t=null;if(e[0]==="data"&&e.length===2){const s=e[1].split(";"),r=s[s.length-1].split(",");if(r.length===2){const i=r[0]==="base64",a=r[1];i?(s.splice(-1,1),t=lS(a)):t=Zte(a)}}return t}const V1=typeof self<"u"?self:void 0;var Xn={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},cr={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function j0(n){switch(n){case cr.FAIRPLAY:return Xn.FAIRPLAY;case cr.PLAYREADY:return Xn.PLAYREADY;case cr.WIDEVINE:return Xn.WIDEVINE;case cr.CLEARKEY:return Xn.CLEARKEY}}function Ev(n){switch(n){case Xn.FAIRPLAY:return cr.FAIRPLAY;case Xn.PLAYREADY:return cr.PLAYREADY;case Xn.WIDEVINE:return cr.WIDEVINE;case Xn.CLEARKEY:return cr.CLEARKEY}}function wp(n){const{drmSystems:e,widevineLicenseUrl:t}=n,s=e?[Xn.FAIRPLAY,Xn.WIDEVINE,Xn.PLAYREADY,Xn.CLEARKEY].filter(r=>!!e[r]):[];return!s[Xn.WIDEVINE]&&t&&s.push(Xn.WIDEVINE),s}const cS=(function(n){return V1!=null&&(n=V1.navigator)!=null&&n.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null})();function ene(n,e,t,s){let r;switch(n){case Xn.FAIRPLAY:r=["cenc","sinf"];break;case Xn.WIDEVINE:case Xn.PLAYREADY:r=["cenc"];break;case Xn.CLEARKEY:r=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${n}`)}return tne(r,e,t,s)}function tne(n,e,t,s){return[{initDataTypes:n,persistentState:s.persistentState||"optional",distinctiveIdentifier:s.distinctiveIdentifier||"optional",sessionTypes:s.sessionTypes||[s.sessionType||"temporary"],audioCapabilities:e.map(i=>({contentType:`audio/mp4; codecs=${i}
106`,robustness:s.audioRobustness||"",encryptionScheme:s.audioEncryptionScheme||null})),videoCapabilities:t.map(i=>({contentType:`video/mp4; codecs=${i}`,robustness:s.videoRobustness||"",encryptionScheme:s.videoEncryptionScheme||null}))}]}function nne(n){var e;return!!n&&(n.sessionType==="persistent-license"||!!((e=n.sessionTypes)!=null&&e.some(t=>t==="persistent-license")))}function ON(n){const e=new Uint16Array(n.buffer,n.byteOffset,n.byteLength/2),t=String.fromCharCode.apply(null,Array.from(e)),s=t.substring(t.indexOf("<"),t.length),a=new DOMParser().parseFromString(s,"text/xml").getElementsByTagName("KID")[0];if(a){const l=a.childNodes[0]?a.childNodes[0].nodeValue:a.getAttribute("VALUE");if(l){const c=lS(l).subarray(0,16);return DN(c),c}}return null}let hh={};class zl{static clearKeyUriToKeyIdMap(){hh={}}static setKeyIdForUri(e,t){hh[e]=t}static addKeyIdForUri(e){const t=Object.keys(hh).length%Number.MAX_SAFE_INTEGER,s=new Uint8Array(16);return new DataView(s.buffer,12,4).setUint32(0,t),hh[e]=s,s}constructor(e,t,s,r=[1],i=null,a){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=s,this.keyFormatVersions=r,this.iv=i,this.encrypted=e?e!=="NONE":!1,this.isCommonEncryption=this.encrypted&&!Hh(e),a!=null&&a.startsWith("0x")&&(this.keyId=new Uint8Array(cN(a)))}matches(e){return e.uri===this.uri&&e.method===this.method&&e.encrypted===this.encrypted&&e.keyFormat===this.keyFormat&&U1(e.keyFormatVersions,this.keyFormatVersions)&&$_(e.iv,this.iv)&&$_(e.keyId,this.keyId)}isSupported(){if(this.method){if(Hh(this.method)||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES";switch(this.keyFormat){case cr.FAIRPLAY:case cr.WIDEVINE:case cr.PLAYREADY:case cr.CLEARKEY:return["SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1}getDecryptData(e,t){if(!this.encrypted||!this.uri)return null;if(Hh(this.method)){let i=this.iv;return i||(typeof e!="number"&&(An.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0),i=rne(e)),new zl(this.method,this.uri,"identity",this.keyFormatVersions,i)}if(this.keyId){const i=hh[this.uri];if(i&&!U1(this.keyId,i)&&zl.setKeyIdForUri(this.uri,this.keyId),this.pssh)return this}const s=jN(this.uri);if(s)switch(this.keyFormat){case cr.WIDEVINE:if(this.pssh=s,!this.keyId){const i=ute(s.buffer);if(i.length){var r;const a=i[0];this.keyId=(r=a.kids)!=null&&r.length?a.kids[0]:null}}this.keyId||(this.keyId=H_(t));break;case cr.PLAYREADY:{const i=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=cte(i,null,s),this.keyId=ON(s);break}default:{let i=s.subarray(0,16);if(i.length!==16){const a=new Uint8Array(16);a.set(i,16-i.length),i=a}this.keyId=i;break}}if(!this.keyId||this.keyId.byteLength!==16){let i;i=sne(t),i||(i=H_(t),i||(i=hh[this.uri])),i&&(this.keyId=i,zl.setKeyIdForUri(this.uri,i))}return this}}function sne(n){const e=n?.[cr.WIDEVINE];return e?e.keyId:null}function H_(n){const e=n?.[cr.PLAYREADY];if(e){const t=jN(e.uri);if(t)return ON(t)}return null}function rne(n){const e=new Uint8Array(16);for(let t=12;t<16;t++)e[t]=n>>8*(15-t)&255;return e}const W_=/#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,G_=/#EXT-X-MEDIA:(.*)/g,ine=/^#EXT(?:INF|-X-TARGETDURATION):/m,Tv=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),ane=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 io{static findGroup(e,t){for(let s=0;s<e.length;s++){const r=e[s];if(r.id===t)return r}}static resolve(e,t){return Z6.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return ine.test(e)}static parseMasterPlaylist(e,t){const s=V_(e),r={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:s},i=[];if(W_.lastIndex=0,!e.startsWith("#EXTM3U"))return r.playlistParsingError=new Error("no EXTM3U delimiter"),r;let a;for(;(a=W_.exec(e))!=null;)if(a[1]){var l;const d=new Qn(a[1],r),h=iw(r,a[2]),p={attrs:d,bitrate:d.decimalInteger("BANDWIDTH")||d.decimalInteger("AVERAGE-BANDWIDTH"),name:d.NAME,url:io.resolve(h,t)},m=d.decimalResolution("RESOLUTION");m&&(p.width=m.width,p.height=m.height),Y_(d.CODECS,p);const y=d["SUPPLEMENTAL-CODECS"];y&&(p.supplemental={},Y_(y,p.supplemental)),(l=p.unknownCodecs)!=null&&l.length||i.push(p),r.levels.push(p)}else if(a[3]){const d=a[3],h=a[4];switch(d){case"SESSION-DATA":{const p=new Qn(h,r),m=p["DATA-ID"];m&&(r.sessionData===null&&(r.sessionData={}),r.sessionData[m]=p);break}case"SESSION-KEY":{const p=K_(h,t,r);p.encrypted&&p.isSupported()?(r.sessionKeys===null&&(r.sessionKeys=[]),r.sessionKeys.push(p)):An.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${h}"`);break}case"DEFINE":{{const p=new Qn(h,r);B_(r,p,t)}break}case"CONTENT-STEERING":{const p=new Qn(h,r);r.contentSteering={uri:io.resolve(p["SERVER-URI"],t),pathwayId:p["PATHWAY-ID"]||"."};break}
vendor: 4,081 bytes, line 106
106case"START":{r.startTimeOffset=q_(h);break}}}const c=i.length>0&&i.length<r.levels.length;return r.levels=c?i:r.levels,r.levels.length===0&&(r.playlistParsingError=new Error("no levels found in manifest")),r}static parseMasterPlaylistMedia(e,t,s){let r;const i={},a=s.levels,l={AUDIO:a.map(d=>({id:d.attrs.AUDIO,audioCodec:d.audioCodec})),SUBTITLES:a.map(d=>({id:d.attrs.SUBTITLES,textCodec:d.textCodec})),"CLOSED-CAPTIONS":[]};let c=0;for(G_.lastIndex=0;(r=G_.exec(e))!==null;){const d=new Qn(r[1],s),h=d.TYPE;if(h){const p=l[h],m=i[h]||[];i[h]=m;const y=d.LANGUAGE,x=d["ASSOC-LANGUAGE"],w=d.CHANNELS,S=d.CHARACTERISTICS,_=d["INSTREAM-ID"],L={attrs:d,bitrate:0,id:c++,groupId:d["GROUP-ID"]||"",name:d.NAME||y||"",type:h,default:d.bool("DEFAULT"),autoselect:d.bool("AUTOSELECT"),forced:d.bool("FORCED"),lang:y,url:d.URI?io.resolve(d.URI,t):""};if(x&&(L.assocLang=x),w&&(L.channels=w),S&&(L.characteristics=S),_&&(L.instreamId=_),p!=null&&p.length){const R=io.findGroup(p,L.groupId)||p[0];Q_(L,R,"audioCodec"),Q_(L,R,"textCodec")}m.push(L)}}return i}static parseLevelPlaylist(e,t,s,r,i,a){var l;const c={url:t},d=new LN(t),h=d.fragments,p=[];let m=null,y=0,x=0,w=0,S=0,_=0,L=null,R=new L0(r,c),M,V,W,I=-1,k=!1,P=null,N;if(Tv.lastIndex=0,d.m3u8=e,d.hasVariableRefs=V_(e),((l=Tv.exec(e))==null?void 0:l[0])!=="#EXTM3U")return d.playlistParsingError=new Error("Missing format identifier #EXTM3U"),d;for(;(M=Tv.exec(e))!==null;){k&&(k=!1,R=new L0(r,c),R.playlistOffset=w,R.setStart(w),R.sn=y,R.cc=S,_&&(R.bitrate=_),R.level=s,m&&(R.initSegment=m,m.rawProgramDateTime&&(R.rawProgramDateTime=m.rawProgramDateTime,m.rawProgramDateTime=null),P&&(R.setByteRange(P),P=null)));const fe=M[1];if(fe){R.duration=parseFloat(fe);const oe=(" "+M[2]).slice(1);R.title=oe||null,R.tagList.push(oe?["INF",fe,oe]:["INF",fe])}else if(M[3]){if(et(R.duration)){R.playlistOffset=w,R.setStart(w),W&&J_(R,W,d),R.sn=y,R.level=s,R.cc=S,h.push(R);const oe=(" "+M[3]).slice(1);R.relurl=iw(d,oe),ow(R,L,p),L=R,w+=R.duration,y++,x=0,k=!0}}else{if(M=M[0].match(ane),!M){An.warn("No matches on slow regex match for level playlist!");continue}for(V=1;V<M.length&&M[V]===void 0;V++);const oe=(" "+M[V]).slice(1),X=(" "+M[V+1]).slice(1),Q=M[V+2]?(" "+M[V+2]).slice(1):null;switch(oe){case"BYTERANGE":L?R.setByteRange(X,L):R.setByteRange(X);break;case"PROGRAM-DATE-TIME":R.rawProgramDateTime=X,R.tagList.push(["PROGRAM-DATE-TIME",X]),I===-1&&(I=h.length);break;case"PLAYLIST-TYPE":d.type&&Tl(d,oe,M),d.type=X.toUpperCase();break;case"MEDIA-SEQUENCE":d.startSN!==0?Tl(d,oe,M):h.length>0&&Z_(d,oe,M),y=d.startSN=parseInt(X);break;case"SKIP":{d.skippedSegments&&Tl(d,oe,M);const G=new Qn(X,d),Y=G.decimalInteger("SKIPPED-SEGMENTS");if(et(Y)){d.skippedSegments+=Y;for(let H=Y;H--;)h.push(null);y+=Y}const ee=G.enumeratedString("RECENTLY-REMOVED-DATERANGES");ee&&(d.recentlyRemovedDateranges=(d.recentlyRemovedDateranges||[]).concat(ee.split(" ")));break}case"TARGETDURATION":d.targetduration!==0&&Tl(d,oe,M),d.targetduration=Math.max(parseInt(X),1);break;case"VERSION":d.version!==null&&Tl(d,oe,M),d.version=parseInt(X);break;case"INDEPENDENT-SEGMENTS":break;case"ENDLIST":d.live||Tl(d,oe,M),d.live=!1;break;case"#":(X||Q)&&R.tagList.push(Q?[X,Q]:[X]);break;case"DISCONTINUITY":S++,R.tagList.push(["DIS"]);break;case"GAP":R.gap=!0,R.tagList.push([oe]);break;case"BITRATE":R.tagList.push([oe,X]),_=parseInt(X)*1e3,et(_)?R.bitrate=_:_=0;break;case"DATERANGE":{const G=new Qn(X,d),Y=new aS(G,d.dateRanges[G.ID],d.dateRangeTagCount);d.dateRangeTagCount++,Y.isValid||d.skippedSegments?d.dateRanges[Y.id]=Y:An.warn(`Ignoring invalid DATERANGE tag: "${X}"`),R.tagList.push(["EXT-X-DATERANGE",X]);break}case"DEFINE":{{const G=new Qn(X,d);"IMPORT"in G?Kte(d,G,a):B_(d,G,t)}break}case"DISCONTINUITY-SEQUENCE":d.startCC!==0?Tl(d,oe,M):h.length>0&&Z_(d,oe,M),d.startCC=S=parseInt(X);break;case"KEY":{const G=K_(X,t,d);if(G.isSupported()){if(G.method==="NONE"){W=void 0;break}W||(W={});const Y=W[G.keyFormat];Y!=null&&Y.matches(G)||(Y&&(W=kn({},W)),W[G.keyFormat]=G)}else An.warn(`[Keys] Ignoring unsupported EXT-X-KEY tag: "${X}"`);break}
vendor: 5,916 bytes, line 106
106case"START":d.startTimeOffset=q_(X);break;case"MAP":{const G=new Qn(X,d);if(R.duration){const Y=new L0(r,c);X_(Y,G,s,W),m=Y,R.initSegment=m,m.rawProgramDateTime&&!R.rawProgramDateTime&&(R.rawProgramDateTime=m.rawProgramDateTime)}else{const Y=R.byteRangeEndOffset;if(Y){const ee=R.byteRangeStartOffset;P=`${Y-ee}@${ee}`}else P=null;X_(R,G,s,W),m=R,k=!0}m.cc=S;break}case"SERVER-CONTROL":{N&&Tl(d,oe,M),N=new Qn(X),d.canBlockReload=N.bool("CAN-BLOCK-RELOAD"),d.canSkipUntil=N.optionalFloat("CAN-SKIP-UNTIL",0),d.canSkipDateRanges=d.canSkipUntil>0&&N.bool("CAN-SKIP-DATERANGES"),d.partHoldBack=N.optionalFloat("PART-HOLD-BACK",0),d.holdBack=N.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{d.partTarget&&Tl(d,oe,M);const G=new Qn(X);d.partTarget=G.decimalFloatingPoint("PART-TARGET");break}case"PART":{let G=d.partList;G||(G=d.partList=[]);const Y=x>0?G[G.length-1]:void 0,ee=x++,H=new Qn(X,d),K=new uN(H,R,c,ee,Y);G.push(K),R.duration+=K.duration;break}case"PRELOAD-HINT":{const G=new Qn(X,d);d.preloadHint=G;break}case"RENDITION-REPORT":{const G=new Qn(X,d);d.renditionReports=d.renditionReports||[],d.renditionReports.push(G);break}default:An.warn(`line parsed but not handled: ${M}`);break}}}L&&!L.relurl?(h.pop(),w-=L.duration,d.partList&&(d.fragmentHint=L)):d.partList&&(ow(R,L,p),R.cc=S,d.fragmentHint=R,W&&J_(R,W,d)),d.targetduration||(d.playlistParsingError=new Error("Missing Target Duration"));const F=h.length,z=h[0],U=h[F-1];if(w+=d.skippedSegments*d.targetduration,w>0&&F&&U){d.averagetargetduration=w/F;const fe=U.sn;d.endSN=fe!=="initSegment"?fe:0,d.live||(U.endList=!0),I>0&&(lne(h,I),z&&p.unshift(z))}return d.fragmentHint&&(w+=d.fragmentHint.duration),d.totalduration=w,p.length&&d.dateRangeTagCount&&z&&MN(p,d),d.endCC=S,d}}function MN(n,e){let t=n.length;if(!t)if(e.hasProgramDateTime){const l=e.fragments[e.fragments.length-1];n.push(l),t++}else return;const s=n[t-1],r=e.live?1/0:e.totalduration,i=Object.keys(e.dateRanges);for(let l=i.length;l--;){const c=e.dateRanges[i[l]],d=c.startDate.getTime();c.tagAnchor=s.ref;for(let h=t;h--;){var a;if(((a=n[h])==null?void 0:a.sn)<e.startSN)break;const p=one(e,d,n,h,r);if(p!==-1){c.tagAnchor=e.fragments[p].ref;break}}}}function one(n,e,t,s,r){const i=t[s];if(i){const l=i.programDateTime;if(e>=l||s===0){var a;const c=(((a=t[s+1])==null?void 0:a.start)||r)-i.start;if(e<=l+c*1e3){const d=t[s].sn-n.startSN;if(d<0)return-1;const h=n.fragments;if(h.length>t.length){const m=(t[s+1]||h[h.length-1]).sn-n.startSN;for(let y=m;y>d;y--){const x=h[y].programDateTime;if(e>=x&&e<x+h[y].duration*1e3)return y}}return d}}}return-1}function K_(n,e,t){var s,r;const i=new Qn(n,t),a=(s=i.METHOD)!=null?s:"",l=i.URI,c=i.hexadecimalInteger("IV"),d=i.KEYFORMATVERSIONS,h=(r=i.KEYFORMAT)!=null?r:"identity";l&&i.IV&&!c&&An.error(`Invalid IV: ${i.IV}`);const p=l?io.resolve(l,e):"",m=(d||"1").split("/").map(Number).filter(Number.isFinite);return new zl(a,p,h,m,c,i.KEYID)}function q_(n){const t=new Qn(n).decimalFloatingPoint("TIME-OFFSET");return et(t)?t:null}function Y_(n,e){let t=(n||"").split(/[ ,]+/).filter(s=>s);["video","audio","text"].forEach(s=>{const r=t.filter(i=>nS(i,s));r.length&&(e[`${s}Codec`]=r.map(i=>i.split("/")[0]).join(","),t=t.filter(i=>r.indexOf(i)===-1))}),e.unknownCodecs=t}function Q_(n,e,t){const s=e[t];s&&(n[t]=s)}function lne(n,e){let t=n[e];for(let s=e;s--;){const r=n[s];if(!r)return;r.programDateTime=t.programDateTime-r.duration*1e3,t=r}}function ow(n,e,t){n.rawProgramDateTime?t.push(n):e!=null&&e.programDateTime&&(n.programDateTime=e.endProgramDateTime)}function X_(n,e,t,s){n.relurl=e.URI,e.BYTERANGE&&n.setByteRange(e.BYTERANGE),n.level=t,n.sn="initSegment",s&&(n.levelkeys=s),n.initSegment=null}function J_(n,e,t){n.levelkeys=e;const{encryptedFragments:s}=t;(!s.length||s[s.length-1].levelkeys!==e)&&Object.keys(e).some(r=>e[r].isCommonEncryption)&&s.push(n)}function Tl(n,e,t){n.playlistParsingError=new Error(`#EXT-X-${e} must not appear more than once (${t[0]})`)}function Z_(n,e,t){n.playlistParsingError=new Error(`#EXT-X-${e} must appear before the first Media Segment (${t[0]})`)}function _v(n,e){const t=e.startPTS;if(et(t)){let s=0,r;e.sn>n.sn?(s=t-n.start,r=n):(s=n.start-t,r=e),r.duration!==s&&r.setDuration(s)}else e.sn>n.sn?n.cc===e.cc&&n.minEndPTS?e.setStart(n.start+(n.minEndPTS-n.start)):e.setStart(n.start+n.duration):e.setStart(Math.max(n.start-e.duration,0))}function FN(n,e,t,s,r,i,a){s-t<=0&&(a.warn("Fragment should have a positive duration",e),s=t+e.duration,i=r+e.duration);let c=t,d=s;const h=e.startPTS,p=e.endPTS;if(et(h)){const _=Math.abs(h-t);n&&_>n.totalduration?a.warn(`media timestamps and playlist times differ by ${_}s for level ${e.level} ${n.url}`):et(e.deltaPTS)?e.deltaPTS=Math.max(_,e.deltaPTS):e.deltaPTS=_,c=Math.max(t,h),t=Math.min(t,h),r=e.startDTS!==void 0?Math.min(r,e.startDTS):r,d=Math.min(s,p),s=Math.max(s,p),i=e.endDTS!==void 0?Math.max(i,e.endDTS):i}const m=t-e.start;e.start!==0&&e.setStart(t),e.setDuration(s-e.start),e.startPTS=t,e.maxStartPTS=c,e.startDTS=r,e.endPTS=s,e.minEndPTS=d,e.endDTS=i;const y=e.sn;if(!n||y<n.startSN||y>n.endSN)return 0;let x;const w=y-n.startSN,S=n.fragments;for(S[w]=e,x=w;x>0;x--)_v(S[x],S[x-1]);for(x=w;x<S.length-1;x++)_v(S[x],S[x+1]);return n.fragmentHint&&_v(S[S.length-1],n.fragmentHint),n.PTSKnown=n.alignedSliding=!0,m}function cne(n,e,t){if(n===e)return;let s=null;const r=n.fragments;for(let h=r.length-1;h>=0;h--){const p=r[h].initSegment;if(p){s=p;break}}n.fragmentHint&&delete n.fragmentHint.endPTS;let i;hne(n,e,(h,p,m,y)=>{if((!e.startCC||e.skippedSegments)&&p.cc!==h.cc){const x=h.cc-p.cc;for(let w=m;w<y.length;w++)y[w].cc+=x;e.endCC=y[y.length-1].cc}et(h.startPTS)&&et(h.endPTS)&&(p.setStart(p.startPTS=h.startPTS),p.startDTS=h.startDTS,p.maxStartPTS=h.maxStartPTS,p.endPTS=h.endPTS,p.endDTS=h.endDTS,p.minEndPTS=h.minEndPTS,p.setDuration(h.endPTS-h.startPTS),p.duration&&(i=p),e.PTSKnown=e.alignedSliding=!0),h.hasStream
106s&&(p.elementaryStreams=h.elementaryStreams),p.loader=h.loader,h.hasStats&&(p.stats=h.stats),h.initSegment&&(p.initSegment=h.initSegment,s=h.initSegment)});const a=e.fragments,l=e.fragmentHint?a.concat(e.fragmentHint):a;if(s&&l.forEach(h=>{var p;h&&(!h.initSegment||h.initSegment.relurl===((p=s)==null?void 0:p.relurl))&&(h.initSegment=s)}),e.skippedSegments){if(e.deltaUpdateFailed=a.some(h=>!h),e.deltaUpdateFailed){t.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let h=e.skippedSegments;h--;)a.shift();e.startSN=a[0].sn}else{e.canSkipDateRanges&&(e.dateRanges=une(n.dateRanges,e,t));const h=n.fragments.filter(p=>p.rawProgramDateTime);if(n.hasProgramDateTime&&!e.hasProgramDateTime)for(let p=1;p<l.length;p++)l[p].programDateTime===null&&ow(l[p],l[p-1],h);MN(h,e)}e.endCC=a[a.length-1].cc}if(!e.startCC){var c;const h=BN(n,e.startSN-1);e.startCC=(c=h?.cc)!=null?c:a[0].cc}dne(n.partList,e.partList,(h,p)=>{p.elementaryStreams=h.elementaryStreams,p.stats=h.stats}),i?FN(e,i,i.startPTS,i.endPTS,i.startDTS,i.endDTS,t):UN(n,e),a.length&&(e.totalduration=e.edge-a[0].start),e.driftStartTime=n.driftStartTime,e.driftStart=n.driftStart;const d=e.advancedDateTime;if(e.advanced&&d){const h=e.edge;e.driftStart||(e.driftStartTime=d,e.driftStart=h),e.driftEndTime=d,e.driftEnd=h}else e.driftEndTime=n.driftEndTime,e.driftEnd=n.driftEnd,e.advancedDateTime=n.advancedDateTime;e.requestScheduled===-1&&(e.requestScheduled=n.requestScheduled)}function une(n,e,t){const{dateRanges:s,recentlyRemovedDateranges:r}=e,i=kn({},n);r&&r.forEach(c=>{delete i[c]});const l=Object.keys(i).length;return l?(Object.keys(s).forEach(c=>{const d=i[c],h=new aS(s[c].attr,d);h.isValid?(i[c]=h,d||(h.tagOrder+=l)):t.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${jn(s[c].attr)}"`)}),i):s}function dne(n,e,t){if(n&&e){let s=0;for(let r=0,i=n.length;r<=i;r++){const a=n[r],l=e[r+s];a&&l&&a.index===l.index&&a.fragment.sn===l.fragment.sn?t(a,l):s--}}}function hne(n,e,t){const s=e.skippedSegments,r=Math.max(n.startSN,e.startSN)-e.startSN,i=(n.fragmentHint?1:0)+(s?e.endSN:Math.min(n.endSN,e.endSN))-e.startSN,a=e.startSN-n.startSN,l=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,c=n.fragmentHint?n.fragments.concat(n.fragmentHint):n.fragments;for(let d=r;d<=i;d++){const h=c[a+d];let p=l[d];if(s&&!p&&h&&(p=e.fragments[d]=h),h&&p){t(h,p,d,l);const m=h.relurl,y=p.relurl;if(m&&fne(m,y)){e.playlistParsingError=eI(`media sequence mismatch ${p.sn}:`,n,e,h,p);return}else if(h.cc!==p.cc){e.playlistParsingError=eI(`discontinuity sequence mismatch (${h.cc}!=${p.cc})`,n,e,h,p);return}}}}function eI(n,e,t,s,r){return new Error(`${n} ${r.url} 107Playlist starting @${e.startSN} 108${e.m3u8} 109 110Playlist starting @${t.startSN} 111${t.m3u8}`)}function UN(n,e,t=!0){const s=e.startSN+e.skippedSegments-n.startSN,r=n.fragments,i=s>=0;let a=0;if(i&&s<r.length)a=r[s].start;else if(i&&e.startSN===n.endSN+1)a=n.fragmentEnd;else if(i&&t)a=n.fragmentStart+s*e.levelTargetDuration;else if(!e.skippedSegments&&e.fragmentStart===0)a=n.fragmentStart;else return;lw(e,a)}function lw(n,e){if(e){const t=n.fragments;for(let s=n.skippedSegments;s<t.length;s++)t[s].addStart(e);n.fragmentHint&&n.fragmentHint.addStart(e)}}function VN(n,e=1/0){let t=1e3*n.targetduration;if(n.updated){const s=n.fragments;if(s.length&&t*4>e){const i=s[s.length-1].duration*1e3;i<t&&(t=i)}}else t/=2;return Math.round(t)}function BN(n,e,t){if(!n)return null;let s=n.fragments[e-n.startSN];return s||(s=n.fragmentHint,s&&s.sn===e)?s:e<n.startSN&&t&&t.sn===e?t:null}function tI(n,e,t){return n?zN(n.partList,e,t):null}function zN(n,e,t){if(n)for(let s=n.length;s--;){const r=n[s];if(r.index===t&&r.fragment.sn===e)return r}return null}function $N(n){n.forEach((e,t)=>{var s;(s=e.details)==null||s.fragments.forEach(r=>{r.level=t,r.initSegment&&(r.initSegment.level=t)})})}function fne(n,e){return n!==e&&e?nI(n)!==nI(e):!1}function nI(n){return n.replace(/\?[^?]*$/,"")}function Fp(n,e){for(let s=0,r=n.length;s<r;s++){var t;if(((t=n[s])==null?void 0:t.cc)===e)return n[s]}return null}function pne(n,e){return!!(n&&e.startCC<n.endCC&&e.endCC>n.startCC)}function sI(n,e){const t=n.start+e;n.startPTS=t,n.setStart(t),n.endPTS=t+n.duration}function HN(n,e){const t=e.fragments;for(let s=0,r=t.length;s<r;s++)sI(t[s],n);e.fragmentHint&&sI(e.fragmentHint,n),e.alignedSliding=!0}function mne(n,e){n&&(WN(e,n),e.alignedSliding||B1(e,n),!e.alignedSliding&&!e.skippedSegments&&UN(n,e,!1))}function WN(n,e){if(!pne(e,n))return;const t=Math.min(e.endCC,n.endCC),s=Fp(e.fragments,t),r=Fp(n.fragments,t);
vendor: 8,828 bytes, line 111
111if(!s||!r)return;An.log(`Aligning playlist at start of dicontinuity sequence ${t}`);const i=s.start-r.start;HN(i,n)}function B1(n,e){if(!n.hasProgramDateTime||!e.hasProgramDateTime)return;const t=n.fragments,s=e.fragments;if(!t.length||!s.length)return;let r,i;const a=Math.min(e.endCC,n.endCC);e.startCC<a&&n.startCC<a&&(r=Fp(s,a),i=Fp(t,a)),(!r||!i)&&(r=s[Math.floor(s.length/2)],i=Fp(t,r.cc)||t[Math.floor(t.length/2)]);const l=r.programDateTime,c=i.programDateTime;if(!l||!c)return;const d=(c-l)/1e3-(i.start-r.start);HN(d,n)}function ei(n,e,t){Ti(n,e,t),n.addEventListener(e,t)}function Ti(n,e,t){n.removeEventListener(e,t)}const gne={toString:function(n){let e="";const t=n.length;for(let s=0;s<t;s++)e+=`[${n.start(s).toFixed(3)}-${n.end(s).toFixed(3)}]`;return e}},Ae={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"};class ay extends PN{constructor(e,t,s,r,i){super(r,e.logger),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=Ae.STOPPED,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:a,fragCurrent:l,media:c,mediaBuffer:d,state:h}=this,p=c?c.currentTime:0,m=Bt.bufferInfo(d||c,p,a.maxBufferHole),y=!m.len;if(this.log(`Media seeking to ${et(p)?p.toFixed(3):p}, state: ${h}, ${y?"out of":"in"} buffer`),this.state===Ae.ENDED)this.resetLoadingState();else if(l){const x=a.maxFragLookUpTolerance,w=l.start-x,S=l.start+l.duration+x;if(y||S<m.start||w>m.end){const _=p>S;(p<w||_)&&(_&&l.loader&&(this.log(`Cancelling fragment load for seek (sn: ${l.sn})`),l.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}if(c){this.fragmentTracker.removeFragmentsInRange(p,1/0,this.playlistType,!0);const x=this.lastCurrentTime;if(p>x&&(this.lastCurrentTime=p),!this.loadingParts){const w=Math.max(m.end,p),S=this.shouldLoadParts(this.getLevelDetails(),w);S&&(this.log(`LL-Part loading ON after seeking to ${p.toFixed(2)} with buffer @${w.toFixed(2)}`),this.loadingParts=S)}}this.hls.hasEnoughToStart||(this.log(`Setting ${y?"startPosition":"nextLoadPosition"} to ${p} for seek without enough to start`),this.nextLoadPosition=p,y&&(this.startPosition=p)),y&&this.state===Ae.IDLE&&this.tickImmediate()},this.onMediaEnded=()=>{this.log("setting startPosition to 0 because media ended"),this.startPosition=this.lastCurrentTime=0},this.playlistType=i,this.hls=e,this.fragmentLoader=new Wte(e.config),this.keyLoader=s,this.fragmentTracker=t,this.config=e.config,this.decrypter=new iS(e.config)}registerListeners(){const{hls:e}=this;e.on(j.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(j.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(j.MANIFEST_LOADING,this.onManifestLoading,this),e.on(j.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(j.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(j.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(j.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(j.MANIFEST_LOADING,this.onManifestLoading,this),e.off(j.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(j.ERROR,this.onError,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){if(this.state===Ae.STOPPED)return;this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);const e=this.fragCurrent;e!=null&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=Ae.STOPPED}get startPositionValue(){const{nextLoadPosition:e,startPosition:t}=this;return t===-1&&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 s=e.end||0,r=this.config.timelineOffset||0;if(s<=r)return!1;const i=e.buffered;this.config.maxBufferHole&&i&&i.length>1&&(e=Bt.bufferedInfo(i,e.start,0));const a=e.nextStart;if(a&&a>r&&a<t.edge||this.media.currentTime<e.start)return!1;const c=t.partList;if(c!=null&&c.length){const h=c[c.length-1];return Bt.isBuffered(this.media,h.start+h.duration/2)}const d=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(d)}getLevelDetails(){if(this.levels&&this.levelLastLoaded!==null)return this.levelLastLoaded.details}get timelineOffset(){const e=this.config.timelineOffset;if(e){var t;return((t=this.getLevelDetails())==null?void 0:t.appliedTimelineOffset)||e}return 0}onMediaAttached(e,t){const s=this.media=this.mediaBuffer=t.media;ei(s,"seeking",this.onMediaSeeking),ei(s,"ended",this.onMediaEnded);const r=this.config;this.levels&&r.autoStartLoad&&this.state===Ae.STOPPED&&this.startLoad(r.startPosition)}onMediaDetaching(e,t){const s=!!t.transferMedia,r=this.media;if(r!==null){if(r.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),Ti(r,"seeking",this.onMediaSeeking),Ti(r,"ended",this.onMediaEnded),this.keyLoader&&!s&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loopSn=void 0,s){this.resetLoadingState(),this.resetTransmuxer();return}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=Ae.STOPPED,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,s){this.startFragRequested=!0,this._loadFragForPlayback(e,t,s)}_loadFragForPlayback(e,t,s){const r=i=>{const a=i.frag;if(this.fragContextChanged(a)){this.warn(`${a.type} sn: ${a.sn}${i.part?" part: "+i.part.index:""} of ${this.fragInfo(a,!1,i.part)}) was dropped during download.`),this.fragmentTracker.removeFragment(a);return}a.stats.chunkCount++,this._handleFragmentLoadProgress(i)};this._doFragLoad(e,t,s,r).then(i=>{if(!i)return;const a=this.state,l=i.frag;if(this.fragContextChanged(l)){(a===Ae.FRAG_LOADING||!this.fragCurrent&&a===Ae.PARSING)&&(this.fragmentTracker.removeFragment(l),this.state=Ae.IDLE);return}"payload"in i&&(this.log(`Loaded ${l.type} sn: ${l.sn} of ${this.playlistLabel()} ${l.level}`),this.hls.trigger(j.FRAG_LOADED,i)),this._handleFragmentLoadComplete(i)}).catch(i=>{this.state===Ae.STOPPED||this.state===Ae.ERROR||(this.warn(`Frag error: ${i?.message||i}`),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var t;const{fragmentTracker:s}=this;if(s.getState(e)===Gs.APPENDING){const i=e.type,a=this.getFwdBufferInfo(this.mediaBuffer,i),l=Math.max(e.duration,a?a.len:this.config.maxBufferLength),c=this.backtrackFragment;((c?e.sn-c.sn:0)===1||this.reduceMaxBufferLength(l,e.duration))&&s.removeFragment(e)}else((t=this.mediaBuffer)==null?void 0:t.buffered.length)===0?s.removeAllFragments():s.hasParts(e.type)&&(s.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),s.getState(e)===Gs.PARTIAL&&s.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 t?.live&&t.type!=="EVENT"&&(this.levelLastLoaded!==e||t.expired)}flushMainBuffer(e,t,s=null){if(!(e-t))return;const r={startOffset:e,endOffset:t,type:s};this.hls.trigger(j.BUFFER_FLUSHING,r)}_loadInitSegment(e,t){this._doFragLoad(e,t).then(s=>{const r=s?.frag;if(!r||this.fragContextChanged(r)||!this.levels)throw new Error("init load aborted");return s}).then(s=>{const{hls:r}=this,{frag:i,payload:a}=s,l=i.decryptdata;if(a&&a.byteLength>0&&l!=null&&l.key&&l.iv&&Hh(l.method)){const c=self.performance.now();
111return this.decrypter.decrypt(new Uint8Array(a),l.key.buffer,l.iv.buffer,oS(l.method)).catch(d=>{throw r.trigger(j.ERROR,{type:xt.MEDIA_ERROR,details:he.FRAG_DECRYPT_ERROR,fatal:!1,error:d,reason:d.message,frag:i}),d}).then(d=>{const h=self.performance.now();return r.trigger(j.FRAG_DECRYPTED,{frag:i,payload:d,stats:{tstart:c,tdecrypt:h}}),s.payload=d,this.completeInitSegmentLoad(s)})}return this.completeInitSegmentLoad(s)}).catch(s=>{this.state===Ae.STOPPED||this.state===Ae.ERROR||(this.warn(s),this.resetFragmentLoading(e))})}completeInitSegmentLoad(e){const{levels:t}=this;if(!t)throw new Error("init load aborted, missing levels");const s=e.frag.stats;this.state!==Ae.STOPPED&&(this.state=Ae.IDLE),e.frag.data=new Uint8Array(e.payload),s.parsing.start=s.buffering.start=self.performance.now(),s.parsing.end=s.buffering.end=self.performance.now(),this.tick()}unhandledEncryptionError(e,t){var s,r;const i=e.tracks;if(i&&!t.encrypted&&((s=i.audio)!=null&&s.encrypted||(r=i.video)!=null&&r.encrypted)&&(!this.config.emeEnabled||!this.keyLoader.emeController)){const a=this.media,l=new Error(`Encrypted track with no key in ${this.fragInfo(t)} (media ${a?"attached mediaKeys: "+a.mediaKeys:"detached"})`);return this.warn(l.message),!a||a.mediaKeys?!1:(this.hls.trigger(j.ERROR,{type:xt.KEY_SYSTEM_ERROR,details:he.KEY_SYSTEM_NO_KEYS,fatal:!1,error:l,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 s=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:${s?gne.toString(Bt.getBuffered(s)):"(detached)"})`),_s(e)){var r;if(e.type!==st.SUBTITLE){const a=e.elementaryStreams;if(!Object.keys(a).some(l=>!!a[l])){this.state=Ae.IDLE;return}}const i=(r=this.levels)==null?void 0:r[e.level];i!=null&&i.fragmentError&&(this.log(`Resetting level fragment error count of ${i.fragmentError} on frag buffered`),i.fragmentError=0)}this.state=Ae.IDLE}_handleFragmentLoadComplete(e){const{transmuxer:t}=this;if(!t)return;const{frag:s,part:r,partsLoaded:i}=e,a=!i||i.length===0||i.some(c=>!c),l=new iy(s.level,s.sn,s.stats.chunkCount+1,0,r?r.index:-1,!a);t.flush(l)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,s=null,r){var i;this.fragCurrent=e;const a=t.details;if(!this.levels||!a)throw new Error(`frag load aborted, missing level${a?"":" detail"}s`);let l=null;if(e.encrypted&&!((i=e.decryptdata)!=null&&i.key)){if(this.log(`Loading key for ${e.sn} of [${a.startSN}-${a.endSN}], ${this.playlistLabel()} ${e.level}`),this.state=Ae.KEY_LOADING,this.fragCurrent=e,l=this.keyLoader.load(e).then(m=>{if(!this.fragContextChanged(m.frag))return this.hls.trigger(j.KEY_LOADED,m),this.state===Ae.KEY_LOADING&&(this.state=Ae.IDLE),m}),this.hls.trigger(j.KEY_LOADING,{frag:e}),this.fragCurrent===null)return this.log("context changed in KEY_LOADING"),Promise.resolve(null)}else e.encrypted||(l=this.keyLoader.loadClear(e,a.encryptedFragments,this.startFragRequested),l&&this.log("[eme] blocking frag load until media-keys acquired"));const c=this.fragPrevious;if(_s(e)&&(!c||e.sn!==c.sn)){const m=this.shouldLoadParts(t.details,e.end);m!==this.loadingParts&&(this.log(`LL-Part loading ${m?"ON":"OFF"} loading sn ${c?.sn}->${e.sn}`),this.loadingParts=m)}if(s=Math.max(e.start,s||0),this.loadingParts&&_s(e)){const m=a.partList;if(m&&r){s>a.fragmentEnd&&a.fragmentHint&&(e=a.fragmentHint);const y=this.getNextPart(m,e,s);if(y>-1){const x=m[y];e=this.fragCurrent=x.fragment,this.log(`Loading ${e.type} sn: ${e.sn} part: ${x.index} (${y}/${m.length-1}) of ${this.fragInfo(e,!1,x)}) cc: ${e.cc} [${a.startSN}-${a.endSN}], target: ${parseFloat(s.toFixed(3))}`),this.nextLoadPosition=x.start+x.duration,this.state=Ae.FRAG_LOADING;let w;return l?w=l.then(S=>!S||this.fragContextChanged(S.frag)?null:this.doFragPartsLoad(e,x,t,r)).catch(S=>this.handleFragLoadError(S)):w=this.doFragPartsLoad(e,x,t,r).catch(S=>this.handleFragLoadError(S)),this.hls.trigger(j.FRAG_LOADING,{frag:e,part:x,targetBufferTime:s}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):w}else if(!e.url||this.loadedEndOfParts(m,s))return Promise.resolve(null)}}if(_s(e)&&this.loadingParts){var d;this.log(`LL-Part loading OFF after next part miss @${s.toFixed(2)} Check buffer at sn: ${e.sn} loaded parts: ${(d=a.partList)==null?void 0:d.filter(m=>m.loaded).map(m=>`[${m.start}-${m.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} ${"["+a.startSN+"-"+a.endSN+"]"}, target: ${parseFloat(s.toFixed(3))}`),et(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=Ae.FRAG_LOADING;const h=this.config.progressive&&e.type!==st.SUBTITLE;let p;return h&&l?p=l.then(m=>!m||this.fragContextChanged(m.frag)?null:this.fragmentLoader.load(e,r)).catch(m=>this.handleFragLoadError(m)):p=Promise.all([this.fragmentLoader.load(e,h?r:void 0),l]).then(([m])=>(!h&&r&&r(m),m)).catch(m=>this.handleFragLoadError(m)),this.hls.trigger(j.FRAG_LOADING,{frag:e,targetBufferTime:s}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):p}doFragPartsLoad(e,t,s,r){return new Promise((i,a)=>{var l;const c=[],d=(l=s.details)==null?void 0:l.partList,h=p=>{this.fragmentLoader.loadPart(e,p,r).then(m=>{c[p.index]=m;const y=m.part;this.hls.trigger(j.FRAG_LOADED,m);const x=tI(s.details,e.sn,p.index+1)||zN(d,e.sn,p.index+1);if(x)h(x);else return i({frag:e,part:y,partsLoaded:c})}).catch(a)};h(t)})}handleFragLoadError(e){if("data"in e){const t=e.data;t.frag&&t.details===he.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):t.frag&&t.type===xt.KEY_SYSTEM_ERROR?(t.frag.abortRequests(),this.resetStartWhenNotLoaded(),this.resetFragmentLoading(t.frag)):this.hls.trigger(j.ERROR,t)}else this.hls.trigger(j.ERROR,{type:xt.OTHER_ERROR,details:he.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){const t=this.getCurrentContext(e);if(!t||this.state!==Ae.PARSING){!this.fragCurrent&&this.state!==Ae.STOPPED&&this.state!==Ae.ERROR&&(this.state=Ae.IDLE);return}const{frag:s,part:r,level:i}=t,a=self.performance.now();s.stats.parsing.end=a,r&&(r.stats.parsing.end=a);const l=this.getLevelDetails(),d=l&&s.sn>l.endSN||this.shouldLoadParts(l,s.end);d!==this.loadingParts&&(this.log(`LL-Part loading ${d?"ON":"OFF"} after parsing segment ending @${s.end.toFixed(2)}`),this.loadingParts=d),this.updateLevelTiming(s,r,i,e.partial)}shouldLoadParts(e,t){if(this.config.lowLatencyMode){if(!e)return this.loadingParts;if(e.partList){var s;const i=e.partList[0];if(i.fragment.type===st.SUBTITLE)return!1;const a=i.end+(((s=e.fragmentHint)==null?void 0:s.duration)||0);if(t>=a){var r;if((this.hls.hasEnoughToStart?((r=this.media)==null?void 0:r.currentTime)||this.lastCurrentTime:this.getLoadPosition())>i.start-i.fragment.duration)return!0}}}return!1}getCurrentContext(e){const{levels:t,fragCurrent:s}=this,{level:r,sn:i,part:a}=e;if(!(t!=null&&t[r]))return this.warn(`Levels object was unset while buffering fragment ${i} of ${this.playlistLabel()} ${r}. The current chunk will not be buffered.`),null;const l=t[r],c=l.details,d=a>-1?tI(c,i,a):null,h=d?d.fragment:BN(c,i,s);return h?(s&&s!==h&&(h.stats=s.stats),{frag:h,part:d,level:l}):null}bufferFragmentData(e,t,s,r,i){if(this.state!==Ae.PARSING)return;const{data1:a,data2:l}=e;let c=a;if(l&&(c=ka(a,l)),!c.length)return;
111const d=this.initPTS[t.cc],h=d?-d.baseTime/d.timescale:void 0,p={type:e.type,frag:t,part:s,chunkMeta:r,offset:h,parent:t.type,data:c};if(this.hls.trigger(j.BUFFER_APPENDING,p),e.dropped&&e.independent&&!s){if(i)return;this.flushBufferGap(t)}}flushBufferGap(e){const t=this.media;if(!t)return;if(!Bt.isBuffered(t,t.currentTime)){this.flushMainBuffer(0,e.start);return}const s=t.currentTime,r=Bt.bufferInfo(t,s,0),i=e.duration,a=Math.min(this.config.maxFragLookUpTolerance*2,i*.25),l=Math.max(Math.min(e.start-a,r.end-a),s+a);e.start-l>a&&this.flushMainBuffer(l,e.start)}getFwdBufferInfo(e,t){var s;const r=this.getLoadPosition();if(!et(r))return null;const a=this.lastCurrentTime>r||(s=this.media)!=null&&s.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(e,r,t,a)}getFwdBufferInfoAtPos(e,t,s,r){const i=Bt.bufferInfo(e,t,r);if(i.len===0&&i.nextStart!==void 0){const a=this.fragmentTracker.getBufferedFrag(t,s);if(a&&(i.nextStart<=a.end||a.gap)){const l=Math.max(Math.min(i.nextStart,a.end)-t,r);return Bt.bufferInfo(e,t,l)}}return i}getMaxBufferLength(e){const{config:t}=this;let s;return e?s=Math.max(8*t.maxBufferSize/e,t.maxBufferLength):s=t.maxBufferLength,Math.min(s,t.maxMaxBufferLength)}exceedsMaxBuffer(e,t,s){const r=e.nextStart;if(r&&s.start>r){const i=e.buffered;if(i){let a=e.len;const l=e.bufferedIndex;for(let c=i.length-1;c>l;c--)i[c].start<s.start&&(a+=i[c].end-i[c].start);return a>=t}}return!1}reduceMaxBufferLength(e,t){const s=this.config,r=Math.max(Math.min(e-t,s.maxBufferLength),t),i=Math.max(e-t*3,s.maxMaxBufferLength/2,r);return i>=r?(s.maxMaxBufferLength=i,this.warn(`Reduce max buffer length to ${i}s`),!0):!1}getAppendedFrag(e,t=st.MAIN){const s=this.fragmentTracker?this.fragmentTracker.getAppendedFrag(e,t):null;return s&&"fragment"in s?s.fragment:s}getNextFragment(e,t){const s=t.fragments,r=s.length;if(!r)return null;const{config:i}=this,a=t.fragmentStart,l=i.lowLatencyMode&&!!t.partList;let c=null;if(t.live){const p=i.initialLiveManifestSize;if(r<p)return this.warn(`Not enough fragments to start playback (have: ${r}, need: ${p})`),null;if(!t.PTSKnown&&!this.startFragRequested&&this.startPosition===-1||e<a){var d;l&&!this.loadingParts&&(this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=!0),c=this.getInitialLiveFragment(t);const m=this.config.startPosition,y=this.hls.startPosition,x=this.hls.liveSyncPosition,w=((d=c)==null?void 0:d.start)||0;let S,_;y!==-1&&y>=a?(S=y,_=y===m?"config":"next load start"):x!==null?(S=x,_="live edge"):(S=e,_="buffer pos"),S<w&&(S=w,_="live frag start"),S<a&&(S=a,_="playlist start"),(this.startPosition!=S||this.nextLoadPosition!=S)&&(this.log(`Setting startPosition to ${S.toFixed(3)} ${y===-1?"":`(from ${m}) `}based on ${_}. live edge: ${x} live frag start: ${w.toFixed(3)} playlist start: ${a.toFixed(3)} buffer pos: ${e}`),this.startPosition=this.nextLoadPosition=S)}}else e<=a&&(c=s[0]);if(!c){const p=this.loadingParts?t.partEnd:t.fragmentEnd;c=this.getFragmentAtPosition(e,p,t)}let h=this.filterReplacedPrimary(c,t);if(!h&&c){const p=c.sn-t.startSN;h=this.filterReplacedPrimary(s[p+1]||null,t)}return this.mapToInitFragWhenRequired(h)}isLoopLoading(e,t){if(this.nextLoadPosition<=t)return!1;const s=this.fragmentTracker.getState(e);return s===Gs.OK||s===Gs.PARTIAL&&!!e.gap}getNextFragmentLoopLoading(e,t,s,r,i){let a=null;if(e.gap&&(a=this.getNextFragment(this.nextLoadPosition,t),a&&!a.gap&&s.nextStart)){const l=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,s.nextStart,r,0);if(l!==null&&s.len+l.len>=i){const c=a.sn;return this.loopSn!==c&&(this.log(`buffer full after gaps in "${r}" playlist starting at sn: ${c}`),this.loopSn=c),null}}return this.loopSn=void 0,a}get primaryPrefetch(){if(rI(this.config)){var e;if((e=this.hls.interstitialsManager)==null||(e=e.playingItem)==null?void 0:e.event)return!0}return!1}filterReplacedPrimary(e,t){if(!e)return e;if(rI(this.config)&&e.type!==st.SUBTITLE){const s=this.hls.interstitialsManager,r=s?.bufferingItem;if(r){const a=r.event;if(a){if(a.appendInPlace||Math.abs(e.start-r.start)>1||r.start===0)return null}
111else if(e.end<=r.start&&t?.live===!1||e.start>r.end&&r.nextEvent&&(r.nextEvent.appendInPlace||e.start-r.end>1))return null}const i=s?.playerQueue;if(i)for(let a=i.length;a--;){const l=i[a].interstitial;if(l.appendInPlace&&e.start>=l.startTime&&e.end<=l.resumeTime)return null}}return e}mapToInitFragWhenRequired(e){return e!=null&&e.initSegment&&!e.initSegment.data&&!this.bitrateTest?e.initSegment:e}getNextPart(e,t,s){let r=-1,i=!1,a=!0;for(let l=0,c=e.length;l<c;l++){const d=e[l];if(a=a&&!d.independent,r>-1&&s<d.start)break;const h=d.loaded;h?r=-1:(i||(d.independent||a)&&d.fragment===t)&&(d.fragment!==t&&this.warn(`Need buffer at ${s} but next unloaded part starts at ${d.start}`),r=l),i=h}return r}loadedEndOfParts(e,t){let s;for(let r=e.length;r--;){if(s=e[r],!s.loaded)return!1;if(t>s.start)return!0}return!1}getInitialLiveFragment(e){const t=e.fragments,s=this.fragPrevious;let r=null;if(s){if(e.hasProgramDateTime&&(r=Dte(t,s.endProgramDateTime,this.config.maxFragLookUpTolerance),r&&this.log(`Live playlist, switching playlist, load frag with same PDT: ${s.programDateTime}`)),!r){const i=s.sn+1;if(i>=e.startSN&&i<=e.endSN){const a=t[i-e.startSN];s.cc===a.cc&&(r=a,this.log(`Live playlist, switching playlist, load frag with next SN: ${r.sn}`))}r||(r=AN(e,s.cc,s.end),r&&this.log(`Live playlist, switching playlist, load frag with same CC: ${r.sn}`))}}else{const i=this.hls.liveSyncPosition;i!==null&&(r=this.getFragmentAtPosition(i,this.bitrateTest?e.fragmentEnd:e.edge,e))}return r}getFragmentAtPosition(e,t,s){const{config:r}=this;let{fragPrevious:i}=this,{fragments:a,endSN:l}=s;const{fragmentHint:c}=s,{maxFragLookUpTolerance:d}=r,h=s.partList,p=!!(this.loadingParts&&h!=null&&h.length&&c);p&&!this.bitrateTest&&h[h.length-1].fragment.sn===c.sn&&(a=a.concat(c),l=c.sn);let m;if(e<t){var y;const w=e<this.lastCurrentTime||e>t-d||(y=this.media)!=null&&y.paused||!this.startFragRequested?0:d;m=Id(i,a,e,w)}else m=a[a.length-1];if(m){const x=m.sn-s.startSN,w=this.fragmentTracker.getState(m);if((w===Gs.OK||w===Gs.PARTIAL&&m.gap)&&(i=m),i&&m.sn===i.sn&&(!p||h[0].fragment.sn>m.sn||!s.live)&&m.level===i.level){const _=a[x+1];m.sn<l&&this.fragmentTracker.getState(_)!==Gs.OK?m=_:m=null}}return m}alignPlaylists(e,t,s){const r=e.fragments.length;if(!r)return this.warn("No fragments in live playlist"),0;const i=e.fragmentStart,a=!t,l=e.alignedSliding&&et(i);if(a||!l&&!i){mne(s,e);const c=e.fragmentStart;return this.log(`Live playlist sliding: ${c.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} fragments: ${r}`),c}return i}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,e.partTarget*3)}setStartPosition(e,t){let s=this.startPosition;s<t&&(s=-1);const r=this.timelineOffset;if(s===-1){const i=this.startTimeOffset!==null,a=i?this.startTimeOffset:e.startTimeOffset;a!==null&&et(a)?(s=t+a,a<0&&(s+=e.edge),s=Math.min(Math.max(t,s),t+e.totalduration),this.log(`Setting startPosition to ${s} for start time offset ${a} found in ${i?"multivariant":"media"} playlist`),this.startPosition=s):e.live?(s=this.hls.liveSyncPosition||t,this.log(`Setting startPosition to -1 to start at live edge ${s}`),this.startPosition=-1):(this.log("setting startPosition to 0 by default"),this.startPosition=s=0),this.lastCurrentTime=s+r}this.nextLoadPosition=s+r}getLoadPosition(){var e;const{media:t}=this;let s=0;return(e=this.hls)!=null&&e.hasEnoughToStart&&t?s=t.currentTime:this.nextLoadPosition>=0&&(s=this.nextLoadPosition),s}handleFragLoadAborted(e,t){this.transmuxer&&e.type===this.playlistType&&_s(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!==Ae.FRAG_LOADING_WAITING_RETRY)&&(this.state=Ae.IDLE)}onFragmentOrKeyLoadError(e,t){var s;if(t.chunkMeta&&!t.frag){const _=this.getCurrentContext(t.chunkMeta);_&&(t.frag=_.frag)}const r=t.frag;if(!r||r.type!==e||!this.levels)return;if(this.fragContextChanged(r)){var i;this.warn(`Frag load error must match current frag to retry ${r.url} > ${(i=this.fragCurrent)==null?void 0:i.url}`);return}const a=t.details===he.FRAG_GAP;a&&this.fragmentTracker.fragBuffered(r,!0);const l=t.errorAction;if(!l){this.state=Ae.ERROR;return}const{action:c,flags:d,retryCount:h=0,retryConfig:p}=l,m=!!p,y=m&&c===Ws.RetryRequest,x=m&&!l.resolved&&d===vi.MoveAllAlternatesMatchingHost,w=(s=this.hls.latestLevelDetails)==null?void 0:s.live;if(!y&&x&&_s(r)&&!r.endList&&w&&!kN(t))this.resetFragmentErrors(e),this.treatAsGap(r),l.resolved=!0;else if((y||x)&&h<p.maxNumRetry){var S;const _=rw((S=t.response)==null?void 0:S.code),L=rS(p,h);if(this.resetStartWhenNotLoaded(),this.retryDate=self.performance.now()+L,this.state=Ae.FRAG_LOADING_WAITING_RETRY,l.resolved=!0,_){this.log("Waiting for connection (offline)"),this.retryDate=1/0,t.reason="offline";return}this.warn(`Fragment ${r.sn} of ${e} ${r.level} errored with ${t.details}, retrying loading ${h+1}/${p.maxNumRetry} in ${L}ms`)}else if(p)if(this.resetFragmentErrors(e),h<p.maxNumRetry)!a&&c!==Ws.RemoveAlternatePermanently&&(l.resolved=!0);else{this.warn(`${t.details} reached or exceeded max retry (${h})`);return}else c===Ws.SendAlternateToPenaltyBox?this.state=Ae.WAITING_LEVEL:this.state=Ae.ERROR;this.tickImmediate()}checkRetryDate(){const e=self.performance.now(),t=this.retryDate,s=t===1/0;(!t||e>=t||s&&!rw(0))&&(s&&this.log("Connection restored (online)"),this.resetStartWhenNotLoaded(),this.state=Ae.IDLE)}reduceLengthAndFlushBuffer(e){if(this.state===Ae.PARSING||this.state===Ae.PARSED){const t=e.frag,s=e.parent,r=this.getFwdBufferInfo(this.mediaBuffer,s),i=r&&r.len>.5;i&&this.reduceMaxBufferLength(r.len,t?.duration||10);const a=!i;return a&&this.warn(`Buffer full error while media.currentTime (${this.getLoadPosition()}) is not buffered, flush ${s} buffer`),t&&(this.fragmentTracker.removeFragment(t),this.nextLoadPosition=t.start),this.resetLoadingState(),a}return!1}resetFragmentErrors(e){e===st.AUDIO&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==Ae.STOPPED&&(this.state=Ae.IDLE)}afterBufferFlushed(e,t,s){if(!e)return;const r=Bt.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,r,s),this.state===Ae.ENDED&&this.resetLoadingState()}
vendor: 55,691 bytes, line 111
111resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==Ae.STOPPED&&(this.state=Ae.IDLE)}resetStartWhenNotLoaded(){if(!this.hls.hasEnoughToStart){this.startFragRequested=!1;const e=this.levelLastLoaded,t=e?e.details:null;t!=null&&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()} ${e.level===-1?"<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,s,r){const i=s.details;if(!i){this.warn("level.details undefined");return}if(!Object.keys(e.elementaryStreams).reduce((c,d)=>{const h=e.elementaryStreams[d];if(h){const p=h.endPTS-h.startPTS;if(p<=0)return this.warn(`Could not parse fragment ${e.sn} ${d} duration reliably (${p})`),c||!1;const m=r?0:FN(i,e,h.startPTS,h.endPTS,h.startDTS,h.endDTS,this);return this.hls.trigger(j.LEVEL_PTS_UPDATED,{details:i,level:s,drift:m,type:d,frag:e,start:h.startPTS,end:h.endPTS}),!0}return c},!1)){var l;const c=((l=this.transmuxer)==null?void 0:l.error)===null;if((s.fragmentError===0||c&&(s.fragmentError<2||e.endList))&&this.treatAsGap(e,s),c){const d=new Error(`Found no media in fragment ${e.sn} of ${this.playlistLabel()} ${e.level} resetting transmuxer to fallback to playlist timing`);if(this.warn(d.message),this.hls.trigger(j.ERROR,{type:xt.MEDIA_ERROR,details:he.FRAG_PARSING_ERROR,fatal:!1,error:d,frag:e,reason:`Found no media in msn ${e.sn} of ${this.playlistLabel()} "${s.url}"`}),!this.hls)return;this.resetTransmuxer()}}this.state=Ae.PARSED,this.log(`Parsed ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)})`),this.hls.trigger(j.FRAG_PARSED,{frag:e,part:t})}playlistLabel(){return this.playlistType===st.MAIN?"level":"track"}fragInfo(e,t=!0,s){var r,i;return`${this.playlistLabel()} ${e.level} (${s?"part":"frag"}:[${((r=t&&!s?e.startPTS:(s||e).start)!=null?r:NaN).toFixed(3)}-${((i=t&&!s?e.endPTS:(s||e).end)!=null?i:NaN).toFixed(3)}]${s&&e.type==="main"?"INDEPENDENT="+(s.independent?"YES":"NO"):""}`}treatAsGap(e,t){t&&t.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)}resetTransmuxer(){var e;(e=this.transmuxer)==null||e.reset()}recoverWorkerError(e){e.event==="demuxerWorker"&&(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 rI(n){return!!n.interstitialsController&&n.enableInterstitialPlayback!==!1}class GN{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){const{chunks:e,dataLength:t}=this;let s;if(e.length)e.length===1?s=e[0]:s=xne(e,t);else return new Uint8Array(0);return this.reset(),s}reset(){this.chunks.length=0,this.dataLength=0}}function xne(n,e){const t=new Uint8Array(e);let s=0;for(let r=0;r<n.length;r++){const i=n[r];t.set(i,s),s+=i.length}return t}var Iv={exports:{}},iI;function yne(){return iI||(iI=1,(function(n){var e=Object.prototype.hasOwnProperty,t="~";function s(){}Object.create&&(s.prototype=Object.create(null),new s().__proto__||(t=!1));function r(c,d,h){this.fn=c,this.context=d,this.once=h||!1}function i(c,d,h,p,m){if(typeof h!="function")throw new TypeError("The listener must be a function");var y=new r(h,p||c,m),x=t?t+d:d;return c._events[x]?c._events[x].fn?c._events[x]=[c._events[x],y]:c._events[x].push(y):(c._events[x]=y,c._eventsCount++),c}function a(c,d){--c._eventsCount===0?c._events=new s:delete c._events[d]}function l(){this._events=new s,this._eventsCount=0}l.prototype.eventNames=function(){var d=[],h,p;if(this._eventsCount===0)return d;for(p in h=this._events)e.call(h,p)&&d.push(t?p.slice(1):p);return Object.getOwnPropertySymbols?d.concat(Object.getOwnPropertySymbols(h)):d},l.prototype.listeners=function(d){var h=t?t+d:d,p=this._events[h];if(!p)return[];if(p.fn)return[p.fn];for(var m=0,y=p.length,x=new Array(y);m<y;m++)x[m]=p[m].fn;return x},l.prototype.listenerCount=function(d){var h=t?t+d:d,p=this._events[h];return p?p.fn?1:p.length:0},l.prototype.emit=function(d,h,p,m,y,x){var w=t?t+d:d;if(!this._events[w])return!1;var S=this._events[w],_=arguments.length,L,R;if(S.fn){switch(S.once&&this.removeListener(d,S.fn,void 0,!0),_){case 1:return S.fn.call(S.context),!0;case 2:return S.fn.call(S.context,h),!0;case 3:return S.fn.call(S.context,h,p),!0;case 4:return S.fn.call(S.context,h,p,m),!0;case 5:return S.fn.call(S.context,h,p,m,y),!0;case 6:return S.fn.call(S.context,h,p,m,y,x),!0}for(R=1,L=new Array(_-1);R<_;R++)L[R-1]=arguments[R];S.fn.apply(S.context,L)}else{var M=S.length,V;for(R=0;R<M;R++)switch(S[R].once&&this.removeListener(d,S[R].fn,void 0,!0),_){case 1:S[R].fn.call(S[R].context);break;case 2:S[R].fn.call(S[R].context,h);break;case 3:S[R].fn.call(S[R].context,h,p);break;case 4:S[R].fn.call(S[R].context,h,p,m);break;default:if(!L)for(V=1,L=new Array(_-1);V<_;V++)L[V-1]=arguments[V];S[R].fn.apply(S[R].context,L)}}return!0},l.prototype.on=function(d,h,p){return i(this,d,h,p,!1)},l.prototype.once=function(d,h,p){return i(this,d,h,p,!0)},l.prototype.removeListener=function(d,h,p,m){var y=t?t+d:d;if(!this._events[y])return this;if(!h)return a(this,y),this;var x=this._events[y];if(x.fn)x.fn===h&&(!m||x.once)&&(!p||x.context===p)&&a(this,y);else{for(var w=0,S=[],_=x.length;w<_;w++)(x[w].fn!==h||m&&!x[w].once||p&&x[w].context!==p)&&S.push(x[w]);S.length?this._events[y]=S.length===1?S[0]:S:a(this,y)}return this},l.prototype.removeAllListeners=function(d){var h;return d?(h=t?t+d:d,this._events[h]&&a(this,h)):(this._events=new s,this._eventsCount=0),this},l.prototype.off=l.prototype.removeListener,l.prototype.addListener=l.prototype.on,l.prefixed=t,l.EventEmitter=l,n.exports=l})(Iv)),Iv.exports}var vne=yne(),uS=qee(vne);const ym="1.6.16",of={};function bne(){return typeof __HLS_WORKER_BUNDLE__=="function"}function wne(){const n=of[ym];if(n)return n.clientCount++,n;const e=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),t=self.URL.createObjectURL(e),r={worker:new self.Worker(t),objectURL:t,clientCount:1};return of[ym]=r,r}function Sne(n){const e=of[n];if(e)return e.clientCount++,e;const t=new self.URL(n,self.location.href).href,r={worker:new self.Worker(t),scriptURL:t,clientCount:1};return of[n]=r,r}function Ene(n){const e=of[n||ym];if(e&&e.clientCount--===1){const{worker:s,objectURL:r}=e;delete of[n||ym],r&&self.URL.revokeObjectURL(r),s.terminate()}}function KN(n,e){return e+10<=n.length&&n[e]===51&&n[e+1]===68&&n[e+2]===73&&n[e+3]<255&&n[e+4]<255&&n[e+6]<128&&n[e+7]<128&&n[e+8]<128&&n[e+9]<128}function dS(n,e){return e+10<=n.length&&n[e]===73&&n[e+1]===68&&n[e+2]===51&&n[e+3]<255&&n[e+4]<255&&n[e+6]<128&&n[e+7]<128&&n[e+8]<128&&n[e+9]<128}function oy(n,e){let t=0;return t=(n[e]&127)<<21,t|=(n[e+1]&127)<<14,t|=(n[e+2]&127)<<7,t|=n[e+3]&127,t}function vm(n,e){const t=e;let s=0;for(;dS(n,e);){s+=10;const r=oy(n,e+6);s+=r,KN(n,e+10)&&(s+=10),e+=s}if(s>0)return n.subarray(t,t+s)}function Tne(n,e,t,s){const r=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],i=e[t+2],a=i>>2&15;if(a>12){const y=new Error(`invalid ADTS sampling index:${a}`);n.emit(j.ERROR,j.ERROR,{type:xt.MEDIA_ERROR,details:he.FRAG_PARSING_ERROR,fatal:!0,error:y,reason:y.message});return}const l=(i>>6&3)+1,c=e[t+3]>>6&3|(i&1)<<2,d="mp4a.40."+l,h=r[a];let p=a;(l===5||l===29)&&(p-=3);const m=[l<<3|(p&14)>>1,(p&1)<<7|c<<3];return An.log(`manifest codec:${s}, parsed codec:${d}, channels:${c}, rate:${h} (ADTS object type:${l} sampling index:${a})`),{config:m,samplerate:h,channelCount:c,codec:d,parsedCodec:d,manifestCodec:s}}function qN(n,e){return n[e]===255&&(n[e+1]&246)===240}function YN(n,e){return n[e+1]&1?7:9}function hS(n,e){return(n[e+3]&3)<<11|n[e+4]<<3|(n[e+5]&224)>>>5}function _ne(n,e){return e+5<n.length}function z1(n,e){return e+1<n.length&&qN(n,e)}function Ine(n,e){return _ne(n,e)&&qN(n,e)&&hS(n,e)<=n.length-e}function Ane(n,e){if(z1(n,e)){const t=YN(n,e);if(e+t>=n.length)return!1;const s=hS(n,e);if(s<=t)return!1;const r=e+s;return r===n.length||z1(n,r)}return!1}function QN(n,e,t,s,r){if(!n.samplerate){const i=Tne(e,t,s,r);if(!i)return;kn(n,i)}}function XN(n){return 1024*9e4/n}function Cne(n,e){const t=YN(n,e);if(e+t<=n.length){const s=hS(n,e)-t;if(s>0)return{headerLength:t,frameLength:s}}}function JN(n,e,t,s,r){const i=XN(n.samplerate),a=s+r*i,l=Cne(e,t);let c;if(l){const{frameLength:p,headerLength:m}=l,y=m+p,x=Math.max(0,t+y-e.length);x?(c=new Uint8Array(y-m),c.set(e.subarray(t+m,e.length),0)):c=e.subarray(t+m,t+y);const w={unit:c,pts:a};return x||n.samples.push(w),{sample:w,length:y,missing:x}}const d=e.length-t;return c=new Uint8Array(d),c.set(e.subarray(t,e.length),0),{sample:{unit:c,pts:a},length:d,missing:-1}}function kne(n,e){return dS(n,e)&&oy(n,e+6)+10<=n.length-e}function Rne(n){return n instanceof ArrayBuffer?n:n.byteOffset==0&&n.byteLength==n.buffer.byteLength?n.buffer:new Uint8Array(n).buffer}function Av(n,e=0,t=1/0){return Pne(n,e,t,Uint8Array)}function Pne(n,e,t,s){const r=Nne(n);let i=1;"BYTES_PER_ELEMENT"in s&&(i=s.BYTES_PER_ELEMENT);const a=Lne(n)?n.byteOffset:0,l=(a+n.byteLength)/i,c=(a+e)/i,d=Math.floor(Math.max(0,Math.min(c,l))),h=Math.floor(Math.min(d+Math.max(t,0),l));return new s(r,d,h-d)}function Nne(n){return n instanceof ArrayBuffer?n:n.buffer}function Lne(n){return n&&n.buffer instanceof ArrayBuffer&&n.byteLength!==void 0&&n.byteOffset!==void 0}function Dne(n){const e={key:n.type,description:"",data:"",mimeType:null,pictureType:null},t=3;if(n.size<2||n.data[0]!==t)return;const s=n.data.subarray(1).indexOf(0);if(s===-1)return;const r=na(Av(n.data,1,s)),i=n.data[2+s],a=n.data.subarray(3+s).indexOf(0);if(a===-1)return;const l=na(Av(n.data,3+s,a));let c;return r==="-->"?c=na(Av(n.data,4+s+a)):c=Rne(n.data.subarray(4+s+a)),e.mimeType=r,e.pictureType=i,e.description=l,e.data=c,e}function jne(n){if(n.size<2)return;const e=na(n.data,!0),t=new Uint8Array(n.data.subarray(e.length+1));return{key:n.type,info:e,data:t.buffer}}function One(n){if(n.size<2)return;if(n.type==="TXXX"){let t=1;const s=na(n.data.subarray(t),!0);t+=s.length+1;const r=na(n.data.subarray(t));return{key:n.type,info:s,data:r}}const e=na(n.data.subarray(1));return{key:n.type,info:"",data:e}}function Mne(n){if(n.type==="WXXX"){if(n.size<2)return;let t=1;const s=na(n.data.subarray(t),!0);t+=s.length+1;const r=na(n.data.subarray(t));return{key:n.type,info:s,data:r}}const e=na(n.data);return{key:n.type,info:"",data:e}}function Fne(n){return n.type==="PRIV"?jne(n):n.type[0]==="W"?Mne(n):n.type==="APIC"?Dne(n):One(n)}function Une(n){const e=String.fromCharCode(n[0],n[1],n[2],n[3]),t=oy(n,4),s=10;return{type:e,size:t,data:n.subarray(s,s+t)}}const s0=10,Vne=10;function ZN(n){let e=0;const t=[];for(;dS(n,e);){const s=oy(n,e+6);n[e+5]>>6&1&&(e+=s0),e+=s0;const r=e+s;for(;e+Vne<r;){const i=Une(n.subarray(e)),a=Fne(i);a&&t.push(a),e+=i.size+s0}KN(n,e)&&(e+=s0)}return t}function eL(n){return n&&n.key==="PRIV"&&n.info==="com.apple.streaming.transportStreamTimestamp"}function Bne(n){if(n.data.byteLength===8){const e=new Uint8Array(n.data),t=e[3]&1;let s=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return s/=45,t&&(s+=4772185884e-2),Math.round(s)}}function fS(n){const e=ZN(n);for(let t=0;t<e.length;t++){const s=e[t];if(eL(s))return Bne(s)}}let wi=(function(n){return n.audioId3="org.id3",n.dateRange="com.apple.quicktime.HLS",n.emsg="https://aomedia.org/emsg/ID3",n.misbklv="urn:misb:KLV:bin:1910.1",n})({});function Mo(n="",e=9e4){return{type:n,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}class pS{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,s,r){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,s){}demux(e,t){this.cachedData&&(e=ka(this.cachedData,e),this.cachedData=null);let s=vm(e,0),r=s?s.length:0,i;const a=this._audioTrack,l=this._id3Track,c=s?fS(s):void 0,d=e.length;for((this.basePTS===null||this.frameIndex===0&&et(c))&&(this.basePTS=zne(c,t,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),s&&s.length>0&&l.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:s,type:wi.audioId3,duration:Number.POSITIVE_INFINITY});r<d;){if(this.canParse(e,r)){const h=this.appendFrame(a,e,r);h?(this.frameIndex++,this.lastPTS=h.sample.pts,r+=h.length,i=r):r=d}else kne(e,r)?(s=vm(e,r),l.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:s,type:wi.audioId3,duration:Number.POSITIVE_INFINITY}),r+=s.length,i=r):r++;if(r===d&&i!==d){const h=e.slice(i);this.cachedData?this.cachedData=ka(this.cachedData,h):this.cachedData=h}}return{audioTrack:a,videoTrack:Mo(),id3Track:l,textTrack:Mo()}}demuxSampleAes(e,t,s){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:Mo(),id3Track:this._id3Track,textTrack:Mo()}}destroy(){this.cachedData=null,this._audioTrack=this._id3Track=void 0}}const zne=(n,e,t)=>{if(et(n))return n*90;const s=t?t.baseTime*9e4/t.timescale:0;return e*9e4+s};let r0=null;const $ne=[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],Hne=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],Wne=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],Gne=[0,1,1,4];function tL(n,e,t,s,r){if(t+24>e.length)return;const i=nL(e,t);if(i&&t+i.frameLength<=e.length){const a=i.samplesPerFrame*9e4/i.sampleRate,l=s+r*a,c={unit:e.subarray(t,t+i.frameLength),pts:l,dts:l};return n.config=[],n.channelCount=i.channelCount,n.samplerate=i.sampleRate,n.samples.push(c),{sample:c,length:i.frameLength,missing:0}}}function nL(n,e){const t=n[e+1]>>3&3,s=n[e+1]>>1&3,r=n[e+2]>>4&15,i=n[e+2]>>2&3;if(t!==1&&r!==0&&r!==15&&i!==3){const a=n[e+2]>>1&1,l=n[e+3]>>6,c=t===3?3-s:s===3?3:4,d=$ne[c*14+r-1]*1e3,p=Hne[(t===3?0:t===2?1:2)*3+i],m=l===3?1:2,y=Wne[t][s],x=Gne[s],w=y*8*x,S=Math.floor(y*d/p+a)*x;if(r0===null){const R=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);r0=R?parseInt(R[1]):0}return r0&&r0<=87&&s===2&&d>=224e3&&l===0&&(n[e+3]=n[e+3]|128),{sampleRate:p,channelCount:m,frameLength:S,samplesPerFrame:w}}}function mS(n,e){return n[e]===255&&(n[e+1]&224)===224&&(n[e+1]&6)!==0}function sL(n,e){return e+1<n.length&&mS(n,e)}function Kne(n,e){return mS(n,e)&&4<=n.length-e}function rL(n,e){if(e+1<n.length&&mS(n,e)){const s=nL(n,e);let r=4;s!=null&&s.frameLength&&(r=s.frameLength);const i=e+r;return i===n.length||sL(n,i)}return!1}class qne extends pS{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t}resetInitSegment(e,t,s,r){super.resetInitSegment(e,t,s,r),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:r,inputTimeScale:9e4,dropped:0}}static probe(e,t){if(!e)return!1;const s=vm(e,0);let r=s?.length||0;if(rL(e,r))return!1;for(let i=e.length;r<i;r++)if(Ane(e,r))return t.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return Ine(e,t)}appendFrame(e,t,s){QN(e,this.observer,t,s,e.manifestCodec);const r=JN(e,t,s,this.basePTS,this.frameIndex);if(r&&r.missing===0)return r}}const iL=(n,e)=>{let t=0,s=5;e+=s;const r=new Uint32Array(1),i=new Uint32Array(1),a=new Uint8Array(1);for(;s>0;){a[0]=n[e];const l=Math.min(s,8),c=8-l;i[0]=4278190080>>>24+c<<c,r[0]=(a[0]&i[0])>>c,t=t?t<<l|r[0]:r[0],e+=1,s-=l}return t};class Yne extends pS{constructor(e){super(),this.observer=void 0,this.observer=e}resetInitSegment(e,t,s,r){super.resetInitSegment(e,t,s,r),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:t,duration:r,inputTimeScale:9e4,dropped:0}}canParse(e,t){return t+64<e.length}appendFrame(e,t,s){const r=aL(e,t,s,this.basePTS,this.frameIndex);if(r!==-1)return{sample:e.samples[e.samples.length-1],length:r,missing:0}}static probe(e){if(!e)return!1;const t=vm(e,0);if(!t)return!1;const s=t.length;return e[s]===11&&e[s+1]===119&&fS(t)!==void 0&&iL(e,s)<16}}function aL(n,e,t,s,r){if(t+8>e.length||e[t]!==11||e[t+1]!==119)return-1;const i=e[t+4]>>6;if(i>=3)return-1;const l=[48e3,44100,32e3][i],c=e[t+4]&63,h=[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][c*3+i]*2;if(t+h>e.length)return-1;const p=e[t+6]>>5;let m=0;p===2?m+=2:(p&1&&p!==1&&(m+=2),p&4&&(m+=2));const y=(e[t+6]<<8|e[t+7])>>12-m&1,w=[2,1,2,3,3,4,4,5][p]+y,S=e[t+5]>>3,_=e[t+5]&7,L=new Uint8Array([i<<6|S<<1|_>>2,(_&3)<<6|p<<3|y<<2|c>>4,c<<4&224]),R=1536/l*9e4,M=s+r*R,V=e.subarray(t,t+h);return n.config=L,n.channelCount=w,n.samplerate=l,n.samples.push({unit:V,pts:M}),h}class Qne extends pS{resetInitSegment(e,t,s,r){super.resetInitSegment(e,t,s,r),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:r,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;const t=vm(e,0);let s=t?.length||0;if(t&&e[s]===11&&e[s+1]===119&&fS(t)!==void 0&&iL(e,s)<=16)return!1;for(let r=e.length;s<r;s++)if(rL(e,s))return An.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return Kne(e,t)}appendFrame(e,t,s){if(this.basePTS!==null)return tL(e,t,s,this.basePTS,this.frameIndex)}}const Xne=/\/emsg[-/]ID3/i;class Jne{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,s,r){const i=this.videoTrack=Mo("video",1),a=this.audioTrack=Mo("audio",1),l=this.txtTrack=Mo("text",1);if(this.id3Track=Mo("id3",1),this.timeOffset=0,!(e!=null&&e.byteLength))return;const c=mN(e);if(c.video){const{id:d,timescale:h,codec:p,supplemental:m}=c.video;i.id=d,i.timescale=l.timescale=h,i.codec=p,i.supplemental=m}if(c.audio){const{id:d,timescale:h,codec:p}=c.audio;a.id=d,a.timescale=h,a.codec=p}l.id=hN.text,i.sampleDuration=0,i.duration=a.duration=r}resetContiguity(){this.remainderData=null}static probe(e){return Jee(e)}demux(e,t){this.timeOffset=t;let s=e;const r=this.videoTrack,i=this.txtTrack;if(this.config.progressive){this.remainderData&&(s=ka(this.remainderData,e));const l=ite(s);this.remainderData=l.remainder,r.samples=l.valid||new Uint8Array}else r.samples=s;const a=this.extractID3Track(r,t);return i.samples=T_(t,r),{videoTrack:r,audioTrack:this.audioTrack,id3Track:a,textTrack:this.txtTrack}}flush(){const e=this.timeOffset,t=this.videoTrack,s=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;const r=this.extractID3Track(t,this.timeOffset);return s.samples=T_(e,t),{videoTrack:t,audioTrack:Mo(),id3Track:r,textTrack:Mo()}}extractID3Track(e,t){const s=this.id3Track;if(e.samples.length){const r=qt(e.samples,["emsg"]);r&&r.forEach(i=>{const a=ote(i);if(Xne.test(a.schemeIdUri)){const l=aI(a,t);let c=a.eventDuration===4294967295?Number.POSITIVE_INFINITY:a.eventDuration/a.timeScale;c<=.001&&(c=Number.POSITIVE_INFINITY);const d=a.payload;s.samples.push({data:d,len:d.byteLength,dts:l,pts:l,type:wi.emsg,duration:c})}else if(this.config.enableEmsgKLVMetadata&&a.schemeIdUri.startsWith("urn:misb:KLV:bin:1910.1")){const l=aI(a,t);s.samples.push({data:a.payload,len:a.payload.byteLength,dts:l,pts:l,type:wi.misbklv,duration:Number.POSITIVE_INFINITY})}})}return s}demuxSampleAes(e,t,s){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}}function aI(n,e){return et(n.presentationTime)?n.presentationTime/n.timeScale:e+n.presentationTimeDelta/n.timeScale}class Zne{constructor(e,t,s){this.keyData=void 0,this.decrypter=void 0,this.keyData=s,this.decrypter=new iS(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,hu.cbc)}decryptAacSample(e,t,s){const r=e[t].unit;if(r.length<=16)return;const i=r.subarray(16,r.length-r.length%16),a=i.buffer.slice(i.byteOffset,i.byteOffset+i.length);this.decryptBuffer(a).then(l=>{const c=new Uint8Array(l);r.set(c,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,s)}).catch(s)}decryptAacSamples(e,t,s){for(;;t++){if(t>=e.length){s();return}if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,s),!this.decrypter.isSync()))return}}getAvcEncryptedData(e){const t=Math.floor((e.length-48)/160)*16+16,s=new Int8Array(t);let r=0;for(let i=32;i<e.length-16;i+=160,r+=16)s.set(e.subarray(i,i+16),r);return s}getAvcDecryptedUnit(e,t){const s=new Uint8Array(t);let r=0;for(let i=32;i<e.length-16;i+=160,r+=16)e.set(s.subarray(r,r+16),i);return e}decryptAvcSample(e,t,s,r,i){const a=yN(i.data),l=this.getAvcEncryptedData(a);this.decryptBuffer(l.buffer).then(c=>{i.data=this.getAvcDecryptedUnit(a,c),this.decrypter.isSync()||this.decryptAvcSamples(e,t,s+1,r)}).catch(r)}decryptAvcSamples(e,t,s,r){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,s=0){if(t>=e.length){r();return}const i=e[t].units;for(;!(s>=i.length);s++){const a=i[s];if(!(a.data.length<=48||a.type!==1&&a.type!==5)&&(this.decryptAvcSample(e,t,s,r,a),!this.decrypter.isSync()))return}}}}class oL{constructor(){this.VideoSample=null}createVideoSample(e,t,s){return{key:e,frame:!1,pts:t,dts:s,units:[],length:0}}getLastNalUnit(e){var t;let s=this.VideoSample,r;if((!s||s.units.length===0)&&(s=e[e.length-1]),(t=s)!=null&&t.units){const i=s.units;r=i[i.length-1]}return r}pushAccessUnit(e,t){if(e.units.length&&e.frame){if(e.pts===void 0){const s=t.samples,r=s.length;if(r){const i=s[r-1];e.pts=i.pts,e.dts=i.dts}else{t.dropped++;return}}t.samples.push(e)}}parseNALu(e,t,s){const r=t.byteLength;let i=e.naluState||0;const a=i,l=[];let c=0,d,h,p,m=-1,y=0;for(i===-1&&(m=0,y=this.getNALuType(t,0),i=0,c=1);c<r;){if(d=t[c++],!i){i=d?0:1;continue}if(i===1){i=d?0:2;continue}if(!d)i=3;else if(d===1){if(h=c-i-1,m>=0){const x={data:t.subarray(m,h),type:y};l.push(x)}else{const x=this.getLastNalUnit(e.samples);x&&(a&&c<=4-a&&x.state&&(x.data=x.data.subarray(0,x.data.byteLength-a)),h>0&&(x.data=ka(x.data,t.subarray(0,h)),x.state=0))}c<r?(p=this.getNALuType(t,c),m=c,y=p,i=0):i=-1}else i=0}if(m>=0&&i>=0){const x={data:t.subarray(m,r),type:y,state:i};l.push(x)}if(l.length===0){const x=this.getLastNalUnit(e.samples);x&&(x.data=ka(x.data,t))}return e.naluState=i,l}}class Up{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,s=e.byteLength-t,r=new Uint8Array(4),i=Math.min(4,t);if(i===0)throw new Error("no bytes available");r.set(e.subarray(s,s+i)),this.word=new DataView(r.buffer).getUint32(0),this.bitsAvailable=i*8,this.bytesAvailable-=i}skipBits(e){let t;e=Math.min(e,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,t=e>>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 s=this.word>>>32-t;if(e>32&&An.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return t=e-t,t>0&&this.bitsAvailable?s<<t|this.readBits(t):s}skipLZ(){let e;for(e=0;e<this.bitsAvailable;++e)if((this.word&2147483648>>>e)!==0)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 this.readBits(1)===1}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}}class ese extends oL{parsePES(e,t,s,r){const i=this.parseNALu(e,s.data,r);let a=this.VideoSample,l,c=!1;s.data=null,a&&i.length&&!e.audFound&&(this.pushAccessUnit(a,e),a=this.VideoSample=this.createVideoSample(!1,s.pts,s.dts)),i.forEach(d=>{var h,p;switch(d.type){case 1:{let w=!1;l=!0;const S=d.data;if(c&&S.length>4){const _=this.readSliceType(S);(_===2||_===4||_===7||_===9)&&(w=!0)}if(w){var m;(m=a)!=null&&m.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null)}a||(a=this.VideoSample=this.createVideoSample(!0,s.pts,s.dts)),a.frame=!0,a.key=w;break}case 5:l=!0,(h=a)!=null&&h.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null),a||(a=this.VideoSample=this.createVideoSample(!0,s.pts,s.dts)),a.key=!0,a.frame=!0;break;case 6:{l=!0,tS(d.data,1,s.pts,t.samples);break}case 7:{var y,x;l=!0,c=!0;const w=d.data,S=this.readSPS(w);if(!e.sps||e.width!==S.width||e.height!==S.height||((y=e.pixelRatio)==null?void 0:y[0])!==S.pixelRatio[0]||((x=e.pixelRatio)==null?void 0:x[1])!==S.pixelRatio[1]){e.width=S.width,e.height=S.height,e.pixelRatio=S.pixelRatio,e.sps=[w];const _=w.subarray(1,4);let L="avc1.";for(let R=0;R<3;R++){let M=_[R].toString(16);M.length<2&&(M="0"+M),L+=M}e.codec=L}break}case 8:l=!0,e.pps=[d.data];break;case 9:l=!0,e.audFound=!0,(p=a)!=null&&p.frame&&(this.pushAccessUnit(a,e),a=null),a||(a=this.VideoSample=this.createVideoSample(!1,s.pts,s.dts));break;case 12:l=!0;break;default:l=!1;break}a&&l&&a.units.push(d)}),r&&a&&(this.pushAccessUnit(a,e),this.VideoSample=null)}getNALuType(e,t){return e[t]&31}readSliceType(e){const t=new Up(e);return t.readUByte(),t.readUEG(),t.readUEG()}skipScalingList(e,t){let s=8,r=8,i;for(let a=0;a<e;a++)r!==0&&(i=t.readEG(),r=(s+i+256)%256),s=r===0?s:r}readSPS(e){const t=new Up(e);let s=0,r=0,i=0,a=0,l,c,d;const h=t.readUByte.bind(t),p=t.readBits.bind(t),m=t.readUEG.bind(t),y=t.readBoolean.bind(t),x=t.skipBits.bind(t),w=t.skipEG.bind(t),S=t.skipUEG.bind(t),_=this.skipScalingList.bind(this);h();const L=h();if(p(5),x(3),h(),S(),L===100||L===110||L===122||L===244||L===44||L===83||L===86||L===118||L===128){const k=m();if(k===3&&x(1),S(),S(),x(1),y())for(c=k!==3?8:12,d=0;d<c;d++)y()&&(d<6?_(16,t):_(64,t))}S();const R=m();if(R===0)m();else if(R===1)for(x(1),w(),w(),l=m(),d=0;d<l;d++)w();S(),x(1);const M=m(),V=m(),W=p(1);W===0&&x(1),x(1),y()&&(s=m(),r=m(),i=m(),a=m());let I=[1,1];if(y()&&y())switch(h()){case 1:I=[1,1];break;case 2:I=[12,11];break;case 3:I=[10,11];break;case 4:I=[16,11];break;case 5:I=[40,33];break;case 6:I=[24,11];break;case 7:I=[20,11];break;case 8:I=[32,11];break;case 9:I=[80,33];break;case 10:I=[18,11];break;case 11:I=[15,11];break;case 12:I=[64,33];break;case 13:I=[160,99];break;case 14:I=[4,3];break;case 15:I=[3,2];break;case 16:I=[2,1];break;case 255:{I=[h()<<8|h(),h()<<8|h()];break}}return{width:Math.ceil((M+1)*16-s*2-r*2),height:(2-W)*(V+1)*16-(W?2:4)*(i+a),pixelRatio:I}}}class tse extends oL{constructor(...e){super(...e),this.initVPS=null}parsePES(e,t,s,r){const i=this.parseNALu(e,s.data,r);let a=this.VideoSample,l,c=!1;s.data=null,a&&i.length&&!e.audFound&&(this.pushAccessUnit(a,e),a=this.VideoSample=this.createVideoSample(!1,s.pts,s.dts)),i.forEach(d=>{var h,p;switch(d.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,s.pts,s.dts)),a.frame=!0,l=!0;break;case 16:case 17:case 18:case 21:if(l=!0,c){var m;(m=a)!=null&&m.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null)}a||(a=this.VideoSample=this.createVideoSample(!0,s.pts,s.dts)),a.key=!0,a.frame=!0;break;case 19:case 20:l=!0,(h=a)!=null&&h.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null),a||(a=this.VideoSample=this.createVideoSample(!0,s.pts,s.dts)),a.key=!0,a.frame=!0;break;case 39:l=!0,tS(d.data,2,s.pts,t.samples);break;case 32:l=!0,e.vps||(typeof e.params!="object"&&(e.params={}),e.params=kn(e.params,this.readVPS(d.data)),this.initVPS=d.data),e.vps=[d.data];break;case 33:if(l=!0,c=!0,e.vps!==void 0&&e.vps[0]!==this.initVPS&&e.sps!==void 0&&!this.matchSPS(e.sps[0],d.data)&&(this.initVPS=e.vps[0],e.sps=e.pps=void 0),!e.sps){const y=this.readSPS(d.data);e.width=y.width,e.height=y.height,e.pixelRatio=y.pixelRatio,e.codec=y.codecString,e.sps=[],typeof e.params!="object"&&(e.params={});for(const x in y.params)e.params[x]=y.params[x]}this.pushParameterSet(e.sps,d.data,e.vps),a||(a=this.VideoSample=this.createVideoSample(!0,s.pts,s.dts)),a.key=!0;break;case 34:if(l=!0,typeof e.params=="object"){if(!e.pps){e.pps=[];const y=this.readPPS(d.data);for(const x in y)e.params[x]=y[x]}this.pushParameterSet(e.pps,d.data,e.vps)}break;case 35:l=!0,e.audFound=!0,(p=a)!=null&&p.frame&&(this.pushAccessUnit(a,e),a=null),a||(a=this.VideoSample=this.createVideoSample(!1,s.pts,s.dts));break;default:l=!1;break}a&&l&&a.units.push(d)}),r&&a&&(this.pushAccessUnit(a,e),this.VideoSample=null)}pushParameterSet(e,t,s){(s&&s[0]===this.initVPS||!s&&!e.length)&&e.push(t)}getNALuType(e,t){return(e[t]&126)>>>1}ebsp2rbsp(e){const t=new Uint8Array(e.byteLength);let s=0;for(let r=0;r<e.byteLength;r++)r>=2&&e[r]===3&&e[r-1]===0&&e[r-2]===0||(t[s]=e[r],s++);return new Uint8Array(t.buffer,0,s)}pushAccessUnit(e,t){super.pushAccessUnit(e,t),this.initVPS&&(this.initVPS=null)}readVPS(e){const t=new Up(e);t.readUByte(),t.readUByte(),t.readBits(4),t.skipBits(2),t.readBits(6);const s=t.readBits(3),r=t.readBoolean();return{numTemporalLayers:s+1,temporalIdNested:r}}readSPS(e){const t=new Up(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.readBits(4);const s=t.readBits(3);t.readBoolean();const r=t.readBits(2),i=t.readBoolean(),a=t.readBits(5),l=t.readUByte(),c=t.readUByte(),d=t.readUByte(),h=t.readUByte(),p=t.readUByte(),m=t.readUByte(),y=t.readUByte(),x=t.readUByte(),w=t.readUByte(),S=t.readUByte(),_=t.readUByte(),L=[],R=[];for(let at=0;at<s;at++)L.push(t.readBoolean()),R.push(t.readBoolean());if(s>0)for(let at=s;at<8;at++)t.readBits(2);for(let at=0;at<s;at++)L[at]&&(t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte()),R[at]&&t.readUByte();t.readUEG();const M=t.readUEG();M==3&&t.skipBits(1);const V=t.readUEG(),W=t.readUEG(),I=t.readBoolean();let k=0,P=0,N=0,F=0;I&&(k+=t.readUEG(),P+=t.readUEG(),N+=t.readUEG(),F+=t.readUEG());const z=t.readUEG(),U=t.readUEG(),fe=t.readUEG(),oe=t.readBoolean();for(let at=oe?0:s;at<=s;at++)t.skipUEG(),t.skipUEG(),t.skipUEG();if(t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.readBoolean()&&t.readBoolean())for(let ft=0;ft<4;ft++)for(let Nt=0;Nt<(ft===3?2:6);Nt++)if(!t.readBoolean())t.readUEG();else{const ot=Math.min(64,1<<4+(ft<<1));ft>1&&t.readEG();for(let Yt=0;Yt<ot;Yt++)t.readEG()}t.readBoolean(),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.skipUEG(),t.skipUEG(),t.readBoolean());const G=t.readUEG();let Y=0;for(let at=0;at<G;at++){let ft=!1;if(at!==0&&(ft=t.readBoolean()),ft){at===G&&t.readUEG(),t.readBoolean(),t.readUEG();let Nt=0;for(let At=0;At<=Y;At++){const ot=t.readBoolean();let Yt=!1;ot||(Yt=t.readBoolean()),(ot||Yt)&&Nt++}Y=Nt}else{const Nt=t.readUEG(),At=t.readUEG();Y=Nt+At;for(let ot=0;ot<Nt;ot++)t.readUEG(),t.readBoolean();for(let ot=0;ot<At;ot++)t.readUEG(),t.readBoolean()}}if(t.readBoolean()){const at=t.readUEG();for(let ft=0;ft<at;ft++){for(let Nt=0;Nt<fe+4;Nt++)t.readBits(1);t.readBits(1)}}let H=0,K=1,pe=1,Fe=!0,_e=1,ze=0;t.readBoolean(),t.readBoolean();let Ye=!1;if(t.readBoolean()){if(t.readBoolean()){const zt=t.readUByte(),wn=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2],Dt=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1];zt>0&&zt<16?(K=wn[zt-1],pe=Dt[zt-1]):zt===255&&(K=t.readBits(16),pe=t.readBits(16))}if(t.readBoolean()&&t.readBoolean(),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(),Ye=t.readBoolean(),Ye&&(t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG()),t.readBoolean()&&(_e=t.readBits(32),ze=t.readBits(32),t.readBoolean()&&t.readUEG(),t.readBoolean())){const Dt=t.readBoolean(),Ee=t.readBoolean();let He=!1;(Dt||Ee)&&(He=t.readBoolean(),He&&(t.readUByte(),t.readBits(5),t.readBoolean(),t.readBits(5)),t.readBits(4),t.readBits(4),He&&t.readBits(4),t.readBits(5),t.readBits(5),t.readBits(5));for(let le=0;le<=s;le++){Fe=t.readBoolean();const ne=Fe||t.readBoolean();let J=!1;ne?t.readEG():J=t.readBoolean();const De=J?1:t.readUEG()+1;if(Dt)for(let Le=0;Le<De;Le++)t.readUEG(),t.readUEG(),He&&(t.readUEG(),t.readUEG()),t.skipBits(1);if(Ee)for(let Le=0;Le<De;Le++)t.readUEG(),t.readUEG(),He&&(t.readUEG(),t.readUEG()),t.skipBits(1)}}t.readBoolean()&&(t.readBoolean(),t.readBoolean(),t.readBoolean(),H=t.readUEG())}let lt=V,ut=W;if(I){let at=1,ft=1;M===1?at=ft=2:M==2&&(at=2),lt=V-at*P-at*k,ut=W-ft*F-ft*N}const cn=r?["A","B","C"][r]:"",ke=l<<24|c<<16|d<<8|h;let Ue=0;for(let at=0;at<32;at++)Ue=(Ue|(ke>>at&1)<<31-at)>>>0;let rt=Ue.toString(16);return a===1&&rt==="2"&&(rt="6"),{codecString:`hvc1.${cn}${a}.${rt}.${i?"H":"L"}${_}.B0`,params:{general_tier_flag:i,general_profile_idc:a,general_profile_space:r,general_profile_compatibility_flags:[l,c,d,h],general_constraint_indicator_flags:[p,m,y,x,w,S],general_level_idc:_,bit_depth:z+8,bit_depth_luma_minus8:z,bit_depth_chroma_minus8:U,min_spatial_segmentation_idc:H,chroma_format_idc:M,frame_rate:{fixed:Fe,fps:ze/_e}},width:lt,height:ut,pixelRatio:[K,pe]}}readPPS(e){const t=new Up(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 a=1;return i&&r?a=0:i?a=3:r&&(a=2),{parallelismType:a}}matchSPS(e,t){return String.fromCharCode.apply(null,e).substr(3)===String.fromCharCode.apply(null,t).substr(3)}}const or=188;class Nc{constructor(e,t,s,r){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=s,this.logger=r,this.videoParser=null}static probe(e,t){const s=Nc.syncOffset(e);return s>0&&t.warn(`MPEG2-TS detected but first sync word found @ offset ${s}`),s!==-1}static syncOffset(e){const t=e.length;let s=Math.min(or*5,t-or)+1,r=0;for(;r<s;){let i=!1,a=-1,l=0;for(let c=r;c<t;c+=or)if(e[c]===71&&(t-c===or||e[c+or]===71)){if(l++,a===-1&&(a=c,a!==0&&(s=Math.min(a+or*99,e.length-or)+1)),i||(i=cw(e,c)===0),i&&l>1&&(a===0&&l>2||c+or>s))return a}else{if(l)return-1;break}r++}return-1}static createTrack(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:hN[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}}resetInitSegment(e,t,s,r){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=Nc.createTrack("video"),this._videoTrack.duration=r,this._audioTrack=Nc.createTrack("audio",r),this._id3Track=Nc.createTrack("id3"),this._txtTrack=Nc.createTrack("text"),this._audioTrack.segmentCodec="aac",this.videoParser=null,this.aacOverFlow=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=s}resetTimeStamp(){}resetContiguity(){const{_audioTrack:e,_videoTrack:t,_id3Track:s}=this;e&&(e.pesData=null),t&&(t.pesData=null),s&&(s.pesData=null),this.aacOverFlow=null,this.remainderData=null}demux(e,t,s=!1,r=!1){s||(this.sampleAes=null);let i;const a=this._videoTrack,l=this._audioTrack,c=this._id3Track,d=this._txtTrack;let h=a.pid,p=a.pesData,m=l.pid,y=c.pid,x=l.pesData,w=c.pesData,S=null,_=this.pmtParsed,L=this._pmtId,R=e.length;if(this.remainderData&&(e=ka(this.remainderData,e),R=e.length,this.remainderData=null),R<or&&!r)return this.remainderData=e,{audioTrack:l,videoTrack:a,id3Track:c,textTrack:d};const M=Math.max(0,Nc.syncOffset(e));R-=(R-M)%or,R<e.byteLength&&!r&&(this.remainderData=new Uint8Array(e.buffer,R,e.buffer.byteLength-R));let V=0;for(let I=M;I<R;I+=or)if(e[I]===71){const k=!!(e[I+1]&64),P=cw(e,I),N=(e[I+3]&48)>>4;let F;if(N>1){if(F=I+5+e[I+4],F===I+or)continue}else F=I+4;switch(P){case h:k&&(p&&(i=fh(p,this.logger))&&(this.readyVideoParser(a.segmentCodec),this.videoParser!==null&&this.videoParser.parsePES(a,d,i,!1)),p={data:[],size:0}),p&&(p.data.push(e.subarray(F,I+or)),p.size+=I+or-F);break;case m:if(k){if(x&&(i=fh(x,this.logger)))switch(l.segmentCodec){case"aac":this.parseAACPES(l,i);break;case"mp3":this.parseMPEGPES(l,i);break;case"ac3":this.parseAC3PES(l,i);break}x={data:[],size:0}}x&&(x.data.push(e.subarray(F,I+or)),x.size+=I+or-F);break;case y:k&&(w&&(i=fh(w,this.logger))&&this.parseID3PES(c,i),w={data:[],size:0}),w&&(w.data.push(e.subarray(F,I+or)),w.size+=I+or-F);break;case 0:k&&(F+=e[F]+1),L=this._pmtId=nse(e,F);break;case L:{k&&(F+=e[F]+1);const z=sse(e,F,this.typeSupported,s,this.observer,this.logger);h=z.videoPid,h>0&&(a.pid=h,a.segmentCodec=z.segmentVideoCodec),m=z.audioPid,m>0&&(l.pid=m,l.segmentCodec=z.segmentAudioCodec),y=z.id3Pid,y>0&&(c.pid=y),S!==null&&!_&&(this.logger.warn(`MPEG-TS PMT found at ${I} after unknown PID '${S}'. Backtracking to sync byte @${M} to parse all TS packets.`),S=null,I=M-188),_=this.pmtParsed=!0;break}case 17:case 8191:break;default:S=P;break}}else V++;V>0&&uw(this.observer,new Error(`Found ${V} TS packet/s that do not start with 0x47`),void 0,this.logger),a.pesData=p,l.pesData=x,c.pesData=w;const W={audioTrack:l,videoTrack:a,id3Track:c,textTrack:d};return r&&this.extractRemainingSamples(W),W}flush(){const{remainderData:e}=this;this.remainderData=null;let t;return e?t=this.demux(e,-1,!1,!0):t={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:s,id3Track:r,textTrack:i}=e,a=s.pesData,l=t.pesData,c=r.pesData;let d;if(a&&(d=fh(a,this.logger))?(this.readyVideoParser(s.segmentCodec),this.videoParser!==null&&(this.videoParser.parsePES(s,i,d,!0),s.pesData=null)):s.pesData=a,l&&(d=fh(l,this.logger))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,d);break;case"mp3":this.parseMPEGPES(t,d);break;case"ac3":this.parseAC3PES(t,d);break}t.pesData=null}else l!=null&&l.size&&this.logger.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=l;c&&(d=fh(c,this.logger))?(this.parseID3PES(r,d),r.pesData=null):r.pesData=c}demuxSampleAes(e,t,s){const r=this.demux(e,s,!0,!this.config.progressive),i=this.sampleAes=new Zne(this.observer,this.config,t);return this.decrypt(r,i)}readyVideoParser(e){this.videoParser===null&&(e==="avc"?this.videoParser=new ese:e==="hevc"&&(this.videoParser=new tse))}decrypt(e,t){return new Promise(s=>{const{audioTrack:r,videoTrack:i}=e;r.samples&&r.segmentCodec==="aac"?t.decryptAacSamples(r.samples,0,()=>{i.samples?t.decryptAvcSamples(i.samples,0,0,()=>{s(e)}):s(e)}):i.samples&&t.decryptAvcSamples(i.samples,0,0,()=>{s(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 s=0;const r=this.aacOverFlow;let i=t.data;if(r){this.aacOverFlow=null;const p=r.missing,m=r.sample.unit.byteLength;if(p===-1)i=ka(r.sample.unit,i);else{const y=m-p;r.sample.unit.set(i.subarray(0,p),y),e.samples.push(r.sample),s=r.missing}}let a,l;for(a=s,l=i.length;a<l-1&&!z1(i,a);a++);if(a!==s){let p;const m=a<l-1;if(m?p=`AAC PES did not start with ADTS header,offset:${a}`:p="No ADTS header found in AAC PES",uw(this.observer,new Error(p),m,this.logger),!m)return}QN(e,this.observer,i,a,this.audioCodec);let c;if(t.pts!==void 0)c=t.pts;else if(r){const p=XN(e.samplerate);c=r.sample.pts+p}else{this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}let d=0,h;for(;a<l;)if(h=JN(e,i,a,c,d),a+=h.length,h.missing){this.aacOverFlow=h;break}else for(d++;a<l-1&&!z1(i,a);a++);}parseMPEGPES(e,t){const s=t.data,r=s.length;let i=0,a=0;const l=t.pts;if(l===void 0){this.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<r;)if(sL(s,a)){const c=tL(e,s,a,l,i);if(c)a+=c.length,i++;else break}else a++}parseAC3PES(e,t){{const s=t.data,r=t.pts;if(r===void 0){this.logger.warn("[tsdemuxer]: AC3 PES unknown PTS");return}const i=s.length;let a=0,l=0,c;for(;l<i&&(c=aL(e,s,l,r,a++))>0;)l+=c}}parseID3PES(e,t){if(t.pts===void 0){this.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}const s=kn({},t,{type:this._videoTrack?wi.emsg:wi.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(s)}}function cw(n,e){return((n[e+1]&31)<<8)+n[e+2]}function nse(n,e){return(n[e+10]&31)<<8|n[e+11]}function sse(n,e,t,s,r,i){const a={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},l=(n[e+1]&15)<<8|n[e+2],c=e+3+l-4,d=(n[e+10]&15)<<8|n[e+11];for(e+=12+d;e<c;){const h=cw(n,e),p=(n[e+3]&15)<<8|n[e+4];switch(n[e]){case 207:if(!s){Cv("ADTS AAC",i);break}case 15:a.audioPid===-1&&(a.audioPid=h);break;case 21:a.id3Pid===-1&&(a.id3Pid=h);break;case 219:if(!s){Cv("H.264",i);break}case 27:a.videoPid===-1&&(a.videoPid=h);break;case 3:case 4:!t.mpeg&&!t.mp3?i.log("MPEG audio found, not supported in this browser"):a.audioPid===-1&&(a.audioPid=h,a.segmentAudioCodec="mp3");break;case 193:if(!s){Cv("AC-3",i);break}case 129:t.ac3?a.audioPid===-1&&(a.audioPid=h,a.segmentAudioCodec="ac3"):i.log("AC-3 audio found, not supported in this browser");break;case 6:if(a.audioPid===-1&&p>0){let m=e+5,y=p;for(;y>2;){n[m]===106&&(t.ac3!==!0?i.log("AC-3 audio found, not supported in this browser for now"):(a.audioPid=h,a.segmentAudioCodec="ac3"));const w=n[m+1]+2;m+=w,y-=w}}break;case 194:case 135:return uw(r,new Error("Unsupported EC-3 in M2TS found"),void 0,i),a;case 36:a.videoPid===-1&&(a.videoPid=h,a.segmentVideoCodec="hevc",i.log("HEVC in M2TS found"));break}e+=p+5}return a}function uw(n,e,t,s){s.warn(`parsing error: ${e.message}`),n.emit(j.ERROR,j.ERROR,{type:xt.MEDIA_ERROR,details:he.FRAG_PARSING_ERROR,fatal:!1,levelRetry:t,error:e,reason:e.message})}function Cv(n,e){e.log(`${n} with AES-128-CBC encryption found in unencrypted stream`)}function fh(n,e){let t=0,s,r,i,a,l;const c=n.data;if(!n||n.size===0)return null;for(;c[0].length<19&&c.length>1;)c[0]=ka(c[0],c[1]),c.splice(1,1);if(s=c[0],(s[0]<<16)+(s[1]<<8)+s[2]===1){if(r=(s[4]<<8)+s[5],r&&r>n.size-6)return null;const h=s[7];h&192&&(a=(s[9]&14)*536870912+(s[10]&255)*4194304+(s[11]&254)*16384+(s[12]&255)*128+(s[13]&254)/2,h&64?(l=(s[14]&14)*536870912+(s[15]&255)*4194304+(s[16]&254)*16384+(s[17]&255)*128+(s[18]&254)/2,a-l>60*9e4&&(e.warn(`${Math.round((a-l)/9e4)}s delta between PTS and DTS, align them`),a=l)):l=a),i=s[8];let p=i+9;if(n.size<=p)return null;n.size-=p;const m=new Uint8Array(n.size);for(let y=0,x=c.length;y<x;y++){s=c[y];let w=s.byteLength;if(p)if(p>w){p-=w;continue}else s=s.subarray(p),w-=p,p=0;m.set(s,t),t+=w}return r&&(r-=i+3),{data:m,pts:a,dts:l,len:r}}return null}class rse{static getSilentFrame(e,t){switch(e){case"mp4a.40.2":if(t===1)return new Uint8Array([0,200,0,128,35,128]);if(t===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(t===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(t===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(t===5)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(t===6)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]);break;default:if(t===1)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(t===2)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(t===3)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]);break}}}const Cc=Math.pow(2,32)-1;class de{static init(){de.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:[]};let e;for(e in de.types)de.types.hasOwnProperty(e)&&(de.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]),s=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]);de.HDLR_TYPES={video:t,audio:s};const r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),i=new Uint8Array([0,0,0,0,0,0,0,0]);de.STTS=de.STSC=de.STCO=i,de.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),de.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),de.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),de.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const a=new Uint8Array([105,115,111,109]),l=new Uint8Array([97,118,99,49]),c=new Uint8Array([0,0,0,1]);de.FTYP=de.box(de.types.ftyp,a,c,a,l),de.DINF=de.box(de.types.dinf,de.box(de.types.dref,r))}static box(e,...t){let s=8,r=t.length;const i=r;for(;r--;)s+=t[r].byteLength;const a=new Uint8Array(s);for(a[0]=s>>24&255,a[1]=s>>16&255,a[2]=s>>8&255,a[3]=s&255,a.set(e,4),r=0,s=8;r<i;r++)a.set(t[r],s),s+=t[r].byteLength;return a}static hdlr(e){return de.box(de.types.hdlr,de.HDLR_TYPES[e])}static mdat(e){return de.box(de.types.mdat,e)}static mdhd(e,t){t*=e;const s=Math.floor(t/(Cc+1)),r=Math.floor(t%(Cc+1));return de.box(de.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,e&255,s>>24,s>>16&255,s>>8&255,s&255,r>>24,r>>16&255,r>>8&255,r&255,85,196,0,0]))}static mdia(e){return de.box(de.types.mdia,de.mdhd(e.timescale||0,e.duration||0),de.hdlr(e.type),de.minf(e))}static mfhd(e){return de.box(de.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255]))}static minf(e){return e.type==="audio"?de.box(de.types.minf,de.box(de.types.smhd,de.SMHD),de.DINF,de.stbl(e)):de.box(de.types.minf,de.box(de.types.vmhd,de.VMHD),de.DINF,de.stbl(e))}static moof(e,t,s){return de.box(de.types.moof,de.mfhd(e),de.traf(s,t))}static moov(e){let t=e.length;const s=[];for(;t--;)s[t]=de.trak(e[t]);return de.box.apply(null,[de.types.moov,de.mvhd(e[0].timescale||0,e[0].duration||0)].concat(s).concat(de.mvex(e)))}static mvex(e){let t=e.length;const s=[];for(;t--;)s[t]=de.trex(e[t]);return de.box.apply(null,[de.types.mvex,...s])}static mvhd(e,t){t*=e;const s=Math.floor(t/(Cc+1)),r=Math.floor(t%(Cc+1)),i=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,e&255,s>>24,s>>16&255,s>>8&255,s&255,r>>24,r>>16&255,r>>8&255,r&255,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 de.box(de.types.mvhd,i)}static sdtp(e){const t=e.samples||[],s=new Uint8Array(4+t.length);let r,i;for(r=0;r<t.length;r++)i=t[r].flags,s[r+4]=i.dependsOn<<4|i.isDependedOn<<2|i.hasRedundancy;return de.box(de.types.sdtp,s)}static stbl(e){return de.box(de.types.stbl,de.stsd(e),de.box(de.types.stts,de.STTS),de.box(de.types.stsc,de.STSC),de.box(de.types.stsz,de.STSZ),de.box(de.types.stco,de.STCO))}static avc1(e){let t=[],s=[],r,i,a;for(r=0;r<e.sps.length;r++)i=e.sps[r],a=i.byteLength,t.push(a>>>8&255),t.push(a&255),t=t.concat(Array.prototype.slice.call(i));for(r=0;r<e.pps.length;r++)i=e.pps[r],a=i.byteLength,s.push(a>>>8&255),s.push(a&255),s=s.concat(Array.prototype.slice.call(i));const l=de.box(de.types.avcC,new Uint8Array([1,t[3],t[4],t[5],255,224|e.sps.length].concat(t).concat([e.pps.length]).concat(s))),c=e.width,d=e.height,h=e.pixelRatio[0],p=e.pixelRatio[1];return de.box(de.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,c>>8&255,c&255,d>>8&255,d&255,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]),l,de.box(de.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),de.box(de.types.pasp,new Uint8Array([h>>24,h>>16&255,h>>8&255,h&255,p>>24,p>>16&255,p>>8&255,p&255])))}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,t&255,0,0])}static mp4a(e){return de.box(de.types.mp4a,de.audioStsd(e),de.box(de.types.esds,de.esds(e)))}static mp3(e){return de.box(de.types[".mp3"],de.audioStsd(e))}static ac3(e){return de.box(de.types["ac-3"],de.audioStsd(e),de.box(de.types.dac3,e.config))}static stsd(e){const{segmentCodec:t}=e;if(e.type==="audio"){if(t==="aac")return de.box(de.types.stsd,de.STSD,de.mp4a(e));if(t==="ac3"&&e.config)return de.box(de.types.stsd,de.STSD,de.ac3(e));if(t==="mp3"&&e.codec==="mp3")return de.box(de.types.stsd,de.STSD,de.mp3(e))}else if(e.pps&&e.sps){if(t==="avc")return de.box(de.types.stsd,de.STSD,de.avc1(e));if(t==="hevc"&&e.vps)return de.box(de.types.stsd,de.STSD,de.hvc1(e))}else throw new Error("video track missing pps or sps");throw new Error(`unsupported ${e.type} segment codec (${t}/${e.codec})`)}static tkhd(e){const t=e.id,s=(e.duration||0)*(e.timescale||0),r=e.width||0,i=e.height||0,a=Math.floor(s/(Cc+1)),l=Math.floor(s%(Cc+1));return de.box(de.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,t&255,0,0,0,0,a>>24,a>>16&255,a>>8&255,a&255,l>>24,l>>16&255,l>>8&255,l&255,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,r>>8&255,r&255,0,0,i>>8&255,i&255,0,0]))}static traf(e,t){const s=de.sdtp(e),r=e.id,i=Math.floor(t/(Cc+1)),a=Math.floor(t%(Cc+1));return de.box(de.types.traf,de.box(de.types.tfhd,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,r&255])),de.box(de.types.tfdt,new Uint8Array([1,0,0,0,i>>24,i>>16&255,i>>8&255,i&255,a>>24,a>>16&255,a>>8&255,a&255])),de.trun(e,s.length+16+20+8+16+8+8),s)}static trak(e){return e.duration=e.duration||4294967295,de.box(de.types.trak,de.tkhd(e),de.mdia(e))}static trex(e){const t=e.id;return de.box(de.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,t){const s=e.samples||[],r=s.length,i=12+16*r,a=new Uint8Array(i);let l,c,d,h,p,m;for(t+=8+i,a.set([e.type==="video"?1:0,0,15,1,r>>>24&255,r>>>16&255,r>>>8&255,r&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255],0),l=0;l<r;l++)c=s[l],d=c.duration,h=c.size,p=c.flags,m=c.cts,a.set([d>>>24&255,d>>>16&255,d>>>8&255,d&255,h>>>24&255,h>>>16&255,h>>>8&255,h&255,p.isLeading<<2|p.dependsOn,p.isDependedOn<<6|p.hasRedundancy<<4|p.paddingValue<<1|p.isNonSync,p.degradPrio&61440,p.degradPrio&15,m>>>24&255,m>>>16&255,m>>>8&255,m&255],12+16*l);return de.box(de.types.trun,a)}static initSegment(e){de.types||de.init();const t=de.moov(e);return ka(de.FTYP,t)}static hvc1(e){const t=e.params,s=[e.vps,e.sps,e.pps],r=4,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),r-1|t.temporal_id_nested<<2|t.num_temporal_layers<<3|(t.frame_rate.fixed?64:0),s.length]);let a=i.length;for(let x=0;x<s.length;x+=1){a+=3;for(let w=0;w<s[x].length;w+=1)a+=2+s[x][w].length}const l=new Uint8Array(a);l.set(i,0),a=i.length;const c=s.length-1;for(let x=0;x<s.length;x+=1){l.set(new Uint8Array([32+x|(x===c?128:0),0,s[x].length]),a),a+=3;for(let w=0;w<s[x].length;w+=1)l.set(new Uint8Array([s[x][w].length>>8,s[x][w].length&255]),a),a+=2,l.set(s[x][w],a),a+=s[x][w].length}const d=de.box(de.types.hvcC,l),h=e.width,p=e.height,m=e.pixelRatio[0],y=e.pixelRatio[1];return de.box(de.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,h>>8&255,h&255,p>>8&255,p&255,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]),d,de.box(de.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),de.box(de.types.pasp,new Uint8Array([m>>24,m>>16&255,m>>8&255,m&255,y>>24,y>>16&255,y>>8&255,y&255])))}}de.types=void 0;de.HDLR_TYPES=void 0;de.STTS=void 0;de.STSC=void 0;de.STCO=void 0;de.STSZ=void 0;de.VMHD=void 0;de.SMHD=void 0;de.STSD=void 0;de.FTYP=void 0;de.DINF=void 0;const lL=9e4;function gS(n,e,t=1,s=!1){const r=n*e*t;return s?Math.round(r):r}function ise(n,e,t=1,s=!1){return gS(n,e,1/t,s)}function dp(n,e=!1){return gS(n,1e3,1/lL,e)}function ase(n,e=1){return gS(n,lL,1/e)}function oI(n){const{baseTime:e,timescale:t,trackId:s}=n;return`${e/t} (${e}/${t}) trackId: ${s}`}const ose=10*1e3,lse=1024,cse=1152,use=1536;let ph=null,kv=null;function lI(n,e,t,s){return{duration:e,size:t,cts:s,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:n?2:1,isNonSync:n?0:1}}}class O0 extends Pa{constructor(e,t,s,r){if(super("mp4-remuxer",r),this.observer=void 0,this.config=void 0,this.typeSupp
111orted=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=s,this.ISGenerated=!1,ph===null){const a=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);ph=a?parseInt(a[1]):0}if(kv===null){const i=navigator.userAgent.match(/Safari\/(\d+)/i);kv=i?parseInt(i[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&&oI(t)} > ${e&&oI(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 s=e[0].pts,r=e.reduce((i,a)=>{let l=a.pts,c=l-i;return c<-4294967296&&(t=!0,l=Qi(l,s),c=l-i),c>0?i:l},s);return t&&this.debug("PTS rollover detected"),r}remux(e,t,s,r,i,a,l,c){let d,h,p,m,y,x,w=i,S=i;const _=e.pid>-1,L=t.pid>-1,R=t.samples.length,M=e.samples.length>0,V=l&&R>0||R>1;if((!_||M)&&(!L||V)||this.ISGenerated||l){if(this.ISGenerated){var I,k,P,N;const fe=this.videoTrackConfig;(fe&&(t.width!==fe.width||t.height!==fe.height||((I=t.pixelRatio)==null?void 0:I[0])!==((k=fe.pixelRatio)==null?void 0:k[0])||((P=t.pixelRatio)==null?void 0:P[1])!==((N=fe.pixelRatio)==null?void 0:N[1]))||!fe&&V||this.nextAudioTs===null&&M)&&this.resetInitSegment()}this.ISGenerated||(p=this.generateIS(e,t,i,a));const F=this.isVideoContiguous;let z=-1,U;if(V&&(z=dse(t.samples),!F&&this.config.forceKeyFrameOnDiscontinuity))if(x=!0,z>0){this.warn(`Dropped ${z} out of ${R} video samples due to a missing keyframe`);const fe=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(z),t.dropped+=z,S+=(t.samples[0].pts-fe)/t.inputTimeScale,U=S}else z===-1&&(this.warn(`No keyframe found out of ${R} video samples`),x=!1);if(this.ISGenerated){if(M&&V){const fe=this.getVideoStartPts(t.samples),X=(Qi(e.samples[0].pts,fe)-fe)/t.inputTimeScale;w+=Math.max(0,X),S+=Math.max(0,-X)}if(M){if(e.samplerate||(this.warn("regenerate InitSegment as audio detected"),p=this.generateIS(e,t,i,a)),h=this.remuxAudio(e,w,this.isAudioContiguous,a,L||V||c===st.AUDIO?S:void 0),V){const fe=h?h.endPTS-h.startPTS:0;t.inputTimeScale||(this.warn("regenerate InitSegment as video detected"),p=this.generateIS(e,t,i,a)),d=this.remuxVideo(t,S,F,fe)}}else V&&(d=this.remuxVideo(t,S,F,0));d&&(d.firstKeyFrame=z,d.independent=z!==-1,d.firstKeyFramePTS=U)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(s.samples.length&&(y=cL(s,i,this._initPTS,this._initDTS)),r.samples.length&&(m=uL(r,i,this._initPTS))),{audio:h,video:d,initSegment:p,independent:x,text:m,id3:y}}computeInitPts(e,t,s,r){const i=Math.round(s*t);let a=Qi(e,i);if(a<i+t)for(this.log(`Adjusting PTS for rollover in timeline near ${(i-a)/t} ${r}`);a<i+t;)a+=8589934592;return a-i}generateIS(e,t,s,r){const i=e.samples,a=t.samples,l=this.typeSupported,c={},d=this._initPTS;let h=!d||r,p="audio/mp4",m,y,x,w=-1;if(h&&(m=y=1/0),e.config&&i.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":l.mpeg?(p="audio/mpeg",e.codec=""):l.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3";break}c.audio={id:"audio",container:p,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&l.mpeg?new Uint8Array(0):de.initSegment([e]),metadata:{channelCount:e.channelCount}},h&&(w=e.id,x=e.inputTimeScale,!d||x!==d.timescale?m=y=this.computeInitPts(i[0].pts,x,s,"audio"):h=!1)}if(t.sps&&t.pps&&a.length){if(t.timescale=t.inputTimeScale,c.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:de.initSegment([t]),metadata:{width:t.width,height:t.height}},h)if(w=t.id,x=t.inputTimeScale,!d||x!==d.timescale){const S=this.getVideoStartPts(a),_=Qi(a[0].dts,S),L=this.computeInitPts(_,x,s,"video"),R=this.computeInitPts(S,x,s,"video");y=Math.min(y,L),m=Math.min(m,R)}else h=!1;this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(c).length)return this.ISGenerated=!0,h?(d&&this.warn(`Timestamps at playlist time: ${r?"":"~"}${s} ${m/x} != initPTS: ${d.baseTime/d.timescale} (${d.baseTime}/${d.timescale}) trackId: ${d.trackId}`),this.log(`Found initPTS at playlist time: ${s} offset: ${m/x} (${m}/${x}) trackId: ${w}`),this._initPTS={baseTime:m,timescale:x,trackId:w},this._initDTS={baseTime:y,timescale:x,trackId:w}):m=x=void 0,{tracks:c,initPTS:m,timescale:x,trackId:w}}remuxVideo(e,t,s,r){const i=e.inputTimeScale,a=e.samples,l=[],c=a.length,d=this._initPTS,h=d.baseTime*i/d.timescale;let p=this.nextVideoTs,m=8,y=this.videoSampleDuration,x,w,S=Number.POSITIVE_INFINITY,_=Number.NEGATIVE_INFINITY,L=!1;if(!s||p===null){const H=h+t*i,K=a[0].pts-Qi(a[0].dts,a[0].pts);ph&&p!==null&&Math.abs(H-K-(p+h))<15e3?s=!0:p=H-K-h}const R=p+h;for(let H=0;H<c;H++){const K=a[H];K.pts=Qi(K.pts,R),K.dts=Qi(K.dts,R),K.dts<a[H>0?H-1:H].dts&&(L=!0)}L&&a.sort(function(H,K){const pe=H.dts-K.dts,Fe=H.pts-K.pts;return pe||Fe}),x=a[0].dts,w=a[a.length-1].dts;const M=w-x,V=M?Math.round(M/(c-1)):y||e.inputTimeScale/30;if(s){const H=x-R,K=H>V,pe=H<-1;if((K||pe)&&(K?this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${dp(H,!0)} ms (${H}dts) hole between fragments detected at ${t.toFixed(3)}`):this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${dp(-H,!0)} ms (${H}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!pe||R>=a[0].pts||ph)){x=R;const Fe=a[0].pts-H;if(K)a[0].dts=x,a[0].pts=Fe;else{let _e=!0;for(let ze=0;ze<a.length&&!(a[ze].dts>Fe&&_e);ze++){const Ye=a[ze].pts;
111if(a[ze].dts-=H,a[ze].pts-=H,ze<a.length-1){const tt=a[ze+1].pts,lt=a[ze].pts,ut=tt<=lt,cn=tt<=Ye;_e=ut==cn}}}this.log(`Video: Initial PTS/DTS adjusted: ${dp(Fe,!0)}/${dp(x,!0)}, delta: ${dp(H,!0)} ms`)}}x=Math.max(0,x);let W=0,I=0,k=x;for(let H=0;H<c;H++){const K=a[H],pe=K.units,Fe=pe.length;let _e=0;for(let ze=0;ze<Fe;ze++)_e+=pe[ze].data.length;I+=_e,W+=Fe,K.length=_e,K.dts<k?(K.dts=k,k+=V/4|0||1):k=K.dts,S=Math.min(K.pts,S),_=Math.max(K.pts,_)}w=a[c-1].dts;const P=I+4*W+8;let N;try{N=new Uint8Array(P)}catch(H){this.observer.emit(j.ERROR,j.ERROR,{type:xt.MUX_ERROR,details:he.REMUX_ALLOC_ERROR,fatal:!1,error:H,bytes:P,reason:`fail allocating video mdat ${P}`});return}const F=new DataView(N.buffer);F.setUint32(0,P),N.set(de.types.mdat,4);let z=!1,U=Number.POSITIVE_INFINITY,fe=Number.POSITIVE_INFINITY,oe=Number.NEGATIVE_INFINITY,X=Number.NEGATIVE_INFINITY;for(let H=0;H<c;H++){const K=a[H],pe=K.units;let Fe=0;for(let Ye=0,tt=pe.length;Ye<tt;Ye++){const lt=pe[Ye],ut=lt.data,cn=lt.data.byteLength;F.setUint32(m,cn),m+=4,N.set(ut,m),m+=cn,Fe+=4+cn}let _e;if(H<c-1)y=a[H+1].dts-K.dts,_e=a[H+1].pts-K.pts;else{const Ye=this.config,tt=H>0?K.dts-a[H-1].dts:V;if(_e=H>0?K.pts-a[H-1].pts:V,Ye.stretchShortVideoTrack&&this.nextAudioTs!==null){const lt=Math.floor(Ye.maxBufferHole*i),ut=(r?S+r*i:this.nextAudioTs+h)-K.pts;ut>lt?(y=ut-tt,y<0?y=tt:z=!0,this.log(`It is approximately ${ut/90} ms to the next segment; using duration ${y/90} ms for the last video frame.`)):y=tt}else y=tt}const ze=Math.round(K.pts-K.dts);U=Math.min(U,y),oe=Math.max(oe,y),fe=Math.min(fe,_e),X=Math.max(X,_e),l.push(lI(K.key,y,Fe,ze))}if(l.length){if(ph){if(ph<70){const H=l[0].flags;H.dependsOn=2,H.isNonSync=0}}else if(kv&&X-fe<oe-U&&V/oe<.025&&l[0].cts===0){this.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let H=x;for(let K=0,pe=l.length;K<pe;K++){const Fe=H+l[K].duration,_e=H+l[K].cts;if(K<pe-1){const ze=Fe+l[K+1].cts;l[K].duration=ze-_e}else l[K].duration=K?l[K-1].duration:V;l[K].cts=0,H=Fe}}}y=z||!y?V:y;const Q=w+y;this.nextVideoTs=p=Q-h,this.videoSampleDuration=y,this.isVideoContiguous=!0;const ee={data1:de.moof(e.sequenceNumber++,x,kn(e,{samples:l})),data2:N,startPTS:(S-h)/i,endPTS:(_+y-h)/i,startDTS:(x-h)/i,endDTS:p/i,type:"video",hasAudio:!1,hasVideo:!0,nb:l.length,dropped:e.dropped};return e.samples=[],e.dropped=0,ee}getSamplesPerFrame(e){switch(e.segmentCodec){case"mp3":return cse;case"ac3":return use;default:return lse}}remuxAudio(e,t,s,r,i){const a=e.inputTimeScale,l=e.samplerate?e.samplerate:a,c=a/l,d=this.getSamplesPerFrame(e),h=d*c,p=this._initPTS,m=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,y=[],x=i!==void 0;let w=e.samples,S=m?0:8,_=this.nextAudioTs||-1;const L=p.baseTime*a/p.timescale,R=L+t*a;if(this.isAudioContiguous=s=s||w.length&&_>0&&(r&&Math.abs(R-(_+L))<9e3||Math.abs(Qi(w[0].pts,R)-(_+L))<20*h),w.forEac
111h(function(X){X.pts=Qi(X.pts,R)}),!s||_<0){const X=w.length;if(w=w.filter(Q=>Q.pts>=0),X!==w.length&&this.warn(`Removed ${w.length-X} of ${X} samples (initPTS ${L} / ${a})`),!w.length)return;i===0?_=0:r&&!x?_=Math.max(0,R-L):_=w[0].pts-L}if(e.segmentCodec==="aac"){const X=this.config.maxAudioFramesDrift;for(let Q=0,G=_+L;Q<w.length;Q++){const Y=w[Q],ee=Y.pts,H=ee-G,K=Math.abs(1e3*H/a);if(H<=-X*h&&x)Q===0&&(this.warn(`Audio frame @ ${(ee/a).toFixed(3)}s overlaps marker by ${Math.round(1e3*H/a)} ms.`),this.nextAudioTs=_=ee-L,G=ee);else if(H>=X*h&&K<ose&&x){let pe=Math.round(H/h);for(G=ee-pe*h;G<0&&pe&&h;)pe--,G+=h;Q===0&&(this.nextAudioTs=_=G-L),this.warn(`Injecting ${pe} audio frames @ ${((G-L)/a).toFixed(3)}s due to ${Math.round(1e3*H/a)} ms gap.`);for(let Fe=0;Fe<pe;Fe++){let _e=rse.getSilentFrame(e.parsedCodec||e.manifestCodec||e.codec,e.channelCount);_e||(this.log("Unable to get silent frame for given audio codec; duplicating last frame instead."),_e=Y.unit.subarray()),w.splice(Q,0,{unit:_e,pts:G}),G+=h,Q++}}Y.pts=G,G+=h}}let M=null,V=null,W,I=0,k=w.length;for(;k--;)I+=w[k].unit.byteLength;for(let X=0,Q=w.length;X<Q;X++){const G=w[X],Y=G.unit;let ee=G.pts;if(V!==null){const K=y[X-1];K.duration=Math.round((ee-V)/c)}else if(s&&e.segmentCodec==="aac"&&(ee=_+L),M=ee,I>0){I+=S;try{W=new Uint8Array(I)}catch(K){this.observer.emit(j.ERROR,j.ERROR,{type:xt.MUX_ERROR,details:he.REMUX_ALLOC_ERROR,fatal:!1,error:K,bytes:I,reason:`fail allocating audio mdat ${I}`});return}m||(new DataView(W.buffer).setUint32(0,I),W.set(de.types.mdat,4))}else return;W.set(Y,S);const H=Y.byteLength;S+=H,y.push(lI(!0,d,H,0)),V=ee}const P=y.length;if(!P)return;const N=y[y.length-1];_=V-L,this.nextAudioTs=_+c*N.duration;const F=m?new Uint8Array(0):de.moof(e.sequenceNumber++,M/c,kn({},e,{samples:y}));e.samples=[];const z=(M-L)/a,U=this.nextAudioTs/a,oe={data1:F,data2:W,startPTS:z,endPTS:U,startDTS:z,endDTS:U,type:"audio",hasAudio:!0,hasVideo:!1,nb:P};return this.isAudioContiguous=!0,oe}}function Qi(n,e){let t;if(e===null)return n;for(e<n?t=-8589934592:t=8589934592;Math.abs(n-e)>4294967296;)n+=t;return n}function dse(n){for(let e=0;e<n.length;e++)if(n[e].key)return e;return-1}function cL(n,e,t,s){const r=n.samples.length;if(!r)return;const i=n.inputTimeScale;for(let l=0;l<r;l++){const c=n.samples[l];c.pts=Qi(c.pts-t.baseTime*i/t.timescale,e*i)/i,c.dts=Qi(c.dts-s.baseTime*i/s.timescale,e*i)/i}const a=n.samples;return n.samples=[],{samples:a}}function uL(n,e,t){const s=n.samples.length;if(!s)return;const r=n.inputTimeScale;for(let a=0;a<s;a++){const l=n.samples[a];l.pts=Qi(l.pts-t.baseTime*r/t.timescale,e*r)/r}n.samples.sort((a,l)=>a.pts-l.pts);const i=n.samples;return n.samples=[],{samples:i}}class hse extends Pa{constructor(e,t,s,r){super("passthrough-remuxer",r),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,s,r){this.audioCodec=t,this.videoCodec=s,this.generateInitSegment(e,r),this.emitInitSegment=!0}generateInitSegment(e,t){let{audioCodec:s,videoCodec:r}=this;if(!(e!=null&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}const{audio:i,video:a}=this.initData=mN(e);if(t)nte(e,t);else{const c=i||a;c!=null&&c.encrypted&&this.warn(`Init segment with encrypted track with has no key ("${c.codec}")!`)}i&&(s=cI(i,Ln.AUDIO,this)),a&&(r=cI(a,Ln.VIDEO,this));const l={};i&&a?l.audiovideo={container:"video/mp4",codec:s+","+r,supplemental:a.supplemental,encrypted:a.encrypted,initSegment:e,id:"main"}:i?l.audio={container:"audio/mp4",codec:s,encrypted:i.encrypted,initSegment:e,id:"audio"}:a?l.video={container:"video/mp4",codec:r,supplemental:a.supplemental,encrypted:a.encrypted,initSegment:e,id:"main"}:this.warn("initSegment does not contain moov or trak boxes."),this.initTracks=l}remux(e,t,s,r,i,a){var l,c;let{initPTS:d,lastEndTime:h}=this;const p={audio:void 0,video:void 0,text:r,id3:s,initSegment:void 0};et(h)||(h=this.lastEndTime=i||0);const m=t.samples;if(!m.length)return p;const y={initPTS:void 0,timescale:void 0,trackId:void 0};let x=this.initData;if((l=x)!=null&&l.length||(this.generateInitSegment(m),x=this.initData),!((c=x)!=null&&c.length))return this.warn("Failed to generate initSegment."),p;this.emitInitSegment&&(y.tracks=this.initTracks,this.emitInitSegment=!1);const w=rte(m,x,this),S=x.audio?w[x.audio.id]:null,_=x.video?w[x.video.id]:null,L=i0(_,1/0),R=i0(S,1/0),M=i0(_,0,!0),V=i0(S,0,!0);let W=i,I=0;const k=S&&(!_||!d&&R<L||d&&d.trackId===x.audio.id),P=k?S:_;if(P){const G=P.timescale,Y=P.start-i*G,ee=k?x.audio.id:x.video.id;W=P.start/G,I=k?V-R:M-L,(a||!d)&&(fse(d,W,i,I)||G!==d.timescale)&&(d&&this.warn(`Timestamps at playlist time: ${a?"":"~"}${i} ${Y/G} != initPTS: ${d.baseTime/d.timescale} (${d.baseTime}/${d.timescale}) trackId: ${d.trackId}`),this.log(`Found initPTS at playlist time: ${i} offset: ${W-i} (${Y}/${G}) trackId: ${ee}`),d=null,y.initPTS=Y,y.timescale=G,y.trackId=ee)}else this.warn(`No audio or video samples found for initPTS at playlist time: ${i}`);d?(y.initPTS=d.baseTime,y.timescale=d.timescale,y.trackId=d.trackId):((!y.timescale||y.trackId===void 0||y.initPTS===void 0)&&(this.warn("Could not set initPTS"),y.initPTS=W,y.timescale=1,y.trackId=-1),this.initPTS=d={baseTime:y.initPTS,timescale:y.timescale,trackId:y.trackId});const N=W-d.baseTime/d.timescale,F=N+I;I>0?this.lastEndTime=F:(this.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const z=!!x.audio,U=!!x.video;let fe="";z&&(fe+="audio"),U&&(fe+="video");const oe=(x.audio?x.audio.encrypted:!1)||(x.video?x.video.encrypted:!1),X={data1:m,startPTS:N,startDTS:N,endPTS:F,endDTS:F,type:fe,hasAudio:z,hasVideo:U,nb:1,dropped:0,encrypted:oe};p.audio=z&&!U?X:void 0,p.video=U?X:void 0;
vendor: 13,887 bytes, lines 111-117
111const Q=_?.sampleCount;if(Q){const G=_.keyFrameIndex,Y=G!==-1;X.nb=Q,X.dropped=G===0||this.isVideoContiguous?0:Y?G:Q,X.independent=Y,X.firstKeyFrame=G,Y&&_.keyFrameStart&&(X.firstKeyFramePTS=(_.keyFrameStart-d.baseTime)/d.timescale),this.isVideoContiguous||(p.independent=Y),this.isVideoContiguous||(this.isVideoContiguous=Y),X.dropped&&this.warn(`fmp4 does not start with IDR: firstIDR ${G}/${Q} dropped: ${X.dropped} start: ${X.firstKeyFramePTS||"NA"}`)}return p.initSegment=y,p.id3=cL(s,i,d,d),r.samples.length&&(p.text=uL(r,i,d)),p}}function i0(n,e,t=!1){return n?.start!==void 0?(n.start+(t?n.duration:0))/n.timescale:e}function fse(n,e,t,s){if(n===null)return!0;const r=Math.max(s,1),i=e-n.baseTime/n.timescale;return Math.abs(i-t)>r}function cI(n,e,t){const s=n.codec;return s&&s.length>4?s:e===Ln.AUDIO?s==="ec-3"||s==="ac-3"||s==="alac"?s:s==="fLaC"||s==="Opus"?D1(s,!1):(t.warn(`Unhandled audio codec "${s}" in mp4 MAP`),s||"mp4a"):(t.warn(`Unhandled video codec "${s}" in mp4 MAP`),s||"avc1")}let Cl;try{Cl=self.performance.now.bind(self.performance)}catch{Cl=Date.now}const M0=[{demux:Jne,remux:hse},{demux:Nc,remux:O0},{demux:qne,remux:O0},{demux:Qne,remux:O0}];M0.splice(2,0,{demux:Yne,remux:O0});class uI{constructor(e,t,s,r,i,a){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=s,this.id=i,this.logger=a}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,s,r){const i=s.transmuxing;i.executeStart=Cl();let a=new Uint8Array(e);const{currentTransmuxState:l,transmuxConfig:c}=this;r&&(this.currentTransmuxState=r);const{contiguous:d,discontinuity:h,trackSwitch:p,accurateTimeOffset:m,timeOffset:y,initSegmentChange:x}=r||l,{audioCodec:w,videoCodec:S,defaultInitPts:_,duration:L,initSegmentData:R}=c,M=pse(a,t);if(M&&Hh(M.method)){const k=this.getDecrypter(),P=oS(M.method);if(k.isSync()){let N=k.softwareDecrypt(a,M.key.buffer,M.iv.buffer,P);if(s.part>-1){const z=k.flush();N=z&&z.buffer}if(!N)return i.executeEnd=Cl(),Rv(s);a=new Uint8Array(N)}else return this.asyncResult=!0,this.decryptionPromise=k.webCryptoDecrypt(a,M.key.buffer,M.iv.buffer,P).then(N=>{const F=this.push(N,null,s);return this.decryptionPromise=null,F}),this.decryptionPromise}const V=this.needsProbing(h,p);if(V){const k=this.configureTransmuxer(a);if(k)return this.logger.warn(`[transmuxer] ${k.message}`),this.observer.emit(j.ERROR,j.ERROR,{type:xt.MEDIA_ERROR,details:he.FRAG_PARSING_ERROR,fatal:!1,error:k,reason:k.message}),i.executeEnd=Cl(),Rv(s)}(h||p||x||V)&&this.resetInitSegment(R,w,S,L,t),(h||x||V)&&this.resetInitialTimestamp(_),d||this.resetContiguity();const W=this.transmux(a,M,y,m,s);this.asyncResult=bm(W);const I=this.currentTransmuxState;return I.contiguous=!0,I.discontinuity=!1,I.trackSwitch=!1,i.executeEnd=Cl(),W}flush(e){const t=e.transmuxing;t.executeStart=Cl();const{decrypter:s,currentTransmuxState:r,decryptionPromise:i}=this;if(i)return this.asyncResult=!0,i.then(()=>this.flush(e));const a=[],{timeOffset:l}=r;if(s){const p=s.flush();p&&a.push(this.push(p.buffer,null,e))}const{demuxer:c,remuxer:d}=this;if(!c||!d){t.executeEnd=Cl();const p=[Rv(e)];return this.asyncResult?Promise.resolve(p):p}const h=c.flush(l);return bm(h)?(this.asyncResult=!0,h.then(p=>(this.flushRemux(a,p,e),a))):(this.flushRemux(a,h,e),this.asyncResult?Promise.resolve(a):a)}flushRemux(e,t,s){const{audioTrack:r,videoTrack:i,id3Track:a,textTrack:l}=t,{accurateTimeOffset:c,timeOffset:d}=this.currentTransmuxState;this.logger.log(`[transmuxer.ts]: Flushed ${this.id} sn: ${s.sn}${s.part>-1?" part: "+s.part:""} of ${this.id===st.MAIN?"level":"track"} ${s.level}`);const h=this.remuxer.remux(r,i,a,l,d,c,!0,this.id);e.push({remuxResult:h,chunkMeta:s}),s.transmuxing.executeEnd=Cl()}resetInitialTimestamp(e){const{demuxer:t,remuxer:s}=this;!t||!s||(t.resetTimeStamp(e),s.resetTimeStamp(e))}resetContiguity(){const{demuxer:e,remuxer:t}=this;!e||!t||(e.resetContiguity(),t.resetNextTimestamp())}resetInitSegment(e,t,s,r,i){const{demuxer:a,remuxer:l}=this;!a||!l||(a.resetInitSegment(e,t,s,r),l.resetInitSegment(e,t,s,i))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,s,r,i){let a;return t&&t.method==="SAMPLE-AES"?a=this.transmuxSampleAes(e,t,s,r,i):a=this.transmuxUnencrypted(e,s,r,i),a}transmuxUnencrypted(e,t,s,r){const{audioTrack:i,videoTrack:a,id3Track:l,textTrack:c}=this.demuxer.demux(e,t,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(i,a,l,c,t,s,!1,this.id),chunkMeta:r}}transmuxSampleAes(e,t,s,r,i){return this.demuxer.demuxSampleAes(e,t,s).then(a=>({remuxResult:this.remuxer.remux(a.audioTrack,a.videoTrack,a.id3Track,a.textTrack,s,r,!1,this.id),chunkMeta:i}))}configureTransmuxer(e){const{config:t,observer:s,typeSupported:r}=this;let i;for(let p=0,m=M0.length;p<m;p++){var a;if((a=M0[p].demux)!=null&&a.probe(e,this.logger)){i=M0[p];break}}if(!i)return new Error("Failed to find demuxer by probing fragment data");const l=this.demuxer,c=this.remuxer,d=i.remux,h=i.demux;(!c||!(c instanceof d))&&(this.remuxer=new d(s,t,r,this.logger)),(!l||!(l instanceof h))&&(this.demuxer=new h(s,t,r,this.logger),this.probe=h.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new iS(this.config)),e}}function pse(n,e){let t=null;return n.byteLength>0&&e?.key!=null&&e.iv!==null&&e.method!=null&&(t=e),t}const Rv=n=>({remuxResult:{},chunkMeta:n});function bm(n){return"then"in n&&n.then instanceof Function}class mse{constructor(e,t,s,r,i){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=s,this.duration=r,this.defaultInitPts=i||null}}class gse{constructor(e,t,s,r,i,a){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=s,this.trackSwitch=r,this.timeOffset=i,this.initSegmentChange=a}}let dI=0;class dL{constructor(e,t,s,r){this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=dI++,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=c=>{const d=c.data,h=this.hls;if(!(!h||!(d!=null&&d.event)||d.instanceNo!==this.instanceNo))switch(d.event){case"init":{var p;const m=(p=this.workerContext)==null?void 0:p.objectURL;m&&self.URL.revokeObjectURL(m);break}case"transmuxComplete":{this.handleTransmuxComplete(d.data);break}case"flush":{this.onFlush(d.data);break}case"workerLog":{h.logger[d.data.logType]&&h.logger[d.data.logType](d.data.message);break}default:{d.data=d.data||{},d.data.frag=this.frag,d.data.part=this.part,d.data.id=this.id,h.trigger(d.event,d.data);break}}},this.onWorkerError=c=>{if(!this.hls)return;const d=new Error(`${c.message} (${c.filename}:${c.lineno})`);this.hls.config.enableWorker=!1,this.hls.logger.warn(`Error in "${this.id}" Web Worker, fallback to inline`),this.hls.trigger(j.ERROR,{type:xt.OTHER_ERROR,details:he.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:d})};const i=e.config;this.hls=e,this.id=t,this.useWorker=!!i.enableWorker,this.onTransmuxComplete=s,this.onFlush=r;const a=(c,d)=>{d=d||{},d.frag=this.frag||void 0,c===j.ERROR&&(d=d,d.parent=this.id,d.part=this.part,this.error=d.error),this.hls.trigger(c,d)};this.observer=new uS,this.observer.on(j.FRAG_DECRYPTED,a),this.observer.on(j.ERROR,a);const l=A_(i.preferManagedMediaSource);if(this.useWorker&&typeof Worker<"u"){const c=this.hls.logger;if(i.workerPath||bne()){try{i.workerPath?(c.log(`loading Web Worker ${i.workerPath} for "${t}"`),this.workerContext=Sne(i.workerPath)):(c.log(`injecting Web Worker for "${t}"`),this.workerContext=wne());const{worker:h}=this.workerContext;h.addEventListener("message",this.onWorkerMessage),h.addEventListener("error",this.onWorkerError),h.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:l,id:t,config:jn(i)})}catch(h){c.warn(`Error setting up "${t}" Web Worker, fallback to inline`,h),this.terminateWorker(),this.error=null,this.transmuxer=new uI(this.observer,l,i,"",t,e.logger)}return}}this.transmuxer=new uI(this.observer,l,i,"",t,e.logger)}reset(){if(this.frag=null,this.part=null,this.workerContext){const e=this.instanceNo;this.instanceNo=dI++;const t=this.hls.config,s=A_(t.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:e,typeSupported:s,id:this.id,config:jn(t)})}}terminateWorker(){if(this.workerContext){const{worker:e}=this.workerContext;this.workerContext=null,e.removeEventListener("message",this.onWorkerMessage),e.removeEventListener("error",this.onWorkerError),Ene(this.hls.config.workerPath)}}destroy(){if(this.workerContext)this.terminateWorker(),this.onWorkerMessage=this.onWorkerError=null;else{const t=this.transmuxer;t&&(t.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,s,r,i,a,l,c,d,h){var p,m;d.transmuxing.start=self.performance.now();const{instanceNo:y,transmuxer:x}=this,w=a?a.start:i.start,S=i.decryptdata,_=this.frag,L=!(_&&i.cc===_.cc),R=!(_&&d.level===_.level),M=_?d.sn-_.sn:-1,V=this.part?d.part-this.part.index:-1,W=M===0&&d.id>1&&d.id===_?.stats.chunkCount,I=!R&&(M===1||M===0&&(V===1||W&&V<=0)),k=self.performance.now();(R||M||i.stats.parsing.start===0)&&(i.stats.parsing.start=k),a&&(V||!I)&&(a.stats.parsing.start=k);const P=!(_&&((p=i.initSegment)==null?void 0:p.url)===((m=_.initSegment)==null?void 0:m.url)),N=new gse(L,I,c,R,w,P);if(!I||L||P){this.hls.logger.log(`[transmuxer-interface]: Starting new transmux session for ${i.type} sn: ${d.sn}${d.part>-1?" part: "+d.part:""} ${this.id===st.MAIN?"level":"track"}: ${d.level} id: ${d.id} 112 discontinuity: ${L} 113 trackSwitch: ${R} 114 contiguous: ${I} 115 accurateTimeOffset: ${c} 116 timeOffset: ${w} 117 initSegmentChange: ${P}`);const F=new mse(s,r,t,l,h);this.configureTransmuxer(F)}if(this.frag=i,this.part=a,this.workerContext)this.workerContext.worker.postMessage({instanceNo:y,cmd:"demux",data:e,decryptdata:S,chunkMeta:d,state:N},e instanceof ArrayBuffer?[e]:[]);else if(x){const F=x.push(e,S,d,N);bm(F)?F.then(z=>{this.handleTransmuxComplete(z)}).catch(z=>{this.transmuxerError(z,d,"transmuxer-interface push error")}):this.handleTransmuxComplete(F)}}flush(e){e.transmuxing.start=self.performance.now();const{instanceNo:t,transmuxer:s}=this;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:t,cmd:"flush",chunkMeta:e});else if(s){const r=s.flush(e);bm(r)?r.then(i=>{this.handleFlushResult(i,e)}).catch(i=>{this.transmuxerError(i,e,"transmuxer-interface flush error")}):this.handleFlushResult(r,e)}}transmuxerError(e,t,s){this.hls&&(this.error=e,this.hls.trigger(j.ERROR,{type:xt.MEDIA_ERROR,details:he.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,part:this.part||void 0,fatal:!1,error:e,err:e,reason:s}))}handleFlushResult(e,t){e.forEach(s=>{this.handleTransmuxComplete(s)}),this.onFlush(t)}configureTransmuxer(e){const{instanceNo:t,transmuxer:s}=this;this.workerContext?this.workerContext.worker.postMessage({instanceNo:t,cmd:"configure",config:e}):s&&s.configure(e)}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}}const hI=100;class hL extends ay{constructor(e,t,s){super(e,t,s,"audio-stream-controller",st.AUDIO),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(j.LEVEL_LOADED,this.onLevelLoaded,this),e.on(j.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(j.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(j.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(j.BUFFER_RESET,this.onBufferReset,this),e.on(j.BUFFER_CREATED,this.onBufferCreated,this),e.on(j.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(j.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(j.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(j.FRAG_LOADING,this.onFragLoading,this),e.on(j.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){const{hls:e}=this;e&&(super.unregisterListeners(),e.off(j.LEVEL_LOADED,this.onLevelLoaded,this),e.off(j.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(j.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(j.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(j.BUFFER_RESET,this.onBufferReset,this),e.off(j.BUFFER_CREATED,this.onBufferCreated,this),e.off(j.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(j.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(j.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(j.FRAG_LOADING,this.onFragLoading,this),e.off(j.FRAG_BUFFERED,this.onFragBuffered,this))}onInitPtsFound(e,{frag:t,id:s,initPTS:r,timescale:i,trackId:a}){if(s===st.MAIN){const l=t.cc,c=this.fragCurrent;if(this.initPTS[l]={baseTime:r,timescale:i,trackId:a},this.log(`InitPTS for cc: ${l}
117 found from main: ${r/i} (${r}/${i}) trackId: ${a}`),this.mainAnchor=t,this.state===Ae.WAITING_INIT_PTS){const d=this.waitingData;(!d&&!this.loadingParts||d&&d.frag.cc!==l)&&this.syncWithAnchor(t,d?.frag)}else!this.hls.hasEnoughToStart&&c&&c.cc!==l?(c.abortRequests(),this.syncWithAnchor(t,c)):this.state===Ae.IDLE&&this.tick()}}getLoadPosition(){return!this.startFragRequested&&this.nextLoadPosition>=0?this.nextLoadPosition:super.getLoadPosition()}syncWithAnchor(e,t){var s;const r=((s=this.mainFragLoading)==null?void 0:s.frag)||null;if(t&&r?.cc===t.cc)return;const i=(r||e).cc,a=this.getLevelDetails(),l=this.getLoadPosition(),c=AN(a,i,l);c&&(this.log(`Syncing with main frag at ${c.start} cc ${c.cc}`),this.startFragRequested=!1,this.nextLoadPosition=c.start,this.resetLoadingState(),this.state===Ae.IDLE&&this.doTickIdle())}startLoad(e,t){if(!this.levels){this.startPosition=e,this.state=Ae.STOPPED;return}const s=this.lastCurrentTime;this.stopLoad(),this.setInterval(hI),s>0&&e===-1?(this.log(`Override startPosition with lastCurrentTime @${s.toFixed(3)}`),e=s,this.state=Ae.IDLE):this.state=Ae.WAITING_TRACK,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}doTick(){switch(this.state){case Ae.IDLE:this.doTickIdle();break;case Ae.WAITING_TRACK:{const{levels:e,trackId:t}=this,s=e?.[t],r=s?.details;if(r&&!this.waitForLive(s)){if(this.waitForCdnTuneIn(r))break;this.state=Ae.WAITING_INIT_PTS}break}case Ae.FRAG_LOADING_WAITING_RETRY:{this.checkRetryDate();break}case Ae.WAITING_INIT_PTS:{const e=this.waitingData;if(e){const{frag:t,part:s,cache:r,complete:i}=e,a=this.mainAnchor;if(this.initPTS[t.cc]!==void 0){this.waitingData=null,this.state=Ae.FRAG_LOADING;const l=r.flush().buffer,c={frag:t,part:s,payload:l,networkDetails:null};this._handleFragmentLoadProgress(c),i&&super._handleFragmentLoadComplete(c)}else a&&a.cc!==e.frag.cc&&this.syncWithAnchor(a,e.frag)}else this.state=Ae.IDLE}}this.onTickEnd()}resetLoadingState(){const e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null),super.resetLoadingState()}onTickEnd(){const{media:e}=this;e!=null&&e.readyState&&(this.lastCurrentTime=e.currentTime)}doTickIdle(){var e;const{hls:t,levels:s,media:r,trackId:i}=this,a=t.config;if(!this.buffering||!r&&!this.primaryPrefetch&&(this.startFragRequested||!a.startFragPrefetch)||!(s!=null&&s[i]))return;const l=s[i],c=l.details;if(!c||this.waitForLive(l)||this.waitForCdnTuneIn(c)){this.state=Ae.WAITING_TRACK,this.startFragRequested=!1;return}const d=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&d&&(this.bufferFlushed=!1,this.afterBufferFlushed(d,Ln.AUDIO,st.AUDIO));const h=this.getFwdBufferInfo(d,st.AUDIO);if(h===null)return;if(!this.switchingTrack&&this._streamEnded(h,c)){t.trigger(j.BUFFER_EOS,{type:"audio"}),this.state=Ae.ENDED;return}const p=h.len,m=t.maxBufferLength,y=c.fragments,x=y[0].start,w=this.getLoadPosition(),S=this.flushing?w:h.end;if(this.switchingTrack&&r){const R=w;c.PTSKnown&&R<x&&(h.end>x||h.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),r.currentTime=x+.05)}if(p>=m&&!this.switchingTrack&&S<y[y.length-1].start)return;let _=this.getNextFragment(S,c);if(_&&this.isLoopLoading(_,S)&&(_=this.getNextFragmentLoopLoading(_,c,h,st.MAIN,m)),!_){this.bufferFlushed=!0;return}if(this.exceedsMaxBuffer(h,m,_))return;let L=((e=this.mainFragLoading)==null?void 0:e.frag)||null;if(!this.audioOnly&&this.startFragRequested&&L&&_s(_)&&!_.endList&&(!c.live||!this.loadingParts&&S<this.hls.liveSyncPosition)&&(this.fragmentTracker.getState(L)===Gs.OK&&(this.mainFragLoading=L=null),L&&_s(L))){if(_.start>L.end){const M=this.fragmentTracker.getFragAtPos(S,st.MAIN);M&&M.end>L.end&&(L=M,this.mainFragLoading={frag:M,targetBufferTime:null})}if(_.start>L.end)return}this.loadFragment(_,l,S)}onMediaDetaching(e,t){this.bufferFlushed=this.flushing=!1,super.onMediaDetaching(e,t)}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(s=>new af(s))}onAudioTrackSwitching(e,t){const s=!!t.url;this.trackId=t.id;const{fragCurrent:r}=this;r&&(r.abortRequests(),this.removeUnbufferedFrags(r.start)),this.resetLoadingState(),s?(this.switchingTrack=t,this.flushAudioIfNeeded(t),this.state!==Ae.STOPPED&&(this.setInterval(hI),this.state=Ae.IDLE,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 s=this.cachedTrackLoadedData;s&&(this.cachedTrackLoadedData=null,this.onAudioTrackLoaded(j.AUDIO_TRACK_LOADED,s))}onAudioTrackLoaded(e,t){var s;const{levels:r}=this,{details:i,id:a,groupId:l,track:c}=t;if(!r){this.warn(`Audio tracks reset while loading track ${a} "${c.name}" of "${l}"`);return}const d=this.mainDetails;if(!d||i.endCC>d.endCC||d.expired){this.cachedTrackLoadedData=t,this.state!==Ae.STOPPED&&(this.state=Ae.WAITING_TRACK);return}this.cachedTrackLoadedData=null,this.log(`Audio track ${a} "${c.name}" of "${l}" loaded [${i.startSN},${i.endSN}]${i.lastPartSn?`[part-${i.lastPartSn}-${i.lastPartIndex}]`:""},duration:${i.totalduration}`);const h=r[a];let p=0;if(i.live||(s=h.details)!=null&&s.live){if(this.checkLiveUpdate(i),i.deltaUpdateFailed)return;if(h.details){var m;p=this.alignPlaylists(i,h.details,(m=this.levelLastLoaded)==null?void 0:m.details)}i.alignedSliding||(WN(i,d),i.alignedSliding||B1(i,d),p=i.fragmentStart)}h.details=i,this.levelLastLoaded=h,this.startFragRequested||this.setStartPosition(d,p),this.hls.trigger(j.AU
vendor: 9,581 bytes, line 117
117DIO_TRACK_UPDATED,{details:i,id:a,groupId:t.groupId}),this.state===Ae.WAITING_TRACK&&!this.waitForCdnTuneIn(i)&&(this.state=Ae.IDLE),this.tick()}_handleFragmentLoadProgress(e){var t;const s=e.frag,{part:r,payload:i}=e,{config:a,trackId:l,levels:c}=this;if(!c){this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${s.sn} of level ${s.level} will not be buffered`);return}const d=c[l];if(!d){this.warn("Audio track is undefined on fragment load progress");return}const h=d.details;if(!h){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(s.start);return}const p=a.defaultAudioCodec||d.audioCodec||"mp4a.40.2";let m=this.transmuxer;m||(m=this.transmuxer=new dL(this.hls,st.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const y=this.initPTS[s.cc],x=(t=s.initSegment)==null?void 0:t.data;if(y!==void 0){const S=r?r.index:-1,_=S!==-1,L=new iy(s.level,s.sn,s.stats.chunkCount,i.byteLength,S,_);m.push(i,x,p,"",s,r,h.totalduration,!1,L,y)}else{this.log(`Unknown video PTS for cc ${s.cc}, waiting for video PTS before demuxing audio frag ${s.sn} of [${h.startSN} ,${h.endSN}],track ${l}`);const{cache:w}=this.waitingData=this.waitingData||{frag:s,part:r,cache:new GN,complete:!1};w.push(new Uint8Array(i)),this.state!==Ae.STOPPED&&(this.state=Ae.WAITING_INIT_PTS)}}_handleFragmentLoadComplete(e){if(this.waitingData){this.waitingData.complete=!0;return}super._handleFragmentLoadComplete(e)}onBufferReset(){this.mediaBuffer=null}onBufferCreated(e,t){this.bufferFlushed=this.flushing=!1;const s=t.tracks.audio;s&&(this.mediaBuffer=s.buffer||null)}onFragLoading(e,t){!this.audioOnly&&t.frag.type===st.MAIN&&_s(t.frag)&&(this.mainFragLoading=t,this.state===Ae.IDLE&&this.tick())}onFragBuffered(e,t){const{frag:s,part:r}=t;if(s.type!==st.AUDIO){!this.audioOnly&&s.type===st.MAIN&&!s.elementaryStreams.video&&!s.elementaryStreams.audiovideo&&(this.audioOnly=!0,this.mainFragLoading=null);return}if(this.fragContextChanged(s)){this.warn(`Fragment ${s.sn}${r?" p: "+r.index:""} of level ${s.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);return}if(_s(s)){this.fragPrevious=s;const i=this.switchingTrack;i&&(this.bufferedTrack=i,this.switchingTrack=null,this.hls.trigger(j.AUDIO_TRACK_SWITCHED,In({},i)))}this.fragBufferedComplete(s,r),this.media&&this.tick()}onError(e,t){var s;if(t.fatal){this.state=Ae.ERROR;return}switch(t.details){case he.FRAG_GAP:case he.FRAG_PARSING_ERROR:case he.FRAG_DECRYPT_ERROR:case he.FRAG_LOAD_ERROR:case he.FRAG_LOAD_TIMEOUT:case he.KEY_LOAD_ERROR:case he.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(st.AUDIO,t);break;case he.AUDIO_TRACK_LOAD_ERROR:case he.AUDIO_TRACK_LOAD_TIMEOUT:case he.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===Ae.WAITING_TRACK&&((s=t.context)==null?void 0:s.type)===Zt.AUDIO_TRACK&&(this.state=Ae.IDLE);break;case he.BUFFER_ADD_CODEC_ERROR:case he.BUFFER_APPEND_ERROR:if(t.parent!=="audio")return;this.reduceLengthAndFlushBuffer(t)||this.resetLoadingState();break;case he.BUFFER_FULL_ERROR:if(t.parent!=="audio")return;this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case he.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onBufferFlushing(e,{type:t}){t!==Ln.VIDEO&&(this.flushing=!0)}onBufferFlushed(e,{type:t}){if(t!==Ln.VIDEO){this.flushing=!1,this.bufferFlushed=!0,this.state===Ae.ENDED&&(this.state=Ae.IDLE);const s=this.mediaBuffer||this.media;s&&(this.afterBufferFlushed(s,t,st.AUDIO),this.tick())}}_handleTransmuxComplete(e){var t;const s="audio",{hls:r}=this,{remuxResult:i,chunkMeta:a}=e,l=this.getCurrentContext(a);if(!l){this.resetWhenMissingContext(a);return}const{frag:c,part:d,level:h}=l,{details:p}=h,{audio:m,text:y,id3:x,initSegment:w}=i;if(this.fragContextChanged(c)||!p){this.fragmentTracker.removeFragment(c);return}if(this.state=Ae.PARSING,this.switchingTrack&&m&&this.completeAudioSwitch(this.switchingTrack),w!=null&&w.tracks){const S=c.initSegment||c;if(this.unhandledEncryptionError(w,c))return;this._bufferInitSegment(h,w.tracks,S,a),r.trigger(j.FRAG_PARSING_INIT_SEGMENT,{frag:S,id:s,tracks:w.tracks})}if(m){const{startPTS:S,endPTS:_,startDTS:L,endDTS:R}=m;d&&(d.elementaryStreams[Ln.AUDIO]={startPTS:S,endPTS:_,startDTS:L,endDTS:R}),c.setElementaryStreamInfo(Ln.AUDIO,S,_,L,R),this.bufferFragmentData(m,c,d,a)}if(x!=null&&(t=x.samples)!=null&&t.length){const S=kn({id:s,frag:c,details:p},x);r.trigger(j.FRAG_PARSING_METADATA,S)}if(y){const S=kn({id:s,frag:c,details:p},y);r.trigger(j.FRAG_PARSING_USERDATA,S)}}_bufferInitSegment(e,t,s,r){if(this.state!==Ae.PARSING||(t.video&&delete t.video,t.audiovideo&&delete t.audiovideo,!t.audio))return;const i=t.audio;i.id=st.AUDIO;const a=e.audioCodec;this.log(`Init audio buffer, container:${i.container}, codecs[level/parsed]=[${a}/${i.codec}]`),a&&a.split(",").length===1&&(i.levelCodec=a),this.hls.trigger(j.BUFFER_CODECS,t);const l=i.initSegment;if(l!=null&&l.byteLength){const c={type:"audio",frag:s,part:null,chunkMeta:r,parent:s.type,data:l};this.hls.trigger(j.BUFFER_APPENDING,c)}this.tickImmediate()}loadFragment(e,t,s){const r=this.fragmentTracker.getState(e);if(this.switchingTrack||r===Gs.NOT_LOADED||r===Gs.PARTIAL){var i;if(!_s(e))this._loadInitSegment(e,t);else if((i=t.details)!=null&&i.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=Ae.WAITING_INIT_PTS;const a=this.mainDetails;a&&a.fragmentStart!==t.details.fragmentStart&&B1(t.details,a)}else super.loadFragment(e,t,s)}else this.clearTrackerIfNeeded(e)}flushAudioIfNeeded(e){if(this.media&&this.bufferedTrack){const{name:t,lang:s,assocLang:r,characteristics:i,audioCodec:a,channels:l}=this.bufferedTrack;ud({name:t,lang:s,assocLang:r,characteristics:i,audioCodec:a,channels:l},e,Ku)||(O1(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(j.AUDIO_TRACK_SWITCHED,In({},e))}}class ly extends Pa{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(){this.timer!==-1&&(self.clearTimeout(this.timer),this.timer=-1)}startLoad(){this.canLoad=!0,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(e,t,s){const r=t?.renditionReports;if(r){let i=-1;for(let a=0;a<r.length;a++){const l=r[a];let c;try{c=new self.URL(l.URI,t.url).href}catch(d){this.warn(`Could not construct new URL for Rendition Report: ${d}`),c=l.URI||""}if(c===e){i=a;break}else c===e.substring(0,c.length)&&(i=a)}if(i!==-1){const a=r[i],l=parseInt(a["LAST-MSN"])||t.lastPartSn;let c=parseInt(a["LAST-PART"])||t.lastPartIndex;if(this.hls.config.lowLatencyMode){const h=Math.min(t.age-t.partTarget,t.targetduration);c>=0&&h>t.partTarget&&(c+=1)}const d=s&&C_(s);return new sw(l,c>=0?c:void 0,d)}}}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(s){this.warn(`Could not construct new URL with HLS Delivery Directives: ${s}`)}return e}playlistLoaded(e,t,s){const{details:r,stats:i}=t,a=self.performance.now(),l=i.loading.first?Math.max(0,a-i.loading.first):0;r.advancedDateTime=Date.now()-l;const c=this.hls.config.timelineOffset;if(c!==r.appliedTimelineOffset){const h=Math.max(c||0,0);r.appliedTimelineOffset=h,r.fragments.forEach(p=>{p.setStart(p.playlistOffset+h)})}if(r.live||s!=null&&s.live){const h="levelInfo"in t?t.levelInfo:t.track;if(r.reloaded(s),s&&r.fragments.length>0){cne(s,r,this);const L=r.playlistParsingError;if(L){this.warn(L);const R=this.hls;if(!R.config.ignorePlaylistParsingErrors){var d;const{networkDetails:M}=t;R.trigger(j.ERROR,{type:xt.NETWORK_ERROR,details:he.LEVEL_PARSING_ERROR,fatal:!1,url:r.url,error:L,reason:L.message,level:t.level||void 0,parent:(d=r.fragments[0])==null?void 0:d.type,networkDetails:M,stats:i});return}r.playlistParsingError=null}}r.requestScheduled===-1&&(r.requestScheduled=i.loading.start);const p=this.hls.mainForwardBufferInfo,m=p?p.end-p.len:0,y=(r.edge-m)*1e3,x=VN(r,y);if(r.requestScheduled+x<a?r.requestScheduled=a:r.requestScheduled+=x,this.log(`live playlist ${e} ${r.advanced?"REFRESHED "+r.lastPartSn+"-"+r.lastPartIndex:r.updated?"UPDATED":"MISSED"}`),!this.canLoad||!r.live)return;let w,S,_;if(r.canBlockReload&&r.endSN&&r.advanced){const L=this.hls.config.lowLatencyMode,R=r.lastPartSn,M=r.endSN,V=r.lastPartIndex,W=V!==-1,I=R===M;W?I?(S=M+1,_=L?0:V):(S=R,_=L?V+1:r.maxPartIndex):S=M+1;const k=r.age,P=k+r.ageHeader;let N=Math.min(P-r.partTarget,r.targetduration*1.5);if(N>0){if(P>r.targetduration*3)this.log(`Playlist last advanced ${k.toFixed(2)}s ago. Omitting segment and part directives.`),S=void 0,_=void 0;else if(s!=null&&s.tuneInGoal&&P-r.partTarget>s.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${s.tuneInGoal} to: ${N} with playlist age: ${r.age}`),N=0;else{const F=Math.floor(N/r.targetduration);if(S+=F,_!==void 0){const z=Math.round(N%r.targetduration/r.partTarget);_+=z}this.log(`CDN Tune-in age: ${r.ageHeader}s last advanced ${k.toFixed(2)}s goal: ${N}
117 skip sn ${F} to part ${_}`)}r.tuneInGoal=N}if(w=this.getDeliveryDirectives(r,t.deliveryDirectives,S,_),L||!I){r.requestScheduled=a,this.loadingPlaylist(h,w);return}}else(r.canBlockReload||r.canSkipUntil)&&(w=this.getDeliveryDirectives(r,t.deliveryDirectives,S,_));w&&S!==void 0&&r.canBlockReload&&(r.requestScheduled=i.loading.first+Math.max(x-l*2,x/2)),this.scheduleLoading(h,w,r)}else this.clearTimer()}scheduleLoading(e,t,s){const r=s||e.details;if(!r){this.loadingPlaylist(e,t);return}const i=self.performance.now(),a=r.requestScheduled;if(i>=a){this.loadingPlaylist(e,t);return}const l=a-i;this.log(`reload live playlist ${e.name||e.bitrate+"bps"} in ${Math.round(l)} ms`),this.clearTimer(),this.timer=self.setTimeout(()=>this.loadingPlaylist(e,t),l)}getDeliveryDirectives(e,t,s,r){let i=C_(e);return t!=null&&t.skip&&e.deltaUpdateFailed&&(s=t.msn,r=t.part,i=Mp.No),new sw(s,r,i)}checkRetry(e){const t=e.details,s=M1(e),r=e.errorAction,{action:i,retryCount:a=0,retryConfig:l}=r||{},c=!!r&&!!l&&(i===Ws.RetryRequest||!r.resolved&&i===Ws.SendAlternateToPenaltyBox);if(c){var d;if(a>=l.maxNumRetry)return!1;if(s&&(d=e.context)!=null&&d.deliveryDirectives)this.warn(`Retrying playlist loading ${a+1}/${l.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{const h=rS(l,a);this.clearTimer(),this.timer=self.setTimeout(()=>this.loadPlaylist(),h),this.warn(`Retrying playlist loading ${a+1}/${l.maxNumRetry} after "${t}" in ${h}ms`)}e.levelRetry=!0,r.resolved=!0}return c}}function fL(n,e){if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(!wm(n[t].attrs,e[t].attrs))return!1;return!0}function wm(n,e,t){const s=n["STABLE-RENDITION-ID"];return s&&!t?s===e["STABLE-RENDITION-ID"]:!(t||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some(r=>n[r]!==e[r])}function dw(n,e){return e.label.toLowerCase()===n.name.toLowerCase()&&(!e.language||e.language.toLowerCase()===(n.lang||"").toLowerCase())}class pL extends ly{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(j.MANIFEST_LOADING,this.onManifestLoading,this),e.on(j.MANIFEST_PARSED,this.onManifestParsed,this),e.on(j.LEVEL_LOADING,this.onLevelLoading,this),e.on(j.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(j.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(j.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(j.MANIFEST_LOADING,this.onManifestLoading,this),e.off(j.MANIFEST_PARSED,this.onManifestParsed,this),e.off(j.LEVEL_LOADING,this.onLevelLoading,this),e.off(j.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(j.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(j.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:s,groupId:r,details:i}=t,a=this.tracksInGroup[s];if(!a||a.groupId!==r){this.warn(`Audio track with id:${s} and group:${r} not found in active group ${a?.groupId}`);return}const l=a.details;a.details=t.details,this.log(`Audio track ${s} "${a.name}" lang:${a.lang} group:${r} loaded [${i.startSN}-${i.endSN}]`),s===this.trackId&&this.playlistLoaded(s,t,l)}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 s=t.audioGroups||null,r=this.groupIds;let i=this.currentTrack;if(!s||r?.length!==s?.length||s!=null&&s.some(l=>r?.indexOf(l)===-1)){this.groupIds=s,this.trackId=-1,this.currentTrack=null;const l=this.tracks.filter(m=>!s||s.indexOf(m.groupId)!==-1);if(l.length)this.selectDefaultTrack&&!l.some(m=>m.default)&&(this.selectDefaultTrack=!1),l.forEach((m,y)=>{m.id=y});else if(!i&&!this.tracksInGroup.length)return;this.tracksInGroup=l;const c=this.hls.config.audioPreference;if(!i&&c){const m=$o(c,l,Ku);if(m>-1)i=l[m];else{const y=$o(c,this.tracks);i=this.tracks[y]}}let d=this.findTrackId(i);d===-1&&i&&(d=this.findTrackId(null));const h={audioTracks:l};this.log(`Updating audio tracks, ${l.length} track(s) found in group(s): ${s?.join(",")}
117`),this.hls.trigger(j.AUDIO_TRACKS_UPDATED,h);const p=this.trackId;if(d!==-1&&p===-1)this.setAudioTrack(d);else if(l.length&&p===-1){var a;const m=new Error(`No audio track selected for current audio group-ID(s): ${(a=this.groupIds)==null?void 0:a.join(",")} track count: ${l.length}`);this.warn(m.message),this.hls.trigger(j.ERROR,{type:xt.MEDIA_ERROR,details:he.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:m})}}}onError(e,t){t.fatal||!t.context||t.context.type===Zt.AUDIO_TRACK&&t.context.id===this.trackId&&(!this.groupIds||this.groupIds.indexOf(t.context.groupId)!==-1)&&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 s=this.allAudioTracks;if(this.selectDefaultTrack=!1,s.length){const r=this.currentTrack;if(r&&ud(e,r,Ku))return r;const i=$o(e,this.tracksInGroup,Ku);if(i>-1){const a=this.tracksInGroup[i];return this.setAudioTrack(i),a}else if(r){let a=t.loadLevel;a===-1&&(a=t.firstAutoLevel);const l=Lte(e,t.levels,s,a,Ku);if(l===-1)return null;t.nextLoadLevel=l}if(e.channels||e.audioCodec){const a=$o(e,s);if(a>-1)return s[a]}}}return null}setAudioTrack(e){const t=this.tracksInGroup;if(e<0||e>=t.length){this.warn(`Invalid audio track id: ${e}`);return}this.selectDefaultTrack=!1;const s=this.currentTrack,r=t[e],i=r.details&&!r.details.live;if(e===this.trackId&&r===s&&i||(this.log(`Switching to audio-track ${e} "${r.name}" lang:${r.lang} group:${r.groupId} channels:${r.channels}`),this.trackId=e,this.currentTrack=r,this.hls.trigger(j.AUDIO_TRACK_SWITCHING,In({},r)),i))return;const a=this.switchParams(r.url,s?.details,r.details);this.loadPlaylist(a)}findTrackId(e){const t=this.tracksInGroup;for(let s=0;s<t.length;s++){const r=t[s];if(!(this.selectDefaultTrack&&!r.default)&&(!e||ud(e,r,Ku)))return s}if(e){const{name:s,lang:r,assocLang:i,characteristics:a,audioCodec:l,channels:c}=e;for(let d=0;d<t.length;d++){const h=t[d];if(ud({name:s,lang:r,assocLang:i,characteristics:a,audioCodec:l,channels:c},h,Ku))return d}for(let d=0;d<t.length;d++){const h=t[d];if(wm(e.attrs,h.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return d}for(let d=0;d<t.length;d++){const h=t[d];if(wm(e.attrs,h.attrs,["LANGUAGE"]))return d}}return-1}loadPlaylist(e){super.loadPlaylist();const t=this.currentTrack;this.shouldLoadPlaylist(t)&&O1(t.url,this.hls)&&this.scheduleLoading(t,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);const s=e.id,r=e.groupId,i=this.getUrlWithDirectives(e.url,t),a=e.details,l=a?.age;this.log(`Loading audio-track ${s} "${e.name}" lang:${e.lang} group:${r}${t?.msn!==void 0?" at sn "+t.msn+" part "+t.part:""}${l&&a.live?" age "+l.toFixed(1)+(a.type&&" "+a.type||""):""} ${i}`),this.hls.trigger(j.AUDIO_TRACK_LOADING,{url:i,id:s,groupId:r,deliveryDirectives:t||null,track:e})}}class xse{constructor(e){this.tracks=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.tracks=e}destroy(){this.tracks=this.queues=null}append(e,t,s){if(this.queues===null||this.tracks===null)return;const r=this.queues[t];r.push(e),r.length===1&&!s&&this.executeNext(t)}appendBlocker(e){return new Promise(t=>{const s={label:"async-blocker",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.append(s,e)})}prependBlocker(e){return new Promise(t=>{if(this.queues){const s={label:"async-blocker-prepend",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.queues[e].unshift(s)}})}removeBlockers(){this.queues!==null&&[this.queues.video,this.queues.audio,this.queues.audiovideo].forEach(e=>{var t;const s=(t=e[0])==null?void 0:t.label;(s==="async-blocker"||s==="async-blocker-prepend")&&(e[0].execute(),e.splice(0,1))})}unblockAudio(e){if(this.queues===null)return;this.queues.audio[0]===e&&this.shiftAndExecuteNext("audio")}executeNext(e){if(this.queues===null||this.tracks===null)return;const t=this.queues[e];if(t.length){const r=t[0];try{r.execute()}catch(i){var s;if(r.onError(i),this.queues===null||this.tracks===null)return;const a=(s=this.tracks[e])==null?void 0:s.buffer;a!=null&&a.updating||this.shiftAndExecuteNext(e)}}}shiftAndExecuteNext(e){this.queues!==null&&(this.queues[e].shift(),this.executeNext(e))}current(e){var t;return((t=this.queues)==null?void 0:t[e][0])||null}toString(){const{queues:e,tracks:t}=this;return e===null||t===null?"<destroyed>":` 118${this.list("video")} 119${this.list("audio")} 120${this.list("audiovideo")}}`}list(e){var t,s;return(t=this.queues)!=null&&t[e]||(s=this.tracks)!=null&&s[e]?`${e}: (${this.listSbInfo(e)}) ${this.listOps(e)}`:""}listSbInfo(e){var t;const s=(t=this.tracks)==null?void 0:t[e],r=s?.buffer;return r?`SourceBuffer${r.updating?" updating":""}${s.ended?" ended":""}${s.ending?" ending":""}`:"none"}listOps(e){var t;return((t=this.queues)==null?void 0:t[e].map(s=>s.label).join(", "))||""}}const fI=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,mL="HlsJsTrackRemovedError";
vendor: 4,295 bytes, line 120
120class yse extends Error{constructor(e){super(e),this.name=mL}}class gL extends Pa{constructor(e,t){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=s=>{var r;this.hls&&((r=this.mediaSource)==null?void 0:r.readyState)==="open"&&this.hls.pauseBuffering()},this._onStartStreaming=s=>{this.hls&&this.hls.resumeBuffering()},this._onMediaSourceOpen=s=>{const{media:r,mediaSource:i}=this;s&&this.log("Media source opened"),!(!r||!i)&&(i.removeEventListener("sourceopen",this._onMediaSourceOpen),r.removeEventListener("emptied",this._onMediaEmptied),this.updateDuration(),this.hls.trigger(j.MEDIA_ATTACHED,{media:r,mediaSource:i}),this.mediaSource!==null&&this.checkPendingTracks())},this._onMediaSourceClose=()=>{this.log("Media source closed")},this._onMediaSourceEnded=()=>{this.log("Media source ended")},this._onMediaEmptied=()=>{const{mediaSrc:s,_objectUrl:r}=this;s!==r&&this.error(`Media element src was set while attaching MediaSource (${r} > ${s})`)},this.hls=e,this.fragmentTracker=t,this.appendSource=Kee(Ql(e.config.preferManagedMediaSource)),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(j.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(j.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(j.MANIFEST_LOADING,this.onManifestLoading,this),e.on(j.MANIFEST_PARSED,this.onManifestParsed,this),e.on(j.BUFFER_RESET,this.onBufferReset,this),e.on(j.BUFFER_APPENDING,this.onBufferAppending,this),e.on(j.BUFFER_CODECS,this.onBufferCodecs,this),e.on(j.BUFFER_EOS,this.onBufferEos,this),e.on(j.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(j.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(j.FRAG_PARSED,this.onFragParsed,this),e.on(j.FRAG_CHANGED,this.onFragChanged,this),e.on(j.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(j.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(j.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(j.MANIFEST_LOADING,this.onManifestLoading,this),e.off(j.MANIFEST_PARSED,this.onManifestParsed,this),e.off(j.BUFFER_RESET,this.onBufferReset,this),e.off(j.BUFFER_APPENDING,this.onBufferAppending,this),e.off(j.BUFFER_CODECS,this.onBufferCodecs,this),e.off(j.BUFFER_EOS,this.onBufferEos,this),e.off(j.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(j.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(j.FRAG_PARSED,this.onFragParsed,this),e.off(j.FRAG_CHANGED,this.onFragChanged,this),e.off(j.ERROR,this.onError,this)}transferMedia(){const{media:e,mediaSource:t}=this;if(!e)return null;const s={};if(this.operationQueue){const i=this.isUpdating();i||this.operationQueue.removeBlockers();const a=this.isQueued();(i||a)&&this.warn(`Transfering MediaSource with${a?" operations in queue":""}${i?" updating SourceBuffer(s)":""} ${this.operationQueue}`),this.operationQueue.destroy()}const r=this.transferData;return!this.sourceBufferCount&&r&&r.mediaSource===t?kn(s,r.tracks):this.sourceBuffers.forEach(i=>{const[a]=i;a&&(s[a]=kn({},this.tracks[a]),this.removeBuffer(a)),i[0]=i[1]=null}),{media:e,mediaSource:t,tracks:s}}initTracks(){const e={};this.sourceBuffers=[[null,null],[null,null]],this.tracks=e,this.resetQueue(),this.resetAppendErrors(),this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.lastVideoAppendEnd=0}onManifestLoading(){this.bufferCodecEventsTotal=0,this.details=null}onManifestParsed(e,t){var s;let r=2;(t.audio&&!t.video||!t.altAudio)&&(r=1),this.bufferCodecEventsTotal=r,this.log(`${r}
120 bufferCodec event(s) expected.`),(s=this.transferData)!=null&&s.mediaSource&&this.sourceBufferCount&&r&&this.bufferCreated()}onMediaAttaching(e,t){const s=this.media=t.media;this.transferData=this.overrides=void 0;const r=Ql(this.appendSource);if(r){const i=!!t.mediaSource;(i||t.overrides)&&(this.transferData=t,this.overrides=t.overrides);const a=this.mediaSource=t.mediaSource||new r;if(this.assignMediaSource(a),i)this._objectUrl=s.src,this.attachTransferred();else{const l=this._objectUrl=self.URL.createObjectURL(a);if(this.appendSource)try{s.removeAttribute("src");const c=self.ManagedMediaSource;s.disableRemotePlayback=s.disableRemotePlayback||c&&a instanceof c,pI(s),vse(s,l),s.load()}catch{s.src=l}else s.src=l}s.addEventListener("emptied",this._onMediaEmptied)}}assignMediaSource(e){var t,s;this.log(`${((t=this.transferData)==null?void 0:t.mediaSource)===e?"transferred":"created"} media source: ${(s=e.constructor)==null?void 0:s.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 s=this.tracks,r=t.tracks,i=r?Object.keys(r):null,a=i?i.length:0,l=()=>{Promise.resolve().then(()=>{this.media&&this.mediaSourceOpenOrEnded&&this._onMediaSourceOpen()})};if(r&&i&&a){if(!this.tracksReady){this.hls.config.startFragPrefetch=!0,this.log("attachTransferred: waiting for SourceBuffer track info");return}if(this.log(`attachTransferred: (bufferCodecEventsTotal ${this.bufferCodecEventsTotal})
121required tracks: ${jn(s,(c,d)=>c==="initSegment"?void 0:d)}; 122transfer tracks: ${jn(r,(c,d)=>c==="initSegment"?void 0:d)}}`),!lN(r,s)){t.mediaSource=null,t.tracks=void 0;const c=e.currentTime,d=this.details,h=Math.max(c,d?.fragments[0].start||0);if(h-c>1){this.log(`attachTransferred: waiting for playback to reach new tracks start time ${c} -> ${h}`);return}this.warn(`attachTransferred: resetting MediaSource for incompatible tracks ("${Object.keys(r)}"->"${Object.keys(s)}") start time: ${h} currentTime: ${c}`),this.onMediaDetaching(j.MEDIA_DETACHING,{}),this.onMediaAttaching(j.MEDIA_ATTACHING,t),e.currentTime=h;return}this.transferData=void 0,i.forEach(c=>{const d=c,h=r[d];if(h){const p=h.buffer;if(p){const m=this.fragmentTracker,y=h.id;if(m.hasFragments(y)||m.hasParts(y)){const S=Bt.getBuffered(p);m.detectEvictedFragments(d,S,y,null,!0)}const x=Pv(d),w=[d,p];this.sourceBuffers[x]=w,p.updating&&this.operationQueue&&this.operationQueue.prependBlocker(d),this.trackSourceBuffer(d,h)}}}),l(),this.bufferCreated()}else this.log("attachTransferred: MediaSource w/o SourceBuffers"),l()}get mediaSourceOpenOrEnded(){var e;const t=(e=this.mediaSource)==null?void 0:e.readyState;return t==="open"||t==="ended"}onMediaDetaching(e,t){const s=!!t.transferMedia;this.transferData=this.overrides=void 0;const{media:r,mediaSource:i,_objectUrl:a}=this;if(i){if(this.log(`media source ${s?"transferring":"detaching"}`),s)this.sourceBuffers.forEach(([l])=>{l&&this.removeBuffer(l)}),this.resetQueue();else{if(this.mediaSourceOpenOrEnded){const l=i.readyState==="open";try{const c=i.sourceBuffers;for(let d=c.length;d--;)l&&c[d].abort(),i.removeSourceBuffer(c[d]);l&&i.endOfStream()}catch(c){this.warn(`onMediaDetaching: ${c.message} while calling endOfStream`)}}this.sourceBufferCount&&this.onBufferReset()}i.removeEventListener("sourceopen",this._onMediaSourceOpen),i.removeEventListener("sourceended",this._onMediaSourceEnded),i.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(i.removeEventListener("startstreaming",this._onStartStreaming),i.removeEventListener("endstreaming",this._onEndStreaming)),this.mediaSource=null,this._objectUrl=null}r&&(r.removeEventListener("emptied",this._onMediaEmptied),s||(a&&self.URL.revokeObjectURL(a),this.mediaSrc===a?(r.removeAttribute("src"),this.appendSource&&pI(r),r.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null),this.hls.trigger(j.MEDIA_DETACHED,t)}onBufferReset(){this.sourceBuffers.forEach(([e])=>{e&&this.resetBuffer(e)}),this.initTracks()}resetBuffer(e){var t;const s=(t=this.tracks[e])==null?void 0:t.buffer;if(this.removeBuffer(e),s)try{var r;(r=this.mediaSource)!=null&&r.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(s)}catch(i){this.warn(`onBufferReset ${e}`,i)}delete this.tracks[e]}removeBuffer(e){this.removeBufferListeners(e),this.sourceBuffers[Pv(e)]=[null,null];const t=this.tracks[e];t&&(t.buffer=void 0)}resetQueue(){this.operationQueue&&this.operationQueue.destroy(),this.operationQueue=new xse(this.tracks)}onBufferCodecs(e,t){var s;const r=this.tracks,i=Object.keys(t);this.log(`BUFFER_CODECS: "${i}" (current SB count ${this.sourceBufferCount})`);const a="audiovideo"in t&&(r.audio||r.video)||r.audiovideo&&("audio"in t||"video"in t),l=!a&&this.sourceBufferCount&&this.media&&i.some(c=>!r[c]);if(a||l){this.warn(`Unsupported transition between "${Object.keys(r)}" and "${i}" SourceBuffers`);return}i.forEach(c=>{var d,h;const p=t[c],{id:m,codec:y,levelCodec:x,container:w,metadata:S,supplemental:_}=p;let L=r[c];const R=(d=this.transferData)==null||(d=d.tracks)==null?void 0:d[c],M=R!=null&&R.buffer?R:L,V=M?.pendingCodec||M?.codec,W=M?.levelCodec;L||(L=r[c]={buffer:void 0,listeners:[],codec:y,supplemental:_,container:w,levelCodec:x,metadata:S,id:m});const I=D0(V,W),k=I?.replace(fI,"$1");let P=D0(y,x);const N=(h=P)==null?void 0:h.replace(fI,"$1");P&&I&&k!==N&&(c.slice(0,5)==="audio"&&(P=D1(P,this.appendSource)),this.log(`switching codec ${V} to ${P}`),P!==(L.pendingCodec||L.codec)&&(L.pendingCodec=P),L.container=w,this.appendChangeType(c,w,P))}),(this.tracksReady||this.sourceBufferCount)&&(t.tracks=this.sourceBufferTracks),!this.sourceBufferCount&&(this.bufferCodecEventsTotal>1&&!this.tracks.video&&!t.video&&((s=t.audio)==null?void 0:s.id)==="main"&&(this.log("Main audio-only"),this.bufferCodecEventsTotal=1),this.mediaSourceOpenOrEnded&&this.checkPendingTracks())}get sourceBufferTracks(){return Object.keys(this.tracks).reduce((e,t)=>
122{const s=this.tracks[t];return e[t]={id:s.id,container:s.container,codec:s.codec,levelCodec:s.levelCodec},e},{})}appendChangeType(e,t,s){const r=`${t};codecs=${s}`,i={label:`change-type=${r}`,execute:()=>{const a=this.tracks[e];if(a){const l=a.buffer;l!=null&&l.changeType&&(this.log(`changing ${e} sourceBuffer type to ${r}`),l.changeType(r),a.codec=s,a.container=t)}this.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:a=>{this.warn(`Failed to change ${e} SourceBuffer type`,a)}};this.append(i,e,this.isPending(this.tracks[e]))}blockAudio(e){var t;const s=e.start,r=s+e.duration*.05;if(((t=this.fragmentTracker.getAppendedFrag(s,st.MAIN))==null?void 0:t.gap)===!0)return;const a={label:"block-audio",execute:()=>{var l;const c=this.tracks.video;(this.lastVideoAppendEnd>r||c!=null&&c.buffer&&Bt.isBuffered(c.buffer,r)||((l=this.fragmentTracker.getAppendedFrag(r,st.MAIN))==null?void 0:l.gap)===!0)&&(this.blockedAudioAppend=null,this.shiftAndExecuteNext("audio"))},onStart:()=>{},onComplete:()=>{},onError:l=>{this.warn("Error executing block-audio operation",l)}};this.blockedAudioAppend={op:a,frag:e},this.append(a,"audio",!0)}unblockAudio(){const{blockedAudioAppend:e,operationQueue:t}=this;e&&t&&(this.blockedAudioAppend=null,t.unblockAudio(e.op))}onBufferAppending(e,t){const{tracks:s}=this,{data:r,type:i,parent:a,frag:l,part:c,chunkMeta:d,offset:h}=t,p=d.buffering[i],{sn:m,cc:y}=l,x=self.performance.now();p.start=x;const w=l.stats.buffering,S=c?c.stats.buffering:null;w.start===0&&(w.start=x),S&&S.start===0&&(S.start=x);const _=s.audio;let L=!1;i==="audio"&&_?.container==="audio/mpeg"&&(L=!this.lastMpegAudioChunk||d.id===1||this.lastMpegAudioChunk.sn!==d.sn,this.lastMpegAudioChunk=d);const R=s.video,M=R?.buffer;if(M&&m!=="initSegment"){const I=c||l,k=this.blockedAudioAppend;if(i==="audio"&&a!=="main"&&!this.blockedAudioAppend&&!(R.ending||R.ended)){const N=I.start+I.duration*.05,F=M.buffered,z=this.currentOp("video");!F.length&&!z?this.blockAudio(I):!z&&!Bt.isBuffered(M,N)&&this.lastVideoAppendEnd<N&&this.blockAudio(I)}else if(i==="video"){const P=I.end;if(k){const N=k.frag.start;(P>N||P<this.lastVideoAppendEnd||Bt.isBuffered(M,N))&&this.unblockAudio()}this.lastVideoAppendEnd=P}}const V=(c||l).start,W={label:`append-${i}`,execute:()=>{var I;p.executeStart=self.performance.now();const k=(I=this.tracks[i])==null?void 0:I.buffer;k&&(L?this.updateTimestampOffset(k,V,.1,i,m,y):h!==void 0&&et(h)&&this.updateTimestampOffset(k,h,1e-6,i,m,y)),this.appendExecutor(r,i)},onStart:()=>{},onComplete:()=>{const I=self.performance.now();p.executeEnd=p.end=I,w.first===0&&(w.first=I),S&&S.first===0&&(S.first=I);const k={};this.sourceBuffers.forEach(([P,N])=>{P&&(k[P]=Bt.getBuffered(N))}),this.appendErrors[i]=0,i==="audio"||i==="video"?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger(j.BUFFER_APPENDED,{type:i,frag:l,part:c,chunkMeta:d,parent:l.type,timeRanges:k})},onError:I=>{var k;const P={type:xt.MEDIA_ERROR,parent:l.type,details:he.BUFFER_APPEND_ERROR,sourceBufferName:i,frag:l,part:c,chunkMeta:d,error:I,err:I,fatal:!1},N=(k=this.media)==null?void 0:k.error;if(I.code===DOMException.QUOTA_EXCEEDED_ERR||I.name=="QuotaExceededError"||"quota"in I)P.details=he.BUFFER_FULL_ERROR;else if(I.code===DOMException.INVALID_STATE_ERR&&this.mediaSourceOpenOrEnded&&!N)P.errorAction=$h(!0);else if(I.name===mL&&this.sourceBufferCount===0)P.errorAction=$h(!0);else{const F=++this.appendErrors[i];this.warn(`Failed ${F}/${this.hls.config.appendErrorMaxRetry} times to append segment in "${i}" sourceBuffer (${N||"no media error"}
122)`),(F>=this.hls.config.appendErrorMaxRetry||N)&&(P.fatal=!0)}this.hls.trigger(j.ERROR,P)}};this.log(`queuing "${i}" append sn: ${m}${c?" p: "+c.index:""} of ${l.type===st.MAIN?"level":"track"} ${l.level} cc: ${y}`),this.append(W,i,this.isPending(this.tracks[i]))}getFlushOp(e,t,s){return this.log(`queuing "${e}" remove ${t}-${s}`),{label:"remove",execute:()=>{this.removeExecutor(e,t,s)},onStart:()=>{},onComplete:()=>{this.hls.trigger(j.BUFFER_FLUSHED,{type:e})},onError:r=>{this.warn(`Failed to remove ${t}-${s} from "${e}" SourceBuffer`,r)}}}onBufferFlushing(e,t){const{type:s,startOffset:r,endOffset:i}=t;s?this.append(this.getFlushOp(s,r,i),s):this.sourceBuffers.forEach(([a])=>{a&&this.append(this.getFlushOp(a,r,i),a)})}onFragParsed(e,t){const{frag:s,part:r}=t,i=[],a=r?r.elementaryStreams:s.elementaryStreams;a[Ln.AUDIOVIDEO]?i.push("audiovideo"):(a[Ln.AUDIO]&&i.push("audio"),a[Ln.VIDEO]&&i.push("video"));const l=()=>{const c=self.performance.now();s.stats.buffering.end=c,r&&(r.stats.buffering.end=c);const d=r?r.stats:s.stats;this.hls.trigger(j.FRAG_BUFFERED,{frag:s,part:r,stats:d,id:s.type})};i.length===0&&this.warn(`Fragments must have at least one ElementaryStreamType set. type: ${s.type} level: ${s.level} sn: ${s.sn}`),this.blockBuffers(l,i).catch(c=>{this.warn(`Fragment buffered callback ${c}`),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 s;this.sourceBuffers.forEach(([a])=>{if(a){const l=this.tracks[a];(!t.type||t.type===a)&&(l.ending=!0,l.ended||(l.ended=!0,this.log(`${a} buffer reached EOS`)))}});const r=((s=this.overrides)==null?void 0:s.endOfStream)!==!1;this.sourceBufferCount>0&&!this.sourceBuffers.some(([a])=>{var l;return a&&!((l=this.tracks[a])!=null&&l.ended)})?r?(this.log("Queueing EOS"),this.blockUntilOpen(()=>{this.tracksEnded();const{mediaSource:a}=this;if(!a||a.readyState!=="open"){a&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${a.readyState}`);return}this.log("Calling mediaSource.endOfStream()"),a.endOfStream(),this.hls.trigger(j.BUFFERED_TO_END,void 0)})):(this.tracksEnded(),this.hls.trigger(j.BUFFERED_TO_END,void 0)):t.type==="video"&&this.unblockAudio()}tracksEnded(){this.sourceBuffers.forEach(([e])=>{if(e!==null){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===he.BUFFER_APPEND_ERROR&&t.frag){var s;const r=(s=t.errorAction)==null?void 0:s.nextAutoLevel;et(r)&&r!==t.frag.level&&this.resetAppendErrors()}}resetAppendErrors(){this.appendErrors={audio:0,video:0,audiovideo:0}}trimBuffers(){const{hls:e,details:t,media:s}=this;if(!s||t===null||!this.sourceBufferCount)return;const r=e.config,i=s.currentTime,a=t.levelTargetDuration,l=t.live&&r.liveBackBufferLength!==null?r.liveBackBufferLength:r.backBufferLength;if(et(l)&&l>=0){const d=Math.max(l,a),h=Math.floor(i/a)*a-d;this.flushBackBuffer(i,a,h)}const c=r.frontBufferFlushThreshold;if(et(c)&&c>0){const d=Math.max(r.maxBufferLength,c),h=Math.max(d,a),p=Math.floor(i/a)*a+h;this.flushFrontBuffer(i,a,p)}}flushBackBuffer(e,t,s){this.sourceBuffers.forEach(([r,i])=>{if(i){const l=Bt.getBuffered(i);if(l.length>0&&s>l.start(0)){var a;this.hls.trigger(j.BACK_BUFFER_REACHED,{bufferEnd:s});const c=this.tracks[r];if((a=this.details)!=null&&a.live)this.hls.trigger(j.LIVE_BACK_BUFFER_REACHED,{bufferEnd:s});else if(c!=null&&c.ended){this.log(`Cannot flush ${r} back buffer while SourceBuffer is in ended state`);return}this.hls.trigger(j.BUFFER_FLUSHING,{startOffset:0,endOffset:s,type:r})}}})}flushFrontBuffer(e,t,s){this.sourceBuffers.forEach(([r,i])=>{if(i){const a=Bt.getBuffered(i),l=a.length;if(l<2)return;const c=a.start(l-1),d=a.end(l-1);if(s>c||e>=c&&e<=d)return;this.hls.trigger(j.BUFFER_FLUSHING,{startOffset:c,endOffset:1/0,type:r})}})}getDurationAndRange(){var e;const{details:t,mediaSource:s}=this;if(!t||!this.media||s?.readyState!=="open")return null;const r=t.edge;
vendor: 5,138 bytes, line 122
122if(t.live&&this.hls.config.liveDurationInfinity){if(t.fragments.length&&s.setLiveSeekableRange){const d=Math.max(0,t.fragmentStart),h=Math.max(d,r);return{duration:1/0,start:d,end:h}}return{duration:1/0}}const i=(e=this.overrides)==null?void 0:e.duration;if(i)return et(i)?{duration:i}:null;const a=this.media.duration,l=et(s.duration)?s.duration:0;return r>l&&r>a||!et(a)?{duration:r}:null}updateMediaSource({duration:e,start:t,end:s}){const r=this.mediaSource;!this.media||!r||r.readyState!=="open"||(r.duration!==e&&(et(e)&&this.log(`Updating MediaSource duration to ${e.toFixed(3)}`),r.duration=e),t!==void 0&&s!==void 0&&(this.log(`MediaSource duration is set to ${r.duration}. Setting seekable range to ${t}-${s}.`),r.setLiveSeekableRange(t,s)))}get tracksReady(){const e=this.pendingTrackCount;return e>0&&(e>=this.bufferCodecEventsTotal||this.isPending(this.tracks.audiovideo))}checkPendingTracks(){const{bufferCodecEventsTotal:e,pendingTrackCount:t,tracks:s}=this;if(this.log(`checkPendingTracks (pending: ${t} codec events expected: ${e}) ${jn(s)}`),this.tracksReady){var r;const i=(r=this.transferData)==null?void 0:r.tracks;i&&Object.keys(i).length?this.attachTransferred():this.createSourceBuffers()}}bufferCreated(){if(this.sourceBufferCount){const e={};this.sourceBuffers.forEach(([t,s])=>{if(t){const r=this.tracks[t];e[t]={buffer:s,container:r.container,codec:r.codec,supplemental:r.supplemental,levelCodec:r.levelCodec,id:r.id,metadata:r.metadata}}}),this.hls.trigger(j.BUFFER_CREATED,{tracks:e}),this.log(`SourceBuffers created. Running queue: ${this.operationQueue}`),this.sourceBuffers.forEach(([t])=>{this.executeNext(t)})}else{const e=new Error("could not create source buffer for media codec(s)");this.hls.trigger(j.ERROR,{type:xt.MEDIA_ERROR,details:he.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:e,reason:e.message})}}createSourceBuffers(){const{tracks:e,sourceBuffers:t,mediaSource:s}=this;if(!s)throw new Error("createSourceBuffers called when mediaSource was null");for(const i in e){const a=i,l=e[a];if(this.isPending(l)){const c=this.getTrackCodec(l,a),d=`${l.container};codecs=${c}`;l.codec=c,this.log(`creating sourceBuffer(${d})${this.currentOp(a)?" Queued":""} ${jn(l)}`);try{const h=s.addSourceBuffer(d),p=Pv(a),m=[a,h];t[p]=m,l.buffer=h}catch(h){var r;this.error(`error while trying to add sourceBuffer: ${h.message}`),this.shiftAndExecuteNext(a),(r=this.operationQueue)==null||r.removeBlockers(),delete this.tracks[a],this.hls.trigger(j.ERROR,{type:xt.MEDIA_ERROR,details:he.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:h,sourceBufferName:a,mimeType:d,parent:l.id});return}this.trackSourceBuffer(a,l)}}this.bufferCreated()}getTrackCodec(e,t){const s=e.supplemental;let r=e.codec;s&&(t==="video"||t==="audiovideo")&&gm(s,"video")&&(r=pte(r,s));const i=D0(r,e.levelCodec);return i?t.slice(0,5)==="audio"?D1(i,this.appendSource):i:""}trackSourceBuffer(e,t){const s=t.buffer;if(!s)return;const r=this.getTrackCodec(t,e);this.tracks[e]={buffer:s,codec:r,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",(i,a)=>{const l=a.removedRanges;l!=null&&l.length&&this.hls.trigger(j.BUFFER_FLUSHED,{type:i})})}get mediaSrc(){var e,t;const s=((e=this.media)==null||(t=e.querySelector)==null?void 0:t.call(e,"source"))||this.media;return s?.src}onSBUpdateStart(e){const t=this.currentOp(e);t&&t.onStart()}onSBUpdateEnd(e){var t;if(((t=this.mediaSource)==null?void 0:t.readyState)==="closed"){this.resetBuffer(e);return}const s=this.currentOp(e);s&&(s.onComplete(),this.shiftAndExecuteNext(e))}onSBUpdateError(e,t){var s;const r=new Error(`${e} SourceBuffer error. MediaSource readyState: ${(s=this.mediaSource)==null?void 0:s.readyState}`);this.error(`${r}`,t),this.hls.trigger(j.ERROR,{type:xt.MEDIA_ERROR,details:he.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:r,fatal:!1});const i=this.currentOp(e);i&&i.onError(r)}updateTimestampOffset(e,t,s,r,i,a){const l=t-e.timestampOffset;Math.abs(l)>=s&&(this.log(`Updating ${r} SourceBuffer timestampOffset to ${t} (sn: ${i} cc: ${a})`),e.timestampOffset=t)}removeExecutor(e,t,s){const{media:r,mediaSource:i}=this,a=this.tracks[e],l=a?.buffer;if(!r||!i||!l){this.warn(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`),this.shiftAndExecuteNext(e);return}const c=et(r.duration)?r.duration:1/0,d=et(i.duration)?i.duration:1/0,h=Math.max(0,t),p=Math.min(s,c,d);p>h&&(!a.ending||a.ended)?(a.ended=!1,this.log(`Removing [${h},${p}] from the ${e} SourceBuffer`),l.remove(h,p)):this.shiftAndExecuteNext(e)}appendExecutor(e,t){const s=this.tracks[t],r=s?.buffer;if(!r)throw new yse(`Attempting to append to the ${t} SourceBuffer, but it does not exist`);s.ending=!1,s.ended=!1,r.appendBuffer(e)}blockUntilOpen(e){if(this.isUpdating()||this.isQueued())this.blockBuffers(e).catch(t=>{this.warn(`SourceBuffer blocked callback ${t}
122`),this.stepOperationQueue(this.sourceBufferTypes)});else try{e()}catch(t){this.warn(`Callback run without blocking ${this.operationQueue} ${t}`)}}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:s}=this,r=t.map(a=>this.appendBlocker(a));return t.length>1&&this.blockedAudioAppend&&this.unblockAudio(),Promise.all(r).then(a=>{s===this.operationQueue&&(e(),this.stepOperationQueue(this.sourceBufferTypes))})}stepOperationQueue(e){e.forEach(t=>{var s;const r=(s=this.tracks[t])==null?void 0:s.buffer;!r||r.updating||this.shiftAndExecuteNext(t)})}append(e,t,s){this.operationQueue&&this.operationQueue.append(e,t,s)}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,s){const r=this.tracks[e];if(!r)return;const i=r.buffer;if(!i)return;const a=s.bind(this,e);r.listeners.push({event:t,listener:a}),i.addEventListener(t,a)}removeBufferListeners(e){const t=this.tracks[e];if(!t)return;const s=t.buffer;s&&(t.listeners.forEach(r=>{s.removeEventListener(r.event,r.listener)}),t.listeners.length=0)}}function pI(n){const e=n.querySelectorAll("source");[].slice.call(e).forEach(t=>{n.removeChild(t)})}function vse(n,e){const t=self.document.createElement("source");t.type="video/mp4",t.src=e,n.appendChild(t)}function Pv(n){return n==="audio"?1:0}class cy{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(j.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(j.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(j.MANIFEST_PARSED,this.onManifestParsed,this),e.on(j.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(j.BUFFER_CODECS,this.onBufferCodecs,this),e.on(j.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:e}=this;e.off(j.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(j.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(j.MANIFEST_PARSED,this.onManifestParsed,this),e.off(j.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(j.BUFFER_CODECS,this.onBufferCodecs,this),e.off(j.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(e,t){const s=this.hls.levels[t.droppedLevel];this.isLevelAllowed(s)&&this.restrictedLevels.push({bitrate:s.bitrate,height:s.height,width:s.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 s=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,s.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onLevelsUpdated(e,t){this.timer&&et(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){this.clientRect=null;return}const e=this.hls.levels;if(e.length){const t=this.hls,s=this.getMaxLevel(e.length-1);s!==this.autoLevelCapping&&t.logger.log(`Setting autoLevelCapping to ${s}: ${e[s].height}p@${e[s].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),t.autoLevelCapping=s,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 s=t.filter((r,i)=>this.isLevelAllowed(r)&&i<=e);return this.clientRect=null,cy.getMaxLevelByMediaSize(s,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 s=e.getBoundingClientRect();t.width=s.width,t.height=s.height,!t.width&&!t.height&&(t.width=s.right-s.left||e.
vendor: 4,071 bytes, line 122
122width||0,t.height=s.bottom-s.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{}return Math.min(e,this.hls.config.maxDevicePixelRatio)}isLevelAllowed(e){return!this.restrictedLevels.some(s=>e.bitrate===s.bitrate&&e.width===s.width&&e.height===s.height)}static getMaxLevelByMediaSize(e,t,s){if(!(e!=null&&e.length))return-1;const r=(l,c)=>c?l.width!==c.width||l.height!==c.height:!0;let i=e.length-1;const a=Math.max(t,s);for(let l=0;l<e.length;l+=1){const c=e[l];if((c.width>=a||c.height>=a)&&r(c,e[l+1])){i=l;break}}return i}}const bse={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"},yi=bse,wse={HLS:"h"},Sse=wse;class Zo{constructor(e,t){Array.isArray(e)&&(e=e.map(s=>s instanceof Zo?s:new Zo(s))),this.value=e,this.params=t}}const Ese="Dict";function Tse(n){return Array.isArray(n)?JSON.stringify(n):n instanceof Map?"Map{}":n instanceof Set?"Set{}":typeof n=="object"?JSON.stringify(n):String(n)}function _se(n,e,t,s){return new Error(`failed to ${n} "${Tse(e)}" as ${t}`,{cause:s})}function el(n,e,t){return _se("serialize",n,e,t)}class xL{constructor(e){this.description=e}}const mI="Bare Item",Ise="Boolean";function Ase(n){if(typeof n!="boolean")throw el(n,Ise);return n?"?1":"?0"}function Cse(n){return btoa(String.fromCharCode(...n))}const kse="Byte Sequence";function Rse(n){if(ArrayBuffer.isView(n)===!1)throw el(n,kse);return`:${Cse(n)}:`}const Pse="Integer";function Nse(n){return n<-999999999999999||999999999999999<n}function yL(n){if(Nse(n))throw el(n,Pse);return n.toString()}function Lse(n){return`@${yL(n.getTime()/1e3)}`}function vL(n,e){if(n<0)return-vL(-n,e);const t=Math.pow(10,e);if(Math.abs(n*t%1-.5)<Number.EPSILON){const r=Math.floor(n*t);return(r%2===0?r:r+1)/t}else return Math.round(n*t)/t}const Dse="Decimal";function jse(n){const e=vL(n,3);if(Math.floor(Math.abs(e)).toString().length>12)throw el(n,Dse);const t=e.toString();return t.includes(".")?t:`${t}.0`}const Ose="String",Mse=/[\x00-\x1f\x7f]+/;function Fse(n){if(Mse.test(n))throw el(n,Ose);return`"${n.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function Use(n){return n.description||n.toString().slice(7,-1)}const Vse="Token";function gI(n){const e=Use(n);if(/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(e)===!1)throw el(e,Vse);return e}function hw(n){switch(typeof n){case"number":if(!et(n))throw el(n,mI);return Number.isInteger(n)?yL(n):jse(n);case"string":return Fse(n);case"symbol":return gI(n);case"boolean":return Ase(n);case"object":if(n instanceof Date)return Lse(n);if(n instanceof Uint8Array)return Rse(n);if(n instanceof xL)return gI(n);default:throw el(n,mI)}}const Bse="Key";function fw(n){if(/^[a-z*][a-z0-9\-_.*]*$/.test(n)===!1)throw el(n,Bse);return n}function xS(n){return n==null?"":Object.entries(n).map(([e,t])=>t===!0?`;${fw(e)}`:`;${fw(e)}=${hw(t)}`).join("")}function bL(n){return n instanceof Zo?`${hw(n.value)}${xS(n.params)}`:hw(n)}function zse(n){return`(${n.value.map(bL).join(" ")})${xS(n.params)}`}function $se(n,e={whitespace:!0}){if(typeof n!="object"||n==null)throw el(n,Ese);const t=n instanceof Map?n.entries():Object.entries(n),s=e?.whitespace?" ":"";return Array.from(t).map(([r,i])=>{i instanceof Zo||(i=new Zo(i));let a=fw(r);return i.value===!0?a+=xS(i.params):(a+="=",Array.isArray(i.value)?a+=zse(i):a+=bL(i)),a}).join(`,${s}`)}function wL(n,e){return $se(n,e)}const Po="CMCD-Object",hs="CMCD-Request",Vu="CMCD-Session",kc="CMCD-Status",Hse={br:Po,ab:Po,d:Po,ot:Po,tb:Po,tpb:Po,lb:Po,tab:Po,lab:Po,url:Po,pb:hs,bl:hs,tbl:hs,dl:hs,ltc:hs,mtp:hs,nor:hs,nrr:hs,rc:hs,sn:hs,sta:hs,su:hs,ttfb:hs,ttfbb:hs,ttlb:hs,cmsdd:hs,cmsds:hs,smrt:hs,df:hs,cs:hs,ts:hs,cid:Vu,pr:Vu,sf:Vu,sid:Vu,st:Vu,v:Vu,msd:Vu,bs:kc,bsd:kc,cdn:kc,rtp:kc,bg:kc,pt:kc,ec:kc,e:kc},Wse={REQUEST:hs};function Gse(n){return Object.keys(n).reduce((e,t)=>{var s;
122return(s=n[t])===null||s===void 0||s.forEach(r=>e[r]=t),e},{})}function Kse(n,e){const t={};if(!n)return t;const s=Object.keys(n),r=e?Gse(e):{};return s.reduce((i,a)=>{var l;const c=Hse[a]||r[a]||Wse.REQUEST,d=(l=i[c])!==null&&l!==void 0?l:i[c]={};return d[a]=n[a],i},t)}function qse(n){return["ot","sf","st","e","sta"].includes(n)}function Yse(n){return typeof n=="number"?et(n):n!=null&&n!==""&&n!==!1}const SL="event";function Qse(n,e){const t=new URL(n),s=new URL(e);if(t.origin!==s.origin)return n;const r=t.pathname.split("/").slice(1),i=s.pathname.split("/").slice(1,-1);for(;r[0]===i[0];)r.shift(),i.shift();for(;i.length;)i.shift(),r.unshift("..");return r.join("/")+t.search+t.hash}const F0=n=>Math.round(n),pw=(n,e)=>Array.isArray(n)?n.map(t=>pw(t,e)):n instanceof Zo&&typeof n.value=="string"?new Zo(pw(n.value,e),n.params):(e.baseUrl&&(n=Qse(n,e.baseUrl)),e.version===1?encodeURIComponent(n):n),a0=n=>F0(n/100)*100,Xse=(n,e)=>{let t=n;return e.version>=2&&(n instanceof Zo&&typeof n.value=="string"?t=new Zo([n]):typeof n=="string"&&(t=[n])),pw(t,e)},Jse={br:F0,d:F0,bl:a0,dl:a0,mtp:a0,nor:Xse,rtp:a0,tb:F0},EL="request",TL="response",yS=["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"],Zse=["e"],ere=/^[a-zA-Z0-9-.]+-[a-zA-Z0-9-.]+$/;function uy(n){return ere.test(n)}function tre(n){return yS.includes(n)||Zse.includes(n)||uy(n)}const _L=["d","dl","nor","ot","rtp","su"];function nre(n){return yS.includes(n)||_L.includes(n)||uy(n)}const sre=["cmsdd","cmsds","rc","smrt","ttfb","ttfbb","ttlb","url"];function rre(n){return yS.includes(n)||_L.includes(n)||sre.includes(n)||uy(n)}const ire=["bl","br","bs","cid","d","dl","mtp","nor","nrr","ot","pr","rtp","sf","sid","st","su","tb","v"];function are(n){return ire.includes(n)||uy(n)}const ore={[TL]:rre,[SL]:tre,[EL]:nre};function IL(n,e={}){const t={};if(n==null||typeof n!="object")return t;const s=e.version||n.v||1,r=e.reportingMode||EL,i=s===1?are:ore[r];let a=Object.keys(n).filter(i);const l=e.filter;typeof l=="function"&&(a=a.filter(l));const c=r===TL||r===SL;c&&!a.includes("ts")&&a.push("ts"),s>1&&!a.includes("v")&&a.push("v");const d=kn({},Jse,e.formatters),h={version:s,reportingMode:r,baseUrl:e.baseUrl};return a.sort().forEach(p=>{let m=n[p];const y=d[p];if(typeof y=="function"&&(m=y(m,h)),p==="v"){if(s===1)return;m=s}p=="pr"&&m===1||(c&&p==="ts"&&!et(m)&&(m=Date.now()),Yse(m)&&(qse(p)&&typeof m=="string"&&(m=new xL(m)),t[p]=m))}),t}function lre(n,e={}){const t={};if(!n)return t;const s=IL(n,e),r=Kse(s,e?.customHeaderMap);return Object.entries(r).reduce((i,[a,l])=>{const c=wL(l,{whitespace:!1});return c&&(i[a]=c),i},t)}function cre(n,e,t){return kn(n,lre(e,t))}const ure="CMCD";function dre(n,e={}){return n?wL(IL(n,e),{whitespace:!1}):""}function hre(n,e={}){if(!n)return"";const t=dre(n,e);return encodeURIComponent(t)}function fre(n,e={}){if(!n)return"";const t=hre(n,e);return`${ure}=${t}`}const xI=/CMCD=[^&#]+/;function pre(n,e,t){const s=fre(e,t);if(!s)return n;if(xI.test(n))return n.replace(xI,s);const r=n.includes("?")?"&":"?";return`${n}${r}${s}`}class AL{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=r=>{try{this.apply(r,{ot:yi.MANIFEST,su:!this.initialized})}catch(i){this.hls.logger.warn("Could not generate manifest CMCD data.",i)}},this.applyFragmentData=r=>{try{const{frag:i,part:a}=r,l=this.hls.levels[i.level],c=this.getObjectType(i),d={d:(a||i).duration*1e3,ot:c};(c===yi.VIDEO||c===yi.AUDIO||c==yi.MUXED)&&(d.br=l.bitrate/1e3,d.tb=this.getTopBandwidth(c)/1e3,d.bl=this.getBufferLength(c));const h=a?this.getNextPart(a):this.getNextFrag(i);h!=null&&h.url&&h.url!==i.url&&(d.nor=h.url),this.apply(r,d)}catch(i){this.hls.logger.warn("Could not generate segment CMCD data.",i)}},this.hls=e;const t=this.config=e.config,{cmcd:s}=t;s!=null&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=s.sessionId||e.sessionId,this.cid=s.contentId,this.useHeaders=s.useHeaders===!0,this.includeKeys=s.includeKeys,this.registerListeners())}registerListeners(){const e=this.hls;
122e.on(j.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(j.MEDIA_DETACHED,this.onMediaDetached,this),e.on(j.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const e=this.hls;e.off(j.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(j.MEDIA_DETACHED,this.onMediaDetached,this),e.off(j.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 s,r;this.audioBuffer=(s=t.tracks.audio)==null?void 0:s.buffer,this.videoBuffer=(r=t.tracks.video)==null?void 0:r.buffer}createData(){var e;return{v:1,sf:Sse.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){kn(t,this.createData());const s=t.ot===yi.INIT||t.ot===yi.VIDEO||t.ot===yi.MUXED;this.starved&&s&&(t.bs=!0,t.su=!0,this.starved=!1),t.su==null&&(t.su=this.buffering);const{includeKeys:r}=this;r&&(t=Object.keys(t).reduce((a,l)=>(r.includes(l)&&(a[l]=t[l]),a),{}));const i={baseUrl:e.url};this.useHeaders?(e.headers||(e.headers={}),cre(e.headers,t,i)):e.url=pre(e.url,t,i)}getNextFrag(e){var t;const s=(t=this.hls.levels[e.level])==null?void 0:t.details;if(s){const r=e.sn-s.startSN;return s.fragments[r+1]}}getNextPart(e){var t;const{index:s,fragment:r}=e,i=(t=this.hls.levels[r.level])==null||(t=t.details)==null?void 0:t.partList;if(i){const{sn:a}=r;for(let l=i.length-1;l>=0;l--){const c=i[l];if(c.index===s&&c.fragment.sn===a)return i[l+1]}}}getObjectType(e){const{type:t}=e;if(t==="subtitle")return yi.TIMED_TEXT;if(e.sn==="initSegment")return yi.INIT;if(t==="audio")return yi.AUDIO;if(t==="main")return this.hls.audioTracks.length?yi.VIDEO:yi.MUXED}getTopBandwidth(e){let t=0,s;const r=this.hls;if(e===yi.AUDIO)s=r.audioTracks;else{const i=r.maxAutoLevel,a=i>-1?i+1:r.levels.length;s=r.levels.slice(0,a)}return s.forEach(i=>{i.bitrate>t&&(t=i.bitrate)}),t>0?t:NaN}getBufferLength(e){const t=this.media,s=e===yi.AUDIO?this.audioBuffer:this.videoBuffer;return!s||!t?NaN:Bt.bufferInfo(s,t.currentTime,this.config.maxBufferHole).len*1e3}createPlaylistLoader(){const{pLoader:e}=this.config,t=this.applyPlaylistData,s=e||this.config.loader;return class{constructor(i){this.loader=void 0,this.loader=new s(i)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(i,a,l){t(i),this.loader.load(i,a,l)}}}createFragmentLoader(){const{fLoader:e}=this.config,t=this.applyFragmentData,s=e||this.config.loader;return class{constructor(i){this.loader=void 0,this.loader=new s(i)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(i,a,l){t(i),this.loader.load(i,a,l)}}}}const mre=3e5;class CL extends Pa{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(j.MANIFEST_LOADING,this.onManifestLoading,this),e.on(j.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(j.MANIFEST_PARSED,this.onManifestParsed,this),e.on(j.ERROR,this.onError,this)}unregisterListeners(){const e=this.hls;e&&(e.off(j.MANIFEST_LOADING,this.onManifestLoading,this),e.off(j.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(j.MANIFEST_PARSED,this.onManifestParsed,this),e.off(j.ERROR,this.onError,this))}pathways(){return(this.levels||[]).reduce((e,t)=>(e.indexOf(t.pathwayId)===-1&&e.push(t.pathwayId),e),[])}get pathwayPriority(){return this._pathwayPriority}set pathwayPriority(e){this.updatePathwayPriority(e)}
vendor: 6,684 bytes, line 122
122startLoad(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){const e=this.timeToLoad*1e3-(performance.now()-this.updated);if(e>0){this.scheduleRefresh(this.uri,e);return}}this.loadSteeringManifest(this.uri)}}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}clearTimeout(){this.reloadTimer!==-1&&(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(s=>s!==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:s}=t;s!==null&&(this.pathwayId=s.pathwayId,this.uri=s.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){const{errorAction:s}=t;if(s?.action===Ws.SendAlternateToPenaltyBox&&s.flags===vi.MoveAllAlternatesMatchingHost){const r=this.levels;let i=this._pathwayPriority,a=this.pathwayId;if(t.context){const{groupId:l,pathwayId:c,type:d}=t.context;l&&r?a=this.getPathwayForGroupId(l,d,a):c&&(a=c)}a in this.penalizedPathways||(this.penalizedPathways[a]=performance.now()),!i&&r&&(i=this.pathways()),i&&i.length>1&&(this.updatePathwayPriority(i),s.resolved=this.pathwayId!==a),t.details===he.BUFFER_APPEND_ERROR&&!t.fatal?s.resolved=!0:s.resolved||this.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${a} levels: ${r&&r.length} priorities: ${jn(i)} penalized: ${jn(this.penalizedPathways)}`)}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){const s=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${s}"`),t=this.getLevelsForPathway(s),this.pathwayId=s}return t.length!==e.length&&this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t}getLevelsForPathway(e){return this.levels===null?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){this._pathwayPriority=e;let t;const s=this.penalizedPathways,r=performance.now();Object.keys(s).forEach(i=>{r-s[i]>mre&&delete s[i]});for(let i=0;i<e.length;i++){const a=e[i];if(a in s)continue;if(a===this.pathwayId)return;const l=this.hls.nextLoadLevel,c=this.hls.levels[l];if(t=this.getLevelsForPathway(a),t.length>0){this.log(`Setting Pathway to "${a}"`),this.pathwayId=a,$N(t),this.hls.trigger(j.LEVELS_UPDATED,{levels:t});const d=this.hls.levels[l];c&&d&&this.levels&&(d.attrs["STABLE-VARIANT-ID"]!==c.attrs["STABLE-VARIANT-ID"]&&d.bitrate!==c.bitrate&&this.log(`Unstable Pathways change from bitrate ${c.bitrate} to ${d.bitrate}`),this.hls.nextLoadLevel=l);break}}}getPathwayForGroupId(e,t,s){const r=this.getLevelsForPathway(s).concat(this.levels||[]);for(let i=0;i<r.length;i++)if(t===Zt.AUDIO_TRACK&&r[i].hasAudioGroup(e)||t===Zt.SUBTITLE_TRACK&&r[i].hasSubtitleGroup(e))return r[i].pathwayId;return s}clonePathways(e){const t=this.levels;if(!t)return;const s={},r={};e.forEach(i=>{const{ID:a,"BASE-ID":l,"URI-REPLACEMENT":c}=i;if(t.some(h=>h.pathwayId===a))return;const d=this.getLevelsForPathway(l).map(h=>{const p=new Qn(h.attrs);p["PATHWAY-ID"]=a;const m=p.AUDIO&&`${p.AUDIO}_clone_${a}`,y=p.SUBTITLES&&`${p.SUBTITLES}_clone_${a}`;m&&(s[p.AUDIO]=m,p.AUDIO=m),y&&(r[p.SUBTITLES]=y,p.SUBTITLES=y);const x=kL(h.uri,p["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",c),w=new af({attrs:p,audioCodec:h.audioCodec,bitrate:h.bitrate,height:h.height,name:h.name,url:x,videoCodec:h.videoCodec,width:h.width});if(h.audioGroups)for(let S=1;S<h.audioGroups.length;S++)w.addGroupId("audio",`${h.audioGroups[S]}_clone_${a}`);if(h.subtitleGroups)for(let S=1;S<h.subtitleGroups.length;S++)w.addGroupId("text",`${h.subtitleGroups[S]}_clone_${a}`);return w});t.push(...d),yI(this.audioTracks,s,c,a),yI(this.subtitleTracks,r,c,a)})}loadSteeringManifest(e){const t=this.hls.config,s=t.loader;this.loader&&this.loader.destroy(),this.loader=new s(t);let r;try{r=new self.URL(e)}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${e}`);return}if(r.protocol!=="data:"){const h=(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate)|0;r.searchParams.set("_HLS_pathway",this.pathwayId),r.searchParams.set("_HLS_throughput",""+h)}const i={responseType:"json",url:r.href},a=t.steeringManifestLoadPolicy.default,l=a.errorRetry||a.timeoutRetry||{},c={loadPolicy:a,timeout:a.maxLoadTimeMs,maxRetry:l.maxNumRetry||0,retryDelay:l.retryDelayMs||0,maxRetryDelay:l.maxRetryDelayMs||0},d={onSuccess:(h,p,m,y)=>{this.log(`Loaded steering manifest: "${r}"`);const x=h.data;if(x?.VERSION!==1){this.log(`Steering VERSION ${x.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=x.TTL;const{"RELOAD-URI":w,"PATHWAY-CLONES":S,"PATHWAY-PRIORITY":_}=x;if(w)try{this.uri=new self.URL(w,r).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${w}`);return}this.scheduleRefresh(this.uri||m.url),S&&this.clonePathways(S);const L={steeringManifest:x,url:r.toString()};this.hls.trigger(j.STEERING_MANIFEST_LOADED,L),_&&this.updatePathwayPriority(_)},onError:(h,p,m,y)=>{if(this.log(`Error loading steering manifest: ${h.code} ${h.text} (${p.url})`),this.stopLoad(),h.code===410){this.enabled=!1,this.log(`Steering manifest ${p.url} no longer available`);return}let x=this.timeToLoad*1e3;if(h.code===429){const w=this.loader;if(typeof w?.getResponseHeader=="function"){const S=w.getResponseHeader("Retry-After");S&&(x=parseFloat(S)*1e3)}this.log(`Steering manifest ${p.url} rate limited`);return}this.scheduleRefresh(this.uri||p.url,x)},onTimeout:(h,p,m)=>{this.log(`Timeout loading steering manifest (${p.url})`),this.scheduleRefresh(this.uri||p.url)}};this.log(`Requesting steering manifest: ${r}`),this.loader.load(i,c,d)}scheduleRefresh(e,t=this.timeToLoad*1e3){this.clearTimeout(),this.reloadTimer=self.setTimeout(()=>{var s;const r=(s=this.hls)==null?void 0:s.media;if(r&&!r.ended){this.loadSteeringManifest(e);return}this.scheduleRefresh(e,this.timeToLoad*1e3)},t)}}function yI(n,e,t,s){n&&Object.keys(e).forEach(r=>{const i=n.filter(a=>a.groupId===r).map(a=>{const l=kn({},a);return l.details=void 0,l.attrs=new Qn(l.attrs),l.url=l.attrs.URI=kL(a.url,a.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",t),l.groupId=l.attrs["GROUP-ID"]=e[r],l.attrs["PATHWAY-ID"]=s,l});n.push(...i)})}function kL(n,e,t,s){const{HOST:r,PARAMS:i,[t]:a}=s;let l;e&&(l=a?.[e],l&&(n=l));const c=new self.URL(n);
122return r&&!l&&(c.host=r),i&&Object.keys(i).sort().forEach(d=>{d&&c.searchParams.set(d,i[d])}),c.href}class dd extends Pa{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=dd.CDMCleanupPromise?[dd.CDMCleanupPromise]:[],this.bannedKeyIds={},this.onMediaEncrypted=t=>{const{initDataType:s,initData:r}=t,i=`"${t.type}" event: init data type: "${s}"`;if(this.debug(i),r!==null){if(!this.keyFormatPromise){let a=Object.keys(this.keySystemAccessPromises);a.length||(a=wp(this.config));const l=a.map(Ev).filter(c=>!!c);this.keyFormatPromise=this.getKeyFormatPromise(l)}this.keyFormatPromise.then(a=>{const l=j0(a);if(s!=="sinf"||l!==Xn.FAIRPLAY){this.log(`Ignoring "${t.type}" event with init data type: "${s}" for selected key-system ${l}`);return}let c;try{const y=Hs(new Uint8Array(r)),x=lS(JSON.parse(y).sinf),w=xN(x);if(!w)throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");c=new Uint8Array(w.subarray(8,24))}catch(y){this.warn(`${i} Failed to parse sinf: ${y}`);return}const d=vr(c),{keyIdToKeySessionPromise:h,mediaKeySessions:p}=this;let m=h[d];for(let y=0;y<p.length;y++){const x=p[y],w=x.decryptdata;if(!w.keyId)continue;const S=vr(w.keyId);if(U1(c,w.keyId)||w.uri.replace(/-/g,"").indexOf(d)!==-1){if(m=h[S],!m)continue;if(w.pssh)break;delete h[S],w.pssh=new Uint8Array(r),w.keyId=c,m=h[d]=m.then(()=>this.generateRequestWithPreferredKeySession(x,s,r,"encrypted-event-key-match")),m.catch(_=>this.handleError(_));break}}m||this.handleError(new Error(`Key ID ${d} not encountered in playlist. Key-system sessions ${p.length}.`))}).catch(a=>this.handleError(a))}},this.onWaitingForKey=t=>{this.log(`"${t.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(j.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(j.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(j.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(j.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.on(j.DESTROYING,this.onDestroying,this)}unregisterListeners(){this.hls.off(j.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(j.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(j.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(j.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.off(j.DESTROYING,this.onDestroying,this)}getLicenseServerUrl(e){const{drmSystems:t,widevineLicenseUrl:s}=this.config,r=t?.[e];if(r)return r.licenseUrl;if(e===Xn.WIDEVINE&&s)return s}getLicenseServerUrlOrThrow(e){const t=this.getLicenseServerUrl(e);if(t===void 0)throw new Error(`no license server URL configured for key-system "${e}"`);return t}getServerCertificateUrl(e){const{drmSystems:t}=this.config,s=t?.[e];if(s)return s.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}attemptKeySystemAccess(e){const t=this.hls.levels,s=(a,l,c)=>!!a&&c.indexOf(a)===l,r=t.map(a=>a.audioCodec).filter(s),i=t.map(a=>a.videoCodec).filter(s);return r.length+i.length===0&&i.push("avc1.42e01e"),new Promise((a,l)=>{const c=d=>{const h=d.shift();this.getMediaKeysPromise(h,r,i).then(p=>a({keySystem:h,mediaKeys:p})).catch(p=>{d.length?c(d):p instanceof qi?l(p):l(new qi({type:xt.KEY_SYSTEM_ERROR,details:he.KEY_SYSTEM_NO_ACCESS,error:p,fatal:!0},p.message))})};c(e)})}requestMediaKeySystemAccess(e,t){const{requestMediaKeySystemAccessFunc:s}=this.config;if(typeof s!="function"){let r=`Configured requestMediaKeySystemAccess is not a function ${s}`;return cS===null&&self.location.protocol==="http:"&&(r=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(r))}return s(e,t)}getMediaKeysPromise(e,t,s){var r;const i=ene(e,t,s,this.config.drmSystemOptions||{});let a=this.keySystemAccessPromises[e],l=(r=a)==null?void 0:r.keySystemAccess;if(!l){this.log(`Requesting encrypted media "${e}" key-system access with config: ${jn(i)}`),l=this.requestMediaKeySystemAccess(e,i);const c=a=this.keySystemAccessPromises[e]={keySystemAccess:l};return l.catch(d=>{this.log(`Failed to obtain access to key-system "${e}": ${d}`)}),l.then(d=>{this.log(`Access for key-system "${d.keySystem}" obtained`);const h=this.fetchServerCertificate(e);this.log(`Create media-keys for "${e}"`);const p=c.mediaKeys=d.createMediaKeys().then(m=>(this.log(`Media-keys created for "${e}"`),c.hasMediaKeys=!0,h.then(y=>y?this.setMediaKeysServerCertificate(m,e,y):m)));return p.catch(m=>{this.error(`Failed to create media-keys for "${e}"}: ${m}`)}),p})}return l.then(()=>a.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:s}){this.log(`Creating key-system session "${t}" keyId: ${vr(e.keyId||[])} keyUri: ${e.uri}`);const r=s.createSession(),i={decryptdata:e,keySystem:t,mediaKeys:s,mediaKeysSession:r,keyStatus:"status-pending"};return this.mediaKeySessions.push(i),i}renewKeySession(e){const t=e.decryptdata;if(t.pssh){const s=this.createMediaKeySessionContext(e),r=o0(t),i="cenc";this.keyIdToKeySessionPromise[r]=this.generateRequestWithPreferredKeySession(s,i,t.pssh.buffer,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}updateKeySession(e,t){const s=e.mediaKeysSession;return this.log(`Updating key-session "${s.sessionId}" for keyId ${vr(e.decryptdata.keyId||[])} 123 } (data length: ${t.byteLength})`),s.update(t)}getSelectedKeySystemFormats(){return Object.keys(this.keySystemAccessPromises).map(e=>({keySystem:e,hasMediaKeys:this.keySystemAccessPromises[e].hasMediaKeys})).filter(({hasMediaKeys:e})=>!!e).map(({keySystem:e})=>Ev(e)).filter(e=>!!e)}getKeySystemAccess(e){return this.getKeySystemSelectionPromise(e).then(({keySystem:t,mediaKeys:s})=>this.attemptSetMediaKeys(t,s))}selectKeySystem(e){return new Promise((t,s)=>{this.getKeySystemSelectionPromise(e).then(({keySystem:r})=>{const i=Ev(r);i?t(i):s(new Error(`Unable to find format for key-system "${r}"`))}).catch(s)})}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=wp(this.config),s=e.map(j0).filter(r=>!!r&&t.indexOf(r)!==-1);return this.selectKeySystem(s)}getKeyStatus(e){const{mediaKeySessions:t}=this;for(let s=0;s<t.length;s++){const r=gre(e,t[s]);if(r)return r}}loadKey(e){const t=e.keyInfo.decryptdata,s=o0(t),r=this.bannedKeyIds[s];if(r||this.getKeyStatus(t)==="internal-error"){const l=vI(r||"internal-error",t);return this.handleError(l,e.frag),Promise.reject(l)}const i=`(keyId: ${s} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${i}`);const a=this.keyIdToKeySessionPromise[s];if(!a){const l=this.getKeySystemForKeyPromise(t).then(({keySystem:c,mediaKeys:d})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${i}`),this.attemptSetMediaKeys(c,d).then(()=>(this.throwIfDestroyed(),this.createMediaKeySessionContext({keySystem:c,mediaKeys:d,decryptdata:t}))))).then(c=>{const d="cenc",h=t.pssh?t.pssh.buffer:null;return this.generateRequestWithPreferredKeySession(c,d,h,"playlist-key")});return l.catch(c=>this.handleError(c,e.frag)),this.keyIdToKeySessionPromise[s]=l,l}return a.catch(l=>{if(l instanceof qi){const c=In({},l.data);this.getKeyStatus(t)==="internal-error"&&(c.decryptdata=t);const d=new qi(c,l.message);this.handleError(d,e.frag)}}),a}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e,t){if(this.hls)if(e instanceof qi){t&&(e.data.frag=t);const s=e.data.decryptdata;this.error(`${e.message}${s?` (${vr(s.keyId||[])})`:""}`),this.hls.trigger(j.ERROR,e.data)}else this.error(e.message),this.hls.trigger(j.ERROR,{type:xt.KEY_SYSTEM_ERROR,details:he.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0})}
123getKeySystemForKeyPromise(e){const t=o0(e),s=this.keyIdToKeySessionPromise[t];if(!s){const r=j0(e.keyFormat),i=r?[r]:wp(this.config);return this.attemptKeySystemAccess(i)}return s}getKeySystemSelectionPromise(e){if(e.length||(e=wp(this.config)),e.length===0)throw new qi({type:xt.KEY_SYSTEM_ERROR,details:he.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${jn({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}attemptSetMediaKeys(e,t){if(this.mediaResolved=void 0,this.mediaKeys===t)return Promise.resolve();const s=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);const r=Promise.all(s).then(()=>this.media?this.media.setMediaKeys(t):new Promise((i,a)=>{this.mediaResolved=()=>{if(this.mediaResolved=void 0,!this.media)return a(new Error("Attempted to set mediaKeys without media element attached"));this.mediaKeys=t,this.media.setMediaKeys(t).then(i).catch(a)}}));return this.mediaKeys=t,this.setMediaKeysQueue.push(r),r.then(()=>{this.log(`Media-keys set for "${e}"`),s.push(r),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(i=>s.indexOf(i)===-1)})}generateRequestWithPreferredKeySession(e,t,s,r){var i;const a=(i=this.config.drmSystems)==null||(i=i[e.keySystem])==null?void 0:i.generateRequest;if(a)try{const x=a.call(this.hls,t,s,e);if(!x)throw new Error("Invalid response from configured generateRequest filter");t=x.initDataType,s=x.initData?x.initData:null,e.decryptdata.pssh=s?new Uint8Array(s):null}catch(x){if(this.warn(x.message),this.hls&&this.hls.config.debug)throw x}if(s===null)return this.log(`Skipping key-session request for "${r}" (no initData)`),Promise.resolve(e);const l=o0(e.decryptdata),c=e.decryptdata.uri;this.log(`Generating key-session request for "${r}" keyId: ${l} URI: ${c} (init data type: ${t} length: ${s.byteLength})`);const d=new uS,h=e._onmessage=x=>{const w=e.mediaKeysSession;if(!w){d.emit("error",new Error("invalid state"));return}const{messageType:S,message:_}=x;this.log(`"${S}" message event for session "${w.sessionId}" message size: ${_.byteLength}`),S==="license-request"||S==="license-renewal"?this.renewLicense(e,_).catch(L=>{d.eventNames().length?d.emit("error",L):this.handleError(L)}):S==="license-release"?e.keySystem===Xn.FAIRPLAY&&this.updateKeySession(e,aw("acknowledged")).then(()=>this.removeSession(e)).catch(L=>this.handleError(L)):this.warn(`unhandled media key message type "${S}"`)},p=(x,w)=>{w.keyStatus=x;let S;x.startsWith("usable")?d.emit("resolved"):x==="internal-error"||x==="output-restricted"||x==="output-downscaled"?S=vI(x,w.decryptdata):x==="expired"?S=new Error(`key expired (keyId: ${l})`):x==="released"?S=new Error("key released"):x==="status-pending"||this.warn(`unhandled key status change "${x}" (keyId: ${l})`),S&&(d.eventNames().length?d.emit("error",S):this.handleError(S))},m=e._onkeystatuseschange=x=>{if(!e.mediaKeysSession){d.emit("error",new Error("invalid state"));return}const S=this.getKeyStatuses(e);if(!Object.keys(S).some(M=>S[M]!=="status-pending"))return;if(S[l]==="expired"){this.log(`Expired key ${jn(S)} in key-session "${e.mediaKeysSession.sessionId}"`),this.renewKeySession(e);return}let L=S[l];if(L)p(L,e);else{var R;e.keyStatusTimeouts||(e.keyStatusTimeouts={}),(R=e.keyStatusTimeouts)[l]||(R[l]=self.setTimeout(()=>{if(!e.mediaKeysSession||!this.mediaKeys)return;const V=this.getKeyStatus(e.decryptdata);if(V&&V!=="status-pending")return this.log(`No status for keyId ${l} in key-session "${e.mediaKeysSession.sessionId}". Using session key-status ${V} from other session.`),p(V,e);this.log(`key status for ${l} in key-session "${e.mediaKeysSession.sessionId}" timed out after 1000ms`),L="internal-error",p(L,e)},1e3)),this.log(`No status for keyId ${l} (${jn(S)}).`)}};ei(e.mediaKeysSession,"message",h),ei(e.mediaKeysSession,"keystatuseschange",m);const y=new Promise((x,w)=>{d.on("error",w),d.on("resolved",x)});return e.mediaKeysSession.generateRequest(t,s).then(()=>{this.log(`Request generated for key-session "${e.mediaKeysSession.sessionId}" keyId: ${l} URI: ${c}`)}).catch(x=>{throw new qi({type:xt.KEY_SYSTEM_ERROR,details:he.KEY_SYSTEM_NO_SESSION,error:x,decryptdata:e.decryptdata,fatal:!1},`Error generating key-session request: ${x}`)}).then(()=>y).catch(x=>(d.removeAllListeners(),this.removeSession(e).then(()=>{throw x}))).then(()=>(d.removeAllListeners(),e))}getKeyStatuses(e){const t={};
123return e.mediaKeysSession.keyStatuses.forEach((s,r)=>{if(typeof r=="string"&&typeof s=="object"){const l=r;r=s,s=l}const i="buffer"in r?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):new Uint8Array(r);if(e.keySystem===Xn.PLAYREADY&&i.length===16){const l=vr(i);t[l]=s,DN(i)}const a=vr(i);s==="internal-error"&&(this.bannedKeyIds[a]=s),this.log(`key status change "${s}" for keyStatuses keyId: ${a} key-session "${e.mediaKeysSession.sessionId}"`),t[a]=s}),t}fetchServerCertificate(e){const t=this.config,s=t.loader,r=new s(t),i=this.getServerCertificateUrl(e);return i?(this.log(`Fetching server certificate for "${e}"`),new Promise((a,l)=>{const c={responseType:"arraybuffer",url:i},d=t.certLoadPolicy.default,h={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},p={onSuccess:(m,y,x,w)=>{a(m.data)},onError:(m,y,x,w)=>{l(new qi({type:xt.KEY_SYSTEM_ERROR,details:he.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:x,response:In({url:c.url,data:void 0},m)},`"${e}" certificate request failed (${i}). Status: ${m.code} (${m.text})`))},onTimeout:(m,y,x)=>{l(new qi({type:xt.KEY_SYSTEM_ERROR,details:he.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:x,response:{url:c.url,data:void 0}},`"${e}" certificate request timed out (${i})`))},onAbort:(m,y,x)=>{l(new Error("aborted"))}};r.load(c,h,p)})):Promise.resolve()}setMediaKeysServerCertificate(e,t,s){return new Promise((r,i)=>{e.setServerCertificate(s).then(a=>{this.log(`setServerCertificate ${a?"success":"not supported by CDM"} (${s.byteLength}) on "${t}"`),r(e)}).catch(a=>{i(new qi({type:xt.KEY_SYSTEM_ERROR,details:he.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:a,fatal:!0},a.message))})})}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then(s=>this.updateKeySession(e,new Uint8Array(s)).catch(r=>{throw new qi({type:xt.KEY_SYSTEM_ERROR,details:he.KEY_SYSTEM_SESSION_UPDATE_FAILED,decryptdata:e.decryptdata,error:r,fatal:!1},r.message)}))}unpackPlayReadyKeyMessage(e,t){const s=String.fromCharCode.apply(null,new Uint16Array(t.buffer));if(!s.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;const r=new DOMParser().parseFromString(s,"application/xml"),i=r.querySelectorAll("HttpHeader");if(i.length>0){let h;for(let p=0,m=i.length;p<m;p++){var a,l;h=i[p];const y=(a=h.querySelector("name"))==null?void 0:a.textContent,x=(l=h.querySelector("value"))==null?void 0:l.textContent;y&&x&&e.setRequestHeader(y,x)}}const c=r.querySelector("Challenge"),d=c?.textContent;if(!d)throw new Error("Cannot find <Challenge> in key message");return aw(atob(d))}setupLicenseXHR(e,t,s,r){const i=this.config.licenseXhrSetup;return i?Promise.resolve().then(()=>{if(!s.decryptdata)throw new Error("Key removed");return i.call(this.hls,e,t,s,r)}).catch(a=>{if(!s.decryptdata)throw a;return e.open("POST",t,!0),i.call(this.hls,e,t,s,r)}).then(a=>(e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:a||r})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:r}))}requestLicense(e,t){const s=this.config.keyLoadPolicy.default;return new Promise((r,i)=>{const a=this.getLicenseServerUrlOrThrow(e.keySystem);this.log(`Sending license request to URL: ${a}`);const l=new XMLHttpRequest;l.responseType="arraybuffer",l.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return i(new Error("invalid state"));if(l.readyState===4)if(l.status===200){this._requestLicenseFailureCount=0;let c=l.response;this.log(`License received ${c instanceof ArrayBuffer?c.byteLength:c}`);const d=this.config.licenseResponseCallback;if(d)try{c=d.call(this.hls,l,a,e)}catch(h){this.error(h)}r(c)}else{const c=s.errorRetry,d=c?c.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>d||l.status>=400&&l.status<500)i(new qi({type:xt.KEY_SYSTEM_ERROR,details:he.KEY_SYSTEM_LICENSE_REQUEST_FAILED,decryptdata:e.decryptdata,fatal:!0,networkDetails:l,response:{url:a,data:void 0,code:l.status,text:l.statusText}},`License Request XHR failed (${a}). Status: ${l.status} (${l.statusText})`));else{const h=d-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${h} attempts left`),this.requestLicense(e,t).then(r,i)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=l,this.setupLicenseXHR(l,a,e,t).then(({xhr:c,licenseChallenge:d})=>{e.keySystem==Xn.PLAYREADY&&(d=this.unpackPlayReadyKeyMessage(c,d)),c.send(d)}).catch(i)})}onDestroying(){this.unregisterListeners(),this._clear()}onMediaAttached(e,t){if(!this.config.emeEnabled)return;const s=t.media;this.media=s,ei(s,"encrypted",this.onMediaEncrypted),ei(s,"waitingforkey",this.onWaitingForKey);const r=this.mediaResolved;r?r():this.mediaKeys=s.mediaKeys}onMediaDetached(){const e=this.media;e&&(Ti(e,"encrypted",this.onMediaEncrypted),Ti(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 s=this.media,r=this.mediaKeySessions.slice();this.mediaKeySessions=[],this.mediaKeys=null,zl.clearKeyUriToKeyIdMap();const i=r.length;
123dd.CDMCleanupPromise=Promise.all(r.map(a=>this.removeSession(a)).concat((s==null||(e=s.setMediaKeys(null))==null?void 0:e.catch(a=>{this.log(`Could not clear media keys: ${a}`),this.hls&&this.hls.trigger(j.ERROR,{type:xt.OTHER_ERROR,details:he.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR,fatal:!1,error:new Error(`Could not clear media keys: ${a}`)})}))||Promise.resolve())).catch(a=>{this.log(`Could not close sessions and clear media keys: ${a}`),this.hls&&this.hls.trigger(j.ERROR,{type:xt.OTHER_ERROR,details:he.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close sessions and clear media keys: ${a}`)})}).then(()=>{i&&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 s=t.reduce((r,i)=>(r.indexOf(i.keyFormat)===-1&&r.push(i.keyFormat),r),[]);this.log(`Selecting key-system from session-keys ${s.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(s)}}removeSession(e){const{mediaKeysSession:t,licenseXhr:s,decryptdata:r}=e;if(t){this.log(`Remove licenses and keys and close session "${t.sessionId}" keyId: ${vr(r?.keyId||[])}`),e._onmessage&&(t.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(t.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),s&&s.readyState!==XMLHttpRequest.DONE&&s.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;const i=this.mediaKeySessions.indexOf(e);i>-1&&this.mediaKeySessions.splice(i,1);const{keyStatusTimeouts:a}=e;a&&Object.keys(a).forEach(d=>self.clearTimeout(a[d]));const{drmSystemOptions:l}=this.config;return(nne(l)?new Promise((d,h)=>{self.setTimeout(()=>h(new Error("MediaKeySession.remove() timeout")),8e3),t.remove().then(d).catch(h)}):Promise.resolve()).catch(d=>{this.log(`Could not remove session: ${d}`),this.hls&&this.hls.trigger(j.ERROR,{type:xt.OTHER_ERROR,details:he.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR,fatal:!1,error:new Error(`Could not remove session: ${d}`)})}).then(()=>t.close()).catch(d=>{this.log(`Could not close session: ${d}`),this.hls&&this.hls.trigger(j.ERROR,{type:xt.OTHER_ERROR,details:he.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close session: ${d}`)})})}return Promise.resolve()}}dd.CDMCleanupPromise=void 0;function o0(n){if(!n)throw new Error("Could not read keyId of undefined decryptdata");if(n.keyId===null)throw new Error("keyId is null");return vr(n.keyId)}function gre(n,e){if(n.keyId&&e.mediaKeysSession.keyStatuses.has(n.keyId))return e.mediaKeysSession.keyStatuses.get(n.keyId);if(n.matches(e.decryptdata))return e.keyStatus}class qi 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 vI(n,e){const t=n==="output-restricted",s=t?he.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:he.KEY_SYSTEM_STATUS_INTERNAL_ERROR;return new qi({type:xt.KEY_SYSTEM_ERROR,details:s,fatal:!1,decryptdata:e},t?"HDCP level output restricted":`key status changed to "${n}"`)}class RL{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(j.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(j.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListeners(){this.hls.off(j.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(j.MEDIA_DETACHING,this.onMediaDetaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){const s=this.hls.config;if(s.capLevelOnFPSDrop){const r=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=r,r&&typeof r.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),s.fpsDroppedMonitoringPeriod)}}onMediaDetaching(){this.media=null}checkFPS(e,t,s){const r=performance.now();if(t){if(this.lastTime){const i=r-this.lastTime,a=s-this.lastDroppedFrames,l=t-this.lastDecodedFrames,c=1e3*a/i,d=this.hls;if(d.trigger(j.FPS_DROP,{currentDropped:a,currentDecoded:l,totalDroppedFrames:s}),c>0&&a>d.config.fpsDroppedMonitoringThreshold*l){let h=d.currentLevel;d.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+h),h>0&&(d.autoLevelCapping===-1||d.autoLevelCapping>
vendor: 9,937 bytes, line 123
123=h)&&(h=h-1,d.trigger(j.FPS_DROP_LEVEL_CAPPING,{level:h,droppedLevel:d.currentLevel}),d.autoLevelCapping=h,this.streamController.nextLevelSwitch())}}this.lastTime=r,this.lastDroppedFrames=s,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)}}function PL(n,e){let t;try{t=new Event("addtrack")}catch{t=document.createEvent("Event"),t.initEvent("addtrack",!1,!1)}t.track=n,e.dispatchEvent(t)}function NL(n,e){const t=n.mode;if(t==="disabled"&&(n.mode="hidden"),n.cues&&!n.cues.getCueById(e.id))try{if(n.addCue(e),!n.cues.getCueById(e.id))throw new Error(`addCue is failed for: ${e}`)}catch(s){An.debug(`[texttrack-utils]: ${s}`);try{const r=new self.TextTrackCue(e.startTime,e.endTime,e.text);r.id=e.id,n.addCue(r)}catch(r){An.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${r}`)}}t==="disabled"&&(n.mode=t)}function Ch(n,e){const t=n.mode;if(t==="disabled"&&(n.mode="hidden"),n.cues)for(let s=n.cues.length;s--;)e&&n.cues[s].removeEventListener("enter",e),n.removeCue(n.cues[s]);t==="disabled"&&(n.mode=t)}function mw(n,e,t,s){const r=n.mode;if(r==="disabled"&&(n.mode="hidden"),n.cues&&n.cues.length>0){const i=yre(n.cues,e,t);for(let a=0;a<i.length;a++)(!s||s(i[a]))&&n.removeCue(i[a])}r==="disabled"&&(n.mode=r)}function xre(n,e){if(e<=n[0].startTime)return 0;const t=n.length-1;if(e>n[t].endTime)return-1;let s=0,r=t,i;for(;s<=r;)if(i=Math.floor((r+s)/2),e<n[i].startTime)r=i-1;else if(e>n[i].startTime&&s<t)s=i+1;else return i;return n[s].startTime-e<e-n[r].startTime?s:r}function yre(n,e,t){const s=[],r=xre(n,e);if(r>-1)for(let i=r,a=n.length;i<a;i++){const l=n[i];if(l.startTime>=e&&l.endTime<=t)s.push(l);else if(l.startTime>t)return s}return s}function U0(n){const e=[];for(let t=0;t<n.length;t++){const s=n[t];(s.kind==="subtitles"||s.kind==="captions")&&s.label&&e.push(n[t])}return e}class LL extends ly{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 t=null;const s=U0(this.media.textTracks);for(let i=0;i<s.length;i++)if(s[i].mode==="hidden")t=s[i];else if(s[i].mode==="showing"){t=s[i];break}const r=this.findTrackForTextTrack(t);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(j.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(j.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(j.MANIFEST_LOADING,this.onManifestLoading,this),e.on(j.MANIFEST_PARSED,this.onManifestParsed,this),e.on(j.LEVEL_LOADING,this.onLevelLoading,this),e.on(j.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(j.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(j.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(j.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(j.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(j.MANIFEST_LOADING,this.onManifestLoading,this),e.off(j.MANIFEST_PARSED,this.onManifestParsed,this),e.off(j.LEVEL_LOADING,this.onLevelLoading,this),e.off(j.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(j.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(j.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 s=this.media;if(!s)return;const r=!!t.transferMedia;if(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||s.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),this.subtitleTrack=-1,this.media=null,r)return;U0(s.textTracks).forEach(a=>{Ch(a)})}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:s,groupId:r,details:i}=t,a=this.tracksInGroup[s];if(!a||a.groupId!==r){this.warn(`Subtitle track with id:${s} and group:${r} not found in active group ${a?.groupId}`);return}const l=a.details;a.details=t.details,this.log(`Subtitle track ${s} "${a.name}" lang:${a.lang} group:${r} loaded [${i.startSN}-${i.endSN}]`),s===this.trackId&&this.playlistLoaded(s,t,l)}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 s=t.subtitleGroups||null,r=this.groupIds;let i=this.currentTrack;if(!s||r?.length!==s?.length||s!=null&&s.some(a=>r?.indexOf(a)===-1)){this.groupIds=s,this.trackId=-1,this.currentTrack=null;const a=this.tracks.filter(h=>!s||s.indexOf(h.groupId)!==-1);if(a.length)this.selectDefaultTrack&&!a.some(h=>h.default)&&(this.selectDefaultTrack=!1),a.forEach((h,p)=>{h.id=p});else if(!i&&!this.tracksInGroup.length)return;this.tracksInGroup=a;const l=this.hls.config.subtitlePreference;if(!i&&l){this.selectDefaultTrack=!1;const h=$o(l,a);if(h>-1)i=a[h];else{const p=$o(l,this.tracks);i=this.tracks[p]}}let c=this.findTrackId(i);c===-1&&i&&(c=this.findTrackId(null));const d={subtitleTracks:a};this.log(`Updating subtitle tracks, ${a.length} track(s) found in "${s?.join(",")}" group-id`),this.hls.trigger(j.SUBTITLE_TRACKS_UPDATED,d),c!==-1&&this.trackId===-1&&this.setSubtitleTrack(c)}}findTrackId(e){const t=this.tracksInGroup,s=this.selectDefaultTrack;for(let r=0;r<t.length;r++){const i=t[r];if(!(s&&!i.default||!s&&!e)&&(!e||ud(i,e)))return r}if(e){for(let r=0;r<t.length;r++){const i=t[r];if(wm(e.attrs,i.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return r}for(let r=0;r<t.length;r++){const i=t[r];if(wm(e.attrs,i.attrs,["LANGUAGE"]))return r}}return-1}findTrackForTextTrack(e){if(e){const t=this.tracksInGroup;for(let s=0;s<t.length;s++){const r=t[s];if(dw(r,e))return s}}return-1}onError(e,t){t.fatal||!t.context||t.context.type===Zt.SUBTITLE_TRACK&&t.context.id===this.trackId&&(!this.groupIds||this.groupIds.indexOf(t.context.groupId)!==-1)&&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(e.id===-1)return this.setSubtitleTrack(-1),null;const t=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,t.length){const s=this.currentTrack;if(s&&ud(e,s))return s;const r=$o(e,this.tracksInGroup);if(r>-1){const i=this.tracksInGroup[r];return this.setSubtitleTrack(r),i}else{if(s)return null;{const i=$o(e,t);if(i>-1)return t[i]}}}}return null}loadPlaylist(e){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentTrack)&&this.scheduleLoading(this.currentTrack,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);const s=e.id,r=e.groupId,i=this.getUrlWithDirectives(e.url,t),a=e.details,l=a?.age;this.log(`Loading subtitle ${s} "${e.name}" lang:${e.lang} group:${r}${t?.msn!==void 0?" at sn "+t.msn+" part "+t.part:""}${l&&a.live?" age "+l.toFixed(1)+(a.type&&" "+a.type||""):""} ${i}`),this.hls.trigger(j.SUBTITLE_TRACK_LOADING,{url:i,id:s,groupId:r,deliveryDirectives:t||null,track:e})}toggleTrackModes(){const{media:e}=this;if(!e)return;const t=U0(e.textTracks),s=this.currentTrack;let r;if(s&&(r=t.filter(i=>dw(s,i))[0],r||this.warn(`Unable to find subtitle TextTrack with name "${s.name}" and language "${s.lang}"`)),[].slice.call(t).forEach(i=>{i.mode!=="disabled"&&i!==r&&(i.mode="disabled")}),r){const i=this.subtitleDisplay?"showing":"hidden";r.mode!==i&&(r.mode=i)}}setSubtitleTrack(e){const t=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(e<-1||e>=t.length||!et(e)){this.warn(`Invalid subtitle track id: ${e}`);return}this.selectDefaultTrack=!1;const s=this.currentTrack,r=t[e]||null;if(this.trackId=e,this.currentTrack=r,this.toggleTrackModes(),!r){this.hls.trigger(j.SUBTITLE_TRACK_SWITCH,{id:e});return}const i=!!r.details&&!r.details.live;if(e===this.trackId&&r===s&&i)return;this.log(`Switching to subtitle-track ${e}`+(r?` "${r.name}" lang:${r.lang} group:${r.groupId}`:""));const{id:a,groupId:l="",name:c,type:d,url:h}=r;this.hls.trigger(j.SUBTITLE_TRACK_SWITCH,{id:a,groupId:l,name:c,type:d,url:h});const p=this.switchParams(r.url,s?.details,r.details);this.loadPlaylist(p)}}function vre(){try{return crypto.randomUUID()}catch{try{const e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch{let t=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,r=>{const i=(t+Math.random()*16)%16|0;return t=Math.floor(t/16),(r=="x"?i:i&3|8).toString(16)})}}}function Vp(n){let e=5381,t=n.length;for(;t;
vendor: 8,471 bytes, line 123
123)e=e*33^n.charCodeAt(--t);return(e>>>0).toString()}const Wh=.025;let $1=(function(n){return n[n.Point=0]="Point",n[n.Range=1]="Range",n})({});function bre(n,e,t){return`${n.identifier}-${t+1}-${Vp(e)}`}class wre{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,(e=this.assetListLoader)==null||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 s=this.playoutLimit;return e<=0||isNaN(s)?!1:s===0?!0:(((t=this.assetList[e])==null?void 0:t.startOffset)||0)>s}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 Nv(e,t)}return e}get startOffset(){return this.cue.pre?0:this.startTime}get startIsAligned(){if(this.startTime===0||this.snapOptions.out)return!0;const e=this.dateRange.tagAnchor;if(e){const t=this.dateRange.startTime,s=Nv(t,e);return t-s<.1}return!1}get resumptionOffset(){const e=this.resumeOffset,t=et(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 Nv(e,t)}return e}get appendInPlace(){return this.appendInPlaceStarted?!0:this.appendInPlaceDisabled?!1:!!(!this.cue.once&&!this.cue.pre&&this.startIsAligned&&(isNaN(this.playoutLimit)&&isNaN(this.resumeOffset)||this.resumeOffset&&this.duration&&Math.abs(this.resumeOffset-this.duration)<Wh))}set appendInPlace(e){if(this.appendInPlaceStarted){this.resetOnResume=!e;return}this.appendInPlaceDisabled=!e}get timelineStart(){return this._timelineStart!==null?this._timelineStart:this.startTime}set timelineStart(e){this._timelineStart=e}get duration(){const e=this.playoutLimit;let t;return this._duration!==null?t=this._duration:this.dateRange.duration?t=this.dateRange.duration:t=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 this.dateRange.attr["X-TIMELINE-OCCUPIES"]==="RANGE"?$1.Range:$1.Point}get supplementsPrimary(){return this.dateRange.attr["X-TIMELINE-STYLE"]==="PRIMARY"}get contentMayVary(){return this.dateRange.attr["X-CONTENT-MAY-VARY"]!=="NO"}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||this.assetListResponse!==null}toString(){return Sre(this)}}function Nv(n,e){return n-e.start<e.duration/2&&!(Math.abs(n-(e.start+e.duration))<Wh)?e.start:e.start+e.duration}function DL(n,e,t){const s=new self.URL(n,t);return s.protocol!=="data:"&&s.searchParams.set("_HLS_primary_id",e),s}function Lv(n,e){for(;(t=n.assetList[++e])!=null&&t.error;)var t;return e}function Sre(n){return`["${n.identifier}" ${n.cue.pre?"<pre>":n.cue.post?"<post>":""}${n.timelineStart.toFixed(2)}-${n.resumeTime.toFixed(2)}]`}function Th(n){const e=n.timelineStart,t=n.duration||0;return`["${n.identifier}" ${e.toFixed(2)}-${(e+t).toFixed(2)}]`}class Ere{constructor(e,t,s,r){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(j.PLAYOUT_LIMIT_REACHED,{})};const i=this.hls=new e(t);this.interstitial=s,this.assetItem=r;const a=()=>{this.hasDetails=!0};i.once(j.LEVEL_LOADED,a),i.once(j.AUDIO_TRACK_LOADED,a),i.once(j.SUBTITLE_TRACK_LOADED,a),i.on(j.MEDIA_ATTACHING,(l,{media:c})=>{this.removeMediaListeners(),this.mediaAttached=c,this.interstitial.playoutLimit&&(c.addEventListener("timeupdate",this.checkPlayout),this.appendInPlace&&i.on(j.BUFFER_APPENDED,()=>{const h=this.bufferedEnd;this.reachedPlayout(h)&&(this._bufferedEosTime=h,i.trigger(j.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=DL(t,e.config.primarySessionId||"").href}catch{}e.loadSource(t)}}bufferedInPlaceToEnd(e){var t;if(!this.appendInPlace)return!1;if((t=this.hls)!=null&&t.bufferedToEnd)return!0;if(!e)return!1;const s=Math.min(this._bufferedEosTime||1/0,this.duration),r=this.timelineOffset,i=Bt.bufferInfo(e,r,0);return this.getAssetTime(i.end)>=s-.02}reachedPlayout(e){const s=this.interstitial.playoutLimit;return this.startOffset+e>=s}get destroyed(){var e;return!((e=this.hls)!=null&&e.userConfig)}get assetId(){return this.assetItem.identifier}get interstitialId(){return this.assetItem.parentIdentifier}get media(){var e;return((e=this.hls)==null?void 0:e.media)||null}get bufferedEnd(){const e=this.media||this.mediaAttached;if(!e)return this._bufferedEosTime?this._bufferedEosTime:this.currentTime;const t=Bt.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 s=t-this.startOffset;if(s>0&&s<e)return s}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((e=this.hls)==null?void 0:e.config.timelineOffset)||0}set timelineOffset(e){const t=this.timelineOffset;if(e!==t){const s=e-t;if(Math.abs(s)>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,s=this.duration;return Math.min(Math.max(0,e-t),s)}removeMediaListeners(){const e=this.mediaAttached;e&&(this._currentTime=e.currentTime,this.bufferSnapShot(),e.removeEventListener("timeupdate",this.checkPlayout))}bufferSnapShot(){if(this.mediaAttached){var e;(e=this.hls)!=null&&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(),(t=this.hls)==null||t.attachMedia(e)}detachMedia(){var e;this.removeMediaListeners(),this.mediaAttached=null,(e=this.hls)==null||e.detachMedia()}resumeBuffering(){var e;(e=this.hls)==null||e.resumeBuffering()}pauseBuffering(){var e;(e=this.hls)==null||e.pauseBuffering()}transferMedia(){var e;return this.bufferSnapShot(),((e=this.hls)==null?void 0:e.transferMedia())||null}resetDetails(){const e=this.hls;if(e&&this.hasDetails){e.stopLoad();const t=s=>delete s.details;e.levels.forEach(t),e.allAudioTracks.forEach(t),e.allSubtitleTracks.forEach(t),this.hasDetails=!1}}on(e,t,s){var r;(r=this.hls)==null||r.on(e,t)}once(e,t,s){var r;(r=this.hls)==null||r.once(e,t)}off(e,t,s){var r;(r=this.hls)==null||r.off(e,t)}toString(){var e;return`HlsAssetPlayer: ${Th(this.assetItem)} ${(e=this.hls)==null?void 0:e.sessionId} ${this.appendInPlace?"append-in-place":""}`}}const bI=.033;class Tre extends Pa{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={}
vendor: 2,217 bytes, line 123
123,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((s,r)=>e<=r.startOffset&&t>r.startOffset?(delete r.error,s+1):s,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 s=-1;e.nextEvent?s=this.findEventIndex(e.nextEvent.identifier)-1:e.previousEvent&&(s=this.findEventIndex(e.previousEvent.identifier)+1);const r=this.items;if(r)for(r[s]||(t===void 0&&(t=e.start),s=this.findItemIndexAtTime(t));s>=0&&(i=r[s])!=null&&i.event;){var i;s--}return s}findItemIndexAtTime(e,t){const s=this.items;if(s)for(let r=0;r<s.length;r++){let i=s[r];if(t&&t!=="primary"&&(i=i[t]),e===i.start||e>i.start&&e<i.end)return r}return-1}findJumpRestrictedIndex(e,t){const s=this.items;if(s)for(let r=e;r<=t&&s[r];r++){const i=s[r].event;if(i!=null&&i.restrictions.jump&&!i.appendInPlace)return r}return-1}findEventIndex(e){const t=this.items;if(t)for(let r=t.length;r--;){var s;if(((s=t[r].event)==null?void 0:s.identifier)===e)return r}return-1}findAssetIndex(e,t){const s=e.assetList,r=s.length;if(r>1)for(let i=0;i<r;i++){const a=s[i];if(!a.error){const l=a.timelineStart;if(t===l||t>l&&(t<l+(a.duration||0)||i===r-1))return i}}return 0}get assetIdAtEnd(){var e;const t=(e=this.items)==null||(e=e[this.length-1])==null?void 0:e.event;if(t){const s=t.assetList,r=s[s.length-1];if(r)return r.identifier}return null}parseInterstitialDateRanges(e,t){const s=e.main.details,{dateRanges:r}=s,i=this.events,a=this.parseDateRanges(r,{url:s.url},t),l=Object.keys(r),c=i?i.filter(d=>!l.includes(d.identifier)):[];a.length&&a.sort((d,h)=>{const p=d.cue.pre,m=d.cue.post,y=h.cue.pre,x=h.cue.post;if(p&&!y)return-1;if(y&&!p||m&&!x)return 1;if(x&&!m)return-1;if(!p&&!y&&!m&&!x){const w=d.startTime,S=h.startTime;if(w!==S)return w-S}return d.dateRange.tagOrder-h.dateRange.tagOrder}),this.events=a,c.forEach(d=>{this.removeEvent(d)}),this.updateSchedule(e,c)}updateSchedule(e,t=[],s=!1){const r=this.events||[];
vendor: 19,468 bytes, lines 123-124
123if(r.length||t.length||this.length<2){const i=this.items,a=this.parseSchedule(r,e);(s||t.length||i?.length!==a.length||a.some((c,d)=>Math.abs(c.playout.start-i[d].playout.start)>.005||Math.abs(c.playout.end-i[d].playout.end)>.005))&&(this.items=a,this.onScheduleUpdate(t,i))}}parseDateRanges(e,t,s){const r=[],i=Object.keys(e);for(let a=0;a<i.length;a++){const l=i[a],c=e[l];if(c.isInterstitial){let d=this.eventMap[l];d?d.setDateRange(c):(d=new wre(c,t),this.eventMap[l]=d,s===!1&&(d.appendInPlace=s)),r.push(d)}}return r}parseSchedule(e,t){const s=[],r=t.main.details,i=r.live?1/0:r.edge;let a=0;if(e=e.filter(c=>!c.error&&!(c.cue.once&&c.hasPlayed)),e.length){this.resolveOffsets(e,t);let c=0,d=0;if(e.forEach((h,p)=>{const m=h.cue.pre,y=h.cue.post,x=e[p-1]||null,w=h.appendInPlace,S=y?i:h.startOffset,_=h.duration,L=h.timelineOccupancy===$1.Range?_:0,R=h.resumptionOffset,M=x?.startTime===S,V=S+h.cumulativeDuration;let W=w?V+_:S+R;if(m||!y&&S<=0){const k=d;d+=L,h.timelineStart=V;const P=a;a+=_,s.push({event:h,start:V,end:W,playout:{start:P,end:a},integrated:{start:k,end:d}})}else if(S<=i){if(!M){const N=S-c;if(N>bI){const F=c,z=d;d+=N;const U=a;a+=N;const fe={previousEvent:e[p-1]||null,nextEvent:h,start:F,end:F+N,playout:{start:U,end:a},integrated:{start:z,end:d}};s.push(fe)}else N>0&&x&&(x.cumulativeDuration+=N,s[s.length-1].end=S)}y&&(W=V),h.timelineStart=V;const k=d;d+=L;const P=a;a+=_,s.push({event:h,start:V,end:W,playout:{start:P,end:a},integrated:{start:k,end:d}})}else return;const I=h.resumeTime;y||I>i?c=i:c=I}),c<i){var l;const h=c,p=d,m=i-c;d+=m;const y=a;a+=m,s.push({previousEvent:((l=s[s.length-1])==null?void 0:l.event)||null,nextEvent:null,start:c,end:h+m,playout:{start:y,end:a},integrated:{start:p,end:d}})}this.setDurations(i,a,d)}else s.push({previousEvent:null,nextEvent:null,start:0,end:i,playout:{start:0,end:i},integrated:{start:0,end:i}}),this.setDurations(i,i,i);return s}setDurations(e,t,s){this.durations={primary:e,playout:t,integrated:s}}resolveOffsets(e,t){const s=t.main.details,r=s.live?1/0:s.edge;let i=0,a=-1;e.forEach((l,c)=>{const d=l.cue.pre,h=l.cue.post,p=d?0:h?r:l.startTime;this.updateAssetDurations(l),a===p?l.cumulativeDuration=i:(i=0,a=p),!h&&l.snapOptions.in&&(l.resumeAnchor=Id(null,s.fragments,l.startOffset+l.resumptionOffset,0,0)||void 0),l.appendInPlace&&!l.appendInPlaceStarted&&(this.primaryCanResumeInPlaceAt(l,t)||(l.appendInPlace=!1)),!l.appendInPlace&&c+1<e.length&&e[c+1].startTime-e[c].resumeTime<bI&&(e[c+1].appendInPlace=!1,e[c+1].appendInPlace&&this.warn(`Could not change append strategy for abutting event ${l}`));const y=et(l.resumeOffset)?l.resumeOffset:l.duration;i+=y})}primaryCanResumeInPlaceAt(e,t){const s=e.resumeTime,r=e.startTime+e.resumptionOffset;return Math.abs(s-r)>Wh?(this.log(`"${e.identifier}" resumption ${s} not aligned with estimated timeline end ${r}`),!1):!Object.keys(t).some(a=>{const l=t[a].details,c=l.edge;if(s>=c)return this.log(`"${e.identifier}" resumption ${s} past ${a} playlist end ${c}`),!1;const d=Id(null,l.fragments,s);if(!d)return this.log(`"${e.identifier}" resumption ${s} does not align with any fragments in ${a} playlist (${l.fragStart}-${l.fragmentEnd})`),!0;const h=a==="audio"?.175:0;return Math.abs(d.start-s)<Wh+h||Math.abs(d.end-s)<Wh+h?!1:(this.log(`"${e.identifier}" resumption ${s} not aligned with ${a} fragment bounds (${d.start}-${d.end} sn: ${d.sn} cc: ${d.cc})`),!0)})}updateAssetDurations(e){if(!e.assetListLoaded)return;const t=e.timelineStart;let s=0,r=!1,i=!1;for(let a=0;a<e.assetList.length;a++){const l=e.assetList[a],c=t+s;l.startOffset=s,l.timelineStart=c,r||(r=l.duration===null),i||(i=!!l.error);const d=l.error?0:l.duration||0;s+=d}r&&!i?e.duration=Math.max(s,e.duration):e.duration=s}removeEvent(e){e.reset(),delete this.eventMap[e.identifier]}}function Xa(n){return`[${n.event?'"'+n.event.identifier+'"':"primary"}: ${n.start.toFixed(2)}-${n.end.toFixed(2)}]`}class _re{constructor(e){this.hls=void 0,this.hls=e}destroy(){this.hls=null}loadAssetList(e,t){const s=e.assetListUrl;let r;try{r=DL(s,this.hls.sessionId,e.baseUrl)}catch(m){const y=this.assignAssetListError(e,he.ASSET_LIST_LOAD_ERROR,m,s);this.hls.trigger(j.ERROR,y);return}t&&r.protocol!=="data:"&&r.searchParams.set("_HLS_start_offset",""+t);const i=this.hls.config,a=i.loader,l=new a(i),c={responseType:"json",url:r.href},d=i.interstitialAssetListLoadPolicy.default,h={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},p={onSuccess:(m,y,x,w)=>{const S=m.data,_=S?.ASSETS;if(!Array.isArray(_)){const L=this.assignAssetListError(e,he.ASSET_LIST_PARSING_ERROR,new Error("Invalid interstitial asset list"),x.url,y,w);this.hls.trigger(j.ERROR,L);return}e.assetListResponse=S,this.hls.trigger(j.ASSET_LIST_LOADED,{event:e,assetListResponse:S,networkDetails:w})},onError:(m,y,x,w)=>{const S=this.assignAssetListError(e,he.ASSET_LIST_LOAD_ERROR,new Error(`Error loading X-ASSET-LIST: HTTP status ${m.code} ${m.text} (${y.url})`),y.url,w,x);this.hls.trigger(j.ERROR,S)},onTimeout:(m,y,x)=>{const w=this.assignAssetListError(e,he.ASSET_LIST_LOAD_TIMEOUT,new Error(`Timeout loading X-ASSET-LIST (${y.url})`),y.url,m,x);this.hls.trigger(j.ERROR,w)}};return l.load(c,h,p),this.hls.trigger(j.ASSET_LIST_LOADING,{event:e}),l}assignAssetListError(e,t,s,r,i,a){return e.error=s,{type:xt.NETWORK_ERROR,details:t,fatal:!1,interstitial:e,url:r,error:s,networkDetails:a,stats:i}}}function wI(n){var e;n==null||(e=n.play())==null||e.catch(()=>{})}function mh(n,e){return`[${n}] Advancing timeline position to ${e}`}class Ire extends Pa{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 s=this.currentTime;if(s===void 0||this.playbackDisabled||!this.schedule)return;const r=s-this.timelinePos;if(Math.abs(r)<1/7056e5)return;const a=r<=-.01;this.timelinePos===-1&&!this.effectivePlayingItem&&this.checkStart(),this.timelinePos=s,this.bufferedPos=s;const l=this.playingItem;if(!l){this.checkBuffer();return}if(a&&this.schedule.resetErrorsInRange(s,s-r)&&this.updateSchedule(!0),this.checkBuffer(),a&&s<l.start||s>=l.end){var c;const y=this.findItemIndex(l);let x=this.schedule.findItemIndexAtTime(s);if(x===-1&&(x=y+(a?-1:1),this.log(`seeked ${a?"back ":""}to position not covered by schedule ${s} (resolving from ${y} to ${x})`)),!this.isInterstitial(l)&&(c=this.media)!=null&&c.paused&&(this.shouldPlay=!1),!a&&x>y){const w=this.schedule.findJumpRestrictedIndex(y+1,x);if(w>y){this.setSchedulePosition(w);return}}this.setSchedulePosition(x);return}const d=this.playingAsset;if(!d){if(this.playingLastItem&&this.isInterstitial(l)){const y=l.event.assetList[0];y&&(this.endedItem=this.playingItem,this.playingItem=null,this.setScheduleToAssetAtTime(s,y))}return}const h=d.timelineStart,p=d.duration||0;if(a&&s<h||s>=h+p){var m;(m=l.event)!=null&&m.appendInPlace&&(this.clearAssetPlayers(l.event,l),this.flushFrontBuffer(s)),this.setScheduleToAssetAtTime(s,d)}},this.onTimeupdate=()=>{const s=this.currentTime;if(s===void 0||this.playbackDisabled)return;if(this.timelinePos===-1&&!this.effectivePlayingItem&&this.checkStart(),s>this.timelinePos)this.timelinePos=s,s>this.bufferedPos&&this.checkBuffer();else return;const r=this.playingItem;if(!r||this.playingLastItem)return;if(s>=r.end){this.timelinePos=r.end;const l=this.findItemIndex(r);this.setSchedulePosition(l+1)}const i=this.playingAsset;if(!i)return;const a=i.timelineStart+(i.duration||0);s>=a&&this.setScheduleToAssetAtTime(s,i)},this.onScheduleUpdate=(s,r)=>{const i=this.schedule;if(!i)return;const a=this.playingItem,l=i.events||[],c=i.items||[],d=i.durations,h=s.map(w=>w.identifier),p=!!(l.length||h.length);(p||r)&&this.log(`INTERSTITIALS_UPDATED (${l.length}): ${l} 124Schedule: ${c.map(w=>Xa(w))} pos: ${this.timelinePos}`),h.length&&this.log(`Removed events ${h}`);let m=null,y=null;a&&(m=this.updateItem(a,this.timelinePos),this.itemsMatch(a,m)?this.playingItem=m:this.waitingItem=this.endedItem=null),this.waitingItem=this.updateItem(this.waitingItem),this.endedItem=this.updateItem(this.endedItem);const x=this.bufferingItem;if(x&&(y=this.updateItem(x,this.bufferedPos),this.itemsMatch(x,y)?this.bufferingItem=y:x.event&&(this.bufferingItem=this.playingItem,this.clearInterstitial(x.event,null))),s.forEach(w=>{w.assetList.forEach(S=>{this.clearAssetPlayer(S.identifier,null)})}),this.playerQueue.forEach(w=>{if(w.interstitial.appendInPlace){const S=w.assetItem.timelineStart,_=w.timelineOffset-S;if(_)try{w.timelineOffset=S}catch(L){Math.abs(_)>Wh&&this.warn(`${L} ("${w.assetId}" ${w.timelineOffset}->${S})`)}}}),p||r){if(this.hls.trigger(j.INTERSTITIALS_UPDATED,{events:l.slice(0),schedule:c.slice(0),durations:d,removedIds:h}),this.isInterstitial(a)&&h.includes(a.event.identifier)){this.warn(`Interstitial "${a.event.identifier}" removed while playing`),this.primaryFallback(a.event);return}a&&this.trimInPlace(m,a),x&&y!==m&&this.trimInPlace(y,x),this.checkBuffer()}},this.hls=e,this.HlsPlayerClass=t,this.assetListLoader=new _re(e),this.schedule=new Tre(this.onScheduleUpdate,e.logger),this.registerListeners()}registerListeners(){const e=this.hls;e&&(e.on(j.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(j.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(j.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(j.MANIFEST_LOADING,this.onManifestLoading,this),e.on(j.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(j.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(j.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.on(j.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(j.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.on(j.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.on(j.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.on(j.BUFFER_APPENDED,this.onBufferAppended,this),e.on(j.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(j.BUFFERED_TO_END,this.onBufferedToEnd,this),e.on(j.MEDIA_ENDED,this.onMediaEnded,this),e.on(j.ERROR,this.onError,this),e.on(j.DESTROYING,this.onDestroying,this))}unregisterListeners(){const e=this.hls;e&&(e.off(j.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(j.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(j.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(j.MANIFEST_LOADING,this.onManifestLoading,this),e.off(j.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(j.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(j.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.off(j.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(j.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.off(j.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.off(j.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.off(j.BUFFER_CODECS,this.onBufferCodecs,this),e.off(j.BUFFER_APPENDED,this.onBufferAppended,this),e.off(j.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(j.BUFFERED_TO_END,this.onBufferedToEnd,this),e.off(j.MEDIA_ENDED,this.onMediaEnded,this),e.off(j.ERROR,this.onError,this),e.off(j.DESTROYING,this.onDestroying,this))}startLoad(){this.resumeBuffering()}stopLoad(){this.pauseBuffering()}resumeBuffering(){var e;(e=this.getBufferingPlayer())==null||e.resumeBuffering()}pauseBuffering(){var e;(e=this.getBufferingPlayer())==null||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){Ti(e,"play",this.onPlay),Ti(e,"pause",this.onPause),Ti(e,"seeking",this.onSeeking),Ti(e,"timeupdate",this.onTimeupdate)}onMediaAttaching(e,t){const s=this.media=t.media;ei(s,"seeking",this.onSeeking),ei(s,"timeupdate",this.onTimeupdate),ei(s,"play",this.onPlay),ei(s,"pause",this.onPause)}onMediaAttached(e,t){const s=this.effectivePlayingItem,r=this.detachedData;if(this.detachedData=null,s===null)this.checkStart();else if(!r){this.clearScheduleState();const i=this.findItemIndex(s);this.setSchedulePosition(i)}}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 s=!!t.transferMedia,r=this.media;if(this.media=null,!s&&(r&&this.removeMediaListeners(r),this.detachedData)){const i=this.getBufferingPlayer();i&&(this.log(`Removing schedule state for detachedData and ${i}`),this.playingAsset=this.endedAsset=this.bufferingAsset=this.bufferingItem=this.waitingItem=this.detachedData=null,i.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,s=p=>p&&e.getAssetPlayer(p.identifier),r=(p,m,y,x,w)=>{if(p){let S=p[m].start;const _=p.event;if(_){if(m==="playout"||_.timelineOccupancy!==$1.Point){const L=s(y);L?.interstitial===_&&(S+=L.assetItem.startOffset+L[w])}}else{const L=x==="bufferedPos"?a():e[x];S+=L-p.start}return S}return 0},i=(p,m)=>{var y;if(p!==0&&m!=="primary"&&(y=e.schedule)!=null&&y.length){var x;const w=e.schedule.findItemIndexAtTime(p),S=(x=e.schedule.items)==null?void 0:x[w];if(S){const _=S[m].start-S.start;return p+_}}return p},a=()=>{const p=e.bufferedPos;return p===Number.MAX_VALUE?l("primary"):Math.max(p,0)},l=p=>{var m,y;return(m=e.primaryDetails)!=null&&m.live?e.primaryDetails.edge:((y=e.schedule)==null?void 0:y.durations[p])||0},c=(p,m)=>{var y,x;const w=e.effectivePlayingItem;if(w!=null&&(y=w.event)!=null&&y.restrictions.skip||!e.schedule)return;e.log(`seek to ${p} "${m}"`);const S=e.effectivePlayingItem,_=e.schedule.findItemIndexAtTime(p,m),L=(x=e.schedule.items)==null?void 0:x[_],R=e.getBufferingPlayer(),M=R?.interstitial,V=M?.appendInPlace,W=S&&e.itemsMatch(S,L);if(S&&(V||W)){const I=s(e.playingAsset),k=I?.media||e.primaryMedia;if(k){const P=m==="primary"?k.currentTime:r(S,m,e.playingAsset,"timelinePos","currentTime"),N=p-P,F=(V?P:k.currentTime)+N;if(F>=0&&(!I||V||F<=I.duration)){k.currentTime=F;return}}}if(L){let I=p;if(m!=="primary"){const P=L[m].start,N=p-P;I=L.start+N}const k=!e.isInterstitial(L);if((!e.isInterstitial(S)||S.event.appendInPlace)&&(k||L.event.appendInPlace)){const P=e.media||(V?R?.media:null);P&&(P.currentTime=I)}else if(S){const P=e.findItemIndex(S);if(_>P){const F=e.schedule.findJumpRestrictedIndex(P+1,_);if(F>P){e.setSchedulePosition(F);return}}let N=0;if(k)e.timelinePos=I,e.checkBuffer();else{const F=L.event.assetList,z=p-(L[m]||L).start;for(let U=F.length;U--;){const fe=F[U];if(fe.duration&&z>=fe.startOffset&&z<fe.startOffset+fe.duration){N=U;break}}}e.setSchedulePosition(_,N)}}},d=()=>{const p=e.effectivePlayingItem;if(e.isInterstitial(p))return p;const m=t();return e.isInterstitial(m)?m:null},h={get bufferedEnd(){const p=t(),m=e.bufferingItem;if(m&&m===p){var y;return r(m,"playout",e.bufferingAsset,"bufferedPos","bufferedEnd")-m.playout.start||((y=e.bufferingAsset)==null?void 0:y.startOffset)||0}return 0},get currentTime(){const p=d(),m=e.effectivePlayingItem;return m&&m===p?r(m,"playout",e.effectivePlayingAsset,"timelinePos","currentTime")-m.playout.start:0},set currentTime(p){const m=d(),y=e.effectivePlayingItem;y&&y===m&&c(p+y.playout.start,"playout")},get duration(){const p=d();return p?p.playout.end-p.playout.start:0},get assetPlayers(){var p;const m=(p=d())==null?void 0:p.event.assetList;return m?m.map(y=>e.getAssetPlayer(y.identifier)):[]},get playingIndex(){var p;const m=(p=d())==null?void 0:p.event;return m&&e.effectivePlayingAsset?m.findAssetIndex(e.effectivePlayingAsset):-1},get scheduleItem(){return d()}};return this.manager={get events(){var p;return((p=e.schedule)==null||(p=p.events)==null?void 0:p.slice(0))||[]},get schedule(){var p;return((p=e.schedule)==null||(p=p.items)==null?void 0:p.slice(0))||[]},get interstitialPlayer(){return d()?h:null},get playerQueue(){return e.playerQueue.slice(0)},get bufferingAsset(){return e.bufferingAsset},get bufferingItem(){return t()},get bufferingIndex(){const p=t();return e.findItemIndex(p)},get playingAsset(){return e.effectivePlayingAsset},get playingItem(){return e.effectivePlayingItem},get playingIndex(){const p=e.effectivePlayingItem;return e.findItemIndex(p)},primary:{get bufferedEnd(){return a()},get currentTime(){const p=e.timelinePos;return p>0?p:0},set currentTime(p){c(p,"primary")},get duration(){return l("primary")},get seekableStart(){var p;return((p=e.primaryDetails)==null?void 0:p.fragmentStart)||0}},integrated:{get bufferedEnd(){return r(t(),"integrated",e.bufferingAsset,"bufferedPos","bufferedEnd")},get currentTime(){return r(e.effectivePlayingItem,"integrated",e.effectivePlayingAsset,"timelinePos","currentTime")},set currentTime(p){c(p,"integrated")},get duration(){return l("integrated")},get seekableStart(){var p;return i(((p=e.primaryDetails)==null?void 0:p.fragmentStart)||0,"integrated")}},skip:()=>{const p=e.effectivePlayingItem,m=p?.event;if(m&&!m.restrictions.skip){const y=e.findItemIndex(p);if(m.appendInPlace){const x=p.playout.start+p.event.duration;c(x+.001,"playout")}else e.advanceAfterAssetEnded(m,y,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,s=(e=this.schedule)==null?void 0:e.items;return!this.playbackStarted||!t||!s?!1:this.findItemIndex(t)===s.length-1}get playbackStarted(){return this.effectivePlayingItem!==null}get currentTime(){var e,t;if(this.mediaSelection===null)return;const s=this.waitingItem||this.playingItem;if(this.isInterstitial(s)&&!s.event.appendInPlace)return;let r=this.media;!r&&(e=this.bufferingItem)!=null&&(e=e.event)!=null&&e.appendInPlace&&(r=this.primaryMedia);const i=(t=r)==null?void 0:t.currentTime;if(!(i===void 0||!et(i)))return i}get primaryMedia(){var e;return this.media||((e=this.detachedData)==null?void 0:e.media)||null}isInterstitial(e){return!!(e!=null&&e.event)}retreiveMediaSource(e,t){const s=this.getAssetPlayer(e);s&&this.transferMediaFromPlayer(s,t)}transferMediaFromPlayer(e,t){const s=e.interstitial.appendInPlace,r=e.media;if(s&&r===this.primaryMedia){if(this.bufferingAsset=null,(!t||this.isInterstitial(t)&&!t.event.appendInPlace)&&t&&r){this.detachedData={media:r};return}const i=e.transferMedia();this.log(`transfer MediaSource from ${e} ${jn(i)}`),this.detachedData=i}else t&&r&&(this.shouldPlay||(this.shouldPlay=!r.paused))}transferMediaTo(e,t){var s,r;if(e.media===t)return;let i=null;const a=this.hls,l=e!==a,c=l&&e.interstitial.appendInPlace,d=(s=this.detachedData)==null?void 0:s.mediaSource;let h;if(a.media)c&&(i=a.transferMedia(),this.detachedData=i),h="Primary";
124else if(d){const x=this.getBufferingPlayer();x?(i=x.transferMedia(),h=`${x}`):h="detached MediaSource"}else h="detached media";if(!i){if(d)i=this.detachedData,this.log(`using detachedData: MediaSource ${jn(i)}`);else if(!this.detachedData||a.media===t){const x=this.playerQueue;x.length>1&&x.forEach(w=>{if(l&&w.interstitial.appendInPlace!==c){const S=w.interstitial;this.clearInterstitial(w.interstitial,null),S.appendInPlace=!1,S.appendInPlace&&this.warn(`Could not change append strategy for queued assets ${S}`)}}),this.hls.detachMedia(),this.detachedData={media:t}}}const p=i&&"mediaSource"in i&&((r=i.mediaSource)==null?void 0:r.readyState)!=="closed",m=p&&i?i:t;this.log(`${p?"transfering MediaSource":"attaching media"} to ${l?e:"Primary"} from ${h} (media.currentTime: ${t.currentTime})`);const y=this.schedule;if(m===i&&y){const x=l&&e.assetId===y.assetIdAtEnd;m.overrides={duration:y.duration,endOfStream:!l||x,cueRemoval:!l}}e.attachMedia(m)}onInterstitialCueEnter(){this.onTimeupdate()}checkStart(){const e=this.schedule,t=e?.events;if(!t||this.playbackDisabled||!this.media)return;this.bufferedPos===-1&&(this.bufferedPos=0);const s=this.timelinePos,r=this.effectivePlayingItem;if(s===-1){const i=this.hls.startPosition;if(this.timelinePos=i,t.length===0)this.setSchedulePosition(0);else if(t[0].cue.pre){this.log(mh("checkStart (preroll)",i));const a=e.findEventIndex(t[0].identifier);this.setSchedulePosition(a)}else if(i>=0||!this.primaryLive){this.log(mh("checkStart",i));const a=this.timelinePos=i>0?i:0,l=e.findItemIndexAtTime(a);this.setSchedulePosition(l)}else this.hls.liveSyncPosition===0?this.setSchedulePosition(0):this.log("[checkStart] waiting for live start")}else if(r&&!this.playingItem){this.log(mh("checkStart (playing item)",r.start));const i=e.findItemIndex(r);this.setSchedulePosition(i)}}advanceAssetBuffering(e,t){const s=e.event,r=s.findAssetIndex(t),i=Lv(s,r);if(!s.isAssetPastPlayoutLimit(i))this.bufferedToEvent(e,i);else if(this.schedule){var a;const l=(a=this.schedule.items)==null?void 0:a[this.findItemIndex(e)+1];l&&this.bufferedToItem(l)}}advanceAfterAssetEnded(e,t,s){const r=Lv(e,s);if(e.isAssetPastPlayoutLimit(r)){if(this.schedule){const i=this.schedule.items;if(i){const a=t+1,l=i.length;if(a>=l){this.setSchedulePosition(-1);return}const c=e.resumeTime;this.timelinePos<c&&(this.log(mh("advanceAfterAssetEnded",c)),this.timelinePos=c,e.appendInPlace&&this.advanceInPlace(c),this.checkBuffer(this.bufferedPos<c)),this.setSchedulePosition(a)}}}else{if(e.appendInPlace){const i=e.assetList[r];i&&this.advanceInPlace(i.timelineStart)}this.setSchedulePosition(t,r)}}setScheduleToAssetAtTime(e,t){const s=this.schedule;if(!s)return;const r=t.parentIdentifier,i=s.getEvent(r);if(i){const a=s.findEventIndex(r),l=s.findAssetIndex(i,e);this.advanceAfterAssetEnded(i,a,l-1)}}setSchedulePosition(e,t){var s;const r=(s=this.schedule)==null?void 0:s.items;if(!r||this.playbackDisabled)return;const i=e>=0?r[e]:null;this.log(`setSchedulePosition ${e}, ${t} (${i&&Xa(i)}) pos: ${this.timelinePos}`);const a=this.waitingItem||this.playingItem,l=this.playingLastItem;if(this.isInterstitial(a)){const h=a.event,p=this.playingAsset,m=p?.identifier,y=m?this.getAssetPlayer(m):null;if(y&&m&&(!this.eventItemsMatch(a,i)||t!==void 0&&m!==h.assetList[t].identifier)){var c;const x=h.findAssetIndex(p);if(this.log(`INTERSTITIAL_ASSET_ENDED ${x+1}/${h.assetList.length} ${Th(p)}`),this.endedAsset=p,this.playingAsset=null,this.hls.trigger(j.INTERSTITIAL_ASSET_ENDED,{asset:p,assetListIndex:x,event:h,schedule:r.slice(0),scheduleIndex:e,player:y}),a!==this.playingItem){this.itemsMatch(a,this.playingItem)&&!this.playingAsset&&this.advanceAfterAssetEnded(h,this.findItemIndex(this.playingItem),x);return}this.retreiveMediaSource(m,i),y.media&&!((c=this.detachedData)!=null&&c.mediaSource)&&y.detachMedia()}if(!this.eventItemsMatch(a,i)&&(this.endedItem=a,this.playingItem=null,this.log(`INTERSTITIAL_ENDED ${h} ${Xa(a)}`),h.hasPlayed=!0,this.hls.trigger(j.INTERSTITIAL_ENDED,{event:h,schedule:r.slice(0),scheduleIndex:e}),h.cue.once)){var d;this.updateSchedule();const x=(d=this.schedule)==null?void 0:d.items;if(i&&x){const w=this.findItemIndex(i);this.advanceSchedule(w,x,t,a,l)}return}}this.advanceSchedule(e,r,t,a,l)}advanceSchedule(e,t,s,r,i){const a=this.schedule;if(!a)return;const l=t[e]||null,c=this.primaryMedia,d=this.playerQueue;if(d.length&&d.forEach(h=>{const p=h.interstitial,m=a.findEventIndex(p.identifier);(m<e||m>e+1)&&this.clearInterstitial(p,l)}),this.isInterstitial(l)){this.timelinePos=Math.min(Math.max(this.timelinePos,l.start),l.end);const h=l.event;if(s===void 0){s=a.findAssetIndex(h,this.timelinePos);const x=Lv(h,s-1);if(h.isAssetPastPlayoutLimit(x)||h.appendInPlace&&this.timelinePos===l.end){this.advanceAfterAssetEnded(h,e,s);return}s=x}const p=this.waitingItem;this.assetsBuffered(l,c)||this.setBufferingItem(l);let m=this.preloadAssets(h,s);if(this.eventItemsMatch(l,p||r)||(this.waitingItem=l,this.log(`INTERSTITIAL_STARTED ${Xa(l)} ${h.appendInPlace?"append in place":""}`),this.hls.trigger(j.INTERSTITIAL_STARTED,{event:h,schedule:t.slice(0),scheduleIndex:e})),!h.assetListLoaded){this.log(`Waiting for ASSET-LIST to complete loading ${h}`);return}if(h.assetListLoader&&(h.assetListLoader.destroy(),h.assetListLoader=void 0),!c){this.log(`Waiting for attachMedia to start Interstitial ${h}`);return}this.waitingItem=this.endedItem=null,this.playingItem=l;const y=h.assetList[s];if(!y){this.advanceAfterAssetEnded(h,e,s||0);return}if(m||(m=this.getAssetPlayer(y.identifier)),m===null||m.destroyed){const x=h.assetList.length;this.warn(`asset ${s+1}/${x} player destroyed ${h}`),m=this.createAssetPlayer(h,y,s),m.loadSource()}if(!this.eventItemsMatch(l,this.bufferingItem)&&h.appendInPlace&&this.isAssetBuffered(y))return;this.startAssetPlayer(m,s,t,e,c),this.shouldPlay&&wI(m.media)}else l?(this.resumePrimary(l,e,r),this.shouldPlay&&wI(this.hls.media)):i&&this.isInterstitial(r)&&(this.endedItem=null,this.playingItem=r,r.event.appendInPlace||this.attachPrimary(a.durations.primary,null))}get playbackDisabled(){return this.hls.config.enableInterstitialPlayback===!1}get primaryDetails(){var e;return(e=this.mediaSelection)==null?void 0:e.main.details}get primaryLive(){var e;return!!((e=this.primaryDetails)!=null&&e.live)}resumePrimary(e,t,s){var r,i;if(this.playingItem=e,this.playingAsset=this.endedAsset=null,this.waitingItem=this.endedItem=null,this.bufferedToItem(e),this.log(`resuming ${Xa(e)}`),!((r=this.detachedData)!=null&&r.mediaSource)){let l=this.timelinePos;(l<e.start||l>=e.end)&&(l=this.getPrimaryResumption(e,t),this.log(mh("resumePrimary",l)),this.timelinePos=l),this.attachPrimary(l,e)}if(!s)return;const a=(i=this.schedule)==null?void 0:i.items;a&&(this.log(`INTERSTITIALS_PRIMARY_RESUMED ${Xa(e)}`),this.hls.trigger(j.INTERSTITIALS_PRIMARY_RESUMED,{schedule:a.slice(0),scheduleIndex:t}),this.checkBuffer())}getPrimaryResumption(e,t){const s=e.start;if(this.primaryLive){const r=this.primaryDetails;if(t===0)return this.hls.startPosition;if(r&&(s<r.fragmentStart||s>r.edge))return this.hls.liveSyncPosition||-1}return s}isAssetBuffered(e){const t=this.getAssetPlayer(e.identifier);return t!=null&&t.hls?t.hls.bufferedToEnd:Bt.bufferInfo(this.primaryMedia,this.timelinePos,0).end+1>=e.timelineStart+(e.duration||0)}attachPrimary(e,t,s){t?this.setBufferingItem(t):this.bufferingItem=this.playingItem,this.bufferingAsset=null;const r=this.primaryMedia;if(!r)return;const i=this.hls;i.media?this.checkBuffer():(this.transferMediaTo(i,r),s&&this.startLoadingPrimaryAt(e,s)),s||(this.log(mh("attachPrimary",e)),this.timelinePos=e,this.startLoadingPrimaryAt(e,s))}
vendor: 4,927 bytes, line 124
124startLoadingPrimaryAt(e,t){var s;const r=this.hls;!r.loadingEnabled||!r.media||Math.abs((((s=r.mainForwardBufferInfo)==null?void 0:s.start)||r.media.currentTime)-e)>.5?r.startLoad(e,t):r.bufferingEnabled||r.resumeBuffering()}onManifestLoading(){var e;this.stopLoad(),(e=this.schedule)==null||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(j.BUFFER_CODECS,this.onBufferCodecs,this),this.hls.on(j.BUFFER_CODECS,this.onBufferCodecs,this)}onLevelUpdated(e,t){if(t.level===-1||!this.schedule)return;const s=this.hls.levels[t.level];if(!s.details)return;const r=In(In({},this.mediaSelection||this.altSelection),{},{main:s});this.mediaSelection=r,this.schedule.parseInterstitialDateRanges(r,this.hls.config.interstitialAppendInPlace),!this.effectivePlayingItem&&this.schedule.items&&this.checkStart()}onAudioTrackUpdated(e,t){const s=this.hls.audioTracks[t.id],r=this.mediaSelection;if(!r){this.altSelection=In(In({},this.altSelection),{},{audio:s});return}const i=In(In({},r),{},{audio:s});this.mediaSelection=i}onSubtitleTrackUpdated(e,t){const s=this.hls.subtitleTracks[t.id],r=this.mediaSelection;if(!r){this.altSelection=In(In({},this.altSelection),{},{subtitles:s});return}const i=In(In({},r),{},{subtitles:s});this.mediaSelection=i}onAudioTrackSwitching(e,t){const s=R_(t);this.playerQueue.forEach(({hls:r})=>r&&(r.setAudioOption(t)||r.setAudioOption(s)))}onSubtitleTrackSwitch(e,t){const s=R_(t);this.playerQueue.forEach(({hls:r})=>r&&(r.setSubtitleOption(t)||t.id!==-1&&r.setSubtitleOption(s)))}onBufferCodecs(e,t){const s=t.tracks;s&&(this.requiredTracks=s)}onBufferAppended(e,t){this.checkBuffer()}onBufferFlushed(e,t){const s=this.playingItem;if(s&&!this.itemsMatch(s,this.bufferingItem)&&!this.isInterstitial(s)){const r=this.timelinePos;this.bufferedPos=r,this.checkBuffer()}}onBufferedToEnd(e){if(!this.schedule)return;const t=this.schedule.events;if(this.bufferedPos<Number.MAX_VALUE&&t){for(let r=0;r<t.length;r++){const i=t[r];if(i.cue.post){var s;const a=this.schedule.findEventIndex(i.identifier),l=(s=this.schedule.items)==null?void 0:s[a];this.isInterstitial(l)&&this.eventItemsMatch(l,this.bufferingItem)&&this.bufferedToItem(l,0);break}}this.bufferedPos=Number.MAX_VALUE}}onMediaEnded(e){const t=this.playingItem;if(!this.playingLastItem&&t){const s=this.findItemIndex(t);this.setSchedulePosition(s+1)}else this.shouldPlay=!1}updateItem(e,t){var s;const r=(s=this.schedule)==null?void 0:s.items;if(e&&r){const i=this.findItemIndex(e,t);return r[i]||null}return null}trimInPlace(e,t){if(this.isInterstitial(e)&&e.event.appendInPlace&&t.end-e.end>.25){e.event.assetList.forEach((i,a)=>{e.event.isAssetPastPlayoutLimit(a)&&this.clearAssetPlayer(i.identifier,null)});const s=e.end+.25,r=Bt.bufferInfo(this.primaryMedia,s,0);(r.end>s||(r.nextStart||0)>s)&&(this.log(`trim buffered interstitial ${Xa(e)} (was ${Xa(t)})`),this.attachPrimary(s,null,!0),this.flushFrontBuffer(s))}}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 s;return!!t&&(e===t||e.event.identifier===((s=t.event)==null?void 0:s.identifier))}findItemIndex(e,t){return e&&this.schedule?this.schedule.findItemIndex(e,t):-1}updateSchedule(e=!1){var t;const s=this.mediaSelection;s&&((t=this.schedule)==null||t.updateSchedule(s,[],e))}checkBuffer(e){var t;const s=(t=this.schedule)==null?void 0:t.items;if(!s)return;const r=Bt.bufferInfo(this.primaryMedia,this.timelinePos,0);e&&(this.bufferedPos=this.timelinePos),e||(e=r.len<1),this.updateBufferedPos(r.end,s,e)}updateBufferedPos(e,t,s){const r=this.schedule,i=this.bufferingItem;if(this.bufferedPos>e||!r)return;if(t.length===1&&this.itemsMatch(t[0],i)){this.bufferedPos=e;return}const a=this.playingItem,l=this.findItemIndex(a);let c=r.findItemIndexAtTime(e);if(this.bufferedPos<e){var d;const h=this.findItemIndex(i),p=Math.min(h+1,t.length-1),m=t[p];if((c===-1&&i&&e>=i.end||(d=m.event)!=null&&d.appendInPlace&&e+.01>=m.start)&&(c=p),this.isInterstitial(i)){const y=i.event;if(p-l>1&&y.appendInPlace===!1||y.assetList.length===0&&y.assetListLoader)return}if(this.bufferedPos=e,c>h&&c>l)this.bufferedToItem(m);else{const y=this.primaryDetails;this.primaryLive&&y&&e>y.edge-y.targetduration&&m.start<y.edge+this.hls.config.interstitialLiveLookAhead&&this.isInterstitial(m)&&this.preloadAssets(m.event,0)}}else s&&a&&!this.itemsMatch(a,i)&&(c===l?this.bufferedToItem(a):c===l+1&&this.bufferedToItem(t[c]))}assetsBuffered(e,t){return e.event.assetList.length===0?!1:!e.event.assetList.some(r=>{const i=this.getAssetPlayer(r.identifier);return!(i!=null&&i.bufferedInPlaceToEnd(t))})}setBufferingItem(e){const t=this.bufferingItem,s=this.schedule;if(!this.itemsMatch(e,t)&&s){const{items:r,events:i}=s;if(!r||!i)return t;
124const a=this.isInterstitial(e),l=this.getBufferingPlayer();this.bufferingItem=e,this.bufferedPos=Math.max(e.start,Math.min(e.end,this.timelinePos));const c=l?l.remaining:t?t.end-this.timelinePos:0;if(this.log(`INTERSTITIALS_BUFFERED_TO_BOUNDARY ${Xa(e)}`+(t?` (${c.toFixed(2)} remaining)`:"")),!this.playbackDisabled)if(a){const d=s.findAssetIndex(e.event,this.bufferedPos);e.event.assetList.forEach((h,p)=>{const m=this.getAssetPlayer(h.identifier);m&&(p===d&&m.loadSource(),m.resumeBuffering())})}else this.hls.resumeBuffering(),this.playerQueue.forEach(d=>d.pauseBuffering());this.hls.trigger(j.INTERSTITIALS_BUFFERED_TO_BOUNDARY,{events:i.slice(0),schedule:r.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 s=this.setBufferingItem(e);if(!this.playbackDisabled){if(this.isInterstitial(e))this.bufferedToEvent(e,t);else if(s!==null){this.bufferingAsset=null;const r=this.detachedData;r?r.mediaSource?this.attachPrimary(e.start,e,!0):this.preloadPrimary(e):this.preloadPrimary(e)}}}preloadPrimary(e){const t=this.findItemIndex(e),s=this.getPrimaryResumption(e,t);this.startLoadingPrimaryAt(s)}bufferedToEvent(e,t){const s=e.event,r=s.assetList.length===0&&!s.assetListLoader,i=s.cue.once;if(r||!i){const a=this.preloadAssets(s,t);if(a!=null&&a.interstitial.appendInPlace){const l=this.primaryMedia;l&&this.bufferAssetPlayer(a,l)}}}preloadAssets(e,t){const s=e.assetUrl,r=e.assetList.length,i=r===0&&!e.assetListLoader,a=e.cue.once;if(i){const c=e.timelineStart;if(e.appendInPlace){var l;const m=this.playingItem;!this.isInterstitial(m)&&(m==null||(l=m.nextEvent)==null?void 0:l.identifier)===e.identifier&&this.flushFrontBuffer(c+.25)}let d,h=0;if(!this.playingItem&&this.primaryLive&&(h=this.hls.startPosition,h===-1&&(h=this.hls.liveSyncPosition||0)),h&&!(e.cue.pre||e.cue.post)){const m=h-c;m>0&&(d=Math.round(m*1e3)/1e3)}if(this.log(`Load interstitial asset ${t+1}/${s?1:r} ${e}${d?` live-start: ${h} start-offset: ${d}`:""}`),s)return this.createAsset(e,0,0,c,e.duration,s);const p=this.assetListLoader.loadAssetList(e,d);p&&(e.assetListLoader=p)}else if(!a&&r){for(let d=t;d<r;d++){const h=e.assetList[d],p=this.getAssetPlayerQueueIndex(h.identifier);(p===-1||this.playerQueue[p].destroyed)&&!h.error&&this.createAssetPlayer(e,h,d)}const c=e.assetList[t];if(c){const d=this.getAssetPlayer(c.identifier);return d&&d.loadSource(),d}}return null}flushFrontBuffer(e){const t=this.requiredTracks;if(!t)return;this.log(`Removing front buffer starting at ${e}`),Object.keys(t).forEach(r=>{this.hls.trigger(j.BUFFER_FLUSHING,{startOffset:e,endOffset:1/0,type:r})})}getAssetPlayerQueueIndex(e){const t=this.playerQueue;for(let s=0;s<t.length;s++)if(e===t[s].assetId)return s;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 s=0;s<e.length;s++)if(e[s].media===t)return e[s]}return null}createAsset(e,t,s,r,i,a){const l={parentIdentifier:e.identifier,identifier:bre(e,a,t),duration:i,startOffset:s,timelineStart:r,uri:a};return this.createAssetPlayer(e,l,t)}createAssetPlayer(e,t,s){const r=this.hls,i=r.userConfig;let a=i.videoPreference;const l=r.loadLevelObj||r.levels[r.currentLevel];(a||l)&&(a=kn({},a),l.videoCodec&&(a.videoCodec=l.videoCodec),l.videoRange&&(a.allowedVideoRanges=[l.videoRange]));const c=r.audioTracks[r.audioTrack],d=r.subtitleTracks[r.subtitleTrack];let h=0;if(this.primaryLive||e.appendInPlace){const M=this.timelinePos-t.timelineStart;if(M>1){const V=t.duration;V&&M<V&&(h=M)}}const p=t.identifier,m=In(In({},i),{},{maxMaxBufferLength:Math.min(180,r.config.maxMaxBufferLength),autoStartLoad:!0,startFragPrefetch:!0,primarySessionId:r.sessionId,assetPlayerId:p,abrEwmaDefaultEstimate:r.bandwidthEstimate,interstitialsController:void 0,startPosition:h,liveDurationInfinity:!1,testBandwidth:!1,videoPreference:a,audioPreference:c||i.audioPreference,subtitlePreference:d||i.subtitlePreference});e.appendInPlace&&(e.appendInPlaceStarted=!0,t.timelineStart&&(m.timelineOffset=t.timelineStart));const y=m.cmcd;y!=null&&y.sessionId&&y.contentId&&(m.cmcd=kn({},y,{contentId:Vp(t.uri)})),this.getAssetPlayer(p)&&this.warn(`Duplicate date range identifier ${e} and asset ${p}`);const x=new Ere(this.HlsPlayerClass,m,e,t);this.playerQueue.push(x),e.assetList[s]=t;let w=!0;const S=M=>{if(M.live){var V;const k=new Error(`Interstitials MUST be VOD assets ${e}`),P={fatal:!0,type:xt.OTHER_ERROR,details:he.INTERSTITIAL_ASSET_ITEM_ER
124ROR,error:k},N=((V=this.schedule)==null?void 0:V.findEventIndex(e.identifier))||-1;this.handleAssetItemError(P,e,N,s,k.message);return}const W=M.edge-M.fragmentStart,I=t.duration;(w||I===null||W>I)&&(w=!1,this.log(`Interstitial asset "${p}" duration change ${I} > ${W}`),t.duration=W,this.updateSchedule())};x.on(j.LEVEL_UPDATED,(M,{details:V})=>S(V)),x.on(j.LEVEL_PTS_UPDATED,(M,{details:V})=>S(V)),x.on(j.EVENT_CUE_ENTER,()=>this.onInterstitialCueEnter());const _=(M,V)=>{const W=this.getAssetPlayer(p);if(W&&V.tracks){W.off(j.BUFFER_CODECS,_),W.tracks=V.tracks;const I=this.primaryMedia;this.bufferingAsset===W.assetItem&&I&&!W.media&&this.bufferAssetPlayer(W,I)}};x.on(j.BUFFER_CODECS,_);const L=()=>{var M;const V=this.getAssetPlayer(p);if(this.log(`buffered to end of asset ${V}`),!V||!this.schedule)return;const W=this.schedule.findEventIndex(e.identifier),I=(M=this.schedule.items)==null?void 0:M[W];this.isInterstitial(I)&&this.advanceAssetBuffering(I,t)};x.on(j.BUFFERED_TO_END,L);const R=M=>()=>{if(!this.getAssetPlayer(p)||!this.schedule)return;this.shouldPlay=!0;const W=this.schedule.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,W,M)};return x.once(j.MEDIA_ENDED,R(s)),x.once(j.PLAYOUT_LIMIT_REACHED,R(1/0)),x.on(j.ERROR,(M,V)=>{if(!this.schedule)return;const W=this.getAssetPlayer(p);if(V.details===he.BUFFER_STALLED_ERROR){if(W!=null&&W.appendInPlace){this.handleInPlaceStall(e);return}this.onTimeupdate(),this.checkBuffer(!0);return}this.handleAssetItemError(V,e,this.schedule.findEventIndex(e.identifier),s,`Asset player error ${V.error} ${e}`)}),x.on(j.DESTROYING,()=>{if(!this.getAssetPlayer(p)||!this.schedule)return;const V=new Error(`Asset player destroyed unexpectedly ${p}`),W={fatal:!0,type:xt.OTHER_ERROR,details:he.INTERSTITIAL_ASSET_ITEM_ERROR,error:V};this.handleAssetItemError(W,e,this.schedule.findEventIndex(e.identifier),s,V.message)}),this.log(`INTERSTITIAL_ASSET_PLAYER_CREATED ${Th(t)}`),this.hls.trigger(j.INTERSTITIAL_ASSET_PLAYER_CREATED,{asset:t,assetListIndex:s,event:e,player:x}),x}clearInterstitial(e,t){this.clearAssetPlayers(e,t),e.reset()}clearAssetPlayers(e,t){e.assetList.forEach(s=>{this.clearAssetPlayer(s.identifier,t)})}resetAssetPlayer(e){const t=this.getAssetPlayerQueueIndex(e);if(t!==-1){this.log(`reset asset player "${e}" after error`);const s=this.playerQueue[t];this.transferMediaFromPlayer(s,null),s.resetDetails()}}clearAssetPlayer(e,t){const s=this.getAssetPlayerQueueIndex(e);if(s!==-1){const r=this.playerQueue[s];this.log(`clear ${r} toSegment: ${t&&Xa(t)}`),this.transferMediaFromPlayer(r,t),this.playerQueue.splice(s,1),r.destroy()}}emptyPlayerQueue(){let e;for(;e=this.playerQueue.pop();)e.destroy();this.playerQueue=[]}startAssetPlayer(e,t,s,r,i){const{interstitial:a,assetItem:l,assetId:c}=e,d=a.assetList.length,h=this.playingAsset;this.endedAsset=null,this.playingAsset=l,(!h||h.identifier!==c)&&(h&&(this.clearAssetPlayer(h.identifier,s[r]),delete h.error),this.log(`INTERSTITIAL_ASSET_STARTED ${t+1}/${d} ${Th(l)}`),this.hls.trigger(j.INTERSTITIAL_ASSET_STARTED,{asset:l,assetListIndex:t,event:a,schedule:s.slice(0),scheduleIndex:r,player:e})),this.bufferAssetPlayer(e,i)}bufferAssetPlayer(e,t){var s,r;if(!this.schedule)return;const{interstitial:i,assetItem:a}=e,l=this.schedule.findEventIndex(i.identifier),c=(s=this.schedule.items)==null?void 0:s[l];if(!c)return;e.loadSource(),this.setBufferingItem(c),this.bufferingAsset=a;const d=this.getBufferingPlayer();if(d===e)return;const h=i.appendInPlace;if(h&&d?.interstitial.appendInPlace===!1)return;const p=d?.tracks||((r=this.detachedData)==null?void 0:r.tracks)||this.requiredTracks;if(h&&a!==this.playingAsset){if(!e.tracks){this.log(`Waiting for track info before buffering ${e}`);return}if(p&&!lN(p,e.tracks)){const m=new Error(`Asset ${Th(a)} SourceBuffer tracks ('${Object.keys(e.tracks)}') are not compatible with primary content tracks ('${Object.keys(p)}')`),y={fatal:!0,type:xt.OTHER_ERROR,details:he.INTERSTITIAL_ASSET_ITEM_ERROR,error:m},x=i.findAssetIndex(a);this.handleAssetItemError(y,i,l,x,m.message);return}}this.transferMediaTo(e,t)}handleInPlaceStall(e){const t=this.schedule,s=this.primaryMedia;if(!t||!s)return;const r=s.currentTime,i=t.findAssetIndex(e,r),a=e.assetList[i];if(a){const l=this.getAssetPlayer(a.identifier);if(l){const c=l.currentTime||r-a.timelineStart,d=l.duration-c;if(this.warn(`Stalled at ${c} of ${c+d} in ${l} ${e} (media.currentTime: ${r}
vendor: 4,293 bytes, line 124
124)`),c&&(d/s.playbackRate<.5||l.bufferedInPlaceToEnd(s))&&l.hls){const h=t.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,h,i)}}}}advanceInPlace(e){const t=this.primaryMedia;t&&t.currentTime<e&&(t.currentTime=e)}handleAssetItemError(e,t,s,r,i){if(e.details===he.BUFFER_STALLED_ERROR)return;const a=t.assetList[r]||null;if(this.warn(`INTERSTITIAL_ASSET_ERROR ${a&&Th(a)} ${e.error}`),!this.schedule)return;const l=a?.identifier||"",c=this.getAssetPlayerQueueIndex(l),d=this.playerQueue[c]||null,h=this.schedule.items,p=kn({},e,{fatal:!1,errorAction:$h(!0),asset:a,assetListIndex:r,event:t,schedule:h,scheduleIndex:s,player:d});if(this.hls.trigger(j.INTERSTITIAL_ASSET_ERROR,p),!e.fatal)return;const m=this.playingAsset,y=this.bufferingAsset,x=new Error(i);if(a&&(this.clearAssetPlayer(l,null),a.error=x),!t.assetList.some(w=>!w.error))t.error=x;else for(let w=r;w<t.assetList.length;w++)this.resetAssetPlayer(t.assetList[w].identifier);this.updateSchedule(!0),t.error?this.primaryFallback(t):m&&m.identifier===l?this.advanceAfterAssetEnded(t,s,r):y&&y.identifier===l&&this.isInterstitial(this.bufferingItem)&&this.advanceAssetBuffering(this.bufferingItem,y)}primaryFallback(e){const t=e.timelineStart,s=this.effectivePlayingItem;let r=this.timelinePos;if(s){this.log(`Fallback to primary from event "${e.identifier}" start: ${t} pos: ${r} playing: ${Xa(s)} error: ${e.error}`),r===-1&&(r=this.hls.startPosition);const a=this.updateItem(s,r);this.itemsMatch(s,a)&&this.clearInterstitial(e,null),e.appendInPlace&&(this.attachPrimary(t,null),this.flushFrontBuffer(t))}else if(r===-1){this.checkStart();return}if(!this.schedule)return;const i=this.schedule.findItemIndexAtTime(r);this.setSchedulePosition(i)}onAssetListLoaded(e,t){var s,r;const i=t.event,a=i.identifier,l=t.assetListResponse.ASSETS;if(!((s=this.schedule)!=null&&s.hasEvent(a)))return;const c=i.timelineStart,d=i.duration;let h=0;l.forEach((w,S)=>{const _=parseFloat(w.DURATION);this.createAsset(i,S,h,c+h,_,w.URI),h+=_}),i.duration=h,this.log(`Loaded asset-list with duration: ${h} (was: ${d}) ${i}`);const p=this.waitingItem,m=p?.event.identifier===a;this.updateSchedule();const y=(r=this.bufferingItem)==null?void 0:r.event;if(m){var x;const w=this.schedule.findEventIndex(a),S=(x=this.schedule.items)==null?void 0:x[w];if(S){if(!this.playingItem&&this.timelinePos>S.end&&this.schedule.findItemIndexAtTime(this.timelinePos)!==w){i.error=new Error(`Interstitial ${l.length?"no longer within playback range":"asset-list is empty"} ${this.timelinePos} ${i}`),this.log(i.error.message),this.updateSchedule(!0),this.primaryFallback(i);return}this.setBufferingItem(S)}this.setSchedulePosition(w)}else if(y?.identifier===a){const w=i.assetList[0];if(w){const S=this.getAssetPlayer(w.identifier);if(y.appendInPlace){const _=this.primaryMedia;S&&_&&this.bufferAssetPlayer(S,_)}else S&&S.loadSource()}}}onError(e,t){if(this.schedule)switch(t.details){case he.ASSET_LIST_PARSING_ERROR:case he.ASSET_LIST_LOAD_ERROR:case he.ASSET_LIST_LOAD_TIMEOUT:{const s=t.interstitial;s&&(this.updateSchedule(!0),this.primaryFallback(s));break}case he.BUFFER_STALLED_ERROR:{const s=this.endedItem||this.waitingItem||this.playingItem;if(this.isInterstitial(s)&&s.event.appendInPlace){this.handleInPlaceStall(s.event);return}this.log(`Primary player stall @${this.timelinePos} bufferedPos: ${this.bufferedPos}`),this.onTimeupdate(),this.checkBuffer(!0);break}}}}const SI=500;class jL extends ay{constructor(e,t,s){super(e,t,s,"subtitle-stream-controller",st.SUBTITLE),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(j.LEVEL_LOADED,this.onLevelLoaded,this),e.on(j.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(j.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(j.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(j.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(j.BUFFER_FLUSHING,this.onBufferFlushing,this)}unregisterListeners(){super.unregisterListeners();const{hls:e}=this;e.off(j.LEVEL_LOADED,this.onLevelLoaded,this),e.off(j.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUp
vendor: 61,007 bytes, lines 124-135
124dated,this),e.off(j.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(j.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(j.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(j.BUFFER_FLUSHING,this.onBufferFlushing,this)}startLoad(e,t){this.stopLoad(),this.state=Ae.IDLE,this.setInterval(SI),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:s,success:r}=t;if(this.fragContextChanged(s)||(_s(s)&&(this.fragPrevious=s),this.state=Ae.IDLE),!r)return;const i=this.tracksBuffered[this.currentTrackId];if(!i)return;let a;const l=s.start;for(let d=0;d<i.length;d++)if(l>=i[d].start&&l<=i[d].end){a=i[d];break}const c=s.start+s.duration;a?a.end=c:(a={start:l,end:c},i.push(a)),this.fragmentTracker.fragBuffered(s),this.fragBufferedComplete(s,null),this.media&&this.tick()}onBufferFlushing(e,t){const{startOffset:s,endOffset:r}=t;if(s===0&&r!==Number.POSITIVE_INFINITY){const i=r-1;if(i<=0)return;t.endOffsetSubtitles=Math.max(0,i),this.tracksBuffered.forEach(a=>{for(let l=0;l<a.length;){if(a[l].end<=i){a.shift();continue}else if(a[l].start<i)a[l].start=i;else break;l++}}),this.fragmentTracker.removeFragmentsInRange(s,i,st.SUBTITLE)}}onError(e,t){const s=t.frag;s?.type===st.SUBTITLE&&(t.details===he.FRAG_GAP&&this.fragmentTracker.fragBuffered(s,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==Ae.STOPPED&&(this.state=Ae.IDLE))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){if(this.levels&&fL(this.levels,t)){this.levels=t.map(s=>new af(s));return}this.tracksBuffered=[],this.levels=t.map(s=>{const r=new af(s);return this.tracksBuffered[r.id]=[],r}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,st.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null}onSubtitleTrackSwitch(e,t){var s;if(this.currentTrackId=t.id,!((s=this.levels)!=null&&s.length)||this.currentTrackId===-1){this.clearInterval();return}const r=this.levels[this.currentTrackId];r!=null&&r.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,r&&this.state!==Ae.STOPPED&&this.setInterval(SI)}onSubtitleTrackLoaded(e,t){var s;const{currentTrackId:r,levels:i}=this,{details:a,id:l}=t;if(!i){this.warn(`Subtitle tracks were reset while loading level ${l}`);return}const c=i[l];if(l>=i.length||!c)return;this.log(`Subtitle track ${l} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""},duration:${a.totalduration}`),this.mediaBuffer=this.mediaBufferTimeRanges;let d=0;if(a.live||(s=c.details)!=null&&s.live){if(a.deltaUpdateFailed)return;const p=this.mainDetails;if(!p){this.startFragRequested=!1;return}const m=p.fragments[0];if(!c.details)a.hasProgramDateTime&&p.hasProgramDateTime?(B1(a,p),d=a.fragmentStart):m&&(d=m.start,lw(a,d));else{var h;d=this.alignPlaylists(a,c.details,(h=this.levelLastLoaded)==null?void 0:h.details),d===0&&m&&(d=m.start,lw(a,d))}p&&!this.startFragRequested&&this.setStartPosition(p,d)}c.details=a,this.levelLastLoaded=c,l===r&&(this.hls.trigger(j.SUBTITLE_TRACK_UPDATED,{details:a,id:l,groupId:t.groupId}),this.tick(),a.live&&!this.fragCurrent&&this.media&&this.state===Ae.IDLE&&(Id(null,a.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),c.details=void 0)))}_handleFragmentLoadComplete(e){const{frag:t,payload:s}=e,r=t.decryptdata,i=this.hls;if(!this.fragContextChanged(t)&&s&&s.byteLength>0&&r!=null&&r.key&&r.iv&&Hh(r.method)){const a=performance.now();this.decrypter.decrypt(new Uint8Array(s),r.key.buffer,r.iv.buffer,oS(r.method)).catch(l=>{throw i.trigger(j.ERROR,{type:xt.MEDIA_ERROR,details:he.FRAG_DECRYPT_ERROR,fatal:!1,error:l,reason:l.message,frag:t}),l}).then(l=>{const c=performance.now();i.trigger(j.FRAG_DECRYPTED,{frag:t,payload:l,stats:{tstart:a,tdecrypt:c}})}).catch(l=>{this.warn(`${l.name}: ${l.message}`),this.state=Ae.IDLE})}}doTick(){if(!this.media){this.state=Ae.IDLE;return}if(this.state===Ae.IDLE){const{currentTrackId:e,levels:t}=this,s=t?.[e];if(!s||!t.length||!s.details||this.waitForLive(s))return;const{config:r}=this,i=this.getLoadPosition(),a=Bt.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],i,r.maxBufferHole),{end:l,len:c}=a,d=s.details,h=this.hls.maxBufferLength+d.levelTargetDuration;if(c>h)return;const p=d.fragments,m=p.length,y=d.edge;let x=null;const w=this.fragPrevious;if(l<y){const L=r.maxFragLookUpTolerance,R=l>y-L?0:L;x=Id(w,p,Math.max(p[0].start,l),R),!x&&w&&w.start<p[0].start&&(x=p[0])}else x=p[m-1];if(x=this.filterReplacedPrimary(x,s.details),!x)return;const S=x.sn-d.startSN,_=p[S-1];if(_&&_.cc===x.cc&&this.fragmentTracker.getState(_)===Gs.NOT_LOADED&&(x=_),this.fragmentTracker.getState(x)===Gs.NOT_LOADED){const L=this.mapToInitFragWhenRequired(x);L&&this.loadFragment(L,s,l)}}}loadFragment(e,t,s){_s(e)?super.loadFragment(e,t,s):this._loadInitSegment(e,t)}get mediaBufferTimeRanges(){return new Are(this.tracksBuffered[this.currentTrackId]||[])}}class Are{constructor(e){this.buffered=void 0;const t=(s,r,i)=>{if(r=r>>>0,r>i-1)throw new DOMException(`Failed to execute '${s}' on 'TimeRanges': The index provided (${r}) is greater than the maximum bound (${i})`);return e[r][s]};this.buffered={get length(){return e.length},end(s){return t("end",s,e.length)},start(s){return t("start",s,e.length)}}}}const Cre={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},OL=n=>String.fromCharCode(Cre[n]||n),to=15,_l=100,kre={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},Rre={17:2,18:4,21:6,22:8,23:10,19:13,20:15},Pre={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},Nre={25:2,26:4,29:6,30:8,31:10,27:13,28:15},Lre=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class Dre{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){const s=typeof t=="function"?t():t;An.log(`${this.time} [${e}] ${s}`)}}}const Bu=function(e){const t=[];for(let s=0;s<e.length;s++)t.push(e[s].toString(16));return t};class ML{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 s=0;s<t.length;s++){const r=t[s];e.hasOwnProperty(r)&&(this[r]=e[r])}}isDefault(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!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 jre{constructor(){this.uchar=" ",this.penState=new ML}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 Ore{constructor(e){this.chars=[],this.pos=0,this.currPenState=new ML,this.cueStartTime=null,this.logger=void 0;for(let t=0;t<_l;t++)this.chars.push(new jre);this.logger=e}equals(e){for(let t=0;t<_l;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}copy(e){for(let t=0;t<_l;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<_l;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>_l&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=_l)}moveCursor(e){const t=this.pos+e;if(e>1)for(let s=this.pos+1;s<t+1;s++)this.chars[s].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=OL(e);if(this.pos>=_l){this.logger.log(0,()=>"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1)}clearFromPos(e){let t;for(t=e;t<_l;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 s=0;s<_l;s++){const r=this.chars[s].uchar;r!==" "&&(t=!1),e.push(r)}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}}class Dv{constructor(e){this.rows=[],this.currRow=to-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let t=0;t<to;t++)this.rows.push(new Ore(e));this.logger=e}reset(){for(let e=0;e<to;e++)this.rows[e].clear();this.currRow=to-1}equals(e){let t=!0;for(let s=0;s<to;s++)if(!this.rows[s].equals(e.rows[s])){t=!1;break}return t}copy(e){for(let t=0;t<to;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<to;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 = "+jn(e));let t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(let l=0;l<to;l++)this.rows[l].clear();const i=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){const l=a.rows[i].cueStartTime,c=this.logger.time;if(l!==null&&c!==null&&l<c)for(let d=0;d<this.nrRollUpRows;d++)this.rows[t-this.nrRollUpRows+d+1].copy(a.rows[i+d])}}this.currRow=t;const s=this.rows[this.currRow];if(e.indent!==null){const i=e.indent,a=Math.max(i-1,0);s.setCursor(e.indent),e.color=s.chars[a].penState.foreground}const r={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(r)}setBkgData(e){this.logger.log(2,()=>"bkgData = "+jn(e)),this.backSpace(),this.setPen(e),this.insertChar(32)}setRollUpRows(e){this.nrRollUpRows=e}rollUp(){if(this.nrRollUpRows===null){this.logger.log(3,"roll_up but nrRollUpRows not set yet");return}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 s="",r=-1;for(let i=0;i<to;i++){const a=this.rows[i].getTextString();a&&(r=i+1,e?t.push("Row "+r+": '"+a+"'"):t.push(a.trim()))}return t.length>0&&(e?s="["+t.join(" | ")+"]":s=t.join(` 125`)),s}getTextAndFormat(){return this.rows}}class EI{constructor(e,t,s){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 Dv(s),this.nonDisplayedMemory=new Dv(s),this.lastOutputScreen=new Dv(s),this.currRollUpRow=this.displayedMemory.rows[to-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=s}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[to-1],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),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}insertChars(e){for(let s=0;s<e.length;s++)this.writeScreen.insertChar(e[s]);const t=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>t+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(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"),this.mode!=="MODE_TEXT"&&(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"),this.mode==="MODE_POP-ON"){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 s=Math.floor(e/2)-16,r=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=r[s]}this.logger.log(2,"MIDROW: "+jn(t)),this.writeScreen.setPen(t)}outputDataUpdate(e=!1){const t=this.logger.time;t!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=t: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.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 TI{constructor(e,t,s){this.channels=void 0,this.currentChannel=0,this.cmdHistory=Fre(),this.logger=void 0;const r=this.logger=new Dre;this.channels=[null,new EI(e,t,r),new EI(e+1,s,r)]}getHandler(e){return this.channels[e].getHandler()}setHandler(e,t){this.channels[e].setHandler(t)}addData(e,t){this.logger.time=e;for(let s=0;s<t.length;s+=2){const r=t[s]&127,i=t[s+1]&127;let a=!1,l=null;if(r===0&&i===0)continue;this.logger.log(3,()=>"["+Bu([t[s],t[s+1]])+"] -> ("+Bu([r,i])+")");const c=this.cmdHistory;if(r>=16&&r<=31){if(Mre(r,i,c)){l0(null,null,c),this.logger.log(3,()=>"Repeated command ("+Bu([r,i])+") is dropped");continue}l0(r,i,this.cmdHistory),a=this.parseCmd(r,i),a||(a=this.parseMidrow(r,i)),a||(a=this.parsePAC(r,i)),a||(a=this.parseBackgroundAttributes(r,i))}else l0(null,null,c);if(!a&&(l=this.parseChars(r,i),l)){const h=this.currentChannel;h&&h>0?this.channels[h].insertChars(l):this.logger.log(2,"No channel found yet. TEXT-MODE?")}!a&&!l&&this.logger.log(2,()=>"Couldn't parse cleaned data "+Bu([r,i])+" orig: "+Bu([t[s],t[s+1]]))}}parseCmd(e,t){const s=(e===20||e===28||e===21||e===29)&&t>=32&&t<=47,r=(e===23||e===31)&&t>=33&&t<=35;if(!(s||r))return!1;const i=e===20||e===21||e===23?1:2,a=this.channels[i];return e===20||e===21||e===28||e===29?t===32?a.ccRCL():t===33?a.ccBS():t===34?a.ccAOF():t===35?a.ccAON():t===36?a.ccDER():t===37?a.ccRU(2):t===38?a.ccRU(3):t===39?a.ccRU(4):t===40?a.ccFON():t===41?a.ccRDC():t===42?a.ccTR():t===43?a.ccRTD():t===44?a.ccEDM():t===45?a.ccCR():t===46?a.ccENM():t===47&&a.ccEOC():a.ccTO(t-32),this.currentChannel=i,!0}parseMidrow(e,t){let s=0;if((e===17||e===25)&&t>=32&&t<=47){if(e===17?s=1:s=2,s!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;const r=this.channels[s];return r?(r.ccMIDROW(t),this.logger.log(3,()=>"MIDROW ("+Bu([e,t])+")"),!0):!1}return!1}parsePAC(e,t){let s;const r=(e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127,i=(e===16||e===24)&&t>=64&&t<=95;if(!(r||i))return!1;const a=e<=23?1:2;t>=64&&t<=95?s=a===1?kre[e]:Pre[e]:s=a===1?Rre[e]:Nre[e];const l=this.channels[a];return l?(l.setPAC(this.interpretPAC(s,t)),this.currentChannel=a,!0):!1}interpretPAC(e,t){let s;const r={color:null,italics:!1,indent:null,underline:!1,row:e};return t>95?s=t-96:s=t-64,r.underline=(s&1)===1,s<=13?r.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(s/2)]:s<=15?(r.italics=!0,r.color="white"):r.indent=Math.floor((s-16)/2)*4,r}parseChars(e,t){let s,r=null,i=null;if(e>=25?(s=2,i=e-8):(s=1,i=e),i>=17&&i<=19){let a;i===17?a=t+80:i===18?a=t+112:a=t+144,this.logger.log(2,()=>"Special char '"+OL(a)+"' in channel "+s),r=[a]}else e>=32&&e<=127&&(r=t===0?[e]:[e,t]);return r&&this.logger.log(3,()=>"Char codes = "+Bu(r).join(",")),r}parseBackgroundAttributes(e,t){const s=(e===16||e===24)&&t>=32&&t<=47,r=(e===23||e===31)&&t>=45&&t<=47;if(!(s||r))return!1;let i;const a={};e===16||e===24?(i=Math.floor((t-32)/2),a.background=Lre[i],t%2===1&&(a.background=a.background+"_semi")):t===45?a.background="transparent":(a.foreground="black",t===47&&(a.underline=!0));const l=e<=23?1:2;return this.channels[l].setBkgData(a),!0}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){const t=this.channels[e];t&&t.reset()}l0(null,null,this.cmdHistory)}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){const s=this.channels[t];s&&s.cueSplitAtTime(e)}}}function l0(n,e,t){t.a=n,t.b=e}function Mre(n,e,t){return t.a===n&&t.b===e}function Fre(){return{a:null,b:null}}var vS=(function(){if(V1!=null&&V1.VTTCue)return self.VTTCue;const n=["","lr","rl"],e=["start","middle","end","left","right"];function t(l,c){if(typeof c!="string"||!Array.isArray(l))return!1;const d=c.toLowerCase();return~l.indexOf(d)?d:!1}function s(l){return t(n,l)}function r(l){return t(e,l)}function i(l,...c){let d=1;for(;d<arguments.length;d++){const h=arguments[d];for(const p in h)l[p]=h[p]}return l}function a(l,c,d){const h=this,p={enumerable:!0};h.hasBeenReset=!1;let m="",y=!1,x=l,w=c,S=d,_=null,L="",R=!0,M="auto",V="start",W=50,I="middle",k=50,P="middle";Object.defineProperty(h,"id",i({},p,{get:function(){return m},set:function(N){m=""+N}})),Object.defineProperty(h,"pauseOnExit",i({},p,{get:function(){return y},set:function(N){y=!!N}})),Object.defineProperty(h,"startTime",i({},p,{get:function(){return x},set:function(N){if(typeof N!="number")throw new TypeError("Start time must be set to a number.");x=N,this.hasBeenReset=!0}})),Object.defineProperty(h,"endTime",i({},p,{get:function(){return w},set:function(N){if(typeof N!="number")throw new TypeError("End time must be set to a number.");w=N,this.hasBeenReset=!0}})),Object.defineProperty(h,"text",i({},p,{get:function(){return S},set:function(N){S=""+N,this.hasBeenReset=!0}})),Object.defineProperty(h,"region",i({},p,{get:function(){return _},set:function(N){_=N,this.hasBeenReset=!0}})),Object.defineProperty(h,"vertical",i({},p,{get:function(){return L},set:function(N){const F=s(N);if(F===!1)throw new SyntaxError("An invalid or illegal string was specified.");L=F,this.hasBeenReset=!0}})),Object.defineProperty(h,"snapToLines",i({},p,{get:function(){return R},set:function(N){R=!!N,this.hasBeenReset=!0}})),Object.defineProperty(h,"line",i({},p,{get:function(){return M},set:function(N){if(typeof N!="number"&&N!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");M=N,this.hasBeenReset=!0}})),Object.defineProperty(h,"lineAlign",i({},p,{get:function(){return V},set:function(N){const F=r(N);if(!F)throw new SyntaxError("An invalid or illegal string was specified.");V=F,this.hasBeenReset=!0}})),Object.defineProperty(h,"position",i({},p,{get:function(){return W},set:function(N){if(N<0||N>100)throw new Error("Position must be between 0 and 100.");W=N,this.hasBeenReset=!0}})),Object.defineProperty(h,"positionAlign",i({},p,{get:function(){return I},set:function(N){const F=r(N);if(!F)throw new SyntaxError("An invalid or illegal string was specified.");I=F,this.hasBeenReset=!0}})),Object.defineProperty(h,"size",i({},p,{get:function(){return k},set:function(N){if(N<0||N>100)throw new Error("Size must be between 0 and 100.");k=N,this.hasBeenReset=!0}})),Object.defineProperty(h,"align",i({},p,{get:function(){return P},set:function(N){const F=r(N);if(!F)throw new SyntaxError("An invalid or illegal string was specified.");P=F,this.hasBeenReset=!0}})),h.displayState=void 0}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a})();class Ure{decode(e,t){if(!e)return"";if(typeof e!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}function FL(n){function e(s,r,i,a){return(s|0)*3600+(r|0)*60+(i|0)+parseFloat(a||0)}const t=n.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return t?parseFloat(t[2])>59?e(t[2],t[3],0,t[4]):e(t[1],t[2],t[3],t[4]):null}class Vre{constructor(){this.values=Object.create(null)}set(e,t){!this.get(e)&&t!==""&&(this.values[e]=t)}get(e,t,s){return s?this.has(e)?this.values[e]:t[s]:this.has(e)?this.values[e]:t}has(e){return e in this.values}alt(e,t,s){for(let r=0;r<s.length;++r)if(t===s[r]){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 s=parseFloat(t);if(s>=0&&s<=100)return this.set(e,s),!0}return!1}}function UL(n,e,t,s){const r=s?n.split(s):[n];for(const i in r){if(typeof r[i]!="string")continue;const a=r[i].split(t);if(a.length!==2)continue;const l=a[0],c=a[1];e(l,c)}}const gw=new vS(0,0,""),c0=gw.align==="middle"?"middle":"center";function Bre(n,e,t){const s=n;function r(){const l=FL(n);if(l===null)throw new Error("Malformed timestamp: "+s);return n=n.replace(/^[^\sa-zA-Z-]+/,""),l}function i(l,c){const d=new Vre;UL(l,function(m,y){let x;switch(m){case"region":for(let w=t.length-1;w>=0;w--)if(t[w].id===y){d.set(m,t[w].region);break}break;case"vertical":d.alt(m,y,["rl","lr"]);break;case"line":x=y.split(","),d.integer(m,x[0]),d.percent(m,x[0])&&d.set("snapToLines",!1),d.alt(m,x[0],["auto"]),x.length===2&&d.alt("lineAlign",x[1],["start",c0,"end"]);break;case"position":x=y.split(","),d.percent(m,x[0]),x.length===2&&d.alt("positionAlign",x[1],["start",c0,"end","line-left","line-right","auto"]);break;case"size":d.percent(m,y);break;case"align":d.alt(m,y,["start",c0,"end","left","right"]);break}},/:/,/\s/),c.region=d.get("region",null),c.vertical=d.get("vertical","");let h=d.get("line","auto");h==="auto"&&gw.line===-1&&(h=-1),c.line=h,c.lineAlign=d.get("lineAlign","start"),c.snapToLines=d.get("snapToLines",!0),c.size=d.get("size",100),c.align=d.get("align",c0);let p=d.get("position","auto");p==="auto"&&gw.position===50&&(p=c.align==="start"||c.align==="left"?0:c.align==="end"||c.align==="right"?100:50),c.position=p}function a(){n=n.replace(/^\s+/,"")}if(a(),e.startTime=r(),a(),n.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+s);n=n.slice(3),a(),e.endTime=r(),a(),i(n,e)}function VL(n){return n.replace(/<br(?: \/)?>/gi,` 126`)}class zre{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new Ure,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(e){const t=this;e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));function s(){let i=t.buffer,a=0;for(i=VL(i);a<i.length&&i[a]!=="\r"&&i[a]!==` 127`;)++a;const l=i.slice(0,a);return i[a]==="\r"&&++a,i[a]===` 128`&&++a,t.buffer=i.slice(a),l}function r(i){UL(i,function(a,l){},/:/)}try{let i="";if(t.state==="INITIAL"){if(!/\r\n|\n/.test(t.buffer))return this;i=s();const l=i.match(/^()?WEBVTT([ \t].*)?$/);if(!(l!=null&&l[0]))throw new Error("Malformed WebVTT signature.");t.state="HEADER"}let a=!1;for(;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(a?a=!1:i=s(),t.state){case"HEADER":/:/.test(i)?r(i):i||(t.state="ID");continue;case"NOTE":i||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(i)){t.state="NOTE";break}if(!i)continue;if(t.cue=new vS(0,0,""),t.state="CUE",i.indexOf("-->")===-1){t.cue.id=i;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{Bre(i,t.cue,t.regionList)}catch{t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{const l=i.indexOf("-->")!==-1;if(!i||l&&(a=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(t.cue===null)continue;t.cue.text&&(t.cue.text+=` 129`),t.cue.text+=i}continue;case"BADCUE":i||(t.state="ID")}}}catch{t.state==="CUETEXT"&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state=t.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this}flush(){const e=this;try{if((e.cue||e.state==="HEADER")&&(e.buffer+=` 130 131`,e.parse()),e.state==="INITIAL"||e.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this}}const $re=/\r\n|\n\r|\n|\r/g,jv=function(e,t,s=0){return e.slice(s,s+t.length)===t},Hre=function(e){let t=parseInt(e.slice(-3));const s=parseInt(e.slice(-6,-4)),r=parseInt(e.slice(-9,-7)),i=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!et(t)||!et(s)||!et(r)||!et(i))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*s,t+=60*1e3*r,t+=3600*1e3*i,t};function bS(n,e,t){return Vp(n.toString())+Vp(e.toString())+Vp(t)}const Wre=function(e,t,s){let r=e[t],i=e[r.prevCC];if(!i||!i.new&&r.new){e.ccOffset=e.presentationOffset=r.start,r.new=!1;return}for(;(a=i)!=null&&a.new;){var a;e.ccOffset+=r.start-i.start,r.new=!1,r=i,i=e[r.prevCC]}e.presentationOffset=s};function Gre(n,e,t,s,r,i,a){const l=new zre,c=na(new Uint8Array(n)).trim().replace($re,` 132`).split(` 133`),d=[],h=e?ase(e.baseTime,e.timescale):0;let p="00:00.000",m=0,y=0,x,w=!0;l.oncue=function(S){const _=t[s];let L=t.ccOffset;const R=(m-h)/9e4;if(_!=null&&_.new&&(y!==void 0?L=t.ccOffset=_.start:Wre(t,s,R)),R){if(!e){x=new Error("Missing initPTS for VTT MPEGTS");return}L=R-t.presentationOffset}const M=S.endTime-S.startTime,V=Qi((S.startTime+L-y)*9e4,r*9e4)/9e4;S.startTime=Math.max(V,0),S.endTime=Math.max(V+M,0);const W=S.text.trim();S.text=decodeURIComponent(encodeURIComponent(W)),S.id||(S.id=bS(S.startTime,S.endTime,W)),S.endTime>0&&d.push(S)},l.onparsingerror=function(S){x=S},l.onflush=function(){if(x){a(x);return}i(d)},c.forEach(S=>{if(w)if(jv(S,"X-TIMESTAMP-MAP=")){w=!1,S.slice(16).split(",").forEach(_=>{jv(_,"LOCAL:")?p=_.slice(6):jv(_,"MPEGTS:")&&(m=parseInt(_.slice(7)))});try{y=Hre(p)/1e3}catch(_){x=_}return}else S===""&&(w=!1);l.parse(S+` 134`)}),l.flush()}const Ov="stpp.ttml.im1t",BL=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,zL=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,Kre={left:"start",center:"center",right:"end",start:"start",end:"end"};function _I(n,e,t,s){const r=qt(new Uint8Array(n),["mdat"]);if(r.length===0){s(new Error("Could not parse IMSC1 mdat"));return}const i=r.map(l=>na(l)),a=ise(e.baseTime,1,e.timescale);try{i.forEach(l=>t(qre(l,a)))}catch(l){s(l)}}function qre(n,e){const r=new DOMParser().parseFromString(n,"text/xml").getElementsByTagName("tt")[0];if(!r)throw new Error("Invalid ttml");const i={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},a=Object.keys(i).reduce((p,m)=>(p[m]=r.getAttribute(`ttp:${m}`)||i[m],p),{}),l=r.getAttribute("xml:space")!=="preserve",c=II(Mv(r,"styling","style")),d=II(Mv(r,"layout","region")),h=Mv(r,"body","[begin]");return[].map.call(h,p=>{const m=$L(p,l);if(!m||!p.hasAttribute("begin"))return null;const y=Uv(p.getAttribute("begin"),a),x=Uv(p.getAttribute("dur"),a);let w=Uv(p.getAttribute("end"),a);if(y===null)throw AI(p);if(w===null){if(x===null)throw AI(p);w=y+x}const S=new vS(y-e,w-e,m);S.id=bS(S.startTime,S.endTime,S.text);const _=d[p.getAttribute("region")],L=c[p.getAttribute("style")],R=Yre(_,L,c),{textAlign:M}=R;if(M){const V=Kre[M];V&&(S.lineAlign=V),S.align=M}return kn(S,R),S}).filter(p=>p!==null)}function Mv(n,e,t){const s=n.getElementsByTagName(e)[0];return s?[].slice.call(s.querySelectorAll(t)):[]}function II(n){return n.reduce((e,t)=>{const s=t.getAttribute("xml:id");return s&&(e[s]=t),e},{})}function $L(n,e){return[].slice.call(n.childNodes).reduce((t,s,r)=>{var i;return s.nodeName==="br"&&r?t+` 135`:(i=s.childNodes)!=null&&i.length?$L(s,e):e?t+s.textContent.trim().replace(/\s+/g," "):t+s.textContent},"")}function Yre(n,e,t){const s="http://www.w3.org/ns/ttml#styling";let r=null;const i=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],a=n!=null&&n.hasAttribute("style")?n.getAttribute("style"):null;return a&&t.hasOwnProperty(a)&&(r=t[a]),i.reduce((l,c)=>{const d=Fv(e,s,c)||Fv(n,s,c)||Fv(r,s,c);return d&&(l[c]=d),l},{})}function Fv(n,e,t){return n&&n.hasAttributeNS(e,t)?n.getAttributeNS(e,t):null}function AI(n){return new Error(`Could not parse ttml timestamp ${n}`)}function Uv(n,e){if(!n)return null;let t=FL(n);return t===null&&(BL.test(n)?t=Qre(n,e):zL.test(n)&&(t=Xre(n,e))),t}function Qre(n,e){const t=BL.exec(n),s=(t[4]|0)+(t[5]|0)/e.subFrameRate;return(t[1]|0)*3600+(t[2]|0)*60+(t[3]|0)+s/e.frameRate}function Xre(n,e){const t=zL.exec(n),s=Number(t[1]);switch(t[2]){case"h":return s*3600;case"m":return s*60;case"ms":return s*1e3;case"f":return s/e.frameRate;case"t":return s/e.tickRate}return s}class u0{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(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(e,t,s){(this.startTime===null||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=s,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}class HL{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=kI(),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(j.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(j.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(j.MANIFEST_LOADING,this.onManifestLoading,this),e.on(j.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(j.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(j.FRAG_LOADING,this.onFragLoading,this),e.on(j.FRAG_LOADED,this.onFragLoaded,this),e.on(j.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(j.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(j.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(j.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(j.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:e}=this;e.off(j.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(j.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(j.MANIFEST_LOADING,this.onManifestLoading,this),e.off(j.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(j.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(j.FRAG_LOADING,this.onFragLoading,this),e.off(j.FRAG_LOADED,this.onFragLoaded,this),e.off(j.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(j.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(j.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(j.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(j.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.media=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){const e=new u0(this,"textTrack1"),t=new u0(this,"textTrack2"),s=new u0(this,"textTrack3"),r=new u0(this,"textTrack4");this.cea608Parser1=new TI(1,e,t),this.cea608Parser2=new TI(3,s,r)}addCues(e,t,s,r,i){let a=!1;for(let l=i.length;l--;){const c=i[l],d=Jre(c[0],c[1],t,s);if(d>=0&&(c[0]=Math.min(c[0],t),c[1]=Math.max(c[1],s),a=!0,d/(s-t)>.5))return}if(a||i.push([t,s]),this.config.renderTextTracksNatively){const l=this.captionsTracks[e];this.Cues.newCue(l,t,s,r)}else{const l=this.Cues.newCue(null,t,s,r);this.hls.trigger(j.CUES_PARSED,{type:"captions",cues:l,track:e})}}onInitPtsFound(e,{frag:t,id:s,initPTS:r,timescale:i,trackId:a}){const{unparsedVttFrags:l}=this;s===st.MAIN&&(this.initPTS[t.cc]={baseTime:r,timescale:i,trackId:a}),l.length&&(this.unparsedVttFrags=[],l.forEach(c=>{this.initPTS[c.frag.cc]?this.onFragLoaded(j.FRAG_LOADED,c):this.hls.trigger(j.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:c.frag,error:new Error("Subtitle discontinuity domain does not match main")})}))}getExistingTrack(e,t){const{media:s}=this;if(s)for(let r=0;r<s.textTracks.length;r++){const i=s.textTracks[r];if(CI(i,{name:e,lang:t,characteristics:"transcribes-spoken-dialog,describes-music-and-sound"}))return i}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(this.captionsTracks[e])return;const{captionsProperties:t,captionsTracks:s,media:r}=this,{label:i,languageCode:a}=t[e],l=this.getExistingTrack(i,a);if(l)s[e]=l,Ch(s[e]),PL(s[e],r);else{const c=this.createTextTrack("captions",i,a);c&&(c[e]=!0,s[e]=c)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;const t=this.captionsProperties[e];if(!t)return;const s=t.label,r={_id:e,label:s,kind:"captions",default:t.media?!!t.media.default:!1,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=r,this.hls.trigger(j.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[r]})}createTextTrack(e,t,s){const r=this.media;if(r)return r.addTextTrack(e,t,s)}onMediaAttaching(e,t){this.media=t.media,t.mediaSource||this._cleanTracks()}onMediaDetaching(e,t){const s=!!t.transferMedia;if(this.media=null,s)return;const{captionsTracks:r}=this;Object.keys(r).forEach(i=>{Ch(r[i]),delete r[i]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=kI(),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 s=0;s<t.length;s++)Ch(t[s])}onSubtitleTracksUpdated(e,t){const s=t.subtitleTracks||[],r=s.some(i=>i.textCodec===Ov);if(this.config.enableWebVTT||r&&this.config.enableIMSC1){if(fL(this.tracks,s)){this.tracks=s;return}if(this.textTracks=[],this.tracks=s,this.config.renderTextTracksNatively){const a=this.media,l=a?U0(a.textTracks):null;if(this.tracks.forEach((c,d)=>{let h;if(l){let p=null;for(let m=0;m<l.length;m++)if(l[m]&&CI(l[m],c)){p=l[m],l[m]=null;break}p&&(h=p)}if(h)Ch(h);else{const p=WL(c);h=this.createTextTrack(p,c.name,c.lang),h&&(h.mode="disabled")}h&&this.textTracks.push(h)}),l!=null&&l.length){const c=l.filter(d=>d!==null).map(d=>d.label);c.length&&this.hls.logger.warn(`Media element contains unused subtitle tracks: ${c.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`)}}else if(this.tracks.length){const a=this.tracks.map(l=>({label:l.name,kind:l.type.toLowerCase(),default:l.default,subtitleTrack:l}));this.hls.trigger(j.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:a})}}}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(s=>{const r=/(?:CC|SERVICE)([1-4])/.exec(s.instreamId);if(!r)return;const i=`textTrack${r[1]}`,a=this.captionsProperties[i];a&&(a.label=s.name,s.lang&&(a.languageCode=s.lang),a.media=s)})}closedCaptionsForLevel(e){const t=this.hls.levels[e.level];return t?.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){if(this.enabled&&t.frag.type===st.MAIN){var s,r;const{cea608Parser1:i,cea608Parser2:a,lastSn:l}=this,{cc:c,sn:d}=t.frag,h=(s=(r=t.part)==null?void 0:r.index)!=null?s:-1;i&&a&&(d!==l+1||d===l&&h!==this.lastPartIndex+1||c!==this.lastCc)&&(i.reset(),a.reset()),this.lastCc=c,this.lastSn=d,this.lastPartIndex=h}}onFragLoaded(e,t){const{frag:s,payload:r}=t;if(s.type===st.SUBTITLE)if(r.byteLength){const i=s.decryptdata,a="stats"in t;if(i==null||!i.encrypted||a){const l=this.tracks[s.level],c=this.vttCCs;c[s.cc]||(c[s.cc]={start:s.start,prevCC:this.prevCC,new:!0},this.prevCC=s.cc),l&&l.textCodec===Ov?this._parseIMSC1(s,r):this._parseVTTs(t)}}else this.hls.trigger(j.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:s,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){const s=this.hls;_I(t,this.initPTS[e.cc],r=>{this._appendCues(r,e.level),s.trigger(j.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},r=>{s.logger.log(`Failed to parse IMSC1: ${r}`),s.trigger(j.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:r})})}_parseVTTs(e){var t;const{frag:s,payload:r}=e,{initPTS:i,unparsedVttFrags:a}=this,l=i.length-1;if(!i[s.cc]&&l===-1){a.push(e);return}const c=this.hls,d=(t=s.initSegment)!=null&&t.data?ka(s.initSegment.data,new Uint8Array(r)).buffer:r;Gre(d,this.initPTS[s.cc],this.vttCCs,s.cc,s.start,h=>{this._appendCues(h,s.level),c.trigger(j.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:s})},h=>{const p=h.message==="Missing initPTS for VTT MPEGTS";p?a.push(e):this._fallbackToIMSC1(s,r),c.logger.log(`Failed to parse VTT cue: ${h}`),!(p&&l>s.cc)&&c.trigger(j.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:s,error:h})})}_fallbackToIMSC1(e,t){const s=this.tracks[e.level];s.textCodec||_I(t,this.initPTS[e.cc],()=>{s.textCodec=Ov,this._parseIMSC1(e,t)},()=>{s.textCodec="wvtt"})}_appendCues(e,t){const s=this.hls;if(this.config.renderTextTracksNatively){const r=this.textTracks[t];if(!r||r.mode==="disabled")return;e.forEach(i=>NL(r,i))}else{const r=this.tracks[t];if(!r)return;const i=r.default?"default":"subtitles"+t;s.trigger(j.CUES_PARSED,{type:"subtitles",cues:e,track:i})}}onFragDecrypted(e,t){const{frag:s}=t;s.type===st.SUBTITLE&&this.onFragLoaded(j.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){if(!this.enabled||!this.config.enableCEA708Captions)return;const{frag:s,samples:r}=t;if(!(s.type===st.MAIN&&this.closedCaptionsForLevel(s)==="NONE"))for(let i=0;i<r.length;i++){const a=r[i].bytes;if(a){this.cea608Parser1||this.initCea608Parsers();const l=this.extractCea608Data(a);this.cea608Parser1.addData(r[i].pts,l[0]),this.cea608Parser2.addData(r[i].pts,l[1])}}}onBufferFlushing(e,{startOffset:t,endOffset:s,endOffsetSubtitles:r,type:i}){const{media:a}=this;if(!(!a||a.currentTime<s)){if(!i||i==="video"){const{captionsTracks:l}=this;Object.keys(l).forEach(c=>mw(l[c],t,s))}if(this.config.renderTextTracksNatively&&t===0&&r!==void 0){const{textTracks:l}=this;Object.keys(l).forEach(c=>mw(l[c],t,r))}}}extractCea608Data(e){const t=[[],[]],s=e[0]&31;let r=2;for(let i=0;i<s;i++){const a=e[r++],l=127&e[r++],c=127&e[r++];if(l===0&&c===0)continue;if((4&a)!==0){const h=3&a;(h===0||h===1)&&(t[h].push(l),t[h].push(c))}}return t}}function WL(n){return n.characteristics&&/transcribes-spoken-dialog/gi.test(n.characteristics)&&/describes-music-and-sound/gi.test(n.characteristics)?"captions":"subtitles"}function CI(n,e){return!!n&&n.kind===WL(e)&&dw(e,n)}function Jre(n,e,t,s){return Math.min(e,s)-Math.max(n,t)}function kI(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}const Zre=/\s/,GL={newCue(n,e,t,s){const r=[];let i,a,l,c,d;const h=self.VTTCue||self.TextTrackCue;for(let m=0;m<s.rows.length;m++)if(i=s.rows[m],l=!0,c=0,d="",!i.isEmpty()){var p;for(let w=0;w<i.chars.length;w++)Zre.test(i.chars[w].uchar)&&l?c++:(d+=i.chars[w].uchar,l=!1);i.cueStartTime=e,e===t&&(t+=1e-4),c>=16?c--:c++;const y=VL(d.trim()),x=bS(e,t,y);n!=null&&(p=n.cues)!=null&&p.getCueById(x)||(a=new h(e,t,y),a.id=x,a.line=m+1,a.align="left",a.position=10+Math.min(80,Math.floor(c*8/32)*10),r.push(a))}return n&&r.length&&(r.sort((m,y)=>m.line==="auto"||y.line==="auto"?0:m.line>8&&y.line>8?y.line-m.line:m.line-y.line),r.forEach(m=>NL(n,m))),r}};function KL(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}const eie=/(\d+)-(\d+)\/(\d+)/;class xw{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||rie,this.controller=new self.AbortController,this.stats=new sy}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(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(e,t,s){const r=this.stats;if(r.loading.start)throw new Error("Loader can only be used once.");r.loading.start=self.performance.now();const i=tie(e,this.controller.signal),a=e.responseType==="arraybuffer",l=a?"byteLength":"length",{maxTimeToFirstByteMs:c,maxLoadTimeMs:d}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=s,this.request=this.fetchSetup(e,i),self.clearTimeout(this.requestTimeout),t.timeout=c&&et(c)?c:d,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(r,e,this.response))},t.timeout),(bm(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then(p=>{var m;this.response=this.loader=p;const y=Math.max(self.performance.now(),r.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=d,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(r,e,this.response))},d-(y-r.loading.start)),!p.ok){const{status:w,statusText:S}=p;throw new iie(S||"fetch, bad network response",w,p)}r.loading.first=y,r.total=sie(p.headers)||r.total;const x=(m=this.callbacks)==null?void 0:m.onProgress;return x&&et(t.highWaterMark)?this.loadProgressively(p,r,e,t.highWaterMark,x):a?p.arrayBuffer():e.responseType==="json"?p.json():p.text()}).then(p=>{var m,y;const x=this.response;if(!x)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),r.loading.end=Math.max(self.performance.now(),r.loading.first);const w=p[l];w&&(r.loaded=r.total=w);const S={url:x.url,data:p,code:x.status},_=(m=this.callbacks)==null?void 0:m.onProgress;_&&!et(t.highWaterMark)&&_(r,e,p,x),(y=this.callbacks)==null||y.onSuccess(S,r,e,x)}).catch(p=>{var m;if(self.clearTimeout(this.requestTimeout),r.aborted)return;const y=p&&p.code||0,x=p?p.message:null;(m=this.callbacks)==null||m.onError({code:y,text:x},e,p?p.details:null,r)})}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,s,r=0,i){const a=new GN,l=e.body.getReader(),c=()=>l.read().then(d=>{if(d.done)return a.dataLength&&i(t,s,a.flush().buffer,e),Promise.resolve(new ArrayBuffer(0));const h=d.value,p=h.length;return t.loaded+=p,p<r||a.dataLength?(a.push(h),a.dataLength>=r&&i(t,s,a.flush().buffer,e)):i(t,s,h.buffer,e),c()}).catch(()=>Promise.reject());return c()}}function tie(n,e){const t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(kn({},n.headers))};return n.rangeEnd&&t.headers.set("Range","bytes="+n.rangeStart+"-"+String(n.rangeEnd-1)),t}function nie(n){const e=eie.exec(n);if(e)return parseInt(e[2])-parseInt(e[1])+1}function sie(n){const e=n.get("Content-Range");if(e){const s=nie(e);if(et(s))return s}const t=n.get("Content-Length");if(t)return parseInt(t)}function rie(n,e){return new self.Request(n.url,e)}class iie extends Error{constructor(e,t,s){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=s}}const aie=/^age:\s*[\d.]+\s*$/im;class wS{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 sy,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,e.readyState!==4&&(this.stats.aborted=!0,e.abort()))}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(e,t,s){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=s,this.loadInternal()}loadInternal(){const{config:e,context:t}=this;if(!e||!t)return;const s=this.loader=new self.XMLHttpRequest,r=this.stats;r.loading.first=0,r.loaded=0,r.aborted=!1;const i=this.xhrSetup;i?Promise.resolve().then(()=>{if(!(this.loader!==s||this.stats.aborted))return i(s,t.url)}).catch(a=>{if(!(this.loader!==s||this.stats.aborted))return s.open("GET",t.url,!0),i(s,t.url)}).then(()=>{this.loader!==s||this.stats.aborted||this.openAndSendXhr(s,t,e)}).catch(a=>{var l;(l=this.callbacks)==null||l.onError({code:s.status,text:a.message},t,s,r)}):this.openAndSendXhr(s,t,e)}openAndSendXhr(e,t,s){e.readyState||e.open("GET",t.url,!0);const r=t.headers,{maxTimeToFirstByteMs:i,maxLoadTimeMs:a}=s.loadPolicy;if(r)for(const l in r)e.setRequestHeader(l,r[l]);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),s.timeout=i&&et(i)?i:a,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),s.timeout),e.send()}readystatechange(){const{context:e,loader:t,stats:s}=this;if(!e||!t)return;const r=t.readyState,i=this.config;if(!s.aborted&&r>=2&&(s.loading.first===0&&(s.loading.first=Math.max(self.performance.now(),s.loading.start),i.timeout!==i.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),i.timeout=i.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.loadPolicy.maxLoadTimeMs-(s.loading.first-s.loading.start)))),r===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;const d=t.status,h=t.responseType==="text"?t.responseText:null;if(d>=200&&d<300){const x=h??t.response;if(x!=null){var a,l;s.loading.end=Math.max(self.performance.now(),s.loading.first);const w=t.responseType==="arraybuffer"?x.byteLength:x.length;s.loaded=s.total=w,s.bwEstimate=s.total*8e3/(s.loading.end-s.loading.first);const S=(a=this.callbacks)==null?void 0:a.onProgress;S&&S(s,e,x,t);const _={url:t.responseURL,data:x,code:d};(l=this.callbacks)==null||l.onSuccess(_,s,e,t);return}}const p=i.loadPolicy.errorRetry,m=s.retry,y={url:e.url,data:void 0,code:d};if(F1(p,m,!1,y))this.retry(p);else{var c;An.error(`${d} while loading ${e.url}`),(c=this.callbacks)==null||c.onError({code:d,text:t.statusText},e,t,s)}}}loadtimeout(){if(!this.config)return;const e=this.config.loadPolicy.timeoutRetry,t=this.stats.retry;if(F1(e,t,!0))this.retry(e);else{var s;An.warn(`timeout while loading ${(s=this.context)==null?void 0:s.url}`);const r=this.callbacks;r&&(this.abortInternal(),r.onTimeout(this.stats,this.context,this.loader))}}retry(e){const{context:t,stats:s}=this;this.retryDelay=rS(e,s.retry),s.retry++,An.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${t?.url}, retrying ${s.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&&aie.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 oie={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},lie=In(In({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:60*1e3*1e3,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:wS,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:_N,bufferController:gL,capLevelController:cy,errorController:RN,fpsController:RL,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:cS,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:oie},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},cie()),{},{subtitleStreamController:jL,subtitleTrackController:LL,timelineController:HL,audioStreamController:hL,audioTrackController:pL,emeController:dd,cmcdController:AL,contentSteeringController:CL,interstitialsController:Ire});function cie(){return{cueHandler:GL,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function uie(n,e,t){if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(e.liveMaxLatencyDurationCount!==void 0&&(e.liveSyncDurationCount===void 0||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(e.liveMaxLatencyDuration!==void 0&&(e.liveSyncDuration===void 0||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const s=yw(n),r=["manifest","level","frag"],i=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return r.forEach(a=>{const l=`${a==="level"?"playlist":a}LoadPolicy`,c=e[l]===void 0,d=[];i.forEach(h=>{const p=`${a}Loading${h}`,m=e[p];if(m!==void 0&&c){d.push(p);const y=s[l].default;switch(e[l]={default:y},h){case"TimeOut":y.maxLoadTimeMs=m,y.maxTimeToFirstByteMs=m;break;case"MaxRetry":y.errorRetry.maxNumRetry=m,y.timeoutRetry.maxNumRetry=m;break;case"RetryDelay":y.errorRetry.retryDelayMs=m,y.timeoutRetry.retryDelayMs=m;break;case"MaxRetryTimeout":y.errorRetry.maxRetryDelayMs=m,y.timeoutRetry.maxRetryDelayMs=m;break}}}),d.length&&t.warn(`hls.js config: "${d.join('", "')}" setting(s) are deprecated, use "${l}": ${jn(e[l])}`)}),In(In({},s),e)}function yw(n){return n&&typeof n=="object"?Array.isArray(n)?n.map(yw):Object.keys(n).reduce((e,t)=>(e[t]=yw(n[t]),e),{}):n}function die(n,e){const t=n.loader;t!==xw&&t!==wS?(e.log("[config]: Custom loader detected, cannot enable progressive streaming"),n.progressive=!1):KL()&&(n.loader=xw,n.progressive=!0,n.enableSoftwareAES=!0,e.log("[config]: Progressive streaming enabled, using FetchLoader"))}const V0=2,hie=.1,fie=.05,pie=100;class mie extends PN{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 s;(s=this.media)!=null&&s.seeking||(this.waiting=self.performance.now(),this.tick())},this.onMediaEnded=()=>{if(this.hls){var s;this.ended=((s=this.media)==null?void 0:s.currentTime)||1,this.hls.trigger(j.MEDIA_ENDED,{stalled:!1})}},this.hls=e,this.fragmentTracker=t,this.registerListeners()}registerListeners(){const{hls:e}=this;e&&(e.on(j.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(j.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(j.BUFFER_APPENDED,this.onBufferAppended,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off(j.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(j.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(j.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(pie),this.mediaSource=t.mediaSource;const s=this.media=t.media;ei(s,"playing",this.onMediaPlaying),ei(s,"waiting",this.onMediaWaiting),ei(s,"ended",this.onMediaEnded)}onMediaDetaching(e,t){this.clearInterval();const{media:s}=this;s&&(Ti(s,"playing",this.onMediaPlaying),Ti(s,"waiting",this.onMediaWaiting),Ti(s,"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(!((e=this.media)!=null&&e.readyState)||!this.hasBuffered)return;const t=this.media.currentTime;this.poll(t,this.lastCurrentTime),this.lastCurrentTime=t}poll(e,t){var s,r;const i=(s=this.hls)==null?void 0:s.config;if(!i)return;const a=this.media;if(!a)return;const{seeking:l}=a,c=this.seeking&&!l,d=!this.seeking&&l,h=a.paused&&!l||a.ended||a.playbackRate===0;if(this.seeking=l,e!==t){t&&(this.ended=0),this.moved=!0,l||(this.nudgeRetry=0,i.nudgeOnVideoHole&&!h&&e>t&&this.nudgeOnVideoHole(e,t)),this.waiting===0&&this.stallResolved(e);return}if(d||c){c&&this.stallResolved(e);return}if(h){this.nudgeRetry=0,this.stallResolved(e),!this.ended&&a.ended&&this.hls&&(this.ended=e||1,this.hls.trigger(j.MEDIA_ENDED,{stalled:!1}));return}if(!Bt.getBuffered(a).length){this.nudgeRetry=0;return}const p=Bt.bufferInfo(a,e,0),m=p.nextStart||0,y=this.fragmentTracker;if(l&&y&&this.hls){const W=RI(this.hls.inFlightFragments,e),I=p.len>V0,k=!m||W||m-e>V0&&!y.getPartialFragment(e);if(I||k)return;this.moved=!1}const x=(r=this.hls)==null?void 0:r.latestLevelDetails;if(!this.moved&&this.stalled!==null&&y){if(!(p.len>0)&&!m)return;const I=Math.max(m,p.start||0)-e,P=!!(x!=null&&x.live)?x.targetduration*2:V0,N=d0(e,y);if(I>0&&(I<=P||N)){a.paused||this._trySkipBufferHole(N);return}}const w=i.detectStallWithCurrentTimeMs,S=self.performance.now(),_=this.waiting;let L=this.stalled;if(L===null)if(_>0&&S-_<w)L=this.stalled=_;else{this.stalled=S;return}const R=S-L;if(!l&&(R>=w||_)&&this.hls){var M;if(((M=this.mediaSource)==null?void 0:M.readyState)==="ended"&&!(x!=null&&x.live)&&Math.abs(e-(x?.edge||0))<1){if(this.ended)return;this.ended=e||1,this.hls.trigger(j.MEDIA_ENDED,{stalled:!0});return}if(this._reportStall(p),!this.media||!this.hls)return}const V=Bt.bufferInfo(a,e,i.maxBufferHole);this._tryFixBufferStall(V,R,e)}stallResolved(e){const t=this.stalled;if(t&&this.hls&&(this.stalled=null,this.stallReported)){const s=self.performance.now()-t;this.log(`playback not stuck anymore @${e}, after ${Math.round(s)}ms`),this.stallReported=!1,this.waiting=0,this.hls.trigger(j.STALL_RESOLVED,{})}}nudgeOnVideoHole(e,t){var s;const r=this.buffered.video;
135if(this.hls&&this.media&&this.fragmentTracker&&(s=this.buffered.audio)!=null&&s.length&&r&&r.length>1&&e>r.end(0)){const i=Bt.bufferedInfo(Bt.timeRangesToArray(this.buffered.audio),e,0);if(i.len>1&&t>=i.start){const a=Bt.timeRangesToArray(r),l=Bt.bufferedInfo(a,t,0).bufferedIndex;if(l>-1&&l<a.length-1){const c=Bt.bufferedInfo(a,e,0).bufferedIndex,d=a[l].end,h=a[l+1].start;if((c===-1||c>l)&&h-d<1&&e-d<2){const p=new Error(`nudging playhead to flush pipeline after video hole. currentTime: ${e} hole: ${d} -> ${h} buffered index: ${c}`);this.warn(p.message),this.media.currentTime+=1e-6;let m=d0(e,this.fragmentTracker);m&&"fragment"in m?m=m.fragment:m||(m=void 0);const y=Bt.bufferInfo(this.media,e,0);this.hls.trigger(j.ERROR,{type:xt.MEDIA_ERROR,details:he.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:p,reason:p.message,frag:m,buffer:y.len,bufferInfo:y})}}}}}_tryFixBufferStall(e,t,s){var r,i;const{fragmentTracker:a,media:l}=this,c=(r=this.hls)==null?void 0:r.config;if(!l||!a||!c)return;const d=(i=this.hls)==null?void 0:i.latestLevelDetails,h=d0(s,a);if((h||d!=null&&d.live&&s<d.fragmentStart)&&(this._trySkipBufferHole(h)||!this.media))return;const p=e.buffered,m=this.adjacentTraversal(e,s);(p&&p.length>1&&e.len>c.maxBufferHole||e.nextStart&&(e.nextStart-s<c.maxBufferHole||m))&&(t>c.highBufferWatchdogPeriod*1e3||this.waiting)&&(this.warn("Trying to nudge playhead over buffer-hole"),this._tryNudgeBuffer(e))}adjacentTraversal(e,t){const s=this.fragmentTracker,r=e.nextStart;if(s&&r){const i=s.getFragAtPos(t,st.MAIN),a=s.getFragAtPos(r,st.MAIN);if(i&&a)return a.sn-i.sn<2}return!1}_reportStall(e){const{hls:t,media:s,stallReported:r,stalled:i}=this;if(!r&&i!==null&&s&&t){this.stallReported=!0;const a=new Error(`Playback stalling at @${s.currentTime} due to low buffer (${jn(e)})`);this.warn(a.message),t.trigger(j.ERROR,{type:xt.MEDIA_ERROR,details:he.BUFFER_STALLED_ERROR,fatal:!1,error:a,buffer:e.len,bufferInfo:e,stalled:{start:i}})}}_trySkipBufferHole(e){var t;const{fragmentTracker:s,media:r}=this,i=(t=this.hls)==null?void 0:t.config;if(!r||!s||!i)return 0;const a=r.currentTime,l=Bt.bufferInfo(r,a,0),c=a<l.start?l.start:l.nextStart;if(c&&this.hls){const h=l.len<=i.maxBufferHole,p=l.len>0&&l.len<1&&r.readyState<3,m=c-a;if(m>0&&(h||p)){if(m>i.maxBufferHole){let x=!1;if(a===0){const w=s.getAppendedFrag(0,st.MAIN);w&&c<w.end&&(x=!0)}if(!x&&e){var d;if(!((d=this.hls.loadLevelObj)!=null&&d.details)||RI(this.hls.inFlightFragments,c))return 0;let S=!1,_=e.end;for(;_<c;){const L=d0(_,s);if(L)_+=L.duration;else{S=!0;break}}if(S)return 0}}const y=Math.max(c+fie,a+hie);if(this.warn(`skipping hole, adjusting currentTime from ${a} to ${y}`),this.moved=!0,r.currentTime=y,!(e!=null&&e.gap)){const x=new Error(`fragment loaded with buffer holes, seeking from ${a} to ${y}`),w={type:xt.MEDIA_ERROR,details:he.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:x,reason:x.message,buffer:l.len,bufferInfo:l};e&&("fragment"in e?w.part=e:w.frag=e),this.hls.trigger(j.ERROR,w)}return y}}return 0}_tryNudgeBuffer(e){const{hls:t,media:s,nudgeRetry:r}=this,i=t?.config;if(!s||!i)return 0;const a=s.currentTime;if(this.nudgeRetry++,r<i.nudgeMaxRetry){const l=a+(r+1)*i.nudgeOffset,c=new Error(`Nudging 'currentTime' from ${a} to ${l}`);this.warn(c.message),s.currentTime=l,t.trigger(j.ERROR,{type:xt.MEDIA_ERROR,details:he.BUFFER_NUDGE_ON_STALL,error:c,fatal:!1,buffer:e.len,bufferInfo:e})}else{const l=new Error(`Playhead still not moving while enough data buffered @${a} after ${i.nudgeMaxRetry} nudges`);this.error(l.message),t.trigger(j.ERROR,{type:xt.MEDIA_ERROR,details:he.BUFFER_STALLED_ERROR,error:l,fatal:!0,buffer:e.len,bufferInfo:e})}}}function RI(n,e){const t=PI(n.main);if(t&&t.start<=e)return t;const s=PI(n.audio);return s&&s.start<=e?s:null}function PI(n){if(!n)return null;switch(n.state){case Ae.IDLE:case Ae.STOPPED:case Ae.ENDED:case Ae.ERROR:return null}return n.frag}function d0(n,e){return e.getAppendedFrag(n,st.MAIN)||e.getPartialFragment(n)}const gie=.25;function vw(){if(!(typeof self>"u"))return self.VTTCue||self.TextTrackCue}function Vv(n,e,t,s,r){let i=new n(e,t,"");try{i.value=s,r&&(i.type=r)}catch{i=new n(e,t,jn(r?In({type:r},s):s))}return i}const h0=(()=>
135{const n=vw();try{n&&new n(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();class xie{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(j.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(j.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(j.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(j.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(j.MANIFEST_LOADING,this.onManifestLoading,this),e.on(j.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(j.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(j.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(j.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}_unregisterListeners(){const{hls:e}=this;e&&(e.off(j.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(j.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(j.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(j.MANIFEST_LOADING,this.onManifestLoading,this),e.off(j.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(j.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(j.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(j.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}onMediaAttaching(e,t){var s;this.media=t.media,((s=t.overrides)==null?void 0:s.cueRemoval)===!1&&(this.removeCues=!1)}onMediaAttached(){var e;const t=(e=this.hls)==null?void 0:e.latestLevelDetails;t&&this.updateDateRangeCues(t)}onMediaDetaching(e,t){this.media=null,!t.transferMedia&&(this.id3Track&&(this.removeCues&&Ch(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 s=e[t];if(s.kind==="metadata"&&s.label==="id3")return PL(s,this.media),s}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media||!this.hls)return;const{enableEmsgMetadataCues:s,enableID3MetadataCues:r}=this.hls.config;if(!s&&!r)return;const{samples:i}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));const a=vw();if(a)for(let l=0;l<i.length;l++){const c=i[l].type;if(c===wi.emsg&&!s||!r)continue;const d=ZN(i[l].data),h=i[l].pts;let p=h+i[l].duration;p>h0&&(p=h0),p-h<=0&&(p=h+gie);for(let y=0;y<d.length;y++){const x=d[y];if(!eL(x)){this.updateId3CueEnds(h,c);const w=Vv(a,h,p,x,c);w&&this.id3Track.addCue(w)}}}}updateId3CueEnds(e,t){var s;const r=(s=this.id3Track)==null?void 0:s.cues;if(r)for(let i=r.length;i--;){const a=r[i];a.type===t&&a.startTime<e&&a.endTime===h0&&(a.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:s,type:r}){const{id3Track:i,hls:a}=this;if(!a)return;const{config:{enableEmsgMetadataCues:l,enableID3MetadataCues:c}}=a;if(i&&(l||c)){let d;r==="audio"?d=h=>h.type===wi.audioId3&&c:r==="video"?d=h=>h.type===wi.emsg&&l:d=h=>h.type===wi.audioId3&&c||h.type===wi.emsg&&l,mw(i,t,s,d)}}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:s,timelineOffset:r,enableDateRangeMetadataCues:i,interstitialsController:a}=this.hls.config;if(!i)return;const l=vw();if(s&&r&&!a){const{fragmentStart:w,fragmentEnd:S}=e;let _=this.assetCue;_?(_.startTime=w,_.endTime=S):l&&(_=this.assetCue=Vv(l,w,S,{assetPlayerId:this.hls.config.assetPlayerId},"hlsjs.interstitial.asset"),_&&(_.id=s,this.id3Track||(this.id3Track=this.createTrack(this.media)),this.id3Track.addCue(_),_.addEventListener("enter",this.onEventCueEnter)))}if(!e.hasProgramDateTime)return;const{id3Track:c}=this,{dateRanges:d}=e,h=Object.keys(d);let p=this.dateRangeCuesAppended;if(c&&t){var m;if((m=c.cues)!=null&&m.length){const w=Object.keys(p).filter(S=>!h.includes(S));for(let S=w.length;S--;){var y;const _=w[S],L=(y=p[_])==null?void 0:y.cues;
vendor: 6,441 bytes, line 135
135delete p[_],L&&Object.keys(L).forEach(R=>{const M=L[R];if(M){M.removeEventListener("enter",this.onEventCueEnter);try{c.removeCue(M)}catch{}}})}}else p=this.dateRangeCuesAppended={}}const x=e.fragments[e.fragments.length-1];if(!(h.length===0||!et(x?.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(let w=0;w<h.length;w++){const S=h[w],_=d[S],L=_.startTime,R=p[S],M=R?.cues||{};let V=R?.durationKnown||!1,W=h0;const{duration:I,endDate:k}=_;if(k&&I!==null)W=L+I,V=!0;else if(_.endOnNext&&!V){const N=h.reduce((F,z)=>{if(z!==_.id){const U=d[z];if(U.class===_.class&&U.startDate>_.startDate&&(!F||_.startDate<F.startDate))return U}return F},null);N&&(W=N.startTime,V=!0)}const P=Object.keys(_.attr);for(let N=0;N<P.length;N++){const F=P[N];if(!Qte(F))continue;const z=M[F];if(z)V&&!(R!=null&&R.durationKnown)?z.endTime=W:Math.abs(z.startTime-L)>.01&&(z.startTime=L,z.endTime=W);else if(l){let U=_.attr[F];Xte(F)&&(U=cN(U));const oe=Vv(l,L,W,{key:F,data:U},wi.dateRange);oe&&(oe.id=S,this.id3Track.addCue(oe),M[F]=oe,a&&(F==="X-ASSET-LIST"||F==="X-ASSET-URL")&&oe.addEventListener("enter",this.onEventCueEnter))}}p[S]={cues:M,dateRange:_,durationKnown:V}}}}}class yie{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:t}=this,s=this.levelDetails;if(!t||!s)return;this.currentTime=t.currentTime;const r=this.computeLatency();if(r===null)return;this._latency=r;const{lowLatencyMode:i,maxLiveSyncPlaybackRate:a}=this.config;if(!i||a===1||!s.live)return;const l=this.targetLatency;if(l===null)return;const c=r-l,d=Math.min(this.maxLatency,l+s.targetduration);if(c<d&&c>.05&&this.forwardBufferLength>1){const p=Math.min(2,Math.max(1,a)),m=Math.round(2/(1+Math.exp(-.75*c-this.edgeStalled))*20)/20,y=Math.min(p,Math.max(1,m));this.changeMediaPlaybackRate(t,y)}else t.playbackRate!==1&&t.playbackRate!==0&&this.changeMediaPlaybackRate(t,1)},this.hls=e,this.config=e.config,this.registerListeners()}get levelDetails(){var e;return((e=this.hls)==null?void 0:e.latestLevelDetails)||null}get latency(){return this._latency||0}get maxLatency(){const{config:e}=this;if(e.liveMaxLatencyDuration!==void 0)return e.liveMaxLatencyDuration;const t=this.levelDetails;return t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){const e=this.levelDetails;if(e===null||this.hls===null)return null;const{holdBack:t,partHoldBack:s,targetduration:r}=e,{liveSyncDuration:i,liveSyncDurationCount:a,lowLatencyMode:l}=this.config,c=this.hls.userConfig;let d=l&&s||t;(this._targetLatencyUpdated||c.liveSyncDuration||c.liveSyncDurationCount||d===0)&&(d=i!==void 0?i:a*r);const h=r;return d+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,h)}set targetLatency(e){this.stallCount=0,this.config.liveSyncDuration=e,this._targetLatencyUpdated=!0}get liveSyncPosition(){const e=this.estimateLiveEdge(),t=this.targetLatency;if(e===null||t===null)return null;const s=this.levelDetails;if(s===null)return null;const r=s.edge,i=e-t-this.edgeStalled,a=r-s.totalduration,l=r-(this.config.lowLatencyMode&&s.partTarget||s.targetduration);return Math.min(Math.max(a,i),l)}get drift(){const e=this.levelDetails;return e===null?1:e.drift}get edgeStalled(){const e=this.levelDetails;if(e===null)return 0;const t=(this.config.lowLatencyMode&&e.partTarget||e.targetduration)*3;return Math.max(e.age-t,0)}get forwardBufferLength(){const{media:e}=this,t=this.levelDetails;if(!e||!t)return 0;const s=e.buffered.length;return(s?e.buffered.end(s-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null}registerListeners(){const{hls:e}=this;e&&(e.on(j.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(j.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(j.MANIFEST_LOADING,this.onManifestLoading,this),e.on(j.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(j.ERROR,this.onError,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off(j.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(j.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(j.MANIFEST_LOADING,this.onManifestLoading,this),e.off(j.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(j.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 s;t.details===he.BUFFER_STALLED_ERROR&&(this.stallCount++,this.hls&&(s=this.levelDetails)!=null&&s.live&&this.hls.logger.warn("[latency-controller]: Stall detected, adjusting target latency"))}changeMediaPlaybackRate(e,t){var s,r;e.playbackRate!==t&&((s=this.hls)==null||s.logger.debug(`[latency-controller]: latency=${this.latency.toFixed(3)}, targetLatency=${(r=this.targetLatency)==null?void 0:r.toFixed(3)}, forwardBufferLength=${this.forwardBufferLength.toFixed(3)}: adjusting playback rate from ${e.playbackRate} to ${t}`),e.playbackRate=t)}estimateLiveEdge(){const e=this.levelDetails;return e===null?null:e.edge+e.age}computeLatency(){const e=this.estimateLiveEdge();return e===null?null:e-this.currentTime}}class vie extends ly{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(j.MANIFEST_LOADING,this.onManifestLoading,this),e.on(j.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(j.LEVEL_LOADED,this.onLevelLoaded,this),e.on(j.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(j.FRAG_BUFFERED,this.onFragBuffered,this),e.on(j.ERROR,this.onError,this)}_unregisterListeners(){const{hls:e}=this;e.off(j.MANIFEST_LOADING,this.onManifestLoading,this),e.off(j.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(j.LEVEL_LOADED,this.onLevelLoaded,this),e.off(j.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(j.FRAG_BUFFERED,this.onFragBuffered,this),e.off(j.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}
vendor: 4,549 bytes, line 135
135stopLoad(){this._levels.forEach(t=>{t.loadError=0,t.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 s=this.hls.config.preferManagedMediaSource,r=[],i={},a={};let l=!1,c=!1,d=!1;t.levels.forEach(h=>{const p=h.attrs;let{audioCodec:m,videoCodec:y}=h;m&&(h.audioCodec=m=D1(m,s)||void 0),y&&(y=h.videoCodec=mte(y));const{width:x,height:w,unknownCodecs:S}=h,_=S?.length||0;if(l||(l=!!(x&&w)),c||(c=!!y),d||(d=!!m),_||m&&!this.isAudioSupported(m)||y&&!this.isVideoSupported(y)){this.log(`Some or all CODECS not supported "${p.CODECS}"`);return}const{CODECS:L,"FRAME-RATE":R,"HDCP-LEVEL":M,"PATHWAY-ID":V,RESOLUTION:W,"VIDEO-RANGE":I}=p,P=`${`${V||"."}-`}${h.bitrate}-${W}-${R}-${L}-${I}-${M}`;if(i[P])if(i[P].uri!==h.url&&!h.attrs["PATHWAY-ID"]){const N=a[P]+=1;h.attrs["PATHWAY-ID"]=new Array(N+1).join(".");const F=this.createLevel(h);i[P]=F,r.push(F)}else i[P].addGroupId("audio",p.AUDIO),i[P].addGroupId("text",p.SUBTITLES);else{const N=this.createLevel(h);i[P]=N,a[P]=1,r.push(N)}}),this.filterAndSortMediaOptions(r,t,l,c,d)}createLevel(e){const t=new af(e),s=e.supplemental;if(s!=null&&s.videoCodec&&!this.isVideoSupported(s.videoCodec)){const r=new Error(`SUPPLEMENTAL-CODECS not supported "${s.videoCodec}"`);this.log(r.message),t.supportedResult=wN(r,[])}return t}isAudioSupported(e){return gm(e,"audio",this.hls.config.preferManagedMediaSource)}isVideoSupported(e){return gm(e,"video",this.hls.config.preferManagedMediaSource)}filterAndSortMediaOptions(e,t,s,r,i){var a;let l=[],c=[],d=e;const h=((a=t.stats)==null?void 0:a.parsing)||{};if((s||r)&&i&&(d=d.filter(({videoCodec:L,videoRange:R,width:M,height:V})=>(!!L||!!(M&&V))&&_te(R))),d.length===0){Promise.resolve().then(()=>{if(this.hls){let L="no level with compatible codecs found in manifest",R=L;t.levels.length&&(R=`one or more CODECS in variant not supported: ${jn(t.levels.map(V=>V.attrs.CODECS).filter((V,W,I)=>I.indexOf(V)===W))}`,this.warn(R),L+=` (${R})`);const M=new Error(L);this.hls.trigger(j.ERROR,{type:xt.MEDIA_ERROR,details:he.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:M,reason:R})}}),h.end=performance.now();return}t.audioTracks&&(l=t.audioTracks.filter(L=>!L.audioCodec||this.isAudioSupported(L.audioCodec)),NI(l)),t.subtitles&&(c=t.subtitles,NI(c));const p=d.slice(0);d.sort((L,R)=>{if(L.attrs["HDCP-LEVEL"]!==R.attrs["HDCP-LEVEL"])return(L.attrs["HDCP-LEVEL"]||"")>(R.attrs["HDCP-LEVEL"]||"")?1:-1;if(s&&L.height!==R.height)return L.height-R.height;if(L.frameRate!==R.frameRate)return L.frameRate-R.frameRate;if(L.videoRange!==R.videoRange)return j1.indexOf(L.videoRange)-j1.indexOf(R.videoRange);if(L.videoCodec!==R.videoCodec){const M=__(L.videoCodec),V=__(R.videoCodec);if(M!==V)return V-M}if(L.uri===R.uri&&L.codecSet!==R.codecSet){const M=L1(L.codecSet),V=L1(R.codecSet);if(M!==V)return V-M}return L.averageBitrate!==R.averageBitrate?L.averageBitrate-R.averageBitrate:0});let m=p[0];if(this.steering&&(d=this.steering.filterParsedLevels(d),d.length!==p.length)){for(let L=0;L<p.length;L++)if(p[L].pathwayId===d[0].pathwayId){m=p[L];break}}this._levels=d;for(let L=0;L<d.length;L++)if(d[L]===m){var y;this._firstLevel=L;const R=m.bitrate,M=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${d.length} level(s) found, first bitrate: ${R}`),((y=this.hls.userConfig)==null?void 0:y.abrEwmaDefaultEstimate)===void 0){const V=Math.min(R,this.hls.config.abrEwmaDefaultEstimateMax);V>M&&M===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=V)}break}const x=i&&!r,w=this.hls.config,S=!!(w.audioStreamController&&w.audioTrackController),_={levels:d,audioTracks:l,subtitleTracks:c,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:i,video:r,altAudio:S&&!x&&l.some(L=>!!L.url)};h.end=performance.now(),this.hls.trigger(j.MANIFEST_PARSED,_)}get levels(){return this._levels.length===0?null:this._levels}get loadLevelObj(){return this.currentLevel}get level(){return this.currentLevelIndex}set level(e){const t=this._levels;if(t.length===0)return;if(e<0||e>=t.length){const h=new Error("invalid level idx"),p=e<0;if(this.hls.trigger(j.ERROR,{type:xt.OTHER_ERROR,details:he.LEVEL_SWITCH_ERROR,level:e,fatal:p,error:h,reason:h.message}),p)return;e=Math.min(e,t.length-1)}const s=this.currentLevelIndex,r=this.currentLevel,i=r?r.attrs["PATHWAY-ID"]:void 0,a=t[e],l=a.attrs["PATHWAY-ID"];
vendor: 4,343 bytes, line 135
135if(this.currentLevelIndex=e,this.currentLevel=a,s===e&&r&&i===l)return;this.log(`Switching to level ${e} (${a.height?a.height+"p ":""}${a.videoRange?a.videoRange+" ":""}${a.codecSet?a.codecSet+" ":""}@${a.bitrate})${l?" with Pathway "+l:""} from level ${s}${i?" with Pathway "+i:""}`);const c={level:e,attrs:a.attrs,details:a.details,bitrate:a.bitrate,averageBitrate:a.averageBitrate,maxBitrate:a.maxBitrate,realBitrate:a.realBitrate,width:a.width,height:a.height,codecSet:a.codecSet,audioCodec:a.audioCodec,videoCodec:a.videoCodec,audioGroups:a.audioGroups,subtitleGroups:a.subtitleGroups,loaded:a.loaded,loadError:a.loadError,fragmentError:a.fragmentError,name:a.name,id:a.id,uri:a.uri,url:a.url,urlId:0,audioGroupIds:a.audioGroupIds,textGroupIds:a.textGroupIds};this.hls.trigger(j.LEVEL_SWITCHING,c);const d=a.details;if(!d||d.live){const h=this.switchParams(a.uri,r?.details,d);this.loadPlaylist(h)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,this._startLevel===void 0&&(this._startLevel=e),e!==-1&&(this.level=e)}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e}get startLevel(){if(this._startLevel===void 0){const e=this.hls.config.startLevel;return e!==void 0?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(),s=e.filter(r=>t.indexOf(r)!==-1);if(e.length<1){this.warn(`pathwayPriority ${e} should contain at least one pathway from list: ${t}`);return}this.steering.pathwayPriority=s}}onError(e,t){t.fatal||!t.context||t.context.type===Zt.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}onFragBuffered(e,{frag:t}){if(t!==void 0&&t.type===st.MAIN){const s=t.elementaryStreams;if(!Object.keys(s).some(i=>!!s[i]))return;const r=this._levels[t.level];r!=null&&r.loadError&&(this.log(`Resetting level error count of ${r.loadError} on frag buffered`),r.loadError=0)}}onLevelLoaded(e,t){var s;const{level:r,details:i}=t,a=t.levelInfo;if(!a){var l;this.warn(`Invalid level index ${r}`),(l=t.deliveryDirectives)!=null&&l.skip&&(i.deltaUpdateFailed=!0);return}if(a===this.currentLevel||t.withoutMultiVariant){a.fragmentError===0&&(a.loadError=0);let c=a.details;c===t.details&&c.advanced&&(c=void 0),this.playlistLoaded(r,t,c)}else(s=t.deliveryDirectives)!=null&&s.skip&&(i.deltaUpdateFailed=!0)}loadPlaylist(e){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLoading(this.currentLevel,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);const s=this.getUrlWithDirectives(e.uri,t),r=this.currentLevelIndex,i=e.attrs["PATHWAY-ID"],a=e.details,l=a?.age;this.log(`Loading level index ${r}${t?.msn!==void 0?" at sn "+t.msn+" part "+t.part:""}${i?" Pathway "+i:""}${l&&a.live?" age "+l.toFixed(1)+(a.type&&" "+a.type||""):""} ${s}`),this.hls.trigger(j.LEVEL_LOADING,{url:s,level:r,levelInfo:e,pathwayId:e.attrs["PATHWAY-ID"],id:0,deliveryDirectives:t||null})}get nextLoadLevel(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=e)}removeLevel(e){var t;if(this._levels.length===1)return;const s=this._levels.filter((i,a)=>a!==e?!0:(this.steering&&this.steering.removeLevel(i),i===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,i.details&&i.details.fragments.forEach(l=>l.level=-1)),!1));$N(s),this._levels=s,this.currentLevelIndex>-1&&(t=this.currentLevel)!=null&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.manualLevelIndex>-1&&(this.manualLevelIndex=this.currentLevelIndex);const r=s.length-1;this._firstLevel=Math.min(this._firstLevel,r),this._startLevel&&(this._startLevel=Math.min(this._startLevel,r)),this.hls.trigger(j.LEVELS_UPDATED,{levels:s})}onLevelsUpdated(e,{levels:t}){this._levels=t}checkMaxAutoUpdated(){const{autoLevelCapping:e,maxAutoLevel:t,maxHdcpLevel:s}=this.hls;this._maxAutoLevel!==t&&(this._maxAutoLevel=t,this.hls.trigger(j.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:s}))}}function NI(n){const e={};
vendor: 16,387 bytes, line 135
135n.forEach(t=>{const s=t.groupId||"";t.id=e[s]=e[s]||0,e[s]++})}function qL(){return self.SourceBuffer||self.WebKitSourceBuffer}function SS(){if(!Ql())return!1;const e=qL();return!e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function"}function YL(){if(!SS())return!1;const n=Ql();return typeof n?.isTypeSupported=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(e=>n.isTypeSupported(xm(e,"video")))||["mp4a.40.2","fLaC"].some(e=>n.isTypeSupported(xm(e,"audio"))))}function bie(){var n;const e=qL();return typeof(e==null||(n=e.prototype)==null?void 0:n.changeType)=="function"}const wie=100;class Sie extends ay{constructor(e,t,s){super(e,t,s,"stream-controller",st.MAIN),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 r=this.media,i=r?r.currentTime:null;if(i===null||!et(i)||(this.log(`Media seeked to ${i.toFixed(3)}`),!this.getBufferedFrag(i)))return;const a=this.getFwdBufferInfoAtPos(r,i,st.MAIN,0);if(a===null||a.len===0){this.warn(`Main forward buffer length at ${i} on "seeked" event ${a?a.len:"empty"})`);return}this.tick()},this.registerListeners()}registerListeners(){super.registerListeners();const{hls:e}=this;e.on(j.MANIFEST_PARSED,this.onManifestParsed,this),e.on(j.LEVEL_LOADING,this.onLevelLoading,this),e.on(j.LEVEL_LOADED,this.onLevelLoaded,this),e.on(j.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(j.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(j.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(j.BUFFER_CREATED,this.onBufferCreated,this),e.on(j.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(j.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(j.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){super.unregisterListeners();const{hls:e}=this;e.off(j.MANIFEST_PARSED,this.onManifestParsed,this),e.off(j.LEVEL_LOADED,this.onLevelLoaded,this),e.off(j.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(j.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(j.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(j.BUFFER_CREATED,this.onBufferCreated,this),e.off(j.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(j.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(j.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),super.onHandlerDestroying()}startLoad(e,t){if(this.levels){const{lastCurrentTime:s,hls:r}=this;if(this.stopLoad(),this.setInterval(wie),this.level=-1,!this.startFragRequested){let i=r.startLevel;i===-1&&(r.config.testBandwidth&&this.levels.length>1?(i=0,this.bitrateTest=!0):i=r.firstAutoLevel),r.nextLoadLevel=i,this.level=r.loadLevel,this._hasEnoughToStart=!!t}s>0&&e===-1&&!t&&(this.log(`Override startPosition with lastCurrentTime @${s.toFixed(3)}`),e=s),this.state=Ae.IDLE,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}else this._forceStartLoad=!0,this.state=Ae.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case Ae.WAITING_LEVEL:{const{levels:e,level:t}=this,s=e?.[t],r=s?.details;if(r&&(!r.live||this.levelLastLoaded===s&&!this.waitForLive(s))){if(this.waitForCdnTuneIn(r))break;this.state=Ae.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=Ae.IDLE;break}break}case Ae.FRAG_LOADING_WAITING_RETRY:this.checkRetryDate();break}this.state===Ae.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){var e;super.onTickEnd(),(e=this.media)!=null&&e.readyState&&this.media.seeking===!1&&(this.lastCurrentTime=this.media.currentTime),this.checkFragmentChanged()}doTickIdle(){const{hls:e,levelLastLoaded:t,levels:s,media:r}=this;if(t===null||!r&&!this.primaryPrefetch&&(this.startFragRequested||!e.config.startFragPrefetch)||this.altAudio&&this.audioOnly)return;const i=this.buffering?e.nextLoadLevel:e.loadLevel;if(!(s!=null&&s[i]))return;const a=s[i],l=this.getMainFwdBufferInfo();if(l===null)return;const c=this.getLevelDetails();if(c&&this._streamEnded(l,c)){const w={};this.altAudio===2&&(w.type="video"),this.hls.trigger(j.BUFFER_EOS,w),this.state=Ae.ENDED;return}if(!this.buffering)return;e.loadLevel!==i&&e.manualLevel===-1&&this.log(`Adapting to level ${i} from level ${this.level}`),this.level=e.nextLoadLevel=i;const d=a.details;if(!d||this.state===Ae.WAITING_LEVEL||this.waitForLive(a)){this.level=i,this.state=Ae.WAITING_LEVEL,this.startFragRequested=!1;return}const h=l.len,p=this.getMaxBufferLength(a.maxBitrate);if(h>=p)return;this.backtrackFragment&&this.backtrackFragment.start>l.end&&(this.backtrackFragment=null);const m=this.backtrackFragment?this.backtrackFragment.start:l.end;let y=this.getNextFragment(m,d);if(this.couldBacktrack&&!this.fragPrevious&&y&&_s(y)&&this.fragmentTracker.getState(y)!==Gs.OK){var x;const S=((x=this.backtrackFragment)!=null?x:y).sn-d.startSN,_=d.fragments[S-1];_&&y.cc===_.cc&&(y=_,this.fragmentTracker.removeFragment(_))}else this.backtrackFragment&&l.len&&(this.backtrackFragment=null);if(y&&this.isLoopLoading(y,m)){if(!y.gap){const S=this.audioOnly&&!this.altAudio?Ln.AUDIO:Ln.VIDEO,_=(S===Ln.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;_&&this.afterBufferFlushed(_,S,st.MAIN)}y=this.getNextFragmentLoopLoading(y,d,l,st.MAIN,p)}y&&(this.exceedsMaxBuffer(l,p,y)||(y.initSegment&&!y.initSegment.data&&!this.bitrateTest&&(y=y.initSegment),this.loadFragment(y,a,m)))}loadFragment(e,t,s){const r=this.fragmentTracker.getState(e);r===Gs.NOT_LOADED||r===Gs.PARTIAL?_s(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,s):this._loadInitSegment(e,t):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,st.MAIN)}followingBufferedFrag(e){return e?this.getBufferedFrag(e.end+.5):null}immediateLevelSwitch(){if(this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY),this.altAudio!==0){var e;(((e=this.getLevelDetails())==null?void 0:e.fragmentStart)||0)>this.lastCurrentTime&&super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio")}}nextLevelSwitch(){const{levels:e,media:t}=this;if(t!=null&&t.readyState){let s;const r=this.getAppendedFrag(t.currentTime);r&&r.start>1&&this.flushMainBuffer(0,r.start-1);const i=this.getLevelDetails();if(i!=null&&i.live){const l=this.getMainFwdBufferInfo();if(!l||l.len<i.targetduration*2)return}if(!t.paused&&e){const l=this.hls.nextLoadLevel,c=e[l],d=this.fragLastKbps;d&&this.fragCurrent?s=this.fragCurrent.duration*c.maxBitrate/(1e3*d)+1:s=0}else s=0;const a=this.getBufferedFrag(t.currentTime+s);if(a){const l=this.followingBufferedFrag(a);if(l){this.abortCurrentFrag();const c=l.maxStartPTS?l.maxStartPTS:l.start,d=l.duration,h=Math.max(a.end,c+Math.min(Math.max(d-this.config.maxFragLookUpTolerance,d*(this.couldBacktrack?.5:.125)),d*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(h,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 Ae.KEY_LOADING:case Ae.FRAG_LOADING:case Ae.FRAG_LOADING_WAITING_RETRY:case Ae.PARSING:case Ae.PARSED:this.state=Ae.IDLE;break}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,this.altAudio===2?"video":null)}onMediaAttached(e,t){super.onMediaAttached(e,t);const s=t.media;ei(s,"playing",this.onMediaPlaying),ei(s,"seeked",this.onMediaSeeked)}onMediaDetaching(e,t){const{media:s}=this;s&&(Ti(s,"playing",this.onMediaPlaying),Ti(s,"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(j.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 s=!1,r=!1;for(let i=0;i<t.levels.length;i++){const a=t.levels[i].audioCodec;a&&(s=s||a.indexOf("mp4a.40.2")!==-1,r=r||a.indexOf("mp4a.40.5")!==-1)}this.audioCodecSwitch=s&&r&&!bie(),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:s}=this;if(!s||this.state!==Ae.IDLE)return;const r=t.levelInfo;(!r.details||r.details.live&&(this.levelLastLoaded!==r||r.details.expired)||this.waitForCdnTuneIn(r.details))&&(this.state=Ae.WAITING_LEVEL)}onLevelLoaded(e,t){var s;const{levels:r,startFragRequested:i}=this,a=t.level,l=t.details,c=l.totalduration;if(!r){this.warn(`Levels were reset while loading level ${a}`);return}this.log(`Level ${a} loaded [${l.startSN},${l.endSN}]${l.lastPartSn?`[part-${l.lastPartSn}-${l.lastPartIndex}]`:""}, cc [${l.startCC}, ${l.endCC}] duration:${c}`);const d=t.levelInfo,h=this.fragCurrent;h&&(this.state===Ae.FRAG_LOADING||this.state===Ae.FRAG_LOADING_WAITING_RETRY)&&h.level!==t.level&&h.loader&&this.abortCurrentFrag();let p=0;if(l.live||(s=d.details)!=null&&s.live){var m;if(this.checkLiveUpdate(l),l.deltaUpdateFailed)return;p=this.alignPlaylists(l,d.details,(m=this.levelLastLoaded)==null?void 0:m.details)}if(d.details=l,this.levelLastLoaded=d,i||this.setStartPosition(l,p),this.hls.trigger(j.LEVEL_UPDATED,{details:l,level:a}),this.state===Ae.WAITING_LEVEL){if(this.waitForCdnTuneIn(l))return;this.state=Ae.IDLE}i&&l.live&&this.synchronizeToLiveEdge(l),this.tick()}synchronizeToLiveEdge(e){const{config:t,media:s}=this;if(!s)return;const r=this.hls.liveSyncPosition,i=this.getLoadPosition(),a=e.fragmentStart,l=e.edge,c=i>=a-t.maxFragLookUpTolerance&&i<=l;if(r!==null&&s.duration>r&&(i<r||!c)){const h=t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;if((!c&&s.readyState<4||i<l-h)&&(this._hasEnoughToStart||(this.nextLoadPosition=r),s.readyState))if(this.warn(`Playback: ${i.toFixed(3)} is located too far from the end of live sliding playlist: ${l}, reset currentTime to : ${r.toFixed(3)}`),this.config.liveSyncMode==="buffered"){var d;const p=Bt.bufferInfo(s,r,0);if(!((d=p.buffered)!=null&&d.length)){s.currentTime=r;return}if(p.start<=i){s.currentTime=r;return}const{nextStart:y}=Bt.bufferedInfo(p.buffered,i,0);y&&(s.currentTime=y)}else s.currentTime=r}}_handleFragmentLoadProgress(e){var t;const s=e.frag,{part:r,payload:i}=e,{levels:a}=this;if(!a){this.warn(`Levels were reset while fragment load was in progress. Fragment ${s.sn} of level ${s.level} will not be buffered`);return}const l=a[s.level];if(!l){this.warn(`Level ${s.level} not found on progress`);return}const c=l.details;if(!c){this.warn(`Dropping fragment ${s.sn} of level ${s.level} after level details were reset`),this.fragmentTracker.removeFragment(s);return}const d=l.videoCodec,h=c.PTSKnown||!c.live,p=(t=s.initSegment)==null?void 0:t.data,m=this._getAudioCodec(l),y=this.transmuxer=this.transmuxer||new dL(this.hls,st.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),x=r?r.index:-1,w=x!==-1,S=new iy(s.level,s.sn,s.stats.chunkCount,i.byteLength,x,w),_=this.initPTS[s.cc];y.push(i,p,m,d,s,r,c.totalduration,h,S,_)}onAudioTrackSwitching(e,t){const s=this.hls,r=this.altAudio!==0;if(O1(t.url,s))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 a=this.fragCurrent;a&&(this.log("Switching to main audio track, cancel main fragment load"),a.abortRequests(),this.fragmentTracker.removeFragment(a)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();if(r){this.altAudio=0,this.fragmentTracker.removeAllFragments(),s.once(j.BUFFER_FLUSHED,()=>{this.hls&&this.hls.trigger(j.AUDIO_TRACK_SWITCHED,t)}),s.trigger(j.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});return}s.trigger(j.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){const s=O1(t.url,this.hls);if(s){const r=this.videoBuffer;r&&this.mediaBuffer!==r&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=r)}this.altAudio=s?2:0,this.tick()}onBufferCreated(e,t){const s=t.tracks;let r,i,a=!1;for(const l in s){const c=s[l];if(c.id==="main"){if(i=l,r=c,l==="video"){const d=s[l];d&&(this.videoBuffer=d.buffer)}}else a=!0}a&&r?(this.log(`Alternate track found, use ${i}.buffered to schedule main fragment loading`),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){const{frag:s,part:r}=t,i=s.type===st.MAIN;if(i){if(this.fragContextChanged(s)){this.warn(`Fragment ${s.sn}${r?" p: "+r.index:""} of level ${s.level} finished buffering, but was aborted. state: ${this.state}`),this.state===Ae.PARSED&&(this.state=Ae.IDLE);return}const l=r?r.stats:s.stats;this.fragLastKbps=Math.round(8*l.total/(l.buffering.end-l.loading.first)),_s(s)&&(this.fragPrevious=s),this.fragBufferedComplete(s,r)}const a=this.media;a&&(!this._hasEnoughToStart&&Bt.getBuffered(a).length&&(this._hasEnoughToStart=!0,this.seekToStartPos()),i&&this.tick())}get hasEnoughToStart(){return this._hasEnoughToStart}onError(e,t){var s;if(t.fatal){this.state=Ae.ERROR;return}switch(t.details){case he.FRAG_GAP:case he.FRAG_PARSING_ERROR:case he.FRAG_DECRYPT_ERROR:case he.FRAG_LOAD_ERROR:case he.FRAG_LOAD_TIMEOUT:case he.KEY_LOAD_ERROR:case he.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(st.MAIN,t);break;case he.LEVEL_LOAD_ERROR:case he.LEVEL_LOAD_TIMEOUT:case he.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===Ae.WAITING_LEVEL&&((s=t.context)==null?void 0:s.type)===Zt.LEVEL&&(this.state=Ae.IDLE);break;case he.BUFFER_ADD_CODEC_ERROR:case he.BUFFER_APPEND_ERROR:if(t.parent!=="main")return;this.reduceLengthAndFlushBuffer(t)&&this.resetLoadingState();break;case he.BUFFER_FULL_ERROR:if(t.parent!=="main")return;this.reduceLengthAndFlushBuffer(t)&&(!this.config.interstitialsController&&this.config.assetPlayerId?this._hasEnoughToStart=!0:this.flushMainBuffer(0,Number.POSITIVE_INFINITY));break;case he.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onFragLoadEmergencyAborted(){this.state=Ae.IDLE,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==Ln.AUDIO||!this.altAudio){const s=(t===Ln.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;s&&(this.afterBufferFlushed(s,t,st.MAIN),this.tick())}}onLevelsUpdated(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level,this.level===-1&&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 s=this.startPosition;if(s>=0&&t<s){if(e.seeking){this.log(`could not seek to ${s}, already seeking at ${t}`);return}const r=this.timelineOffset;r&&s&&(s+=r);const i=this.getLevelDetails(),a=Bt.getBuffered(e),l=a.length?a.start(0):0,c=l-s,d=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);(this.config.startOnSegmentBoundary||c>0&&(c<d||this.loadingParts&&c<2*(i?.partTarget||0)))&&(this.log(`adjusting start position by ${c} to match buffer start`),s+=c,this.startPosition=s),t<s&&(this.log(`seek to target start position ${s} from current time ${t} buffer start ${l}`),e.currentTime=s)}}_getAudioCodec(e){let t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t.indexOf("mp4a.40.5")!==-1?t="mp4a.40.2":t="mp4a.40.5"),t}_loadBitrateTestFrag(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then(s=>{const{hls:r}=this,i=s?.frag;if(!i||this.fragContextChanged(i))return;t.fragmentError=0,this.state=Ae.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;const a=i.stats;a.parsing.start=a.parsing.end=a.buffering.start=a.buffering.end=self.performance.now(),r.trigger(j.FRAG_LOADED,s),i.bitrateTest=!1}
vendor: 4,829 bytes, line 135
135).catch(s=>{this.state===Ae.STOPPED||this.state===Ae.ERROR||(this.warn(s),this.resetFragmentLoading(e))})}_handleTransmuxComplete(e){const t=this.playlistType,{hls:s}=this,{remuxResult:r,chunkMeta:i}=e,a=this.getCurrentContext(i);if(!a){this.resetWhenMissingContext(i);return}const{frag:l,part:c,level:d}=a,{video:h,text:p,id3:m,initSegment:y}=r,{details:x}=d,w=this.altAudio?void 0:r.audio;if(this.fragContextChanged(l)){this.fragmentTracker.removeFragment(l);return}if(this.state=Ae.PARSING,y){const S=y.tracks;if(S){const M=l.initSegment||l;if(this.unhandledEncryptionError(y,l))return;this._bufferInitSegment(d,S,M,i),s.trigger(j.FRAG_PARSING_INIT_SEGMENT,{frag:M,id:t,tracks:S})}const _=y.initPTS,L=y.timescale,R=this.initPTS[l.cc];if(et(_)&&(!R||R.baseTime!==_||R.timescale!==L)){const M=y.trackId;this.initPTS[l.cc]={baseTime:_,timescale:L,trackId:M},s.trigger(j.INIT_PTS_FOUND,{frag:l,id:t,initPTS:_,timescale:L,trackId:M})}}if(h&&x){w&&h.type==="audiovideo"&&this.logMuxedErr(l);const S=x.fragments[l.sn-1-x.startSN],_=l.sn===x.startSN,L=!S||l.cc>S.cc;if(r.independent!==!1){const{startPTS:R,endPTS:M,startDTS:V,endDTS:W}=h;if(c)c.elementaryStreams[h.type]={startPTS:R,endPTS:M,startDTS:V,endDTS:W};else if(h.firstKeyFrame&&h.independent&&i.id===1&&!L&&(this.couldBacktrack=!0),h.dropped&&h.independent){const I=this.getMainFwdBufferInfo(),k=(I?I.end:this.getLoadPosition())+this.config.maxBufferHole,P=h.firstKeyFramePTS?h.firstKeyFramePTS:R;if(!_&&k<P-this.config.maxBufferHole&&!L){this.backtrack(l);return}else L&&(l.gap=!0);l.setElementaryStreamInfo(h.type,l.start,M,l.start,W,!0)}else _&&R-(x.appliedTimelineOffset||0)>V0&&(l.gap=!0);l.setElementaryStreamInfo(h.type,R,M,V,W),this.backtrackFragment&&(this.backtrackFragment=l),this.bufferFragmentData(h,l,c,i,_||L)}else if(_||L)l.gap=!0;else{this.backtrack(l);return}}if(w){const{startPTS:S,endPTS:_,startDTS:L,endDTS:R}=w;c&&(c.elementaryStreams[Ln.AUDIO]={startPTS:S,endPTS:_,startDTS:L,endDTS:R}),l.setElementaryStreamInfo(Ln.AUDIO,S,_,L,R),this.bufferFragmentData(w,l,c,i)}if(x&&m!=null&&m.samples.length){const S={id:t,frag:l,details:x,samples:m.samples};s.trigger(j.FRAG_PARSING_METADATA,S)}if(x&&p){const S={id:t,frag:l,details:x,samples:p.samples};s.trigger(j.FRAG_PARSING_USERDATA,S)}}logMuxedErr(e){this.warn(`${_s(e)?"Media":"Init"} segment with muxed audiovideo where only video expected: ${e.url}`)}_bufferInitSegment(e,t,s,r){if(this.state!==Ae.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&(delete t.audio,t.audiovideo&&this.logMuxedErr(s));const{audio:i,video:a,audiovideo:l}=t;if(i){const d=e.audioCodec;let h=D0(i.codec,d);h==="mp4a"&&(h="mp4a.40.5");const p=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){h&&(h.indexOf("mp4a.40.5")!==-1?h="mp4a.40.2":h="mp4a.40.5");const m=i.metadata;m&&"channelCount"in m&&(m.channelCount||1)!==1&&p.indexOf("firefox")===-1&&(h="mp4a.40.5")}h&&h.indexOf("mp4a.40.5")!==-1&&p.indexOf("android")!==-1&&i.container!=="audio/mpeg"&&(h="mp4a.40.2",this.log(`Android: force audio codec to ${h}`)),d&&d!==h&&this.log(`Swapping manifest audio codec "${d}" for "${h}"`),i.levelCodec=h,i.id=st.MAIN,this.log(`Init audio buffer, container:${i.container}, codecs[selected/level/parsed]=[${h||""}/${d||""}/${i.codec}]`),delete t.audiovideo}if(a){a.levelCodec=e.videoCodec,a.id=st.MAIN;const d=a.codec;if(d?.length===4)switch(d){case"hvc1":case"hev1":a.codec="hvc1.1.6.L120.90";break;case"av01":a.codec="av01.0.04M.08";break;case"avc1":a.codec="avc1.42e01e";break}this.log(`Init video buffer, container:${a.container}, codecs[level/parsed]=[${e.videoCodec||""}/${d}]${a.codec!==d?" parsed-corrected="+a.codec:""}${a.supplemental?" supplemental="+a.supplemental:""}`),delete t.audiovideo}l&&(this.log(`Init audiovideo buffer, container:${l.container}, codecs[level/parsed]=[${e.codecs}/${l.codec}]`),delete t.video,delete t.audio);const c=Object.keys(t);if(c.length){if(this.hls.trigger(j.BUFFER_CODECS,t),!this.hls)return;c.forEach(d=>{const p=t[d].initSegment;p!=null&&p.byteLength&&this.hls.trigger(j.BUFFER_APPENDING,{type:d,data:p,frag:s,part:null,chunkMeta:r,parent:s.type})})}this.tickImmediate()}getMainFwdBufferInfo(){const e=this.mediaBuffer&&this.altAudio===2?this.mediaBuffer:this.media;return this.getFwdBufferInfo(e,st.MAIN)}get maxBufferLength(){const{levels:e,level:t}=this,s=e?.[t];return s?this.getMaxBufferLength(s.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=Ae.IDLE}checkFragmentChanged(){const e=this.media;let t=null;if(e&&e.readyState>1&&e.seeking===!1){const s=e.currentTime;if(Bt.isBuffered(e,s)?t=this.getAppendedFrag(s):Bt.isBuffered(e,s+.1)&&
135(t=this.getAppendedFrag(s+.1)),t){this.backtrackFragment=null;const r=this.fragPlaying,i=t.level;(!r||t.sn!==r.sn||r.level!==i)&&(this.fragPlaying=t,this.hls.trigger(j.FRAG_CHANGED,{frag:t}),(!r||r.level!==i)&&this.hls.trigger(j.LEVEL_SWITCHED,{level:i}))}}}get nextLevel(){const e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){var e;if(this.fragPlaying)return this.fragPlaying;const t=((e=this.media)==null?void 0:e.currentTime)||this.lastCurrentTime;return et(t)?this.getAppendedFrag(t):null}get currentProgramDateTime(){var e;const t=((e=this.media)==null?void 0:e.currentTime)||this.lastCurrentTime;if(et(t)){const s=this.getLevelDetails(),r=this.currentFrag||(s?Id(null,s.fragments,t):null);if(r){const i=r.programDateTime;if(i!==null){const a=i+(t-r.start)*1e3;return new Date(a)}}}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 Eie extends Pa{constructor(e,t){super("key-loader",t),this.config=void 0,this.keyIdToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(const s in this.keyIdToKeyInfo){const r=this.keyIdToKeyInfo[s].loader;if(r){var t;if(e&&e!==((t=r.context)==null?void 0:t.frag.type))return;r.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=he.KEY_LOAD_ERROR,s,r,i){return new Al({type:xt.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:i,error:s,networkDetails:r})}loadClear(e,t,s){if(this.emeController&&this.config.emeEnabled&&!this.emeController.getSelectedKeySystemFormats().length){if(t.length)for(let r=0,i=t.length;r<i;r++){const a=t[r];if(e.cc<=a.cc&&(!_s(e)||!_s(a)||e.sn<a.sn)||!s&&r==i-1)return this.emeController.selectKeySystemFormat(a).then(l=>{if(!this.emeController)return;a.setKeyFormat(l);const c=j0(l);if(c)return this.emeController.getKeySystemAccess([c])})}if(this.config.requireKeySystemAccessOnStart){const r=wp(this.config);if(r.length)return this.emeController.getKeySystemAccess(r)}}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 s,r;t&&e.setKeyFormat(t);const i=e.decryptdata;if(!i){const d=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,he.KEY_LOAD_ERROR,d))}const a=i.uri;if(!a)return Promise.reject(this.createKeyLoadError(e,he.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${a}"`)));const l=Bv(i);let c=this.keyIdToKeyInfo[l];if((s=c)!=null&&s.decryptdata.key)return i.key=c.decryptdata.key,Promise.resolve({frag:e,keyInfo:c});if(this.emeController&&(r=c)!=null&&r.keyLoadPromise)switch(this.emeController.getKeyStatus(c.decryptdata)){case"usable":case"usable-in-future":return c.keyLoadPromise.then(h=>{const{keyInfo:p}=h;return i.key=p.decryptdata.key,{frag:e,keyInfo:p}})}switch(this.log(`${this.keyIdToKeyInfo[l]?"Rel":"L"}oading${i.keyId?" keyId: "+vr(i.keyId):""} URI: ${i.uri} from ${e.type} ${e.level}`),c=this.keyIdToKeyInfo[l]={decryptdata:i,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},i.method){case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return i.keyFormat==="identity"?this.loadKeyHTTP(c,e):this.loadKeyEME(c,e);case"AES-128":case"AES-256":case"AES-256-CTR":return this.loadKeyHTTP(c,e);default:return Promise.reject(this.createKeyLoadError(e,he.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${i.method}"`)))}}loadKeyEME(e,t){const s={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var r;if(!e.decryptdata.keyId&&(r=t.initSegment)!=null&&r.data){const a=ste(t.initSegment.data);if(a.length){let l=a[0];l.some(c=>
vendor: 6,017 bytes, line 135
135c!==0)?(this.log(`Using keyId found in init segment ${vr(l)}`),zl.setKeyIdForUri(e.decryptdata.uri,l)):(l=zl.addKeyIdForUri(e.decryptdata.uri),this.log(`Generating keyId to patch media ${vr(l)}`)),e.decryptdata.keyId=l}}if(!e.decryptdata.keyId&&!_s(t))return Promise.resolve(s);const i=this.emeController.loadKey(s);return(e.keyLoadPromise=i.then(a=>(e.mediaKeySessionContext=a,s))).catch(a=>{throw e.keyLoadPromise=null,"data"in a&&(a.data.frag=t),a})}return Promise.resolve(s)}loadKeyHTTP(e,t){const s=this.config,r=s.loader,i=new r(s);return t.keyLoader=e.loader=i,e.keyLoadPromise=new Promise((a,l)=>{const c={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},d=s.keyLoadPolicy.default,h={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},p={onSuccess:(m,y,x,w)=>{const{frag:S,keyInfo:_}=x,L=Bv(_.decryptdata);if(!S.decryptdata||_!==this.keyIdToKeyInfo[L])return l(this.createKeyLoadError(S,he.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),w));_.decryptdata.key=S.decryptdata.key=new Uint8Array(m.data),S.keyLoader=null,_.loader=null,a({frag:S,keyInfo:_})},onError:(m,y,x,w)=>{this.resetLoader(y),l(this.createKeyLoadError(t,he.KEY_LOAD_ERROR,new Error(`HTTP Error ${m.code} loading key ${m.text}`),x,In({url:c.url,data:void 0},m)))},onTimeout:(m,y,x)=>{this.resetLoader(y),l(this.createKeyLoadError(t,he.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),x))},onAbort:(m,y,x)=>{this.resetLoader(y),l(this.createKeyLoadError(t,he.INTERNAL_ABORTED,new Error("key loading aborted"),x))}};i.load(c,h,p)})}resetLoader(e){const{frag:t,keyInfo:s,url:r}=e,i=s.loader;t.keyLoader===i&&(t.keyLoader=null,s.loader=null);const a=Bv(s.decryptdata)||r;delete this.keyIdToKeyInfo[a],i&&i.destroy()}}function Bv(n){if(n.keyFormat!==cr.FAIRPLAY){const e=n.keyId;if(e)return vr(e)}return n.uri}function LI(n){const{type:e}=n;switch(e){case Zt.AUDIO_TRACK:return st.AUDIO;case Zt.SUBTITLE_TRACK:return st.SUBTITLE;default:return st.MAIN}}function zv(n,e){let t=n.url;return(t===void 0||t.indexOf("data:")===0)&&(t=e.url),t}class Tie{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(j.MANIFEST_LOADING,this.onManifestLoading,this),e.on(j.LEVEL_LOADING,this.onLevelLoading,this),e.on(j.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(j.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.on(j.LEVELS_UPDATED,this.onLevelsUpdated,this)}unregisterListeners(){const{hls:e}=this;e.off(j.MANIFEST_LOADING,this.onManifestLoading,this),e.off(j.LEVEL_LOADING,this.onLevelLoading,this),e.off(j.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(j.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.off(j.LEVELS_UPDATED,this.onLevelsUpdated,this)}createInternalLoader(e){const t=this.hls.config,s=t.pLoader,r=t.loader,i=s||r,a=new i(t);return this.loaders[e.type]=a,a}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:s}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Zt.MANIFEST,url:s,deliveryDirectives:null,levelOrTrack:null})}onLevelLoading(e,t){const{id:s,level:r,pathwayId:i,url:a,deliveryDirectives:l,levelInfo:c}=t;this.load({id:s,level:r,pathwayId:i,responseType:"text",type:Zt.LEVEL,url:a,deliveryDirectives:l,levelOrTrack:c})}onAudioTrackLoading(e,t){const{id:s,groupId:r,url:i,deliveryDirectives:a,track:l}=t;this.load({id:s,groupId:r,level:null,responseType:"text",type:Zt.AUDIO_TRACK,url:i,deliveryDirectives:a,levelOrTrack:l})}onSubtitleTrackLoading(e,t){const{id:s,groupId:r,url:i,deliveryDirectives:a,track:l}=t;this.load({id:s,groupId:r,level:null,responseType:"text",type:Zt.SUBTITLE_TRACK,url:i,deliveryDirectives:a,levelOrTrack:l})}onLevelsUpdated(e,t){const s=this.loaders[Zt.LEVEL];if(s){const r=s.context;r&&!t.levels.some(i=>i===r.levelOrTrack)&&(s.abort(),delete this.loaders[Zt.LEVEL])}}load(e){var t;const s=this.hls.config;let r=this.getInternalLoader(e);if(r){const d=this.hls.logger,h=r.context;if(h&&h.levelOrTrack===e.levelOrTrack&&(h.url===e.url||h.deliveryDirectives&&!e.deliveryDirectives)){h.url===e.url?d.log(`[playlist-loader]: ignore ${e.url} ongoing request`):d.log(`[playlist-loader]: ignore ${e.url} in favor of ${h.url}`);return}d.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),r.abort()}let i;if(e.type===Zt.MANIFEST?i=s.manifestLoadPolicy.default:i=kn({},s.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),r=this.createInternalLoader(e),et((t=e.deliveryDirectives)==null?void 0:t.part)){let d;if(e.type===Zt.LEVEL&&e.level!==null?d=this.hls.levels[e.level].details:e.type===Zt.AUDIO_TRACK&&e.id!==null?d=this.hls.audioTracks[e.id].details:e.type===Zt.SUBTITLE_TRACK&&e.id!==null&&(d=this.hls.subtitleTracks[e.id].details),d){const h=d.partTarget,p=d.targetduration;if(h&&p){const m=Math.max(h*3,p*.8)*1e3;i=kn({},i,{maxTimeToFirstByteMs:Math.min(m,i.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(m,i.maxTimeToFirstByteMs)})}}}const a=i.errorRetry||i.timeoutRetry||{},l={loadPolicy:i,timeout:i.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},c={onSuccess:(d,h,p,m)=>{const y=this.getInternalLoader(p);this.resetInternalLoader(p.type);const x=d.data;h.parsing.start=performance.now(),io.isMediaPlaylist(x)||p.type!==Zt.MANIFEST?this.handleTrackOrLevelPlaylist(d,h,p,m||null,y):this.handleMasterPlaylist(d,h,p,m)},onError:(d,h,p,m)=>{this.handleNetworkError(h,p,!1,d,m)},onTimeout:(d,h,p)=>{this.handleNetworkError(h,p,!0,void 0,d)}};r.load(e,l,c)}
vendor: 4,542 bytes, line 135
135checkAutostartLoad(){if(!this.hls)return;const{config:{autoStartLoad:e,startPosition:t},forceStartLoad:s}=this.hls;(e||s)&&(this.hls.logger.log(`${e?"auto":"force"} startLoad with configured startPosition ${t}`),this.hls.startLoad(t))}handleMasterPlaylist(e,t,s,r){const i=this.hls,a=e.data,l=zv(e,s),c=io.parseMasterPlaylist(a,l);if(c.playlistParsingError){t.parsing.end=performance.now(),this.handleManifestParsingError(e,s,c.playlistParsingError,r,t);return}const{contentSteering:d,levels:h,sessionData:p,sessionKeys:m,startTimeOffset:y,variableList:x}=c;this.variableList=x,h.forEach(L=>{const{unknownCodecs:R}=L;if(R){const{preferManagedMediaSource:M}=this.hls.config;let{audioCodec:V,videoCodec:W}=L;for(let I=R.length;I--;){const k=R[I];gm(k,"audio",M)?(L.audioCodec=V=V?`${V},${k}`:k,rf.audio[V.substring(0,4)]=2,R.splice(I,1)):gm(k,"video",M)&&(L.videoCodec=W=W?`${W},${k}`:k,rf.video[W.substring(0,4)]=2,R.splice(I,1))}}});const{AUDIO:w=[],SUBTITLES:S,"CLOSED-CAPTIONS":_}=io.parseMasterPlaylistMedia(a,l,c);w.length&&!w.some(R=>!R.url)&&h[0].audioCodec&&!h[0].attrs.AUDIO&&(this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),w.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new Qn({}),bitrate:0,url:""})),i.trigger(j.MANIFEST_LOADED,{levels:h,audioTracks:w,subtitles:S,captions:_,contentSteering:d,url:l,stats:t,networkDetails:r,sessionData:p,sessionKeys:m,startTimeOffset:y,variableList:x})}handleTrackOrLevelPlaylist(e,t,s,r,i){const a=this.hls,{id:l,level:c,type:d}=s,h=zv(e,s),p=et(c)?c:et(l)?l:0,m=LI(s),y=io.parseLevelPlaylist(e.data,h,p,m,0,this.variableList);if(d===Zt.MANIFEST){const x={attrs:new Qn({}),bitrate:0,details:y,name:"",url:h};y.requestScheduled=t.loading.start+VN(y,0),a.trigger(j.MANIFEST_LOADED,{levels:[x],audioTracks:[],url:h,stats:t,networkDetails:r,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),s.levelDetails=y,this.handlePlaylistLoaded(y,e,t,s,r,i)}handleManifestParsingError(e,t,s,r,i){this.hls.trigger(j.ERROR,{type:xt.NETWORK_ERROR,details:he.MANIFEST_PARSING_ERROR,fatal:t.type===Zt.MANIFEST,url:e.url,err:s,error:s,reason:s.message,response:e,context:t,networkDetails:r,stats:i})}handleNetworkError(e,t,s=!1,r,i){let a=`A network ${s?"timeout":"error"+(r?" (status "+r.code+")":"")} occurred while loading ${e.type}`;e.type===Zt.LEVEL?a+=`: ${e.level} id: ${e.id}`:(e.type===Zt.AUDIO_TRACK||e.type===Zt.SUBTITLE_TRACK)&&(a+=` id: ${e.id} group-id: "${e.groupId}"`);const l=new Error(a);this.hls.logger.warn(`[playlist-loader]: ${a}`);let c=he.UNKNOWN,d=!1;const h=this.getInternalLoader(e);switch(e.type){case Zt.MANIFEST:c=s?he.MANIFEST_LOAD_TIMEOUT:he.MANIFEST_LOAD_ERROR,d=!0;break;case Zt.LEVEL:c=s?he.LEVEL_LOAD_TIMEOUT:he.LEVEL_LOAD_ERROR,d=!1;break;case Zt.AUDIO_TRACK:c=s?he.AUDIO_TRACK_LOAD_TIMEOUT:he.AUDIO_TRACK_LOAD_ERROR,d=!1;break;case Zt.SUBTITLE_TRACK:c=s?he.SUBTITLE_TRACK_LOAD_TIMEOUT:he.SUBTITLE_LOAD_ERROR,d=!1;break}h&&this.resetInternalLoader(e.type);const p={type:xt.NETWORK_ERROR,details:c,fatal:d,url:e.url,loader:h,context:e,error:l,networkDetails:t,stats:i};if(r){const m=t?.url||e.url;p.response=In({url:m,data:void 0},r)}this.hls.trigger(j.ERROR,p)}handlePlaylistLoaded(e,t,s,r,i,a){const l=this.hls,{type:c,level:d,levelOrTrack:h,id:p,groupId:m,deliveryDirectives:y}=r,x=zv(t,r),w=LI(r);let S=typeof r.level=="number"&&w===st.MAIN?d:void 0;const _=e.playlistParsingError;if(_){if(this.hls.logger.warn(`${_} ${e.url}`),!l.config.ignorePlaylistParsingErrors){l.trigger(j.ERROR,{type:xt.NETWORK_ERROR,details:he.LEVEL_PARSING_ERROR,fatal:!1,url:x,error:_,reason:_.message,response:t,context:r,level:S,parent:w,networkDetails:i,stats:s});return}e.playlistParsingError=null}if(!e.fragments.length){const L=e.playlistParsingError=new Error("No Segments found in Playlist");l.trigger(j.ERROR,{type:xt.NETWORK_ERROR,details:he.LEVEL_EMPTY_ERROR,fatal:!1,url:x,error:L,reason:L.message,response:t,context:r,level:S,parent:w,networkDetails:i,stats:s});return}switch(e.live&&a&&(a.getCacheAge&&(e.ageHeader=a.getCacheAge()||0),(!a.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),c){case Zt.MANIFEST:case Zt.LEVEL:if(S){if(!h)S=0;else if(h!==l.levels[S]){const L=l.levels.indexOf(h);L>-1&&(S=L)}}l.trigger(j.LEVEL_LOADED,{details:e,levelInfo:h||l.levels[0],level:S||0,id:p||0,stats:s,networkDetails:i,deliveryDirectives:y,withoutMultiVariant:c===Zt.MANIFEST});break;
vendor: 10,314 bytes, line 135
135case Zt.AUDIO_TRACK:l.trigger(j.AUDIO_TRACK_LOADED,{details:e,track:h,id:p||0,groupId:m||"",stats:s,networkDetails:i,deliveryDirectives:y});break;case Zt.SUBTITLE_TRACK:l.trigger(j.SUBTITLE_TRACK_LOADED,{details:e,track:h,id:p||0,groupId:m||"",stats:s,networkDetails:i,deliveryDirectives:y});break}}}class Xr{static get version(){return ym}static isMSESupported(){return SS()}static isSupported(){return YL()}static getMediaSource(){return Ql()}static get Events(){return j}static get MetadataSchema(){return wi}static get ErrorTypes(){return xt}static get ErrorDetails(){return he}static get DefaultConfig(){return Xr.defaultConfig?Xr.defaultConfig:lie}static set DefaultConfig(e){Xr.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 uS,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=Gee(e.debug||!1,"Hls instance",e.assetPlayerId),s=this.config=uie(Xr.DefaultConfig,e,t);this.userConfig=e,s.progressive&&die(s,t);const{abrController:r,bufferController:i,capLevelController:a,errorController:l,fpsController:c}=s,d=new l(this),h=this.abrController=new r(this),p=new Fte(this),m=s.interstitialsController,y=m?this.interstitialsController=new m(this,Xr):null,x=this.bufferController=new i(this,p),w=this.capLevelController=new a(this),S=new c(this),_=new Tie(this),L=s.contentSteeringController,R=L?new L(this):null,M=this.levelController=new vie(this,R),V=new xie(this),W=new Eie(this.config,this.logger),I=this.streamController=new Sie(this,p,W),k=this.gapController=new mie(this,p);w.setStreamController(I),S.setStreamController(I);const P=[_,M,I];y&&P.splice(1,0,y),R&&P.splice(1,0,R),this.networkControllers=P;const N=[h,x,k,w,S,V,p];this.audioTrackController=this.createController(s.audioTrackController,P);const F=s.audioStreamController;F&&P.push(this.audioStreamController=new F(this,p,W)),this.subtitleTrackController=this.createController(s.subtitleTrackController,P);const z=s.subtitleStreamController;z&&P.push(this.subtititleStreamController=new z(this,p,W)),this.createController(s.timelineController,N),W.emeController=this.emeController=this.createController(s.emeController,N),this.cmcdController=this.createController(s.cmcdController,N),this.latencyController=this.createController(yie,N),this.coreComponents=N,P.push(d);const U=d.onErrorOut;typeof U=="function"&&this.on(j.ERROR,U,d),this.on(j.MANIFEST_LOADED,_.onManifestLoaded,_)}createController(e,t){if(e){const s=new e(this);return t&&t.push(s),s}return null}on(e,t,s=this){this._emitter.on(e,t,s)}once(e,t,s=this){this._emitter.once(e,t,s)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,s=this,r){this._emitter.off(e,t,s,r)}listeners(e){return this._emitter.listeners(e)}emit(e,t,s){return this._emitter.emit(e,t,s)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(s){if(this.logger.error("An internal error happened while handling event "+e+'. Error message: "'+s.message+'". Here is a stacktrace:',s),!this.triggeringException){this.triggeringException=!0;const r=e===j.ERROR;this.trigger(j.ERROR,{type:xt.OTHER_ERROR,details:he.INTERNAL_EXCEPTION,fatal:r,event:e,error:s}),this.triggeringException=!1}}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){this.logger.log("destroy"),this.trigger(j.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this._url=null,this.networkControllers.forEach(t=>t.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(t=>t.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 i=new Error(`attachMedia failed: invalid argument (${e})`);this.trigger(j.ERROR,{type:xt.OTHER_ERROR,details:he.ATTACH_MEDIA_ERROR,fatal:!0,error:i});return}this.logger.log("attachMedia"),this._media&&(this.logger.warn("media must be detached before attaching"),this.detachMedia());const t="media"in e,s=t?e.media:e,r=t?e:{media:s};this._media=s,this.trigger(j.MEDIA_ATTACHING,r)}detachMedia(){this.logger.log("detachMedia"),this.trigger(j.MEDIA_DETACHING,{}),this._media=null}transferMedia(){this._media=null;const e=this.bufferController.transferMedia();return this.trigger(j.MEDIA_DETACHING,{transferMedia:e}),e}loadSource(e){this.stopLoad();const t=this.media,s=this._url,r=this._url=Z6.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log(`loadSource:${r}`),t&&s&&(s!==r||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(j.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 s=0;s<this.networkControllers.length&&(this.networkControllers[s].startLoad(e,t),!(!this.started||!this.networkControllers));s++);}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={[st.MAIN]:this.streamController.inFlightFrag};return this.audioStreamController&&(e[st.AUDIO]=this.audioStreamController.inFlightFrag),this.subtititleStreamController&&(e[st.SUBTITLE]=this.subtititleStreamController.inFlightFrag),e}swapAudioCodec(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){this.logger.log("recoverMediaError");const e=this._media,t=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=vre()),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 e===-1&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e}set startLevel(e){this.logger.log(`set startLevel:${e}`),e!==-1&&(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){Tte(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}get autoLevelEnabled(){return this.levelController.manualLevel===-1}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){const{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;const s=e.length;for(let r=0;r<s;r++)if(e[r].maxBitrate>=t)return r;return 0}get maxAutoLevel(){const{levels:e,autoLevelCapping:t,maxHdcpLevel:s}=this;let r;if(t===-1&&e!=null&&e.length?r=e.length-1:r=t,s)for(let i=r;i--;){const a=e[i].attrs["HDCP-LEVEL"];if(a&&a<=s)return i}return r}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((t=this.audioTrackController)==null?void 0:t.setAudioOption(e))||null}
135setSubtitleOption(e){var t;return((t=this.subtitleTrackController)==null?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:!1}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!!((e=this.bufferController)!=null&&e.bufferedToEnd)}get interstitialsManager(){var e;return((e=this.interstitialsController)==null?void 0:e.interstitialsManager)||null}getMediaDecodingInfo(e,t=this.allAudioTracks){const s=TN(t);return SN(e,s,navigator.mediaCapabilities)}}Xr.defaultConfig=void 0;const _ie=Object.freeze(Object.defineProperty({__proto__:null,AbrController:_N,AttrList:Qn,AudioStreamController:hL,AudioTrackController:pL,BasePlaylistController:ly,BaseSegment:eS,BaseStreamController:ay,BufferController:gL,CMCDController:AL,CapLevelController:cy,ChunkMetadata:iy,ContentSteeringController:CL,Cues:GL,DateRange:aS,EMEController:dd,ErrorActionFlags:vi,ErrorController:RN,ErrorDetails:he,ErrorTypes:xt,Events:j,FPSController:RL,FetchLoader:xw,Fragment:L0,Hls:Xr,HlsSkip:Mp,HlsUrlParameters:sw,KeySystemFormats:cr,KeySystems:Xn,Level:af,LevelDetails:LN,LevelKey:zl,LoadStats:sy,M3U8Parser:io,MetadataSchema:wi,NetworkErrorAction:Ws,Part:uN,PlaylistLevelType:st,SubtitleStreamController:jL,SubtitleTrackController:LL,TimelineController:HL,XhrLoader:wS,default:Xr,fetchSupported:KL,getMediaSource:Ql,isMSESupported:SS,isSupported:YL,requestMediaKeySystemAccess:cS},Symbol.toStringTag,{value:"Module"}));function DI({src:n,muted:e=!1,controls:t=!0,autoPlay:s=!0,className:r,style:i,onPlaybackError:a,onStatus:l}){const c=T.useRef(null),d=T.useRef(a),h=T.useRef(l);return T.useEffect(()=>{d.current=a,h.current=l},[a,l]),T.useEffect(()=>{const p=c.current;if(!p||!n)return;let m=!1,y=null,x=0,w=null,S=()=>{p.load(),s&&p.play().catch(()=>{})};const _=6,L=F=>{m||h.current?.(F)},R=()=>{y&&clearTimeout(y),y=null},M=()=>{if(m||y||x>=_){x>=_&&(L("offline"),d.current?.());return}x+=1,L("reconnecting");const F=Math.min(15e3,1e3*2**(x-1));y=setTimeout(()=>{y=null,m||S()},F)},V=()=>{x=0,R(),L("live")},W=()=>{w&&clearTimeout(w),w=setTimeout(M,8e3)},I=()=>{w&&clearTimeout(w),w=null,V()},k=()=>M(),P=()=>L("loading");if(L("loading"),p.addEventListener("playing",I),p.addEventListener("canplay",P),p.addEventListener("waiting",W),p.addEventListener("stalled",W),p.addEventListener("error",k),p.canPlayType("application/vnd.apple.mpegurl"))return p.src=n,p.load(),s&&p.play().catch(()=>{}),()=>{m=!0,R(),w&&clearTimeout(w),p.removeEventListener("playing",I),p.removeEventListener("canplay",P),p.removeEventListener("waiting",W),p.removeEventListener("stalled",W),p.removeEventListener("error",k),p.pause(),p.removeAttribute("src"),p.load()};if(!Xr.isSupported()){L("offline"),d.current?.();return}const N=new Xr({lowLatencyMode:!0,liveSyncDurationCount:2,liveMaxLatencyDurationCount:5,enableWorker:!0});return S=()=>{N.startLoad(),s&&p.play().catch(()=>{})},N.loadSource(n),N.attachMedia(p),N.on(Xr.Events.MANIFEST_PARSED,()=>{L("loading"),s&&p.play().catch(()=>{})}),N.on(Xr.Events.FRAG_LOADED,V),N.on(Xr.Events.ERROR,(F,z)=>{!z.fatal||m||(z.type===Xr.ErrorTypes.MEDIA_ERROR&&N.recoverMediaError(),M())}),()=>{m=!0,R(),w&&clearTimeout(w),p.removeEventListener("playing",I),p.removeEventListener("canplay",P),p.removeEventListener("waiting",W),p.removeEventListener("stalled",W),p.removeEventListener("error",k),N.destroy()}},[n,s]),o.jsx("video",{ref:c,muted:e,controls:t,autoPlay:s,playsInl
135ine:!0,className:r,style:i})}function Iie(n,e,t,s){const r=e?.filter(p=>p.categoryIds?.includes(n.id)||p.channelName===n.name||p.subcategoryAssignment===n.name)||[],i=n.containerFolder?.toLowerCase()==="channels"?"CHANNELS":n.containerFolder?.toLowerCase()==="movies"?"MOVIES":"ORIGINALS",a=t?.filter(p=>p.categoryAssignment===i&&p.subcategoryAssignment===n.name)||[],l=s?.filter(p=>p.parentCategoryId===n.id)||[];let c=0;l.forEach(p=>{const m=e?.filter(y=>y.categoryIds?.includes(p.id)||y.channelName===p.name||y.subcategoryAssignment===p.name)||[];c+=m.length});const d=r.length+a.length+c,h=l.length;return{totalEpisodes:d,seriesCount:h,directEpisodes:r.length,urlEpisodes:a.length,seriesEpisodes:c,series:l}}function Aie({show:n,onBack:e,onPlayVideo:t,startupData:s,showLiveUrls:r,showDescriptions:i,initialAlbumId:a}){const[l,c]=T.useState(null),[d,h]=T.useState(!1),[p,m]=T.useState("idle"),[y,x]=T.useState(null),[w,S]=T.useState(!1),[_,L]=T.useState(null),[R,M]=T.useState(null),V=R?R.isLive&&R.liveStreamUrl||null:n.isLive&&n.liveStreamUrl||null,[W,I]=T.useState(!1),[k,P]=T.useState(!1),[N,F]=T.useState(!1),[z,U]=T.useState("loading"),fe=!!(!l&&(R?.isLive||n.isLive)&&V&&!N),[oe,X]=T.useState(!1),[Q,G]=T.useState(!1),[Y,ee]=T.useState(null),[H,K]=T.useState(null),[pe,Fe]=T.useState(!1),[_e,ze]=T.useState(!1),Ye=ne=>ne.trim().toLowerCase().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-"),tt=ne=>{c(ne),window.history.pushState({screen:"series",showSlug:Ye(n.name),seriesSlug:Ye(ne.name)},"",`/chronictv/${Ye(n.name)}/${Ye(ne.name)}`)},lt=()=>{c(null),window.history.pushState({screen:"show",showSlug:Ye(n.name)},"",`/chronictv/${Ye(n.name)}`)},{data:ut,isLoading:cn}=gn({queryKey:["/api/audio-albums",n.id],queryFn:async()=>(await fetch(`/api/audio-albums?categoryId=${n.id}`)).json(),enabled:!!n.id}),ke=ut?.data||[],{data:Ue}=gn({queryKey:["/api/audio-albums",y?.id],queryFn:async()=>(await fetch(`/api/audio-albums/${y?.id}`)).json(),enabled:!!y?.id});T.useEffect(()=>{if(a&&ut?.data){const ne=ut.data.find(J=>J.id===a);ne&&x(ne)}},[a,ut]),T.useEffect(()=>{if(n._preSelectSeries&&n.series){const ne=n.series.find(J=>J.id===n._preSelectSeries);ne&&c(ne)}},[n._preSelectSeries,n.series]),T.useEffect(()=>{async function ne(){const J=It?.currentUser;if(!J?.email){S(!1);return}const De=await jP(J.email);if(L(De),!De||!De.isCreator){S(!1);return}const Le=n.name?.toLowerCase(),Qe=(De.brandNames||[De.brandName]).some(it=>it?.toLowerCase()===Le);S(Qe)}ne()},[n.name]),T.useEffect(()=>{const ne=FP(n.name,J=>{M(J),J?.isLive||(F(!1),U("offline"),P(!1))});return()=>ne()},[n.name]),T.useEffect(()=>{F(!1),U("loading")},[V]),T.useEffect(()=>{async function ne(){if(!w)return;const J=It?.currentUser;if(J)try{const De=await J.getIdToken(),Le=await fetch("/api/creator/update-status",{headers:{Authorization:`Bearer ${De}`}});if(!Le.ok)return;const Lt=await Le.json();Lt.success&&Lt.hasActiveUpdate&&!Lt.hasAcknowledged&&(K(Lt.activeUpdate),Fe(!0))}catch{}}ne()},[w]),T.useEffect(()=>{async function ne(){const J=It?.currentUser;if(!(!J||!je||!n.id))try{const De=Gt(je,"users",J.uid),Le=await Sr(De);if(Le.exists()){const Lt=Le.data()?.notifications?.subscribedCreators||[];X(Lt.includes(n.id))}}catch{}}ne()},[n.id]);async function rt(){const ne=It?.currentUser;if(!ne||!je){ee("Sign in to get live alerts"),setTimeout(()=>ee(null),3e3);return}G(!0);try{const J=!oe;if(J&&"Notification"in window&&await Notification.requestPermission()==="granted"&&"serviceWorker"in navigator)try{const Lt=await navigator.serviceWorker.ready,Qe=await fetch("/api/push/vapid-key");if(Qe.ok){const{publicKey:it}=await Qe.json(),Mn=await Lt.pushManager.getSubscription()||await Lt.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:it}),Gn=await ne.getIdToken();await fetch("/api/push/subscribe",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Gn}`},body:JSON.stringify({subscription:Mn.toJSON()})})}}catch{}const De=Gt(je,"users",ne.uid);await R6(De,{"notifications.liveAlerts":!0,"notifications.push":!0,"notifications.subscribedCreators":J?YR(n.id):AG(n.id)}),X(J),ee(J?"Live alerts on":"Alerts turned off"),setTimeout(()=>ee(null),2500)}catch{ee("Could not update alerts"),setTimeout(()=>ee(null),3e3)}G(!1)}const Ct=async()=>
135{if(!H)return;const ne=It?.currentUser;if(ne){ze(!0);try{const J=await ne.getIdToken();(await fetch("/api/creator/acknowledge-update",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${J}`},body:JSON.stringify({updateId:H.id,updateVersion:H.version,contentHash:H.contentHash})})).ok&&(Fe(!1),K(null))}catch{}finally{ze(!1)}}},at=ne=>({id:ne.id,title:zh(ne.customTitle||ne.title||ne.name||"Episode"),videoUrl:ne.embedUrl||ne.videoUrl||ne.video_url,embedUrl:ne.embedUrl||ne.videoUrl||ne.video_url,sourceUrl:ne.embedUrl||ne.videoUrl||ne.video_url,thumbnailUrl:ne.thumbnailUrl||ne.extractedThumbnail||ne.thumbnail_url,description:ne.extractedDescription||ne.description||"Episode from ChronicTV",duration:ne.extractedDuration||ne.duration,channelName:ne.extractedChannelName||ne.channelName||ne.channel_name||n.name,platform:ne.platform,platformVideoId:ne.platformVideoId,categoryName:n.name,videoId:ne.id,vimeoUrl:ne.vimeoUrl,video_url:ne.video_url,url:ne.url}),ft=ne=>{if(ne.thumbnailUrl)return ne.thumbnailUrl;if(ne.extractedThumbnail)return ne.extractedThumbnail;if(ne.thumbnail)return ne.thumbnail;if(ne.pictures?.sizes&&Array.isArray(ne.pictures.sizes)){const J=ne.pictures.sizes,De=J.filter(Le=>Le.width>=320).sort((Le,Lt)=>Le.width-Lt.width)[0]||J[J.length-1];return De?.link_with_play_button||De?.link||null}return null},Nt=ne=>ne?.name?.trim().toLowerCase()==="starr struck"?"/starr-struck-thumbnail.png":ne.thumbnailUrl&&ne.thumbnailUrl!==null?ne.thumbnailUrl:null,At=l||n;let ot=l?s?.videos?.filter(ne=>{const J=ne.categoryIds?.some(De=>String(De)===String(l.id))||ne.channelName===l.name||ne.subcategoryAssignment===l.name;return l.name==="Artist Interviews"&&ne.title?.toLowerCase().includes("interview"),J})||[]:s?.videos?.filter(ne=>ne.categoryIds?.includes(n.id))||[];const Yt=At.containerFolder?.toLowerCase()==="channels"?"CHANNELS":At.containerFolder?.toLowerCase()==="movies"?"MOVIES":"ORIGINALS",zt=s?.urlContent?.filter(ne=>ne.categoryAssignment===Yt&&ne.subcategoryAssignment===At.name)||[];if(ot=[...ot,...zt],!l&&n.series&&n.series.length>0){const ne=n.series.map(J=>J.id);ot.length,ot=ot.filter(J=>!(Array.isArray(J.categoryIds)&&J.categoryIds.some(Le=>ne.includes(Le))))}n.isSubfolder&&n.filteredEpisodes&&(ot=n.filteredEpisodes),n.name==="Ok Air Fest"&&n.series?.find(ne=>ne.name==="Artist Interviews");let wn=n.series||[];const Dt=Iie(n,s?.videos||[],s?.urlContent||[],s?.categories||[]),Ee=ke.length,He=l?ot.length:Dt.totalEpisodes,le=l?`${He} Episodes`:Dt.seriesCount>0?`${Dt.totalEpisodes} Episodes, ${Dt.seriesCount} Series${Ee>0?`, ${Ee} Album${Ee>1?"s":""}`:""}`:`${Dt.totalEpisodes} episodes${Ee>0?`, ${Ee} Album${Ee>1?"s":""}`:""}`;if(n.name==="Ok Air Fest"){const ne=s?.videos||[];ne.filter(J=>J.categoryIds?.includes(n.id)),ne.filter(J=>J.channelName===n.name),ne.filter(J=>J.subcategoryAssignment===n.name)}return o.jsxs("div",{style:{padding:"20px",background:"#1a1a1a",minHeight:"100vh",color:"white"},children:[o.jsxs("div",{style:{position:"relative",marginBottom:"30px",borderRadius:"12px",overflow:"hidden",background:"#333"},children:[o.jsxs("div",{style:{width:"100%",height:"400px",backgroundImage:(()=>{let ne=null;return l?(ne=Nt(l),ne||(ne=Nt(n))):ne=Nt(n),ne?`url(${ne})`:"none"})(),backgroundSize:"cover",backgroundPosition:"center",backgroundColor:"#444",display:"flex",alignItems:"center",justifyContent:"center",position:"relative"},children:[fe&&V&&o.jsx(DI,{src:V,muted:!0,controls:!1,autoPlay:!0,onPlaybackError:()=>F(!0),onStatus:U,style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover",zIndex:1,background:"#000"}}),fe&&z==="reconnecting"&&o.jsx("div",{style:{position:"absolute",zIndex:2,bottom:"16px",left:"16px",background:"rgba(0,0,0,0.78)",color:"white",padding:"8px 12px",borderRadius:"999px",fontSize:"12px",fontWeight:700},children:"Reconnecting to live broadcastâ¦"}),!(l&&Nt(l)||Nt(n))&&o.jsx("div",{style:{fontSize:"48px",opacity:.5},children:"ðº"}),(n.liveUrl||r?.[n.name])&&o.jsx("div",{style:{position:"absolute",top:"15px",right:"15px",background:"#4ade80",color:"black",padding:"8px 12px",borderRadius:"20px",fontSize:"12px",fontWeight:"bold"},children:"Top"})]}),o.jsxs("div",{style:{padding:"20px",display:"flex",alignItems:"center",gap:"20px",flexWrap:"wrap"},children:[o.jsxs("div",{style:{display:"flex",gap:"12px",flexWrap:"wrap"},children:[o.jsx("button",{onClick:()=>{ot.length>0&&t(at(ot[0]))},style:{background:"#4ade80",color:"black",border:"none",padding:"12px 18px",borderRadius:"6px",fontSize:"14px",fontWeight:"bold",cursor:"pointer",display:"flex",alignItems:"center",gap:"6px"},children:"â¶ Play Now"}),!l&&o.jsx("button",{onClick:()=>h(!0),style:{background:"#666",color:"white",border:"none",padding:"12px 18px",borderRadius:"6px",fontSize:"14px",cursor:"pointer"},children:"Show Info"}),o.jsx("button",{onClick:()=>{const ne=Ye(n.name),J=l?`${window.location.origin}/chronictv/${encodeURIComponent(ne)}/${encodeURIComponent(Ye(l.name))}`:`${window.location.origin}/chronictv/${encodeURIComponent(ne)}`;navigator.share?navigator.share({title:At.name,text:`Watch ${At.name} on ChronicTV`,url:J}).catch(()=>{}):navigator.clipboard.writeText(J).then(()=>{m("copied"),setTimeout(()=>m("idle"),2500)})},style:{background:p==="copied"?"#166534":"#333",color:p==="copied"?"#4ade80":"white",border:`1px solid ${p==="copied"?"#4ade80":"#555"}`,padding:"12px 18px",borderRadius:"6px",fontSize:"14px",cursor:"pointer",display:"flex",alignItems:"center",gap:"6px",transition:"all 0.2s"},children:p==="copied"?o.jsxs(o.Fragment,{children:[o.jsx(_a,{size:15})," Copied!"]}):o.jsxs(o.Fragment,{children:[o.jsx(Jc,{size:15})," Share"]})}),!l&&(w?o.jsx("button",{onClick:()=>I(!0),style:{display:"flex",alignItems:"center",gap:"6px",background:R?.isLive?"#dc2626":"#22c55e",color:"white",border:"none",padding:"12px 18px",borderRadius:"6px",fontSize:"14px",cursor:"pointer",fontWeight:"bold"},children:R?.isLive?o.jsxs(o.Fragment,{children:[o.jsx("span",{style:{width:"8px",height:"8px",background:"white",borderRadius:"50%"}}),"Live Now"]}):o.jsx(o.Fragment,{children:"ð¹ Go Live"})}):R?.isLive&&R.liveStreamUrl?o.jsxs("button",{onClick:()=>P(!0),style:{display:"flex",alignItems:"center",gap:"6px",background:"#dc2626",color:"white",border:"none",padding:"12px 18px",borderRadius:"6px",fontSize:"14px",cursor:"pointer",fontWeight:"bold",animation:"pulse 2s ease-in-out infinite"},children:[o.jsx("span",{style:{width:"8px",height:"8px",background:"white",borderRadius:"50%"}}),"Watch Live"]}):R?.isLive?o.jsxs("button",{onClick:()=>I(!0),style:{display:"flex",alignItems:"center",gap:"6px",background:"#dc2626",color:"white",border:"none",padding:"12px 18px",borderRadius:"6px",fontSize:"14px",cursor:"pointer",fontWeight:"bold"},children:[o.jsx("span",{style:{width:"8px",height:"8px",background:"white",borderRadius:"50%"}}),"Watch Live ",R.viewerCount>0&&`(${R.viewerCount})`]}):n.isLive&&n.liveStreamUrl?o.jsxs("button",{onClick:()=>P(!0),style:{display:"flex",alignItems:"center",gap:"6px",background:"#dc2626",color:"white",border:"none",padding:"12px 18px",borderRadius:"6px",fontSize:"14px",cursor:"pointer",fontWeight:"bold",animation:"pulse 2s ease-in-out infinite"},children:[o.jsx("span",{style:{width:"8px",height:"8px",background:"white",borderRadius:"50%"}}),"ð´ Watch Live"]}):n.liveUrl||r?.[n.name]?o.jsx("button",{onClick:()=>{const ne=n.liveUrl||r?.[n.name];ne&&window.open(ne,"_blank")},style:{background:"#666",color:"white",border:"none",padding:"12px 18px",borderRadius:"6px",fontSize:"14px",cursor:"pointer"},children:"ð´ Live"}):null)]}),o.jsxs("div",{style:{flex:"1",minWidth:"200px"},children:[o.jsx("h1",{style:{fontSize:"24px",margin:"0 0 5px 0",fontWeight:"bold",color:"white"},children:At.name}),o.jsx("p",{style:{color:"#aaa",fontSize:"14px",margin:0},children:le})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",position:"relative"},children:[Y&&o.jsx("span",{style:{position:"absolute",bottom:"-32px",right:0,background:"rgba(0,0,0,0.85)",color:"#4ade80",fontSize:"12px",padding:"4px 10px",borderRadius:"6px",whiteSpace:"nowrap",pointerEvents:"none"},children:Y}),!w&&o.jsx("button",{onClick:rt,disabled:Q,title:oe?"Turn off live alerts":"Notify me when live",style:{background:oe?"rgba(220,38,38,0.2)":"#333",border:oe?"1px solid rgba(220,38,38,0.5)":"none",borderRadius:"50%",width:"50px",height:"50px",color:oe?"#f87171":"#aaa",cursor:Q?"default":"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s",opacity:Q?.6:1},children:oe?o.jsx(cF,{size:20}):o.jsx(uF,{size:20})}),o.jsx("button",{onClick:()=>l?lt():e(),title:l?`Back to ${n.name}`:"Back to ChronicTV",style:{background:"#333",border:"none",borderRadius:"50%",width:"50px",height:"50px",color:"white",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 0.2s"},onMouseEnter:ne=>{ne.currentTarget.style.background="#444"},onMouseLeave:ne=>{ne.currentTarget.style.background="#333"},children:o.jsx(Fr,{size:24})})]})]})]}),d&&o.jsx("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0, 0, 0, 0.8)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",padding:"20px"},children:o.jsxs("div",{style:{background:"#222",borderRadius:"8px",maxWidth:"600px",width:"100%",maxHeight:"80vh",overflow:"auto",position:"relative"},children:[o.jsx("button",{onClick:()=>h(!1),style:{position:"absolute",top:"10px",right:"10px",background:"transparent",border:"none",color:"#999",fontSize:"24px",cursor:"pointer",padding:"5px",lineHeight:"1"},children:"Ã"}),o.jsxs("div",{style:{padding:"30px"},children:[o.jsx("h2",{style:{fontSize:"24px",fontWeight:"bold",marginBottom:"20px",color:"white"},children:n.name}),o.jsx("p",{style:{fontSize:"16px",lineHeight:"1.6",color:"#ccc",whiteSpace:"pre-wrap"},children:(()=>{const ne=i?.[n.name]||n.summaryContent||"",J=["LIVE_URL:","Public find U
135RL:","Twitch:","YouTube:","Instagram:","Twitter:","Facebook:","Website:"];return ne.split(` 136`).filter(De=>!J.some(Le=>De.startsWith(Le))).join(` 137`).trim()||"No description available."})()})]})]})}),l&&o.jsxs("div",{style:{marginBottom:"24px"},children:[o.jsxs("button",{onClick:lt,style:{background:"#4ade80",color:"black",border:"none",borderRadius:"6px",padding:"8px 16px",fontSize:"14px",fontWeight:"bold",cursor:"pointer",display:"flex",alignItems:"center",gap:"6px"},"data-testid":"button-back-to-show",children:[o.jsx(Fr,{size:16}),"Back to ",n.name]}),o.jsxs("div",{style:{marginTop:"14px",maxWidth:"760px",padding:"16px 18px",background:"#242424",border:"1px solid #3a3a3a",borderRadius:"8px"},children:[o.jsxs("h2",{style:{margin:"0 0 8px",fontSize:"18px",color:"white"},children:[l.name," Details"]}),o.jsx("p",{style:{margin:0,color:"#ccc",fontSize:"15px",lineHeight:1.6,whiteSpace:"pre-wrap"},children:l.summaryContent||l.description||"No series description available."}),l.liveUrl&&o.jsxs("a",{href:l.liveUrl,target:"_blank",rel:"noreferrer",style:{display:"inline-block",marginTop:"12px",color:"#4ade80",textDecoration:"underline",textUnderlineOffset:"3px"},children:["Visit the ",l.name," page"]})]})]}),!l&&wn.length>0&&o.jsxs(o.Fragment,{children:[o.jsx("div",{style:{marginBottom:"20px"},children:o.jsx("h2",{style:{fontSize:"20px",color:"white",margin:0,fontWeight:"bold"},children:"Series"})}),o.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:"16px",marginBottom:"30px"},children:wn.map(ne=>o.jsxs("div",{onClick:()=>{tt(ne)},style:{background:"#333",borderRadius:"8px",overflow:"hidden",cursor:"pointer",transition:"transform 0.2s, box-shadow 0.2s",border:"2px solid #4ade80"},onMouseEnter:J=>{J.currentTarget.style.transform="scale(1.02)",J.currentTarget.style.boxShadow="0 4px 20px rgba(74, 222, 128, 0.4)"},onMouseLeave:J=>{J.currentTarget.style.transform="scale(1)",J.currentTarget.style.boxShadow="none"},children:[o.jsx("div",{style:{width:"100%",height:"120px",backgroundImage:(()=>{const J=Nt(ne);return J?`url(${J})`:"none"})(),backgroundSize:"cover",backgroundPosition:"center",backgroundColor:"#4ade80",display:"flex",alignItems:"center",justifyContent:"center",position:"relative"},children:o.jsxs("div",{style:{position:"absolute",bottom:"6px",right:"6px",background:"rgba(0,0,0,0.8)",color:"white",padding:"2px 6px",borderRadius:"3px",fontSize:"11px",fontWeight:"bold"},children:[ne.episodeCountInSeason||ne.videoCount||0," eps"]})}),o.jsx("div",{style:{padding:"12px"},children:o.jsx("h3",{style:{fontSize:"13px",color:"white",margin:0,fontWeight:"bold",overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",lineHeight:"1.3"},children:ne.name})})]},ne.id))})]}),!l&&ke.length>0&&o.jsxs(o.Fragment,{children:[o.jsx("div",{style:{marginBottom:"20px",marginTop:wn.length>0?"20px":"0"},children:o.jsxs("h2",{style:{fontSize:"20px",color:"white",margin:0,fontWeight:"bold",display:"flex",alignItems:"center",gap:"8px"},children:[o.jsx(B2,{size:20,color:"#4ade80"}),"Albums"]})}),o.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(160px, 1fr))",gap:"16px",marginBottom:"30px"},children:ke.map(ne=>o.jsxs("div",{onClick:()=>x(ne),style:{background:"#222",borderRadius:"8px",overflow:"hidden",cursor:"pointer",transition:"transform 0.2s, box-shadow 0.2s"},onMouseEnter:J=>{J.currentTarget.style.transform="scale(1.03)",J.currentTarget.style.boxShadow="0 8px 30px rgba(74, 222, 128, 0.3)"},onMouseLeave:J=>{J.currentTarget.style.transform="scale(1)",J.currentTarget.style.boxShadow="none"},"data-testid":`card-album-${ne.id}`,children:[o.jsxs("div",{style:{width:"100%",aspectRatio:"1",background:ne.coverUrl?`url(${ne.coverUrl}) center/cover`:"linear-gradient(135deg, #4ade80 0%, #22c55e 100%)",display:"flex",alignItems:"center",justifyContent:"center",position:"relative"},children:[!ne.coverUrl&&o.jsx(K7,{size:48,color:"rgba(0,0,0,0.3)"}),o.jsxs("div",{style:{position:"absolute",bottom:"8px",right:"8px",background:ne.albumType==="youtube"?"rgba(255,0,0,0.9)":"rgba(0,0,0,0.8)",color:"white",padding:"3px 8px",borderRadius:"4px",fontSize:"11px",fontWeight:"bold",display:"flex",alignItems:"center",gap:"4px"},children:[o.jsx(B2,{size:12}),ne.albumType==="youtube"?"YouTube":`${ne.trackCount} tracks`]})]}),o.jsxs("div",{style:{padding:"12px"},children:[o.jsx("h3",{style:{fontSize:"14px",color:"white",margin:0,fontWeight:"bold",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:ne.name}),o.jsx("p",{style:{fontSize:"12px",color:"#888",margin:"4px 0 0 0"},children:ne.albumType==="audiobook"?"Audiobook":"Album"})]})]},ne.id))})]}),ot.length>0&&o.jsx("div",{style:{marginBottom:"20px",display:"flex",alignItems:"center",justifyContent:"space-between"},children:o.jsx("h2",{style:{color:"white",fontSize:"20px",margin:0,fontWeight:"bold"},children:l?`${l.name} Episodes`:"Episodes"})}),ot.length>0&&o.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:"16px"},children:ot.map(ne=>o.jsxs("div",{onClick:()=>t(at(ne)),style:{background:"#333",borderRadius:"8px",overflow:"hidden",cursor:"pointer",transition:"transform 0.2s, box-shadow 0.2s"},onMouseEnter:J=>{J.currentTarget.style.transform="scale(1.02)",J.currentTarget.style.boxShadow="0 4px 20px rgba(74, 222, 128, 0.3)"},onMouseLeave:J=>{J.currentTarget.style.transform="scale(1)",J.currentTarget.style.boxShadow="none"},children:[o.jsxs("div",{style:{width:"100%",height:"120px",backgroundImage:ft(ne)?`url(${ft(ne)})`:"none",backgroundSize:"cover",backgroundPosition:"center",backgroundColor:ft(ne)?"#000":"#4ade80",display:"flex",alignItems:"center",justifyContent:"center",position:"relative"},children:[!ft(ne)&&o.jsx("div",{style:{fontSize:"24px",opacity:.6,color:"white"},children:"ðº"}),o.jsx("div",{style:{background:"rgba(0,0,0,0.7)",borderRadius:"50%",width:"40px",height:"40px",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"16px",color:"white"},children:"â¶"}),!ne.platform&&ne.duration&&!isNaN(ne.duration)&&o.jsxs("div",{style:{position:"absolute",bottom:"6px",right:"6px",background:"rgba(0,0,0,0.8)",color:"white",padding:"2px 6px",borderRadius:"3px",fontSize:"11px",fontWeight:"bold"},children:[Math.floor(ne.duration/60),"m"]}),o.jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,background:"linear-gradient(transparent, rgba(0,0,0,0.8))",padding:"20px 8px 8px",color:"white"},children:o.jsx("h3",{style:{fontSize:"12px",fontWeight:"bold",margin:0,textShadow:"0 1px 2px rgba(0,0,0,0.8)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:zh(ne.customTitle||ne.extractedTitle||ne.title||ne.name||"Episode")})})]}),o.jsx("div",{style:{padding:"8px 12px"}})]},ne.id))}),wn.length===0&&ot.length===0&&ke.length===0&&o.jsxs("div",{style:{textAlign:"center",padding:"50px 20px",color:"#666"},children:[o.jsx("div",{style:{fontSize:"48px",marginBottom:"20px",opacity:.5},children:"ðº"}),o.jsx("p",{children:"No episodes available for this show"})]}),y&&!Ue?.data&&o.jsxs("div",{style:{position:"fixed",inset:0,background:"rgba(0, 0, 0, 0.9)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column",gap:"16px"},children:[o.jsx(B2,{size:48,className:"animate-pulse",style:{color:"#4ade80"}}),o.jsx("p",{style:{color:"white"},children:"Loading album..."})]}),y&&Ue?.data&&Ue.data.tracks&&o.jsx(Oee,{album:Ue.data,onClose:()=>x(null)}),W&&o.jsx(Mee,{showName:n.name,isCreator:w,liveStatus:R,onClose:()=>I(!1)}),k&&V&&o.jsxs("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.95)",zIndex:9999,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left))",minHeight:"100dvh"},role:"dialog","aria-modal":"true","aria-label":`${n.name} live broadcast`,onKeyDown:ne=>{ne.key==="Escape"&&P(!1)}
137,tabIndex:-1,children:[o.jsxs("div",{style:{width:"100%",maxWidth:"960px",display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"12px"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[o.jsxs("span",{style:{background:"#dc2626",color:"white",padding:"4px 10px",borderRadius:"8px",fontSize:"12px",fontWeight:"bold",display:"flex",alignItems:"center",gap:"6px"},children:[o.jsx("span",{style:{width:"7px",height:"7px",background:"white",borderRadius:"50%",display:"inline-block",animation:"pulse 1s ease-in-out infinite"}}),"LIVE"]}),o.jsx("span",{style:{color:"white",fontWeight:"bold",fontSize:"16px"},children:R?.streamTitle||n.liveTitle||n.name})]}),o.jsx("button",{onClick:()=>P(!1),"aria-label":"Close live broadcast",style:{background:"rgba(255,255,255,0.1)",border:"1px solid rgba(255,255,255,0.2)",color:"white",padding:"8px 16px",borderRadius:"6px",cursor:"pointer",fontSize:"14px"},children:"â Close"})]}),o.jsx("div",{style:{width:"100%",maxWidth:"960px",aspectRatio:"16/9",background:"#000",borderRadius:"10px",overflow:"hidden",border:"1px solid rgba(220,38,38,0.5)",boxShadow:"0 0 30px rgba(220,38,38,0.3)"},children:o.jsx(DI,{src:V,controls:!0,autoPlay:!0,onPlaybackError:()=>P(!1),onStatus:U,style:{width:"100%",height:"100%",objectFit:"contain"}})}),z==="reconnecting"&&o.jsx("p",{style:{color:"#fbbf24",fontSize:"13px",marginTop:"10px"},role:"status",children:"Reconnecting⦠the broadcast should resume automatically."})]}),pe&&H&&o.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0, 0, 0, 0.95)",zIndex:99999,display:"flex",alignItems:"center",justifyContent:"center",padding:"20px"},children:o.jsxs("div",{style:{background:"linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%)",border:"2px solid #4ade80",borderRadius:"16px",maxWidth:"600px",width:"100%",maxHeight:"80vh",overflow:"hidden",display:"flex",flexDirection:"column"},children:[o.jsxs("div",{style:{padding:"20px",borderBottom:"1px solid rgba(255,255,255,0.1)",display:"flex",alignItems:"center",gap:"12px"},children:[o.jsx("div",{style:{background:"linear-gradient(135deg, #4ade80 0%, #22c55e 100%)",borderRadius:"10px",padding:"10px",display:"flex",alignItems:"center",justifyContent:"center"},children:o.jsx(NF,{size:24,color:"white"})}),o.jsxs("div",{children:[o.jsx("h2",{style:{color:"white",fontSize:"20px",fontWeight:"bold",margin:0},children:"Creator Update"}),o.jsxs("p",{style:{color:"#9ca3af",fontSize:"14px",margin:0},children:["Version ",H.version," ⢠",new Date(H.createdAt).toLocaleDateString()]})]})]}),o.jsx("div",{style:{padding:"20px",background:"rgba(74, 222, 128, 0.1)",borderBottom:"1px solid rgba(255,255,255,0.1)"},children:o.jsx("h3",{style:{color:"#4ade80",fontSize:"18px",fontWeight:"600",margin:0},children:H.title})}),o.jsx("div",{style:{padding:"20px",overflow:"auto",flex:1,maxHeight:"300px"},children:o.jsx("p",{style:{color:"#e5e7eb",fontSize:"15px",lineHeight:"1.7",margin:0,whiteSpace:"pre-wrap"},children:H.content})}),o.jsxs("div",{style:{padding:"20px",borderTop:"1px solid rgba(255,255,255,0.1)",display:"flex",flexDirection:"column",gap:"12px"},children:[o.jsx("p",{style:{color:"#9ca3af",fontSize:"13px",textAlign:"center",margin:0},children:"Please acknowledge this update to continue using creator features."}),o.jsx("button",{onClick:Ct,disabled:_e,style:{background:_e?"#6b7280":"linear-gradient(135deg, #4ade80 0%, #22c55e 100%)",color:"white",padding:"14px 24px",borderRadius:"10px",fontSize:"16px",fontWeight:"600",border:"none",cursor:_e?"not-allowed":"pointer",transition:"all 0.2s",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:_e?o.jsxs(o.Fragment,{children:[o.jsx("div",{style:{width:"18px",height:"18px",border:"2px solid rgba(255,255,255,0.3)",borderTop:"2px solid white",borderRadius:"50%",animation:"spin 1s linear infinite"}}),"Acknowledging..."]}):"Got It - Acknowledge Update"})]})]})})]})}function QL(){const[n,e]=T.useState(!0),[t,s]=T.useState(null),[r,i]=T.useState(null),[a,l]=T.useState(!1);T.useEffect(()=>{(async()=>{const m=window.location.pathname.match(/^\/([^\/]+)\/MembershipStatus$/i),y=m?m[1]:null;if(!y){i("Invalid membership link"),e(!1);return}try{const w=await(await fetch(`/api/membership/verify/${encodeURIComponent(y)}`)).json();w.success&&w.data?s({displayName:w.data.displayName,email:w.data.email,tier:w.data.tier,status:w.data.status,lastRenewalDate:w.data.lastRenewalDate?new Date(w.data.lastRenewalDate):null,nextBillingDate:w.data.nextBillingDate?new Date(w.data.nextBillingDate):null,photoIdUrl:w.data.photoIdUrl}):i(w.error||"Member not found")}catch{i("Failed to verify membership")}e(!1)})()},[]);const c=h=>h?h.toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}):"N/A";if(n)return o.jsx("div",{style:{minHeight:"100vh",background:"linear-gradient(135deg, #0a0a0a 0%, #1a1a1a 100%)",display:"flex",justifyContent:"center",alignItems:"center",padding:"20px"},children:o.jsxs("div",{style:{background:"#1e1e1e",borderRadius:"16px",padding:"40px",textAlign:"center",maxWidth:"400px",
137width:"100%"},children:[o.jsx("div",{style:{width:"48px",height:"48px",border:"4px solid #333",borderTopColor:"#4ade80",borderRadius:"50%",animation:"spin 1s linear infinite",margin:"0 auto 20px"}}),o.jsx("p",{style:{color:"#888",fontSize:"14px"},children:"Verifying membership..."}),o.jsx("style",{children:"@keyframes spin { to { transform: rotate(360deg); } }"})]})});if(r)return o.jsx("div",{style:{minHeight:"100vh",background:"linear-gradient(135deg, #0a0a0a 0%, #1a1a1a 100%)",display:"flex",justifyContent:"center",alignItems:"center",padding:"20px"},children:o.jsxs("div",{style:{background:"#1e1e1e",borderRadius:"16px",padding:"40px",textAlign:"center",maxWidth:"400px",width:"100%",border:"1px solid #333"},children:[o.jsx(Lh,{size:48,color:"#ff4444",style:{marginBottom:"16px"}}),o.jsx("h2",{style:{color:"#fff",fontSize:"20px",marginBottom:"8px"},children:"Verification Failed"}),o.jsx("p",{style:{color:"#888",fontSize:"14px"},children:r})]})});const d=t?.tier==="premier"&&t?.status==="active";return o.jsx("div",{style:{minHeight:"100vh",background:"linear-gradient(135deg, #0a0a0a 0%, #1a1a1a 100%)",display:"flex",flexDirection:"column",alignItems:"center",padding:"20px"},children:o.jsxs("div",{style:{background:"#1e1e1e",borderRadius:"16px",overflow:"hidden",maxWidth:"400px",width:"100%",border:d?"2px solid #4ade80":"1px solid #333"},children:[o.jsxs("div",{style:{background:d?"linear-gradient(135deg, #1a3a1a 0%, #0a200a 100%)":"#252525",padding:"24px",textAlign:"center",borderBottom:"1px solid #333"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",marginBottom:"12px"},children:[o.jsx(MF,{size:24,color:d?"#4ade80":"#888"}),o.jsxs("span",{style:{color:"#fff",fontSize:"22px",fontWeight:"bold",fontFamily:"system-ui, -apple-system, sans-serif"},children:["Chronic",o.jsx("span",{style:{color:"#4ade80"},children:"TV"})]})]}),o.jsx("h1",{style:{color:"#fff",fontSize:"18px",fontWeight:"bold",margin:0},children:"Membership Verification"})]}),o.jsx("div",{style:{padding:"20px 24px",textAlign:"center",borderBottom:"1px solid #333"},children:o.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:"8px",background:d?"rgba(74, 222, 128, 0.15)":"rgba(255, 215, 0, 0.15)",padding:"12px 24px",borderRadius:"30px",border:d?"2px solid #4ade80":"2px solid #ffd700"},children:[o.jsx(_a,{size:20,color:d?"#4ade80":"#ffd700",strokeWidth:3}),o.jsx("span",{style:{color:d?"#4ade80":"#ffd700",fontSize:"16px",fontWeight:"bold"},children:d?"Premier Active":"Cultured Free Active"})]})}),o.jsxs("div",{style:{padding:"24px"},children:[o.jsxs("div",{style:{marginBottom:"16px"},children:[o.jsx("label",{style:{color:"#666",fontSize:"12px",textTransform:"uppercase",letterSpacing:"1px"},children:"Name"}),o.jsx("p",{style:{color:"#fff",fontSize:"16px",fontWeight:"bold",margin:"4px 0 0 0"},"data-testid":"text-member-name",children:t?.displayName})]}),o.jsxs("div",{style:{marginBottom:"16px"},children:[o.jsx("label",{style:{color:"#666",fontSize:"12px",textTransform:"uppercase",letterSpacing:"1px"},children:"Email"}),o.jsx("p",{style:{color:"#fff",fontSize:"14px",margin:"4px 0 0 0"},"data-testid":"text-member-email",children:t?.email})]}),o.jsxs("div",{style:{marginBottom:"16px"},children:[o.jsx("label",{style:{color:"#666",fontSize:"12px",textTransform:"uppercase",letterSpacing:"1px"},children:"Membership Tier"}),o.jsxs("p",{style:{color:d?"#ffd700":"#888",fontSize:"14px",fontWeight:"bold",margin:"4px 0 0 0",display:"flex",alignItems:"center",gap:"6px"},"data-testid":"text-member-tier",children:[d&&"â"," ",d?"Premier":"Cultured"]})]}),d&&t?.nextBillingDate&&o.jsxs("div",{style:{marginBottom:"16px"},children:[o.jsx("label",{style:{color:"#666",fontSize:"12px",textTransform:"uppercase",letterSpacing:"1px"},children:"Next Renewal"}),o.jsx("p",{style:{color:"#4ade80",fontSize:"14px",margin:"4px 0 0 0"},"data-testid":"text-next-renewal",children:c(t.nextBillingDate)})]}),!d&&t?.lastRenewalDate&&o.jsxs("div",{style:{marginBottom:"16px"},children:[o.jsx("label",{style:{color:"#666",fontSize:"12px",textTransform:"uppercase",letterSpacing:"1px"},children:"Last Premier"}),o.jsx("p",{style:{color:"#888",fontSize:"14px",margin:"4px 0 0 0"},"data-testid":"text-last-premier",children:c(t.lastRenewalDate)})]}
137),t?.photoIdUrl&&o.jsxs("div",{style:{marginBottom:"16px"},children:[o.jsx("label",{style:{color:"#666",fontSize:"12px",textTransform:"uppercase",letterSpacing:"1px",marginBottom:"8px",display:"block"},children:"State Issued ID"}),o.jsxs("div",{onClick:()=>l(!a),style:{position:"relative",cursor:"pointer",borderRadius:"8px",overflow:"hidden",background:"#252525"},"data-testid":"photo-id-container",children:[o.jsx("img",{src:t.photoIdUrl,alt:"Photo ID",style:{width:"100%",maxHeight:"200px",objectFit:"contain",borderRadius:"8px",filter:a?"none":"blur(12px)",transition:"filter 0.3s ease"}}),!a&&o.jsx("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",background:"rgba(0,0,0,0.7)",padding:"8px 16px",borderRadius:"8px",color:"white",fontSize:"12px",fontWeight:"bold"},children:"ð Tap to reveal"})]})]})]}),d?o.jsx("div",{style:{background:"rgba(74, 222, 128, 0.1)",padding:"16px 24px",borderTop:"1px solid #333"},children:o.jsxs("p",{style:{color:"#4ade80",fontSize:"13px",textAlign:"center",margin:0,display:"flex",alignItems:"center",justifyContent:"center",gap:"6px"},children:[o.jsx(_a,{size:16}),"Eligible for Partner Discounts"]})}):o.jsx("div",{style:{background:"rgba(255, 215, 0, 0.1)",padding:"16px 24px",borderTop:"1px solid #333"},children:o.jsx("p",{style:{color:"#ffd700",fontSize:"13px",textAlign:"center",margin:0},children:"Upgrade to Premier for Partner Discounts"})})]})})}vu();function XL({onClose:n}){const[e,t]=T.useState(null),[s,r]=T.useState("profile"),[i,a]=T.useState(""),[l,c]=T.useState(""),[d,h]=T.useState(""),[p,m]=T.useState(""),[y,x]=T.useState(""),[w,S]=T.useState(""),[_,L]=T.useState(""),[R,M]=T.useState(!1),[V,W]=T.useState(!1),[I,k]=T.useState(""),[P,N]=T.useState(""),[F,z]=T.useState(""),[U,fe]=T.useState(""),[oe,X]=T.useState(null),[Q,G]=T.useState(!1),[Y,ee]=T.useState([]),[H,K]=T.useState({street:"",city:"",state:"",zipCode:"",country:"United States"}),[pe,Fe]=T.useState([]),[_e,ze]=T.useState(!1),[Ye,tt]=T.useState(!1),[lt,ut]=T.useState(""),[cn,ke]=T.useState(""),[Ue,rt]=T.useState([]),[Ct,at]=T.useState(!1),[ft,Nt]=T.useState(1),At=10,[ot,Yt]=T.useState([]),[zt,wn]=T.useState(!1),[Dt,Ee]=T.useState(1),[He,le]=T.useState(""),[ne,J]=T.useState(!1),[De,Le]=T.useState(""),[Lt,Qe]=T.useState(!1),[it,Cn]=T.useState(null),[Mn,Gn]=T.useState(!1),{addToCart:ii}=ty();T.useEffect(()=>{const Re=Md(async St=>{if(t(St),St){h(St.email||"");const Un=await AP(St.uid);Un&&(a(Un.firstName||""),c(Un.lastName||""),m(Un.phoneNumber||""))}});return()=>Re()},[]),T.useEffect(()=>{e&&s==="subscription"?ai():e&&s==="billing"?Fs():e&&s==="history"?os():e&&s==="orders"&&vn()},[e,s]);const ai=async()=>{if(e){G(!0);try{const[Re,St]=await Promise.all([zm(e.uid),fetch("/api/partner-brands")]);X(Re);const Un=await St.json();Un.success&&Un.data&&ee(Un.data)}catch{}finally{G(!1)}}},Fs=async()=>{if(e){ze(!0);try{const[Re,St]=await Promise.all([Bm(e.uid),cd(e.uid)]);Re&&K(Re),Fe(St)}catch{}finally{ze(!1)}}},os=async()=>{if(e){at(!0);try{const Re=await fm(e.uid,50);rt(Re)}catch{}finally{at(!1)}}},vn=async()=>{if(e){wn(!0);try{const Re=await fetch(lo(`/api/orders/user/${e.uid}`));if(Re.ok){const St=await Re.json(),Un=Array.isArray(St)?St:St.orders||[];try{const Vn=await fetch(lo("/api/admin/purchase-items"));if(Vn.ok){const La=await Vn.json(),Br=new Map;La.forEach(Rn=>{Rn.id&&Rn.imageUrl&&Br.set(Rn.id,Rn.imageUrl)});const Da=Un.map(Rn=>({...Rn,items:Rn.items.map(Te=>{const pt=Br.get(Te.productId);return pt&&(!Te.imageUrl||Te.imageUrl.startsWith("/uploads/"))?{...Te,imageUrl:pt}:Te})}));Yt(Da)}else Yt(Un)}catch{Yt(Un)}}}catch{}finally{wn(!1)}}},ln=Re=>{switch(Re){case"pending":return o.jsx(uo,{size:16,className:"text-yellow-500"});case"processing":return o.jsx(gd,{size:16,className:"text-blue-500"});case"shipped":return o.jsx(W7,{size:16,className:"text-purple-500"});case"delivered":return o.jsx(Vc,{size:16,className:"text-green-500"});case"cancelled":return o.jsx(ax,{size:16,className:"text-red-500"});default:return o.jsx(uo,{size:16,className:"text-gray-500"})}},Qs=async Re=>{if(Re.preventDefault(),!!e){M(!0),N(""),k("");try{await CP(e.uid,{firstName:i,lastName:l,phoneNumber:p,displayName:`${i} ${l}`.trim()}),k("Profile updated successfully!"),setTimeout(()=>k(""),3e3)}catch(St){N(St.message||"Failed to update profile")}finally{M(!1)}}},Tr=async Re=>{if(Re.preventDefault(),!!e){if(w!==_){fe("New passwords do not match");return}if(w.length<6){fe("Password must be at least 6 characters");return}W(!0),fe(""),z("");try{const St=await kP(y,w);St.success?(z("Password changed successfully!"),x(""),S(""),L(""),setTimeout(()=>z(""),3e3)):fe(St.error||"Failed to change password")}catch(St){fe(St.message||"Failed to change password")}finally{W(!1)}}},hr=async Re=>{if(Re.preventDefault(),!!e){tt(!0),ke(""),ut("");try{await R1(e.uid,H),ut("Billing address saved successfully!"),setTimeout(()=>ut(""),3e3)}catch(St){ke(St.message||"Failed to save billing address")}finally{tt(!1)}}},Na=async()=>
137{if(!(!e||!He.trim())){J(!0),Le(""),Qe(!1),Cn(null);try{const St=await(await fetch(lo("/api/promo-codes/validate"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:He.trim()})})).json();Le(St.message),Qe(St.valid),St.valid&&Cn(He.trim().toUpperCase())}catch(Re){Le(Re.message||"Failed to validate promo code"),Qe(!1)}finally{J(!1)}}},Xs=async()=>{if(!(!e||!it)){Gn(!0);try{await ii({productId:"premier-membership-promo",productName:"Premier Membership (1st Month Free)",price:0,originalPrice:10,isPremierMembership:!0,promoCodeApplied:it,category:"membership"}),Le("Premier Membership added to cart! First month is free, then $10/month."),le(""),Cn(null)}catch(Re){Le(Re.message||"Failed to add to cart"),Qe(!1)}finally{Gn(!1)}}},oi=[{id:"profile",label:"Edit Account",icon:r4},{id:"subscription",label:"Manage Subscription",icon:oo},{id:"billing",label:"Billing Information",icon:v0},{id:"history",label:"Watch History",icon:TT},{id:"orders",label:"Purchase History",icon:X0}],_r=Ue.slice((ft-1)*At,ft*At),es=Math.ceil(Ue.length/At),Ir=ot.slice((Dt-1)*At,Dt*At),Ar=Math.ceil(ot.length/At);return o.jsx("div",{style:{minHeight:"100vh",background:"#121212",color:"white",padding:"20px"},children:o.jsxs("div",{style:{maxWidth:"800px",margin:"0 auto"},children:[o.jsxs("button",{onClick:n,style:{display:"flex",alignItems:"center",gap:"8px",background:"none",border:"none",color:"#4ade80",fontSize:"16px",cursor:"pointer",padding:"10px 0",marginBottom:"20px"},"data-testid":"button-back-from-account",children:[o.jsx(Fr,{size:20}),"Back"]}),o.jsxs("h1",{style:{fontSize:"28px",fontWeight:"bold",margin:"0 0 30px 0",display:"flex",alignItems:"center",gap:"12px"},children:[o.jsx(jh,{size:28}),"My Account"]}),o.jsx("div",{style:{display:"flex",gap:"8px",marginBottom:"30px",flexWrap:"wrap"},children:oi.map(Re=>o.jsxs("button",{onClick:()=>r(Re.id),style:{display:"flex",alignItems:"center",gap:"8px",padding:"12px 16px",borderRadius:"8px",border:"none",background:s===Re.id?"#4ade80":"#2a2a2a",color:s===Re.id?"black":"white",fontSize:"14px",fontWeight:s===Re.id?"bold":"normal",cursor:"pointer",transition:"all 0.2s"},children:[o.jsx(Re.icon,{size:18}),Re.label]},Re.id))}),s==="profile"&&o.jsxs("div",{style:{maxWidth:"500px"},children:[o.jsxs("form",{onSubmit:Qs,style:{marginBottom:"40px"},children:[o.jsx("h2",{style:{fontSize:"20px",fontWeight:"600",margin:"0 0 20px 0",color:"#ccc"},children:"Profile Information"}),o.jsxs("div",{style:{display:"flex",gap:"12px",marginBottom:"16px"},children:[o.jsxs("div",{style:{flex:1,minWidth:0},children:[o.jsx("label",{style:{display:"block",color:"#888",fontSize:"14px",marginBottom:"6px"},children:"First Name"}),o.jsx("input",{type:"text",value:i,onChange:Re=>a(Re.target.value),style:{width:"100%",padding:"14px",borderRadius:"8px",border:"1px solid #444",background:"#2a2a2a",color:"white",fontSize:"15px",boxSizing:"border-box"},"data-testid":"input-first-name"})]}),o.jsxs("div",{style:{flex:1,minWidth:0},children:[o.jsx("label",{style:{display:"block",color:"#888",fontSize:"14px",marginBottom:"6px"},children:"Last Name"}),o.jsx("input",{type:"text",value:l,onChange:Re=>c(Re.target.value),style:{width:"100%",padding:"14px",borderRadius:"8px",border:"1px solid #444",background:"#2a2a2a",color:"white",fontSize:"15px",boxSizing:"border-box"},"data-testid":"input-last-name"})]})]}),o.jsxs("div",{style:{marginBottom:"16px"},children:[o.jsx("label",{style:{display:"block",color:"#888",fontSize:"14px",marginBottom:"6px"},children:"Phone Number"}),o.jsx("input",{type:"tel",value:p,onChange:Re=>m(Re.target.value),style:{width:"100%",padding:"14px",borderRadius:"8px",border:"1px solid #444",background:"#2a2a2a",color:"white",fontSize:"15px",boxSizing:"border-box"},"data-testid":"input-phone"})]}),o.jsxs("div",{style:{marginBottom:"20px"},children:[o.jsx("label",{style:{display:"block",color:"#888",fontSize:"14px",marginBottom:"6px"},children:"Email Address"}),o.jsx("input",{type:"email",value:d,disabled:!0,style:{width:"100%",padding:"14px",borderRadius:"8px",border:"1px solid #333",background:"#1a1a1a",color:"#666",fontSize:"15px",boxSizing:"border-box",cursor:"not-allowed"},"data-testid":"input-email"}),o.jsx("p",{style:{color:"#666",fontSize:"12px",margin:"6px 0 0 0"},children:"Email cannot be changed"})]}),P&&o.jsx("p",{style:{color:"#ff4444",fontSize:"14px",margin:"0 0 16px 0"},children:P}),I&&o.jsx("p",{style:{color:"#4ade80",fontSize:"14px",margin:"0 0 16px 0"},children:I}),o.jsxs("button",{type:"submit",disabled:R,style:{width:"100%",padding:"14px",borderRadius:"8px",border:"none",background:"#4ade80",color:"black",fontSize:"16px",fontWeight:"bold",cursor:R?"wait":"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",opacity:R?.7:1},"data-testid":"button-save-profile",children:[R?o.jsx(Nn,{size:20,className:"animate-spin"}):o.jsx(kT,{size:20}),R?"Saving...":"Save Profile"]})]}),o.jsx("div",{style:{height:"1px",background:"#333",margin:"30px 0"}}),o.jsxs("form",{onSubmit:Tr,children:[o.jsxs("h2",{style:{fontSize:"20px",fontWeight:"600",margin:"0 0 20px 0",color:"#ccc",display:"flex",alignItems:"center",gap:"10px"},children:[o.jsx(Gh,{size:20}),"Change Password"]}
137),o.jsxs("div",{style:{marginBottom:"16px"},children:[o.jsx("label",{style:{display:"block",color:"#888",fontSize:"14px",marginBottom:"6px"},children:"Current Password"}),o.jsx("input",{type:"password",value:y,onChange:Re=>x(Re.target.value),style:{width:"100%",padding:"14px",borderRadius:"8px",border:"1px solid #444",background:"#2a2a2a",color:"white",fontSize:"15px",boxSizing:"border-box"},"data-testid":"input-current-password"})]}),o.jsxs("div",{style:{marginBottom:"16px"},children:[o.jsx("label",{style:{display:"block",color:"#888",fontSize:"14px",marginBottom:"6px"},children:"New Password"}),o.jsx("input",{type:"password",value:w,onChange:Re=>S(Re.target.value),style:{width:"100%",padding:"14px",borderRadius:"8px",border:"1px solid #444",background:"#2a2a2a",color:"white",fontSize:"15px",boxSizing:"border-box"},"data-testid":"input-new-password"})]}),o.jsxs("div",{style:{marginBottom:"20px"},children:[o.jsx("label",{style:{display:"block",color:"#888",fontSize:"14px",marginBottom:"6px"},children:"Confirm New Password"}),o.jsx("input",{type:"password",value:_,onChange:Re=>L(Re.target.value),style:{width:"100%",padding:"14px",borderRadius:"8px",border:"1px solid #444",background:"#2a2a2a",color:"white",fontSize:"15px",boxSizing:"border-box"},"data-testid":"input-confirm-password"})]}),U&&o.jsx("p",{style:{color:"#ff4444",fontSize:"14px",margin:"0 0 16px 0"},children:U}),F&&o.jsx("p",{style:{color:"#4ade80",fontSize:"14px",margin:"0 0 16px 0"},children:F}),o.jsxs("button",{type:"submit",disabled:V||!y||!w||!_,style:{width:"100%",padding:"14px",borderRadius:"8px",border:"none",background:y&&w&&_?"#4ade80":"#444",color:y&&w&&_?"black":"#888",fontSize:"16px",fontWeight:"bold",cursor:V?"wait":y&&w&&_?"pointer":"not-allowed",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",opacity:V?.7:1},"data-testid":"button-change-password",children:[V?o.jsx(Nn,{size:20,className:"animate-spin"}):o.jsx(Gh,{size:20}),V?"Changing...":"Change Password"]})]})]}),s==="subscription"&&o.jsxs("div",{style:{maxWidth:"600px"},children:[o.jsxs("h2",{style:{fontSize:"20px",fontWeight:"600",margin:"0 0 20px 0",color:"#ccc",display:"flex",alignItems:"center",gap:"10px"},children:[o.jsx(oo,{size:20}),"Manage Subscription"]}),Q?o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",color:"#888"},children:[o.jsx(Nn,{size:20,className:"animate-spin"}),"Loading subscription info..."]}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{background:"#2a2a2a",borderRadius:"12px",padding:"20px",marginBottom:"24px"},children:[o.jsx("p",{style:{color:"#888",fontSize:"14px",margin:"0 0 8px 0"},children:"Current Plan"}),o.jsx("p",{style:{color:"white",fontSize:"18px",fontWeight:"bold",margin:0},children:oe?.tier||"Free"}),oe?.expiresAt&&o.jsxs("p",{style:{color:"#888",fontSize:"14px",margin:"8px 0 0 0"},children:["Expires: ",new Date(oe.expiresAt).toLocaleDateString()]})]}),oe?.tier!=="premier"&&oe?.tier!=="Premier"&&o.jsxs("div",{style:{background:"linear-gradient(135deg, #1a3a1a 0%, #0a200a 100%)",borderRadius:"12px",padding:"20px",marginBottom:"24px",border:"1px solid #4ade80"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",marginBottom:"12px"},children:[o.jsx(t4,{size:20,color:"#4ade80"}),o.jsx("h3",{style:{color:"#4ade80",fontSize:"16px",margin:0,fontWeight:"bold"},children:"Have a Promo Code?"})]}),o.jsx("p",{style:{color:"#ccc",fontSize:"14px",margin:"0 0 16px 0"},children:"Enter your promo code to get your first month of Premier free!"}),o.jsxs("div",{style:{display:"flex",gap:"12px"},children:[o.jsx("input",{type:"text",value:He,onChange:Re=>{le(Re.target.value.toUpperCase()),it&&(Cn(null),Le(""),Qe(!1))},placeholder:"Enter promo code",disabled:!!it,style:{flex:1,padding:"12px 16px",borderRadius:"8px",border:`1px solid ${it?"#4ade80":"#333"}`,background:"#1a1a1a",color:"white",fontSize:"14px",letterSpacing:"1px",opacity:it?.7:1}}),o.jsx("button",{onClick:Na,disabled:ne||!He.trim()||!!it,style:{padding:"12px 24px",borderRadius:"8px",border:"none",background:ne||!He.trim()||it?"#333":"#4ade80",color:ne||!He.trim()||it?"#666":"black",fontWeight:"bold",cursor:ne||!He.trim()||it?"not-allowed":"pointer",display:"flex",alignItems:"center",gap:"8px"},children:ne?o.jsxs(o.Fragment,{children:[o.jsx(Nn,{size:16,className:"animate-spin"}),"Checking..."]}):it?o.jsxs(o.Fragment,{children:[o.jsx(Vc,{size:16}),"Applied"]}):o.jsxs(o.Fragment,{children:[o.jsx(ox,{size:16}),"Apply"]})})]}),De&&o.jsx("p",{style:{margin:"12px 0 0 0",padding:"10px",borderRadius:"6px",fontSize:"14px",background:Lt?"rgba(74, 222, 128, 0.1)":"rgba(239, 68, 68, 0.1)",color:Lt?"#4ade80":"#ef4444",border:`1px solid ${Lt?"#4ade80":"#ef4444"}`},children:De}),it&&o.jsx("button",{onClick:Xs,disabled:Mn,style:{width:"100%",marginTop:"12px",padding:"14px 24px",borderRadius:"8px",border:"2px s
137olid #4ade80",background:"rgba(74, 222, 128, 0.15)",color:"#4ade80",fontWeight:"bold",fontSize:"15px",cursor:Mn?"not-allowed":"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"10px"},children:Mn?o.jsxs(o.Fragment,{children:[o.jsx(Nn,{size:18,className:"animate-spin"}),"Adding..."]}):o.jsxs(o.Fragment,{children:[o.jsx(Fl,{size:18}),"Add Premier Membership to Cart â 1st Month Free"]})})]}),Y.length>0&&o.jsxs(o.Fragment,{children:[o.jsx("h3",{style:{color:"#ccc",fontSize:"16px",margin:"0 0 16px 0"},children:"Partner Brand Discounts"}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:Y.map((Re,St)=>o.jsxs("a",{href:Re.referralLink,target:"_blank",rel:"noopener noreferrer",style:{display:"flex",justifyContent:"space-between",alignItems:"center",background:"#2a2a2a",borderRadius:"8px",padding:"16px",textDecoration:"none",color:"white"},children:[o.jsxs("div",{children:[o.jsx("p",{style:{margin:0,fontWeight:"bold"},children:Re.brandName}),Re.shortInfo&&o.jsx("p",{style:{margin:"4px 0 0 0",color:"#888",fontSize:"14px"},children:Re.shortInfo})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[Re.discount&&o.jsx("span",{style:{color:"#4ade80",fontWeight:"bold"},children:Re.discount}),o.jsx(Uc,{size:18,color:"#888"})]})]},St))})]})]})]}),s==="billing"&&o.jsxs("div",{style:{maxWidth:"500px"},children:[o.jsxs("h2",{style:{fontSize:"20px",fontWeight:"600",margin:"0 0 20px 0",color:"#ccc",display:"flex",alignItems:"center",gap:"10px"},children:[o.jsx(v0,{size:20}),"Billing Information"]}),_e?o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",color:"#888"},children:[o.jsx(Nn,{size:20,className:"animate-spin"}),"Loading billing info..."]}):o.jsxs(o.Fragment,{children:[pe.length>0&&o.jsxs("div",{style:{marginBottom:"24px"},children:[o.jsx("h3",{style:{color:"#ccc",fontSize:"16px",margin:"0 0 12px 0"},children:"Saved Payment Methods"}),pe.map((Re,St)=>o.jsxs("div",{style:{background:"#2a2a2a",borderRadius:"8px",padding:"16px",marginBottom:"8px",display:"flex",alignItems:"center",gap:"12px"},children:[o.jsx(v0,{size:24,color:"#4ade80"}),o.jsxs("div",{children:[o.jsxs("p",{style:{margin:0,fontWeight:"bold"},children:[Re.cardType||"Card"," ending in ",Re.lastFour||"****"]}),Re.expiryDate&&o.jsxs("p",{style:{margin:"4px 0 0 0",color:"#888",fontSize:"14px"},children:["Expires ",Re.expiryDate]})]})]},St))]}),o.jsxs("form",{onSubmit:hr,children:[o.jsx("h3",{style:{color:"#ccc",fontSize:"16px",margin:"0 0 16px 0"},children:"Billing Address"}),o.jsxs("div",{style:{marginBottom:"16px"},children:[o.jsx("label",{style:{display:"block",color:"#888",fontSize:"14px",marginBottom:"6px"},children:"Street Address"}),o.jsx("input",{type:"text",value:H.street,onChange:Re=>K({...H,street:Re.target.value}),style:{width:"100%",padding:"14px",borderRadius:"8px",border:"1px solid #444",background:"#2a2a2a",color:"white",fontSize:"15px",boxSizing:"border-box"}})]}),o.jsxs("div",{style:{display:"flex",gap:"12px",marginBottom:"16px"},children:[o.jsxs("div",{style:{flex:1},children:[o.jsx("label",{style:{display:"block",color:"#888",fontSize:"14px",marginBottom:"6px"},children:"City"}),o.jsx("input",{type:"text",value:H.city,onChange:Re=>K({...H,city:Re.target.value}),style:{width:"100%",padding:"14px",borderRadius:"8px",border:"1px solid #444",background:"#2a2a2a",color:"white",fontSize:"15px",boxSizing:"border-box"}})]}),o.jsxs("div",{style:{flex:1},children:[o.jsx("label",{style:{display:"block",color:"#888",fontSize:"14px",marginBottom:"6px"},children:"State"}),o.jsx("input",{type:"text",value:H.state,onChange:Re=>K({...H,state:Re.target.value}),style:{width:"100%",padding:"14px",borderRadius:"8px",border:"1px solid #444",background:"#2a2a2a",color:"white",fontSize:"15px",boxSizing:"border-box"}})]})]}),o.jsxs("div",{style:{display:"flex",gap:"12px",marginBottom:"20px"},children:[o.jsxs("div",{style:{flex:1},children:[o.jsx("label",{style:{display:"block",color:"#888",fontSize:"14px",marginBottom:"6px"},children:"ZIP Code"}),o.jsx("input",{type:"text",value:H.zipCode,onChange:Re=>K({...H,zipCode:Re.target.value}),style:{width:"100%",padding:"14px",borderRadius:"8px",border:"1px solid #444",background:"#2a2a2a",color:"white",fontSize:"15px",boxSizing:"border-box"}})]}),o.jsxs("div",{style:{flex:1},children:[o.jsx("label",{style:{display:"block",color:"#888",fontSize:"14px",marginBottom:"6px"},children:"Country"}),o.jsx("input",{type:"text",value:H.country,disabled:!0,style:{width:"100%",padding:"14px",borderRadius:"8px",border:"1px solid #333",background:"#1a1a1a",color:"#666",fontSize:"15px",boxSizing:"border-box",cursor:"not-allowed"}})]})]}),cn&&o.jsx("p",{style:{color:"#ff4444",fontSize:"14px",margin:"0 0 16px 0"},children:cn}),lt&&o.jsx("p",{style:{color:"#4ade80",fontSize:"14px",margin:"0 0 16px 0"},children:lt}),o.jsxs("button",{type:"submit",disabled:Ye,style:{width:"100%",padding:"14px",borderRadius:"8px",border:"none",background:"#4ade80",color:"black",fontSize:"16px",fontWeight:"bold",cursor:Ye?"wait":"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",opacity:Ye?.7:1},children:[Ye?o.jsx(Nn,{size:20,className:"animate-spin"}):o.jsx(kT,{size:20}),Ye?"Saving...":"Save Billing Address"]})]})]})]}),s==="history"&&o.jsxs("div",{children:[o.jsxs("h2",{style:{fontSize:"20px",fontWeight:"600",margin:"0 0 20px 0",color:"#ccc",display:"flex",alignItems:"center",gap:"10px"},children:[o.jsx(TT,{size:20}),"Watch History"]}),Ct?o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",color:"#888"},children:[o.jsx(Nn,{size:20,className:"animate-spin"}),"Loading watch history..."]}):Ue.length===0?o.jsx("p",{style:{color:"#888"},children:"No watch history yet. Start watching to see your history here!"}):o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[_r.map((Re,St)=>o.jsxs("div",{style:{display:"flex",gap:"16px",background:"#2a2a2a",borderRadius:"8px",padding:"12px",alignItems:"center"},children:[Re.thumbnailUrl?o.jsx("img",{src:Re.thumbnailUrl,alt:Re.videoTitle,style:{width:"120px",height:"68px",objectFit:"cover",borderRadius:"4px",background:"#1a1a1a"}}):o.jsx("div",{style:{width:"120px",height:"68px",background:"#1a1a1a",borderRadius:"4px",display:"flex",alignItems:"center",justifyContent:"center"},children:o.jsx(oo,{size:24,color:"#444"})}),o.jsxs("div",{style:{flex:1,minWidth:0},children:[o.jsx("p",{style:{margin:0,fontWeight:"bold",fontSize:"15px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:Re.videoTitle}),Re.showName&&o.jsx("p",{style:{margin:"4px 0 0 0",color:"#888",fontSize:"14px"},children:Re.showName}),o.jsxs("p",{style:{margin:"4px 0 0 0",color:"#666",fontSize:"12px"},children:[new Date(Re.watchedAt).toLocaleDateString()," at ",new Date(Re.watchedAt).toLocaleTimeString()]})]})]},St)),es>1&&o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"16px",marginTop:"20px",paddingTop:"20px",borderTop:"1px solid #333"},children:[o.jsxs("button",{onClick:()=>Nt(Re=>Math.max(1,Re-1)),disabled:ft===1,style:{display:"flex",alignItems:"center",gap:"4px",padding:"8px 16px",borderRadius:"8px",border:"none",background:ft===1?"#333":"#4ade80",color:ft===1?"#666":"black",cursor:ft===1?"not-allowed":"pointer",fontSize:"14px"},children:[o.jsx(md,{size:18}),"Previous"]}),o.jsxs("span",{style:{color:"#888",fontSize:"14px"},children:["Page ",ft," of ",es]}),o.jsxs("button",{onClick:()=>Nt(Re=>Math.min(es,Re+1)),disabled:ft===es,style:{display:"flex",alignItems:"center",gap:"4px",padding:"8px 16px",borderRadius:"8px",border:"none",background:ft===es?"#333":"#4ade80",color:ft===es?"#666":"black",cursor:ft===es?"not-allowed":"pointer",fontSize:"14px"},children:["Next",o.jsx(Uc,{size:18})]})]})]})]}),s==="orders"&&o.jsxs("div",{children:[o.jsxs("h2",{style:{fontSize:"20px",fontWeight:"600",margin:"0 0 20px 0",color:"#ccc",display:"flex",alignItems:"center",gap:"10px"},children:[o.jsx(X0,{size:20}),"Purchase History"]}),zt?o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",color:"#888"},children:[o.jsx(Nn,{size:20,className:"animate-spin"}),"Loading purchase history..."]}):ot.length===0?o.jsx("p",{style:{color:"#888"},children:"No orders yet. Visit our shop to make your first purchase!"}):o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[Ir.map(Re=>o.jsxs("div",{style:{background:"#2a2a2a",borderRadius:"12px",padding:"16px",border:"1px solid #333"},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"12px"},children:[o.jsxs("div",{children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[o.jsxs("p",{style:{margin:0,color:"#888",fontSize:"12px"},children:["Order #",Re.id.slice(-8).toUpperCase()]}),(Re.orderStatus==="test_completed"||Re.paymentMethod?.includes("Test"))&&o.jsx("span",{style:{background:"#eab308",color:"#000",fontSize:"10px",fontWeight:"bold",padding:"2px 6px",borderRadius:"4px"},children:"TEST"})]}),o.jsxs("p",{style:{margin:"4px 0 0 0",color:"#666",fontSize:"12px"},children:[new Date(Re.createdAt).toLocaleDateString()," at ",new Date(Re.createdAt).toLocaleTimeString()]})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",padding:"4px 10px",background:"#1a1a1a",borderRadius:"20px"},children:[ln(Re.orderStatus),o.jsx("span",{style:{fontSize:"12px",color:"#ccc",textTransform:"capitalize"},children:Re.orderStatus})]})]}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px",marginBottom:"12px"},children:Re.items.map((St,Un)=>o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[St.imageUrl?o.jsx("img",{src:St.imageUrl,alt:St.productName,style:{width:"48px",height:"48px",objectFit:"cover",borderRadius:"4px",background:"#1a1a1a"}}):o.jsx("div",{style:{width:"48px",height:"48px",background:"#1a1a1a",borderRadius:"4px",display:"flex",alignItems:"center",justifyContent:"center"},children:o.jsx(gd,{size:20,color:"#444"})}),o.jsxs("div",{style:{flex:1},children:[o.jsx("p",{style:{margin:0,fontSize:"14px",fontWeight:"500"},children:St.productName}),o.jsxs("p",{style:{margin:"2px 0 0 0",color:"#888",fontSize:"12px"},children:["Qty: ",St.quantity," x $",St.price.toFixed(2)]})]})]},Un))}),o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",paddingTop:"12px",borderTop:"1px solid #333"},children:[o.jsx("span",{style:{color:"#888",fontSize:"14px"},children:Re.paymentMethod}),o.jsxs("span",{style:{color:"#4ade80",fontWeight:"bold",fontSize:"16px"},children:["$",Re.total.toFixed(2)]})]})]},Re.id)),Ar>1&&o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"16px",marginTop:"20px",paddingTop:"20px",borderTop:"1px solid #333"},children:[o.jsxs("button",{onClick:()=>Ee(Re=>Math.max(1,Re-1)),disabled:Dt===1,style:{display:"flex",alignItems:"center",gap:"4px",padding:"8px 16px",borderRadius:"8px",border:"none",background:Dt===1?"#333":"#4ade80",color:Dt===1?"#666":"black",cursor:Dt===1?"not-allowed":"pointer",fontSize:"14px"},children:[o.jsx(md,{size:18}),"Previous"]}),o.jsxs("span",{style:{color:"#888",fontSize:"14px"},children:["Page ",Dt," of ",Ar]}),o.jsxs("button",{onClick:()=>Ee(Re=>Math.min(Ar,Re+1)),disabled:Dt===Ar,style:{display:"flex",alignItems:"center",gap:"4px",padding:"8px 16px",borderRadius:"8px",border:"none",background:Dt===Ar?"#333":"#4ade80",color:Dt===Ar?"#666":"black",cursor:Dt===Ar?"not-allowed":"pointer",fontSize:"14px"},children:["Next",o.jsx(Uc,{size:18})]})]})]})]})]})})}var bw;(function(n){n.Dark="DARK",n.Light="LIGHT",n.Default="DEFAULT"})(bw||(bw={}));var jI;(function(n){n.None="NONE",n.Slide="SLIDE",n.Fade="FADE"})(jI||(jI={}));
137const $v=sl("StatusBar"),f0=sl("App",{web:()=>ps(()=>import("./web-BjLSWetw.js"),[]).then(n=>new n.AppWeb)}),Cie=sl("SplashScreen",{web:()=>ps(()=>import("./web-BvAfqBuc.js"),[]).then(n=>new n.SplashScreenWeb)});var OI;(function(n){n.Dark="DARK",n.Light="LIGHT",n.Default="DEFAULT"})(OI||(OI={}));var MI;(function(n){n.Body="body",n.Ionic="ionic",n.Native="native",n.None="none"})(MI||(MI={}));const FI=sl("Keyboard"),kie=sl("Device",{web:()=>ps(()=>import("./web-BJrblHNK.js"),[]).then(n=>new n.DeviceWeb)}),Nh=class Nh{static async initialize(){if(!Zr.isNativePlatform()||this.isInitialized)return{statusBarHeight:0,navigationBarHeight:0};try{return await this.setupStatusBar(),this.setupAppLifecycle(),this.setupKeyboard(),this.isInitialized=!0,{statusBarHeight:this.statusBarHeight,navigationBarHeight:this.navigationBarHeight}}catch{return{statusBarHeight:0,navigationBarHeight:0}}}static async setupStatusBar(){try{const e=await kie.getInfo();this.deviceDensity=await this.getDeviceDensity();const{statusBarHeight:t,navigationBarHeight:s}
137=await this.getSystemUIMeasurements();this.statusBarHeight=t,this.navigationBarHeight=s,document.documentElement.style.setProperty("--status-bar-height",`${this.statusBarHeight}px`),document.documentElement.style.setProperty("--navigation-bar-height",`${this.navigationBarHeight}px`),document.documentElement.style.setProperty("--device-density",`${this.deviceDensity}`),await $v.setStyle({style:bw.Dark}),await $v.setOverlaysWebView({overlay:!1}),await $v.setBackgroundColor({color:"#000000"})}catch{this.statusBarHeight=28,this.navigationBarHeight=48,document.documentElement.style.setProperty("--status-bar-height",`${this.statusBarHeight}px`),document.documentElement.style.setProperty("--navigation-bar-height",`${this.navigationBarHeight}px`)}}static async getDeviceDensity(){try{return window.devicePixelRatio||1}catch{return 1}}static async getSystemUIMeasurements(){return{statusBarHeight:0,navigationBarHeight:0}}static setupAppLifecycle(){f0.addListener("appStateChange",({isActive:e})=>{e||document.querySelectorAll('video, iframe[src*="vimeo"], iframe[src*="youtube"]').forEach(s=>{s instanceof HTMLVideoElement?s.pause():s instanceof HTMLIFrameElement&&window.dispatchEvent(new CustomEvent("app-background",{detail:{pauseVideo:!0}}))})}),f0.addListener("appUrlOpen",e=>{})}static setupKeyboard(){FI.addListener("keyboardWillShow",e=>{document.documentElement.style.setProperty("--native-keyboard-height",`${e.keyboardHeight}px`),document.body.classList.add("keyboard-visible")}),FI.addListener("keyboardWillHide",()=>{document.documentElement.style.setProperty("--native-keyboard-height","0px"),document.body.classList.remove("keyboard-visible")})}static setupBackButtonNavigation(e){Zr.isNativePlatform()&&f0.addListener("backButton",({canGoBack:t})=>{!e(t)&&!t&&f0.exitApp()})}static async hideSplashScreen(e=!1){if(Zr.isNativePlatform())try{await Cie.hide({fadeOutDuration:e?0:300})}catch{}}static getStatusBarHeight(){return this.statusBarHeight}static isNative(){return Zr.isNativePlatform()}};Nh.statusBarHeight=0,Nh.navigationBarHeight=0,Nh.deviceDensity=1,Nh.isInitialized=!1;let H1=Nh;var ww;(function(n){n.Dark="DARK",n.Light="LIGHT",n.Default="DEFAULT"})(ww||(ww={}));var UI;(function(n){n.StatusBar="STATUS_BAR",n.NavigationBar="NAVIGATION_BAR"})(UI||(UI={}));const Rie=sl("SafeArea",{web:()=>ps(()=>import("./web-CB5rPIIl.js"),[]).then(n=>new n.SafeAreaWeb)});class Pie{static async initialize(){if(Zr.isNativePlatform())try{await Rie.setSystemBarsStyle({style:ww.Dark});const e=getComputedStyle(document.documentElement),t=e.getPropertyValue("--safe-area-inset-top"),s=e.getPropertyValue("--safe-area-inset-bottom")}catch{}}}const JL=T.createContext({});function Nie(n){const e=T.useRef(null);return e.current===null&&(e.current=n()),e.current}const Lie=typeof window<"u",Die=Lie?T.useLayoutEffect:T.useEffect,ES=T.createContext(null);function TS(n,e){n.indexOf(e)===-1&&n.push(e)}function W1(n,e){const t=n.indexOf(e);t>-1&&n.splice(t,1)}const tl=(n,e,t)=>t>e?e:t<n?n:t;let _S=()=>{};const fu={},ZL=n=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(n),eD=n=>typeof n=="object"&&n!==null,tD=n=>/^0[^.\s]+$/u.test(n);function nD(n){let e;return()=>(e===void 0&&(e=n()),e)}const Ta=n=>n,$m=(...n)=>n.reduce((e,t)=>s=>t(e(s))),Sm=(n,e,t)=>{const s=e-n;return s?(t-n)/s:1};class IS{constructor(){this.subscriptions=[]}add(e){return TS(this.subscriptions,e),()=>W1(this.subscriptions,e)}notify(e,t,s){const r=this.subscriptions.length;if(r)if(r===1)this.subscriptions[0](e,t,s);else for(let i=0;i<r;i++){const a=this.subscriptions[i];a&&a(e,t,s)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const sa=n=>n*1e3,Sa=n=>n/1e3,sD=(n,e)=>e?n*(1e3/e):0,rD=(n,e,t)=>(((1-3*t+3*e)*n+(3*t-6*e))*n+3*e)*n,jie=1e-7,Oie=12;function Mie(n,e,t,s,r){let i,a,l=0;do a=e+(t-e)/2,i=rD(a,s,r)-n,i>0?t=a:e=a;while(Math.abs(i)>jie&&++l<Oie);return a}function Hm(n,e,t,s){if(n===e&&t===s)return Ta;const r=i=>Mie(i,0,1,n,t);return i=>i===0||i===1?i:rD(r(i),e,s)}const iD=n=>e=>e<=.5?n(2*e)/2:(2-n(2*(1-e)))/2,aD=n=>e=>1-n(1-e),oD=Hm(.33,1.53,.69,.99),AS=aD(oD),lD=iD(AS),cD=n=>n>=1?1:(n*=2)<1?.5*AS(n):.5*(2-Math.pow(2,-10*(n-1))),CS=n=>1-Math.sin(Math.acos(n)),uD=aD(CS),dD=iD(CS),Fie=Hm(.42,0,1,1),Uie=Hm(0,0,.58,1),hD=Hm(.42,0,.58,1),Vie=n=>Array.isArray(n)&&typeof n[0]!="number",fD=n=>Array.isArray(n)&&typeof n[0]=="number",Bie={linear:Ta,easeIn:Fie,easeInOut:hD,easeOut:Uie,circIn:CS,circInOut:dD,circOut:uD,backIn:AS,backInOut:lD,backOut:oD,anticipate:cD},zie=n=>typeof n=="string",VI=n=>{if(fD(n)){_S(n.length===4);const[e,t,s,r]=n;return Hm(e,t,s,r)}else if(zie(n))return Bie[n];return n},p0=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function $ie(n,e){let t=new Set,s=new Set,r=!1,i=!1;const a=new WeakSet;let l={delta:0,timestamp:0,isProcessing:!1};function c(h){a.has(h)&&(d.schedule(h),n()),h(l)}
vendor: 4,352 bytes, line 137
137const d={schedule:(h,p=!1,m=!1)=>{const x=m&&r?t:s;return p&&a.add(h),x.add(h),h},cancel:h=>{s.delete(h),a.delete(h)},process:h=>{if(l=h,r){i=!0;return}r=!0;const p=t;t=s,s=p,t.forEach(c),t.clear(),r=!1,i&&(i=!1,d.process(h))}};return d}const Hie=40;function pD(n,e){let t=!1,s=!0;const r={delta:0,timestamp:0,isProcessing:!1},i=()=>t=!0,a=p0.reduce((R,M)=>(R[M]=$ie(i),R),{}),{setup:l,read:c,resolveKeyframes:d,preUpdate:h,update:p,preRender:m,render:y,postRender:x}=a,w=()=>{const R=fu.useManualTiming,M=R?r.timestamp:performance.now();t=!1,R||(r.delta=s?1e3/60:Math.max(Math.min(M-r.timestamp,Hie),1)),r.timestamp=M,r.isProcessing=!0,l.process(r),c.process(r),d.process(r),h.process(r),p.process(r),m.process(r),y.process(r),x.process(r),r.isProcessing=!1,t&&e&&(s=!1,n(w))},S=()=>{t=!0,s=!0,r.isProcessing||n(w)};return{schedule:p0.reduce((R,M)=>{const V=a[M];return R[M]=(W,I=!1,k=!1)=>(t||S(),V.schedule(W,I,k)),R},{}),cancel:R=>{for(let M=0;M<p0.length;M++)a[p0[M]].cancel(R)},state:r,steps:a}}const{schedule:On,cancel:pu,state:xr,steps:Hv}=pD(typeof requestAnimationFrame<"u"?requestAnimationFrame:Ta,!0);let B0;function Wie(){B0=void 0}const ti={now:()=>(B0===void 0&&ti.set(xr.isProcessing||fu.useManualTiming?xr.timestamp:performance.now()),B0),set:n=>{B0=n,queueMicrotask(Wie)}},mD=n=>e=>typeof e=="string"&&e.startsWith(n),gD=mD("--"),Gie=mD("var(--"),kS=n=>Gie(n)?Kie.test(n.split("/*")[0].trim()):!1,Kie=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function BI(n){return typeof n!="string"?!1:n.split("/*")[0].includes("var(--")}const Nf={test:n=>typeof n=="number",parse:parseFloat,transform:n=>n},Em={...Nf,transform:n=>tl(0,1,n)},m0={...Nf,default:1},Bp=n=>Math.round(n*1e5)/1e5,RS=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function qie(n){return n==null}const Yie=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,PS=(n,e)=>t=>!!(typeof t=="string"&&Yie.test(t)&&t.startsWith(n)||e&&!qie(t)&&Object.prototype.hasOwnProperty.call(t,e)),xD=(n,e,t)=>s=>{if(typeof s!="string")return s;const[r,i,a,l]=s.match(RS);return{[n]:parseFloat(r),[e]:parseFloat(i),[t]:parseFloat(a),alpha:l!==void 0?parseFloat(l):1}},Qie=n=>tl(0,255,n),Wv={...Nf,transform:n=>Math.round(Qie(n))},td={test:PS("rgb","red"),parse:xD("red","green","blue"),transform:({red:n,green:e,blue:t,alpha:s=1})=>"rgba("+Wv.transform(n)+", "+Wv.transform(e)+", "+Wv.transform(t)+", "+Bp(Em.transform(s))+")"};function Xie(n){let e="",t="",s="",r="";return n.length>5?(e=n.substring(1,3),t=n.substring(3,5),s=n.substring(5,7),r=n.substring(7,9)):(e=n.substring(1,2),t=n.substring(2,3),s=n.substring(3,4),r=n.substring(4,5),e+=e,t+=t,s+=s,r+=r),{red:parseInt(e,16),green:parseInt(t,16),blue:parseInt(s,16),alpha:r?parseInt(r,16)/255:1}}const Sw={test:PS("#"),parse:Xie,transform:td.transform},Wm=n=>({test:e=>typeof e=="string"&&e.endsWith(n)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${n}`}),Il=Wm("deg"),Ko=Wm("%"),ht=Wm("px"),Jie=Wm("vh"),Zie=Wm("vw"),zI={...Ko,parse:n=>Ko.parse(n)/100,transform:n=>Ko.transform(n*100)},kh={test:PS("hsl","hue"),parse:xD("hue","saturation","lightness"),transform:({hue:n,saturation:e,lightness:t,alpha:s=1})=>"hsla("+Math.round(n)+", "+Ko.transform(Bp(e))+", "+Ko.transform(Bp(t))+", "+Bp(Em.transform(s))+")"},Rs={test:n=>td.test(n)||Sw.test(n)||kh.test(n),parse:n=>td.test(n)?td.parse(n):kh.test(n)?kh.parse(n):Sw.parse(n),transform:n=>typeof n=="string"?n:n.hasOwnProperty("red")?td.transform(n):kh.transform(n),getAnimatableNone:n=>{const e=Rs.parse(n);return e.alpha=0,Rs.transform(e)}},eae=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function tae(n){return isNaN(n)&&typeof n=="string"&&(n.match(RS)?.length||0)+(n.match(eae)?.length||0)>0}const yD="number",vD="color",nae="var",sae="var(",$I="${}",rae=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function lf(n){const e=n.toString(),t=[],s={color:[],number:[],var:[]},r=[];let i=0;const l=e.replace(rae,c=>(Rs.test(c)?(s.color.push(i),r.push(vD),t.push(Rs.parse(c))):c.startsWith(sae)?(s.var.push(i),r.push(nae),t.pu
137sh(c)):(s.number.push(i),r.push(yD),t.push(parseFloat(c))),++i,$I)).split($I);return{values:t,split:l,indexes:s,types:r}}function iae(n){return lf(n).values}function bD({split:n,types:e}){const t=n.length;return s=>{let r="";for(let i=0;i<t;i++)if(r+=n[i],s[i]!==void 0){const a=e[i];a===yD?r+=Bp(s[i]):a===vD?r+=Rs.transform(s[i]):r+=s[i]}return r}}function aae(n){return bD(lf(n))}const oae=n=>typeof n=="number"?0:Rs.test(n)?Rs.getAnimatableNone(n):n,lae=(n,e)=>typeof n=="number"?e?.trim().endsWith("/")?n:0:oae(n);function cae(n){const e=lf(n);return bD(e)(e.values.map((s,r)=>lae(s,e.split[r])))}const co={test:tae,parse:iae,createTransformer:aae,getAnimatableNone:cae};function Gv(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*(2/3-t)*6:n}function uae({hue:n,saturation:e,lightness:t,alpha:s}){n/=360,e/=100,t/=100;let r=0,i=0,a=0;if(!e)r=i=a=t;else{const l=t<.5?t*(1+e):t+e-t*e,c=2*t-l;r=Gv(c,l,n+1/3),i=Gv(c,l,n),a=Gv(c,l,n-1/3)}return{red:Math.round(r*255),green:Math.round(i*255),blue:
vendor: 4,208 bytes, line 137
137Math.round(a*255),alpha:s}}function G1(n,e){return t=>t>0?e:n}const Dn=(n,e,t)=>n+(e-n)*t,Kv=(n,e,t)=>{const s=n*n,r=t*(e*e-s)+s;return r<0?0:Math.sqrt(r)},dae=[Sw,td,kh],hae=n=>dae.find(e=>e.test(n));function HI(n){const e=hae(n);if(!e)return!1;let t=e.parse(n);return e===kh&&(t=uae(t)),t}const WI=(n,e)=>{const t=HI(n),s=HI(e);if(!t||!s)return G1(n,e);const r={...t};return i=>(r.red=Kv(t.red,s.red,i),r.green=Kv(t.green,s.green,i),r.blue=Kv(t.blue,s.blue,i),r.alpha=Dn(t.alpha,s.alpha,i),td.transform(r))},Ew=new Set(["none","hidden"]);function fae(n,e){return Ew.has(n)?t=>t<=0?n:e:t=>t>=1?e:n}function pae(n,e){return t=>Dn(n,e,t)}function NS(n){return typeof n=="number"?pae:typeof n=="string"?kS(n)?G1:Rs.test(n)?WI:xae:Array.isArray(n)?wD:typeof n=="object"?Rs.test(n)?WI:mae:G1}function wD(n,e){const t=[...n],s=t.length,r=n.map((i,a)=>NS(i)(i,e[a]));return i=>{for(let a=0;a<s;a++)t[a]=r[a](i);return t}}function mae(n,e){const t={...n,...e},s={};for(const r in t)n[r]!==void 0&&e[r]!==void 0&&(s[r]=NS(n[r])(n[r],e[r]));return r=>{for(const i in s)t[i]=s[i](r);return t}}function gae(n,e){const t=[],s={color:0,var:0,number:0};for(let r=0;r<e.values.length;r++){const i=e.types[r],a=n.indexes[i][s[i]],l=n.values[a]??0;t[r]=l,s[i]++}return t}const xae=(n,e)=>{const t=co.createTransformer(e),s=lf(n),r=lf(e);return s.indexes.var.length===r.indexes.var.length&&s.indexes.color.length===r.indexes.color.length&&s.indexes.number.length>=r.indexes.number.length?Ew.has(n)&&!r.values.length||Ew.has(e)&&!s.values.length?fae(n,e):$m(wD(gae(s,r),r.values),t):G1(n,e)};function SD(n,e,t){return typeof n=="number"&&typeof e=="number"&&typeof t=="number"?Dn(n,e,t):NS(n)(n,e)}const yae=n=>{const e=({timestamp:t})=>n(t);return{start:(t=!0)=>On.update(e,t),stop:()=>pu(e),now:()=>xr.isProcessing?xr.timestamp:ti.now()}},ED=(n,e,t=10)=>{let s="";const r=Math.max(Math.round(e/t),2);for(let i=0;i<r;i++)s+=Math.round(n(i/(r-1))*1e4)/1e4+", ";return`linear(${s.substring(0,s.length-2)})`},K1=2e4;function LS(n){let e=0;const t=50;let s=n.next(e);for(;!s.done&&e<K1;)e+=t,s=n.next(e);return e>=K1?1/0:e}function vae(n,e=100,t){const s=t({...n,keyframes:[0,e]}),r=Math.min(LS(s),K1);return{type:"keyframes",ease:i=>s.next(r*i).value/e,duration:Sa(r)}}const fs={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1};function Tw(n,e){return n*Math.sqrt(1-e*e)}const bae=12;function wae(n,e,t){let s=t;for(let r=1;r<bae;r++)s=s-n(s)/e(s);return s}const qv=.001;function Sae({duration:n=fs.duration,bounce:e=fs.bounce,velocity:t=fs.velocity,mass:s=fs.mass}){let r,i,a=1-e;a=tl(fs.minDamping,fs.maxDamping,a),n=tl(fs.minDuration,fs.maxDuration,Sa(n)),a<1?(r=d=>{const h=d*a,p=h*n,m=h-t,y=Tw(d,a),x=Math.exp(-p);return qv-m/y*x},i=d=>{const p=d*a*n,m=p*t+t,y=Math.pow(a,2)*Math.pow(d,2)*n,x=Math.exp(-p),w=Tw(Math.pow(d,2),a);return(-r(d)+qv>0?-1:1)*((m-y)*x)/w}):(r=d=>{const h=Math.exp(-d*n),p=(d-t)*n+1;return-qv+h*p},i=d=>{const h=Math.exp(-d*n),p=(t-d)*(n*n);return h*p});const l=5/n,c=wae(r,i,l);if(n=sa(n),isNaN(c))return{stiffness:fs.stiffness,damping:fs.damping,duration:n};{const d=Math.pow(c,2)*s;return{stiffness:d,damping:a*2*Math.sqrt(s*d),duration:n}}}const Eae=["duration","bounce"],Tae=["stiffness","damping","mass"];function GI(n,e){return e.some(t=>n[t]!==void 0)}function _ae(n){let e={velocity:fs.velocity,stiffness:fs.stiffness,damping:fs.damping,mass:fs.mass,isResolvedFromDuration:!1,...n};if(!GI(n,Tae)&&GI(n,Eae))if(e.velocity=0,n.visualDuration){const t=n.visualDuration,s=2*Math.PI/(t*1.2),r=s*s,i=2*tl(.05,1,1-(n.bounce||0))*Math.sqrt(r);e={...e,mass:fs.mass,stiffness:r,damping:i}}else{const t=Sae({...n,velocity:0});e={...e,...t,mass:fs.mass},e.isResolvedFromDuration=!0}return e}function q1(n=fs.visualDuration,e=fs.bounce){const t=typeof n!="object"?{visualDuration:n,keyframes:[0,1],bounce:e}:n;let{restSpeed:s,restDelta:r}=t;const i=t.keyframes[0],a=t.keyframes[t.keyframes.length-1],l={done:!1,value:i},{stiffness:c,damping:d,mass:h,duration:p,velocity:m,isResolvedFromDuration:y}=_ae({...t,velocity:-Sa(t.velocity||0)}
137),x=m||0,w=d/(2*Math.sqrt(c*h)),S=a-i,_=Sa(Math.sqrt(c/h)),L=Math.abs(S)<5;s||(s=L?fs.restSpeed.granular:fs.restSpeed.default),r||(r=L?fs.restDelta.granular:fs.restDelta.default);let R,M,V,W,I,k;if(w<1)V=Tw(_,w),W=(x+w*_*S)/V,R=N=>{const F=Math.exp(-w*_*N);return a-F*(W*Math.sin(V*N)+S*Math.cos(V*N))},I=w*_*W+S*V,k=w*_*S-W*V,M=N=>Math.exp(-w*_*N)*(I*Math.sin(V*N)+k*Math.cos(V*N));else if(w===1){R=F=>a-Math.exp(-_*F)*(S+(x+_*S)*F);const N=x+_*S;M=F=>Math.exp(-_*F)*(_*N*F-x)}else{const N=_*Math.sqrt(w*w-1);R=fe=>{const oe=Math.exp(-w*_*fe),X=Math.min(N*fe,300);return a-oe*((x+w*_*S)*Math.sinh(X)+N*S*Math.cosh(X))/N};const F=(x+w*_*S)/N,z=w*_*F-S*N,U=w*_*S-F*N;M=fe=>{const oe=Math.exp(-w*_*fe),X=Math.min(N*fe,300);return oe*(z*Math.sinh(X)+U*Math.cosh(X))}}const P={calculatedDuration:y&&p||null,velocity:N=>sa(M(N)),next:N=>{if(!y&&w<1){const z=Math.exp(-w*_*N),U=Math.sin(V*N),fe=Math.cos(V*N),oe=a-z*(W*U+S*fe),X=sa(z*(I*U+k*fe));return l.done=Math.abs(X)<=s&&Math.abs(a-oe)<=r,l.value=l.done?a:oe,l}const F=R(N);if(y)l.done=N>=p;else{const z=sa(M(N));l.done=Math.abs(z)<=s&&Math.abs(a-F)<=r}return l.value=l.done?a:F,l},toString:()=>{const N=Math.min(LS(P),K1),F=ED(z=>P.next(N*z).value,N,30);return N+"ms "+F},toTransition:()=>{}};return P}q1.applyToOptions=n=>{const e=vae(n,100,q1);return n.ease=e.ease,n.duration=sa(e.duration),n.type="keyframes",n};const Iae=5;function TD(n,e,t){const s=Math.max(e-Iae,0);return sD(t-n(s),e-s)}function _w({keyframes:n,velocity:e=0,power:t=.8,timeConstant:s=325,bounceDamping:r=10,bounceStiffness:i=500,modifyTarget:a,min:l,max:c,restDelta:d=.5,restSpeed:h}){const p=n[0],m={done:!1,value:p},y=k=>l!==void 0&&k<l||c!==void 0&&k>c,x=k=>l===void 0?c:c===void 0||Math.abs(l-k)<Math.abs(c-k)?l:c;let w=t*e;const S=p+w,_=a===void 0?S:a(S);_!==S&&(w=_-p);const L=k=>-w*Math.exp(-k/s),R=k=>_+L(k),M=k=>{const P=L(k),N=R(k);m.done=Math.abs(P)<=d,m.value=m.done?_:N};let V,W;const I=k=>{y(m.value)&&(V=k,W=q1({keyframes:[m.value,x(m.value)],velocity:TD(R,k,m.value),damping:r,stiffness:i,restDelta:d,restSpeed:h}))};return I(0),{calculatedDuration:null,next:k=>{let P=!1;return!W&&V===void 0&&(P=!0,M(k),I(k)),V!==void 0&&k>=V?W.next(k-V):(!P&&M(k),m)}}}function Aae(n,e,t){const s=[],r=t||fu.mix||SD,i=n.length-1;for(let a=0;a<i;a++){let l=r(n[a],n[a+1]);if(e){const c=Array.isArray(e)?e[a]||Ta:e;l=$m(c,l)}s.push(l)}return s}function Cae(n,e,{clamp:t=!0,ease:s,mixer:r}={}){const i=n.length;if(_S(i===e.length),i===1)return()=>e[0];if(i===2&&e[0]===e[1])return()=>e[1];const a=n[0]===n[1];n[0]>n[i-1]&&(n=[...n].reverse(),e=[...e].reverse());const l=Aae(e,s,r),c=l.length,d=h=>{if(a&&h<n[0])return e[0];let p=0;if(c>1)for(;p<n.length-2&&!(h<n[p+1]);p++);const m=Sm(n[p],n[p+1],h);return l[p](m)};return t?h=>d(tl(n[0],n[i-1],h)):d}function kae(n,e){const t=n[n.length-1];for(let s=1;s<=e;s++){const r=Sm(0,e,s);n.push(Dn(t,1,r))}}function Rae(n){const e=[0];return kae(e,n.length-1),e}function Pae(n,e){return n.map(t=>t*e)}function Nae(n,e){return n.map(()=>e||hD).splice(0,n.length-1)}function zp({duration:n=300,keyframes:e,times:t,ease:s="easeInOut"}){const r=Vie(s)?s.map(VI):VI(s),i={done:!1,value:e[0]},a=Pae(t&&t.length===e.length?t:Rae(e),n),l=Cae(a,e,{ease:Array.isArray(r)?r:Nae(e,r)});return{calculatedDuration:n,next:c=>(i.value=l(c),i.done=c>=n,i)}}const Lae=n=>n!==null;function dy(n,{repeat:e,repeatType:t="loop"},s,r=1){const i=n.filter(Lae),l=r<0||e&&t!=="loop"&&e%2===1?0:i.length-1;return!l||s===void 0?i[l]:s}const Dae={decay:_w,inertia:_w,tween:zp,keyframes:zp,spring:q1};function _D(n){typeof n.type=="string"&&(n.type=Dae[n.type])}class DS{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,t){return this.finished.then(e,t)}}const jae=n=>n/100;class Y1 extends DS{constructor(e){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{const{motionValue:t}=this.options;t&&t.updatedAt!==ti.now()&&this.tick(ti.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){const{options:e}=this;_D(e);const{type:t=zp,repeat:s=0,repeatDelay:r=0,repeatType:i,velocity:a=0}=e;let{keyframes:l}=e;const c=t||zp;c!==zp&&typeof l[0]!="number"&&(this.mixKeyframes=$m(jae,SD(l[0],l[1])),l=[0,100]);const d=c({...e,keyframes:l});i==="mirror"&&(this.mirroredGenerator=c({...e,keyframes:[...l].reverse(),velocity:-a})),d.calculatedDuration===null&&(d.calculatedDuration=LS(d));const{calculatedDuration:h}=d;this.calculatedDuration=h,this.resolvedDuration=h+r,this.totalDuration=this.resolvedDuration*(s+1)-r,this.generator=d}updateTime(e){const t=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=t}tick(e,t=!1){const{generator:s,totalDuration:r,mixKeyframes:i,mirroredGenerator:a,resolvedDuration:l,calculatedDuration:c}=this;if(this.startTime===null)return s.next(0);const{delay:d=0,keyframes:h,repeat:p,repeatType:m,repeatDelay:y,type:x,onUp
137date:w,finalKeyframe:S}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-r/this.speed,this.startTime)),t?this.currentTime=e:this.updateTime(e);const _=this.currentTime-d*(this.playbackSpeed>=0?1:-1),L=this.playbackSpeed>=0?_<0:_>r;this.currentTime=Math.max(_,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=r);let R=this.currentTime,M=s;if(p){const k=Math.min(this.currentTime,r)/l;let P=Math.floor(k),N=k%1;!N&&k>=1&&(N=1),N===1&&P--,P=Math.min(P,p+1),P%2&&(m==="reverse"?(N=1-N,y&&(N-=y/l)):m==="mirror"&&(M=a)),R=tl(0,1,N)*l}let V;L?(this.delayState.value=h[0],V=this.delayState):V=M.next(R),i&&!L&&(V.value=i(V.value));let{done:W}=V;!L&&c!==null&&(W=this.playbackSpeed>=0?this.currentTime>=r:this.currentTime<=0);const I=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&W);return I&&x!==_w&&(V.value=dy(h,this.options,S,this.speed)),w&&w(V.value),I&&this.finish(),V}then(e,t){return this.finished.then(e,t)}get duration(){return Sa(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+Sa(e)}get time(){return Sa(this.currentTime)}set time(e){e=sa(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state="paused",this.holdTime=e,this.tick(e))}getGeneratorVelocity(){const e=this.currentTime;if(e<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(e);const t=this.generator.next(e).value;return TD(s=>this.generator.next(s).value,e,t)}get speed(){return this.playbackSpeed}set speed(e){const t=this.playbackSpeed!==e;t&&this.driver&&this.updateTime(ti.now()),this.playbackSpeed=e,t&&this.driver&&(this.time=Sa(this.currentTime))}play(){if(this.isStopped)return;const{driver:e=yae,startTime:t}=this.options;this.driver||(this.driver=e(r=>this.tick(r))),this.options.onPlay?.();const s=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=s):this.holdTime!==null?this.startTime=s-this.holdTime:this.startTime||(this.startTime=t??s),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(ti.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state="finished",this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),e.observe(this)}}function Oae(n){for(let e=1;e<n.length;e++)n[e]??(n[e]=n[e-1])}const nd=n=>n*180/Math.PI,Iw=n=>{const e=nd(Math.atan2(n[1],n[0]));return Aw(e)},Mae={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:n=>(Math.abs(n[0])+Math.abs(n[3]))/2,rotate:Iw,rotateZ:Iw,skewX:n=>nd(Math.atan(n[1])),skewY:n=>nd(Math.atan(n[2])),skew:n=>(Math.abs(n[1])+Math.abs(n[2]))/2},Aw=n=>(n=n%360,n<0&&(n+=360),n),KI=Iw,qI=n=>Math.sqrt(n[0]*n[0]+n[1]*n[1]),YI=n=>Math.sqrt(n[4]*n[4]+n[5]*n[5]),Fae={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:qI,scaleY:YI,scale:n=>(qI(n)+YI(n))/2,rotateX:n=>Aw(nd(Math.atan2(n[6],n[5]))),rotateY:n=>Aw(nd(Math.atan2(-n[2],n[0]))),rotateZ:KI,rotate:KI,skewX:n=>nd(Math.atan(n[4])),skewY:n=>nd(Math.atan(n[1])),skew:n=>(Math.abs(n[1])+Math.abs(n[4]))/2};function Cw(n){return n.includes("scale")?1:0}function kw(n,e){if(!n||n==="none")return Cw(e);const t=n.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,r;if(t)s=Fae,r=t;else{const l=n.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=Mae,r=l}if(!r)return Cw(e);const i=s[e],a=r[1].split(",").map(Vae);return typeof i=="function"?i(a):a[i]}const Uae=(n,e)=>{const{transform:t="none"}=getComputedStyle(n);return kw(t,e)};function Vae(n){return parseFloat(n.trim())}const Lf=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Df=new Set([...Lf,"pathRotation"]),QI=n=>n===Nf||n===ht,Bae=new Set(["x","y","z"]),zae=Lf.filter(n=>!Bae.has(n));function $ae(n){const e=[];return zae.forEach(t=>{const s=n.getValue(t);s!==void 0&&(e.push([t,s.get()]),s.set(t.startsWith("scale")?1:0))}),e}const Mc={width:({x:n},{paddingLeft:e="0",paddingRight:t="0",boxSizing:s})=>{const r=n.max-n.min;return s==="border-box"?r:r-parseFloat(e)-parseFloat(t)},height:({y:n},{paddingTop:e="0",paddingBottom:t="0",boxSizing:s})=>{const r=n.max-n.min;return s==="border-box"?r:r-parseFloat(e)-parseFloat(t)},top:(n,{top:e})=>parseFloat(e),left:(n,{left:e})=>parseFloat(e),bottom:({y:n},{top:e})=>parseFloat(e)+(n.max-n.min),right:({x:n},{left:e})=>parseFloat(e)+(n.max-n.min),x:(n,{transform:e})=>kw(e,"x"),y:(n,{transform:e})=>kw(e,"y")};Mc.translateX=Mc.x;Mc.translateY=Mc.y;const hd=new Set;let Rw=!1,Pw=!1,Nw=!1;function ID(){if(Pw){const n=Array.from(hd).filter(s=>s.needsMeasurement),e=new Set(n.map(s=>s.element)),t=new Map;e.forEach(s=>{const r=$ae(s);r.length&&(t.set(s,r),s.render())}
vendor: 1,667 bytes, line 137
137),n.forEach(s=>s.measureInitialState()),e.forEach(s=>{s.render();const r=t.get(s);r&&r.forEach(([i,a])=>{s.getValue(i)?.set(a)})}),n.forEach(s=>s.measureEndState()),n.forEach(s=>{s.suspendedScrollY!==void 0&&window.scrollTo(0,s.suspendedScrollY)})}Pw=!1,Rw=!1,hd.forEach(n=>n.complete(Nw)),hd.clear()}function AD(){hd.forEach(n=>{n.readKeyframes(),n.needsMeasurement&&(Pw=!0)})}function Hae(){Nw=!0,AD(),ID(),Nw=!1}class jS{constructor(e,t,s,r,i,a=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=t,this.name=s,this.motionValue=r,this.element=i,this.isAsync=a}scheduleResolve(){this.state="scheduled",this.isAsync?(hd.add(this),Rw||(Rw=!0,On.read(AD),On.resolveKeyframes(ID))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:t,element:s,motionValue:r}=this;if(e[0]===null){const i=r?.get(),a=e[e.length-1];if(i!==void 0)e[0]=i;else if(s&&t){const l=s.readValue(t,a);l!=null&&(e[0]=l)}e[0]===void 0&&(e[0]=a),r&&i===void 0&&r.set(e[0])}Oae(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),hd.delete(this)}cancel(){this.state==="scheduled"&&(hd.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const Wae=n=>n.startsWith("--");function CD(n,e,t){Wae(e)?n.style.setProperty(e,t):n.style[e]=t}const Gae={};function kD(n,e){const t=nD(n);return()=>Gae[e]??t()}const Kae=kD(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),RD=kD(()=>{try{document.createElement("div").animate({opacity:0}
137,{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),Sp=([n,e,t,s])=>`cubic-bezier(${n}, ${e}, ${t}, ${s})`,XI={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:Sp([0,.65,.55,1]),circOut:Sp([.55,0,1,.45]),backIn:Sp([.31,.01,.66,-.59]),backOut:Sp([.33,1.53,.69,.99])};function PD(n,e){if(n)return typeof n=="function"?RD()?ED(n,e):"ease-out":fD(n)?Sp(n):Array.isArray(n)?n.map(t=>PD(t,e)||XI.easeOut):XI[n]}function qae(n,e,t,{delay:s=0,duration:r=300,repeat:i=0,repeatType:a="loop",ease:l="easeOut",times:c}={},d=void 0){const h={[e]:t};c&&(h.offset=c);const p=PD(l,r);Array.isArray(p)&&(h.easing=p);const m={delay:s,duration:r,easing:Array.isArray(p)?"linear":p,fill:"both",iterations:i+1,direction:a==="reverse"?"alternate":"normal"};return d&&(m.pseudoElement=d),n.animate(h,m)}function ND(n){return typeof n=="function"&&"applyToOptions"in n}function Yae({type:n,...e}){return ND(n)&&RD()?n.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class LD extends DS{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!e)return;const{element:t,name:s,keyframes:r,pseudoElement:i,allowFlatten:a=!1,finalKeyframe:l,onComplete:c}=e;this.isPseudoElement=!!i,this.allowFlatten=a,this.options=e,_S(typeof e.type!="string");const d=Yae(e);this.animation=qae(t,s,r,d,i),d.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!i){const h=dy(r,this.options,l,this.speed);this.updateMotionValue&&this.updateMotionValue(h),CD(t,s,h),this.animation.cancel()}c?.(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:e}=this;e==="idle"||e==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){const e=this.options?.element;!this.isPseudoElement&&e?.isConnected&&this.animation.commitStyles?.()}get duration(){const e=this.animation.effect?.getComputedTiming?.().duration||0;return Sa(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+Sa(e)}get time(){return Sa(Number(this.animation.currentTime)||0)}set time(e){const t=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=sa(e),t&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(e){this.manualStartTime=this.animation.startTime=e}attachTimeline({timeline:e,rangeStart:t,rangeEnd:s,observe:r}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,e&&Kae()?(this.animation.timeline=e,t&&(this.animation.rangeStart=t),s&&(this.animation.rangeEnd=s),Ta):r(this)}}const DD={anticipate:cD,backInOut:lD,circInOut:dD};function Qae(n){return n in DD}function Xae(n){typeof n.ease=="string"&&Qae(n.ease)&&(n.ease=DD[n.ease])}const Yv=10;class Jae extends LD{constructor(e){Xae(e),_D(e),super(e),e.startTime!==void 0&&e.autoplay!==!1&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){const{motionValue:t,onUpdate:s,onComplete:r,element:i,...a}=this.options;if(!t)return;if(e!==void 0){t.set(e);return}const l=new Y1({...a,autoplay:!1}),c=Math.max(Yv,ti.now()-this.startTime),d=tl(0,Yv,c-Yv),h=l.sample(c).value,{name:p}=this.options;i&&p&&CD(i,p,h),t.setWithVelocity(l.sample(Math.max(0,c-d)).value,h,d),l.stop()}}const JI=(n,e)=>e==="zIndex"?!1:!!(typeof n=="number"||Array.isArray(n)||typeof n=="string"&&(co.test(n)||n==="0")&&!n.startsWith("url("));function Zae(n){const e=n[0];if(n.length===1)return!0;for(let t=0;t<n.length;t++)if(n[t]!==e)return!0}function eoe(n,e,t,s){const r=n[0];if(r===null)return!1;if(e==="display"||e==="visibility")return!0;const i=n[n.length-1],a=JI(r,e),l=JI(i,e);return!a||!l?!1:Zae(n)||(t==="spring"||ND(t))&&s}function Lw(n){n.duration=0,n.type="keyframes"}const jD=new Set(["opacity","clipPath","filter","transform"]),toe=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function noe(n){for(let e=0;e<n.length;e++)if(typeof n[e]=="string"&&toe.test(n[e]))return!0;return!1}const soe=new Set(["color","backgroundColor","outlineColor","fill","stroke","borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor"]),roe=nD(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function ioe(n){const{motionValue:e,name:t,repeatDelay:s,repeatType:r,damping:i,type:a,keyframes:l}=n;if(!(e?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:d,transformTemplate:h}=e.owner.getProps();return roe()&&t&&(jD.has(t)||soe.has(t)&&noe(l))&&(t!=="transform"||!h)&&!d&&!s&&r!=="mirror"&&i!==0&&a!=="inertia"}const aoe=40;class ooe extends DS{constructor({autoplay:e=!0,delay:t=0,type:s="
137keyframes",repeat:r=0,repeatDelay:i=0,repeatType:a="loop",keyframes:l,name:c,motionValue:d,element:h,...p}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=ti.now();const m={autoplay:e,delay:t,type:s,repeat:r,repeatDelay:i,repeatType:a,name:c,motionValue:d,element:h,...p},y=h?.KeyframeResolver||jS;this.keyframeResolver=new y(l,(x,w,S)=>this.onKeyframesResolved(x,w,m,!S),c,d,h),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,t,s,r){this.keyframeResolver=void 0;const{name:i,type:a,velocity:l,delay:c,isHandoff:d,onUpdate:h}=s;this.resolvedAt=ti.now();let p=!0;eoe(e,i,a,l)||(p=!1,(fu.instantAnimations||!c)&&h?.(dy(e,s,t)),e[0]=e[e.length-1],Lw(s),s.repeat=0);const y={startTime:r?this.resolvedAt?this.resolvedAt-this.createdAt>aoe?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:t,...s,keyframes:e},x=p&&!d&&ioe(y),w=y.motionValue?.owner?.current;let S;if(x)try{S=new Jae({...y,element:w})}catch{S=new Y1(y)}else S=new Y1(y);S.finished.then(()=>{this.notifyFinished()}).catch(Ta),this.pendingTimeline&&(this.stopTimeline=S.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=S}get finished(){return this._animation?this.animation.finished:this._finished}then(e,t){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),Hae()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}}function OD(n,e,t,s=0,r=1){const i=Array.from(n).sort((d,h)=>d.sortNodePosition(h)).indexOf(e),a=n.size,l=(a-1)*s;return typeof t=="function"?t(i,a):r===1?i*s:l-i*s}const ZI=30,loe=n=>!isNaN(parseFloat(n));class coe{constructor(e,t={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=s=>{const r=ti.now();if(this.updatedAt!==r&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(s),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(const i of this.dependents)i.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=t.owner}setCurrent(e){this.current=e,this.updatedAt=ti.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=loe(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on("change",e)}on(e,t){this.events[e]||(this.events[e]=new IS);const s=this.events[e].add(t);return e==="change"?()=>{s(),On.read(()=>{this.events.change.getSize()||this.stop()})}:s}clearListeners(){for(const e in this.events)this.events[e].clear()}attach(e,t){this.passiveEffect=e,this.stopPassiveEffect=t}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,t,s){this.set(t),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-s}jump(e,t=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,t&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(e){this.dependents||(this.dependents=new Set),this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const e=ti.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>ZI)return 0;const t=Math.min(this.updatedAt-this.prevUpdatedAt,ZI);return sD(parseFloat(this.current)-parseFloat(this.prevFrameValue),t)}start(e){return this.stop(),new Promise(t=>{this.hasAnimated=!0,this.animation=e(t),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function cf(n,e){return new coe(n,e)}function MD(n,e){if(n?.inherit&&e){const{inherit:t,...s}=n;return{...e,...s}}return n}function OS(n,e){const t=n?.[e]??n?.default??n;return t!==n?MD(t,n):t}const uoe={type:"spring",stiffness:500,damping:25,restSpeed:10},doe=n=>({type:"spring",stiffness:550,damping:n===0?2*Math.sqrt(550):30,restSpeed:10}),hoe={type:"keyframes",duration:.8},foe={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},poe=(n,{keyframes:e})=>e.length>2?hoe:Df.has(n)?n.startsWith("scale")?doe(e[1]):uoe:foe,moe=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function goe(n){for(const e in n)if(!moe.has(e))return!0;return!1}const MS=(n,e,t,s={},r,i)=>a=>{const l=OS(s,n)||{},c=l.delay||s.delay||0;let{elapsed:d=0}=s;d=d-sa(c);const h={keyframes:Array.isArray(t)?t:[null,t],ease:"easeOut",velocity:e.getVelocity(),...l,delay:-d,onUpdate:m=>{e.set(m),l.onUpdate&&l.onUpdate(m)},onComplete:()=>{a(),l.onComplete&&l.onComplete()},name:n,motionValue:e,element:i?void 0:r};goe(l)||Object.assign(h,poe(n,h)),h.duration&&(h.duration=sa(h.duration)),h.repeatDelay&&(h.repeatDelay=sa(h.repeatDelay)),h.from!==void 0&&(h.keyframes[0]=h.from);let p=!1;if((h.type===!1||h.duration===0&&!h.repeatDelay)&&(Lw(h),h.delay===0&&(p=!0)),(fu.instantAnimations||fu.skipAnimations||r?.shouldSkipAnimations||l.skipAnimations)&&(p=!0,Lw(h),h.delay=0),h.allowFlatten=!l.type&&!l.ease,p&&!i&&e.get()!==void 0){const m=dy(h.keyframes,l);if(m!==void 0){On.update(()=>{h.onUpdate(m),h.onComplete()});return}}return l.isSync?new Y1(h):new ooe(h)},xoe=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function yoe(n){const e=xoe.exec(n);if(!e)return[,];const[,t,s,r]=e;return[`--${t??s}`,r]}function FD(n,e,t=1){const[s,r]=yoe(n);if(!s)return;const i=window.getComputedStyle(e).getPropertyValue(s);if(i){const a=i.trim();return ZL(a)?parseFloat(a):a}return kS(r)?FD(r,e,t+1):r}function eA(n){const e=[{},{}];
137return n?.values.forEach((t,s)=>{e[0][s]=t.get(),e[1][s]=t.getVelocity()}),e}function FS(n,e,t,s){if(typeof e=="function"){const[r,i]=eA(s);e=e(t!==void 0?t:n.custom,r,i)}if(typeof e=="string"&&(e=n.variants&&n.variants[e]),typeof e=="function"){const[r,i]=eA(s);e=e(t!==void 0?t:n.custom,r,i)}return e}function fd(n,e,t){const s=n.getProps();return FS(s,e,t!==void 0?t:s.custom,n)}const UD=new Set(["width","height","top","left","right","bottom",...Lf]),Dw=n=>Array.isArray(n);function voe(n,e,t){n.hasValue(e)?n.getValue(e).set(t):n.addValue(e,cf(t))}function boe(n){return Dw(n)?n[n.length-1]||0:n}function woe(n,e){const t=fd(n,e);let{transitionEnd:s={},transition:r={},...i}=t||{};i={...i,...s};for(const a in i){const l=boe(i[a]);voe(n,a,l)}}const br=n=>!!(n&&n.getVelocity);function Soe(n){return!!(br(n)&&n.add)}function jw(n,e){const t=n.getValue("willChange");if(Soe(t))return t.add(e);if(!t&&fu.WillChange){const s=new fu.WillChange("auto");n.addValue("willChange",s),s.add(e)}}function US(n){return n.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}const Eoe="framerAppearId",VD="data-"+US(Eoe);function BD(n){return n.props[VD]}function Toe({protectedKeys:n,needsAnimating:e},t){const s=n.hasOwnProperty(t)&&e[t]!==!0;return e[t]=!1,s}function zD(n,e,{delay:t=0,transitionOverride:s,type:r}={}){let{transition:i,transitionEnd:a,...l}=e;const c=n.getDefaultTransition();i=i?MD(i,c):c;const d=i?.reduceMotion,h=i?.skipAnimations;s&&(i=s);const p=[],m=r&&n.animationState&&n.animationState.getState()[r],y=i?.path;y&&y.animateVisualElement(n,l,i,t,p);for(const x in l){const w=n.getValue(x,n.latestValues[x]??null),S=l[x];if(S===void 0||m&&Toe(m,x))continue;const _={delay:t,...OS(i||{},x)};h&&(_.skipAnimations=!0);const L=w.get();if(L!==void 0&&!w.isAnimating()&&!Array.isArray(S)&&S===L&&!_.velocity){On.update(()=>w.set(S));continue}let R=!1;if(window.MotionHandoffAnimation){const W=BD(n);if(W){const I=window.MotionHandoffAnimation(W,x,On);I!==null&&(_.startTime=I,R=!0)}}jw(n,x);const M=d??n.shouldReduceMotion;w.start(MS(x,w,S,M&&UD.has(x)?{type:!1}:_,n,R));const V=w.animation;V&&p.push(V)}if(a){const x=()=>On.update(()=>{a&&woe(n,a)});p.length?Promise.all(p).then(x):x()}return p}function Ow(n,e,t={}){const s=fd(n,e,t.type==="exit"?n.presenceContext?.custom:void 0);let{transition:r=n.getDefaultTransition()||{}}=s||{};t.transitionOverride&&(r=t.transitionOverride);const i=s?()=>Promise.all(zD(n,s,t)):()=>Promise.resolve(),a=n.variantChildren&&n.variantChildren.size?(c=0)=>{const{delayChildren:d=0,staggerChildren:h,staggerDirection:p}=r;return _oe(n,e,c,d,h,p,t)}:()=>Promise.resolve(),{when:l}=r;if(l){const[c,d]=l==="beforeChildren"?[i,a]:[a,i];return c().then(()=>d())}else return Promise.all([i(),a(t.delay)])}function _oe(n,e,t=0,s=0,r=0,i=1,a){const l=[];for(const c of n.variantChildren)c.notify("AnimationStart",e),l.push(Ow(c,e,{...a,delay:t+(typeof s=="function"?0:s)+OD(n.variantChildren,c,s,r,i)}).then(()=>c.notify("AnimationComplete",e)));return Promise.all(l)}function Ioe(n,e,t={}){n.notify("AnimationStart",e);let s;if(Array.isArray(e)){const r=e.map(i=>Ow(n,i,t));s=Promise.all(r)}else if(typeof e=="string")s=Ow(n,e,t);else{const r=typeof e=="function"?fd(n,e,t.custom):e;s=Promise.all(zD(n,r,t))}return s.then(()=>{n.notify("AnimationComplete",e)})}const Aoe={test:n=>n==="auto",parse:n=>n},$D=n=>e=>e.test(n),HD=[Nf,ht,Ko,Il,Zie,Jie,Aoe],tA=n=>HD.find($D(n));function Coe(n){return typeof n=="number"?n===0:n!==null?n==="none"||n==="0"||tD(n):!0}const koe=new Set(["brightness","contrast","saturate","opacity"]);function Roe(n){const[e,t]=n.slice(0,-1).split("(");if(e==="drop-shadow")return n;const[s]=t.match(RS)||[];if(!s)return n;const r=t.replace(s,"");let i=koe.has(e)?1:0;return s!==t&&(i*=100),e+"("+i+r+")"}const Poe=/\b([a-z-]*)\(.*?\)/gu,Mw={...co,getAnimatableNone:n=>{const e=n.match(Poe);return e?e.map(Roe).join(" "):n}},Fw={...co,getAnimatableNone:n=>{const e=co.parse(n);return co.createTransformer(n)(e.map(s=>typeof s=="number"?0:typeof s=="object"?{...s,alpha:1}:s))}},nA={...Nf,transform:Math.round},Noe={rotate:Il,pathRotation:Il,rotateX:Il,rotateY:Il,rotateZ:Il,scale:m0,scaleX:m0,scaleY:m0,scaleZ:m0,skew:Il,skewX:Il,skewY:Il,distance:ht,translateX:ht,translateY:ht,translateZ:ht,x:ht,y:ht,z:ht,perspective:ht,transformPerspective:ht,opacity:Em,originX:zI,originY:zI,originZ:ht},Q1={borderWidth:ht,borderTopWidth:ht,borderRightWidth:ht,borderBottomWidth:ht,borderLeftWidth:ht,borderRadius:ht,borderTopLeftRadius:ht,borderTopRightRadius:ht,borderBottomRightRadius:ht,borderBottomLeftRadius:ht,width:ht,maxWidth:ht,height:ht,maxHeight:ht,top:ht,right:ht,bottom:ht,left:ht,inset:ht,insetBlock:ht,insetBlockStart:ht,insetBlockEnd:ht,insetInline:ht,insetInlineStart:ht,insetInlineEnd:ht,padding:ht,paddingTop:ht,paddingRight:ht,paddingBottom:ht,paddingLeft:ht,paddingBlock:ht,paddingBlockStart:ht,paddingBlockEnd:ht,paddingInline:ht,paddingInlineStart:ht,paddingInlineEnd:ht,margin:ht,marginTop:ht,marginRight:ht,marginBottom:ht,marginLeft:ht,marginBlock:ht,marginBlockStart:ht,marginBlockEnd:ht,marginInline:ht,marginInlineStart:ht,marginInlineEnd:ht,fontSize:ht,backgroundPositionX:ht,backgroundPositionY:ht,...Noe,zIndex:nA,fillOpacity:Em,strokeOpacity:Em,numOctaves:nA},Loe={...Q1,color:Rs,backgroundColor:Rs,outlineColor:Rs,fill:Rs,stroke:
vendor: 1,989 bytes, line 137
137Rs,borderColor:Rs,borderTopColor:Rs,borderRightColor:Rs,borderBottomColor:Rs,borderLeftColor:Rs,filter:Mw,WebkitFilter:Mw,mask:Fw,WebkitMask:Fw},WD=n=>Loe[n],Doe=new Set([Mw,Fw]);function GD(n,e){let t=WD(n);return Doe.has(t)||(t=co),t.getAnimatableNone?t.getAnimatableNone(e):void 0}const joe=new Set(["auto","none","0"]);function Ooe(n,e,t){let s=0,r;for(;s<n.length&&!r;){const i=n[s];typeof i=="string"&&!joe.has(i)&&lf(i).values.length&&(r=n[s]),s++}if(r&&t)for(const i of e)n[i]=GD(t,r)}class Moe extends jS{constructor(e,t,s,r,i){super(e,t,s,r,i,!0)}readKeyframes(){const{unresolvedKeyframes:e,element:t,name:s}=this;if(!t||!t.current)return;super.readKeyframes();for(let h=0;h<e.length;h++){let p=e[h];if(typeof p=="string"&&(p=p.trim(),kS(p))){const m=FD(p,t.current);m!==void 0&&(e[h]=m),h===e.length-1&&(this.finalKeyframe=p)}}if(this.resolveNoneKeyframes(),!UD.has(s)||e.length!==2)return;const[r,i]=e,a=tA(r),l=tA(i),c=BI(r),d=BI(i);if(c!==d&&Mc[s]){this.needsMeasurement=!0;return}if(a!==l)if(QI(a)&&QI(l))for(let h=0;h<e.length;h++){const p=e[h];typeof p=="string"&&(e[h]=parseFloat(p))}else Mc[s]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:t}=this,s=[];for(let r=0;r<e.length;r++)(e[r]===null||Coe(e[r]))&&s.push(r);s.length&&Ooe(e,s,t)}measureInitialState(){const{element:e,unresolvedKeyframes:t,name:s}=this;if(!e||!e.current)return;s==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Mc[s](e.measureViewportBox(),window.getComputedStyle(e.current)),t[0]=this.measuredOrigin;const r=t[t.length-1];r!==void 0&&e.getValue(s,r).jump(r,!1)}measureEndState(){const{element:e,name:t,unresolvedKeyframes:s}=this;if(!e||!e.current)return;const r=e.getValue(t);r&&r.jump(this.measuredOrigin,!1);const i=s.length-1,a=s[i];s[i]=Mc[t](e.measureViewportBox(),window.getComputedStyle(e.current)),a!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=a),this.removedTransforms?.length&&this.removedTransforms.forEac
137h(([l,c])=>{e.getValue(l).set(c)}),this.resolveNoneKeyframes()}}function KD(n,e,t){if(n==null)return[];if(n instanceof EventTarget)return[n];if(typeof n=="string"){let s=document;const r=t?.[n]??s.querySelectorAll(n);return r?Array.from(r):[]}return Array.from(n).filter(s=>s!=null)}const Uw=(n,e)=>e&&typeof n=="number"?e.transform(n):n;function Foe(n){return eD(n)&&"offsetHeight"in n&&!("ownerSVGElement"in n)}const{schedule:VS}=pD(queueMicrotask,!1),no={x:!1,y:!1};function qD(){return no.x||no.y}function Uoe(n){return n==="x"||n==="y"?no[n]?null:(no[n]=!0,()=>{no[n]=!1}):no.x||no.y?null:(no.x=no.y=!0,()=>{no.x=no.y=!1})}function YD(n,e){const t=KD(n),s=new AbortController,r={passive:!0,...e,signal:s.signal};return[t,r,()=>s.abort()]}function Voe(n){return!(n.pointerType==="touch"||qD())}function Boe(n,e,t={}){const[s,r,i]=YD(n,t);return s.forEach(a=>{let l=!1,c=!1,d;const h=()=>{a.removeEventListener("pointerleave",x)},p=S=>{d&&(d(S),d=void 0),h()},m=S=>{l=!1,window.removeEventListener("pointerup",m),window.removeEventListener("pointercancel",m),c&&(c=!1,p(S))},y=()=>{l=!0,window.addEventListener("pointerup",m,r),window.addEventListener("pointercancel",m,r)},x=S=>{if(S.pointerType!=="touch"){if(l){c=!0;return}p(S)}},w=S=>{if(!Voe(S))return;c=!1;const _=e(a,S);typeof _=="function"&&(d=_,a.addEventListener("pointerleave",x,r))};a.addEventListener("pointerenter",w,r),a.addEventListener("pointerdown",y,r)}),i}const QD=(n,e)=>e?n===e?!0:QD(n,e.parentElement):!1,BS=n=>n.pointerType==="mouse"?typeof n.button!="number"||n.button<=0:n.isPrimary!==!1,zoe=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function $oe(n){return zoe.has(n.tagName)||n.isContentEditable===!0}const Hoe=new Set(["INPUT","SELECT","TEXTAREA"]);function Woe(n){return Hoe.has(n.tagName)||n.isContentEditable===!0}const z0=new WeakSet;function sA(n){return e=>{e.key==="Enter"&&n(e)}}function Qv(n,e){n.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const Goe=(n,e)=>{const t=n.currentTarget;if(!t)return;const s=sA(()=>{if(z0.has(t))return;Qv(t,"down");const r=sA(()=>{Qv(t,"up")}),i=()=>Qv(t,"cancel");t.addEventListener("keyup",r,e),t.addEventListener("blur",i,e)});t.addEventListener("keydown",s,e),t.addEventListener("blur",()=>t.removeEventListener("keydown",s),e)};function rA(n){return BS(n)&&!qD()}const iA=new WeakSet;function Koe(n,e,t={}){const[s,r,i]=YD(n,t),a=l=>{const c=l.currentTarget;if(!rA(l)||iA.has(l))return;z0.add(c),t.stopPropagation&&iA.add(l);const d=e(c,l),h=(y,x)=>{window.removeEventListener("pointerup",p),window.removeEventListener("pointercancel",m),z0.has(c)&&z0.delete(c),rA(y)&&typeof d=="function"&&d(y,{success:x})},p=y=>{h(y,c===window||c===document||t.useGlobalTarget||QD(c,y.target))},m=y=>{h(y,!1)};window.addEventListener("pointerup",p,r),window.addEventListener("pointercancel",m,r)};return s.forEach(l=>{(t.useGlobalTarget?window:l).addEventListener("pointerdown",a,r),Foe(l)&&(l.addEventListener("focus",d=>Goe(d,r)),!$oe(l)&&!l.hasAttribute("tabindex")&&(l.tabIndex=0))}),i}function zS(n){return eD(n)&&"ownerSVGElement"in n}const $0=new WeakMap;let H0;const XD=(n,e,t)=>(s,r)=>r&&r[0]?r[0][n+"Size"]:zS(s)&&"getBBox"in s?s.getBBox()[e]:s[t],qoe=XD("inline","width","offsetWidth"),Yoe=XD("block","height","offsetHeight");function Qoe({target:n,borderBoxSize:e}){$0.get(n)?.forEach(t=>{t(n,{get width(){return qoe(n,e)},get height(){return Yoe(n,e)}})})}function Xoe(n){n.forEach(Qoe)}function Joe(){typeof ResizeObserver>"u"||(H0=new ResizeObserver(Xoe))}function Zoe(n,e){H0||Joe();const t=KD(n);return t.forEach(s=>{let r=$0.get(s);r||(r=new Set,$0.set(s,r)),r.add(e),H0?.observe(s)}),()=>{t.forEach(s=>{const r=$0.get(s);r?.delete(e),r?.size||H0?.unobserve(s)})}}const W0=new Set;let Rh;function ele(){Rh=()=>{const n={get width(){return window.innerWidth},get height(){return window.innerHeight}};
137W0.forEach(e=>e(n))},window.addEventListener("resize",Rh)}function tle(n){return W0.add(n),Rh||ele(),()=>{W0.delete(n),!W0.size&&typeof Rh=="function"&&(window.removeEventListener("resize",Rh),Rh=void 0)}}function aA(n,e){return typeof n=="function"?tle(n):Zoe(n,e)}function nle(n){return zS(n)&&n.tagName==="svg"}const sle=[...HD,Rs,co],rle=n=>sle.find($D(n)),oA=()=>({translate:0,scale:1,origin:0,originPoint:0}),Ph=()=>({x:oA(),y:oA()}),lA=()=>({min:0,max:0}),$s=()=>({x:lA(),y:lA()}),ile=new WeakMap;function hy(n){return n!==null&&typeof n=="object"&&typeof n.start=="function"}function Tm(n){return typeof n=="string"||Array.isArray(n)}const $S=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],HS=["initial",...$S];function fy(n){return hy(n.animate)||HS.some(e=>Tm(n[e]))}function JD(n){return!!(fy(n)||n.variants)}function ale(n,e,t){for(const s in e){const r=e[s],i=t[s];if(br(r))n.addValue(s,r);else if(br(i))n.addValue(s,cf(r,{owner:n}));else if(i!==r)if(n.hasValue(s)){const a=n.getValue(s);a.liveStyle===!0?a.jump(r):a.hasAnimated||a.set(r)}else{const a=n.getStaticValue(s);n.addValue(s,cf(a!==void 0?a:r,{owner:n}))}}for(const s in t)e[s]===void 0&&n.removeValue(s);return e}const X1={current:null},WS={current:!1},ole=typeof window<"u";function ZD(){if(WS.current=!0,!!ole)if(window.matchMedia){const n=window.matchMedia("(prefers-reduced-motion)"),e=()=>X1.current=n.matches;n.addEventListener("change",e),e()}else X1.current=!1}const cA=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let J1={};function ej(n){J1=n}function lle(){return J1}class cle{scrapeMotionValuesFromProps(e,t,s){return{}}constructor({parent:e,props:t,presenceContext:s,reducedMotionConfig:r,skipAnimations:i,blockInitialAnimation:a,visualState:l},c={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=jS,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const y=ti.now();this.renderScheduledAt<y&&(this.renderScheduledAt=y,On.render(this.render,!1,!0))};const{latestValues:d,renderState:h}=l;this.latestValues=d,this.baseTarget={...d},this.initialValues=t.initial?{...d}:{},this.renderState=h,this.parent=e,this.props=t,this.presenceContext=s,this.depth=e?e.depth+1:0,this.reducedMotionConfig=r,this.skipAnimationsConfig=i,this.options=c,this.blockInitialAnimation=!!a,this.isControllingVariants=fy(t),this.isVariantNode=JD(t),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:p,...m}=this.scrapeMotionValuesFromProps(t,{},this);for(const y in m){const x=m[y];d[y]!==void 0&&br(x)&&x.set(d[y])}}mount(e){if(this.hasBeenMounted)for(const t in this.initialValues)this.values.get(t)?.jump(this.initialValues[t]),this.latestValues[t]=this.initialValues[t];this.current=e,ile.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((t,s)=>this.bindToMotionValue(s,t)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(WS.current||ZD(),this.shouldReduceMotion=X1.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,this.parent?.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){this.projection&&this.projection.unmount(),pu(this.notifyUpdate),pu(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(const e in this.events)this.events[e].clear();for(const e in this.features){const t=this.features[e];t&&(t.unmount(),t.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,t){if(this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)(),t.accelerate&&jD.has(e)&&this.current instanceof HTMLElement){const{factory:a,keyframes:l,times:c,ease:d,duration:h}=t.accelerate,p=new LD({element:this.current,name:e,keyframes:l,times:c,ease:d,duration:sa(h)}),m=a(p);this.valueSubscriptions.set(e,()=>{m(),p.cancel()});return}const s=Df.has(e);s&&this.onBindTransform&&this.onBindTransform();const r=t.on("change",a=>{this.latestValues[e]=a,this.props.onUpdate&&On.preRender(this.notifyUpdate),s&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let i;typeof window<"u"&&window.MotionCheckAppearSync&&(i=window.MotionCheckAppearSync(this,e,t)),this.valueSubscriptions.set(e,()=>{r(),i&&i()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e="animation";
vendor: 5,898 bytes, line 137
137for(e in J1){const t=J1[e];if(!t)continue;const{isEnabled:s,Feature:r}=t;if(!this.features[e]&&r&&s(this.props)&&(this.features[e]=new r(this)),this.features[e]){const i=this.features[e];i.isMounted?i.update():(i.mount(),i.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):$s()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,t){this.latestValues[e]=t}update(e,t){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=t;for(let s=0;s<cA.length;s++){const r=cA[s];this.propEventSubscriptions[r]&&(this.propEventSubscriptions[r](),delete this.propEventSubscriptions[r]);const i="on"+r,a=e[i];a&&(this.propEventSubscriptions[r]=this.on(r,a))}this.prevMotionValues=ale(this,this.scrapeMotionValuesFromProps(e,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){const t=this.getClosestVariantNode();if(t)return t.variantChildren&&t.variantChildren.add(e),()=>t.variantChildren.delete(e)}addValue(e,t){const s=this.values.get(e);t!==s&&(s&&this.removeValue(e),this.bindToMotionValue(e,t),this.values.set(e,t),this.latestValues[e]=t.get())}removeValue(e){this.values.delete(e);const t=this.valueSubscriptions.get(e);t&&(t(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,t){if(this.props.values&&this.props.values[e])return this.props.values[e];let s=this.values.get(e);return s===void 0&&t!==void 0&&(s=cf(t===null?void 0:t,{owner:this}),this.addValue(e,s)),s}readValue(e,t){let s=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return s!=null&&(typeof s=="string"&&(ZL(s)||tD(s))?s=parseFloat(s):!rle(s)&&co.test(t)&&(s=GD(e,t)),this.setBaseTarget(e,br(s)?s.get():s)),br(s)?s.get():s}setBaseTarget(e,t){this.baseTarget[e]=t}getBaseTarget(e){const{initial:t}=this.props;let s;if(typeof t=="string"||typeof t=="object"){const i=FS(this.props,t,this.presenceContext?.custom);i&&(s=i[e])}if(t&&s!==void 0)return s;const r=this.getBaseTargetFromProps(this.props,e);return r!==void 0&&!br(r)?r:this.initialValues[e]!==void 0&&s===void 0?void 0:this.baseTarget[e]}on(e,t){return this.events[e]||(this.events[e]=new IS),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}scheduleRenderMicrotask(){VS.render(this.render)}}class tj extends cle{constructor(){super(...arguments),this.KeyframeResolver=Moe}sortInstanceNodePosition(e,t){return e.compareDocumentPosition(t)&2?1:-1}getBaseTargetFromProps(e,t){const s=e.style;return s?s[t]:void 0}removeValueFromRenderState(e,{vars:t,style:s}){delete t[e],delete s[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:e}=this.props;br(e)&&(this.childSubscription=e.on("change",t=>{this.current&&(this.current.textContent=`${t}`)}))}}class bu{constructor(e){this.isMounted=!1,this.node=e}update(){}}function nj({top:n,left:e,right:t,bottom:s}){return{x:{min:e,max:t},y:{min:n,max:s}}}function ule({x:n,y:e}){return{top:e.min,right:n.max,bottom:e.max,left:n.min}}function dle(n,e){if(!e)return n;const t=e({x:n.left,y:n.top}),s=e({x:n.right,y:n.bottom});return{top:t.y,left:t.x,bottom:s.y,right:s.x}}function Xv(n){return n===void 0||n===1}function Vw({scale:n,scaleX:e,scaleY:t}){return!Xv(n)||!Xv(e)||!Xv(t)}function qu(n){return Vw(n)||sj(n)||n.z||n.rotate||n.rotateX||n.rotateY||n.skewX||n.skewY}function sj(n){return uA(n.x)||uA(n.y)}function uA(n){return n&&n!=="0%"}function Z1(n,e,t){const s=n-t,r=e*s;return t+r}function dA(n,e,t,s,r){return r!==void 0&&(n=Z1(n,r,s)),Z1(n,t,s)+e}function Bw(n,e=0,t=1,s,r){n.min=dA(n.min,e,t,s,r),n.max=dA(n.max,e,t,s,r)}function rj(n,{x:e,y:t}){Bw(n.x,e.translate,e.scale,e.originPoint),Bw(n.y,t.translate,t.scale,t.originPoint)}const hA=.999999999999,fA=1.0000000000001;function hle(n,e,t,s=!1){const r=t.length;if(!r)return;e.x=e.y=1;let i,a;for(let l=0;l<r;l++){i=t[l],a=i.projectionDelta;const{visualElement:c}=i.options;c&&c.props.style&&c.props.style.display==="contents"||(s&&i.options.layoutScroll&&i.scroll&&i!==i.root&&(Fo(n.x,-i.scroll.offset.x),Fo(n.y,-i.scroll.offset.y)),a&&(e.x*=a.x.scale,e.y*=a.y.scale,rj(n,a)),s&&qu(i.latestValues)&&G0(n,i.latestValues,i.layout?.layoutBox))}e.x<fA&&e.x>hA&&(e.x=1),e.y<fA&&e.y>hA&&(e.y=1)}function Fo(n,e){n.min+=e,n.max+=e}function pA(n,e,t,s,r=.5){const i=Dn(n.min,n.max,r);Bw(n,e,t,i,s)}function mA(n,e){return typeof n=="string"?parseFloat(n)/100*(e.max-e.min):n}function G0(n,e,t){const s=t??n;pA(n.x,mA(e.x,s.x),e.scaleX,e.scale,e.originX),pA(n.y,mA(e.y,s.y),e.scaleY,e.scale,e.originY)}function ij(n,e){return nj(dle(n.getBoundingClientRect(),e))}function fle(n,e,t){const s=ij(n,t),{scroll:r}=e;return r&&(Fo(s.x,r.offset.x),Fo(s.y,r.offset.y)),s}const ple={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},mle=Lf.length;function gle(n,e,t){let s="",r=!0;for(let a=0;a<mle;a++){const l=Lf[a],c=n[l];if(c===void 0)continue;let d=!0;if(typeof c=="number")d=c===(l.startsWith("scale")?1:0);else{const h=parseFloat(c);d=l.startsWith("scale")?h===1:h===0}if(!d||t){const h=Uw(c,Q1[l]);if(!d){r=!1;const p=ple[l]||l;s+=`${p}(${h}
137) `}t&&(e[l]=h)}}const i=n.pathRotation;return i&&(r=!1,s+=`rotate(${Uw(i,Q1.pathRotation)}) `),s=s.trim(),t?s=t(e,r?"":s):r&&(s="none"),s}function GS(n,e,t){const{style:s,vars:r,transformOrigin:i}=n;let a=!1,l=!1;for(const c in e){const d=e[c];if(Df.has(c)){a=!0;continue}else if(gD(c)){r[c]=d;continue}else{const h=Uw(d,Q1[c]);c.startsWith("origin")?(l=!0,i[c]=h):s[c]=h}}if(e.transform||(a||t?s.transform=gle(e,n.transform,t):s.transform&&(s.transform="none")),l){const{originX:c="50%",originY:d="50%",originZ:h=0}=i;s.transformOrigin=`${c} ${d} ${h}`}}function aj(n,{style:e,vars:t},s,r){const i=n.style;let a;for(a in e)i[a]=e[a];r?.applyProjectionStyles(i,s);for(a in t)i.setProperty(a,t[a])}function gA(n,e){return e.max===e.min?0:n/(e.max-e.min)*100}const hp={correct:(n,e)=>{if(!e.target)return n;if(typeof n=="string")if(ht.test(n))n=parseFloat(n);else return n;const t=gA(n,e.target.x),s=gA(n,e.target.y);return`${t}% ${s}%`}},xle={correct:(n,{treeScale:e,projectionDelta:t})=>{const s=n,r=co.parse(n);if(r.length>5)return s;const i=co.createTransformer(n),a=typeof r[0]!="number"?1:0,l=t.x.scale*e.x,c=t.y.scale*e.y;r[0+a]/=l,r[1+a]/=c;const d=Dn(l,c,.5);return typeof r[2+a]=="number"&&(r[2+a]/=d),typeof r[3+a]=="number"&&(r[3+a]/=d),i(r)}},zw={borderRadius:{...hp,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:hp,borderTopRightRadius:hp,borderBottomLeftRadius:hp,borderBottomRightRadius:hp,boxShadow:xle};function oj(n,{layout:e,layoutId:t}){return Df.has(n)||n.startsWith("origin")||(e||t!==void 0)&&(!!zw[n]||n==="opacity")}function KS(n,e,t){const s=n.style,r=e?.style,i={};if(!s)return i;for(const a in s)(br(s[a])||r&&br(r[a])||oj(a,n)||t?.getValue(a)?.liveStyle!==void 0)&&(i[a]=s[a]);return i}function yle(n){return window.getComputedStyle(n)}class vle extends tj{constructor(){super(...arguments),this.type="html",this.renderInstance=aj}readValueFromInstance(e,t){if(Df.has(t))return this.projection?.isProjecting?Cw(t):Uae(e,t);{const s=yle(e),r=(gD(t)?s.getPropertyValue(t):s[t])||0;return typeof r=="string"?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return ij(e,t)}build(e,t,s){GS(e,t,s.transformTemplate)}scrapeMotionValuesFromProps(e,t,s){return KS(e,t,s)}}const ble={offset:"stroke-dashoffset",array:"stroke-dasharray"},wle={offset:"strokeDashoffset",array:"strokeDasharray"};function Sle(n,e,t=1,s=0,r=!0){n.pathLength=1;const i=r?ble:wle;n[i.offset]=`${-s}`,n[i.array]=`${e} ${t}`}const Ele=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function lj(n,{attrX:e,attrY:t,attrScale:s,pathLength:r,pathSpacing:i=1,pathOffset:a=0,...l},c,d,h){if(GS(n,l,d),c){n.style.viewBox&&(n.attrs.viewBox=n.style.viewBox);return}n.attrs=n.style,n.style={};const{attrs:p,style:m}=n;p.transform&&(m.transform=p.transform,delete p.transform),(m.transform||p.transformOrigin)&&(m.transformOrigin=p.transformOrigin??"50% 50%",delete p.transformOrigin),m.transform&&(m.transformBox=h?.transformBox??"fill-box",delete p.transformBox);for(const y of Ele)p[y]!==void 0&&(m[y]=p[y],delete p[y]);e!==void 0&&(p.x=e),t!==void 0&&(p.y=t),s!==void 0&&(p.scale=s),r!==void 0&&Sle(p,r,i,a,!1)}const cj=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]),uj=n=>typeof n=="string"&&n.toLowerCase()==="svg";function Tle(n,e,t,s){aj(n,e,void 0,s);for(const r in e.attrs)n.setAttribute(cj.has(r)?r:US(r),e.attrs[r])}function dj(n,e,t){const s=KS(n,e,t);for(const r in n)if(br(n[r])||br(e[r])){const i=Lf.indexOf(r)!==-1?"attr"+r.charAt(0).toUpperCase()+r.substring(1):r;s[i]=n[r]}return s}class _le extends tj{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=$s}getBaseTargetFromProps(e,t){return e[t]}readValueFromInstance(e,t){if(Df.has(t)){const s=WD(t);return s&&s.default||0}return t=cj.has(t)?t:US(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,s){return dj(e,t,s)}build(e,t,s){lj(e,t,this.isSVGTag,s.transformTemplate,s.style)}renderInstance(e,t,s,r){Tle(e,t,s,r)}mount(e){this.isSVGTag=uj(e.tagName),super.mount(e)}}const Ile=HS.length;function hj(n){if(!n)return;if(!n.isControllingVariants){const t=n.parent?hj(n.parent)||{}:{};return n.props.initial!==void 0&&(t.initial=n.props.initial),t}const e={};for(let t=0;t<Ile;t++){const s=HS[t],r=n.props[s];(Tm(r)||r===!1)&&(e[s]=r)}return e}function fj(n,e){if(!Array.isArray(e))return!1;const t=e.length;if(t!==n.length)return!1;for(let s=0;s<t;s++)if(e[s]!==n[s])return!1;return!0}const Ale=[...$S].reverse(),Cle=$S.length;function kle(n){return e=>Promise.all(e.map(({animation:t,options:s})=>Ioe(n,t,s)))}
vendor: 6,451 bytes, line 137
137function Rle(n){let e=kle(n),t=xA(),s=!0,r=!1;const i=d=>(h,p)=>{const m=fd(n,p,d==="exit"?n.presenceContext?.custom:void 0);if(m){const{transition:y,transitionEnd:x,...w}=m;h={...h,...w,...x}}return h};function a(d){e=d(n)}function l(d){const{props:h}=n,p=hj(n.parent)||{},m=[],y=new Set;let x={},w=1/0;for(let _=0;_<Cle;_++){const L=Ale[_],R=t[L],M=h[L]!==void 0?h[L]:p[L],V=Tm(M),W=L===d?R.isActive:null;W===!1&&(w=_);let I=M===p[L]&&M!==h[L]&&V;if(I&&(s||r)&&n.manuallyAnimateOnMount&&(I=!1),R.protectedKeys={...x},!R.isActive&&W===null||!M&&!R.prevProp||hy(M)||typeof M=="boolean")continue;if(L==="exit"&&R.isActive&&W!==!0){R.prevResolvedValues&&(x={...x,...R.prevResolvedValues});continue}const k=Ple(R.prevProp,M);let P=k||L===d&&R.isActive&&!I&&V||_>w&&V,N=!1;const F=Array.isArray(M)?M:[M];let z=F.reduce(i(L),{});W===!1&&(z={});const{prevResolvedValues:U={}}=R,fe={...U,...z},oe=G=>{P=!0,y.has(G)&&(N=!0,y.delete(G)),R.needsAnimating[G]=!0;const Y=n.getValue(G);Y&&(Y.liveStyle=!1)};for(const G in fe){const Y=z[G],ee=U[G];if(x.hasOwnProperty(G))continue;let H=!1;Dw(Y)&&Dw(ee)?H=!fj(Y,ee)||k:H=Y!==ee,H?Y!=null?oe(G):y.add(G):Y!==void 0&&y.has(G)?oe(G):R.protectedKeys[G]=!0}R.prevProp=M,R.prevResolvedValues=z,R.isActive&&(x={...x,...z}),(s||r)&&n.blockInitialAnimation&&(P=!1);const X=I&&k;P&&(!X||N)&&m.push(...F.map(G=>{const Y={type:L};if(typeof G=="string"&&(s||r)&&!X&&n.manuallyAnimateOnMount&&n.parent){const{parent:ee}=n,H=fd(ee,G);if(ee.enteringChildren&&H){const{delayChildren:K}=H.transition||{};Y.delay=OD(ee.enteringChildren,n,K)}}return{animation:G,options:Y}}))}if(y.size){const _={};if(typeof h.initial!="boolean"){const L=fd(n,Array.isArray(h.initial)?h.initial[0]:h.initial);L&&L.transition&&(_.transition=L.transition)}y.forEach(L=>{const R=n.getBaseTarget(L),M=n.getValue(L);M&&(M.liveStyle=!0),_[L]=R??null}),m.push({animation:_})}let S=!!m.length;return s&&(h.initial===!1||h.initial===h.animate)&&!n.manuallyAnimateOnMount&&(S=!1),s=!1,r=!1,S?e(m):Promise.resolve()}function c(d,h){if(t[d].isActive===h)return Promise.resolve();n.variantChildren?.forEach(m=>m.animationState?.setActive(d,h)),t[d].isActive=h;const p=l(d);for(const m in t)t[m].protectedKeys={};return p}return{animateChanges:l,setActive:c,setAnimateFunction:a,getState:()=>t,reset:()=>{t=xA(),r=!0}}}function Ple(n,e){return typeof e=="string"?e!==n:Array.isArray(e)?!fj(e,n):!1}function zu(n=!1){return{isActive:n,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function xA(){return{animate:zu(!0),whileInView:zu(),whileHover:zu(),whileTap:zu(),whileDrag:zu(),whileFocus:zu(),exit:zu()}}function $w(n,e){n.min=e.min,n.max=e.max}function Ja(n,e){$w(n.x,e.x),$w(n.y,e.y)}function yA(n,e){n.translate=e.translate,n.scale=e.scale,n.originPoint=e.originPoint,n.origin=e.origin}const pj=1e-4,Nle=1-pj,Lle=1+pj,mj=.01,Dle=0-mj,jle=0+mj;function ni(n){return n.max-n.min}function Ole(n,e,t){return Math.abs(n-e)<=t}function vA(n,e,t,s=.5){n.origin=s,n.originPoint=Dn(e.min,e.max,n.origin),n.scale=ni(t)/ni(e),n.translate=Dn(t.min,t.max,n.origin)-n.originPoint,(n.scale>=Nle&&n.scale<=Lle||isNaN(n.scale))&&(n.scale=1),(n.translate>=Dle&&n.translate<=jle||isNaN(n.translate))&&(n.translate=0)}function $p(n,e,t,s){vA(n.x,e.x,t.x,s?s.originX:void 0),vA(n.y,e.y,t.y,s?s.originY:void 0)}function bA(n,e,t,s=0){const r=s?Dn(t.min,t.max,s):t.min;n.min=r+e.min,n.max=n.min+ni(e)}function Mle(n,e,t,s){bA(n.x,e.x,t.x,s?.x),bA(n.y,e.y,t.y,s?.y)}function wA(n,e,t,s=0){const r=s?Dn(t.min,t.max,s):t.min;n.min=e.min-r,n.max=n.min+ni(e)}function ex(n,e,t,s){wA(n.x,e.x,t.x,s?.x),wA(n.y,e.y,t.y,s?.y)}function SA(n,e,t,s,r){return n-=e,n=Z1(n,1/t,s),r!==void 0&&(n=Z1(n,1/r,s)),n}function Fle(n,e=0,t=1,s=.5,r,i=n,a=n){if(Ko.test(e)&&(e=parseFloat(e),e=Dn(a.min,a.max,e/100)-a.min),typeof e!="number")return;let l=Dn(i.min,i.max,s);n===i&&(l-=e),n.min=SA(n.min,e,t,l,r),n.max=SA(n.max,e,t,l,r)}function EA(n,e,[t,s,r],i,a){Fle(n,e[t],e[s],e[r],e.scale,i,a)}const Ule=["x","scaleX","originX"],Vle=["y","scaleY","originY"];function TA(n,e,t,s){EA(n.x,e,Ule,t?t.x:void 0,s?s.x:void 0),EA(n.y,e,Vle,t?t.y:void 0,s?s.y:void 0)}function _A(n){return n.translate===0&&n.scale===1}function gj(n){return _A(n.x)&&_A(n.y)}function IA(n,e){return n.min===e.min&&n.max===e.max}function Ble(n,e){return IA(n.x,e.x)&&IA(n.y,e.y)}function AA(n,e){return Math.round(n.min)===Math.round(e.min)&&Math.round(n.max)===Math.round(e.max)}function xj(n,e){return AA(n.x,e.x)&&AA(n.y,e.y)}function CA(n){return ni(n.x)/ni(n.y)}function kA(n,e){return n.translate===e.translate&&n.scale===e.scale&&n.originPoint===e.originPoint}function jo(n){return[n("x"),n("y")]}function zle(n,e,t){let s="";const r=n.x.translate/e.x,i=n.y.translate/e.y,a=t?.z||0;if((r||i||a)&&(s=`translate3d(${r}px, ${i}px, ${a}px) `),(e.x!==1||e.y!==1)&&(s+=`scale(${1/e.x}, ${1/e.y}) `),t){const{transformPerspective:d,rotate:h,pathRotation:p,rotateX:m,rotateY:y,skewX:x,skewY:w}=t;d&&(s=`perspective(${d}px) ${s}`),h&&(s+=`rotate(${h}deg) `),p&&(s+=`rotate(${p}deg) `),m&&(s+=`rotateX(${m}deg) `),y&&(s+=`rotateY(${y}deg) `),x&&(s+=`skewX(${x}deg) `),w&&(s+=`skewY(${w}deg) `)}const l=n.x.scale*e.x,c=n.y.scale*e.y;return(l!==1||c!==1)&&(s+=`scale(${l}, ${c})`),s||"none"}const yj=["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"],$le=yj.length,RA=n=>typeof n=="string"?parseFloat(n):n,PA=n=>typeof n=="number"||ht.test(n);function Hle(n,e,t,s,r,i){r?(n.opacity=Dn(0,t.opacity??1,Wle(s)),n.opacityExit=Dn(e.opacity??1,0,Gle(s))):i&&(n.opacity=Dn(e.opacity??1,t.opacity??1,s));for(let a=0;a<$le;a++){const l=yj[a];let c=NA(e,l),d=NA(t,l);if(c===void 0&&d===void 0)continue;c||(c=0),d||(d=0),c===0||d===0||PA(c)===PA(d)?(n[l]=Math.max(Dn(RA(c),RA(d),s),0),(Ko.test(d)||Ko.test(c))&&(n[l]+="%")):n[l]=d}(e.rotate||t.rotate)&&(n.rotate=Dn(e.rotate||0,t.rotate||0,s))}function NA(n,e){return n[e]!==void 0?n[e]:n.borderRadius}const Wle=vj(0,.5,uD),Gle=vj(.5,.95,Ta);function vj(n,e,t){return s=>s<n?0:s>e?1:t(Sm(n,e,s))}function Kle(n,e,t){const s=br(n)?n:cf(n);return s.start(MS("",s,e,t)),s.animation}function _m(n,e,t,s={passive:!0}){return n.addEventListener(e,t,s),()=>n.removeEventListener(e,t)}const qle=(n,e)=>n.depth-e.depth;class Yle{constructor(){this.children=[],this.isDirty=!1}add(e){TS(this.children,e),this.isDirty=!0}remove(e){W1(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(qle),this.isDirty=!1,this.children.forEac
137h(e)}}function Qle(n,e){const t=ti.now(),s=({timestamp:r})=>{const i=r-t;i>=e&&(pu(s),n(i-e))};return On.setup(s,!0),()=>pu(s)}function K0(n){return br(n)?n.get():n}class Xle{constructor(){this.members=[]}add(e){TS(this.members,e);for(let t=this.members.length-1;t>=0;t--){const s=this.members[t];if(s===e||s===this.lead||s===this.prevLead)continue;const r=s.instance;(!r||r.isConnected===!1)&&!s.snapshot&&(W1(this.members,s),s.unmount())}e.scheduleRender()}remove(e){if(W1(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){const t=this.members[this.members.length-1];t&&this.promote(t)}}relegate(e){for(let t=this.members.indexOf(e)-1;t>=0;t--){const s=this.members[t];if(s.isPresent!==!1&&s.instance?.isConnected!==!1)return this.promote(s),!0}return!1}promote(e,t){const s=this.lead;if(e!==s&&(this.prevLead=s,this.lead=e,e.show(),s)){s.updateSnapshot(),e.scheduleRender();const{layoutDependency:r}=s.options,{layoutDependency:i}=e.options;(r===void 0||r!==i)&&(e.resumeFrom=s,t&&(s.preserveOpacity=!0),s.snapshot&&(e.snapshot=s.snapshot,e.snapshot.latestValues=s.animationValues||s.latestValues),e.root?.isUpdating&&(e.isLayoutDirty=!0)),e.options.crossfade===!1&&s.hide()}}exitAnimationComplete(){this.members.forEach(e=>{e.options.onExitComplete?.(),e.resumingFrom?.options.onExitComplete?.()})}scheduleRender(){this.members.forEach(e=>e.instance&&e.scheduleRender(!1))}removeLeadSnapshot(){this.lead?.snapshot&&(this.lead.snapshot=void 0)}}const q0={hasAnimatedSinceResize:!0,hasEverUpdated:!1},Jv=["","X","Y","Z"],Jle=1e3;let Zle=0;function Zv(n,e,t,s){const{latestValues:r}=e;r[n]&&(t[n]=r[n],e.setStaticValue(n,0),s&&(s[n]=0))}function bj(n){if(n.hasCheckedOptimisedAppear=!0,n.root===n)return;const{visualElement:e}=n.options;if(!e)return;const t=BD(e);if(window.MotionHasOptimisedAnimation(t,"transform")){const{layout:r,layoutId:i}=n.options;window.MotionCancelOptimisedAnimation(t,"transform",On,!(r||i))}const{parent:s}=n;s&&!s.hasCheckedOptimisedAppear&&bj(s)}function wj({attachResizeListener:n,defaultParent:e,measureScroll:t,checkIsScrollRoot:s,resetTransform:r}){return class{constructor(a={},l=e?.()){this.id=Zle++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(nce),this.nodes.forEach(lce),this.nodes.forEach(cce),this.nodes.forEach(sce)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=a,this.root=l?l.root||l:this,this.path=l?[...l.path,l]:[],this.parent=l,this.depth=l?l.depth+1:0;for(let c=0;c<this.path.length;c++)this.path[c].shouldResetTransform=!0;this.root===this&&(this.nodes=new Yle)}addEventListener(a,l){return this.eventHandlers.has(a)||this.eventHandlers.set(a,new IS),this.eventHandlers.get(a).add(l)}notifyListeners(a,...l){const c=this.eventHandlers.get(a);c&&c.notify(...l)}hasListeners(a){return this.eventHandlers.has(a)}mount(a){if(this.instance)return;this.isSVG=zS(a)&&!nle(a),this.instance=a;const{layoutId:l,layout:c,visualElement:d}=this.options;if(d&&!d.current&&d.mount(a),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(c||l)&&(this.isLayoutDirty=!0),n){let h,p=0;const m=()=>this.root.updateBlockedByResize=!1;On.read(()=>{p=window.innerWidth}),n(a,()=>{const y=window.innerWidth;y!==p&&(p=y,this.root.updateBlockedByResize=!0,h&&h(),h=Qle(m,250),q0.hasAnimatedSinceResize&&(q0.hasA
vendor: 4,592 bytes, line 137
137nimatedSinceResize=!1,this.nodes.forEach(jA)))})}l&&this.root.registerSharedNode(l,this),this.options.animate!==!1&&d&&(l||c)&&this.addEventListener("didUpdate",({delta:h,hasLayoutChanged:p,hasRelativeLayoutChanged:m,layout:y})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const x=this.options.transition||d.getDefaultTransition()||pce,{onLayoutAnimationStart:w,onLayoutAnimationComplete:S}=d.getProps(),_=!this.targetLayout||!xj(this.targetLayout,y),L=!p&&m;if(this.options.layoutRoot||this.resumeFrom||L||p&&(_||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const R={...OS(x,"layout"),onPlay:w,onComplete:S};(d.shouldReduceMotion||this.options.layoutRoot)&&(R.delay=0,R.type=!1),this.startAnimation(R),this.setAnimationOrigin(h,L,R.path)}else p||jA(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=y})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const a=this.getStack();a&&a.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),pu(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(uce),this.animationId++)}getTransformTemplate(){const{visualElement:a}=this.options;return a&&a.getProps().transformTemplate}willUpdate(a=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&bj(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let h=0;h<this.path.length;h++){const p=this.path[h];p.shouldResetTransform=!0,(typeof p.latestValues.x=="string"||typeof p.latestValues.y=="string")&&(p.isLayoutDirty=!0),p.updateScroll("snapshot"),p.options.layoutRoot&&p.willUpdate(!1)}const{layoutId:l,layout:c}=this.options;if(l===void 0&&!c)return;const d=this.getTransformTemplate();this.prevTransformTemplateValue=d?d(this.latestValues,""):void 0,this.updateSnapshot(),a&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){const c=this.updateBlockedByResize;this.unblockUpdate(),this.updateBlockedByResize=!1,this.clearAllSnapshots(),c&&this.nodes.forEach(ice),this.nodes.forEach(LA);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(DA);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(ace),this.nodes.forEach(oce),this.nodes.forEach(ece),this.nodes.forEach(tce)):this.nodes.forEach(DA),this.clearAllSnapshots();const l=ti.now();xr.delta=tl(0,1e3/60,l-xr.timestamp),xr.timestamp=l,xr.isProcessing=!0,Hv.update.process(xr),Hv.preRender.process(xr),Hv.render.process(xr),xr.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,VS.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(rce),this.sharedNodes.forEach(dce)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,On.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){On.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!ni(this.snapshot.measuredBox.x)&&!ni(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let c=0;c<this.path.length;c++)this.path[c].updateScroll();const a=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected||(this.layoutCorrected=$s()),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:l}=this.options;l&&l.notify("LayoutMeasure",this.layout.layoutBox,a?a.layoutBox:void 0)}updateScroll(a="measure"){let l=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===a&&(l=!1),l&&this.instance){const c=s(this.instance);
137this.scroll={animationId:this.root.animationId,phase:a,isRoot:c,offset:t(this.instance),wasRoot:this.scroll?this.scroll.isRoot:c}}}resetTransform(){if(!r)return;const a=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,l=this.projectionDelta&&!gj(this.projectionDelta),c=this.getTransformTemplate(),d=c?c(this.latestValues,""):void 0,h=d!==this.prevTransformTemplateValue;a&&this.instance&&(l||qu(this.latestValues)||h)&&(r(this.instance,d),this.shouldResetTransform=!1,this.scheduleRender())}measure(a=!0){const l=this.measurePageBox();let c=this.removeElementScroll(l);return a&&(c=this.removeTransform(c)),mce(c),{animationId:this.root.animationId,measuredBox:l,layoutBox:c,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:a}=this.options;if(!a)return $s();const l=a.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(gce))){const{scroll:d}=this.root;d&&(Fo(l.x,d.offset.x),Fo(l.y,d.offset.y))}return l}removeElementScroll(a){const l=$s();if(Ja(l,a),this.scroll?.wasRoot)return l;for(let c=0;c<this.path.length;c++){const d=this.path[c],{scroll:h,options:p}=d;d!==this.root&&h&&p.layoutScroll&&(h.wasRoot&&Ja(l,a),Fo(l.x,h.offset.x),Fo(l.y,h.offset.y))}return l}applyTransform(a,l=!1,c){const d=c||$s();Ja(d,a);for(let h=0;h<this.path.length;h++){const p=this.path[h];!l&&p.options.layoutScroll&&p.scroll&&p!==p.root&&(Fo(d.x,-p.scroll.offset.x),Fo(d.y,-p.scroll.offset.y)),qu(p.latestValues)&&G0(d,p.latestValues,p.layout?.layoutBox)}return qu(this.latestValues)&&G0(d,this.latestValues,this.layout?.layoutBox),d}removeTransform(a){const l=$s();Ja(l,a);for(let c=0;c<this.path.length;c++){const d=this.path[c];if(!qu(d.latestValues))continue;let h;d.instance&&(Vw(d.latestValues)&&d.updateSnapshot(),h=$s(),Ja(h,d.measurePageBox())),TA(l,d.latestValues,d.snapshot?.layoutBox,h)}return qu(this.latestValues)&&TA(l,this.latestValues),l}setTargetDelta(a){this.targetDelta=a,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(a){this.options={...this.options,...a,crossfade:a.crossfade!==void 0?a.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==xr.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(a=!1){const l=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=l.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=l.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=l.isSharedProjectionDirty);const c=!!this.resumingFrom||this!==l;if(!(a||c&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:h,layoutId:p}=this.options;if(!this.layout||!(h||p))return;this.resolvedRelativeTargetAt=xr.timestamp;const m=this.getClosestProjectingParent();m&&this.linkedParentVersion!==m.layoutVersion&&!m.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(this.options.layoutAnchor!==!1&&m&&m.layout?this.createRelativeTarget(m,this.layout.layoutBox,m.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=$s(),this.targetWithTransforms=$s()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),Mle(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):Ja(this.target,this.layout.layoutBox),rj(this.target,this.targetDelta)):Ja(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,this.options.layoutAnchor!==!1&&m&&!!m.resumingFrom==!!this.resumingFrom&&!m.options.layoutScroll&&m.target&&this.animationProgress!==1?this.createRelativeTarget(m,this.target,m.target):this.relativeParent=this.relativeTarget=void 0))}getClosestProjectingParent(){if(!(!this.parent||Vw(this.parent.latestValues)||sj(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(a,l,c){this.relativeParent=a,this.linkedParentVersion=a.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=$s(),this.relativeTargetOrigin=$s(),ex(this.relativeTargetOrigin,l,c,this.options.layoutAnchor||void 0),Ja(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){const a=this.getLead(),l=!!this.resumingFrom||this!==a;let c=!0;
137if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(c=!1),l&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(c=!1),this.resolvedRelativeTargetAt===xr.timestamp&&(c=!1),c)return;const{layout:d,layoutId:h}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(d||h))return;Ja(this.layoutCorrected,this.layout.layoutBox);const p=this.treeScale.x,m=this.treeScale.y;hle(this.layoutCorrected,this.treeScale,this.path,l),a.layout&&!a.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(a.target=a.layout.layoutBox,a.targetWithTransforms=$s());const{target:y}=a;if(!y){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(yA(this.prevProjectionDelta.x,this.projectionDelta.x),yA(this.prevProjectionDelta.y,this.projectionDelta.y)),$p(this.projectionDelta,this.layoutCorrected,y,this.latestValues),(this.treeScale.x!==p||this.treeScale.y!==m||!kA(this.projectionDelta.x,this.prevProjectionDelta.x)||!kA(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",y))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(a=!0){if(this.options.visualElement?.scheduleRender(),a){const l=this.getStack();l&&l.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=Ph(),this.projectionDelta=Ph(),this.projectionDeltaWithTransform=Ph()}setAnimationOrigin(a,l=!1,c){const d=this.snapshot,h=d?d.latestValues:{},p={...this.latestValues},m=Ph();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!l;const y=$s(),x=d?d.source:void 0,w=this.layout?this.layout.source:void 0,S=x!==w,_=this.getStack(),L=!_||_.members.length<=1,R=!!(S&&!L&&this.options.crossfade===!0&&!this.path.some(fce));this.animationProgress=0;let M;const V=c?.interpolateProjection(a);this.mixTargetDelta=W=>{const I=W/1e3,k=V?.(I);k?(m.x.translate=k.x,m.x.scale=Dn(a.x.scale,1,I),m.x.origin=a.x.origin,m.x.originPoint=a.x.originPoint,m.y.translate=k.y,m.y.scale=Dn(a.y.scale,1,I),m.y.origin=a.y.origin,m.y.originPoint=a.y.originPoint):(OA(m.x,a.x,I),OA(m.y,a.y,I)),this.setTargetDelta(m),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(ex(y,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),hce(this.relativeTarget,this.relativeTargetOrigin,y,I),M&&Ble(this.relativeTarget,M)&&(this.isProjectionDirty=!1),M||(M=$s()),Ja(M,this.relativeTarget)),S&&(this.animationValues=p,Hle(p,h,this.latestValues,I,R,L)),k&&k.rotate!==void 0&&(this.animationValues||(this.animationValues=p),this.animationValues.pathRotation=k.rotate),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=I},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(a){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(pu(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=On.update(()=>{q0.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=cf(0)),this.motionValue.jump(0,!1),this.currentAnimation=Kle(this.motionValue,[0,1e3],{...a,velocity:0,isSync:!0,onUpdate:l=>{this.mixTargetDelta(l),a.onUpdate&&a.onUpdate(l)},onStop:()=>{},onComplete:()=>{a.onComplete&&a.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const a=this.getStack();a&&a.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(Jle),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const a=this.getLead();let{targetWithTransforms:l,target:c,layout:d,latestValues:h}=a;if(!(!l||!c||!d)){if(this!==a&&this.layout&&d&&Sj(this.options.animationType,this.layout.layoutBox,d.layoutBox)){c=this.target||$s();const p=ni(this.layout.layoutBox.x);
vendor: 25,917 bytes, line 137
137c.x.min=a.target.x.min,c.x.max=c.x.min+p;const m=ni(this.layout.layoutBox.y);c.y.min=a.target.y.min,c.y.max=c.y.min+m}Ja(l,c),G0(l,h),$p(this.projectionDeltaWithTransform,this.layoutCorrected,l,h)}}registerSharedNode(a,l){this.sharedNodes.has(a)||this.sharedNodes.set(a,new Xle),this.sharedNodes.get(a).add(l);const d=l.options.initialPromotionConfig;l.promote({transition:d?d.transition:void 0,preserveFollowOpacity:d&&d.shouldPreserveFollowOpacity?d.shouldPreserveFollowOpacity(l):void 0})}isLead(){const a=this.getStack();return a?a.lead===this:!0}getLead(){const{layoutId:a}=this.options;return a?this.getStack()?.lead||this:this}getPrevLead(){const{layoutId:a}=this.options;return a?this.getStack()?.prevLead:void 0}getStack(){const{layoutId:a}=this.options;if(a)return this.root.sharedNodes.get(a)}promote({needsReset:a,transition:l,preserveFollowOpacity:c}={}){const d=this.getStack();d&&d.promote(this,c),a&&(this.projectionDelta=void 0,this.needsReset=!0),l&&this.setOptions({transition:l})}relegate(){const a=this.getStack();return a?a.relegate(this):!1}resetSkewAndRotation(){const{visualElement:a}=this.options;if(!a)return;let l=!1;const{latestValues:c}=a;if((c.z||c.rotate||c.rotateX||c.rotateY||c.rotateZ||c.skewX||c.skewY)&&(l=!0),!l)return;const d={};c.z&&Zv("z",a,d,this.animationValues);for(let h=0;h<Jv.length;h++)Zv(`rotate${Jv[h]}`,a,d,this.animationValues),Zv(`skew${Jv[h]}`,a,d,this.animationValues);a.render();for(const h in d)a.setStaticValue(h,d[h]),this.animationValues&&(this.animationValues[h]=d[h]);a.scheduleRender()}applyProjectionStyles(a,l){if(!this.instance||this.isSVG)return;if(!this.isVisible){a.visibility="hidden";return}const c=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,a.visibility="",a.opacity="",a.pointerEvents=K0(l?.pointerEvents)||"",a.transform=c?c(this.latestValues,""):"none";return}const d=this.getLead();if(!this.projectionDelta||!this.layout||!d.target){this.options.layoutId&&(a.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,a.pointerEvents=K0(l?.pointerEvents)||""),this.hasProjected&&!qu(this.latestValues)&&(a.transform=c?c({},""):"none",this.hasProjected=!1);return}a.visibility="";const h=d.animationValues||d.latestValues;this.applyTransformsToTarget();let p=zle(this.projectionDeltaWithTransform,this.treeScale,h);c&&(p=c(h,p)),a.transform=p;const{x:m,y}=this.projectionDelta;a.transformOrigin=`${m.origin*100}% ${y.origin*100}% 0`,d.animationValues?a.opacity=d===this?h.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:h.opacityExit:a.opacity=d===this?h.opacity!==void 0?h.opacity:"":h.opacityExit!==void 0?h.opacityExit:0;for(const x in zw){if(h[x]===void 0)continue;const{correct:w,applyTo:S,isCSSVariable:_}=zw[x],L=p==="none"?h[x]:w(h[x],d);if(S){const R=S.length;for(let M=0;M<R;M++)a[S[M]]=L}else _?this.options.visualElement.renderState.vars[x]=L:a[x]=L}this.options.layoutId&&(a.pointerEvents=d===this?K0(l?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(a=>a.currentAnimation?.stop()),this.root.nodes.forEach(LA),this.root.sharedNodes.clear()}}}function ece(n){n.updateLayout()}function tce(n){const e=n.resumeFrom?.snapshot||n.snapshot;if(n.isLead()&&n.layout&&e&&n.hasListeners("didUpdate")){const{layoutBox:t,measuredBox:s}=n.layout,{animationType:r}=n.options,i=e.source!==n.layout.source;if(r==="size")jo(h=>{const p=i?e.measuredBox[h]:e.layoutBox[h],m=ni(p);p.min=t[h].min,p.max=p.min+m});else if(r==="x"||r==="y"){const h=r==="x"?"y":"x";$w(i?e.measuredBox[h]:e.layoutBox[h],t[h])}else Sj(r,e.layoutBox,t)&&jo(h=>{const p=i?e.measuredBox[h]:e.layoutBox[h],m=ni(t[h]);p.max=p.min+m,n.relativeTarget&&!n.currentAnimation&&(n.isProjectionDirty=!0,n.relativeTarget[h].max=n.relativeTarget[h].min+m)});const a=Ph();$p(a,t,e.layoutBox);const l=Ph();i?$p(l,n.applyTransform(s,!0),e.measuredBox):$p(l,t,e.layoutBox);const c=!gj(a);let d=!1;if(!n.resumeFrom){const h=n.getClosestProjectingParent();if(h&&!h.resumeFrom){const{snapshot:p,layout:m}=h;if(p&&m){const y=n.options.layoutAnchor||void 0,x=$s();ex(x,e.layoutBox,p.layoutBox,y);const w=$s();ex(w,t,m.layoutBox,y),xj(x,w)||(d=!0),h.options.layoutRoot&&(n.relativeTarget=w,n.relativeTargetOrigin=x,n.relativeParent=h)}}}n.notifyListeners("didUpdate",{layout:t,snapshot:e,delta:l,layoutDelta:a,hasLayoutChanged:c,hasRelativeLayoutChanged:d})}else if(n.isLead()){const{onExitComplete:t}=n.options;t&&t()}n.options.transition=void 0}function nce(n){n.parent&&(n.isProjecting()||(n.isProjectionDirty=n.parent.isProjectionDirty),n.isSharedProjectionDirty||(n.isSharedProjectionDirty=!!(n.isProjectionDirty||n.parent.isProjectionDirty||n.parent.isSharedProjectionDirty)),n.isTransformDirty||(n.isTransformDirty=n.parent.isTransformDirty))}function sce(n){n.isProjectionDirty=n.isSharedProjectionDirty=n.isTransformDirty=!1}function rce(n){n.clearSnapshot()}function LA(n){n.clearMeasurements()}function ice(n){n.isLayoutDirty=!0,n.updateLayout()}function DA(n){n.isLayoutDirty=!1}function ace(n){n.isAnimationBlocked&&n.layout&&!n.isLayoutDirty&&(n.snapshot=n.layout,n.isLayoutDirty=!0)}function oce(n){const{visualElement:e}=n.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),n.resetTransform()}function jA(n){n.finishAnimation(),n.targetDelta=n.relativeTarget=n.target=void 0,n.isProjectionDirty=!0}function lce(n){n.resolveTargetDelta()}function cce(n){n.calcProjection()}function uce(n){n.resetSkewAndRotation()}function dce(n){n.removeLeadSnapshot()}function OA(n,e,t){n.translate=Dn(e.translate,0,t),n.scale=Dn(e.scale,1,t),n.origin=e.origin,n.originPoint=e.originPoint}function MA(n,e,t,s){n.min=Dn(e.min,t.min,s),n.max=Dn(e.max,t.max,s)}function hce(n,e,t,s){MA(n.x,e.x,t.x,s),MA(n.y,e.y,t.y,s)}function fce(n){return n.animationValues&&n.animationValues.opacityExit!==void 0}const pce={duration:.45,ease:[.4,0,.1,1]},FA=n=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(n),UA=FA("applewebkit/")&&!FA("chrome/")?Math.round:Ta;function VA(n){n.min=UA(n.min),n.max=UA(n.max)}function mce(n){VA(n.x),VA(n.y)}function Sj(n,e,t){return n==="position"||n==="preserve-aspect"&&!Ole(CA(e),CA(t),.2)}function gce(n){return n!==n.root&&n.scroll?.wasRoot}const xce=wj({attachResizeListener:(n,e)=>_m(n,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),eb={current:void 0},Ej=wj({measureScroll:n=>({x:n.scrollLeft,y:n.scrollTop}),defaultParent:()=>{if(!eb.current){const n=new xce({});n.mount(window),n.setOptions({layoutScroll:!0}),eb.current=n}return eb.current},resetTransform:(n,e)=>{n.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:n=>window.getComputedStyle(n).position==="fixed"}),Tj=T.createContext({transformPagePoint:n=>n,isStatic:!1,reducedMotion:"never"});function yce(n=!0){const e=T.useContext(ES);if(e===null)return[!0,null];const{isPresent:t,onExitComplete:s,register:r}=e,i=T.useId();T.useEffect(()=>{if(n)return r(i)},[n]);const a=T.useCallback(()=>n&&s&&s(i),[i,s,n]);return!t&&s?[!1,a]:[!0]}const _j=T.createContext({strict:!1}),BA={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]};let zA=!1;function vce(){if(zA)return;const n={};for(const e in BA)n[e]={isEnabled:t=>BA[e].some(s=>!!t[s])};ej(n),zA=!0}function Ij(){return vce(),lle()}function bce(n){const e=Ij();for(const t in n)e[t]={...e[t],...n[t]};ej(e)}const wce=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","propagate","ignoreStrict","viewport"]);function tx(n){return n.startsWith("while")||n.startsWith("drag")&&n!=="draggable"||n.startsWith("layout")||n.startsWith("onTap")||n.startsWith("onPan")||n.startsWith("onLayout")||wce.has(n)}let Aj=n=>!tx(n);function Sce(n){typeof n=="function"&&(Aj=e=>e.startsWith("on")?!tx(e):n(e))}try{Sce(require("@emotion/is-prop-valid").default)}catch{}function Ece(n,e,t){const s={};for(const r in n)r==="values"&&typeof n.values=="object"||br(n[r])||(Aj(r)||t===!0&&tx(r)||!e&&!tx(r)||n.draggable&&r.startsWith("onDrag"))&&(s[r]=n[r]);return s}const py=T.createContext({});function Tce(n,e){if(fy(n)){const{initial:t,animate:s}=n;return{initial:t===!1||Tm(t)?t:void 0,animate:Tm(s)?s:void 0}}return n.inherit!==!1?e:{}}function _ce(n){const{initial:e,animate:t}=Tce(n,T.useContext(py));return T.useMemo(()=>({initial:e,animate:t}),[$A(e),$A(t)])}function $A(n){return Array.isArray(n)?n.join(" "):n}const qS=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Cj(n,e,t){for(const s in e)!br(e[s])&&!oj(s,t)&&(n[s]=e[s])}function Ice({transformTemplate:n},e){return T.useMemo(()=>{const t=qS();return GS(t,e,n),Object.assign({},t.vars,t.style)},[e])}function Ace(n,e){const t=n.style||{},s={};return Cj(s,t,n),Object.assign(s,Ice(n,e)),s}function Cce(n,e){const t={},s=Ace(n,e);return n.drag&&n.dragListener!==!1&&(t.draggable=!1,s.userSelect=s.WebkitUserSelect=s.WebkitTouchCallout="none",s.touchAction=n.drag===!0?"none":`pan-${n.drag==="x"?"y":"x"}`),n.tabIndex===void 0&&(n.onTap||n.onTapStart||n.whileTap)&&(t.tabIndex=0),t.style=s,t}const kj=()=>({...qS(),attrs:{}});function kce(n,e,t,s){const r=T.useMemo(()=>{const i=kj();return lj(i,e,uj(s),n.transformTemplate,n.style),{...i.attrs,style:{...i.style}}},[e]);if(n.style){const i={};Cj(i,n.style,n),r.style={...i,...r.style}}return r}const Rce=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function YS(n){return typeof n!="string"||n.includes("-")?!1:!!(Rce.indexOf(n)>-1||/[A-Z]/u.test(n))}function Pce(n,e,t,{latestValues:s},r,i=!1,a){const c=(a??YS(n)?kce:Cce)(e,s,r,n),d=Ece(e,typeof n=="string",i),h=n!==T.Fragment?{...d,...c,ref:t}:{},{children:p}=e,m=T.useMemo(()=>br(p)?p.get():p,[p]);return T.createElement(n,{...h,children:m})}function Nce({scrapeMotionValuesFromProps:n,createRenderState:e},t,s,r){return{latestValues:Lce(t,s,r,n),renderState:e()}}function Lce(n,e,t,s){const r={},i=s(n,{});for(const m in i)r[m]=K0(i[m]);let{initial:a,animate:l}=n;const c=fy(n),d=JD(n);e&&d&&!c&&n.inherit!==!1&&(a===void 0&&(a=e.initial),l===void 0&&(l=e.animate));let h=t?t.initial===!1:!1;h=h||a===!1;const p=h?l:a;if(p&&typeof p!="boolean"&&!hy(p)){const m=Array.isArray(p)?p:[p];for(let y=0;y<m.length;y++){const x=FS(n,m[y]);if(x){const{transitionEnd:w,transition:S,..._}=x;for(const L in _){let R=_[L];if(Array.isArray(R)){const M=h?R.length-1:0;R=R[M]}R!==null&&(r[L]=R)}for(const L in w)r[L]=w[L]}}}return r}const Rj=n=>(e,t)=>{const s=T.useContext(py),r=T.useContext(ES),i=()=>Nce(n,e,s,r);return t?i():Nie(i)},Dce=Rj({scrapeMotionValuesFromProps:KS,createRenderState:qS}),jce=Rj({scrapeMotionValuesFromProps:dj,createRenderState:kj}),Oce=Symbol.for("motionComponentSymbol");function Mce(n,e,t){const s=T.useRef(t);T.useInsertionEffect(()=>{s.current=t});const r=T.useRef(null);return T.useCallback(i=>{i&&n.onMount?.(i),e&&(i?e.mount(i):e.unmount());const a=s.current;if(typeof a=="function")if(i){const l=a(i);typeof l=="function"&&(r.current=l)}else r.current?(r.current(),r.current=null):a(i);else a&&(a.current=i)},[e])}const Pj=T.createContext({});function _h(n){return n&&typeof n=="object"&&Object.prototype.hasOwnProperty.call(n,"current")}function Fce(n,e,t,s,r,i){const{visualElement:a}=T.useContext(py),l=T.useContext(_j),c=T.useContext(ES),d=T.useContext(Tj),h=d.reducedMotion,p=d.skipAnimations,m=T.useRef(null),y=T.useRef(!1);s=s||l.renderer,!m.current&&s&&(m.current=s(n,{visualState:e,parent:a,props:t,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:h,skipAnimations:p,isSVG:i}),y.current&&m.current&&(m.current.manuallyAnimateOnMount=!0));const x=m.current,w=T.useContext(Pj);x&&!x.projection&&r&&(x.type==="html"||x.type==="svg")&&Uce(m.current,t,r,w);const S=T.useRef(!1);T.useInsertionEffect(()=>{x&&S.current&&x.update(t,c)});const _=t[VD],L=T.useRef(!!_&&typeof window<"u"&&!window.MotionHandoffIsComplete?.(_)&&window.MotionHasOptimisedAnimation?.(_));return Die(()=>{y.current=!0,x&&(S.current=!0,window.MotionIsMounted=!0,x.updateFeatures(),x.scheduleRenderMicrotask(),L.current&&x.animationState&&x.animationState.animateChanges())}),T.useEffect(()=>{x&&(!L.current&&x.animationState&&x.animationState.animateChanges(),L.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(_)}),L.current=!1),x.enteringChildren=void 0)}),x}function Uce(n,e,t,s){const{layoutId:r,layout:i,drag:a,dragConstraints:l,layoutScroll:c,layoutRoot:d,layoutAnchor:h,layoutCrossfade:p}=e;n.projection=new t(n.latestValues,e["data-framer-portal-id"]?void 0:Nj(n.parent)),n.projection.setOptions({layoutId:r,layout:i,alwaysMeasureLayout:!!a||l&&_h(l),visualElement:n,animationType:typeof i=="string"?i:"both",initialPromotionConfig:s,crossfade:p,layoutScroll:c,layoutRoot:d,layoutAnchor:h})}function Nj(n){if(n)return n.options.allowProjection!==!1?n.projection:Nj(n.parent)}function tb(n,{forwardMotionProps:e=!1,type:t}={},s,r){s&&bce(s);const i=t?t==="svg":YS(n),a=i?jce:Dce;function l(d,h){let p;const m={...T.useContext(Tj),...d,layoutId:Vce(d)},{isStatic:y}=m,x=_ce(d),w=a(d,y);if(!y&&typeof window<"u"){Bce();const S=zce(m);p=S.MeasureLayout,x.visualElement=Fce(n,w,m,r,S.ProjectionNode,i)}return o.jsxs(py.Provider,{value:x,children:[p&&x.visualElement?o.jsx(p,{visualElement:x.visualElement,...m}):null,Pce(n,d,Mce(w,x.visualElement,h),w,y,e,i)]})}l.displayName=`motion.${typeof n=="string"?n:`create(${n.displayName??n.name??""})`}`;const c=T.forwardRef(l);return c[Oce]=n,c}function Vce({layoutId:n}){const e=T.useContext(JL).id;return e&&n!==void 0?e+"-"+n:n}function Bce(n,e){T.useContext(_j).strict}function zce(n){const e=Ij(),{drag:t,layout:s}=e;if(!t&&!s)return{};const r={...t,...s};return{MeasureLayout:t?.isEnabled(n)||s?.isEnabled(n)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function $ce(n,e){if(typeof Proxy>"u")return tb;const t=new Map,s=(i,a)=>tb(i,a,n,e),r=(i,a)=>s(i,a);return new Proxy(r,{get:(i,a)=>a==="create"?s:(t.has(a)||t.set(a,tb(a,void 0,n,e)),t.get(a))})}const Hce=(n,e)=>e.isSVG??YS(n)?new _le(e):new vle(e,{allowProjection:n!==T.Fragment});class Wce extends bu{constructor(e){super(e),e.animationState||(e.animationState=Rle(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();hy(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:t}=this.node.prevProps||{};e!==t&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let Gce=0;class Kce extends bu{constructor(){super(...arguments),this.id=Gce++,this.isExitComplete=!1}update(){if(!this.node.presenceContext)return;const{isPresent:e,onExitComplete:t}=this.node.presenceContext,{isPresent:s}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===s)return;if(e&&s===!1){if(this.isExitComplete){const{initial:i,custom:a}=this.node.getProps();if(typeof i=="string"||typeof i=="object"&&i!==null&&!Array.isArray(i)){const l=fd(this.node,i,a);if(l){const{transition:c,transitionEnd:d,...h}=l;for(const p in h)this.node.getValue(p)?.jump(h[p])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive("exit",!1);this.isExitComplete=!1;return}const r=this.node.animationState.setActive("exit",!e);t&&!e&&r.then(()=>{this.isExitComplete=!0,t(this.id)})}mount(){const{register:e,onExitComplete:t}=this.node.presenceContext||{};t&&t(this.id),e&&(this.unmount=e(this.id))}unmount(){}}const qce={animation:{Feature:Wce},exit:{Feature:Kce}};function Gm(n){return{point:{x:n.pageX,y:n.pageY}}}const Yce=n=>e=>BS(e)&&n(e,Gm(e));function Hp(n,e,t,s){return _m(n,e,Yce(t),s)}const Lj=({current:n})=>n?n.ownerDocument.defaultView:null,HA=(n,e)=>Math.abs(n-e);function Qce(n,e){const t=HA(n.x,e.x),s=HA(n.y,e.y);return Math.sqrt(t**2+s**2)}const WA=new Set(["auto","scroll"]);class Dj{constructor(e,t,{transformPagePoint:s,contextWindow:r=window,dragSnapToOrigin:i=!1,distanceThreshold:a=3,element:l}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=y=>{this.handleScroll(y.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=g0(this.lastRawMoveEventInfo,this.transformPagePoint));const y=nb(this.lastMoveEventInfo,this.history),x=this.startEvent!==null,w=Qce(y.offset,{x:0,y:0})>=this.distanceThreshold;if(!x&&!w)return;const{point:S}=y,{timestamp:_}=xr;this.history.push({...S,timestamp:_});const{onStart:L,onMove:R}=this.handlers;x||(L&&L(this.lastMoveEvent,y),this.startEvent=this.lastMoveEvent),R&&R(this.lastMoveEvent,y)},this.handlePointerMove=(y,x)=>{this.lastMoveEvent=y,this.lastRawMoveEventInfo=x,this.lastMoveEventInfo=g0(x,this.transformPagePoint),On.update(this.updatePoint,!0)},this.handlePointerUp=(y,x)=>{this.end();const{onEnd:w,onSessionEnd:S,resumeAnimation:_}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&_&&_(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const L=nb(y.type==="pointercancel"?this.lastMoveEventInfo:g0(x,this.transformPagePoint),this.history);this.startEvent&&w&&w(y,L),S&&S(y,L)},!BS(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=s,this.distanceThreshold=a,this.contextWindow=r||window;const c=Gm(e),d=g0(c,this.transformPagePoint),{point:h}=d,{timestamp:p}=xr;this.history=[{...h,timestamp:p}];const{onSessionStart:m}=t;m&&m(e,nb(d,this.history)),this.removeListeners=$m(Hp(this.contextWindow,"pointermove",this.handlePointerMove),Hp(this.contextWindow,"pointerup",this.handlePointerUp),Hp(this.contextWindow,"pointercancel",this.handlePointerUp)),l&&this.startScrollTracking(l)}startScrollTracking(e){let t=e.parentElement;for(;t;){const s=getComputedStyle(t);(WA.has(s.overflowX)||WA.has(s.overflowY))&&this.scrollPositions.set(t,{x:t.scrollLeft,y:t.scrollTop}),t=t.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0}),window.addEventListener("scroll",this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(e){const t=this.scrollPositions.get(e);if(!t)return;const s=e===window,r=s?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},i={x:r.x-t.x,y:r.y-t.y};i.x===0&&i.y===0||(s?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=i.x,this.lastMoveEventInfo.point.y+=i.y):this.history.length>0&&(this.history[0].x-=i.x,this.history[0].y-=i.y),this.scrollPositions.set(e,r),On.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),pu(this.updatePoint)}}function g0(n,e){return e?{point:e(n.point)}:n}function GA(n,e){return{x:n.x-e.x,y:n.y-e.y}}function nb({point:n},e){return{point:n,delta:GA(n,jj(e)),offset:GA(n,Xce(e)),velocity:Jce(e,.1)}}function Xce(n){return n[0]}function jj(n){return n[n.length-1]}function Jce(n,e){if(n.length<2)return{x:0,y:0};let t=n.length-1,s=null;const r=jj(n);for(;t>=0&&(s=n[t],!(r.timestamp-s.timestamp>sa(e)));)t--;if(!s)return{x:0,y:0};s===n[0]&&n.length>2&&r.timestamp-s.timestamp>sa(e)*2&&(s=n[1]);const i=Sa(r.timestamp-s.timestamp);if(i===0)return{x:0,y:0};const a={x:(r.x-s.x)/i,y:(r.y-s.y)/i};return a.x===1/0&&(a.x=0),a.y===1/0&&(a.y=0),a}function Zce(n,{min:e,max:t},s){return e!==void 0&&n<e?n=s?Dn(e,n,s.min):Math.max(n,e):t!==void 0&&n>t&&(n=s?Dn(t,n,s.max):Math.min(n,t)),n}function KA(n,e,t){return{min:e!==void 0?n.min+e:void 0,max:t!==void 0?n.max+t-(n.max-n.min):void 0}}function eue(n,{top:e,left:t,bottom:s,right:r}){return{x:KA(n.x,t,r),y:KA(n.y,e,s)}}function qA(n,e){let t=e.min-n.min,s=e.max-n.max;return e.max-e.min<n.max-n.min&&([t,s]=[s,t]),{min:t,max:s}}function tue(n,e){return{x:qA(n.x,e.x),y:qA(n.y,e.y)}}function nue(n,e){let t=.5;const s=ni(n),r=ni(e);return r>s?t=Sm(e.min,e.max-s,n.min):s>r&&(t=Sm(n.min,n.max-r,e.min)),tl(0,1,t)}function sue(n,e){const t={};return e.min!==void 0&&(t.min=e.min-n.min),e.max!==void 0&&(t.max=e.max-n.min),t}const Hw=.35;function rue(n=Hw){return n===!1?n=0:n===!0&&(n=Hw),{x:YA(n,"left","right"),y:YA(n,"top","bottom")}}function YA(n,e,t){return{min:QA(n,e),max:QA(n,t)}}function QA(n,e){return typeof n=="number"?n:n[e]||0}const iue=new WeakMap;class aue{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=$s(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:t=!1,distanceThreshold:s}={}){const{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;const i=p=>{t&&this.snapToCursor(Gm(p).point),this.stopAnimation()},a=(p,m)=>{const{drag:y,dragPropagation:x,onDragStart:w}=this.getProps();if(y&&!x&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Uoe(y),!this.openDragLock))return;this.latestPointerEvent=p,this.latestPanInfo=m,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),jo(_=>{let L=this.getAxisMotionValue(_).get()||0;if(Ko.test(L)){const{projection:R}=this.visualElement;if(R&&R.layout){const M=R.layout.layoutBox[_];M&&(L=ni(M)*(parseFloat(L)/100))}}this.originPoint[_]=L}),w&&On.update(()=>w(p,m),!1,!0),jw(this.visualElement,"transform");const{animationState:S}=this.visualElement;S&&S.setActive("whileDrag",!0)},l=(p,m)=>{this.latestPointerEvent=p,this.latestPanInfo=m;const{dragPropagation:y,dragDirectionLock:x,onDirectionLock:w,onDrag:S}=this.getProps();if(!y&&!this.openDragLock)return;const{offset:_}=m;if(x&&this.currentDirection===null){this.currentDirection=lue(_),this.currentDirection!==null&&w&&w(this.currentDirection);return}this.updateAxis("x",m.point,_),this.updateAxis("y",m.point,_),this.visualElement.render(),S&&On.update(()=>S(p,m),!1,!0)},c=(p,m)=>{this.latestPointerEvent=p,this.latestPanInfo=m,this.stop(p,m),this.latestPointerEvent=null,this.latestPanInfo=null},d=()=>{const{dragSnapToOrigin:p}=this.getProps();(p||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:h}=this.getProps();this.panSession=new Dj(e,{onSessionStart:i,onStart:a,onMove:l,onSessionEnd:c,resumeAnimation:d},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:h,distanceThreshold:s,contextWindow:Lj(this.visualElement),element:this.visualElement.current})}stop(e,t){const s=e||this.latestPointerEvent,r=t||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!r||!s)return;const{velocity:a}=r;this.startAnimation(a);const{onDragEnd:l}=this.getProps();l&&On.postRender(()=>l(s,r))}cancel(){this.isDragging=!1;const{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:s}=this.getProps();!s&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t&&t.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,t,s){const{drag:r}=this.getProps();if(!s||!x0(e,r,this.currentDirection))return;const i=this.getAxisMotionValue(e);let a=this.originPoint[e]+s[e];this.constraints&&this.constraints[e]&&(a=Zce(a,this.constraints[e],this.elastic[e])),i.set(a)}resolveConstraints(){const{dragConstraints:e,dragElastic:t}=this.getProps(),s=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,r=this.constraints;e&&_h(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&s?this.constraints=eue(s.layoutBox,e):this.constraints=!1,this.elastic=rue(t),r!==this.constraints&&!_h(e)&&s&&this.constraints&&!this.hasMutatedConstraints&&jo(i=>{this.constraints!==!1&&this.getAxisMotionValue(i)&&(this.constraints[i]=sue(s.layoutBox[i],this.constraints[i]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!_h(e))return!1;const s=e.current,{projection:r}=this.visualElement;if(!r||!r.layout)return!1;r.root&&(r.root.scroll=void 0,r.root.updateScroll());const i=fle(s,r.root,this.visualElement.getTransformPagePoint());let a=tue(r.layout.layoutBox,i);if(t){const l=t(ule(a));this.hasMutatedConstraints=!!l,l&&(a=nj(l))}return a}startAnimation(e){const{drag:t,dragMomentum:s,dragElastic:r,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:l}=this.getProps(),c=this.constraints||{},d=jo(h=>{if(!x0(h,t,this.currentDirection))return;
137let p=c&&c[h]||{};(a===!0||a===h)&&(p={min:0,max:0});const m=r?200:1e6,y=r?40:1e7,x={type:"inertia",velocity:s?e[h]:0,bounceStiffness:m,bounceDamping:y,timeConstant:750,restDelta:1,restSpeed:10,...i,...p};return this.startAxisValueAnimation(h,x)});return Promise.all(d).then(l)}startAxisValueAnimation(e,t){const s=this.getAxisMotionValue(e);return jw(this.visualElement,e),s.start(MS(e,s,0,t,this.visualElement,!1))}stopAnimation(){jo(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){const t=`_drag${e.toUpperCase()}`,r=this.visualElement.getProps()[t];return r||this.visualElement.getValue(e,this.visualElement.latestValues[e]??0)}snapToCursor(e){jo(t=>{const{drag:s}=this.getProps();if(!x0(t,s,this.currentDirection))return;const{projection:r}=this.visualElement,i=this.getAxisMotionValue(t);if(r&&r.layout){const{min:a,max:l}=r.layout.layoutBox[t],c=i.get()||0;i.set(e[t]-Dn(a,l,.5)+c)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:t}=this.getProps(),{projection:s}=this.visualElement;if(!_h(t)||!s||!this.constraints)return;this.stopAnimation();const r={x:0,y:0};jo(a=>{const l=this.getAxisMotionValue(a);if(l&&this.constraints!==!1){const c=l.get();r[a]=nue({min:c,max:c},this.constraints[a])}});const{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},""):"none",s.root&&s.root.updateScroll(),s.updateLayout(),this.constraints=!1,this.resolveConstraints(),jo(a=>{if(!x0(a,e,null))return;const l=this.getAxisMotionValue(a),{min:c,max:d}=this.constraints[a];l.set(Dn(c,d,r[a]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;iue.set(this.visualElement,this);const e=this.visualElement.current,t=Hp(e,"pointerdown",d=>{const{drag:h,dragListener:p=!0}=this.getProps(),m=d.target,y=m!==e&&Woe(m);h&&p&&!y&&this.start(d)});let s;const r=()=>{const{dragConstraints:d}=this.getProps();_h(d)&&d.current&&(this.constraints=this.resolveRefConstraints(),s||(s=oue(e,d.current,()=>this.scalePositionWithinConstraints())))},{projection:i}=this.visualElement,a=i.addEventListener("measure",r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),On.read(r);const l=_m(window,"resize",()=>this.scalePositionWithinConstraints()),c=i.addEventListener("didUpdate",(({delta:d,hasLayoutChanged:h})=>{this.isDragging&&h&&(jo(p=>{const m=this.getAxisMotionValue(p);m&&(this.originPoint[p]+=d[p].translate,m.set(m.get()+d[p].translate))}),this.visualElement.render())}));return()=>{l(),t(),a(),c&&c(),s&&s()}}getProps(){const e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:s=!1,dragPropagation:r=!1,dragConstraints:i=!1,dragElastic:a=Hw,dragMomentum:l=!0}=e;return{...e,drag:t,dragDirectionLock:s,dragPropagation:r,dragConstraints:i,dragElastic:a,dragMomentum:l}}}function XA(n){let e=!0;return()=>{if(e){e=!1;return}n()}}function oue(n,e,t){const s=aA(n,XA(t)),r=aA(e,XA(t));return()=>{s(),r()}}function x0(n,e,t){return(e===!0||e===n)&&(t===null||t===n)}function lue(n,e=10){let t=null;return Math.abs(n.y)>e?t="y":Math.abs(n.x)>e&&(t="x"),t}class cue extends bu{constructor(e){super(e),this.removeGroupControls=Ta,this.removeListeners=Ta,this.controls=new aue(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Ta}update(){const{dragControls:e}=this.node.getProps(),{dragControls:t}=this.node.prevProps||{};e!==t&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const sb=n=>(e,t)=>{n&&On.update(()=>n(e,t),!1,!0)};class uue extends bu{constructor(){super(...arguments),this.removePointerDownListener=Ta}onPointerDown(e){this.session=new Dj(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Lj(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:t,onPan:s,onPanEnd:r}=this.node.getProps();return{onSessionStart:sb(e),onStart:sb(t),onMove:sb(s),onEnd:(i,a)=>{delete this.session,r&&On.postRender(()=>r(i,a))}}}mount(){this.removePointerDownListener=Hp(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let rb=!1;class due extends T.Component{componentDidMount(){const{visualElement:e,layoutGroup:t,switchLayoutGroup:s,layoutId:r}=this.props,{projection:i}=e;i&&(t.group&&t.group.add(i),s&&s.register&&r&&s.register(i),rb&&i.root.didUpdate(),i.addEventListener("animationComplete",()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),q0.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:t,visualElement:s,drag:r,isPresent:i}=this.props,{projection:a}=s;return a&&(a.isPresent=i,e.layoutDependency!==t&&a.setOptions({...a.options,layoutDependency:t}),rb=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==i?a.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?a.promote():a.relegate()||On.postRender(()=>{const l=a.getStack();(!l||!l.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{visualElement:e,layoutAnchor:t}=this.props,{projection:s}=e;s&&(s.options.layoutAnchor=t,s.root.didUpdate(),VS.postRender(()=>{!s.currentAnimation&&s.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:t,switchLayoutGroup:s}=this.props,{projection:r}=e;rb=!0,r&&(r.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(r),s&&s.deregister&&s.deregister(r))}safeToRemove(){const{safeToRemove:e}=this.props;e&&e()}render(){return null}}function Oj(n){const[e,t]=yce(),s=T.useContext(JL);return o.jsx(due,{...n,layoutGroup:s,switchLayoutGroup:T.useContext(Pj),isPresent:e,safeToRemove:t})}const hue={pan:{Feature:uue},drag:{Feature:cue,ProjectionNode:Ej,MeasureLayout:Oj}};function JA(n,e,t){const{props:s}=n;n.animationState&&s.whileHover&&n.animationState.setActive("whileHover",t==="Start");const r="onHover"+t,i=s[r];i&&On.postRender(()=>i(e,Gm(e)))}class fue extends bu{mount(){const{current:e}=this.node;e&&(this.unmount=Boe(e,(t,s)=>(JA(this.node,s,"Start"),r=>JA(this.node,r,"End"))))}unmount(){}}class pue extends bu{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=$m(_m(this.node.current,"focus",()=>this.onFocus()),_m(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function ZA(n,e,t){const{props:s}=n;if(n.current instanceof HTMLButtonElement&&n.current.disabled)return;n.animationState&&s.whileTap&&n.animationState.setActive("whileTap",t==="Start");const r="onTap"+(t==="End"?"":t),i=s[r];i&&On.postRender(()=>i(e,Gm(e)))}class mue extends bu{mount(){const{current:e}=this.node;if(!e)return;const{globalTapTarget:t,propagate:s}=this.node.props;this.unmount=Koe(e,(r,i)=>(ZA(this.node,i,"Start"),(a,{success:l})=>ZA(this.node,a,l?"End":"Cancel")),{useGlobalTarget:t,stopPropagation:s?.tap===!1})}unmount(){}}const Ww=new WeakMap,ib=new WeakMap,gue=n=>{const e=Ww.get(n.target);e&&e(n)},xue=n=>
137{n.forEach(gue)};function yue({root:n,...e}){const t=n||document;ib.has(t)||ib.set(t,{});const s=ib.get(t),r=JSON.stringify(e);return s[r]||(s[r]=new IntersectionObserver(xue,{root:n,...e})),s[r]}function vue(n,e,t){const s=yue(e);return Ww.set(n,t),s.observe(n),()=>{Ww.delete(n),s.unobserve(n)}}const bue={some:0,all:1};class wue extends bu{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.stopObserver?.();const{viewport:e={}}=this.node.getProps(),{root:t,margin:s,amount:r="some",once:i}=e,a={root:t?t.current:void 0,rootMargin:s,threshold:typeof r=="number"?r:bue[r]},l=c=>{const{isIntersecting:d}=c;if(this.isInView===d||(this.isInView=d,i&&!d&&this.hasEnteredView))return;d&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",d);const{onViewportEnter:h,onViewportLeave:p}=this.node.getProps(),m=d?h:p;m&&m(c)};this.stopObserver=vue(this.node.current,a,l)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:t}=this.node;["amount","margin","root"].some(Sue(e,t))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}}function Sue({viewport:n={}},{viewport:e={}}={}){return t=>n[t]!==e[t]}const Eue={inView:{Feature:wue},tap:{Feature:mue},focus:{Feature:pue},hover:{Feature:fue}},Tue={layout:{ProjectionNode:Ej,MeasureLayout:Oj}},_ue={...qce,...Eue,...hue,...Tue},Iue=$ce(_ue,Hce);function Aue(){!WS.current&&ZD();const[n]=T.useState(X1.current);return n}function $u({thumbnailSrc:n,title:e,subtitle:t,description:s,badge:r,isFirst:i,onClick:a,onKeyDown:l}){const[c,d]=T.useState(!1),h=T.useRef(null),p=Aue(),m=T.useCallback(()=>{h.current=setTimeout(()=>d(!0),380)},[]),y=T.useCallback(()=>{h.current&&clearTimeout(h.current),d(!1)},[]);return o.jsxs(Iue.div,{tabIndex:0,role:"button","aria-label":`Open ${e}`,className:"content-card genre-scroll-card","data-expanded":c?"true":void 0,style:{position:"relative",background:"#1a1a1a",borderRadius:12,cursor:"pointer",border:c?"1px solid rgba(74, 222, 128, 0.72)":"1px solid rgba(255,255,255,0.1)",transformOrigin:i?"left top":"center top",zIndex:c?12:1,boxShadow:c?"0 20px 44px rgba(0,0,0,0.52), 0 0 0 1px rgba(74,222,128,0.18)":"0 4px 16px rgba(0,0,0,0.18)",overflow:"hidden",flexShrink:0},onClick:a,onKeyDown:l,onMouseEnter:m,onMouseLeave:y,onFocus:()=>d(!0),onBlur:()=>d(!1),initial:!1,animate:{y:c?-6:0,scale:c?1.025:1},transition:{...p?{duration:0}:{type:"spring",stiffness:400,damping:30,mass:.72}},whileTap:p?void 0:{scale:.985},children:[o.jsxs("div",{style:{aspectRatio:"16/9",borderRadius:"11px 11px 0 0",overflow:"hidden",position:"relative",background:"#2a2a2a",transition:"border-radius 0.15s ease"},children:[n?o.jsx("img",{src:n,alt:e,loading:i?"eager":"lazy",decoding:"async",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"},onError:x=>{x.target.style.display="none"}}):o.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",color:"#4ade80",fontSize:"clamp(12px, 2vw, 16px)",fontWeight:"bold",padding:8,textAlign:"center"},children:"Thumbnail Coming Soon"}),o.jsx("div",{style:{position:"absolute",inset:0,background:"linear-gradient(180deg, rgba(0,0,0,0.06), rgba(0,0,0,0.72))",display:"flex",alignItems:"center",justifyContent:"center",opacity:c?1:0,transition:"opacity 0.2s ease",pointerEvents:"none"},children:o.jsx("div",{style:{width:46,height:46,borderRadius:"50%",background:"rgba(255,255,255,0.92)",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 2px 12px rgba(0,0,0,0.5)"},children:o.jsx(Bc,{size:18,fill:"#111",color:"#111",style:{marginLeft:2}})})}),r&&o.jsx("div",{className:"genre-scroll-card__info",style:{position:"absolute",top:6,right:6,background:r==="LIVE"?"#FF0000":"#4ade80",color:r==="LIVE"?"white":"#000",fontSize:9,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",textTransform:"uppercase"},children:r})]}),o.jsx("div",{className:"genre-scroll-card__media",style:{background:"#1e1e1e",padding:"6px 10px",borderTop:"1px solid #2a2a2a"},children:o.jsx("h3",{style:{fontSize:11,fontWeight:700,color:"white",margin:0,lineHeight:1.3,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e})}),o.jsxs("div",{style:{background:"#1e1e1e",borderRadius:"0 0 8px 8px",padding:t||s?"0 10px 9px":"0 10px",maxHeight:c?100:t?34:0,overflow:"hidden",transition:"max-height 0.25s ease, padding 0.15s ease"}
137,children:[t&&o.jsx("p",{style:{fontSize:10,color:"#4ade80",margin:"0 0 4px",fontWeight:600},children:t}),s&&o.jsx("p",{style:{fontSize:10,color:"#aaa",margin:0,lineHeight:1.4,display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden"},children:s})]})]})}function y0({children:n,ariaLabel:e="Scrollable content row"}){const t=T.useRef(null),[s,r]=T.useState(!1),[i,a]=T.useState(!1),[l,c]=T.useState(!1),d=T.useCallback(()=>{const y=t.current;y&&(r(y.scrollLeft>4),a(y.scrollLeft<y.scrollWidth-y.clientWidth-4))},[]);T.useEffect(()=>{const y=t.current;if(!y)return;d(),y.addEventListener("scroll",d,{passive:!0});const x=new ResizeObserver(d);return x.observe(y),()=>{y.removeEventListener("scroll",d),x.disconnect()}},[d]);const h=T.useCallback(y=>{const x=t.current;x&&(Math.abs(y.deltaX)>Math.abs(y.deltaY)||(y.preventDefault(),x.scrollLeft+=y.deltaY*1.5))},[]),p=T.useCallback(y=>{const x=t.current;if(!x)return;const w=x.clientWidth*.75;x.scrollBy({left:y==="left"?-w:w,behavior:"smooth"})},[]),m=T.useCallback(y=>{y.currentTarget===y.target&&(y.key==="ArrowRight"||y.key==="ArrowLeft")&&(y.preventDefault(),p(y.key==="ArrowRight"?"right":"left"))},[p]);return o.jsxs("div",{className:"scroll-row-shell",style:{position:"relative"},onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),onFocus:()=>c(!0),onBlur:y=>{y.currentTarget.contains(y.relatedTarget)||c(!1)},children:[o.jsx("div",{className:"scroll-row-toolbar",children:o.jsxs("button",{type:"button",className:"scroll-row-browse",onClick:()=>p("right"),disabled:!i,"aria-label":i?`Browse more ${e.toLowerCase()}`:`All ${e.toLowerCase()} visible`,children:[o.jsx("span",{children:"Browse collection"}),o.jsx(Uc,{size:14,"aria-hidden":"true"})]})}),s&&o.jsx("button",{onClick:()=>p("left"),type:"button",className:"scroll-row-control scroll-row-control--left",style:{position:"absolute",left:0,top:"50%",transform:"translateY(-50%)",zIndex:80,background:"rgba(0,0,0,0.75)",border:"1px solid rgba(255,255,255,0.15)",borderRadius:"50%",width:36,height:36,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",color:"white",backdropFilter:"blur(4px)",transition:"opacity 0.2s ease",marginLeft:4},"aria-label":"Scroll left",children:o.jsx(md,{size:20})}),i&&o.jsx("button",{onClick:()=>p("right"),type:"button",className:"scroll-row-control scroll-row-control--right",style:{position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",zIndex:80,background:"rgba(0,0,0,0.75)",border:"1px solid rgba(255,255,255,0.15)",borderRadius:"50%",width:36,height:36,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",color:"white",backdropFilter:"blur(4px)",transition:"opacity 0.2s ease",marginRight:4},"aria-label":"Scroll right",children:o.jsx(Uc,{size:20})}),i&&o.jsx("div",{style:{position:"absolute",right:0,top:0,bottom:0,width:80,background:"linear-gradient(to right, transparent, #0a0a0a 90%)",pointerEvents:"none",zIndex:70,transition:"opacity 0.3s ease",opacity:l?1:.6}}),s&&o.jsx("div",{style:{position:"absolute",left:0,top:0,bottom:0,width:60,background:"linear-gradient(to left, transparent, #0a0a0a 90%)",pointerEvents:"none",zIndex:70,transition:"opacity 0.3s ease",opacity:l?1:.5}}),o.jsx("div",{ref:t,className:"scroll-row",onWheel:h,onKeyDown:m,tabIndex:0,role:"region","aria-label":e,children:n})]})}const No=sl("PushNotifications",{}),e7="chronictv_push_registered",ab="chronictv_push_token";function Cue(){const[n,e]=T.useState({isSupported:!1,isRegistered:!1,listenersReady:!1,token:null,error:null}),[,t]=Xl(),s=T.useRef(!1),r=T.useCallback(async a=>{try{const l=Zr.getPlatform();(await fetch("/api/notifications/register",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:a,platform:l})})).ok&&(localStorage.setItem(e7,"true"),localStorage.setItem(ab,a),e(d=>({...d,isRegistered:!0,token:a})))}catch{}},[]),i=T.useCallback(async()=>{if(!Zr.isNativePlatform())return!1;if(n.isRegistered&&n.token)return!0;s.current||await new Promise(a=>{const l=()=>{s.current?a():setTimeout(l,100)};l()});try{const a=await No.checkPermissions();if(a.receive==="prompt"){if((await No.requestPermissions()).receive!=="granted")return e(c=>({...c,error:"Permission denied"})),!1}else if(a.receive!=="granted")return e(l=>({...l,error:"Permission denied"})),!1;return await No.register(),!0}catch(a){return e(l=>({...l,error:String(a)})),!1}},[n.isRegistered,n.token]);return T.useEffect(()=>{const a=Zr.isNativePlatform();return e(c=>({...c,isSupported:a})),a?((async()=>
137{if(await No.addListener("registration",d=>{r(d.value)}),await No.addListener("registrationError",d=>{e(h=>({...h,error:d.error}))}),await No.addListener("pushNotificationReceived",d=>{}),await No.addListener("pushNotificationActionPerformed",d=>{d.notification.data?.type==="new_content"&&t("/")}),s.current=!0,e(d=>({...d,listenersReady:!0})),(await No.checkPermissions()).receive==="granted"){const d=localStorage.getItem(ab);d&&e(h=>({...h,isRegistered:!0,token:d})),await No.register()}else localStorage.removeItem(e7),localStorage.removeItem(ab)})(),()=>{No.removeAllListeners(),s.current=!1}):void 0},[r,t]),{...n,requestPermission:i}}function Lo(n){return{id:n.id,title:n.customTitle||n.extractedTitle||n.title||n.name||"Episode",videoUrl:n.embedUrl||n.videoUrl||n.video_url,embedUrl:n.embedUrl||n.videoUrl||n.video_url,sourceUrl:n.embedUrl||n.videoUrl||n.video_url,thumbnailUrl:n.thumbnailUrl||n.extractedThumbnail||n.thumbnail_url,description:n.extractedDescription||n.description||"Episode from ChronicTV",duration:n.extractedDuration||n.duration,channelName:n.extractedChannelName||n.channelName||n.channel_name,platform:n.platform,platformVideoId:n.platformVideoId,categoryName:n.categoryName,videoId:n.id,vimeoUrl:n.vimeoUrl,video_url:n.video_url,url:n.url}}function so(n){if(n.thumbnailUrl)return n.thumbnailUrl;if(n.extractedThumbnail)return n.extractedThumbnail;if(n.thumbnail)return n.thumbnail;if(n.pictures?.sizes&&Array.isArray(n.pictures.sizes)){const e=n.pictures.sizes,t=e.filter(s=>s.width>=320).sort((s,r)=>s.width-r.width)[0]||e[e.length-1];return t?.link_with_play_button||t?.link||null}return null}function Gw(n,e){const t=(n||[]).filter(a=>!a.isSeasonFolder),s=(e||[]).filter(a=>!a.hidden),r=new Set(s.flatMap(a=>(a.categoryIds||[]).map(l=>String(l))));return(r.size?t.filter(a=>r.has(String(a.id))):t).filter(a=>a.thumbnailUrl).filter((a,l,c)=>c.findIndex(d=>String(d.id)===String(a.id))===l).slice(0,20)}function kue(n,e){const t=(n||[]).filter(r=>r.categoryIds?.includes("25532412")),s=(e||[]).filter(r=>String(r.categoryAssignment||"").toUpperCase()==="MOVIES");return[...t,...s].filter(r=>so(r)).filter((r,i,a)=>a.findIndex(l=>String(l.id)===String(r.id))===i)}function Rue(n,e,t,s){const r=Gw(n,e),i=kue(t,s).map(a=>({...a,thumbnailUrl:so(a)}));return[...r,...i].filter(a=>a.thumbnailUrl).filter((a,l,c)=>c.findIndex(d=>String(d.id)===String(a.id))===l).slice(0,12)}function ob({items:n}){if(!n.length)return null;const e=[-7,4,-3,6,-5,3,-6,5,-2,7,-4,2,-8,5,-3,8,-6,4,-5,2],t=[["-42px","-180px","24deg"],["34px","-220px","-31deg"],["76px","-150px","18deg"],["-78px","-200px","-20deg"],["28px","-245px","29deg"],["92px","-175px","-26deg"],["-52px","-210px","17deg"],["38px","-190px","-22deg"],["-90px","-230px","26deg"],["68px","-195px","-18deg"],["-24px","-255px","34deg"],["105px","-165px","-28deg"],["-110px","-185px","22deg"],["54px","-235px","-27deg"],["-16px","-205px","31deg"],["118px","-215px","-19deg"],["-64px","-260px","25deg"],["86px","-195px","-24deg"],["-100px","-160px","16deg"],["12px","-240px","-34deg"]];return o.jsx("div",{className:"catalog-hero__wall","aria-hidden":"true",children:n.map((s,r)=>o.jsx("div",{className:"catalog-hero__wall-tile",style:{"--tile-rotate":`${e[r%e.length]}deg`,"--tile-delay":`${r*85}ms`,"--tile-drop-x":t[r%t.length][0],"--tile-drop-y":t[r%t.length][1],"--tile-drop-rotate":t[r%t.length][2]},children:o.jsx("img",{src:Eh(s.thumbnailUrl),alt:"",loading:"lazy",decoding:"async"})},`${s.id}-${r}`))})}function Hu(n,e,t,s,r){n.name;const i=e?.filter(x=>x.categoryIds?.includes(n.id)||x.channelName===n.name||x.subcategoryAssignment===n.name)||[],a=n.containerFolder?.toLowerCase()==="channels"?"CHANNELS":n.containerFolder?.toLowerCase()==="movies"?"MOVIES":"ORIGINALS",l=t?.filter(x=>x.categoryAssignment===a&&x.subcategoryAssignment===n.name)||[],c=s?.filter(x=>x.parentCategoryId===n.id)||[],d=String(n.id),h=r?.filter(x=>String(x.categoryId)===d).length||0;n.name;let p=0;
137c.forEach(x=>{const w=e?.filter(S=>S.categoryIds?.includes(x.id)||S.channelName===x.name||S.subcategoryAssignment===x.name)||[];p+=w.length});const m=i.length+l.length+p,y=c.length;return{totalEpisodes:m,seasonCount:y,albumCount:h,directEpisodes:i.length,urlEpisodes:l.length,seasonEpisodes:p,seasons:c}}function Pue({skipSplash:n=!1,initialShowSlug:e,initialVideoId:t}){const[s,r]=T.useState("NOW_PLAYING"),[i,a]=T.useState(""),[l,c]=T.useState(null),[d,h]=T.useState(null),[p,m]=T.useState([]),[y,x]=T.useState(!n),[w,S]=T.useState(null),[_,L]=T.useState([]),[R,M]=T.useState([]),[V,W]=T.useState(!1),{isSupported:I,isRegistered:k,requestPermission:P}=Cue(),[N,F]=T.useState(!1),[z,U]=T.useState(!1),[fe,oe]=T.useState(typeof window<"u"&&window.innerWidth<768),X=Zr.isNativePlatform(),[Q,G]=T.useState(!1),[Y,ee]=T.useState(!1),[H,K]=T.useState(!1),[pe,Fe]=T.useState(!1),[_e,ze]=T.useState(!1),[Ye,tt]=T.useState(!1),[lt,ut]=T.useState(!1),[cn,ke]=T.useState(!1),[Ue,rt]=T.useState({street:"",city:"",state:"",zipCode:"",country:"United States"}),[Ct,at]=T.useState(!1),[ft,Nt]=T.useState([]),[At,ot]=T.useState(!1),[Yt,zt]=T.useState(!1),[wn,Dt]=T.useState(null),[Ee,He]=T.useState(null),[le,ne]=T.useState({cardNumber:"",expMonth:"",expYear:"",cvv:"",cardholderName:"",street:"",city:"",state:"",zipCode:""}),[J,De]=T.useState(!1),[Le,Lt]=T.useState([]),[Qe,it]=T.useState(!1),[Cn,Mn]=T.useState(!1),[Gn,ii]=T.useState([]),[ai,Fs]=T.useState(!1),[os,vn]=T.useState(!1),[ln,Qs]=T.useState("cultured"),[Tr,hr]=T.useState(null),[Na,Xs]=T.useState(!1),[oi,_r]=T.useState(!1),[es,Ir]=T.useState(""),[Ar,Re]=T.useState(!1),[St,Un]=T.useState(!1),[Vn,La]=T.useState(!1),[Br,Da]=T.useState(!1),[Rn,Te]=T.useState(null),[pt,ys]=T.useState(!1),[fr,zr]=T.useState(!1),[ja,ia]=T.useState(!1),[rl,Li]=T.useState(!1),[xn,il]=T.useState(!1),[al,Oa]=T.useState(null),[go,tc]=T.useState(null),[ol,xo]=T.useState(null),[Sn,Ma]=T.useState("signin"),[As,$r]=T.useState(""),[Cr,Fa]=T.useState(""),[li,Ua]=T.useState(""),[un,aa]=T.useState(""),[yo,vo]=T.useState(""),[Di,nc]=T.useState(!1),[sc,ls]=T.useState(""),[Us,Hr]=T.useState(!1),[Qt,Va]=T.useState(!1),[wu,bo]=T.useState(!1),[rc,Su]=T.useState(""),[Xt,Kn]=T.useState(null),[Pn,rn]=T.useState(null),[Js,an]=T.useState(!1),[Ba,oa]=T.useState(!1),[Zs,la]=T.useState(!1),[ji,er]=T.useState(5),[Oi,Mi]=T.useState(null),[En,ic]=T.useState(0),[Fd,ca]=T.useState(!1),[Fi,Ui]=T.useState(!1),Vi=T.useRef(null),[tr,ua]=T.useState(null),[ll,ci]=T.useState(!1),[wo,da]=T.useState(!1),[pr,ui]=T.useState(!1),[Wr,za]=T.useState(""),[$a,Bi]=T.useState(!1),[ac,ts]=T.useState(""),[vs,cl]=T.useState({}),[So,oc]=T.useState({}),[di,lc]=T.useState(new Set),[bs,ul]=T.useState(new Set),[nr,Ud]=T.useState({originals:null,channels:null,movies:null}),[dl,cc]=T.useState({}),ws=T.useRef(()=>!1),uc=T.useRef(null),Eu=T.useRef(!1);T.useEffect(()=>{ws.current=()=>{if(Js){if(an(!1),rn(null),Xt){const D=Xt.name.trim().toLowerCase().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-");window.history.pushState({screen:"show"},"",`/chronictv/${D}`)}else window.history.pushState({},"","/chronictv");return!0}else{if(Xt)return Kn(null),window.history.pushState({},"","/chronictv"),!0;if(Ba)return oa(!1),!0;if(tr?.show)return ua(null),!0;if(wo)return da(!1),!0;if(pr)return ui(!1),za(""),ts(""),!0;if(ll)return ci(!1),!0;if(s!=="NOW_PLAYING")return r("NOW_PLAYING"),!0}return!1}},[Js,Xt,Ba,tr,wo,pr,ll,s]),T.useEffect(()=>{let D=!0;return(async()=>
137{if(D)try{if(await Pie.initialize(),await H1.initialize(),!D)return;H1.setupBackButtonNavigation(()=>ws.current?ws.current():!1)}catch{}})(),()=>{D=!1}},[]);const Eo=(D,q,se)=>{const me=new Set,xe={};for(const Be of D){const Ne=Be.showId?String(Be.showId):"";Ne&&me.add(Ne);const mt=Be.showName?q.find(cs=>cs.name===Be.showName):null;mt&&me.add(String(mt.id));const Ut=Ne||(mt?String(mt.id):"");(se[Ut]||[]).forEach(cs=>{xe[cs]=(xe[cs]||0)+1})}return Object.keys(xe).length===0?[]:q.filter(Be=>!me.has(String(Be.id))).map(Be=>{const mt=(se[String(Be.id)]||[]).reduce((Ut,tn)=>Ut+(xe[tn]||0),0);return{...Be,_recScore:mt}}).filter(Be=>Be._recScore>0).sort((Be,Ne)=>Ne._recScore-Be._recScore).slice(0,10)};T.useEffect(()=>{if(vu()){W(!0),ey().catch(se=>{});const q=Md(async se=>{if(se){S(se);const me=await Xb(se.uid);L(me),fm(se.uid,30).then(async Ut=>{if(Ut.length>0){const tn=await NP(),cs=ye?.categories||[],Kt=Eo(Ut,cs,tn);M(Kt)}}).catch(()=>{}),await uu(se.uid);const xe=await zm(se.uid);xe.tier==="premier"&&xe.status==="active"?Qs("premier"):Qs("cultured"),tc(xe.lastRenewalDate||null),xo(xe.nextBillingDate||null);const Be=await q6(se.uid);Te(Be);const Ne=await Q6(se.uid);Li(Ne);const mt=await W6(se);Ir(mt),I&&!k&&P()}else L([]),M([]),Qs("cultured"),Ir(""),Te(null),tc(null),xo(null),Li(!1)});return()=>q()}},[I,k,P]),T.useEffect(()=>{new URLSearchParams(window.location.search).get("signup")==="true"&&!w&&(Ma("signup"),G(!0),window.history.replaceState({},"",window.location.pathname))},[w]),T.useEffect(()=>{if(!V)return;const D=ZP(q=>{lc(q)});return()=>D()},[V]),T.useEffect(()=>{const D=async()=>{try{const se=await fetch("/api/live-shows");if(!se.ok)return;const me=await se.json();me.liveShows&&ul(new Set(me.liveShows.map(xe=>xe.id)))}catch{}};D();const q=setInterval(D,6e4);return()=>clearInterval(q)},[]),T.useEffect(()=>{uc.current&&(uc.current.scrollTop=0)},[Xt,tr,s]),T.useEffect(()=>{Js&&Pn&&w&&we(Pn,0)},[Js,Pn,w]),T.useEffect(()=>(Zs&&ji>0?Vi.current=setTimeout(()=>{er(D=>D-1)},1e3):Zs&&ji===0&&Oi&&(la(!1),er(5),rn(Oi),Mi(null)),()=>{Vi.current&&clearTimeout(Vi.current)}),[Zs,ji,Oi]);const v=[{id:"NOW_PLAYING",icon:oo,label:"Now Playing"},{id:"ORIGINALS",icon:_a,label:"Originals"},{id:"CHANNELS",icon:Bc,label:"Channels"},{id:"MOVIES",icon:G7,label:"Movies"},{id:"SEARCH",icon:jF,label:"Search"}],A=[{name:"Apple",icon:o4,url:"https://apps.apple.com/us/app/chronic-tv/id6757710156",color:"#fff",bg:"#000"},{name:"Google Play",icon:a4,url:"https://play.google.com/store/apps/details?id=com.chronictv2.app&pcampaignid=web_share",color:"#fff",bg:"#0f9d58"},{name:"Xbox",icon:hf,url:"https://apps.microsoft.com/detail/9p3w2zd0kb50?hl=en-us&gl=us&ocid=pdpshare",color:"#fff",bg:"#107c10"},{name:"Roku",icon:i4,url:"https://channelstore.roku.com/details/484ddc36cb4236b7a260cf6dd37459bb:557787d977c35a2d06a4cb75856abd21/chronic-tv",color:"#fff",bg:"#6f1ab1"}];T.useEffect(()=>{const D=()=>oe(window.innerWidth<768);return window.addEventListener("resize",D),()=>window.removeEventListener("resize",D)},[]),T.useEffect(()=>{Promise.all([fetch("/api/content-organization/originals").then(D=>D.json()).catch(()=>({data:null})),fetch("/api/content-organization/channels").then(D=>D.json()).catch(()=>({data:null})),fetch("/api/content-organization/movies").then(D=>D.json()).catch(()=>({data:null}))]).then(([D,q,se])=>{Ud({originals:D.data||null,channels:q.data||null,movies:se.data||null})}).catch(()=>{})},[]),T.useEffect(()=>{const q=[...(nr.originals?.sections||[]).flatMap(se=>se.archiveIds||[]),...(nr.channels?.sections||[]).flatMap(se=>se.archiveIds||[]),...(nr.movies?.sections||[]).flatMap(se=>se.archiveIds||[])].filter(se=>!dl[se]);q.length&&RP(q).then(se=>{const me={};se.forEach(xe=>{me[xe.identifier]=xe}),cc(xe=>({...xe,...me}))}).catch(()=>{})},[nr]);const O=D=>D.trim().toLowerCase().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-"),$=D=>{Kn(D);const q=O(D.name||"show");window.history.pushState({screen:"show",showSlug:q},"",`/chronictv/${q}`)},ue=async(D,q)=>{try{const me=await(await fetch(`/api/archive/stream/${D}`)).json();me.success&&(rn({id:`archive-${D}`,title:me.title||q,videoUrl:me.streamUrl,embedUrl:me.streamUrl,duration:me.duration||0,thumbnailUrl:me.thumbnailUrl,de
137scription:me.description||"",isArchive:!0}),an(!0))}catch{}},we=async(D,q=0)=>{if(!w||!D)return;const se=D.thumbnailUrl||D.pictures?.sizes?.[3]?.link||Eh(D.id),me=D.duration||D.durationSeconds||0,xe=me>0?q/me>.9:!1;await PP(w.uid,{videoId:String(D.id||D.uri?.split("/").pop()),videoTitle:D.name||D.title||"Unknown Video",showName:D.showName||D.channelName||D.categoryName||"",thumbnailUrl:se,progressSeconds:q,durationSeconds:me,watchedAt:new Date,completed:xe});const Be=await Xb(w.uid);L(Be)},Ke=(D,q,se)=>{ua({show:!0,title:D,content:q||`${D} content is loading from Google Drive...`,hasLink:se}),window.history.pushState({screen:"modal",type:"footer"},"",window.location.href)},Ft=D=>{const q=D.replace(/<[^>]*>/g,"").replace(/ /g," ").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').trim();return q.split(` 138`).map((se,me)=>{const xe=[];[{pattern:/(https?:\/\/[^\s,)]+)/g,getUrl:Kt=>Kt.trim()},{pattern:/(www\.[^\s,)]+)/g,getUrl:Kt=>`https://${Kt.trim()}`},{pattern:/([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,})/g,getUrl:Kt=>`mailto:${Kt.trim()}`}].forEach(({pattern:Kt,getUrl:Vs})=>{[...se.matchAll(Kt)].forEach($i=>{if($i.index!==void 0){const Iu=$i[0],Bd=Vs(Iu);xe.push({text:Iu,url:Bd,start:$i.index,end:$i.index+$i[0].length})}})}),xe.sort((Kt,Vs)=>Kt.start-Vs.start);const Ne=xe.filter((Kt,Vs)=>Vs===0?!0:Kt.start>=xe[Vs-1].end),mt=new Set,Ut=Ne.filter(Kt=>{const Vs=Kt.url.replace(/^https?:\/\//,"").replace(/^mailto:/,"").replace(/\/$/,"");return mt.has(Vs)?!1:(mt.add(Vs),!0)});if(Ut.length===0)return o.jsx("div",{style:{marginBottom:me<q.split(` 139`).length-1?"8px":"0"},children:se},me);const tn=[];let cs=0;return Ut.forEach((Kt,Vs)=>{if(Kt.start>cs){const zi=se.substring(cs,Kt.start);tn.push(zi)}if(tn.push(o.jsx("a",{href:Kt.url,target:"_blank",rel:"noopener noreferrer",style:{color:"#4ade80",textDecoration:"underline",cursor:"pointer",fontWeight:"bold"},onClick:zi=>{zi.stopPropagation()},children:Kt.text},`link-${Vs}`)),cs=Kt.end,Vs<Ut.length-1){const zi=Ut[Vs+1];let $i=se.substring(Kt.end,zi.start);$i.trim()?tn.push($i):tn.push(", ")}}),cs<se.length&&tn.push(se.substring(cs)),o.jsx("div",{style:{marginBottom:me<q.split(` 140`).length-1?"8px":"0"},children:tn.map((Kt,Vs)=>o.jsx("span",{children:Kt},Vs))},me)})},pn=()=>{const D=To?.success?To.data?.success?To.data.data:To.data:null;return o.jsxs("footer",{style:{background:"#2a2a2a",padding:"clamp(20px, 4vw, 30px)",marginTop:"clamp(30px, 6vh, 50px)",borderTop:"1px solid #444",paddingBottom:"calc(clamp(20px, 4vw, 30px) + var(--safe-area-inset-bottom, 0px))"},children:[o.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"clamp(20px, 4vw, 40px)",marginBottom:"clamp(15px, 3vh, 20px)",justifyContent:"space-between"},children:[o.jsxs("div",{style:{flex:"1 1 150px",minWidth:"150px"},children:[o.jsx("h4",{style:{fontSize:"clamp(12px, 2vw, 14px)",color:"#4ade80",fontWeight:"bold",margin:"0 0 10px 0"},children:"Browse"}),o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:[o.jsx("button",{onClick:()=>{r("ORIGINALS"),Kn(null)},style:{background:"none",border:"none",color:"#999",fontSize:"clamp(10px, 1.5vw, 12px)",textAlign:"left",cursor:"pointer",padding:"2px 0"},children:"Originals"}),o.jsx("button",{onClick:()=>{r("CHANNELS"),Kn(null)},style:{background:"none",border:"none",color:"#999",fontSize:"clamp(10px, 1.5vw, 12px)",textAlign:"left",cursor:"pointer",padding:"2px 0"},children:"Channels"}),o.jsx("button",{onClick:()=>{r("MOVIES"),Kn(null)},style:{background:"none",border:"none",color:"#999",fontSize:"clamp(10px, 1.5vw, 12px)",textAlign:"left",cursor:"pointer",padding:"2px 0"},children:"Movies"}),o.jsx("button",{onClick:()=>{r("SEARCH"),Kn(null)},style:{background:"none",border:"none",color:"#999",fontSize:"clamp(10px, 1.5vw, 12px)",textAlign:"left",cursor:"pointer",padding:"2px 0"},children:"Search"}),o.jsx("button",{onClick:()=>U(!0),style:{background:"none",border:"none",color:"#999",fontSize:"clamp(10px, 1.5vw, 12px)",textAlign:"left",cursor:"pointer",padding:"2px 0"},children:"Get the App"})]})]}),o.jsxs("div",{style:{flex:"1 1 150px",minWidth:"150px"},children:[o.jsx("h4",{style:{fontSize:"clamp(12px, 2vw, 14px)",color:"#4ade80",fontWeight:"bold",margin:"0 0 10px 0"},children:"About"}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:D?.about?Object.entries(D.about).map(([q,se])=>o.jsx("button",{onClick:()=>Ke(se.title||q.replace(/_/g," ").replace(/\b\w/g,me=>me.toUpperCase()),se.text,se.hasExternalLink),style:{background:"none",border:"none",color:"#999",fontSize:"clamp(10px, 1.5vw, 12px)",textAlign:"left",cursor:"pointer",padding:"2px 0"},children:se.title||q.replace(/_/g," ").replace(/\b\w/g,me=>me.toUpperCase())},q)):o.jsxs(o.Fragment,{children:[o.jsx("span",{style:{color:"#999",fontSize:"clamp(10px, 1.5vw, 12px)",padding:"2px 0"},children:o.jsx(Is,{suffix:" Culture",size:"xs",color:"#999"})}),o.jsx("span",{style:{color:"#999",fontSize:"clamp(10px, 1.5vw, 12px)",padding:"2px 0"},children:"Premium Content"}),o.jsx("span",{style:{color:"#999",fontSize:"clamp(10px, 1.5vw, 12px)",padding:"2px 0"}
140,children:"Creative Community"})]})})]}),o.jsxs("div",{style:{flex:"1 1 150px",minWidth:"150px"},children:[o.jsx("h4",{style:{fontSize:"clamp(12px, 2vw, 14px)",color:"#4ade80",fontWeight:"bold",margin:"0 0 10px 0"},children:"Support"}),o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:[D?.support&&Object.entries(D.support).map(([q,se])=>o.jsx("button",{onClick:()=>Ke(se.title||q.replace(/_/g," ").replace(/\b\w/g,me=>me.toUpperCase()),se.text,se.hasExternalLink),style:{background:"none",border:"none",color:"#999",fontSize:"clamp(10px, 1.5vw, 12px)",textAlign:"left",cursor:"pointer",padding:"2px 0"},children:se.title||q.replace(/_/g," ").replace(/\b\w/g,me=>me.toUpperCase())},q)),o.jsx("a",{href:"/support",style:{background:"none",border:"none",color:"#999",fontSize:"clamp(10px, 1.5vw, 12px)",textAlign:"left",cursor:"pointer",padding:"2px 0",textDecoration:"none"},"data-testid":"chronictv-footer-support-link",children:"Support"}),o.jsx("a",{href:"/activate-chronictv",style:{background:"none",border:"none",color:"#999",fontSize:"clamp(10px, 1.5vw, 12px)",textAlign:"left",cursor:"pointer",padding:"2px 0",textDecoration:"none"},"data-testid":"chronictv-footer-activate-tv-link",children:"Activate TV"})]})]}),o.jsxs("div",{style:{flex:"1 1 150px",minWidth:"150px"},children:[o.jsx("h4",{style:{fontSize:"clamp(12px, 2vw, 14px)",color:"#4ade80",fontWeight:"bold",margin:"0 0 10px 0"},children:"Legal"}),o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:[D?.legal?Object.entries(D.legal).filter(([q,se])=>{const me=q.toLowerCase().trim().replace(/_/g,"").replace(/-/g,"").replace(/\s+/g,""),xe=(se.title||q).toLowerCase().trim().replace(/_/g,"").replace(/-/g,"").replace(/\s+/g,"");return!(me==="privacy"||me==="privacypolicy"||xe==="privacy"||xe==="privacypolicy"||me==="termsandconditions"||xe==="termsandconditions")}).map(([q,se])=>o.jsx("button",{onClick:()=>Ke(se.title||q.replace(/_/g," ").replace(/\b\w/g,me=>me.toUpperCase()),se.text,se.hasExternalLink),style:{background:"none",border:"none",color:"#999",fontSize:"clamp(10px, 1.5vw, 12px)",textAlign:"left",cursor:"pointer",padding:"2px 0"},children:se.title||q.replace(/_/g," ").replace(/\b\w/g,me=>me.toUpperCase())},q)):o.jsx(o.Fragment,{children:o.jsx("button",{onClick:()=>{const q=Vd?.success?Vd.data?.success?Vd.data.data:Vd.data:'Terms and Conditions document not yet configured in Google Drive. Please add content to the "Terms and Conditions" document in your Google Drive ChronicTV(Beta) folder.';Ke("Terms And Conditions",q,!1)},style:{background:"none",border:"none",color:"#999",fontSize:"clamp(10px, 1.5vw, 12px)",textAlign:"left",cursor:"pointer",padding:"2px 0"},children:"Terms And Conditions"})}),o.jsx("button",{"data-testid":"link-privacy-policy",onClick:()=>{da(!0),window.history.pushState({screen:"privacy"},"","/privacy-policy")},style:{background:"none",border:"none",color:"#999",fontSize:"clamp(10px, 1.5vw, 12px)",textAlign:"left",cursor:"pointer",padding:"2px 0"},children:"Privacy Policy"}),o.jsx("button",{"data-testid":"link-delete-account",onClick:()=>{ui(!0),za(""),ts(""),window.history.pushState({screen:"delete-account"},"","/delete-account")},style:{background:"none",border:"none",color:"#999",fontSize:"clamp(10px, 1.5vw, 12px)",textAlign:"left",cursor:"pointer",padding:"2px 0"},children:"Delete Account"})]})]}),o.jsxs("div",{style:{flex:"1 1 150px",minWidth:"150px"},children:[o.jsx("h4",{style:{fontSize:"clamp(12px, 2vw, 14px)",color:"#4ade80",fontWeight:"bold",margin:"0 0 10px 0"},children:"Chronic Games"}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:o.jsx("a",{href:"/chronic-games","data-testid":"link-chronic-games",onClick:q=>{q.preventDefault(),window.location.href="/chronic-games"},style:{background:"none",border:"none",color:"#999",fontSize:"clamp(10px, 1.5vw, 12px)",textAlign:"left",cursor:"pointer",padding:"2px 0",textDecoration:"none"},children:"View Games Library"})})]})]}),o.jsxs("div",{style:{fontSize:"clamp(9px, 1.2vw, 11px)",color:"#666",lineHeight:1.4},children:[o.jsx("p",{style:{margin:"0 0 8px 0"},children:"© 2025 ChronicTV. Premium Culture, Content, and Creativity."}),o.jsx("p",{style:{margin:0},children:"Streaming Creativity, Culture, Content Worldwide."})]})]})},{data:ye,isLoading:qn,error:sr,refetch:Ha}=gn({queryKey:["/api/startup-bundle"],staleTime:0,refetchOnMount:"always",gcTime:1e3*60*60*2,refetchOnWindowFocus:!1,refetchInterval:!1,refetchIntervalInBackgroun
140d:!1,retry:1,queryFn:async()=>await Tu()}),ns=D=>(D||"").toLowerCase().replace(/[^\w\s]/g,"").replace(/\s+/g," ").trim();T.useEffect(()=>{if(e&&ye?.categories&&!Eu.current){Eu.current=!0;const D=ns(e.replace(/-/g," ")),q=ye.categories.find(se=>ns(se.name||"")===D);if(q)Kn(q),r("ORIGINALS");else{const se=e.replace(/-/g," ");a(se),r("SEARCH"),window.history.replaceState({},"","/chronictv")}}},[e,ye?.categories]),T.useEffect(()=>{const q=window.location.pathname.match(/^\/(?:chronictv\/)?watch\/([^/]+)\/([^/]+)/),se=q?decodeURIComponent(q[1]).replace(/-/g," ").toLowerCase():e?.replace(/-/g," ").toLowerCase()||"",me=q?decodeURIComponent(q[2]):t||"";if((q||t)&&ye?.videos){if(!q&&e&&t&&ye?.categories){const Be=ns(e.replace(/-/g," ")),Ne=ns(t.replace(/-/g," ")),mt=ye.categories.find(tn=>ns(tn.name||"")===Be),Ut=mt?.series?.find(tn=>ns(tn.name||"")===Ne);if(mt&&Ut){Kn({...mt,_preSelectSeries:Ut.id}),r("ORIGINALS");return}}let xe=ye.videos.find(Be=>String(Be.id)===me||String(Be.vimeoId)===me);if(!xe){const Be=ns(me.replace(/-/g," "));xe=ye.videos.find(Ne=>ns(Ne.title||"")===Be)}if(!xe&&ye.urlContent){const Be=ns(me.replace(/-/g," "));xe=ye.urlContent.find(Ne=>ns(Ne.customTitle||Ne.extractedTitle||Ne.title||"")===Be)}if(xe){const Be=ns(se),Ne=ye.categories?.find(mt=>{const Ut=ns(mt.name||"");return xe.categoryIds?.includes(mt.id)&&Ut===Be})||ye.categories?.find(mt=>xe.categoryIds?.includes(mt.id));Ne&&Kn(Ne),rn(Lo(xe)),an(!0)}else{const Be=me.replace(/-/g," ");a(Be),r("SEARCH"),window.history.replaceState({},"","/chronictv")}}},[ye?.videos,ye?.categories,t,e]);const[ha,hl]=T.useState(void 0);T.useEffect(()=>{const q=window.location.pathname.match(/^\/album\/([^/]+)\/(\d+)/);if(q&&ye?.audioAlbums){const se=parseInt(q[2],10),me=ye.audioAlbums.find(xe=>xe.id===se);if(me){const xe=ye.categories?.find(Be=>String(Be.id)===String(me.categoryId));xe?(Kn(xe),hl(se)):window.history.replaceState({},"","/")}else window.history.replaceState({},"","/")}},[ye?.audioAlbums,ye?.categories]),T.useEffect(()=>{const D=window.location.pathname;(D==="/MyAccount"||D==="/myaccount")&&ut(!0)},[]),T.useEffect(()=>{const D=window.location.pathname;if(D==="/privacy-policy")da(!0);else if(D==="/terms-of-service"){const q=ye?.termsData?.success?ye.termsData.data?.success?ye.termsData.data.data:ye.termsData.data:'Terms and Conditions document not yet configured in Google Drive. Please add content to the "Terms and Conditions" document in your Google Drive ChronicTV(Beta) folder.';ua({show:!0,title:"Terms And Conditions",content:q,hasLink:!1})}else D==="/user-safety"?ua({show:!0,title:"User Safety",content:"At Chronic Brands USA, we are committed to providing a safe and secure environment for all our users. We take user safety seriously and have implemented measures to protect our community. If you encounter any safety concerns, please contact [email protected]",hasLink:!1}):D==="/delete-account"?ui(!0):D.endsWith("/MembershipStatus")&&Re(!0)},[ye?.termsData]);async function Tu(){const D=new AbortController,q=setTimeout(()=>{D.signal.aborted||D.abort()},3e4);try{const se=await P1(`/api/startup-bundle?v=${Date.now()}`,{signal:D.signal});if(clearTimeout(q),!se.ok)throw new Error(`Failed to fetch startup data: ${se.status}`);const me=await se.json();return typeof window.trackApiLoaded=="function"&&window.trackApiLoaded(),me}catch(se){if(clearTimeout(q),se?.name==="AbortError")return{videos:[],categories:[],urlContent:[],liveCreators:[],showDescriptions:{},showLiveUrls:{},splashLogo:null};if(se?.name==="NetworkError"||se?.message?.includes("fetch"))return{videos:[],categories:[],urlContent:[],liveCreators:[],showDescriptions:{},showLiveUrls:{},splashLogo:null};throw se}}Tn.useEffect(()=>{ye?.showDescriptions&&cl(ye.showDescriptions),ye?.showLiveUrls&&oc(ye.showLiveUrls)},[ye]),T.useEffect(()=>{if(!y)return;const D=2e3,q=8e3,se=Date.now(),me=()=>{const xe=Date.now()-se,Be=ye||sr,Ne=xe>q;if(xe>=D&&Be||Ne){x(!1);return}setTimeout(me,100)};me()},[ye,sr,y]),T.useEffect(()=>{if(s==="NOW_PLAYING"&&ye){if(ye.tvGuide&&ye.tvGuide.length>0){const D=Ree(ye.tvGuide);m(D)}if(ye.currentVideo){(!l||l.id!==ye.currentVideo.id)&&c(ye.currentVideo);let q=0;if(ye.currentVideo.startTime!==void 0)q=Math.max(0,ye.currentVideo.startTime);else if(ye.currentVideo.scheduledStartSeconds){const Ne=new Date,mt=ye.currentVideo.scheduledStartSeconds,Ut=new Date(Date.UTC(Ne.getUTCFullYear(),Ne.getUTCMonth(),Ne.getUTCDate(),0,0,0,0)),tn=Math.floor((Ne.getTime()-Ut.getTime())/1e3);q=Math.max(0,tn-mt)}const se=ye.currentVideo.duration||0,me=Math.min(q,Math.max(0,se-1)),xe=ye.currentVideo.scheduledStartSeconds,Be={video:ye.currentVideo,timing:{elapsedSeconds:me,startPositionSeconds:me,scheduledStartSeconds:xe}};h(Be)}}},[s,ye?.tvGuide,ye?.currentVideo]);const jf=D=>{if(!D&&D!==0)return"--";
140if(typeof D=="string"){if(D.includes("h")||D.includes("m"))return D;const q=D.replace(/[^0-9]/g,""),se=parseInt(q)||0;if(se===0)return"0m";const me=Math.floor(se/3600),xe=Math.floor(se%3600/60),Be=se%60;return me>0?`${me}h ${xe}m`:xe>0&&Be>0?`${xe}m ${Be}s`:xe>0?`${xe}m`:`${Be}s`}else if(typeof D=="number"){const q=D;if(q===0)return"0m";const se=Math.floor(q/3600),me=Math.floor(q%3600/60),xe=q%60;return se>0?`${se}h ${me}m`:me>0&&xe>0?`${me}m ${xe}s`:me>0?`${me}m`:`${xe}s`}return"--"},Of=ye?.tvGuide&&ye.tvGuide.length>0?Cee(ye.tvGuide):[{id:"loading",title:"Loading TV Schedule...",startTime:"--:--",endTime:"--:--",duration:"--",status:"LOADING"}];if(y||!ye)return o.jsx("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"#000",zIndex:9999},children:o.jsx(Dee,{logoUrl:"/assets/ChronicTV2_splash.png"})});if(lt)return o.jsx(XL,{onClose:()=>{ut(!1),window.history.pushState({},"","/")}});const fl=ye.liveCreators||[],To=ye.footerLinksData||null,Vd=ye.termsData||null,_u=fl.slice(0,3).map(D=>D.name);return sr?o.jsxs("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",backgroundColor:"#000",color:"#fff",padding:"20px",textAlign:"center",zIndex:9999},children:[o.jsx("h2",{style:{color:"#ff6b6b",marginBottom:"16px"},children:"Connection Error"}),o.jsx("p",{style:{marginBottom:"16px"},children:"Unable to connect to ChronicTV servers. Please check your internet connection."}),o.jsxs("p",{style:{fontSize:"14px",color:"#999",marginBottom:"24px"},children:["Error: ",sr.message]}),o.jsx("button",{onClick:()=>window.location.reload(),style:{backgroundColor:"#4ade80",color:"#000",border:"none",padding:"12px 24px",borderRadius:"6px",cursor:"pointer",fontSize:"16px",fontWeight:"bold"},children:"Retry Connection"})]}):Ar?o.jsx(QL,{}):o.jsxs("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"#000",overflow:"hidden",boxSizing:"border-box"},children:[o.jsxs("div",{className:"app-container",children:[o.jsxs("div",{className:"app-header",style:{position:"fixed",top:"var(--safe-area-inset-top, 0px)",left:0,right:0,height:"80px",padding:"0 clamp(10px, 2vw, 20px)",background:"#000",display:"flex",justifyContent:"space-between",alignItems:"center",width:"100%",maxWidth:"100vw",boxSizing:"border-box",zIndex:1e3,borderBottom:"1px solid #333"},children:[o.jsxs("div",{className:"app-header-brand",style:{display:"flex",alignItems:"center",gap:"clamp(6px, 2vw, 20px)",minWidth:0,flexShrink:1,overflow:"hidden"},children:[o.jsx("img",{src:"/assets/ChronicTVlogo2b.png",alt:"ChronicTV",style:{height:"clamp(44px, 10vw, 70px)",width:"auto",objectFit:"contain",flexShrink:0}}),o.jsx("a",{href:"/",style:{textDecoration:"none",padding:"4px 6px",whiteSpace:"nowrap",display:"flex",alignItems:"center",minWidth:0,overflow:"hidden"},children:o.jsx(Is,{suffix:" Brands",size:"sm",color:"#facc15"})})]}),o.jsxs("div",{className:"app-nav-actions",style:{display:"flex",gap:"clamp(6px, 1.5vw, 12px)",alignItems:"center",flexShrink:0},children:[o.jsx("div",{className:"app-store-links",style:{display:"flex",gap:"6px",alignItems:"center",marginRight:"4px"},children:A.map(D=>{const q=D.icon;return o.jsx("a",{href:D.url,target:"_blank",rel:"noopener noreferrer",title:`Get on ${D.name}`,style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",borderRadius:"6px",background:D.bg,color:D.color,textDecoration:"none",flexShrink:0,transition:"opacity 0.2s"},onMouseEnter:se=>se.currentTarget.style.opacity="0.75",onMouseLeave:se=>se.currentTarget.style.opacity="1",children:o.jsx(q,{size:16})},D.name)})}),fe&&!X?o.jsx("button",{className:"mobile-nav-toggle",onClick:()=>F(D=>!D),style:{background:"transparent",border:"2px solid #444",borderRadius:"50%",width:"44px",height:"44px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",color:"white"},children:N?o.jsx(Mr,{size:20}):o.jsx($7,{size:20})}):o.jsx(o.Fragment,{children:v.map(D=>{const q=D.icon;return o.jsxs("button",{className:`nav-tab nav-tab--${D.id.toLowerCase()}`,"data-active":s===D.id?"true":"false",onClick:()=>{r(D.id),Kn(null),an(!1),rn(null),window.history.pushState({screen:"tab",tabId:D.id},"",window.location.href)},style:{background:"transparent",border:s===D.id?"2px solid #4CAF50":"2px solid transparent",borderRadius:"50%",width:"clamp(40px, 6vw, 50px)",height:"clamp(40px, 6vw, 50px)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",transition:"all 0.3s ease",color:s===D.id?"#4CAF50":"white"},title:D.label,children:[o.jsx(q,{size:20}),o.jsx("span",{className:"nav-tab__label",children:D.label})]},D.id)})}),V&&o.jsx("button",{className:"nav-tab nav-tab--profile",onClick:()=>{G(!0),ls("")}
140,style:{background:w?"#4CAF50":"transparent",border:"2px solid #4CAF50",borderRadius:"50%",width:"clamp(40px, 6vw, 50px)",height:"clamp(40px, 6vw, 50px)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",transition:"all 0.3s ease",color:w?"white":"#4CAF50",marginLeft:"8px",overflow:"hidden"},title:w?`Signed in as ${w.displayName||w.email}`:"Sign in","data-testid":"button-user-profile",children:w?.photoURL?o.jsx("img",{src:w.photoURL,alt:"Profile",style:{width:"100%",height:"100%",borderRadius:"50%",objectFit:"cover"}}):o.jsx(jh,{size:20})})]})]}),N&&fe&&!X&&o.jsxs("div",{className:"mobile-nav-menu",style:{position:"fixed",top:"calc(var(--safe-area-inset-top, 0px) + 80px)",left:0,right:0,background:"#111",borderBottom:"1px solid #333",zIndex:999,boxShadow:"0 4px 20px rgba(0,0,0,0.7)"},children:[v.map(D=>{const q=D.icon;return o.jsxs("button",{onClick:()=>{r(D.id),Kn(null),an(!1),rn(null),F(!1),window.history.pushState({screen:"tab",tabId:D.id},"",window.location.href)},style:{width:"100%",display:"flex",alignItems:"center",gap:"14px",padding:"14px 20px",background:"none",border:"none",borderBottom:"1px solid #222",cursor:"pointer",textAlign:"left",color:s===D.id?"#4ade80":"rgba(255,255,255,0.8)",fontSize:"16px",fontWeight:s===D.id?"600":"400"},children:[o.jsx(q,{size:20}),D.label]},D.id)}),o.jsxs("button",{onClick:()=>{U(!0),F(!1)},style:{width:"100%",display:"flex",alignItems:"center",gap:"14px",padding:"14px 20px",background:"none",border:"none",cursor:"pointer",textAlign:"left",color:"rgba(255,255,255,0.8)",fontSize:"16px"},children:[o.jsx(xF,{size:20}),"Get the App"]})]}),z&&o.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.9)",zIndex:4e3,display:"flex",alignItems:"center",justifyContent:"center",padding:"20px"},onClick:D=>{D.target===D.currentTarget&&U(!1)},children:o.jsxs("div",{style:{background:"#111",borderRadius:"16px",border:"1px solid #333",padding:"28px",maxWidth:"400px",width:"100%"},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"8px"},children:[o.jsx("h2",{style:{color:"#fff",fontSize:"20px",fontWeight:"700",margin:0},children:"Get ChronicTV"}),o.jsx("button",{onClick:()=>U(!1),style:{background:"none",border:"none",color:"#999",cursor:"pointer"},children:o.jsx(Mr,{size:22})})]}),o.jsx("p",{style:{color:"#999",fontSize:"13px",marginBottom:"24px"},children:"Available on your favorite platforms"}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[...A,{name:"Website",icon:oo,url:"https://chronicbrandsusa.com/chronic-tv",color:"#fff",bg:"#1a1a1a"}].map(D=>{const q=D.icon;return o.jsxs("a",{href:D.url,target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:"14px",padding:"14px 18px",borderRadius:"10px",background:D.bg,color:D.color,textDecoration:"none",border:"1px solid rgba(255,255,255,0.1)",transition:"opacity 0.2s"},onMouseEnter:se=>se.currentTarget.style.opacity="0.8",onMouseLeave:se=>se.currentTarget.style.opacity="1",children:[o.jsx(q,{size:22}),o.jsxs("div",{children:[o.jsx("div",{style:{fontSize:"11px",opacity:.7,marginBottom:"1px"},children:"Download on"}),o.jsx("div",{style:{fontSize:"15px",fontWeight:"600"},children:D.name})]})]},D.name)})})]})}),Q&&o.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.85)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:3e3,padding:"20px"},onClick:D=>{D.target===D.currentTarget&&G(!1)},children:o.jsxs("div",{style:{background:"#1a1a1a",borderRadius:"16px",width:"100%",maxWidth:"380px",maxHeight:"90vh",overflow:"auto",border:"1px solid #333"},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"20px",borderBottom:"1px solid #333"},children:[o.jsx("h2",{style:{margin:0,fontSize:"20px",color:"white"},children:w?"My Account":Sn==="signin"?"Sign In":Sn==="signup"?"Create Account":"Reset Password"}),o.jsx("button",{onClick:()=>G(!1),style:{background:"none",border:"none",color:"#888",fontSize:"24px",cursor:"pointer",padding:"4px"},"data-testid":"button-close-account-menu",children:"Ã"})]}),o.jsxs("div",{style:{padding:"20px"},children:[Qt&&o.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"32px 0",textAlign:"center"},children:[o.jsx("div",{style:{width:64,height:64,borderRadius:"50%",background:"rgba(74,222,128,0.15)",display:"flex",alignItems:"center",justifyContent:"center",marginBottom:16},children:o.jsx("svg",{width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",stroke:"#4ade80",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:o.jsx("polyline",{points:"20 6 9 17 4 12"})})}),o.jsx("h3",{style:{color:"white",fontSize:20,fontWeight:700,margin:"0 0 8px 0"},children:"Account Created!"}),o.jsx("p",{style:{color:"#888",fontSize:14,margin:0},children:"Welcome to Chronic Brands USA. You're now signed in."})]}),!Qt&&w?o.jsxs("div",{children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"16px",marginBottom:"24px",padding:"16px",background:"#2a2a2a",borderRadius:"12px"},children:[o.jsx("div",{style:{width:"60px",height:"60px",borderRadius:"50%",overflow:"hidden",background:"#4CAF50",display:"flex",alignItems:"center",justifyContent:"center"},children:w.photoURL?o.jsx("img",{src:w.photoURL,alt:"",style:{width:"100%",height:"100%",objectFit:"cover"}}):o.jsx(jh,{size:28,color:"white"})}),o.jsxs("div",{children:[o.jsx("p",{style:{margin:0,color:"white",fontWeight:"bold",fontSize:"16px"},children:w.displayName||"User"}),o.jsx("p",{style:{margin:"4px 0 0 0",color:"#888",fontSize:"14px"},children:w.email})]})]}),o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[o.jsxs("button",{onClick:()=>{G(!1),ut(!0),window.history.pushState({},"","/MyAccount")},style:{background:"#2a2a2a",border:"none",borderRadius:"8px",padding:"14px 16px",color:"white",fontSize:"15px",cursor:"pointer",textAlign:"left",display:"flex",alignItems:"center",gap:"12px"},"data-testid":"button-edit-account",children:[o.jsx(r4,{size:18}),"Edit Account"]}),o.jsx("button",{onClick:async()=>{K(!0),G(!1);try{const q=await(await fetch("/api/partner-brands")).json();q.success&&q.data&&ii(q.data)}catch{}},style:{background:"#2a2a2a",border:"none",borderRadius:"8px",padding:"14px 16px",color:"white",fontSize:"15px",cursor:"pointer",textAlign:"left",display:"flex",alignItems:"center",gap:"12px"},"data-testid":"button-manage-subscription",children:"ðº Manage Subscription"}),o.jsx("button",{onClick:async()=>
140{if(G(!1),ot(!0),tt(!0),w){const[D,q]=await Promise.all([Bm(w.uid),cd(w.uid)]);D&&rt(D),Nt(q)}ot(!1)},style:{background:"#2a2a2a",border:"none",borderRadius:"8px",padding:"14px 16px",color:"white",fontSize:"15px",cursor:"pointer",textAlign:"left",display:"flex",alignItems:"center",gap:"12px"},"data-testid":"button-billing-info",children:"ð³ Billing Information"}),o.jsx("button",{onClick:async()=>{if(w){it(!0),ee(!0),G(!1);const D=await fm(w.uid,50);Lt(D),it(!1)}},style:{background:"#2a2a2a",border:"none",borderRadius:"8px",padding:"14px 16px",color:"white",fontSize:"15px",cursor:"pointer",textAlign:"left",display:"flex",alignItems:"center",gap:"12px"},"data-testid":"button-watch-history",children:"ðº Watch History"}),o.jsx("div",{style:{height:"8px"}}),o.jsx("button",{onClick:async()=>{await k1(),G(!1)},style:{background:"transparent",border:"1px solid #ff4444",borderRadius:"8px",padding:"14px 16px",color:"#ff4444",fontSize:"15px",cursor:"pointer",textAlign:"center"},"data-testid":"button-sign-out",children:"Sign Out"}),o.jsx("button",{onClick:()=>{ze(!0),G(!1)},style:{background:"transparent",border:"1px solid #666",borderRadius:"8px",padding:"14px 16px",color:"#888",fontSize:"14px",cursor:"pointer",textAlign:"center",marginTop:"4px"},"data-testid":"button-deactivate-account",children:"Delete ChronicTV Account"})]})]}):o.jsxs("div",{children:[sc&&o.jsx("div",{style:{background:"rgba(255,68,68,0.1)",border:"1px solid #ff4444",borderRadius:"8px",padding:"12px",marginBottom:"16px",color:"#ff4444",fontSize:"14px"},children:sc}),Sn==="reset"?o.jsxs("form",{onSubmit:async D=>{D.preventDefault(),Hr(!0),ls("");const q=await Pf(As);Hr(!1),q.success?(ls(""),alert("Password reset email sent! Check your inbox."),Ma("signin")):ls(q.error||"Failed to send reset email")},children:[o.jsx("input",{type:"email",placeholder:"Email address",value:As,onChange:D=>$r(D.target.value),required:!0,style:{width:"100%",padding:"14px",borderRadius:"8px",border:"1px solid #444",background:"#2a2a2a",color:"white",fontSize:"15px",marginBottom:"12px",boxSizing:"border-box"},"data-testid":"input-reset-email"}),o.jsx("button",{type:"submit",disabled:Us,style:{width:"100%",padding:"14px",borderRadius:"8px",border:"none",background:"#4CAF50",color:"white",fontSize:"15px",fontWeight:"bold",cursor:Us?"wait":"pointer",opacity:Us?.7:1},"data-testid":"button-send-reset",children:Us?"Sending...":"Send Reset Link"}),o.jsx("button",{type:"button",onClick:()=>Ma("signin"),style:{width:"100%",padding:"12px",marginTop:"12px",background:"none",border:"none",color:"#4CAF50",fontSize:"14px",cursor:"pointer"},children:"Back to Sign In"})]}):o.jsxs("form",{onSubmit:async D=>{if(D.preventDefault(),Hr(!0),ls(""),Sn==="signup"){if(!Di){ls("Please accept the Terms & Conditions"),Hr(!1);return}const q=As,se=li,me=await kf(As,Cr,li,un,yo);me.error?ls(me.error):($r(""),Fa(""),Ua(""),aa(""),vo(""),nc(!1),G(!1),Su(se),bo(!0),fetch("/api/auth/welcome-email",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:q,firstName:se})}).catch(()=>{}),setTimeout(()=>bo(!1),7e3))}else{const q=await Rf(As,Cr);q.error?ls(q.error):(G(!1),$r(""),Fa(""))}Hr(!1)},children:[Sn==="signup"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{display:"flex",gap:"12px",marginBottom:"12px"},children:[o.jsx("input",{type:"text",placeholder:"First name",value:li,onChange:D=>Ua(D.target.value),style:{flex:1,minWidth:0,padding:"14px",borderRadius:"8px",border:"1px solid #444",background:"#2a2a2a",color:"white",fontSize:"15px",boxSizing:"border-box"},"data-testid":"input-first-name"}),o.jsx("input",{type:"text",placeholder:"Last name",value:un,onChange:D=>aa(D.target.value),style:{flex:1,minWidth:0,padding:"14px",borderRadius:"8px",border:"1px solid #444",background:"#2a2a2a",color:"white",fontSize:"15px",boxSizing:"border-box"},"data-testid":"input-last-name"})]}),o.jsx("input",{type:"tel",placeholder:"Phone number",value:yo,onChange:D=>vo(D.target.value),style:{width:"100%",padding:"14px",borderRadius:"8px",border:"1px solid #444",background:"#2a2a2a",color:"white",fontSize:"15px",marginBottom:"12px",boxSizing:"border-box"},"data-testid":"input-phone"})]}),o.jsx("input",{type:"email",placeholder:"Email address",value:As,onChange:D=>$r(D.target.value),required:!0,style:{width:"100%",padding:"14px",borderRadius:"8px",border:"1px solid #444",background:"#2a2a2a",color:"white",fontSize:"15px",marginBottom:"12px",boxSizing:"border-box"},"data-testid":"input-email"}),o.jsx("input",{type:"password",placeholder:"Password",value:Cr,onChange:D=>Fa(D.target.value),required:!0,minLength:6,style:{width:"100%",padding:"14px",borderRadius:"8px",border:"1px solid #444",background:"#2a2a2a",color:"white",fontSize:"15px",marginBottom:"16
140px",boxSizing:"border-box"},"data-testid":"input-password"}),Sn==="signup"&&o.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"12px",marginBottom:"8px",cursor:"pointer"},children:[o.jsx("input",{type:"checkbox",checked:Di,onChange:D=>nc(D.target.checked),style:{width:"20px",height:"20px",marginTop:"2px",accentColor:"#4ade80",cursor:"pointer",flexShrink:0},"data-testid":"input-terms-checkbox"}),o.jsxs("span",{style:{color:"#aaa",fontSize:"14px",lineHeight:"1.4"},children:["I agree to the ",o.jsx("a",{href:"/terms",target:"_blank",rel:"noopener noreferrer",style:{color:"#4ade80",textDecoration:"underline"},children:"Terms & Conditions"})," of Chronic Brands USA"]})]}),Sn==="signup"&&!Di&&o.jsx("p",{style:{color:"#888",fontSize:"12px",textAlign:"center",margin:"0 0 12px 0"},children:"Please check the box above to continue"}),o.jsx("button",{type:"submit",disabled:Us||Sn==="signup"&&!Di,style:{width:"100%",padding:"14px",borderRadius:"8px",border:"none",background:Sn==="signup"&&!Di?"#555":"#4CAF50",color:Sn==="signup"&&!Di?"#888":"white",fontSize:"15px",fontWeight:"bold",cursor:Us||Sn==="signup"&&!Di?"not-allowed":"pointer",opacity:Us?.7:1},"data-testid":Sn==="signup"?"button-create-account":"button-sign-in",children:Us?"Please wait...":Sn==="signup"?"Create Account":"Sign In"}),Sn==="signin"&&o.jsx("button",{type:"button",onClick:()=>Ma("reset"),style:{width:"100%",padding:"10px",marginTop:"8px",background:"none",border:"none",color:"#888",fontSize:"13px",cursor:"pointer"},children:"Forgot password?"})]}),Sn!=="reset"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",margin:"20px 0",gap:"12px"},children:[o.jsx("div",{style:{flex:1,height:"1px",background:"#444"}}),o.jsx("span",{style:{color:"#666",fontSize:"13px"},children:"or"}),o.jsx("div",{style:{flex:1,height:"1px",background:"#444"}})]}),o.jsx("button",{onClick:async()=>{ls(""),Hr(!0);try{await Vm()&&G(!1)}catch(D){ls(D?.message||"Google sign-in failed. Please try again.")}finally{Hr(!1)}},disabled:Us,style:{width:"100%",padding:"14px",borderRadius:"8px",border:"1px solid #444",background:"#2a2a2a",color:"white",fontSize:"15px",cursor:Us?"wait":"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"10px",opacity:Us?.7:1},"data-testid":"button-google-signin",children:Us?o.jsxs(o.Fragment,{children:[o.jsx("div",{style:{width:"18px",height:"18px",border:"2px solid #666",borderTopColor:"white",borderRadius:"50%",animation:"spin 1s linear infinite"}}),"Signing in..."]}):o.jsxs(o.Fragment,{children:[o.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",children:[o.jsx("path",{fill:"#4285F4",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"}),o.jsx("path",{fill:"#34A853",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),o.jsx("path",{fill:"#FBBC05",d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"}),o.jsx("path",{fill:"#EA4335",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})]}),"Continue with Google"]})}),o.jsxs("button",{onClick:async()=>{ls(""),Hr(!0);try{const{signInWithApple:D}=await ps(async()=>{const{signInWithApple:se}=await Promise.resolve().then(()=>HJ);return{signInWithApple:se}},void 0);await D()&&G(!1)}catch(D){ls(D?.message||"Apple sign-in failed. Please try again.")}finally{Hr(!1)}},disabled:Us,style:{width:"100%",padding:"14px",marginTop:"12px",borderRadius:"8px",border:"1px solid #444",background:"black",color:"white",fontSize:"15px",cursor:Us?"wait":"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"10px",opacity:Us?.7:1},"data-testid":"button-apple-signin",children:[o.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor",children:o.jsx("path",{d:"M17.05 20.28c-.98.95-2.05.8-3.08.35-1.09-.46-2.09-.48-3.24 0-1.44.62-2.2.44-3.06-.35C2.79 15.25 3.51 7.59 9.05 7.31c1.35.07 2.29.74 3.08.8 1.18-.24 2.31-.93 3.57-.84 1.51.12 2.65.72 3.4 1.8-3.12 1.87-2.38 5.98.48 7.13-.57 1.5-1.31 2.99-2.54 4.09l.01-.01zM12.03 7.25c-.15-2.23 1.66-4.07 3.74-4.25.29 2.58-2.34 4.5-3.74 4.25z"})}),"Continue with Apple"]}),o.jsx("div",{style:{marginTop:"20px",textAlign:"center",color:"#888",fontSize:"14px"},children:Sn==="signin"?o.jsxs(o.Fragment,{children:["Don't have an account?"," ",o.jsx("button",{onClick:()=>{Ma("signup"),ls("")},style:{background:"none",border:"none",color:"#4CAF50",cursor:"pointer",fontSize:"14px",padding:0},children:"Sign up"})]}):o.jsxs(o.Fragment,{children:["Already have an account?"," ",o.jsx("button",{onClick:()=>{Ma("signin"),ls("")},style:{background:"none",border:"none",color:"#4CAF50",cursor:"pointer",fontSize:"14px",padding:0},children:"Sign in"})]})})]})]})]})]})}),Y&&o.jsx("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0,0,0,0.85)",zIndex:3e3,display:"flex",justifyContent:"center",alignItems:"flex-start",paddingTop:"60px",overflowY:"auto"},onClick:()=>ee(!1),children:o.jsxs("div",{style:{background:"#1e1e1e",borderRadius:"12px",width:"90%",maxWidth:"600px",maxHeight:"80vh",overflow:"hidden",display:"flex",flexDirection:"column"},onClick:D=>D.stopPropagation(),children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"20px",borderBottom:"1px solid #333"},children:[o.jsx("h2",{style:{color:"white",margin:0,fontSize:"20px",fontWeight:"bold"},children:"Watch History"}),o.jsx("button",{onClick:()=>ee(!1),style:{background:"none",border:"none",color:"#888",fontSize:"24px",cursor:"pointer",padding:"4px"},"data-testid":"button-close-watch-history",children:"Ã"})]}),o.jsx("div",{style:{flex:1,overflowY:"auto",padding:"16px"},children:Qe?o.jsx("div",{style:{textAlign:"center",padding:"40px",color:"#888"},children:"Loading..."}):Le.length===0?o.jsx("div",{style:{textAlign:"center",padding:"40px",color:"#888"},children:"No watch history yet. Start watching videos to build your history!"}):o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:Le.map((D,q)=>o.jsxs("div",{style:{display:"flex",gap:"12px",background:"#2a2a2a",borderRadius:"8px",padding:"12px",cursor:"pointer"},onClick:()=>{ee(!1),rn({id:D.videoId,title:D.videoTitle,thumbnailUrl:D.thumbnailUrl,videoUrl:`https://player.vimeo.com/video/${D.videoId}`,duration:D.durationSeconds||0}),an(!0)},"data-testid":`watch-history-item-${q}`,children:[o.jsxs("div",{style:{width:"120px",minWidth:"120px",aspectRatio:"16/9",borderRadius:"6px",overflow:"hidden",position:"relative",background:"#333"},children:[o.jsx("img",{src:D.thumbnailUrl||"/placeholder.png",alt:D.videoTitle,style:{width:"100%",height:"100%",objectFit:"cover"},onError:se=>{se.target.style.display="none"}}),D.progressSeconds>0&&D.durationSeconds&&o.jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,height:"4px",background:"rgba(0,0,0,0.5)"},children:o.jsx("div",{style:{width:`${Math.min(100,D.progressSeconds/D.durationSeconds*100)}%`,height:"100%",background:"#4CAF50"}})})]}),o.jsxs("div",{style:{flex:1,overflow:"hidden"},children:[o.jsx("h3",{style:{color:"white",margin:"0 0 4px 0",fontSize:"14px",fontWeight:"600",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:D.videoTitle}),o.jsx("p",{style:{color:"#888",margin:0,fontSize:"12px"},children:D.showName||"ChronicTV"}),o.jsx("p",{style:{color:"#666",margin:"4px 0 0 0",fontSize:"11px"},children:D.watchedAt?new Date(D.watchedAt).toLocaleDateString():""})]})]},D.videoId+"-"+q))})})]})}),H&&o.jsx("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0,0,0,0.85)",zIndex:3e3,display:"flex",justifyContent:"center",alignItems:"flex-start",paddingTop:"60px",overflowY:"auto"},onClick:()=>K(!1),children:o.jsxs("div",{style:{background:"#1e1e1e",borderRadius:"12px",width:"90%",maxWidth:"400px",overflow:"hidden"},onClick:D=>D.stopPropagation(),children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"20px",borderBottom:"1px solid #333"},children:[o.jsx("h2",{style:{color:"white",margin:0,fontSize:"20px",fontWeight:"bold"},children:"Manage Subscription"}),o.jsx("button",{onClick:()=>K(!1),style:{background:"none",border:"none",color:"#888",fontSize:"24px",cursor:"pointer"},"data-testid":"button-close-subscription",children:"Ã"})]}),o.jsxs("div",{style:{padding:"20px"},children:[o.jsxs("div",{style:{background:"#2a2a2a",borderRadius:"12px",padding:"20px",marginBottom:"16
140px",border:ln==="cultured"?"2px solid #4ade80":"2px solid #444"},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"12px"},children:[o.jsxs("div",{children:[o.jsx("h3",{style:{color:"white",margin:0,fontSize:"20px",fontWeight:"bold"},children:"Cultured"}),o.jsx("p",{style:{color:"#4ade80",margin:"4px 0 0 0",fontSize:"13px",fontWeight:"bold"},children:"FREE"})]}),ln==="cultured"&&o.jsx("span",{style:{background:"#4ade80",color:"black",padding:"6px 14px",borderRadius:"20px",fontSize:"12px",fontWeight:"bold"},children:"Active"})]}),o.jsx("p",{style:{color:"#888",margin:0,fontSize:"13px",lineHeight:"1.5"},children:'Free version - watch all there is to offer without the benefits of "Premier"'})]}),o.jsxs("div",{style:{background:"#2a2a2a",borderRadius:"12px",padding:"20px",marginBottom:"16px",border:ln==="premier"?"2px solid #ffd700":"2px solid #444"},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"12px"},children:[o.jsxs("div",{children:[o.jsx("h3",{style:{color:"#ffd700",margin:0,fontSize:"20px",fontWeight:"bold"},children:"â Premier"}),o.jsx("p",{style:{color:"#ffd700",margin:"4px 0 0 0",fontSize:"13px",fontWeight:"bold"},children:"$10/month"})]}),ln==="premier"&&o.jsx("span",{style:{background:"#ffd700",color:"black",padding:"6px 14px",borderRadius:"20px",fontSize:"12px",fontWeight:"bold"},children:"Active"})]}),o.jsx("p",{style:{color:"#ccc",margin:"0 0 16px 0",fontSize:"13px",lineHeight:"1.5"},children:"Gain exclusive event info, as well as Brand Partner Discounts"}),o.jsxs("div",{style:{background:"#1e1e1e",borderRadius:"8px",padding:"12px"},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px"},children:[o.jsx("h4",{style:{color:"#ffd700",margin:0,fontSize:"14px"},children:"ð¤ Partner Memberships"}),ln!=="premier"&&o.jsx("span",{style:{background:"rgba(0,0,0,0.6)",padding:"4px 10px",borderRadius:"12px",fontSize:"10px",color:"#ffd700",fontWeight:"bold"},children:"ð Upgrade to unlock"})]}),Gn.length>0?o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",opacity:ln==="premier"?1:.7,pointerEvents:ln==="premier"?"auto":"none"},children:Gn.map((D,q)=>o.jsxs("a",{href:D.referralLink,target:"_blank",rel:"noopener noreferrer",style:{display:"block",padding:"10px",background:"#2a2a2a",borderRadius:"6px",textDecoration:"none",cursor:"pointer"},"data-testid":`partner-link-${q}`,children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[o.jsx("p",{style:{color:"white",margin:0,fontSize:"13px",fontWeight:"500"},children:D.brandName}),o.jsx("span",{style:{color:"#4ade80",fontSize:"14px",marginLeft:"8px"},children:"â"})]}),D.shortInfo&&o.jsx("p",{style:{color:"#888",margin:"4px 0 0 0",fontSize:"11px"},children:D.shortInfo}),D.discount&&o.jsx("div",{style:{marginTop:"8px",padding:"6px 8px",background:"rgba(74, 222, 128, 0.2)",borderRadius:"4px",borderLeft:"2px solid #4ade80"},children:o.jsxs("p",{style:{color:"#4ade80",margin:0,fontSize:"11px",fontWeight:"500",lineHeight:"1.3"},children:["ð ",D.discount]})})]},q))}):o.jsx("p",{style:{color:"#666",margin:0,fontSize:"12px",fontStyle:"italic"},children:"Loading partner discounts..."})]}),Tr&&o.jsx("p",{style:{color:"#ff4444",fontSize:"12px",margin:"12px 0 0 0",textAlign:"center"},children:Tr}),ln!=="premier"&&o.jsxs("div",{style:{marginTop:"16px",padding:"12px",background:"rgba(255, 215, 0, 0.1)",border:"1px solid #ffd700",borderRadius:"8px",display:"flex",flexDirection:"column",gap:"12px"},children:[o.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"10px",cursor:"pointer",userSelect:"none"},children:[o.jsx("input",{type:"checkbox",checked:Vn,onChange:D=>La(D.target.checked),style:{width:"18px",height:"18px",marginTop:"2px",accentColor:"#4ade80",cursor:"pointer"},"data-testid":"checkbox-membership-understood"}),o.jsxs("span",{style:{color:"#ccc",fontSize:"11px",lineHeight:"1.5"},children:["I have read and understand how the ",o.jsx("a",{href:"/membership",target:"_blank",style:{color:"#4ade80",textDecoration:"underline"},children:"Chronic Brands membership"})," works."]})]}),o.jsxs("label",{style:{display:"flex",alignItems:"flex-start",ga
140p:"10px",cursor:"pointer",userSelect:"none"},children:[o.jsx("input",{type:"checkbox",checked:St,onChange:D=>Un(D.target.checked),style:{width:"18px",height:"18px",marginTop:"2px",accentColor:"#4ade80",cursor:"pointer"},"data-testid":"checkbox-billing-disclaimer"}),o.jsxs("span",{style:{color:"#ccc",fontSize:"11px",lineHeight:"1.5"},children:["I understand that charges will appear from ",o.jsx("strong",{style:{color:"#ffd700"},children:'"HiveStaffing"'})," on my bank statement. I acknowledge that disputing this subscription charge will result in the ",o.jsx("strong",{style:{color:"#ff6b6b"},children:"loss of Partner discount benefits"}),"."]})]}),o.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"10px",cursor:"pointer",userSelect:"none"},children:[o.jsx("input",{type:"checkbox",checked:Br,onChange:D=>Da(D.target.checked),style:{width:"18px",height:"18px",marginTop:"2px",accentColor:"#4ade80",cursor:"pointer"},"data-testid":"checkbox-id-requirement"}),o.jsxs("span",{style:{color:"#ccc",fontSize:"11px",lineHeight:"1.5"},children:["I understand that without a valid ID matching the name on this account, ",o.jsx("strong",{style:{color:"#ff6b6b"},children:"Brand rebate may be refused by the retailer"}),"."]})]})]}),o.jsx("button",{onClick:async()=>{if(!w){hr("Please sign in to upgrade");return}await K6(w.uid),vn(!0),hr(null);try{const D=await cd(w.uid);if(D.length===0){hr("Please add a payment method in Billing Information first"),vn(!1);return}const q=await w.getIdToken(),me=await(await fetch("/api/payments/create-subscription",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${q}`},body:JSON.stringify({firebaseUid:w.uid,paymentProfileId:D[0].authorizeNetPaymentProfileId,customerProfileId:D[0].authorizeNetCustomerProfileId,subscriptionProductId:"premier-membership"})})).json();if(me.success){const xe=new Date,Be=new Date(xe.getTime()+720*60*60*1e3);await G6(w.uid,{status:"active",planName:"Premier",tier:"premier",priceAmount:10,authorizeNetSubscriptionId:me.subscriptionId,authorizeNetCustomerProfileId:D[0].authorizeNetCustomerProfileId,authorizeNetPaymentProfileId:D[0].authorizeNetPaymentProfileId,lastRenewalDate:xe,nextBillingDate:Be,createdAt:xe}),Qs("premier"),hr(null)}else hr(me.error||"Failed to create subscription")}catch{hr("Failed to process subscription")}vn(!1)},disabled:os||ln==="premier"||!St||!Vn||!Br,style:{width:"100%",padding:"12px",marginTop:"12px",borderRadius:"8px",border:"none",background:ln==="premier"?"#4ade80":St&&Vn&&Br?"#ffd700":"#555",color:ln==="premier"||St&&Vn&&Br?"black":"#888",fontSize:"14px",fontWeight:"bold",cursor:os?"wait":ln==="premier"?"default":St&&Vn&&Br?"pointer":"not-allowed",opacity:os?.7:1},"data-testid":"button-upgrade-premier",children:os?"Processing...":ln==="premier"?"â Premier Active":"Upgrade to Premier - $10/month"}),o.jsxs("button",{onClick:()=>Xs(!0),style:{width:"100%",padding:"12px",marginTop:"12px",borderRadius:"8px",border:ln==="premier"?"2px solid #ffd700":"2px solid #4ade80",background:"transparent",color:ln==="premier"?"#ffd700":"#4ade80",fontSize:"14px",fontWeight:"bold",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},"data-testid":"button-proof-of-discount",children:[o.jsx(Yu,{size:18}),"Get Proof of Discount"]})]}),o.jsx("p",{style:{color:"#666",fontSize:"12px",textAlign:"center",margin:0},children:"Questions? Contact [email protected]"})]})]})}),Na&&w&&o.jsx("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0,0,0,0.9)",zIndex:4e3,display:"flex",justifyContent:"center",alignItems:"center",padding:"20px"},onClick:()=>Xs(!1),children:o.jsxs("div",{style:{background:"#1a1a1a",borderRadius:"16px",width:"100%",maxWidth:"360px",overflow:"hidden"},onClick:D=>D.stopPropagation(),children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"20px",borderBottom:"1px solid #333"},children:[o.jsx("h2",{style:{color:"#ffd700",margin:0,fontSize:"18px",fontWeight:"bold"},children:"ð« Proof of Discount"}),o.jsx("button",{onClick:()=>Xs(!1),style:{background:"none",border:"none",color:"#888",fontSize:"24px",cursor:"pointer"},"data-testid":"button-close-proof",children:"Ã"})]}),o.jsxs("div",{style:{padding:"20px",textAlign:"center"},children:[o.jsx("p",{style:{color:"#ccc",fontSize:"13px",marginBottom:"20px"},children:ln==="premier"?"Show this QR code to any partner to verify your Premier membership and receive your discount.":"Show this QR code to verify your ChronicTV membership status."}),o.jsx("div",{style:{background:"#f5f0e6",padding:"16px",borderRadius:"12px",display:"inline-block",marginBottom:"20px",border:ln==="premier"?"3px solid #4ade80":"3px solid #888"},children:o.jsx(l4,{value:`https://chronicbrandsusa.onrender.com/${es}/MembershipStatus`,size:180,level:"H",includeMargin:!1,bgColor:"#f5f0e6",fgColor:"#000000",imageSettings:{src:"/assets/ChronicTVlogo2b.png",height:45,width:70,excavate:!0}})}),o.jsxs("div",{style:{background:"#2a2a2a",borderRadius:"8px",padding:"12px",marginBottom:"20px",textAlign:"left"},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"8px"},children:[o.jsx("span",{style:{color:"#888",fontSize:"12px"},children:"Name"}),o.jsx("span",{style:{color:"#fff",fontSize:"12px",fontWeight:"bold"},children:w.displayName||"Member"})]}),o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"8px"},children:[o.jsx("span",{style:{color:"#888",fontSize:"12px"},children:"Email"}),o.jsx("span",{style:{color:"#fff",fontSize:"12px"},children:w.email})]}),o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"8px"},children:[o.jsx("span",{style:{color:"#888",fontSize:"12px"},children:"Status"}),o.jsx("span",{style:{color:ln==="premier"?"#4ade80":"#ffd700",fontSize:"12px",fontWeight:"bold"},children:ln==="premier"?"â Premier Active":"â Cultured Free Active"})]}),ln==="premier"&&ol&&o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"8px"},children:[o.jsx("span",{style:{color:"#888",fontSize:"12px"},children:"Next Renewal"}),o.jsx("span",{style:{color:"#4ade80",fontSize:"12px"},children:ol.toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})})]}),ln!=="premier"&&go&&o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"8px"},children:[o.jsx("span",{style:{color:"#888",fontSize:"12px"},children:"Last Premier"}),o.jsx("span",{style:{color:"#888",fontSize:"12px"},children:go.toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})})]})]}),o.jsxs("div",{style:{background:"#2a2a2a",borderRadius:"8px",padding:"12px",marginBottom:"20px"},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"8px"},children:[o.jsx("span",{style:{color:"#ccc",fontSize:"13px",fontWeight:600},children:"State Issued ID"}),o.jsxs("label",{style:{background:"#4ade80",color:"black",padding:"6px 12px",borderRadius:"6px",fontSize:"11px",fontWeight:"bold",cursor:pt?"wait":"pointer",opacity:pt?.7:1,flexShrink:0},children:[o.jsx("input",{type:"file",accept:"image/*",style:{display:"none"},disabled:pt,onChange:async D=>{const q=D.target.files?.[0];if(q&&w){if(!rl){Oa(q),ia(!0),D.target.value="";return}ys(!0);const se=await pm(w.uid,q);se.success&&se.url&&Te(se.url),ys(!1)}},"data-testid":"input-photo-id"}),pt?"Uploading...":Rn?"Update ID":"Upload ID"]})]}),o.jsx("p",{style:{color:"#888",fontSize:"11px",margin:"0 0 6px 0",lineHeight:"1.6"},children:"Your ID is used to verify your identity and ensure our events are safe for everyone. This allows staff to confirm membership and assist in any emergency situations."}),o.jsx("p",{style:{color:"#888",fontSize:"11px",margin:"0 0 6px 0",lineHeight:"1.6"},children:"A Medical Marijuana (MMJ) license is also accepted as an alternative form of ID."}),o.jsx("a",{href:"https://www.chronicdocs.com/CHRONICLOUNGE",target:"_blank",rel:"noopener noreferrer",style:{color:"#4ade80",fontSize:"11px",textDecoration:"underline",cursor:"pointer"},children:"Don't have a MMJ license?"}),Rn&&o.jsxs("div",{onClick:()=>
140zr(!fr),style:{position:"relative",cursor:"pointer",borderRadius:"8px",overflow:"hidden"},"data-testid":"photo-id-container",children:[o.jsx("img",{src:Rn,alt:"Photo ID",style:{width:"100%",maxHeight:"200px",objectFit:"contain",borderRadius:"8px",filter:fr?"none":"blur(12px)",transition:"filter 0.3s ease"}}),!fr&&o.jsx("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",background:"rgba(0,0,0,0.7)",padding:"8px 16px",borderRadius:"8px",color:"white",fontSize:"12px",fontWeight:"bold"},children:"ð Tap to reveal"})]}),!Rn&&o.jsx("p",{style:{color:"#666",fontSize:"11px",textAlign:"center",margin:0},children:"Upload your photo ID for Chronic Lounge access"})]}),o.jsxs("div",{style:{display:"flex",gap:"10px"},children:[o.jsxs("button",{onClick:async()=>{const D=`https://chronicbrandsusa.onrender.com/${es}/MembershipStatus`;try{await navigator.clipboard.writeText(D),_r(!0),setTimeout(()=>_r(!1),2e3)}catch{}},style:{flex:1,padding:"12px",borderRadius:"8px",border:"none",background:oi?"#4ade80":"#333",color:oi?"black":"white",fontSize:"13px",fontWeight:"bold",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"6px"},"data-testid":"button-copy-proof",children:[o.jsx(Dh,{size:16}),oi?"Copied!":"Copy Link"]}),o.jsxs("button",{onClick:async()=>{const D=`https://chronicbrandsusa.onrender.com/${es}/MembershipStatus`;if(navigator.share)try{await navigator.share({title:"ChronicTV Premier Membership",text:`Verify my Premier membership: ${w.displayName||"Member"}`,url:D})}catch{}else await navigator.clipboard.writeText(D),_r(!0),setTimeout(()=>_r(!1),2e3)},style:{flex:1,padding:"12px",borderRadius:"8px",border:"none",background:"#ffd700",color:"black",fontSize:"13px",fontWeight:"bold",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"6px"},"data-testid":"button-share-proof",children:[o.jsx(Jc,{size:16}),"Share"]})]})]})]})}),ja&&o.jsx("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0,0,0,0.9)",zIndex:3e3,display:"flex",justifyContent:"center",alignItems:"center",padding:"20px"},onClick:()=>{ia(!1),Oa(null),il(!1)},children:o.jsxs("div",{style:{background:"#1e1e1e",borderRadius:"12px",width:"100%",maxWidth:"400px",overflow:"hidden"},onClick:D=>D.stopPropagation(),children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"20px",borderBottom:"1px solid #333"},children:[o.jsx("h2",{style:{color:"#4ade80",margin:0,fontSize:"18px",fontWeight:"bold"},children:"ID Verification Consent"}),o.jsx("button",{onClick:()=>{ia(!1),Oa(null),il(!1)},style:{background:"none",border:"none",color:"#888",fontSize:"24px",cursor:"pointer"},"data-testid":"button-close-consent",children:"Ã"})]}),o.jsxs("div",{style:{padding:"20px"},children:[o.jsx("p",{style:{color:"#fff",fontSize:"14px",lineHeight:"1.7",margin:"0 0 20px 0",textAlign:"left"},children:"I understand that Chronic Brands and Chronic Lounge requires my ID to keep all of its members safe, and without ID I may be denied entry."}),o.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"12px",cursor:"pointer",padding:"12px",background:"#2a2a2a",borderRadius:"8px",marginBottom:"20px"},children:[o.jsx("input",{type:"checkbox",checked:xn,onChange:D=>il(D.target.checked),style:{width:"20px",height:"20px",accentColor:"#4ade80",marginTop:"2px",flexShrink:0},"data-testid":"checkbox-id-consent"}),o.jsx("span",{style:{color:"#888",fontSize:"13px",lineHeight:"1.5"},children:"I agree and consent to providing my photo ID for membership verification purposes"})]}),o.jsxs("div",{style:{display:"flex",gap:"12px"},children:[o.jsx("button",{onClick:()=>{ia(!1),Oa(null),il(!1)},style:{flex:1,padding:"14px",borderRadius:"8px",border:"1px solid #444",background:"transparent",color:"white",fontSize:"14px",cursor:"pointer"},"data-testid":"button-cancel-consent",children:"Cancel"}),o.jsx("button",{onClick:async()=>{if(!xn||!w||!al)return;if((await Y6(w.uid)).success){Li(!0),ia(!1),ys(!0);const q=await pm(w.uid,al);q.success&&q.url&&Te(q.url),ys(!1),Oa(null),il(!1)}},disabled:!xn,style:{flex:1,padding:"14px",borderRadius:"8px",border:"none",background:xn?"#4ade80":"#333",color:xn?"black":"#666",fontSize:"14px",fontWeight:"bold",cursor:xn?"pointer":"not-allowed"},"data-testid":"button-confirm-consent",children:"I Agree"})]})]})]})}),_e&&o.jsx("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0,0,0,0.85)",zIndex:3e3,display:"flex",justifyContent:"center",alignItems:"center",padding:"20px"},onClick:()=>ze(!1),children:o.jsxs("div",{style:{background:"#1e1e1e",borderRadius:"12px",width:"100%",maxWidth:"380px",overflow:"hidden"},onClick:D=>D.stopPropagation(),children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"20px",borderBottom:"1px solid #333"},children:[o.jsx("h2",{style:{color:"#ff4444",margin:0,fontSize:"18px",fontWeight:"bold"},children:"Delete ChronicTV Account"}),o.jsx("button",{onClick:()=>ze(!1),style:{background:"none",border:"none",color:"#888",fontSize:"24px",cursor:"pointer"},"data-testid":"button-close-deactivate",children:"Ã"})]}),o.jsxs("div",{style:{padding:"20px"},children:[o.jsx("p",{style:{color:"#888",fontSize:"14px",lineHeight:"1.6",margin:"0 0 20px 0"},children:"Are you sure you want to delete your ChronicTV account? This action will:"}),o.jsxs("ul",{style:{color:"#888",fontSize:"13px",margin:"0 0 20px 0",padding:"0 0 0 20px",lineHeight:"1.8"},children:[o.jsx("li",{children:"Delete your watch history"}),o.jsx("li",{children:"Remove your saved preferences"}),o.jsx("li",{children:"Cancel any active subscriptions"})]}),o.jsx("p",{style:{color:"#ff4444",fontSize:"13px",fontWeight:"bold",margin:"0 0 20px 0"},children:"This action cannot be undone."}),o.jsxs("div",{style:{display:"flex",gap:"12px"},children:[o.jsx("button",{onClick:()=>ze(!1),style:{flex:1,padding:"12px",borderRadius:"8px",border:"1px solid #444",background:"transparent",color:"white",fontSize:"14px",cursor:"pointer"},"data-testid":"button-cancel-deactivate",children:"Cancel"}),o.jsx("button",{onClick:async()=>{ke(!0);const D=await Jb();ke(!1),D.success?(ze(!1),alert("Your ChronicTV account has been deleted.")):D.requiresReauth?alert(D.error):alert(D.error||"Failed to delete account")},disabled:cn,style:{flex:1,padding:"12px",borderRadius:"8px",border:"none",background:"#ff4444",color:"white",fontSize:"14px",fontWeight:"bold",cursor:cn?"wait":"pointer",opacity:cn?.7:1},"data-testid":"button-confirm-deactivate",children:cn?"Deleting...":"Delete"})]})]})]})}),Ye&&o.jsx("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0,0,0,0.85)",zIndex:3e3,display:"flex",justifyContent:"center",alignItems:"flex-start",paddingTop:"60px",overflowY:"auto"},onClick:()=>{tt(!1),zt(!1)},children:o.jsxs("div",{style:{background:"#1e1e1e",borderRadius:"12px",width:"90%",maxWidth:"450px",overflow:"hidden"},onClick:D=>D.stopPropagation(),children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"20px",borderBottom:"1px solid #333"},children:[o.jsx("h2",{style:{color:"white",margin:0,fontSize:"20px",fontWeight:"bold"},children:"Billing Information"}),o.jsx("button",{onClick:()=>{tt(!1),zt(!1)},style:{background:"none",border:"none",color:"#888",fontSize:"24px",cursor:"pointer"},"data-testid":"button-close-payment-methods",children:"Ã"})]}),o.jsx("div",{style:{padding:"20px"},children:At?o.jsx("div",{style:{textAlign:"center",padding:"40px",color:"#888"},children:"Loading payment methods..."}):o.jsxs(o.Fragment,{children:[ft.length===0&&!Yt?o.jsxs("div",{style:{textAlign:"center",padding:"20px"}
140,children:[o.jsx("p",{style:{color:"#888",marginBottom:"16px"},children:"No payment methods saved yet."}),o.jsx("button",{onClick:()=>zt(!0),style:{background:"#4ade80",color:"black",border:"none",borderRadius:"8px",padding:"12px 24px",fontSize:"14px",fontWeight:"bold",cursor:"pointer"},"data-testid":"button-add-first-card",children:"+ Add Payment Method"})]}):null,ft.length>0&&!Yt&&o.jsxs(o.Fragment,{children:[o.jsx("div",{style:{marginBottom:"16px"},children:ft.map(D=>o.jsxs("div",{style:{background:"#2a2a2a",borderRadius:"8px",padding:"16px",marginBottom:"8px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[o.jsx("span",{style:{fontSize:"24px"},children:"ð³"}),o.jsxs("div",{children:[o.jsxs("p",{style:{color:"white",margin:0,fontWeight:"bold"},children:[D.cardBrand," â¢â¢â¢â¢ ",D.cardLast4]}),o.jsxs("p",{style:{color:"#888",margin:"4px 0 0 0",fontSize:"13px"},children:["Expires ",D.expirationMonth,"/",D.expirationYear]})]})]}),D.isDefault&&o.jsx("span",{style:{background:"#4ade80",color:"black",padding:"4px 8px",borderRadius:"4px",fontSize:"11px",fontWeight:"bold"},children:"Default"})]},D.id))}),o.jsx("button",{onClick:()=>zt(!0),style:{width:"100%",background:"transparent",color:"#4ade80",border:"1px dashed #4ade80",borderRadius:"8px",padding:"12px",fontSize:"14px",cursor:"pointer"},"data-testid":"button-add-another-card",children:"+ Add Another Card"})]}),Yt&&o.jsxs("div",{children:[o.jsx("h3",{style:{color:"white",margin:"0 0 16px 0",fontSize:"16px"},children:"Add Payment Method"}),o.jsx("p",{style:{color:"#888",fontSize:"13px",marginBottom:"16px"},children:"Your card information is securely processed by Authorize.net."}),wn&&o.jsx("div",{style:{background:"rgba(239, 68, 68, 0.15)",border:"1px solid #ef4444",borderRadius:"8px",padding:"12px",marginBottom:"16px",color:"#fca5a5",fontSize:"13px"},children:wn}),Ee&&o.jsx("div",{style:{background:"rgba(74, 222, 128, 0.15)",border:"1px solid #4ade80",borderRadius:"8px",padding:"12px",marginBottom:"16px",color:"#4ade80",fontSize:"13px"},children:Ee}),o.jsxs("div",{style:{marginBottom:"16px"},children:[o.jsx("label",{style:{color:"#888",fontSize:"13px",display:"block",marginBottom:"6px"},children:"Card Number"}),o.jsx("input",{type:"text",value:le.cardNumber,onChange:D=>ne({...le,cardNumber:D.target.value.replace(/\D/g,"").slice(0,16)}),placeholder:"1234 5678 9012 3456",style:{width:"100%",padding:"12px",borderRadius:"8px",border:"1px solid #444",background:"#2a2a2a",color:"white",fontSize:"14px",boxSizing:"border-box"},"data-testid":"input-card-number"})]}),o.jsxs("div",{style:{display:"flex",gap:"12px",marginBottom:"16px"},children:[o.jsxs("div",{style:{flex:1},children:[o.jsx("label",{style:{color:"#888",fontSize:"13px",display:"block",marginBottom:"6px"},children:"Expiry Month"}),o.jsx("input",{type:"text",value:le.expMonth,onChange:D=>ne({...le,expMonth:D.target.value.replace(/\D/g,"").slice(0,2)}),placeholder:"MM",maxLength:2,style:{width:"100%",padding:"12px",borderRadius:"8px",border:"1px solid #444",background:"#2a2a2a",color:"white",fontSize:"14px",boxSizing:"border-box"},"data-testid":"input-exp-month"})]}),o.jsxs("div",{style:{flex:1},children:[o.jsx("label",{style:{color:"#888",fontSize:"13px",display:"block",marginBottom:"6px"},children:"Expiry Year"}),o.jsx("input",{type:"text",value:le.expYear,onChange:D=>ne({...le,expYear:D.target.value.replace(/\D/g,"").slice(0,4)}),placeholder:"YYYY",maxLength:4,style:{width:"100%",padding:"12px",borderRadius:"8px",border:"1px solid #444",background:"#2a2a2a",color:"white",fontSize:"14px",boxSizing:"border-box"},"data-testid":"input-exp-year"})]}),o.jsxs("div",{style:{width:"80px"},children:[o.jsx("label",{style:{color:"#888",fontSize:"13px",display:"block",marginBottom:"6px"},children:"CVV"}),o.jsx("input",{type:"text",value:le.cvv,onChange:D=>ne({...le,cvv:D.target.value.replace(/\D/g,"").slice(0,4)}),placeholder:"123",maxLength:4,style:{width:"100%",padding:"12px",borderRadius:"8px",border:"1px solid #444",background:"#2a2a2a",color:"white",fontSize:"14px",boxSizing:"border-box"},"data-testid":"input-cvv"})]})]}
140),o.jsxs("div",{style:{marginBottom:"16px"},children:[o.jsx("label",{style:{color:"#888",fontSize:"13px",display:"block",marginBottom:"6px"},children:"Name on Card"}),o.jsx("input",{type:"text",value:le.cardholderName,onChange:D=>ne({...le,cardholderName:D.target.value}),placeholder:"John Doe",style:{width:"100%",padding:"12px",borderRadius:"8px",border:"1px solid #444",background:"#2a2a2a",color:"white",fontSize:"14px",boxSizing:"border-box"},"data-testid":"input-cardholder-name"})]}),o.jsxs("div",{style:{marginBottom:"16px",borderTop:"1px solid #333",paddingTop:"16px"},children:[o.jsx("p",{style:{color:"#888",fontSize:"12px",marginBottom:"12px"},children:"Billing Address"}),o.jsx("div",{style:{marginBottom:"12px"},children:o.jsx("input",{type:"text",value:le.street,onChange:D=>ne({...le,street:D.target.value}),placeholder:"Street Address",style:{width:"100%",padding:"12px",borderRadius:"8px",border:"1px solid #444",background:"#2a2a2a",color:"white",fontSize:"14px",boxSizing:"border-box"},"data-testid":"input-billing-street"})}),o.jsxs("div",{style:{display:"flex",gap:"12px",marginBottom:"12px"},children:[o.jsx("input",{type:"text",value:le.city,onChange:D=>ne({...le,city:D.target.value}),placeholder:"City",style:{flex:2,padding:"12px",borderRadius:"8px",border:"1px solid #444",background:"#2a2a2a",color:"white",fontSize:"14px",boxSizing:"border-box"},"data-testid":"input-billing-city"}),o.jsx("input",{type:"text",value:le.state,onChange:D=>ne({...le,state:D.target.value.toUpperCase().slice(0,2)}),placeholder:"State",maxLength:2,style:{width:"70px",padding:"12px",borderRadius:"8px",border:"1px solid #444",background:"#2a2a2a",color:"white",fontSize:"14px",boxSizing:"border-box",textTransform:"uppercase"},"data-testid":"input-billing-state"}),o.jsx("input",{type:"text",value:le.zipCode,onChange:D=>ne({...le,zipCode:D.target.value.replace(/\D/g,"").slice(0,5)}),placeholder:"ZIP",maxLength:5,style:{width:"80px",padding:"12px",borderRadius:"8px",border:"1px solid #444",background:"#2a2a2a",color:"white",fontSize:"14px",boxSizing:"border-box"},"data-testid":"input-billing-zip"})]})]}),o.jsxs("div",{style:{display:"flex",gap:"12px"},children:[o.jsx("button",{onClick:()=>{zt(!1),ne({cardNumber:"",expMonth:"",expYear:"",cvv:"",cardholderName:"",street:"",city:"",state:"",zipCode:""}),Dt(null),He(null)},style:{flex:1,padding:"12px",borderRadius:"8px",border:"1px solid #444",background:"transparent",color:"white",fontSize:"14px",cursor:"pointer"},"data-testid":"button-cancel-add-card",children:"Cancel"}),o.jsx("button",{onClick:async()=>{if(Dt(null),He(null),!le.cardNumber||!le.expMonth||!le.expYear||!le.cvv||!le.cardholderName){Dt("Please fill in all card details");return}if(!le.street||!le.city||!le.state||!le.zipCode){Dt("Please fill in your complete billing address");return}De(!0);try{const q=await(await fetch("/api/payments/config")).json();if(!q.configured){Dt("Payment processing is not configured yet. Please contact support."),De(!1);return}const se=q.publicClientKey,me=q.apiLoginId,Be=q.environment==="production"?"https://js.authorize.net/v1/Accept.js":"https://jstest.authorize.net/v1/Accept.js";if(window.Accept?await new Promise((fa,pl)=>{let _o=0;const zd=30,$d=()=>{typeof window.Accept?.dispatchData=="function"?fa():_o<zd?(_o++,setTimeout($d,100)):pl(new Error("Accept.js not ready"))};$d()}):await new Promise((fa,pl)=>{const _o=document.createElement("script");_o.src=Be,_o.onload=()=>{let zd=0;const $d=50,Km=()=>{window.Accept&&typeof window.Accept.dispatchData=="function"?fa():zd<$d?(zd++,setTimeout(Km,100)):pl(new Error("Accept.js failed to initialize"))};setTimeout(Km,200)},_o.onerror=()=>pl(new Error("Failed to load Accept.js")),document.head.appendChild(_o)}),!window.Accept||typeof window.Accept.dispatchData!="function"){Dt("Payment system failed to initialize. Please refresh the page and try again."),De(!1);return}const Ne={authData:{clientKey:se,apiLoginID:me},cardData:{cardNumber:le.cardNumber,month:le.expMonth,year:le.expYear,cardCode:le.cvv,fullName:le.cardholderName}},mt=await new Promise(fa=>{window.Accept.dispatchData(Ne,pl=>{fa(pl)})});if(mt.messages.resultCode==="Error"){const fa=mt.messages.message[0]?.text||"Card validation failed";Dt(fa),De(!1),ne({cardNumber:"",expMonth:"",expYear:"",cvv:"",cardholderName:"",street:"",city:"",state:"",zipCode:""});return}const Ut=le.cardNumber.charAt(0);let tn="Card";Ut==="4"?tn="Visa":Ut==="5"?tn="Mastercard":Ut==="3"?tn="Amex":Ut==="6"&&(tn="Discover");const cs=le.cardNumber.slice(-4),Kt=le.expMonth,Vs=le.expYear,zi=le.cardholderName,$i=mt.opaqueData;if(!w){Dt("Please sign in to save payment methods"),De(!1);return}const Iu=await w.getIdToken(),dc=await(await fetch("/api/payments/create-profile",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Iu}`},body:JSON.stringify({opaqueData:{dataDescriptor:$i.dataDescriptor,dataValue:$i.dataValue},billingAddress:{cardholderName:zi,street:le.street,city:le.city,state:le.state,zipCode:le.zipCode,country:"USA"},userId:w.uid,email:w.email})})).json();if(dc.success){await LP(w.uid,{cardLast4:cs,cardBrand:tn,expirationMonth:Kt,expirationYear:Vs,isDefault:ft.length===0,authorizeNetCustomerProfileId:dc.customerProfileId,authorizeNetPaymentProfileId:dc.paymentProfileId}),He("Payment method saved successfully!");const fa=await cd(w.uid);Nt(fa),setTimeout(()=>{zt(!1),He(null)},1500)}else Dt(dc.error||"Failed to save payment method")}catch{Dt("Failed to process payment method. Please try again.")}finally{De(!1),ne({cardNumber:"",expMonth:"",expYear:"",cvv:"",cardholderName:"",street:"",city:"",state:"",zipCode:""})}},disabled:J,style:{flex:1,padding:"12px",borderRadius:"8px",border:"none",background:"#4ade80",color:"black",fontSize:"14px",fontWeight:"bold",cursor:J?"wait":"pointer",opacity:J?.7:1},"data-testid":"button-save-card",children:J?"Saving...":"Save Card"})]})]})]})})]})}),Cn&&o.jsx("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0,0,0,0.85)",zIndex:3e3,display:"flex",justifyContent:"center",alignItems:"flex-start",paddingTop:"60px",overflowY:"auto"},onClick:()=>Mn(!1),children:o.jsxs("div",{style:{background:"#1e1e1e",borderRadius:"12px",width:"90%",maxWidth:"500px",maxHeight:"80vh",overflow:"hidden",display:"flex",flexDirection:"column"},onClick:D=>D.stopPropagation(),children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"20px",borderBottom:"1px solid #333"},children:[o.jsx("h2",{style:{color:"white",margin:0,fontSize:"20px",fontWeight:"bold"},children:"Manage Memberships"}),o.jsx("button",{onClick:()=>Mn(!1),style:{background:"none",border:"none",color:"#888",fontSize:"24px",cursor:"pointer",padding:"4px"},"data-testid":"button-close-memberships",children:"Ã"})]}),o.jsxs("div",{style:{padding:"20px",overflowY:"auto",flex:1},children:[o.jsxs("div",{style:{background:"#2a2a2a",borderRadius:"12px",padding:"16px",marginBottom:"20px"},children:[o.jsx("h3",{style:{color:"#4CAF50",margin:"0 0 12px 0",fontSize:"14px",fontWeight:"600"},children:"Your ChronicTV Plan"}),o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[o.jsxs("div",{children:[o.jsx("p",{style:{color:"white",margin:0,fontSize:"18px",fontWeight:"bold"},children:"Cultured"}),o.jsx("p",{style:{color:"#888",margin:"4px 0 0 0",fontSize:"12px"},children:"Free during beta"})]}),o.jsx("div",{style:{background:"#4CAF50",color:"white",padding:"6px 12px",borderRadius:"20px",fontSize:"12px",fontWeight:"bold"},children:"Active"})]})]}),o.jsx("h3",{style:{color:"white",margin:"0 0 16px 0",fontSize:"16px",fontWeight:"600"},children:"Chronic Brands Partners"}),o.jsx("p",{style:{color:"#888",margin:"0 0 16px 0",fontSize:"13px"},children:"Exclusive member perks from our partner brands"}),ai?o.jsx("div",{style:{textAlign:"center",padding:"20px",color:"#888"},children:"Loading partners..."}):Gn.length===0?o.jsx("div",{style:{textAlign:"center",padding:"20px",color:"#666"},children:"No partner brands available yet"}):o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:Gn.map((D,q)=>o.jsxs("a",{href:D.referralLink,target:"_blank",rel:"noopener noreferrer",style:{background:"#2a2a2a",borderRadius:"12px",padding:"14px",textDecoration:"none",display:"block",transition:"background 0.2s"},"data-testid":`partner-brand-${q}`,onMouseEnter:se=>se.currentTarget.style.background="#363636",onMouseLeave:se=>se.currentTarget.style.background="#2a2a2a",children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[o.jsxs("div",{style:{flex:1,minWidth:0},children:[o.jsx("h4",{style:{color:"white",margin:"0 0 2px 0",fontSize:"14px",fontWeight:"600"},children:D.brandName}),o.jsx("p",{style:{color:"#888",margin:0,fontSize:"12px"},children:D.shortInfo})]}),o.jsx("div",{style:{color:"#4CAF50",fontSize:"18px",marginLeft:"8px",flexShrink:0},children:"â"})]}),D.discount&&o.jsx("div",{style:{marginTop:"8px",padding:"6px 10px",background:"rgba(74, 222, 128, 0.15)",borderRadius:"6px",borderLeft:"3px solid #4ade80"},children:o.jsxs("p",{style:{color:"#4ade80",margin:0,fontSize:"11px",fontWeight:"500",lineHeight:"1.4"},children:["ð ",D.discount]})})]},D.id||q))})]})]})}),Js&&Pn&&o.jsxs("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"#1a1a1a",zIndex:2e3,overflowY:"auto",overflowX:"hidden",paddingTop:"env(safe-area-inset-top, 0px)",boxSizing:"border-box"},children:[o.jsxs("div",{style:{width:"100%",position:"relative",backgroundColor:"#000"},children:[o.jsx(g_,{video:Pn,broadcastTiming:void 0,onBack:()=>{an(!1),rn(null)},onNearEnd:()=>
140{if(Xt&&ye?.videos){const D=ye.videos.filter(me=>me.categoryIds?.includes(Xt.id)).sort((me,xe)=>(me.order||0)-(xe.order||0)),q=D.findIndex(me=>me.id===Pn.id),se=D[q+1];se&&En<2&&(Mi(Lo(se)),la(!0),er(5))}},onVideoEnd:()=>{const D=En+1;if(ic(D),Xt&&ye?.videos&&D>=3){const q=ye.videos.filter(xe=>xe.categoryIds?.includes(Xt.id)).sort((xe,Be)=>(xe.order||0)-(Be.order||0)),se=q.findIndex(xe=>xe.id===Pn.id),me=q[se+1];me&&(Mi(Lo(me)),la(!1),ca(!0))}}}),Zs&&Oi&&!Fd&&o.jsxs("div",{style:{position:"absolute",bottom:"80px",right:"20px",background:"rgba(0,0,0,0.9)",borderRadius:"12px",padding:"16px 20px",display:"flex",alignItems:"center",gap:"16px",zIndex:100},children:[o.jsxs("div",{style:{color:"white"},children:[o.jsx("p",{style:{margin:0,fontSize:"12px",color:"#888"},children:"Up Next"}),o.jsx("p",{style:{margin:"4px 0 0 0",fontSize:"14px",fontWeight:"bold"},children:Oi.title||Oi.name}),o.jsxs("p",{style:{margin:"4px 0 0 0",fontSize:"12px",color:"#4CAF50"},children:["Playing in ",ji,"..."]})]}),o.jsx("button",{onClick:()=>{la(!1),er(5),Mi(null)},style:{background:"#333",border:"none",borderRadius:"6px",padding:"8px 12px",color:"white",cursor:"pointer",fontSize:"12px"},"data-testid":"button-cancel-autoplay",children:"Cancel"}),o.jsx("button",{onClick:()=>{la(!1),er(5),rn(Oi),Mi(null)},style:{background:"#4CAF50",border:"none",borderRadius:"6px",padding:"8px 16px",color:"white",cursor:"pointer",fontSize:"12px",fontWeight:"bold"},"data-testid":"button-play-next",children:"Play Now"})]}),Fd&&o.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,background:"rgba(0,0,0,0.9)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:200},children:o.jsxs("div",{style:{background:"#1e1e1e",borderRadius:"16px",padding:"32px",textAlign:"center",maxWidth:"400px",width:"90%"},children:[o.jsx("h2",{style:{color:"white",margin:"0 0 8px 0",fontSize:"24px"},children:"Are you still watching?"}),o.jsx("p",{style:{color:"#888",margin:"0 0 24px 0",fontSize:"14px"},children:Xt?.name||"ChronicTV"}),o.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center"},children:[o.jsx("button",{onClick:()=>{ca(!1),la(!1),Mi(null),ic(0),an(!1),rn(null)},style:{background:"#333",border:"none",borderRadius:"8px",padding:"14px 24px",color:"white",cursor:"pointer",fontSize:"14px"},"data-testid":"button-done-watching",children:"I'm done for now"}),o.jsx("button",{onClick:()=>{ca(!1),ic(0),Oi&&(la(!0),er(5))},style:{background:"#4CAF50",border:"none",borderRadius:"8px",padding:"14px 24px",color:"white",cursor:"pointer",fontSize:"14px",fontWeight:"bold"},"data-testid":"button-continue-watching",children:"Continue Watching"})]})]})})]}),o.jsxs("div",{style:{paddingBottom:"100px"},children:[o.jsxs("div",{style:{padding:"16px 16px 0"},children:[Xt&&o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",marginBottom:"8px"},children:[o.jsx("span",{style:{fontSize:"12px",color:"#4ade80",fontWeight:"600",textTransform:"uppercase",letterSpacing:"0.05em"},children:Xt.name}),o.jsx("span",{style:{color:"#333",fontSize:"12px"},children:"·"}),o.jsx("span",{style:{fontSize:"12px",color:"#555"},children:"ChronicTV"})]}),o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"12px",marginBottom:"12px"},children:[o.jsx("h1",{style:{fontSize:"clamp(17px, 4vw, 22px)",fontWeight:"700",color:"white",margin:0,flex:1,lineHeight:1.35},"data-testid":"text-video-title",children:Pn.title||Pn.customTitle||Pn.extractedTitle||"Untitled Video"}),o.jsxs("button",{onClick:()=>{const D=O(Xt?.name||"show"),q=Pn.title||Pn.customTitle||Pn.extractedTitle||"episode",se=O(q),me=`${window.location.origin}/chronictv/${encodeURIComponent(D)}/${encodeURIComponent(se)}`;navigator.share?navigator.share({title:Pn.title||"ChronicTV Video",url:me}).catch(()=>{}):(navigator.clipboard.writeText(me),alert("Link copied!"))},style:{background:"rgba(255,255,255,0.07)",border:"1px solid rgba(255,255,255,0.12)",borderRadius:"20px",padding:"7px 14px",color:"#ddd",cursor:"pointer",display:"flex",alignItems:"center",gap:"6px",fontSize:"13px",fontWeight:"600",whiteSpace:"nowrap",flexShrink:0,transition:"background 0.15s"},onMouseEnter:D=>D.currentTarget.style.background="rgba(255,255,255,0.12)",onMouseLeave:D=>D.currentTarget.style.background="rgba(255,255,255,0.07)","data-testid":"button-share-video",children:[o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[o.jsx("path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8"}),o.jsx("polyline",{points:"16 6 12 2 8 6"}),o.jsx("line",{x1:"12",y1:"2",x2:"12",y2:"15"})]}),"Share"]})]}),(()=>{const D=Pn.description||Pn.extractedDescription||ye?.showDescriptions?.[Xt?.name||""]||(Xt?.name?`Watch ${Pn.title||"this episode"} from ${Xt.name} on ChronicTV.`:"Stream this episode on ChronicTV.");return o.jsxs("div",{style:{marginBottom:"20px"},children:[o.jsx("p",{style:{fontSize:"14px",color:"#aaa",lineHeight:1.65,margin:0,display:Fi?"block":"-webkit-box",WebkitLineClamp:Fi?void 0:2,WebkitBoxOrient:"vertical",overflow:Fi?"visible":"hidden"},"data-testid":"text-video-description",children:D}),D&&D.length>120&&o.jsx("button",{onClick:()=>Ui(q=>!q),style:{background:"none",border:"none",padding:"4px 0 0",color:"#4ade80",cursor:"pointer",fontSize:"13px",fontWeight:"600"},children:Fi?"Show less":"Show more"})]})})()]}),o.jsx("div",{style:{padding:"0 16px",marginBottom:"8px"},children:o.jsx(Lee,{videoId:Pn.id,firebaseUser:w,onSignInPrompt:()=>G(!0)})}),o.jsx("div",{style:{height:"1px",background:"rgba(255,255,255,0.06)",margin:"8px 0 0"}}),Xt&&(()=>{const D=(ye?.videos||[]).filter(q=>q.categoryIds?.includes(Xt.id)&&q.id!==Pn.id);return D.length===0?null:o.jsxs("div",{style:{padding:"24px 16px 0"},children:[o.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"14px"},children:o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[o.jsx("div",{style:{width:"3px",height:"18px",background:"#4ade80",borderRadius:"2px",flexShrink:0}}),o.jsxs("div",{children:[o.jsx("h2",{style:{fontSize:"15px",fontWeight:"700",color:"white",margin:0,lineHeight:1.2},children:"More from this show"}),o.jsxs("span",{style:{fontSize:"12px",color:"#555"},children:[D.length," episode",D.length!==1?"s":""]})]})]})}),o.jsx("div",{style:{display:"flex",overflowX:"auto",gap:"10px",paddingBottom:"4px",scrollSnapType:"x mandatory",WebkitOverflowScrolling:"touch",msOverflowStyle:"none",scrollbarWidth:"none"},children:D.slice(0,20).map(q=>o.jsxs("div",{onClick:()=>{rn(Lo(q)),Ui(!1)},style:{flex:"0 0 auto",width:"clamp(150px, 42vw, 190px)",background:"#161616",borderRadius:"10px",overflow:"hidden",cursor:"pointer",scrollSnapAlign:"start",transition:"transform 0.18s",border:"1px solid rgba(255,255,255,0.06)"},onMouseEnter:se=>{se.currentTarget.style.transform="scale(1.02)"},onMouseLeave:se=>{se.currentTarget.style.transform="scale(1)"},"data-testid":`card-episode-${q.id}`,children:[o.jsxs("div",{style:{aspectRatio:"16/9",position:"relative",overflow:"hidden",background:q.thumbnailUrl?"#000":"#1a1a1a"},children:[q.thumbnailUrl?o.jsx("img",{src:q.thumbnailUrl,alt:q.title,style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}}):o.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",fontSize:"22px",color:"#333"},children:"â¶"}),q.duration&&o.jsxs("div",{style:{position:"absolute",bottom:"5px",right:"5
140px",background:"rgba(0,0,0,0.85)",padding:"2px 5px",borderRadius:"3px",fontSize:"11px",color:"white",fontWeight:"600"},children:[Math.floor(q.duration/60),":",(q.duration%60).toString().padStart(2,"0")]})]}),o.jsx("div",{style:{padding:"9px 10px 10px"},children:o.jsx("p",{style:{fontSize:"12px",color:"#e0e0e0",margin:0,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",lineHeight:1.4},children:q.title})})]},`more-${q.id}`))})]})})(),(()=>{const D=(ye?.videos||[]).filter(q=>q.id!==Pn.id&&q.thumbnailUrl&&!(Xt&&q.categoryIds?.includes(Xt.id))).slice(0,20);return D.length===0?null:o.jsxs("div",{style:{padding:"28px 16px 0"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",marginBottom:"14px"},children:[o.jsx("div",{style:{width:"3px",height:"18px",background:"rgba(255,255,255,0.2)",borderRadius:"2px",flexShrink:0}}),o.jsxs("div",{children:[o.jsx("h2",{style:{fontSize:"15px",fontWeight:"700",color:"white",margin:0,lineHeight:1.2},children:"You might also like"}),o.jsx("span",{style:{fontSize:"12px",color:"#555"},children:"From across ChronicTV"})]})]}),o.jsx("div",{style:{display:"flex",overflowX:"auto",gap:"10px",paddingBottom:"4px",scrollSnapType:"x mandatory",WebkitOverflowScrolling:"touch",msOverflowStyle:"none",scrollbarWidth:"none"},children:D.map(q=>{const se=ye?.categories?.find(me=>me.id===q.categoryIds?.[0]);return o.jsxs("div",{onClick:()=>{rn(Lo(q)),Ui(!1)},style:{flex:"0 0 auto",width:"clamp(150px, 42vw, 190px)",background:"#111",borderRadius:"10px",overflow:"hidden",cursor:"pointer",scrollSnapAlign:"start",transition:"transform 0.18s",border:"1px solid rgba(255,255,255,0.05)"},onMouseEnter:me=>{me.currentTarget.style.transform="scale(1.02)"},onMouseLeave:me=>{me.currentTarget.style.transform="scale(1)"},"data-testid":`card-suggested-${q.id}`,children:[o.jsxs("div",{style:{aspectRatio:"16/9",position:"relative",overflow:"hidden",background:"#181818"},children:[o.jsx("img",{src:q.thumbnailUrl,alt:q.title,style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}}),q.duration&&o.jsxs("div",{style:{position:"absolute",bottom:"5px",right:"5px",background:"rgba(0,0,0,0.85)",padding:"2px 5px",borderRadius:"3px",fontSize:"11px",color:"white",fontWeight:"600"},children:[Math.floor(q.duration/60),":",(q.duration%60).toString().padStart(2,"0")]})]}),o.jsxs("div",{style:{padding:"9px 10px 10px"},children:[o.jsx("p",{style:{fontSize:"12px",color:"#e0e0e0",margin:0,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",lineHeight:1.4},children:q.title}),se&&o.jsx("p",{style:{fontSize:"11px",color:"#4a4a4a",margin:"4px 0 0",fontWeight:"500"},children:se.name})]})]},`suggested-${q.id}`)})})]})})(),pn()]})]}),Ba&&Xt&&o.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.8)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:"clamp(20px, 4vw, 40px)"},children:o.jsxs("div",{style:{background:"#2a2a2a",borderRadius:"12px",padding:"clamp(20px, 4vw, 30px)",maxWidth:"500px",width:"100%",maxHeight:"80vh",overflow:"auto"},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"20px"},children:[o.jsx("h2",{style:{fontSize:"clamp(18px, 3vw, 24px)",color:"white",margin:0,fontWeight:"bold"},children:Xt.name}),o.jsx("button",{onClick:()=>oa(!1),style:{background:"none",border:"none",color:"#999",fontSize:"24px",cursor:"pointer",padding:"5px"},children:"Ã"})]}),o.jsx("p",{style:{color:"#ccc",fontSize:"clamp(14px, 2.5vw, 16px)",lineHeight:"1.5",margin:"0 0 20px 0"},children:vs[Xt.name]||Xt.description||"Loading Summary..."})]})}),o.jsxs("div",{ref:uc,style:{position:"absolute",top:"calc(80px + var(--safe-area-inset-top, 0px))",left:0,right:0,bottom:"var(--safe-area-inset-bottom, 0px)",boxSizing:"border-box",overflow:"auto",WebkitOverflowScrolling:"touch"},children:[Xt&&!Js?o.jsx("div",{style:{background:"#1a1a1a",minHeight:"100%",width:"100%"},children:o.jsx(Aie,{show:Xt,startupData:ye,showLiveUrls:ye?.showLiveUrls,showDescriptions:ye?.showDescriptions,initialAlbumId:ha,onBack:()=>{Kn(null),hl(void 0),window.history.pushState({},"","/chronictv")},onPlayVideo:D=>{rn(D),an(!0);const q=O(Xt?.name||"show"),se=D.title||D.customTitle||D.extractedTitle||"episode",me=O(se);window.history.pushState({screen:"video"},"",`/chronictv/${q}/${me}`)}})}):s==="NOW_PLAYING"?o.jsxs("div",{style:{margin:0,padding:0,width:"100%",maxWidth:"100vw",boxSizing:"border-box",overflow:"hidden"},children:[o.jsx("div",{style:{background:"#000",position:"relative",width:"100%",aspectRatio:"16/9",maxHeight:"calc(100vh - 120px)",overflow:"hidden",boxSizing:"border-box",margin:0,padding:0},children:l?o.jsx(g_,{video:l,broadcastTiming:d?.timing?{elapsedSeconds:d.timing.elapsedSeconds,startPositionSeconds:d.timing.elapsedSeconds,scheduledStartSeconds:d.timing.scheduledStartSeconds}:void 0,onVideoEnd:()=>{Ha().then(()=>{}).catch(D=>{})},onBack:()=>{}}):o.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",background:"#222"},children:o.jsx("p",{children:"Loading broadcast..."})})}),o.jsxs("div",{style:{background:"#2a2a2a",padding:"clamp(12px, 2vh, 20px)",margin:0},children:[o.jsx("h3",{style:{fontSize:"clamp(14px, 2.5vw, 16px)",marginBottom:"clamp(8px, 1.5vh, 15px)",fontWeight:"bold",margin:0,paddingBottom:"clamp(8px, 1.5vh, 15px)"},children:"Now Playing"}),o.jsx("div",{style:{maxHeight:"clamp(60px, 8vh, 80px)",overflow:"hidden"},children:Of.slice(0,1).map((D,q)=>o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"clamp(8px, 1.5vh, 12px) 0",background:D.status==="LIVE NOW"?"rgba(76, 175, 80, 0.1)":"transparent",borderLeft:D.status==="LIVE NOW"?"3px solid #4CAF50":"none",paddingLeft:D.status==="LIVE NOW"?"clamp(12px, 2vw, 15px)":"0"},children:[o.jsxs("div",{style:{flex:1},children:[o.jsx("h4",{style:{fontSize:"clamp(12px, 2vw, 14px)",margin:"0 0 4px 0",fontWeight:"bold",color:D.status==="LIVE NOW"?"#4CAF50":"white"},children:D.title}),o.jsxs("p",{style:{fontSize:"clamp(10px, 1.5vw, 12px)",margin:0,opacity:.7},children:[D.startTime," - ",D.endTime,D.status==="LIVE NOW"&&D.remaining&&o.jsxs("span",{style:{color:"#4CAF50",marginLeft:"8px"},children:["⢠",D.remaining," remaining"]})]})]}),o.jsxs("div",{style:{fontSize:"clamp(10px, 1.5vw, 12px)",opacity:.8,textAlign:"right"},children:[D.status==="LIVE NOW"&&o.jsx("div",{style:{background:"#4CAF50",color:"white",padding:"2px 6px",borderRadius:"3px",fontSize:"clamp(8px, 1.2vw, 10px)",fontWeight:"bold",marginBottom:"4px"},children:"On Now"}),jf(D.duration)]})]},q))}),Of.length>1&&o.jsx("div",{style:{paddingTop:"clamp(8px, 1.5vh, 15px)",borderTop:"1px solid #333",marginTop:"clamp(8px, 1.5vh, 15px)"},children:Of.slice(1,5).map((D,q)=>o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"clamp(8px, 1.5vh, 12px) 0",borderBottom:q<3?"1px solid #4a5568":"none"},children:[o.jsxs("div",{style:{flex:1},children:[o.jsx("h4",{style:{fontSize:"clamp(12px, 2vw, 14px)",margin:"0 0 4px 0",fontWeight:"bold"},children:D.title}),o.jsxs("p",{style:{fontSize:"clamp(10px, 1.5vw, 12px)",margin:0,opacity:.7},children:[D.startTime," - ",D.endTime]})]}),o.jsx("div",{style:{fontSize:"clamp(10px, 1.5vw, 12px)",opacity:.8},children:jf(D.duration)})]},q+1))}),o.jsx("div",{style:{paddingTop:"clamp(15px, 3vh, 20px)",display:"flex",justifyContent:"flex-end"},children:o.jsx("button",{onClick:()=>ci(!0),style:{padding:"clamp(8px, 1.5vh, 10px) clamp(16px, 3vw, 20px)",background:"#4ade80",color:"black",border:"none",borderRadius:"6px",fontSize:"clamp(12px, 2vw, 14px)",fontWeight:"bold",cursor:"pointer",transition:"all 0.2s ease",whiteSpace:"nowrap"},onMouseEnter:D=>{D.currentTarget.style.background="#22c55e"},onMouseLeave:D=>{D.currentTarget.style.background="#4ade80"},children:"Playlist Schedule"})})]}),w&&_.length>0&&o.jsxs("div",{style:{background:"#1a1a1a",padding:"clamp(15px, 3vh, 25px)",margin:0,borderBottom:"1px solid #333"},children:[o.jsx("h3",{style:{fontSize:"clamp(14px, 2.5vw, 16px)",marginBottom:"clamp(10px, 2vh, 15px)",fontWeight:"bold",margin:0,paddingBottom:"clamp(10px, 2vh, 15px)",color:"white"},children:"Continue Watching"}),o.jsx("div",{style:{display:"flex",gap:"clamp(12px, 2vw, 16px)",overflowX:"auto",paddingBottom:"8px",WebkitOverflowScrolling:"touch"},children:_.map(D=>{const q=D.durationSeconds>0?Math.round(D.progressSeconds/D.durationSeconds*100):0;return o.jsxs("div",{onClick:()=>{const me=(ye?.videos||[]).find(xe=>String(xe.id)===D.videoId||xe.uri?.includes(D.videoId));me&&(rn(me),an(!0))},style:{flexShrink:0,width:"clamp(140px, 20vw, 180px)",cursor:"pointer",transition:"transform 0.2s ease"},onMouseEnter:se=>se.currentTarget.style.transform="scale(1.02)",onMouseLeave:se=>se.currentTarget.style.transform="scale(1)","data-testid":`card-continue-watching-${D.videoId}`,children:[o.jsxs("div",{style:{aspectRatio:"16/9",borderRadius:"8px",overflow:"hidden",background:"#333",position:"relative"},children:[o.jsx("img",{src:D.thumbnailUrl?Eh(D.thumbnailUrl):"/api/thumbnails/placeholder",alt:D.videoTitle,style:{width:"100%",height:"100%",objectFit:"cover"},onError:se=>{se.target.style.display="none"}}),o.jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,height:"4px",background:"rgba(0,0,0,0.5)"},children:o.jsx("div",{style:{height:"100%",width:`${q}%`,background:"#4CAF50",transition:"width 0.3s ease"}})}),o.jsx("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",background:"rgba(0,0,0,0.6)",borderRadius:"50%",width:"36px",height:"36px",display:"flex",alignItems:"center",justifyContent:"center"},children:o.jsx(Bc,{size:18,fill:"white",color:"white"})})]}),o.jsx("p",{style:{fontSize:"clamp(10px, 1.5vw, 12px)",margin:"8px 0 2px 0",color:"white",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:D.videoTitle}),o.jsx("p",{style:{fontSize:"clamp(9px, 1.2vw, 10px)",margin:0,color:"#888"},children:D.showName||"Resume watching"})]},D.videoId)})})]}),fl&&fl.length>0&&o.jsxs("div",{style:{background:"#1a1a1a",padding:"clamp(15px, 3vh, 25px)",margin:0},children:[o.jsx("h3",{style:{fontSize:"clamp(14px, 2.5vw, 16px)",marginBottom:"clamp(10px, 2vh, 15px)",fontWeight:"bold",margin:0,paddingBottom:"clamp(10px, 2vh, 15px)",color:"white"},children:"Top Creators"}),o.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(80px, 100px))",gap:"clamp(10px, 2vw, 15px)",justifyContent:"start"},children:fl.map((D,q)=>{const se=D.liveUrl||So[D.name];return o.jsxs("div",{onClick:()=>{se&&window.open(se,"_blank","noopener,noreferrer")},style:{cursor:se?"pointer":"default",textAlign:"center",transition:"transform 0.2s ease",opacity:se?1:.6},onMouseEnter:me=>{se&&(me.currentTarget.style.transform="scale(1.05)")},onMouseLeave:me=>{se&&(me.currentTarget.style.transform="scale(1)")},children:[o.jsxs("div",{style:{width:"clamp(60px, 8vw, 80px)",height:"clamp(60px, 8vw, 80px)",borderRadius:"50%",background:"#333",margin:"0 auto 8px auto",border:D.liveUrl?"2px solid #4CAF50":"2px solid #666",position:"relative",overflow:"visible"},children:[q<3&&o.jsx("div",{style:{position:"absolute",top:"-4px",right:"-4px",width:"24px",height:"24px",borderRadius:"50%",background:q===0?"linear-gradient(135deg, #FFD700, #FFA500)":q===1?"linear-gradient(135deg, #C0C0C0, #A8A8A8)":"linear-gradient(135deg, #CD7F32, #8B4513)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",fontWeight:"bold",color:q===0?"#000":"#fff",zIndex:10,boxShadow:"0 2px 4px rgba(0,0,0,0.3)",border:"2px s
140olid #1a1a1a"},"data-testid":`badge-rank-${q+1}`,children:q===0?"ð¥":q===1?"ð¥":"ð¥"}),D.thumbnailUrl?o.jsx("img",{src:Eh(D.thumbnailUrl),alt:D.name,style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"},onError:me=>{me.target.style.display="none"}}):o.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",background:"#333",color:"#666",fontSize:"clamp(10px, 1.5vw, 12px)",borderRadius:"50%"},children:D.name?.charAt(0)||"?"})]}),o.jsx("p",{style:{fontSize:"clamp(10px, 1.5vw, 12px)",margin:0,color:"white",fontWeight:"500",textAlign:"center",lineHeight:1.2},children:D.name})]},D.id||q)})})]}),pn()]}):null,s==="ORIGINALS"&&!Xt&&o.jsxs("div",{className:"content-screen content-screen--originals",style:{padding:"clamp(15px, 3vw, 25px)",background:"#0a0a0a",minHeight:"calc(100vh - 120px)"},children:[o.jsxs("div",{className:"catalog-hero catalog-hero--with-wall",children:[o.jsx(ob,{items:Gw(ye?.originalsCategories,nr.originals?.sections)}),o.jsxs("div",{className:"catalog-hero__copy",children:[o.jsx("span",{className:"catalog-hero__eyebrow",children:"Made on Chronic TV"}),o.jsx("h2",{className:"catalog-hero__title",children:"Originals"}),o.jsx("p",{className:"catalog-hero__description",children:"Distinct voices, culture, conversations, and series from the Chronic TV community."})]})]}),w&&R.length>0&&o.jsxs("div",{style:{background:"#111",padding:"clamp(15px, 3vh, 25px)",borderBottom:"1px solid #222",marginBottom:24,position:"relative",overflow:"visible"},children:[o.jsx("h3",{style:{fontSize:"clamp(18px, 3.5vw, 22px)",fontWeight:700,color:"white",margin:"0 0 14px",letterSpacing:"-0.3px"},children:"Suggested For You"}),o.jsx(y0,{children:R.map((D,q)=>{const se=Hu(D,ye?.videos||[],ye?.urlContent||[],ye?.categories||[],ye?.audioAlbums||[]),me=[];return se.totalEpisodes>0&&me.push(`${se.totalEpisodes} ${se.totalEpisodes===1?"ep":"eps"}`),se.seasonCount>0&&me.push(`${se.seasonCount} series`),o.jsx($u,{isFirst:q===0,thumbnailSrc:D.thumbnailUrl||null,title:D.name,subtitle:me.join(", ")||void 0,description:vs[D.name],onClick:()=>$(D),onKeyDown:xe=>{(xe.key==="Enter"||xe.key===" ")&&(xe.preventDefault(),$(D))}},D.id)})})]}),qn?o.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(clamp(150px, 20vw, 200px), 1fr))",gap:"clamp(15px, 3vw, 25px)"},children:[1,2,3].map(D=>o.jsx("div",{style:{background:"#2a2a2a",borderRadius:"8px",overflow:"hidden",border:"1px solid #333"},children:o.jsx("div",{style:{aspectRatio:"16/9",background:"#333",display:"flex",alignItems:"center",justifyContent:"center",color:"#666"},children:"Loading..."})},D))}):nr.originals?.sections?.some(D=>(D.categoryIds||[]).length>0||(D.archiveIds||[]).length>0)?o.jsx("div",{style:{overflow:"visible"},children:nr.originals.sections.map((D,q)=>{const se=(D.categoryIds||[]).map(xe=>ye?.originalsCategories?.find(Be=>String(Be.id)===xe)||ye?.categories?.find(Be=>String(Be.id)===xe)).filter(Boolean),me=D.archiveIds||[];return se.length===0&&me.length===0?null:o.jsxs("div",{style:{marginBottom:40,overflow:"visible"},children:[o.jsx("h3",{className:"catalog-section-title",style:{fontSize:"clamp(18px, 3.5vw, 22px)",fontWeight:700,color:"white",margin:"0 0 4px 8px",letterSpacing:"-0.3px"},children:D.title}),o.jsxs(y0,{children:[se.map((xe,Be)=>{const Ne=Hu(xe,ye?.videos||[],ye?.urlContent||[],ye?.categories||[],ye?.audioAlbums||[]),mt=[];Ne.totalEpisodes>0&&mt.push(`${Ne.totalEpisodes} ${Ne.totalEpisodes===1?"ep":"eps"}`),Ne.seasonCount>0&&mt.push(`${Ne.seasonCount} series`);const Ut=di.has(xe.name)||bs.has(String(xe.id))?"LIVE":void 0;return o.jsx($u,{isFirst:Be===0,thumbnailSrc:xe.thumbnailUrl||null,title:xe.name,subtitle:mt.join(", ")||void 0,description:vs[xe.name],badge:Ut,onClick:()=>$(xe),onKeyDown:tn=>{(tn.key==="Enter"||tn.key===" ")&&(tn.preventDefault(),$(xe))}},xe.id)}),me.map(xe=>{const Be=dl[xe],Ne=Be?.title||xe,mt=Be?.thumbnailUrl||`https://archive.org/services/img/${xe}`;return o.jsx($u,{thumbnailSrc:mt,title:Ne,subtitle:Be?.year?String(Be.year):void 0,onClick:()=>ue(xe,Ne),onKeyDown:Ut=>{(Ut.key==="Enter"||Ut.key===" ")&&(Ut.preventDefault(),ue(xe,Ne))}},`archive-${xe}`)})]})]},`${D.title}-${q}`)})}):o.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(clamp(150px, 20vw, 200px), 1fr))",gap:"clamp(15px, 3vw, 25px)"},children:ye?.originalsCategories?.filter(D=>!D.isSeasonFolder).map(D=>{const q=D.thumbnailUrl||null,se=Hu(D,ye?.videos||[],ye?.urlContent||[],ye?.categories||[],ye?.audioAlbums||[]),me=[];se.totalEpisodes>0&&me.push(`${se.totalEpisodes} ${se.totalEpisodes===1?"episode":"episodes"}`),se.seasonCount>0&&me.push(`${se.seasonCount} series`),se.albumCount>0&&me.push(`${se.albumCount} ${se.albumCount===1?"album":"albums"}`);const xe=me.join(", ")||"No content";return o.jsxs("div",{style:{background:"#2a2a2a",borderRadius:"8px",overflow:"hidden",cursor:"pointer",transition:"transform 0.3s ease",border:"1px solid #333"},onClick:()=>$(D),onMouseEnter:Be=>Be.currentTarget.style.transform="scale(1.05)",onMouseLeave:Be=>Be.currentTarget.style.transform="scale(1)",children:[o.jsxs("div",{style:{aspectRatio:"16/9",background:q?`url(${q})`:"#2a2a2a",backgroundSize:"cover",backgroundPosition:"center",position:"relative"},children:[!q&&o.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",background:"#2a2a2a",color:"#4CAF50",fontSize:"clamp(12px, 2vw, 16px)",fontWeight:"bold"}
140,children:"Thumbnail Coming Soon"}),_u.includes(D.name)&&o.jsx("div",{style:{position:"absolute",top:10,left:10,background:"linear-gradient(135deg, #FFD700, #FFA500)",color:"black",padding:"4px 8px",borderRadius:12,fontSize:10,fontWeight:"bold"},children:"TOP"}),(di.has(D.name)||bs.has(D.id))&&o.jsxs("div",{style:{position:"absolute",top:10,right:10,display:"flex",alignItems:"center",gap:4,background:"#FF0000",color:"white",padding:"4px 8px",borderRadius:12,fontSize:10,fontWeight:"bold",animation:"pulse 2s ease-in-out infinite"},children:[o.jsx("span",{style:{width:6,height:6,background:"white",borderRadius:"50%",animation:"pulse 1s ease-in-out infinite"}}),"LIVE"]})]}),o.jsxs("div",{style:{padding:"clamp(10px, 2vw, 15px)"},children:[o.jsx("h3",{style:{fontSize:"clamp(12px, 2vw, 14px)",color:"white",margin:"0 0 4px 0",fontWeight:"bold"},children:D.name}),o.jsx("p",{style:{fontSize:"clamp(10px, 1.5vw, 12px)",color:"#999",margin:"0 0 8px 0"},children:xe}),vs[D.name]&&o.jsx("p",{style:{fontSize:"clamp(9px, 1.4vw, 11px)",color:"#ccc",margin:0,lineHeight:1.3,display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden"},children:vs[D.name]})]})]},D.id)})}),pn()]}),s==="CHANNELS"&&!Xt&&o.jsxs("div",{className:"content-screen content-screen--channels",style:{padding:"clamp(15px, 3vw, 25px)",background:"#0a0a0a",minHeight:"calc(100vh - 120px)"},children:[o.jsxs("div",{className:"catalog-hero catalog-hero--with-wall",children:[o.jsx(ob,{items:Gw([...ye?.channelsCategories||[],...ye?.originalsCategories||[],...ye?.moviesCategories||[],...ye?.categories||[]],void 0)}),o.jsxs("div",{className:"catalog-hero__copy",children:[o.jsx("span",{className:"catalog-hero__eyebrow",children:"Always on"}),o.jsx("h2",{className:"catalog-hero__title",children:"Channels"}),o.jsx("p",{className:"catalog-hero__description",children:"Live community programming, creator-led shows, and the voices shaping the network."})]})]}),qn?o.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(clamp(150px, 20vw, 200px), 1fr))",gap:"clamp(15px, 3vw, 25px)"},children:[1,2,3].map(D=>o.jsx("div",{style:{background:"#2a2a2a",borderRadius:"8px",overflow:"hidden",border:"1px solid #333"},children:o.jsx("div",{style:{aspectRatio:"16/9",background:"#333",display:"flex",alignItems:"center",justifyContent:"center",color:"#666"},children:"Loading..."})},D))}):nr.channels?.sections?.some(D=>(D.categoryIds||[]).length>0||(D.archiveIds||[]).length>0)?o.jsx("div",{style:{overflow:"visible"},children:nr.channels.sections.map((D,q)=>{const se=(D.categoryIds||[]).map(xe=>ye?.channelsCategories?.find(Be=>String(Be.id)===xe)||ye?.originalsCategories?.find(Be=>String(Be.id)===xe)||ye?.categories?.find(Be=>String(Be.id)===xe)).filter(Boolean),me=D.archiveIds||[];return se.length===0&&me.length===0?null:o.jsxs("div",{style:{marginBottom:40,overflow:"visible"},children:[o.jsx("h3",{className:"catalog-section-title",style:{fontSize:"clamp(18px, 3.5vw, 22px)",fontWeight:700,color:"white",margin:"0 0 4px 8px",letterSpacing:"-0.3px"},children:D.title}),o.jsxs(y0,{children:[se.map((xe,Be)=>{const Ne=Hu(xe,ye?.videos||[],ye?.urlContent||[],ye?.categories||[],ye?.audioAlbums||[]),mt=[];Ne.totalEpisodes>0&&mt.push(`${Ne.totalEpisodes} ${Ne.totalEpisodes===1?"ep":"eps"}`),Ne.seasonCount>0&&mt.push(`${Ne.seasonCount} series`);const Ut=di.has(xe.name)||bs.has(String(xe.id))?"LIVE":void 0;return o.jsx($u,{isFirst:Be===0,thumbnailSrc:xe.thumbnailUrl||null,title:xe.name,subtitle:mt.join(", ")||void 0,description:vs[xe.name],badge:Ut,onClick:()=>$(xe),onKeyDown:tn=>{(tn.key==="Enter"||tn.key===" ")&&(tn.preventDefault(),$(xe))}},xe.id)}),me.map(xe=>{const Be=dl[xe],Ne=Be?.title||xe,mt=Be?.thumbnailUrl||`https://archive.org/services/img/${xe}`;return o.jsx($u,{thumbnailSrc:mt,title:Ne,subtitle:Be?.year?String(Be.year):void 0,onClick:()=>ue(xe,Ne),onKeyDown:Ut=>{(Ut.key==="Enter"||Ut.key===" ")&&(Ut.preventDefault(),ue(xe,Ne))}},`archive-${xe}`)})]})]},`${D.title}-${q}`)})}):o.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(clamp(150px, 20vw, 200px), 1fr))",gap:"clamp(15px, 3vw, 25px)"},children:[...ye?.channelsCategories||[],...ye?.originalsCategories||[]].filter(D=>!D.isSeasonFolder).map(D=>{const q=D.thumbnailUrl||null,se=Hu(D,ye?.videos||[],ye?.urlContent||[],ye?.categories||[],ye?.audioAlbums||[]),me=[];se.totalEpisodes>0&&me.push(`${se.totalEpisodes} ${se.totalEpisodes===1?"episode":"episodes"}`),se.seasonCount>0&&me.push(`${se.seasonCount} series`),se.albumCount>0&&me.push(`${se.albumCount} ${se.albumCount===1?"album":"albums"}`);const xe=me.join(", ")||"No content";return o.jsxs("div",{style:{background:"#2a2a2a",borderRadius:"8px",overflow:"hidden",cursor:"pointer",transition:"transform 0.3s ease",border:"1px solid #333"},onClick:()=>$(D),onMouseEnter:Be=>Be.currentTarget.style.transform="scale(1.05)",onMouseLeave:Be=>Be.currentTarget.style.transform="scale(1)",children:[o.jsxs("div",{style:{aspectRatio:"16/9",background:q?`url(${q})`:"#2a2a2a",backgroundSize:"cover",backgroundPosition:"center",position:"relative"},children:[!q&&o.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",background:"#2a2a2a",color:"#4CAF50",fontSize:"clamp(12px, 2vw, 16px)",fontWeight:"bold"}
140,children:"Thumbnail Coming Soon"}),_u.includes(D.name)&&o.jsx("div",{style:{position:"absolute",top:10,left:10,background:"linear-gradient(135deg, #FFD700, #FFA500)",color:"black",padding:"4px 8px",borderRadius:12,fontSize:10,fontWeight:"bold"},children:"TOP"}),(di.has(D.name)||bs.has(D.id))&&o.jsxs("div",{style:{position:"absolute",top:10,right:10,display:"flex",alignItems:"center",gap:4,background:"#FF0000",color:"white",padding:"4px 8px",borderRadius:12,fontSize:10,fontWeight:"bold",animation:"pulse 2s ease-in-out infinite"},children:[o.jsx("span",{style:{width:6,height:6,background:"white",borderRadius:"50%",animation:"pulse 1s ease-in-out infinite"}}),"LIVE"]})]}),o.jsxs("div",{style:{padding:"clamp(10px, 2vw, 15px)"},children:[o.jsx("h3",{style:{fontSize:"clamp(12px, 2vw, 14px)",color:"white",margin:"0 0 4px 0",fontWeight:"bold"},children:D.name}),o.jsx("p",{style:{fontSize:"clamp(10px, 1.5vw, 12px)",color:"#999",margin:"0 0 8px 0"},children:xe}),vs[D.name]&&o.jsx("p",{style:{fontSize:"clamp(9px, 1.4vw, 11px)",color:"#ccc",margin:0,lineHeight:1.3,display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden"},children:vs[D.name]})]})]},D.id)})}),pn()]}),s==="MOVIES"&&!Xt&&o.jsxs("div",{className:"content-screen content-screen--movies",style:{padding:"clamp(15px, 3vw, 25px)",background:"#1a1a1a",minHeight:"calc(100vh - 120px)"},children:[o.jsxs("div",{className:"catalog-hero catalog-hero--with-wall",children:[o.jsx(ob,{items:Rue(ye?.moviesCategories,nr.movies?.sections,ye?.videos,ye?.urlContent)}),o.jsxs("div",{className:"catalog-hero__copy",children:[o.jsx("span",{className:"catalog-hero__eyebrow",children:"Feature presentations"}),o.jsx("h2",{className:"catalog-hero__title",children:"Movies"}),o.jsx("p",{className:"catalog-hero__description",children:"Feature films and cinematic collections, ready whenever you are."})]})]}),qn?o.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(clamp(150px, 20vw, 200px), 1fr))",gap:"clamp(15px, 3vw, 25px)"},children:[1,2,3].map(D=>o.jsxs("div",{style:{background:"#2a2a2a",borderRadius:"8px",overflow:"hidden",border:"1px solid #333"},children:[o.jsx("div",{style:{aspectRatio:"16/9",background:"#333",display:"flex",alignItems:"center",justifyContent:"center",color:"#666",fontSize:"clamp(12px, 2vw, 16px)"},children:"Loading..."}),o.jsxs("div",{style:{padding:"clamp(10px, 2vw, 15px)"},children:[o.jsx("div",{style:{height:"14px",background:"#333",borderRadius:"4px",marginBottom:"8px"}}),o.jsx("div",{style:{height:"10px",background:"#333",borderRadius:"4px",width:"60%"}})]})]},D))}):nr.movies?.sections?.some(D=>(D.categoryIds||[]).length>0||(D.archiveIds||[]).length>0)?o.jsx("div",{style:{overflow:"visible"},children:nr.movies.sections.map((D,q)=>{const se=(D.categoryIds||[]).map(xe=>
140ye?.urlContent?.find(Be=>String(Be.id)===xe)).filter(Boolean),me=D.archiveIds||[];return se.length===0&&me.length===0?null:o.jsxs("div",{style:{marginBottom:40,overflow:"visible"},children:[o.jsx("h3",{className:"catalog-section-title",style:{fontSize:"clamp(18px, 3.5vw, 22px)",fontWeight:700,color:"white",margin:"0 0 4px 8px",letterSpacing:"-0.3px"},children:D.title}),o.jsxs(y0,{children:[se.map((xe,Be)=>o.jsx($u,{isFirst:Be===0,thumbnailSrc:so(xe)||null,title:xe.extractedTitle||xe.customTitle||xe.title,subtitle:xe.duration?`${Math.floor(xe.duration/60)}m`:void 0,onClick:()=>{rn(Lo(xe)),an(!0)},onKeyDown:Ne=>{(Ne.key==="Enter"||Ne.key===" ")&&(Ne.preventDefault(),rn(Lo(xe)),an(!0))}},xe.id)),me.map(xe=>{const Be=dl[xe],Ne=Be?.title||xe,mt=Be?.thumbnailUrl||`https://archive.org/services/img/${xe}`;return o.jsx($u,{isFirst:!1,thumbnailSrc:mt,title:Ne,subtitle:Be?.year?String(Be.year):void 0,onClick:()=>ue(xe,Ne),onKeyDown:Ut=>{(Ut.key==="Enter"||Ut.key===" ")&&(Ut.preventDefault(),ue(xe,Ne))}},`archive-${xe}`)})]})]},`${D.title}-${q}`)})}):o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(clamp(150px, 20vw, 200px), 1fr))",gap:"clamp(15px, 3vw, 25px)"},children:[(ye?.moviesCategories||[]).map(D=>{const q=Hu(D,ye.videos,ye.urlContent,ye.categories);return o.jsxs("div",{onClick:()=>$(D),style:{background:"#2a2a2a",borderRadius:"8px",overflow:"hidden",cursor:"pointer",border:"1px solid #333",transition:"all 0.2s ease",transform:"scale(1)"},onMouseEnter:se=>{se.currentTarget.style.background="#333",se.currentTarget.style.transform="scale(1.02)",se.currentTarget.style.borderColor="#4ade80"},onMouseLeave:se=>{se.currentTarget.style.background="#2a2a2a",se.currentTarget.style.transform="scale(1)",se.currentTarget.style.borderColor="#333"},children:[o.jsx("div",{style:{aspectRatio:"16/9",background:D.thumbnailUrl?"transparent":"#1a1a1a",display:"flex",alignItems:"center",justifyContent:"center",position:"relative",overflow:"hidden"},children:D.thumbnailUrl?o.jsx("img",{src:Eh(D.thumbnailUrl),alt:D.name,style:{width:"100%",height:"100%",objectFit:"cover"}}):o.jsx("div",{style:{fontSize:"clamp(24px, 4vw, 36px)",color:"#666"},children:"ð¬"})}),o.jsxs("div",{style:{padding:"clamp(10px, 2vw, 15px)"},children:[o.jsx("h3",{style:{fontSize:"clamp(12px, 2vw, 16px)",fontWeight:"bold",margin:"0 0 clamp(5px, 1vh, 8px) 0",color:"white",lineHeight:1.2,display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:D.name}),q.seasonCount>0&&o.jsxs("p",{style:{fontSize:"clamp(9px, 1.4vw, 11px)",color:"#4ade80",margin:"0 0 clamp(3px, 0.5vh, 5px) 0",fontWeight:"500"},children:[q.seasonCount," ",q.seasonCount===1?"season":"seasons"," ⢠",q.totalEpisodes," ",q.totalEpisodes===1?"episode":"episodes"]}),q.seasonCount===0&&q.totalEpisodes>0&&o.jsxs("p",{style:{fontSize:"clamp(9px, 1.4vw, 11px)",color:"#4ade80",margin:"0 0 clamp(3px, 0.5vh, 5px) 0",fontWeight:"500"},children:[q.totalEpisodes," ",q.totalEpisodes===1?"movie":"movies"]}),vs[D.name]&&o.jsx("p",{style:{fontSize:"clamp(9px, 1.4vw, 11px)",color:"#ccc",margin:0,lineHeight:1.3,display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden"},children:vs[D.name]})]})]},D.id)}),(ye?.videos?.filter(D=>D.categoryIds?.includes("25532412"))||[]).map(D=>o.jsxs("div",{onClick:()=>{rn(Lo(D)),an(!0)},style:{background:"#333",borderRadius:"8px",overflow:"hidden",cursor:"pointer",transition:"transform 0.2s, box-shadow 0.2s"},onMouseEnter:q=>{q.currentTarget.style.transform="scale(1.02)",q.currentTarget.style.boxShadow="0 4px 20px rgba(74, 222, 128, 0.3)"},onMouseLeave:q=>{q.currentTarget.style.transform="scale(1)",q.currentTarget.style.boxShadow="none"},children:[o.jsxs("div",{style:{width:"100%",height:"clamp(100px, 15vw, 120px)",backgroundImage:so(D)?`url(${so(D)})`:"none",backgroundSize:"cover",backgroundPosition:"center",backgroundColor:so(D)?"#000":"#4ade80",display:"flex",alignItems:"center",justifyContent:"center",position:"relative"},children:[!so(D)&&o.jsx("div",{style:{fontSize:"24px",opacity:.6,color:"white"},children:"ð¬"}),o.jsx("div",{style:{background:"rgba(0,0,0,0.7)",borderRadius:"50%",width:"40px",height:"40px",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"16px",color:"white"},children:"â¶"}),o.jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,background:"linear-gradient(transparent, rgba(0,0,0,0.8))",padding:"20px 8px 8px",color:"white"},children:o.jsx("h3",{style:{fontSize:"clamp(10px, 1.8vw, 12px)",fontWeight:"bold",margin:0,textShadow:"0 1px 2px rgba(0,0,0,0.8)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:D.title||"Movie"})})]}),o.jsx("div",{style:{padding:"8px 12px"},children:D.duration&&o.jsxs("p",{style:{fontSize:"clamp(9px, 1.4vw, 10px)",color:"#999",margin:0,textAlign:"center"},children:[Math.floor(D.duration/60),"m"]})})]},`movie-episode-${D.id}
140`)),(ye?.urlContent?.filter(D=>D.categoryAssignment==="MOVIES"&&(D.subcategoryAssignment===null||D.subcategoryAssignment===void 0))||[]).map(D=>o.jsxs("div",{onClick:()=>{rn(Lo(D)),an(!0)},style:{background:"#333",borderRadius:"8px",overflow:"hidden",cursor:"pointer",transition:"transform 0.2s, box-shadow 0.2s"},onMouseEnter:q=>{q.currentTarget.style.transform="scale(1.02)",q.currentTarget.style.boxShadow="0 4px 20px rgba(74, 222, 128, 0.3)"},onMouseLeave:q=>{q.currentTarget.style.transform="scale(1)",q.currentTarget.style.boxShadow="none"},children:[o.jsxs("div",{style:{width:"100%",height:"clamp(100px, 15vw, 120px)",backgroundImage:so(D)?`url(${so(D)})`:"none",backgroundSize:"cover",backgroundPosition:"center",backgroundColor:so(D)?"#000":"#4ade80",display:"flex",alignItems:"center",justifyContent:"center",position:"relative"},children:[!so(D)&&o.jsx("div",{style:{fontSize:"24px",opacity:.6,color:"white"},children:"ð¬"}),o.jsx("div",{style:{background:"rgba(0,0,0,0.7)",borderRadius:"50%",width:"40px",height:"40px",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"16px",color:"white"},children:"â¶"}),o.jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,background:"linear-gradient(transparent, rgba(0,0,0,0.8))",padding:"20px 8px 8px",color:"white"},children:o.jsx("h3",{style:{fontSize:"clamp(10px, 1.8vw, 12px)",fontWeight:"bold",margin:0,textShadow:"0 1px 2px rgba(0,0,0,0.8)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:D.extractedTitle||D.customTitle||D.title||"Movie"})})]}),o.jsx("div",{style:{padding:"8px 12px"},children:D.extractedDuration&&o.jsxs("p",{style:{fontSize:"clamp(9px, 1.4vw, 10px)",color:"#999",margin:0,textAlign:"center"},children:[Math.floor(D.extractedDuration/60),"m"]})})]},`url-movie-episode-${D.id}`))]}),pn()]}),s==="SEARCH"&&!Xt&&o.jsxs("div",{style:{padding:"clamp(15px, 3vw, 25px)",background:"#1a1a1a",minHeight:"calc(100vh - 120px)"},children:[o.jsx("h2",{style:{fontSize:"clamp(20px, 4vw, 28px)",marginBottom:"clamp(15px, 3vh, 25px)",color:"white",fontWeight:"bold"},children:"Search"}),o.jsx("div",{style:{marginBottom:"clamp(20px, 4vh, 30px)"},children:o.jsx("input",{type:"text",placeholder:"Search shows, episodes, and channels...",value:i,onChange:D=>a(D.target.value),style:{width:"100%",maxWidth:"500px",padding:"clamp(12px, 2vw, 16px)",background:"#2a2a2a",border:"1px solid #444",borderRadius:"8px",color:"white",fontSize:"clamp(14px, 2vw, 16px)",outline:"none"},onFocus:D=>D.target.style.borderColor="#4CAF50",onBlur:D=>D.target.style.borderColor="#444"})}),i?o.jsx("div",{children:(()=>{const D=ye?.videos?.filter(Ne=>Ne.title?.toLowerCase().includes(i.toLowerCase())||Ne.channelName?.toLowerCase().includes(i.toLowerCase()))||[],se=(ye?.urlContent||[]).filter(Ne=>Ne.customTitle?.toLowerCase().includes(i.toLowerCase())||Ne.extractedTitle?.toLowerCase().includes(i.toLowerCase())||Ne.extractedDescription?.toLowerCase().includes(i.toLowerCase())),me=ye?.categories||[],Be=me.filter(Ne=>Ne.name?.toLowerCase().includes(i.toLowerCase())).map(Ne=>{if(Ne.isSeasonFolder&&Ne.parentCategoryId){const mt=me.find(Ut=>Ut.id===Ne.parentCategoryId);if(mt)return{...Ne,_isSeriesCard:!0,_parentShow:mt,displayThumbnailId:mt.id,seriesId:Ne.id,parentShowId:mt.id,parentShowName:mt.name}}return Ne}).filter(Boolean);return D.length===0&&Be.length===0&&se.length===0?o.jsx("div",{style:{textAlign:"center",padding:"clamp(40px, 8vh, 60px)",background:"#2a2a2a",borderRadius:"8px",border:"1px solid #333"},children:o.jsxs("p",{style:{color:"#999",fontSize:"clamp(14px, 2vw, 16px)"},children:['No results found for "',i,'"']})}):o.jsxs("div",{children:[Be.length>0&&o.jsxs("div",{style:{marginBottom:"clamp(25px, 5vh, 40px)"},children:[o.jsx("h3",{style:{fontSize:"clamp(16px, 3vw, 20px)",color:"white",marginBottom:"clamp(15px, 3vh, 20px)",fontWeight:"bold"},children:"Shows & Series"}),o.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(clamp(150px, 20vw, 200px), 1fr))",gap:"clamp(15px, 3vw, 25px)"},children:Be.map(Ne=>{const mt=Ne._isSeriesCard?Ne._parentShow?.thumbnailUrl:Ne.thumbnailUrl,Ut=Ne._isSeriesCard?`${Ne.name} (${Ne.parentShowName})`:Ne.name,tn=Ne.videoCount||0,cs=Ne._isSeriesCard?`${tn} episodes ⢠Series`:`${tn} episodes`;return o.jsxs("div",{style:{background:"#2a2a2a",borderRadius:"8px",overflow:"hidden",cursor:"pointer",transition:"transform 0.3s ease",border:"1px solid #333"},onClick:()=>
140{if(Ne._isSeriesCard){const Kt={...Ne._parentShow};Kt._preSelectSeries=Ne.seriesId,$(Kt)}else $(Ne)},onMouseEnter:Kt=>Kt.currentTarget.style.transform="scale(1.05)",onMouseLeave:Kt=>Kt.currentTarget.style.transform="scale(1)",children:[o.jsx("div",{style:{aspectRatio:"16/9",background:`url(${mt})`,backgroundSize:"cover",backgroundPosition:"center",position:"relative"},children:(di.has(Ne.name)||bs.has(Ne.id))&&o.jsxs("div",{style:{position:"absolute",top:"8px",right:"8px",display:"flex",alignItems:"center",gap:"4px",background:"#FF0000",color:"white",padding:"4px 8px",borderRadius:"12px",fontSize:"10px",fontWeight:"bold",boxShadow:"0 2px 4px rgba(0,0,0,0.5)",animation:"pulse 2s ease-in-out infinite"},children:[o.jsx("span",{style:{width:"6px",height:"6px",background:"white",borderRadius:"50%",animation:"pulse 1s ease-in-out infinite"}}),"LIVE"]})}),o.jsxs("div",{style:{padding:"clamp(10px, 2vw, 15px)"},children:[o.jsx("h3",{style:{fontSize:"clamp(12px, 2vw, 14px)",color:"white",margin:"0 0 4px 0",fontWeight:"bold"},children:Ut}),o.jsx("p",{style:{fontSize:"clamp(10px, 1.5vw, 12px)",color:"#999",margin:0},children:cs})]})]},`${Ne.id}-${Ne._isSeriesCard?"series":"show"}`)})})]}),D.length>0&&o.jsxs("div",{children:[o.jsxs("h3",{style:{fontSize:"clamp(16px, 3vw, 20px)",color:"white",marginBottom:"clamp(15px, 3vh, 20px)",fontWeight:"bold"},children:["Episodes (",D.length,")"]}),o.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(clamp(200px, 25vw, 300px), 1fr))",gap:"clamp(15px, 3vw, 25px)"},children:D.slice(0,20).map(Ne=>o.jsxs("div",{style:{background:"#2a2a2a",borderRadius:"8px",overflow:"hidden",cursor:"pointer",transition:"transform 0.3s ease",border:"1px solid #333"},onClick:()=>{rn(Lo(Ne)),an(!0)},onMouseEnter:mt=>mt.currentTarget.style.transform="scale(1.05)",onMouseLeave:mt=>mt.currentTarget.style.transform="scale(1)",children:[o.jsx("div",{style:{aspectRatio:"16/9",background:Ne.thumbnailUrl?`url(${Ne.thumbnailUrl})`:"#333",backgroundSize:"cover",backgroundPosition:"center",position:"relative",overflow:"hidden"},children:o.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0, 0, 0, 0.3)",color:"white",opacity:.8},children:o.jsx(Bc,{size:24})})}),o.jsxs("div",{style:{padding:"clamp(10px, 2vw, 15px)"},children:[o.jsx("h3",{style:{fontSize:"clamp(12px, 2vw, 14px)",color:"white",margin:"0 0 4px 0",fontWeight:"bold",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:Ne.title}),o.jsx("p",{style:{fontSize:"clamp(10px, 1.5vw, 12px)",color:"#999",margin:0},children:Ne.channelName})]})]},Ne.id))})]}),se.length>0&&o.jsxs("div",{style:{marginBottom:"clamp(25px, 5vh, 40px)"},children:[o.jsx("h3",{style:{fontSize:"clamp(16px, 3vw, 20px)",color:"white",marginBottom:"clamp(15px, 3vh, 20px)",fontWeight:"bold"},children:"Movies & Content"}),o.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(clamp(150px, 20vw, 200px), 1fr))",gap:"clamp(15px, 3vw, 25px)"},children:se.map(Ne=>o.jsxs("div",{style:{background:"#2a2a2a",borderRadius:"8px",overflow:"hidden",cursor:"pointer",transition:"transform 0.3s ease",border:"1px solid #333"},onClick:()=>{const mt={id:Ne.id,title:Ne.customTitle||Ne.extractedTitle,embedUrl:Ne.embedUrl,platform:Ne.platform,thumbnailUrl:Ne.extractedThumbnail};c(mt)},onMouseEnter:mt=>mt.currentTarget.style.transform="scale(1.05)",onMouseLeave:mt=>mt.currentTarget.style.transform="scale(1)",children:[o.jsx("div",{style:{aspectRatio:"16/9",background:Ne.extractedThumbnail?`url(${Ne.extractedThumbnail})`:"#333",backgroundSize:"cover",backgroundPosition:"center",position:"relative"}}),o.jsx("div",{style:{padding:"clamp(10px, 2vw, 15px)"},children:o.jsx("h4",{style:{fontSize:"clamp(12px, 2vw, 14px)",color:"white",margin:"0 0 4px 0",fontWeight:"bold"},children:Ne.customTitle||Ne.extractedTitle})})]},Ne.id))})]})]})})()}):o.jsxs("div",{style:{textAlign:"center",padding:"clamp(40px, 8vh, 80px)",background:"#2a2a2a",borderRadius:"12px",border:"1px solid #333"},children:[o.jsx("div",{style:{fontSize:"clamp(48px, 12vw, 80px)",marginBottom:"clamp(15px, 3vh, 25px)"},children:"ð"}),o.jsx("h3",{style:{fontSize:"clamp(18px, 3vw, 24px)",color:"white",marginBottom:"clamp(10px, 2vh, 15px)",fontWeight:"bold"},children:"Discover Content"}),o.jsx("p",{style:{fontSize:"clamp(12px, 2vw, 16px)",color:"#999",maxWidth:"400px",margin:"0 auto"},children:"Search through our collection of cannabis culture shows, episodes, and channels"})]}),pn()]})]})," ",tr?.show&&o.jsx("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.8)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:"20px"},onClick:()=>ua(null),children:o.jsxs("div",{style:{backgroundColor:"#1a1a1a",borderRadius:"12px",padding:"24px",maxWidth:"500px",width:"100%",maxHeight:"80vh",overflow:"auto",border:"1px solid #333"},onClick:D=>D.stopPropagation(),children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"16
140px"},children:[o.jsx("h3",{style:{color:"#4ade80",margin:0,fontSize:"18px",fontWeight:"bold"},children:tr.title}),o.jsx("button",{onClick:()=>ua(null),style:{background:"none",border:"none",color:"#999",fontSize:"24px",cursor:"pointer",padding:"0",lineHeight:1},children:"Ã"})]}),o.jsx("div",{style:{color:"#ccc",lineHeight:1.6,fontSize:"14px",whiteSpace:"pre-wrap"},children:Ft(tr.content)}),tr.hasLink&&o.jsx("div",{style:{marginTop:"16px",textAlign:"center"},children:o.jsx("button",{onClick:()=>ua(null),style:{backgroundColor:"#4ade80",color:"#000",border:"none",borderRadius:"6px",padding:"8px 16px",fontSize:"14px",cursor:"pointer",fontWeight:"bold"},children:"Close"})})]})}),wo&&o.jsx("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.9)",display:"flex",alignItems:"flex-start",justifyContent:"center",zIndex:1e3,padding:"20px",paddingTop:"calc(20px + var(--safe-area-inset-top, 0px))",overflowY:"auto"},children:o.jsxs("div",{style:{backgroundColor:"#1a1a1a",borderRadius:"12px",padding:"24px",maxWidth:"700px",width:"100%",border:"1px solid #333",marginTop:"20px",marginBottom:"40px"},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"24px"},children:[o.jsx("h2",{style:{color:"#4ade80",margin:0,fontSize:"clamp(20px, 4vw, 28px)",fontWeight:"bold"},children:"Privacy Policy"}),o.jsx("button",{"data-testid":"button-close-privacy",onClick:()=>{da(!1),window.history.replaceState({},"","/")},style:{background:"none",border:"none",color:"#999",fontSize:"28px",cursor:"pointer",padding:"0",lineHeight:1},children:"Ã"})]}),o.jsxs("div",{style:{color:"#ccc",lineHeight:1.8,fontSize:"14px"},children:[o.jsxs("p",{style:{marginBottom:"16px"},children:[o.jsx("strong",{style:{color:"white"},children:"Last Updated:"})," December 2024"]}),o.jsx("h3",{style:{color:"#4ade80",marginTop:"24px",marginBottom:"12px",fontSize:"16px"},children:"1. Information We Collect"}),o.jsx("p",{style:{marginBottom:"16px"},children:"ChronicTV and its parent company Chronic Brands does not collect or share user information with any 3rd party sources. All user information gathered will be utilized by Chronic Brands and its analytics team to improve the user experience."}),o.jsx("p",{style:{marginBottom:"16px"},children:"We may collect the following types of information:"}),o.jsxs("ul",{style:{marginLeft:"20px",marginBottom:"16px"},children:[o.jsx("li",{style:{marginBottom:"8px"},children:"Account information (email address, display name) when you create an account"}),o.jsx("li",{style:{marginBottom:"8px"},children:'Watch history to provide personalized recommendations and "Continue Watching" features'}),o.jsx("li",{style:{marginBottom:"8px"},children:"Device information for app optimization and analytics"}),o.jsx("li",{style:{marginBottom:"8px"},children:"Usage data to improve our service"})]}),o.jsx("h3",{style:{color:"#4ade80",marginTop:"24px",marginBottom:"12px",fontSize:"16px"},children:"2. How We Use Your Information"}),o.jsx("p",{style:{marginBottom:"16px"},children:"We use the information we collect to:"}),o.jsxs("ul",{style:{marginLeft:"20px",marginBottom:"16px"},children:[o.jsx("li",{style:{marginBottom:"8px"},children:"Provide, maintain, and improve our streaming service"}),o.jsx("li",{style:{marginBottom:"8px"},children:"Remember your watch progress and preferences"}),o.jsx("li",{style:{marginBottom:"8px"},children:"Send service-related notifications"}),o.jsx("li",{style:{marginBottom:"8px"},children:"Analyze usage patterns to enhance the user experience"})]}),o.jsx("h3",{style:{color:"#4ade80",marginTop:"24px",marginBottom:"12px",fontSize:"16px"},children:"3. Data Storage & Security"}),o.jsx("p",{style:{marginBottom:"16px"},children:"Your data is stored securely using Firebase Authentication and Firestore database services, which employ industry-standard encryption and security measures."}),o.jsx("h3",{style:{color:"#4ade80",marginTop:"24px",marginBottom:"12px",fontSize:"16px"},children:"4. Your Rights"}),o.jsx("p",{style:{marginBottom:"16px"},children:"You have the right to:"}
140),o.jsxs("ul",{style:{marginLeft:"20px",marginBottom:"16px"},children:[o.jsx("li",{style:{marginBottom:"8px"},children:"Access your personal data"}),o.jsx("li",{style:{marginBottom:"8px"},children:"Request deletion of your account and associated data"}),o.jsx("li",{style:{marginBottom:"8px"},children:"Opt out of analytics tracking"})]}),o.jsx("h3",{style:{color:"#4ade80",marginTop:"24px",marginBottom:"12px",fontSize:"16px"},children:"5. Account Deletion"}),o.jsx("p",{style:{marginBottom:"16px"},children:'You can delete your account at any time through the "Delete Account" option in the app footer. This will permanently remove your account and all associated data including watch history.'}),o.jsx("h3",{style:{color:"#4ade80",marginTop:"24px",marginBottom:"12px",fontSize:"16px"},children:"6. Contact Us"}),o.jsx("p",{style:{marginBottom:"16px"},children:"For questions about this Privacy Policy, please contact us at:"}),o.jsxs("ul",{style:{marginLeft:"20px",marginBottom:"16px"},children:[o.jsx("li",{style:{marginBottom:"8px"},children:"Email: [email protected]"}),o.jsx("li",{style:{marginBottom:"8px"},children:"Phone: 866-405-9333"}),o.jsx("li",{style:{marginBottom:"8px"},children:"Facebook: ChronicTV"})]})]}),o.jsx("div",{style:{marginTop:"24px",textAlign:"center"},children:o.jsx("button",{"data-testid":"button-close-privacy-bottom",onClick:()=>{da(!1),window.history.replaceState({},"","/")},style:{backgroundColor:"#4ade80",color:"#000",border:"none",borderRadius:"8px",padding:"12px 32px",fontSize:"16px",cursor:"pointer",fontWeight:"bold"},children:"Close"})})]})}),pr&&o.jsx("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.9)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:"20px"},children:o.jsxs("div",{style:{backgroundColor:"#1a1a1a",borderRadius:"12px",padding:"32px",maxWidth:"450px",width:"100%",border:"1px solid #333"},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"24px"},children:[o.jsx("h2",{style:{color:"#ef4444",margin:0,fontSize:"clamp(18px, 4vw, 24px)",fontWeight:"bold"},children:"Delete ChronicTV Account"}),o.jsx("button",{"data-testid":"button-close-delete-account",onClick:()=>{ui(!1),za(""),ts(""),window.history.replaceState({},"","/")},style:{background:"none",border:"none",color:"#999",fontSize:"28px",cursor:"pointer",padding:"0",lineHeight:1},children:"Ã"})]}),w?o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{backgroundColor:"rgba(239, 68, 68, 0.1)",border:"1px solid rgba(239, 68, 68, 0.3)",borderRadius:"8px",padding:"16px",marginBottom:"20px"},children:[o.jsxs("p",{style:{color:"#fca5a5",margin:0,fontSize:"14px",lineHeight:1.6},children:[o.jsx("strong",{children:"Warning:"})," This action is permanent and cannot be undone. All your ChronicTV account data will be deleted including:"]}),o.jsxs("ul",{style:{color:"#fca5a5",marginTop:"12px",marginLeft:"20px",marginBottom:0,fontSize:"14px"},children:[o.jsx("li",{children:"Your account information"}),o.jsx("li",{children:"Watch history and progress"}),o.jsx("li",{children:"All saved preferences"})]})]}),o.jsxs("p",{style:{color:"#ccc",marginBottom:"16px",fontSize:"14px"},children:["To confirm deletion, type ",o.jsx("strong",{style:{color:"white"},children:"DELETE"})," below:"]}),o.jsx("input",{"data-testid":"input-delete-confirm",type:"text",value:Wr,onChange:D=>za(D.target.value),placeholder:"Type DELETE to confirm",style:{width:"100%",padding:"12px 16px",borderRadius:"8px",border:"1px solid #444",backgroundColor:"#2a2a2a",color:"white",fontSize:"16px",marginBottom:"16px",boxSizing:"border-box"}}),ac&&o.jsx("p",{style:{color:"#ef4444",marginBottom:"16px",fontSize:"14px"},children:ac}),o.jsxs("div",{style:{display:"flex",gap:"12px"},children:[o.jsx("button",{"data-testid":"button-cancel-delete",onClick:()=>{ui(!1),za(""),ts(""),window.history.replaceState({},"","/")},style:{flex:1,backgroundColor:"#333",color:"white",border:"none",borderRadius:"8px",padding:"12px",fontSize:"14px",cursor:"pointer",fontWeight:"bold"},children:"Cancel"}),o.jsx("button",{"data-testid":"button-confirm-delete",disabled:Wr!=="DELETE"||$a,onClick:async()=>
140{if(Wr!=="DELETE")return;Bi(!0),ts("");const D=await Jb();Bi(!1),D.success?(ui(!1),za(""),window.history.replaceState({},"","/")):ts(D.error||"Failed to delete account")},style:{flex:1,backgroundColor:Wr==="DELETE"?"#ef4444":"#666",color:"white",border:"none",borderRadius:"8px",padding:"12px",fontSize:"14px",cursor:Wr==="DELETE"?"pointer":"not-allowed",fontWeight:"bold",opacity:$a?.7:1},children:$a?"Deleting...":"Delete Account"})]})]}):o.jsxs("div",{style:{textAlign:"center",color:"#ccc"},children:[o.jsx("p",{style:{marginBottom:"20px",fontSize:"16px"},children:"You need to be signed in to delete your account."}),o.jsx("button",{onClick:()=>{ui(!1),G(!0),window.history.replaceState({},"","/")},style:{backgroundColor:"#4ade80",color:"#000",border:"none",borderRadius:"8px",padding:"12px 24px",fontSize:"14px",cursor:"pointer",fontWeight:"bold"},children:"Sign In"})]})]})}),Xt&&!Js?null:o.jsxs("div",{style:{padding:0,background:"#1a1a1a",minHeight:"100%",color:"white"},children:[s==="tv"&&o.jsx("div",{children:o.jsxs("div",{style:{padding:"clamp(15px, 3vw, 20px)",textAlign:"center"},children:[o.jsx("h2",{style:{color:"white",fontSize:"clamp(24px, 5vw, 32px)",marginBottom:"clamp(20px, 4vw, 30px)"},children:"Live TV"}),ye?.currentVideo&&o.jsx("div",{style:{background:"#2a2a2a",borderRadius:"12px",padding:"clamp(20px, 4vw, 30px)",margin:"0 auto",maxWidth:"600px",cursor:"pointer",transition:"transform 0.3s ease",border:"2px solid #4ade80"},onClick:()=>{const D=ye.currentVideo;if(D.isUrlVideo&&D.embedUrl){const q={id:`url-${D.url}`,title:D.title,embedUrl:D.embedUrl,sourceUrl:D.embedUrl,platform:D.platform,platformVideoId:D.platformVideoId,thumbnailUrl:D.extractedThumbnail,description:D.extractedDescription,duration:D.extractedDuration,channelName:D.extractedChannelName||"YouTube"};rn(q)}else rn(D);an(!0),window.history.pushState({screen:"video",videoId:D.id},"",window.location.href)},onMouseEnter:D=>D.currentTarget.style.transform="scale(1.02)",onMouseLeave:D=>D.currentTarget.style.transform="scale(1)",children:o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"20px"},children:[o.jsx("div",{style:{width:"clamp(80px, 15vw, 120px)",height:"clamp(45px, 8.5vw, 67px)",backgroundImage:ye.currentVideo.thumbnailUrl?`url(${ye.currentVideo.thumbnailUrl})`:"none",backgroundSize:"cover",backgroundPosition:"center",backgroundColor:"#333",borderRadius:"8px",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:!ye.currentVideo.thumbnailUrl&&o.jsx("div",{style:{fontSize:"24px",opacity:.5},children:"â¶"})}),o.jsxs("div",{style:{flex:1,textAlign:"left"},children:[o.jsx("h3",{style:{fontSize:"clamp(16px, 3vw, 20px)",margin:"0 0 8px 0",color:"white"},children:"Now Playing"}),o.jsx("p",{style:{fontSize:"clamp(14px, 2.5vw, 16px)",margin:"0 0 4px 0",color:"#4ade80",fontWeight:"bold"},children:(ye.currentVideo.title||"").replace(/^PT\d{1,2}(am|pm)\s+/i,"")}),o.jsx("div",{style:{fontSize:"clamp(12px, 2vw, 14px)",color:"#999"},children:"Tap to watch live"})]})]})}),ye?.tvGuide&&ye.tvGuide.length>1&&o.jsxs("div",{style:{marginTop:"clamp(25px, 5vw, 40px)"},children:[o.jsx("h3",{style:{fontSize:"clamp(18px, 3.5vw, 24px)",margin:"0 0 20px 0",color:"white"},children:"Up Next"}),o.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(clamp(120px, 20vw, 180px), 1fr))",gap:"clamp(15px, 3vw, 20px)",maxWidth:"800px",margin:"0 auto"},children:kee(ye.tvGuide).map((D,q)=>o.jsxs("div",{onClick:()=>{if(D.isUrlVideo&&D.embedUrl){const se={id:`url-${D.url}`,title:D.title,embedUrl:D.embedUrl,sourceUrl:D.embedUrl,platform:D.platform,platformVideoId:D.platformVideoId,thumbnailUrl:D.extractedThumbnail,description:D.extractedDescription,duration:D.extractedDuration,channelName:D.extractedChannelName||"YouTube"};rn(se)}else rn(D);an(!0),window.history.pushState({screen:"video",videoId:D.id},"",window.location.href)},style:{background:"#2a2a2a",borderRadius:"8px",overflow:"hidden",cursor:"pointer",transition:"transform 0.3s ease",border:"1px solid #333"},onMouseEnter:se=>se.currentTarget.style.transform="scale(1.05)",onMouseLeave:se=>se.currentTarget.style.transform="scale(1)",children:[o.jsx("div",{style:{aspectRatio:"16/9",background:"#333",backgroundImage:D.thumbnailUrl?`url(${D.thumbnailUrl})`:"none",backgroundSize:"cover",backgroundPosition:"center",position:"relative",display:"flex",alignItems:"center",justifyContent:"center"},children:o.jsx("div",{style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.4)",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 0.3s ease"},children:o.jsx("div",{style:{color:"white",fontSize:"clamp(24px, 4vw, 32px)",fontWeight:"bold",textShadow:"0 2px 4px rgba(0,0,0,0.8)"},children:"â¶"})})}),o.jsxs("div",{style:{padding:"clamp(6px, 1.2vw, 9px)"},children:[o.jsx("h3",{style:{fontSize:"clamp(8px, 1.2vw, 10px)",color:"white",margin:"0 0 2px 0",fontWeight:"bold",lineHeight:"1.3"},children:(D.title||D.name||"").replace(/^PT\d{1,2}(am|pm)\s+/i,"")}),!D.isUrlVideo&&o.jsx("p",{style:{fontSize:"clamp(7px, 0.9vw, 8px)",color:"#999",margin:0},children:jf(D.duration)})]})]},q))})]}),pn()]})}),s==="channels"&&o.jsx("div",{children:o.jsxs("div",{style:{padding:"clamp(15px, 3vw, 20px)"},children:[o.jsx("h2",{style:{color:"white",fontSize:"clamp(24px, 5vw, 32px)",marginBottom:"clamp(20px, 4vw, 30px)",textAlign:"center"},children:"Channels"}),o.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(clamp(140px, 25vw, 200px), 1fr))",gap:"clamp(15px, 3vw, 20px)",maxWidth:"1000px",margin:"0 auto"},children:(ye?.categories?.filter(q=>q.containerFolder?.toLowerCase()==="channels")||[]).map(q=>{const se=Hu(q,ye?.videos||[],ye?.urlContent||[],ye?.categories||[]),me=q.thumbnailUrl?q.thumbnailUrl.startsWith("http")?q.thumbnailUrl:window.location.origin+q.thumbnailUrl:null;return o.jsxs("div",{onClick:()=>$(q),style:{background:"#2a2a2a",borderRadius:"12px",overflow:"hidden",cursor:"pointer",transition:"transform 0.3s ease, box-shadow 0.3s ease",aspectRatio:"1",position:"relative"},onMouseEnter:xe=>{xe.currentTarget.style.transform="scale(1.05)",xe.currentTarget.style.boxShadow="0 8px 30px rgba(74, 222, 128, 0.3)"},onMouseLeave:xe=>{xe.currentTarget.style.transform="scale(1)",xe.currentTarget.style.boxShadow="none"},children:[o.jsxs("div",{style:{width:"100%",height:"75%",backgroundImage:me?`url(${me})`:q.imageData&&q.imageData.length>747?`url(${q.imageData})`:"none",backgroundSize:"cover",backgroundPosition:"center",backgroundColor:"#333",display:"flex",alignItems:"center",justifyContent:"center",position:"relative"},children:[!(q.imageData&&q.imageData.length>747||q.thumbnailUrl)&&o.jsx("div",{style:{fontSize:"clamp(20px, 4vw, 32px)",opacity:.5,textAlign:"center"},children:"ðº"}),_u.includes(q.name)&&o.jsx("div",{style:{position:"absolute",top:"8px",left:"8px",background:"linear-gradient(135deg, #FFD700, #FFA500)",color:"black",padding:"4px 8px",borderRadius:"12px",fontSize:"clamp(8px, 1.5vw, 10px)",fontWeight:"bold",boxShadow:"0 2px 4px rgba(0,0,0,0.5)"},children:"TOP"}),(di.has(q.name)||bs.has(q.id))&&o.jsxs("div",{style:{position:"absolute",top:"8px",right:"8px",display:"flex",alignItems:"center",gap:"4px",background:"#FF0000",color:"white",padding:"4px 8px",borderRadius:"12px",fontSize:"clamp(8px, 1.5vw, 10px)",fontWeight:"bold",boxShadow:"0 2px 4px rgba(0,0,0,0.5)",animation:"pulse 2s ease-in-out infinite"},children:[o.jsx("span",{style:{width:"6px",height:"6px",background:"white",borderRadius:"50%",animation:"pulse 1s ease-in-out infinite"}}),"LIVE"]})]}),o.jsxs("div",{style:{padding:"clamp(8px, 1.5vw, 12px)",height:"25%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},children:[o.jsx("h3",{style:{fontSize:"clamp(11px, 2vw, 13px)",color:"white",margin:0,fontWeight:"bold",textAlign:"center",lineHeight:"1.1",overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:1,WebkitBoxOrient:"vertical",marginBottom:"2px"},children:q.name}),o.jsxs("p",{style:{fontSize:"clamp(8px, 1.5vw, 10px)",color:"#888",margin:0,textAlign:"center"},children:[se.totalEpisodes," ",se.totalEpisodes===1?"episode":"episodes"]})]})]},q.id)})}),pn()]})}),s==="originals"&&o.jsx("div",{children:o.jsxs("div",{style:{padding:"clamp(15px, 3vw, 20px)"},children:[o.jsx("h2",{style:{color:"white",fontSize:"clamp(24px, 5vw, 32px)",marginBottom:"clamp(20px, 4vw, 30px)",textAlign:"center"},children:"Originals"}),o.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(clamp(140px, 25vw, 200px), 1fr))",gap:"clamp(15px, 3vw, 20px)",maxWidth:"1000px",margin:"0 auto"},children:(()=>{const D=ye?.categories?.filter(q=>q.containerFolder==="Originals")||[];return D.forEach((q,se)=>{q.thumbnailUrl&&(q.thumbnailUrl.startsWith("http")?q.thumbnailUrl:window.location.origin+q.thumbnailUrl)}),D.map(q=>{const se=q.thumbnailUrl?Eh(q.thumbnailUrl):null;return o.jsxs("div",{onClick:()=>$(q),style:{background:"#2a2a2a",borderRadius:"12px",overflow:"hidden",cursor:"pointer",transition:"transform 0.3s ease, box-shadow 0.3s ease",aspectRatio:"1",position:"relative"},onMouseEnter:me=>{me.currentTarget.style.transform="scale(1.05)",me.currentTarget.style.boxShadow="0 8px 30px rgba(74, 222, 128, 0.3)"},onMouseLeave:me=>{me.currentTarget.style.transform="scale(1)",me.currentTarget.style.boxShadow="none"},children:[o.jsxs("div",{style:{width:"100%",height:"75%",backgroundImage:se?`url(${se})`:q.imageData&&q.imageData.length>747?`url(${q.imageData})`:"none",backgroundSize:"cover",backgroundPosition:"center",backgroundColor:"#333",display:"flex",alignItems:"center",justifyContent:"center",position:"relative"},children:[!(q.imageData&&q.imageData.length>747||q.thumbnailUrl)&&o.jsx("div",{style:{fontSize:"clamp(20px, 4vw, 32px)",opacity:.5,textAlign:"center"},children:"ð¬"}),_u.includes(q.name)&&o.jsx("div",{style:{position:"absolute",top:"8px",left:"8px",background:"linear-gradient(135deg, #FFD700, #FFA500)",color:"black",padding:"4px 8px",borderRadius:"12px",fontSize:"clamp(8px, 1.5vw, 10px)",fontWeight:"bold",boxShadow:"0 2px 4px rgba(0,0,0,0.5)"},children:"TOP"}),(di.has(q.name)||bs.has(q.id))&&o.jsxs("div",{style:{position:"absolute",top:"8px",right:"8px",display:"flex",alignItems:"center",gap:"4px",background:"#FF0000",color:"white",padding:"4px 8px",borderRadius:"12px",fontSize:"clamp(8px, 1.5vw, 10px)",fontWeight:"bold",boxShadow:"0 2px 4px rgba(0,0,0,0.5)",animation:"pulse 2s ease-in-out infinite"},children:[o.jsx("span",{style:{width:"6px",height:"6px",background:"white",borderRadius:"50%",animation:"pulse 1s ease-in-out infinite"}}),"LIVE"]})]}),o.jsx("div",{style:{padding:"clamp(8px, 1.5vw, 12px)",height:"25%",display:"flex",alignItems:"center",justifyContent:"center"},children:o.jsx("h3",{style:{fontSize:"clamp(12px, 2.2vw, 14px)",color:"white",margin:0,fontWeight:"bold",textAlign:"center",lineHeight:"1.2",overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:q.name})})]},q.id)})})()}),pn()]})}),s==="live"&&o.jsx("div",{children:o.jsxs("div",{style:{padding:"clamp(15px, 3vw, 20px)"},children:[o.jsx("h2",{style:{color:"white",fontSize:"clamp(24px, 5vw, 32px)",marginBottom:"clamp(20px, 4vw, 30px)",textAlign:"center"},children:"Top Creators"}),o.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(clamp(140px, 25vw, 200px), 1fr))",gap:"clamp(15px, 3vw, 20px)",maxWidth:"1000px",margin:"0 auto"},children:fl.map(D=>o.jsxs("div",{onClick:()=>{D.liveUrl&&window.open(D.liveUrl,"_blank")},style:{background:"#2a2a2a",borderRadius:"12px",overflow:"hidden",cursor:"pointer",transition:"transform 0.3s ease, box-shadow 0.3s ease",aspectRatio:"1",position:"relative",border:D.isLive?"2px solid #FF0000":"1px solid #333"},onMouseEnter:q=>{q.currentTarget.style.transform="scale(1.05)",q.currentTarget.style.boxShadow="0 8px 30px rgba(255, 0, 0, 0.3)"},onMouseLeave:q=>{q.currentTarget.style.transform="scale(1)",q.currentTarget.style.boxShadow="none"},children:[o.jsxs("div",{style:{width:"100%",height:"75%",backgroundImage:D.thumbnailUrl?`url(${D.thumbnailUrl})`:D.imageData&&D.imageData.length>747?`url(${D.imageData})`:"none",backgroundSize:"cover",backgroundPosition:"center",backgroundColor:"#333",display:"flex",alignItems:"center",justifyContent:"center",position:"relative"},children:[!(D.imageData&&D.imageData.length>747||D.thumbnailUrl)&&o.jsx("div",{style:{fontSize:"clamp(20px, 4vw, 32px)",opacity:.5,textAlign:"center"},children:"ð¥"}),D.isLive&&o.jsx("div",{style:{position:"absolute",top:"8px",right:"8px",background:"#FF0000",color:"white",padding:"6px 10px",borderRadius:"12px",fontSize:"clamp(8px, 1.5vw, 10px)",fontWeight:"bold",boxShadow:"0 2px 4px rgba(0,0,0,0.5)",animation:"pulse 2s infinite"},children:"LIVE"})]}),o.jsx("div",{style:{padding:"clamp(8px, 1.5vw, 12px)",height:"25%",display:"flex",alignItems:"center",justifyContent:"center"},children:o.jsx("h3",{style:{fontSize:"clamp(12px, 2.2vw, 14px)",color:"white",margin:0,fontWeight:"bold",textAlign:"center",lineHeight:"1.2",overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:D.name})})]},D.id))}),pn()]})}),s==="browse"&&o.jsx("div",{children:o.jsxs("div",{style:{padding:"clamp(15px, 3vw, 20px)"},children:[o.jsx("h2",{style:{color:"white",fontSize:"clamp(24px, 5vw, 32px)",marginBottom:"clamp(20px, 4vw, 30px)",textAlign:"center"},children:"Browse All"}),o.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(clamp(120px, 20vw, 180px), 1fr))",gap:"clamp(15px, 3vw, 20px)",maxWidth:"1200px",margin:"0 auto"},children:ye?.videos?.slice(0,50).map((D,q)=>o.jsxs("div",{onClick:()=>
140{if(D.isUrlVideo&&D.embedUrl){const se={id:`url-${D.url}`,title:D.title,embedUrl:D.embedUrl,sourceUrl:D.embedUrl,platform:D.platform,platformVideoId:D.platformVideoId,thumbnailUrl:D.extractedThumbnail,description:D.extractedDescription,duration:D.extractedDuration,channelName:D.extractedChannelName||"YouTube"};rn(se)}else rn(D);an(!0),window.history.pushState({screen:"video",videoId:D.id},"",window.location.href)},style:{background:"#2a2a2a",borderRadius:"8px",overflow:"hidden",cursor:"pointer",transition:"transform 0.3s ease",border:"1px solid #333"},onMouseEnter:se=>se.currentTarget.style.transform="scale(1.05)",onMouseLeave:se=>se.currentTarget.style.transform="scale(1)",children:[o.jsx("div",{style:{aspectRatio:"16/9",background:"#333",backgroundImage:D.thumbnailUrl?`url(${D.thumbnailUrl})`:"none",backgroundSize:"cover",backgroundPosition:"center",position:"relative",display:"flex",alignItems:"center",justifyContent:"center"},children:o.jsx("div",{style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.4)",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 0.3s ease"},children:o.jsx("div",{style:{color:"white",fontSize:"clamp(24px, 4vw, 32px)",fontWeight:"bold",textShadow:"0 2px 4px rgba(0,0,0,0.8)"},children:"â¶"})})}),o.jsxs("div",{style:{padding:"clamp(6px, 1.2vw, 9px)"},children:[o.jsx("h3",{style:{fontSize:"clamp(8px, 1.2vw, 10px)",color:"white",margin:"0 0 2px 0",fontWeight:"bold",lineHeight:"1.3"},children:(D.title||D.name||"").replace(/^PT\d{1,2}(am|pm)\s+/i,"")}),!D.isUrlVideo&&o.jsxs("p",{style:{fontSize:"clamp(7px, 0.9vw, 8px)",color:"#999",margin:0},children:[Math.floor((D.duration||0)/60),"m ",(D.duration||0)%60,"s"]})]})]},q))}),pn()]})})]}),ll&&o.jsx("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0, 0, 0, 0.8)",zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",padding:"20px"},children:o.jsxs("div",{style:{background:"#2a2a2a",borderRadius:"12px",width:"100%",maxWidth:"500px",maxHeight:"80vh",border:"1px solid #333",display:"flex",flexDirection:"column"},children:[o.jsxs("div",{style:{padding:"20px",borderBottom:"1px solid #333",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[o.jsx("h2",{style:{color:"white",fontSize:"18px",fontWeight:"bold",margin:0},children:"Todays Playlist"}),o.jsx("button",{onClick:()=>ci(!1),style:{background:"none",border:"none",color:"#999",fontSize:"24px",cursor:"pointer",padding:"5px",lineHeight:1},children:"Ã"})]}),o.jsx("div",{style:{padding:"20px",overflowY:"auto",flex:1,maxHeight:"calc(80vh - 120px)",minHeight:"400px"},children:(()=>{const D=p||[],q=me=>{try{return me&&me.includes(":")?me:new Date(me).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0})}catch{return me||"12:00 AM"}},se=me=>{const xe=Math.floor(me/60);if(xe<60)return`${xe}m`;const Be=Math.floor(xe/60),Ne=xe%60;return`${Be}h ${Ne}m`};return D.length===0?o.jsx("div",{style:{textAlign:"center",color:"#999",padding:"40px"},children:o.jsx("p",{children:"No schedule data available"})}):o.jsx("div",{className:"space-y-2",children:D.map((me,xe)=>{const Be=ye?.currentVideo&&me.id===ye.currentVideo.id;return o.jsxs("div",{className:`schedule-item ${Be?"current":""}`,style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"12px 16px",borderRadius:"8px",backgroundColor:Be?"rgba(34, 197, 94, 0.1)":"rgba(31, 41, 55, 0.5)",borderLeft:Be?"4px solid #22c55e":"4px solid transparent"},children:[o.jsxs("div",{style:{flex:1},children:[o.jsx("h4",{style:{color:"white",fontWeight:"500",fontSize:"14px",margin:"0 0 4px 0"},children:me.title||me.name}),o.jsx("p",{style:{color:"#9ca3af",fontSize:"12px",margin:0},children:me.channelName||me.category||"ChronicTV"})]}),o.jsxs("div",{style:{textAlign:"right"},children:[o.jsxs("div",{style:{color:"white",fontSize:"12px",fontWeight:"500",marginBottom:"2px"},children:[q(me.startTime)," - ",q(me.endTime)]}),o.jsx("div",{style:{color:"#9ca3af",fontSize:"11px"},children:se(parseInt(me.duration)||0)})]})]},xe)})})})()}),o.jsx("div",{style:{padding:"15px 20px",borderTop:"1px solid #333",textAlign:"center"},children:o.jsx("p",{style:{fontSize:"12px",color:"#666",margin:0},children:"Schedule updates every 5 minutes ⢠All times are local"})})]})})]}),wu&&o.jsxs("div",{onClick:()=>bo(!1),style:{position:"fixed",inset:0,zIndex:99999,background:"rgba(0,0,0,0.92)",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"24px",cursor:"pointer"},children:[o.jsxs("div",{style:{background:"linear-gradient(135deg, #111 0%, #1a1a1a 100%)",border:"1px solid rgba(74,222,128,0.3)",borderRadius:20,padding:"48px 40px",maxWidth:480,width:"100%",textAlign:"center",boxShadow:"0 0 60px rgba(74,222,128,0.15)"},children:[o.jsx("div",{style:{width:80,height:80,borderRadius:"50%",background:"rgba(74,222,128,0.15)",display:"flex",alignItems:"center",justifyContent:"center",margin:"0 auto 24px"},children:o.jsx("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"#4ade80",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:o.jsx("polyline",{points:"20 6 9 17 4 12"})})}),o.jsx("div",{style:{fontSize:13,color:"#4ade80",fontWeight:600,letterSpacing:2,textTransform:"uppercase",marginBottom:12},children:"Welcome to"}),o.jsx("div",{style:{fontSize:28,fontWeight:900,color:"#ffffff",marginBottom:8},children:"Chronic Brands USA"}),rc&&o.jsxs("div",{style:{fontSize:20,color:"#4ade80",fontWeight:700,marginBottom:16},children:["Hey ",rc,"! ð"]}),o.jsx("p",{style:{color:"#cccccc",fontSize:15,lineHeight:1.6,margin:"0 0 8px 0"},children:"Your account is ready. A welcome email is on its way to your inbox."}),o.jsx("p",{style:{color:"#666",fontSize:13,margin:"0 0 32px 0"},children:"Tap anywhere to continue"}),o.jsx("div",{style:{width:"100%",height:3,background:"#222",borderRadius:2,overflow:"hidden"},children:o.jsx("div",{style:{height:"100%",background:"#4ade80",borderRadius:2,animation:"welcomeProgress 7s linear forwards"}})})]}),o.jsx("style",{children:` 141 @keyframes welcomeProgress { 142 from { width: 100%; } 143 to { width: 0%; } 144 } 145 `})]})]})}function gh({initialShowSlug:n,initialVideoId:e}){const[t,s]=T.useState(!0),[r,i]=T.useState(0),l=sx().getQueryData(["/api/startup-bundle"]),{data:c,isLoading:d}=gn({queryKey:["/api/startup-bundle"]});return T.useEffect(()=>{if(t){const h=setInterval(()=>{i(p=>p>=100?(clearInterval(h),100):p+(d?5:20))},100);return()=>clearInterval(h)}},[t,d]),T.useEffect(()=>{const h=c||l;if(r>=100&&h){const p=setTimeout(()=>{s(!1)},500);return()=>clearTimeout(p)}},[r,c,l]),t?o.jsxs("div",{className:"min-h-screen bg-black flex flex-col items-center justify-center relative",children:[o.jsxs(Et,{href:"/",className:"absolute top-6 left-6 flex items-center gap-2 text-white/60 hover:text-white transition-colors z-10","data-testid":"back-to-website",children:[o.jsx(Fr,{size:20}),o.jsx("span",{className:"text-sm",children:"Back to Website"})]}),o.jsxs("div",{className:"text-center",children:[o.jsx("img",{src:"/assets/ChronicTVlogo2b.png",alt:"Chronic TV",className:"w-80 h-auto mb-8 mx-auto",onError:h=>{const p=h.target;p.style.display="none"}}),o.jsxs("div",{className:"w-80 mx-auto",children:[o.jsx("div",{className:"h-1.5 bg-white/10 rounded-full overflow-hidden",children:o.jsx("div",{className:"h-full bg-gradient-to-r from-[hsl(142,76%,45%)] to-[hsl(45,93%,47%)] rounded-full transition-all duration-300 ease-out",style:{width:`${r}%`}})}),o.jsx("p",{className:"text-white/60 text-sm mt-4",children:r<100?"Loading premium content...":"Ready!"})]}),o.jsx("p",{className:"text-white/40 text-xs mt-8",children:"Premium Culture, Content, and Creativity"}),o.jsx("div",{className:"mt-6",children:o.jsx(Et,{href:"/guest-signup",className:"inline-flex items-center gap-2 text-xs text-[hsl(142,76%,45%)] hover:text-[hsl(142,76%,55%)] transition-colors border border-[hsl(142,76%,45%)]/30 hover:border-[hsl(142,76%,45%)]/50 px-4 py-2 rounded-full",children:"ðï¸ Apply to be a Show Guest"})})]})]}):o.jsx(Pue,{skipSplash:!0,initialShowSlug:n,initialVideoId:e})}const Mj=`LIABILITY WAIVER, RELEASE OF CLAIMS & ASSUMPTION OF RISK AGREEMENT 146
147This Liability Waiver, Release of Claims, and Assumption of Risk Agreement ("Agreement") is entered into voluntarily between the undersigned participant/member ("Participant") and Sacred Wellness Association, a private membership organization operating as Chronic Brands USA and Chronic TV, including its owners, officers, directors, employees, volunteers, affiliates, venue operators, representatives, contractors, and partners (collectively referred to as the "Association"). 148 149By checking the box below, Participant acknowledges and agrees to the following: 150 1511. VOLUNTARY PARTICIPATION 152Participant understands and acknowledges that participation in any Association activities, programs, services, events, educational workshops, networking functions, wellness activities, content creation activities, studio sessions, private gatherings, business incubator activities, or use of facilities is completely voluntary. Participant chooses to participate at their own free will and assumes full responsibility for their participation. 153 1542. ASSUMPTION OF RISK 155Participant understands that participation in Association activities may involve certain inherent risks, including but not limited to: bodily injury, illness, emotional distress, property damage, accidents, exposure to third parties, equipment-related injuries, wellness or fitness-related risks, food or beverage consumption risks, travel risks, and other known or unknown risks. Participant knowingly and voluntarily assumes all risks associated with participation in Association activities and use of Association facilities. 156 1573. RELEASE OF LIABILITY 158To the fullest extent permitted by law, Participant releases, waives, and forever discharges Sacred Wellness Association and all affiliated persons or entities from any and all claims, liabilities, demands, causes of action, damages, losses, costs, expenses, injuries, or lawsuits arising from or related to: participation in Association activities, use of facilities, attendance at events, interactions with members or guests, educational or wellness information provided, equipment use, or any other Association-related activities. This release applies whether caused by negligence or otherwise, except where prohibited by law. 159 1604. WELLNESS & MEDICAL DISCLAIMER 161Participant acknowledges and understands: Sacred Wellness Association is not a medical provider. The Association does not diagnose, treat, cure, or prevent any disease. Any information shared through the Association is for educational and informational purposes only. Participant should consult licensed healthcare professionals regarding medical conditions or treatment decisions. If participating in any wellness, fitness, nutrition, weight management, or GLP-1 educational programs, Participant understands that results may vary and assumes all responsibility for participation. 162 1635. FACILITY & EQUIPMENT USE 164Participant agrees to use all facilities, studios, equipment, furniture, and Association property responsibly and safely. Participant agrees to: follow posted rules, comply with staff instructions, report hazards or unsafe conditions, and avoid reckless behavior. Participant may be held financially responsible for intentional damage caused to Association property. 165 1666. PERSONAL PROPERTY 167Participant understands that Sacred Wellness Association is not responsible for lost, stolen, or damaged personal property brought onto Association premises or events. 168 1697. MEDIA RELEASE 170Participant grants Sacred Wellness Association permission to photograph, record, livestream, or otherwise capture Participant's likeness, image, voice, video, or participation during Association activities. Participant authorizes the Association to use such media for: promotional purposes, social media, marketing, educational materials, television, streaming platforms, and other lawful business purposes, without compensation unless otherwise agreed in writing. 171 1728. MEMBER & GUEST RESPONSIBILITY 173Participant agrees to act respectfully toward staff, members, guests, and the facilities. Participant understands that unsafe, unlawful, disruptive, threatening, or inappropriate conduct may result in immediate removal and/or termination of membership privileges. 174 1759. INDEMNIFICATION 176Participant agrees to indemnify and hold harmless Sacred Wellness Association from any claims, damages, legal actions, or expenses resulting from Participant's actions, negligence, misconduct, or violation of Association policies. 177 17810. GOVERNING LAW 179This Agreement shall be governed by and interpreted under the laws of the State of Oklahoma. 180 18111. SEVERABILITY 182If any portion of this Agreement is determined to be invalid or unenforceable, the remaining portions shall remain in full force and effect.`,Fj=`MEMBER CODE OF CONDUCT 183 184Our organization was built to foster a positive, uplifting, educational, creative, and supportive environment for all members. By participating in Sacred Wellness Association (operating as Chronic Brands USA and Chronic TV) activities, events, facilities, and programs, all members agree to uphold the following Code of Conduct. 185 1861. OUR MISSION 187The Association exists to promote: holistic wellness, personal growth, mentorship, entrepreneurship, creativity, education, networking, music and arts, content creation, and community collaboration. Members are expected to contribute positively toward this mission. 188 1892. RESPECT FOR OTHERS 190All members, guests, staff, and volunteers must be treated with dignity and respect at all times. Members agree to: communicate respectfully, avoid harassment or bullying, avoid discrimination, avoid threats or intimidation, and maintain a welcoming environment for all individuals regardless of background, ethnicity, religion, gender, orientation, or beliefs. 191 1923. PROFESSIONAL & POSITIVE ENVIRONMENT 193Members shall: act professionally within Association facilities, respect shared spaces, support collaborative opportunities, and avoid creating unnecessary conflict or disruption. The Association is intended to be a safe and productive environment for networking, wellness, and creativity. 194 1954. ZERO TOLERANCE FOR VIOLENCE OR THREATS 196The following behaviors are strictly prohibited: physical violence, threats, aggressive conduct, weapons violations, intimidation, stalking, or abusive behavior. Any member engaging in such conduct may be immediately removed and membership terminated without refund. 197 1985. SUBSTANCE & ALCOHOL RESPONSIBILITY 199Members must comply with all applicable Oklahoma laws and facility rules regarding: alcohol, smoking, wellness products, and controlled substances. Members may not: distribute illegal substances, engage in unlawful conduct, or create unsafe conditions for others. Intoxicated, reckless, or dangerous behavior is prohibited. 200 2016. CONTENT CREATION & MEDIA ETIQUETTE 202The Association encourages: podcasting, photography, videography, music creation, livestreaming, and creative collaboration. However, members must: respect the privacy of others, obtain permission before recording individuals, avoid defamatory or unlawful content, and comply with intellectual property laws. The Association reserves the right to restrict recording in designated private areas or events. 203 2047. BUSINESS NETWORKING ETHICS 205Members are encouraged to: collaborate, network, promote businesses, and cross-market products or services. However: deceptive sales practices, harassment, spam solicitation, or predatory behavior toward members is prohibited. Members should conduct business ethically and transparently. 206 2078. FACILITY RULES 208Members agree to: maintain cleanliness, respect equipment and property, report damages or hazards, and follow all posted facility rules. Members may be financially responsible for intentional or reckless property damage. 209 2109. PRIVACY & CONFIDENTIALITY 211Members agree to respect the privacy of: fellow members, private meetings, networking discussions, wellness conversations, and internal Association matters. Sharing private member information without consent is prohibited. 212 21310. GUEST POLICY 214Guests may only enter Association facilities: when authorized, during approved events, or while accompanied by an active member. Members are responsible for the conduct of their guests. 215 21611. SOCIAL MEDIA & PUBLIC REPRESENTATION 217Members shall not falsely represent themselves as official spokespersons of the Association unless authorized. Members are encouraged to positively represent the Association and community. Defamatory, false, or intentionally damaging public statements directed toward the Association, its members, or staff may result in disciplinary action. 218 21912. VIOLATIONS & DISCIPLINE 220Violation of this Code of Conduct may result in: verbal warnings, suspension, revocation of facility access, termination of membership, or removal from events. The Association reserves the right to deny or revoke membership at its discretion to protect the safety, integrity, and mission of the organization.`,Uj=`PRIVATE MEMBERSHIP AGREEMENT 221 222This Private Membership Agreement ("Agreement") is entered into voluntarily by and between Sacred Wellness Association, a private membership organization operating as Chronic Brands USA and Chronic TV ("Association"), and the undersigned Member ("Member"). 223 224By checking the box below, Member acknowledges and agrees to the following terms and conditions: 225 2261. PURPOSE OF ASSOCIATION 227Sacred Wellness Association is a private membership organization established for the purposes of: wellness education, holistic healing education, entrepreneurship, mentorship, networking, creative collaboration, arts and music, content creation, business incubation, community fellowship, and member-driven educational opportunities. The Association exists as a private contractual association between its members and is not open to the general public. 228 2292. PRIVATE MEMBERSHIP STATUS 230Member understands and agrees that: Sacred Wellness Association is a private membership organization. Access to facilities, events, programs, and services is limited to approved members and authorized guests only. Membership is voluntary and may be revoked at the discretion of the Association. The Association reserves the right to refuse membership to any individual for any lawful reason. 231 2323. MEMBERSHIP ELIGIBILITY 233To qualify for membership, Member must: be at least eighteen (18) years of age; complete and agree to this Agreement; submit any required application information; pay applicable membership dues. 234
2354. MEMBERSHIP BENEFITS 236Membership may include access to: member-only networking events; educational workshops and seminars; business incubator opportunities; content creation areas; podcast and media spaces; music studio access; creative collaboration opportunities; wellness education resources; lounge and coworking areas during approved hours. Benefits may change at any time at the discretion of the Association. 237 2385. MEMBERSHIP DUES 239Member agrees to pay the applicable membership dues as established by the Association. Current General Membership: $10.00 per month. Membership fees are non-refundable unless otherwise determined by the Association. 240 2416. MEMBER CONDUCT 242Members agree to: conduct themselves respectfully toward staff, members, and guests; follow all Association rules and policies; refrain from unlawful conduct; refrain from harassment, violence, threats, or disruptive behavior; respect the privacy and confidentiality of fellow members. The Association reserves the right to suspend or terminate membership at any time for violations of Association policies. 243 2447. ASSUMPTION OF RISK 245Member voluntarily assumes all risks associated with participation in Association activities, events, facilities, workshops, educational programs, and networking functions. Member acknowledges that participation is voluntary and at Member's own risk. 246 2478. RELEASE OF LIABILITY 248To the fullest extent permitted by law, Member releases and holds harmless Sacred Wellness Association, its owners, officers, directors, affiliates, volunteers, employees, agents, venue partners, and representatives from any and all liability, claims, damages, injuries, losses, or causes of action arising out of participation in Association activities or use of Association facilities. 249 2509. WELLNESS & EDUCATIONAL DISCLAIMER 251Member understands: Sacred Wellness Association does not provide medical advice, diagnosis, or treatment. Educational information shared through the Association is for informational and educational purposes only. Any wellness programs, including weight management or GLP-1 educational programs, may involve independent licensed providers where applicable. Members should consult their own healthcare professionals regarding medical decisions. 252 25310. MEDIA RELEASE 254Member grants Sacred Wellness Association permission to photograph, record, and use Member's likeness, image, voice, video, or participation for promotional, marketing, educational, and media purposes without compensation unless otherwise agreed in writing. 255 25611. PRIVACY 257The Association values member privacy. Member information will not be sold to third parties except as required by law or necessary for Association operations. Members agree to respect the privacy and confidentiality of fellow members. 258 25912. NO PUBLIC ACCESS 260Member acknowledges: Association facilities are private member spaces;
260 membership does not grant unrestricted public access; guests may only attend when authorized by the Association or accompanying an active member. 261 26213. TERMINATION OF MEMBERSHIP 263The Association may revoke, suspend, or terminate membership at any time, with or without notice, for conduct deemed contrary to the mission, safety, integrity, or operations of the Association. 264 26514. GOVERNING LAW 266This Agreement shall be governed by the laws of the State of Oklahoma.`,t7=[{id:"waiver",title:"Liability Waiver & Release of Claims",subtitle:"Assumption of Risk Agreement",text:Mj,checkLabel:"I have read and agree to the Liability Waiver & Release of Claims"},{id:"conduct",title:"Member Code of Conduct",subtitle:"Community Standards & Policies",text:Fj,checkLabel:"I have read and agree to the Member Code of Conduct"},{id:"membership",title:"Private Membership Agreement",subtitle:"Terms of Membership & Bylaws",text:Uj,checkLabel:"I have read and agree to the Private Membership Agreement"}];function Vj({onChange:n,darkMode:e=!0}){const[t,s]=T.useState({}),[r,i]=T.useState({waiver:!1,conduct:!1,membership:!1});function a(w){s(S=>({...S,[w]:!S[w]}))}function l(w,S){const _={...r,[w]:S};i(_),n(Object.values(_).every(Boolean))}const c=e?"rgba(20,20,20,0.95)":"#fff",d=e?"#333":"#ddd",h=e?"#fff":"#111",p=e?"#999":"#666",m=e?"#bbb":"#444",y=e?"rgba(10,10,10,0.8)":"#f8f8f8",x=t7.every(w=>!!r[w.id]);return o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[o.jsxs("p",{style:{fontSize:"11px",color:p,marginBottom:"2px",lineHeight:1.4},children:[o.jsx("span",{style:{color:"#f87171",fontWeight:700,marginRight:"3px"},children:"*"}),"All three agreements are required to create your account."]}),t7.map(w=>{const S=!!t[w.id],_=!!r[w.id];return o.jsxs("div",{style:{background:c,border:`1px solid ${_?"rgba(74,222,128,0.4)":x?d:"rgba(248,113,113,0.45)"}`,borderRadius:"10px",overflow:"hidden",transition:"border-color 0.2s"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[o.jsx("label",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"14px 4px 14px 14px",cursor:"pointer",flexShrink:0},onClick:L=>L.stopPropagation(),children:o.jsx("input",{type:"checkbox",checked:_,onChange:L=>l(w.id,L.target.checked),style:{width:"18px",height:"18px",accentColor:"#4ade80",cursor:"pointer",flexShrink:0},"data-testid":`checkbox-agreement-${w.id}`})}),o.jsxs("button",{type:"button",onClick:()=>a(w.id),style:{flex:1,padding:"12px 14px 12px 10px",background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px",textAlign:"left",minWidth:0},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",minWidth:0},children:[o.jsx(gb,{size:14,color:_?"#4ade80":p,style:{flexShrink:0}}),o.jsxs("div",{style:{minWidth:0},children:[o.jsx("p",{style:{margin:0,fontSize:"13px",fontWeight:600,color:_?"#4ade80":h,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:w.title}),o.jsx("p",{style:{margin:0,fontSize:"11px",color:p},children:w.subtitle})]})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",flexShrink:0},children:[o.jsx("span",{style:{fontSize:"10px",color:p},children:"read"}),S?o.jsx(ix,{size:15,color:p}):o.jsx(ao,{size:15,color:p})]})]})]}),S&&o.jsx("div",{className:"no-scrollbar",style:{maxHeight:"220px",overflowY:"auto",padding:"14px 16px",background:y,fontSize:"11px",lineHeight:"1.7",color:m,whiteSpace:"pre-wrap",fontFamily:"system-ui, sans-serif",borderTop:`1px solid ${d}`},children:w.text})]},w.id)})]})}const Nue=()=>o.jsxs("svg",{className:"w-5 h-5 flex-shrink-0",viewBox:"0 0 24 24",children:[o.jsx("path",{fill:"#4285F4",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"}),o.jsx("path",{fill:"#34A853",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),o.jsx("path",{fill:"#FBBC05",d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"}),o.jsx("path",{fill:"#EA4335",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})]}),Lue=()=>o.jsx("svg",{className:"w-5 h-5 flex-shrink-0",viewBox:"0 0 24 24",fill:"
266currentColor",children:o.jsx("path",{d:"M17.05 20.28c-.98.95-2.05.8-3.08.35-1.09-.46-2.09-.48-3.24 0-1.44.62-2.2.44-3.06-.35C2.79 15.25 3.51 7.59 9.05 7.31c1.35.07 2.29.74 3.08.8 1.18-.24 2.31-.93 3.57-.84 1.51.12 2.65.72 3.4 1.8-3.12 1.87-2.38 5.98.48 7.13-.57 1.5-1.31 2.99-2.54 4.09l.01-.01zM12.03 7.25c-.15-2.23 1.66-4.07 3.74-4.25.29 2.58-2.34 4.5-3.74 4.25z"})});function my({isOpen:n,onClose:e,initialMode:t="signup",primaryColor:s="#4ade80"}){const[r,i]=T.useState(t),[a,l]=T.useState(""),[c,d]=T.useState(""),[h,p]=T.useState(!1),[m,y]=T.useState(""),[x,w]=T.useState(""),[S,_]=T.useState(""),[L,R]=T.useState(!1),[M,V]=T.useState(""),[W,I]=T.useState(""),[k,P]=T.useState(!1),[N,F]=T.useState(!1);if(T.useEffect(()=>{if(n){const Y=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=Y}}},[n]),T.useEffect(()=>{if(n){const Y=new URLSearchParams(window.location.search),ee=Y.get("ref")||Y.get("promo")||Y.get("code");ee&&V(ee.toUpperCase())}},[n]),!n)return null;const z=async()=>{P(!0),I("");try{await Vm(),e()}catch(Y){I(Y.message||"Google sign-in failed")}finally{P(!1)}},U=async()=>{P(!0),I("");try{await Zx(),e()}catch(Y){I(Y.message||"Apple sign-in failed")}finally{P(!1)}},fe=async Y=>{Y.preventDefault(),P(!0),I("");try{if(r==="signup"){if(!m.trim()||!x.trim()){I("First name and last name are required"),P(!1);return}if(!L){I("Please read and agree to all membership agreements"),P(!1);return}await kf(a,c,m,x,S),e()}else r==="signin"?(await Rf(a,c),e()):r==="reset"&&(await Pf(a),F(!0))}catch(ee){I(ee.message||"Authentication failed")}finally{P(!1)}},oe="w-full px-4 py-3.5 rounded-xl bg-white/5 border border-white/15 text-white placeholder-white/30 focus:outline-none focus:border-white/40 focus:bg-white/8 transition-all text-base",X="block text-white/50 text-xs font-medium mb-1.5 uppercase tracking-wide",Q=r==="signup",G=!k&&(r!=="signup"||L);return o.jsx("div",{className:"fixed inset-0 z-50 flex items-end sm:items-center justify-center",style:{background:"rgba(0,0,0,0.75)",backdropFilter:"blur(4px)"},onClick:Y=>Y.target===Y.currentTarget&&e(),"data-testid":"auth-modal-overlay",children:o.jsxs("div",{className:"relative w-full sm:max-w-md sm:mx-4 flex flex-col bg-[#161616] sm:rou
266nded-2xl rounded-t-3xl shadow-2xl border border-white/10",style:{maxHeight:"92dvh"},"data-testid":"auth-modal",children:[o.jsx("div",{className:"sm:hidden flex justify-center pt-3 pb-0 flex-shrink-0",children:o.jsx("div",{className:"w-10 h-1 rounded-full bg-white/20"})}),o.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between px-5 pt-4 pb-3 sm:pt-6 border-b border-white/8",children:[o.jsxs("div",{children:[o.jsx("h2",{className:"text-xl sm:text-2xl font-bold text-white leading-tight",children:r==="signin"?"Welcome back":r==="signup"?"Create account":"Reset password"}),r==="signin"&&o.jsx("p",{className:"text-white/40 text-sm mt-0.5",children:"Sign in to your membership"}),r==="signup"&&o.jsx("p",{className:"text-white/40 text-sm mt-0.5",children:"Join the community â it's free"})]}),o.jsx("button",{onClick:e,className:"w-9 h-9 flex items-center justify-center rounded-full bg-white/8 hover:bg-white/15 text-white/60 hover:text-white transition-all flex-shrink-0 ml-3","data-testid":"auth-modal-close",children:o.jsx(Mr,{size:18})})]}),o.jsxs("div",{className:"no-scrollbar flex-1 overflow-y-auto overscroll-contain px-5 py-4 space-y-4",style:{WebkitOverflowScrolling:"touch"},children:[r!=="reset"&&o.jsxs("div",{className:"space-y-2.5",children:[o.jsxs("button",{type:"button",onClick:z,disabled:k,className:"w-full py-3.5 rounded-xl font-semibold bg-white text-zinc-900 flex items-center justify-center gap-3 hover:bg-white/90 active:scale-[0.98] transition-all disabled:opacity-50 text-base","data-testid":"auth-google",children:[o.jsx(Nue,{}),"Continue with Google"]}),o.jsxs("button",{type:"button",onClick:U,disabled:k,className:"w-full py-3.5 rounded-xl font-semibold bg-zinc-900 text-white border border-white/15 flex items-center justify-center gap-3 hover:bg-zinc-800 active:scale-[0.98] transition-all disabled:opacity-50 text-base","data-testid":"auth-apple",children:[o.jsx(Lue,{}),"Continue with Apple"]}),o.jsxs("div",{className:"flex items-center gap-3 py-1",children:[o.jsx("div",{className:"flex-1 h-px bg-white/12"}),o.jsx("span",{className:"text-white/30 text-xs font-medium",children:"or continue with email"}),o.jsx("div",{className:"flex-1 h-px bg-white/12"})]})]}),W&&o.jsxs("div",{className:"p-3.5 rounded-xl bg-red-500/15 border border-red-500/30 text-red-400 text-sm flex items-start gap-2.5",children:[o.jsx("span",{className:"mt-0.5 text-base leading-none",children:"â "}),o.jsx("span",{children:W})]}),r==="reset"&&N?o.jsxs("div",{className:"text-center py-6 space-y-3",children:[o.jsx("div",{className:"text-4xl",children:"ð¬"}),o.jsx("p",{className:"text-white font-semibold",children:"Check your inbox"}),o.jsx("p",{className:"text-white/50 text-sm",children:"We sent a password reset link to your email."}),o.jsx("button",{onClick:()=>{i("signin"),F(!1)},className:"text-sm font-medium hover:underline mt-2",style:{color:s},children:"Back to Sign In"})]}):o.jsxs("form",{onSubmit:fe,className:"space-y-3.5",children:[Q&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs("div",{children:[o.jsx("label",{className:X,children:"First name"}),o.jsx("input",{type:"text",value:m,onChange:Y=>y(Y.target.value),className:oe,placeholder:"First",required:!0,autoComplete:"given-name","data-testid":"auth-first-name"})]}),o.jsxs("div",{children:[o.jsx("label",{className:X,children:"Last name"}),o.jsx("input",{type:"text",value:x,onChange:Y=>w(Y.target.value),className:oe,placeholder:"Last",required:!0,autoComplete:"family-name","data-testid":"auth-last-name"})]})]}),o.jsx("p",{className:"text-white/25 text-xs -mt-1",children:"Name must match government-issued ID"}),o.jsxs("div",{children:[o.jsx("label",{className:X,children:"Phone number"}),o.jsx("input",{type:"tel",value:S,onChange:Y=>_(Y.target.value),className:oe,placeholder:"+1 (555) 000-0000",autoComplete:"tel",inputMode:"tel","data-testid":"auth-phone"})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:X,children:"Email address"}),o.jsx("input",{type:"email",value:a,onChange:Y=>l(Y.target.value),className:oe,placeholder:"[email protected]",required:!0,autoComplete:"email",inputMode:"email","data-testid":"auth-email"})]}),r!=="reset"&&o.jsxs("div",{children:[o.jsx("label",{className:X,children:"Password"}),o.jsxs("div",{className:"relative",children:[o.jsx("input",{type:h?"text":"password",value:c,onChange:Y=>d(Y.target.value),className:oe+" pr-12",placeholder:"â¢â¢â¢â¢â¢â¢â¢â¢",required:!0,autoComplete:Q?"new-password":"current-password","data-testid":"auth-password"}),o.jsx("button",{type:"button",onClick:()=>p(!h),className:"absolute right-3.5 top-1/2 -translate-y-1/2 text-white/30 hover:text-white/60 transition-colors text-xs font-medium select-none",children:h?"HIDE":"SHOW"})]})]}),r==="signin"&&o.jsx("div",{className:"text-right -mt-1",children:o.jsx("button",{type:"button",onClick:()=>i("reset"),className:"text-sm hover:underline",style:{color:s},children:"Forgot password?"})}),Q&&o.jsx("div",{className:"pt-1",children:o.jsx(Vj,{onChange:R})}),Q&&o.jsxs("div",{children:[o.jsxs("label",{className:"block text-xs font-semibold text-white/50 uppercase tracking-wide mb-1.5",children:["Promo or Referral Code ",o.jsx("span",{className:"normal-case font-normal",children:"(optional)"})]}),o.jsx("input",{type:"text",value:M,onChange:Y=>V(Y.target.value.toUpperCase()),placeholder:"Enter code",autoComplete:"off",className:"w-full px-4 py-3 rounded-xl text-sm text-white placeholder-white/25 bg-white/8 border border-white/10 focus:outline-none focus:border-white/30 tracking-widest"})]}),Q&&o.jsxs("p",{className:"text-white/30 text-xs text-center leading-relaxed px-1",children:["Membership is free. ",o.jsx("span",{className:"text-yellow-400/70 font-semibold",children:"Premier"})," is a paid monthly subscription â upgrade anytime for partner discounts & exclusive content."]}),o.jsx("button",{type:"submit",disabled:!G,className:"w-full py-4 rounded-xl font-bold text-black text-base transition-all active:scale-[0.98] disabled:opacity-40 disabled:cursor-not-allowed",style:{background:G?s:"#555"},"data-testid":"auth-submit",children:k?o.jsxs("span",{className:"flex items-center justify-center gap-2",children:[o.jsx("span",{className:"w-4 h-4 border-2 border-black/40 border-t-black rounded-full animate-spin"}),"Please waitâ¦"]}):r==="signin"?"Sign In":r==="signup"?"Create Account":"Send Reset Link"})]}),o.jsx("p",{className:"text-center text-sm text-white/40 pb-2",children:r==="signin"?o.jsxs(o.Fragment,{children:["Don't have an account?"," ",o.jsx("button",{onClick:()=>{i("signup"),I("")},className:"font-semibold hover:underline",style:{color:s},children:"Sign up free"})]}):r==="signup"?o.jsxs(o.Fragment,{children:["Already a member?"," ",o.jsx("button",{onClick:()=>{i("signin"),I("")},className:"font-semibold hover:underline",style:{color:s},children:"Sign in"})]}):o.jsx("button",{onClick:()=>{i("signin"),I("")},className:"font-semibold hover:underline",style:{color:s},children:"â Back to Sign In"})})]})]})})}
266const n7={"Chronic News Classics":["Breaking cannabis industry news","In-depth investigative reports","Legislative updates and policy analysis","Community spotlight stories"],"Chronic Studios":["Full-service video production","Professional lighting and sound","Post-production editing","Brand commercial creation"],"Chronic TMZ with Carri Chronic":["Celebrity cannabis culture coverage","Exclusive interviews and reveals","Entertainment industry insights","Behind-the-scenes access"],"Chronic Reviews":["Honest product evaluations","Strain reviews and ratings","Dispensary spotlights","Consumer buying guides"],"Chronic Cuties":["Lifestyle and fashion content","Brand ambassador features","Photo and video shoots","Social media collaborations"],"Chronic Sports Talk":["Cannabis and athletics coverage","Athlete wellness discussions","Sports industry cannabis news","Live commentary and analysis"],"Chronic Palooza":["Cannabis festival coverage","Live event broadcasting","Vendor and brand showcases","Community celebration events"],"In The Streets with CarriChronic":["Street-level interviews","Community voice platform","Real people, real stories","Oklahoma neighborhood features"],"Chronic Docs":["Medical marijuana evaluations","Licensed physician consultations","Fast and affordable appointments","Renewal and new patient services"],"OlyLife Oklahoma":["Terahertz wellness technology","Pain relief and recovery","Cellular regeneration devices","Holistic health solutions"],"Sacred Wellness Assocation":["Wellness community network","Holistic health education","Member support and resources","Spiritual wellness practices"]};function Due(n){const e=[/player\.vimeo\.com\/video\/(\d+)/,/vimeo\.com\/(\d+)/,/vimeo\.com\/video\/(\d+)/];for(const t of e){const s=n.match(t);if(s)return s[1]}return null}function jue(n){const e=Due(n);return e?`https://player.vimeo.com/video/${e}?autoplay=0&title=0&byline=0&portrait=0`:null}function Oue(n){return new Promise(e=>{const t=new Image;t.crossOrigin="anonymous",t.onload=()=>{const s=document.createElement("canvas"),r=s.getContext("2d");if(!r){e({primary:"#4ade80",secondary:"#facc15",accent:"#fbbf24"});return}s.width=50,s.height=50,r.drawImage(t,0,0,50,50);const i=r.getImageData(0,0,50,50).data,a={};for(let c=0;c<i.length;c+=4){const d=Math.round(i[c]/32)*32,h=Math.round(i[c+1]/32)*32,p=Math.round(i[c+2]/32)*32;if(d<30&&h<30&&p<30||d>225&&h>225&&p>225)continue;const m=`${d},${h},${p}`;a[m]=(a[m]||0)+1}const l=Object.entries(a).sort((c,d)=>d[1]-c[1]).slice(0,3).map(([c])=>{const[d,h,p]=c.split(",").map(Number);return`rgb(${d}, ${h}, ${p})`});e({primary:l[0]||"#4ade80",secondary:l[1]||"#facc15",accent:l[2]||"#fbbf24"})},t.onerror=()=>{e({primary:"#4ade80",secondary:"#facc15",accent:"#fbbf24"})},t.src=n})}function Mue(){const[,n]=eF("/:brandSlug"),e=n?.brandSlug??"",[t,s]=T.useState(null),[r,i]=T.useState(!1),{data:a=[]}=gn({queryKey:["/api/website-brands"],staleTime:0,refetchOnMount:"always"}),[l,c]=T.useState(!1),d=Array.isArray(a)&&a.length>0,h=e.toUpperCase().trim(),{data:p}=gn({queryKey:["/api/code-registry/lookup",h],queryFn:()=>fetch(`/api/code-registry/lookup/${h}`).then(N=>N.json()),enabled:d,staleTime:6e4}),{data:m}=gn({queryKey:["/api/startup-bundle"]}),y=m?.categories||[],x=N=>N.replace(/\s+/g,"").toLowerCase(),w=Array.isArray(a)?a:[],S=w.find(N=>{const F=x(N.brandName),z=x(e);return F===z||F.includes(z)||z.includes(F)}),_=S?y.find(N=>{const F=N.name.toLowerCase().replace(/\s+/g,""),z=S.brandName.toLowerCase().replace(/\s+/g,"");return F===z}):null,L=_?.thumbnailUrl||"",M=(m?.partnerBrands||[]).find(N=>{if(!S?.brandName||!N.brandName)return!1;const F=S.brandName.toLowerCase().replace(/\s+/g,""),z=N.brandName.toLowerCase().replace(/\s+/g,"");return F===z||F.includes(z)||z.includes(F)}),V=S?.description||_?.summaryContent||_?.description||`Welcome to ${S?.brandName||e}. Discover our services and offerings.`,W=Array.isArray(S?.features)&&S.features.length>0?S.features:S?.brandName&&n7[S.brandName]?n7[S.brandName]:[];T.useEffect(()=>{if(L&&!S?.primaryColor){const N=`/api/drive-thumbnail?url=${encodeURIComponent(L)}`;Oue(N).then(s)}},[L,S]);const I=S?.primaryColor||t?.primary||"#4ade80",k=S?.vimeoTrailer?jue(S.vimeoTrailer):null,P=L?`/api/drive-thumbnail?url=${encodeURIComponent(L)}&v=${btoa(L).slice(-12)}`:S?.logoUrl?`/api/drive-thumbnail?url=${encodeURIComponent(S.logoUrl)}`:null;if(!S&&w.length>0){if(p?.found){const N=()=>{navigator.clipboard.writeText(p.code).then(()=>{c(!0),setTimeout(()=>c(!1),2500)})};return o.jsx("div",{className:"min-h-screen bg-[#0a0a0f] flex items-center justify-center p-6",children:o.jsxs("div",{className:"max-w-lg w-full",children:[o.jsxs("div",{className:"text-center mb-8",children:[o.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-2xl bg-green-500/10 border border-green-500/30 mb-4",children:o.jsx(ox,{size:28,className:"text-green-400"})}),o.jsx("h1",{className:"text-3xl font-bold text-white mb-2",children:"You've Got a Code!"}),o.jsxs("p",{className:"text-white/50 text-sm",children:[p.ownerName?`Referred by ${p.ownerName}`:"Referral & promo code",p.sourcePlatform?` · via ${p.sourcePlatform}`:""]})]}),o.jsxs("div",{className:"bg-white/5 border border-white/10 rounded-2xl p-6 mb-6 text-center",children:[o.jsx("p",{className:"text-white/40 text-xs uppercase tracking-widest mb-3",children:"Your Code"}),o.jsxs("div",{className:"flex items-center justify-center gap-3",children:[o.jsx("span",{className:"text-4xl font-black text-white tracking-widest font-mono",children:p.code}),o.jsx("button",{onClick:N,className:"flex items-center gap-1.5 bg-green-500/10 hover:bg-green-500/20 border border-green-500/30 text-green-400 rounded-lg px-3 py-2 text-sm font-semibold transition-all",children:l?o.jsxs(o.Fragment,{children:[o.jsx(dF,{size:15})," Copied!"]}):o.jsxs(o.Fragment,{children:[o.jsx(Dh,{size:15})," Copy"]})})]}),o.jsx("p",{className:"text-white/30 text-xs mt-4",children:"Save this code â you'll need it at checkout or signup"})]}),o.jsxs("div",{className:"bg-white/3 border border-white/8 rounded-xl p-5 mb-6 space-y-3",children:[o.jsxs("p",{className:"text-white/70 text-sm leading-relaxed",children:["This code is registered with ",o.jsx("strong",{className:"text-white",children:"Chronic Brands USA"})," for purchases and services. Use it at checkout to apply any discounts or to credit your referral source."]}),o.jsxs("p",{className:"text-white/50 text-sm",children:["Explore our services below, then enter ",o.jsx("strong",{className:"text-green-400",children:p.code})," when you're ready to buy."]})]}),o.jsxs("div",{className:"flex flex-col gap-3",children:[o.jsxs(Et,{href:"/business",className:"flex items-center justify-center gap-2 bg-green-500 hover:bg-green-400 text-black font-bold px-6 py-4 rounded-xl text-base transition-all",children:[o.jsx(X0,{size:18}),"Explore Our Services"]}),o.jsxs(Et,{href:"/",className:"flex items-center justify-center gap-2 text-white/40 hover:text-white/70 font-medium px-6 py-3 rounded-xl text-sm transition-all border border-white/8 hover:border-white/20",children:[o.jsx(Fr,{size:15}),"Back to Home"]})]})]})})}return o.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:o.jsxs("div",{className:"text-center",children:[o.jsx("h1",{className:"text-4xl font-bold text-white mb-4",children:"Brand Not Found"}),o.jsx("p",{className:"text-white/60 mb-8",children:"The brand you're looking for doesn't exist yet."}),o.jsxs(Et,{href:"/",className:"inline-flex items-center gap-2 bg-[hsl(142,76%,45%)] text-black px-6 py-3 rounded-full font-bold",children:[o.jsx(Fr,{size:18}),"Back to Home"]})]})})}return o.jsxs("div",{className:"min-h-screen bg-black",children:[o.jsxs(Et,{href:"/brands",className:"fixed top-6 left-6 z-30 inline-flex items-center gap-2 text-white/80 hover:text-white transition-colors bg-black/60 px-4 py-2 rounded-full backdrop-blur-sm","data-testid":"back-button",children:[o.jsx(Fr,{size:18}),"Back"]}),o.jsxs("div",{className:"relative w-full h-[70vh] overflow-hidden",style:{backgroundColor:"#1a1a1a"},children:[P&&o.jsxs(o.Fragment,{children:[o.jsx("img",{src:P,alt:S?.brandName||e,className:"absolute inset-0 w-full h-full object-cover"}),o.jsx("div",{className:"absolute inset-0 bg-black/60"})]}),k&&o.jsx("div",{className:"absolute inset-0 flex items-center justify-center p-4 md:p-8",children:o.jsx("div",{className:"w-full max-w-5xl aspect-video rounded-xl overflow-hidden shadow-2xl border border-white/10",children:o.jsx("iframe",{src:k,className:"w-full h-full",allow:"autoplay; fullscreen; picture-in-picture",allowFullScreen:!0,"data-testid":"brand-hero-video"})})}),o.jsx("div",{className:"absolute inset-x-0 bottom-0 h-32",style:{background:"linear-gradient(to bottom, transparent 0%, black 100%)"}})]}),o.jsxs("div",{className:"relative z-10 px-6 md:px-12 py-8 -mt-20",children:[o.jsx("h1",{className:"text-4xl md:text-6xl lg:text-7xl font-bold mb-4",style:{color:I},"data-testid":"brand-title",children:o.jsx(X6,{brandName:S?.brandName||e,size:"4xl",color:I})}),o.jsx("p",{className:"text-white/80 text-lg md:text-xl max-w-3xl leading-relaxed mb-6",children:V}),W.length>0&&o.jsx("ul",{className:"grid grid-cols-1 md:grid-cols-2 gap-2 mb-8 max-w-3xl",children:W.map((N,F)=>o.jsxs("li",{className:"flex items-center gap-2 text-white/80",children:[o.jsx(_a,{size:16,style:{color:I},className:"flex-shrink-0"}),o.jsx("span",{className:"text-sm md:text-base",children:N})]},F))}),o.jsxs("div",{className:"flex flex-wrap gap-4",children:[_&&o.jsxs(Et,{href:`/chronic-tv/${_.name.toLowerCase().replace(/\s+/g,"-")}`,className:"inline-flex items-center gap-2 px-6 py-3 rounded-full font-bold text-lg transition-all hover:scale-105",style:{background:I,color:"black"},"data-testid":"watch-on-chronictv-button",children:[o.jsx("span",{className:"text-black",children:"Watch on"}),o.jsx("img",{src:"/assets/ChronicTVlogo2b.png",alt:"ChronicTV",className:"h-10 w-auto"})]}),S?.brandFunnel?o.jsxs("a",{href:S.brandFunnel,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 px-6 py-3 rounded-full font-bold text-lg transition-all hover:scale-105",style:{background:I,color:"black"},"data-testid":"brand-funnel-button",children:[o.jsx(yh,{size:20}),"Get Merch / Schedule"]}):o.jsxs("span",{className:"inline-flex items-center gap-2 px-6 py-3 rounded-full font-bold text-lg opacity-40 cursor-not-allowed",style:{background:I,color:"black"},"data-testid":"brand-funnel-button-disabled",children:[o.jsx(yh,{size:20}),"Get Merch / Schedule"]}),S?.brandUrl?o.jsxs("a",{href:S.brandUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 px-6 py-3 rounded-full font-bold text-lg border-2 transition-all hover:scale-105",style:{borderColor:I,color:I},"data-testid":"brand-url-button",children:[o.jsx(yh,{size:20}),"Check out Social Media"]}):o.jsxs("span",{className:"inline-flex items-center gap-2 px-6 py-3 rounded-full font-bold text-lg border-2 opacity-40 cursor-not-allowed",style:{borderColor:I,color:I},"data-testid":"brand-url-button-disabled",children:[o.jsx(yh,{size:20}),"Check out Social Media"]})]}),M&&o.jsxs("div",{className:"mt-10 max-w-xl","data-testid":"member-discount-section",children:[o.jsxs("div",{className:"flex items-center justify-between gap-2 mb-2",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-xl",children:"ð"}),o.jsx("h2",{className:"text-xl font-bold text-[#facc15]",children:"Premier Member Discount"})]}),o.jsx("button",{onClick:()=>i(!0),className:"text-sm px-4 py-1.5 rounded-full border border-[#4ade80]/60 text-[#4ade80] hover:bg-[#4ade80]/10 transition-colors","data-testid":"not-a-member-button",children:"Not a Member?"})]}),o.jsxs("a",{href:M.referralLink,target:"_blank",rel:"noopener noreferrer",className:"block p-4 rounded-xl transition-all hover:scale-[1.02]",style:{background:"#1a1a1a",border:`1px solid ${I}30`},"data-testid":"discount-card",children:[o.jsxs("div",{className:"flex justify-between items-start mb-2",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"text-lg font-semibold text-white",children:M.brandName}),o.jsx("p",{className:"text-white/60 text-sm",children:M.shortInfo})]}),o.jsx(yh,{size:16,className:"text-white/40 flex-shrink-0"})]}),o.jsxs("div",{className:"mt-3 flex items-center gap-2 flex-wrap",children:[o.jsxs("div",{className:"px-3 py-2 rounded-lg text-sm font-medium",style:{background:`${I}20`,color:I},children:["ð ",M.discount]}),o.jsx("div",{className:"px-3 py-2 rounded-lg text-sm text-white/50 bg-white/10",children:"For Premier members only"})]})]})]})]}),o.jsx(my,{isOpen:r,onClose:()=>i(!1),initialMode:"signup",primaryColor:I})]})}const Ih=2.8,s7=[0,1,2,3,4,5,6,7,8,9];function Fue({digit:n,delay:e}){const t=T.useRef(!0),[s,r]=T.useState(n),[i,a]=T.useState(!1);return T.useEffect(()=>{if(t.current){t.current=!1,r(n),a(!1);return}if(s===n)return;const l=setTimeout(()=>{a(!0),r(n)},e);return()=>clearTimeout(l)},[n]),o.jsx("span",{style:{display:"inline-block",width:"2.1rem",he
266ight:`${Ih}rem`,overflow:"hidden",position:"relative",borderRadius:"0.375rem",fontSize:"1.9rem",fontFamily:"monospace",fontWeight:700,color:"white",background:"linear-gradient(180deg, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0.04) 100%)",border:"1px solid rgba(255,255,255,0.12)",boxShadow:"inset 0 2px 4px rgba(0,0,0,0.4)",verticalAlign:"middle"},children:o.jsx("span",{style:{display:"block",height:`${s7.length*Ih}rem`,transform:`translateY(-${s*Ih}rem)`,transition:i?"transform 0.65s cubic-bezier(0.23, 1, 0.32, 1)":"none"},children:s7.map(l=>o.jsx("span",{style:{display:"block",height:`${Ih}rem`,lineHeight:`${Ih}rem`,textAlign:"center"},children:l},l))})})}function Uue({count:n}){const e=String(n).replace(/\B(?=(\d{3})+(?!\d))/g,","),t=[];let s=e.replace(/,/g,"").length-1;for(const r of e)r===","?t.push({type:"comma",value:0,key:`c${s}`}):(t.push({type:"digit",value:parseInt(r,10),key:`d${s}`}),s--);return o.jsx("div",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:"0.25rem",flexWrap:"wrap",verticalAlign:"middle"},children:t.map((r,i)=>r.type==="comma"?o.jsx("span",{style:{color:"rgba(255,255,255,0.4)",fontWeight:700,fontSize:"1.6rem",lineHeight:`${Ih}rem`,paddingBottom:"0.1rem"},children:","},r.key):o.jsx(Fue,{digit:r.value,delay:i*70},r.key))})}function Vue(){const[,n]=Xl(),[e,t]=T.useState(!1),[s,r]=T.useState(!1),[i,a]=T.useState(!1),[l,c]=T.useState(!1),[d,h]=T.useState(!1),[p,m]=T.useState("signup"),{data:y}=gn({queryKey:["/api/member-count"],refetchInterval:300*1e3,staleTime:240*1e3});T.useEffect(()=>{vu();const I=Md(async k=>{if(r(!!k),k)try{const P=await zm(k.uid);t(P.tier==="premier"&&P.status==="active")}catch{t(!1)}else t(!1)});return()=>I()},[]);const{data:x,isLoading:w}=gn({queryKey:["/api/google-drive/document/Membership Details"]}),{data:S,isLoading:_}=gn({queryKey:["/api/partner-brands"]}),{data:L}=gn({queryKey:["/api/site-settings"]}),M=(S?.data||[]).filter(I=>I.discount&&I.discount.trim()!==""),W=(()=>{let I=0;return M.forEach(k=>{const P=k.discount.match(/(\d+(?:\.\d+)?)\s*%/);if(P){const F=parseFloat(P[1]);I+=F*10}const N=k.discount.match(/\$(\d+(?:\.\d+)?)/);N&&(I+=parseFloat(N[1]))}),I})();return w||_?o.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:o.jsxs("div",{className:"flex items-center gap-3 text-white/60",children:[o.jsx(Nn,{className:"animate-spin",size:24}),"Loading membership details..."]})}):o.jsxs("div",{className:"min-h-screen bg-black",children:[o.jsxs("section",{className:"relative py-10 md:py-14 px-4 overflow-hidden",children:[o.jsx(tN,{url:L?.membershipHeroMediaUrl,mediaType:L?.membershipHeroMediaType,alt:"Premier Membership hero"}),o.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-[hsl(45,93%,20%)]/20 to-black"}),L?.membershipHeroMediaUrl&&o.jsx("div",{className:"absolute inset-0 bg-black/45"}),o.jsxs("div",{className:"relative max-w-7xl mx-auto text-center",children:[o.jsx(xh,{className:"mx-auto mb-3 text-[hsl(45,93%,47%)]",size:48}),o.jsxs("h1",{className:"text-3xl md:text-5xl font-bold mb-3","data-testid":"membership-title",children:[o.jsx("span",{className:"text-white",children:"Premier "}),o.jsx("span",{className:"text-[hsl(142,76%,45%)]",children:"Membership"})]}),o.jsxs("p",{className:"text-lg md:text-xl text-white/70 max-w-3xl mx-auto inline-flex flex-wrap items-center justify-center gap-1",children:[o.jsx("span",{children:"Exclusive rebates and benefits for"}),o.jsx(Is,{size:"lg",color:"#4ade80",suffix:" Brands",className:"translate-y-1 -mr-2"}),o.jsx("span",{children:"Premier members"})]}),!s&&o.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-center gap-4 mt-6",children:[o.jsxs("div",{className:"flex flex-col items-center",children:[o.jsxs("button",{onClick:()=>{m("signup"),h(!0)},className:"inline-flex items-center gap-2 bg-[hsl(45,93%,47%)] text-black px-8 py-4 rounded-full font-bold text-lg hover:bg-[hsl(45,93%,57%)] transition-colors cursor-pointer",children:[o.jsx(xh,{size:20}),"Join Premier Today"]}),o.jsx("span",{className:"text-white/50 text-xs mt-2",children:"Save $10 on door fees"})]}),o.jsxs("button",{onClick:()=>{m("signup"),h(!0)},className:"inline-flex items-center gap-2 bg-transparent border-2 border-[hsl(142,76%,45%)] text-[hsl(142,76%,45%)] px-8 py-4 rounded-full font-bold text-lg hover:bg-[hsl(142,76%,45%)]/10 transition-colors cursor-pointer",children:[o.jsx(lx,{size:20}),"Join for Free"]})]}),y&&y.count>0&&o.jsxs("div",{className:"mt-10 flex flex-wrap items-center justify-center gap-x-2 gap-y-1 text-white/60 text-sm md:text-base tracking-wide",children:[o.jsx("span",{children:"Be part of the movement, we are"}),o.jsx(Uue,{count:y.count}),o.jsx("span",{children:"members strong"})]})]})]}),s&&o.jsx("section",{className:"px-4 pb-2 -mt-2",children:o.jsx("div",{className:"max-w-lg mx-auto",children:e?o.jsxs("div",{className:"rounded-2xl overflow-hidden border border-[hsl(45,93%,47%)]/40",style:{background:"linear-gradient(135deg, hsl(45,93%,12%) 0%, hsl(142,60%,8%) 100%)"},children:[o.jsxs("div",{className:"flex items-center gap-2 px-4 pt-4 pb-1",children:[o.jsx(H7,{size:14,className:"text-[hsl(45,93%,47%)] fill-[hsl(45,93%,47%)]"}),o.jsx("span",{className:"text-[hsl(45,93%,47%)] text-xs font-bold uppercase tracking-wider",children:"Active Premier Member"})]}),o.jsxs("div",{className:"px-4 pb-4",children:[o.jsx("p",{className:"text-white/70 text-sm mb-4",children:"Show your Member ID at any partner location to receive your discount."}),o.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[o.jsxs("button",{onClick:()=>window.dispatchEvent(new CustomEvent("open-proof-modal")),className:"flex-1 flex items-center justify-center gap-2 py-4 rounded-xl font-bold text-black text-base active:scale-95 transition-transform",style:{background:"#ffd700"},children:[o.jsx(Yu,{size:22}),"Get Proof of Membership"]}),o.jsxs("button",{onClick:()=>{const I=`${window.location.origin}/membership?ref=member`,k=`Hey, join Chronic Brands USA for free today â I'm already a member! ${I}`;navigator.share?navigator.share({title:"Join Chronic Brands USA",text:k,url:I}).catch(()=>{}):(navigator.clipboard.writeText(k),c(!0),setTimeout(()=>c(!1),2e3))},className:"flex items-center justify-center gap-2 px-5 py-4 rounded-xl font-bold text-[hsl(142,76%,45%)] border-2 border-[hsl(142,76%,45%)]/50 text-sm active:scale-95 transition-transform",children:[l?o.jsx(_a,{size:18}):o.jsx(Jc,{size:18}),l?"Copied!":"Refer Friends"]})]})]})]}):o.jsx("div",{className:"rounded-2xl border border-white/10 bg-[hsl(0,0%,6%)] p-4",children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("div",{className:"w-10 h-10 rounded-full bg-[hsl(45,93%,47%)]/15 flex items-center justify-center flex-shrink-0 mt-0.5",children:o.jsx(xh,{size:20,className:"text-[hsl(45,93%,47%)]"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"text-white font-semibold text-sm mb-0.5",children:"Upgrade to Premier"}),o.jsx("p",{className:"text-white/50 text-xs mb-3",children:"Unlock rebates at all partner brands and save on events."}),o.jsxs("div",{className:"flex gap-2",children:[o.jsxs("button",{onClick:()=>n("/my-account"),className:"flex-1 flex items-center justify-center gap-1.5 py-3 rounded-xl bg-[hsl(45,93%,47%)] text-black font-bold text-sm active:scale-95 transition-transform",children:[o.jsx(xh,{size:16}),"View Membership"]}),o.jsx("button",{onClick:()=>{const I=`${window.location.origin}/membership?ref=member`,k=`Hey, join Chronic Brands USA for free today â I'm already a member! ${I}`;navigator.share?navigator.share({title:"Join Chronic Brands USA",text:k,url:I}).catch(()=>{}):(navigator.clipboard.writeText(k),c(!0),setTimeout(()=>c(!1),2e3))},className:"flex items-center justify-center gap-1.5 px-4 py-3 rounded-xl border border-[hsl(142,76%,45%)]/40 text-[hsl(142,76%,45%)] text-sm font-medium active:scale-95 transition-transform",children:l?o.jsx(_a,{size:16}):o.jsx(Jc,{size:16})})]})]})]})})})}),o.jsx("section",{className:"py-10 px-4 bg-[hsl(0,0%,5%)]",children:o.jsx("div",{className:"max-w-4xl mx-auto",children:o.jsxs("div",{className:"flex flex-col sm:flex-row items-center gap-6 p-6 bg-[hsl(142,76%,45%)]/5 border border-[hsl(142,76%,45%)]/20 rounded-2xl",children:[o.jsx("div",{className:"flex-shrink-0 flex items-center justify-center w-16 h-16 rounded-full bg-[hsl(142,76%,45%)]/10 border border-[hsl(142,76%,45%)]/20",children:o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",stroke:"hsl(142,76%,45%)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"}),o.jsx("path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}),o.jsx("line",{x1:"12",x2:"12",y1:"19",y2:"22"})]})}),o.jsxs("div",{className:"flex-1 text-center sm:text-left",children:[o.jsx("div",{className:"inline-flex items-center gap-1.5 bg-[hsl(142,76%,45%)]/10 border border-[hsl(142,76%,45%)]/25 text-[hsl(142,76%,45%)] px-2.5 py-0.5 rounded-full text-xs font-semibold uppercase tracking-wider mb-2",children:"ChronicTV Network"}),o.jsx("h3",{className:"text-base font-bold text-white mb-1",children:"Want to Be on the Show?"}),o.jsx("p",{className:"text-white/60 text-sm leading-relaxed",children:"Members can a
266pply to be a guest on any ChronicTV channel. Pick your show, share your socials, and the creator will reach out if you're selected."})]}),o.jsx("button",{onClick:()=>n("/guest-signup"),className:"shrink-0 inline-flex items-center gap-2 bg-[hsl(142,76%,45%)] hover:bg-[hsl(142,76%,50%)] text-black px-5 py-2.5 rounded-full font-bold text-sm transition-colors cursor-pointer",children:"Apply to Be a Guest"})]})})}),o.jsx(Bue,{isPremier:e}),o.jsx("section",{className:"py-12 px-4 bg-[hsl(0,0%,5%)]",children:o.jsx("div",{className:"max-w-4xl mx-auto",children:o.jsxs("div",{className:"bg-black/40 rounded-2xl border border-white/10 p-8 md:p-12",children:[o.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[o.jsx(ff,{className:"text-[hsl(45,93%,47%)]",size:28}),o.jsx("h2",{className:"text-2xl md:text-3xl font-bold text-white",children:"How the Chronic Brands Membership gives back."})]}),x?.content?(()=>{const I=x.content.split(` 267`).filter(F=>F.trim()),k=Math.min(2,I.length),P=I.length>k,N=i?I:I.slice(0,k);return o.jsxs("div",{className:"prose prose-invert max-w-none",children:[o.jsxs("div",{className:`relative ${!i&&P?"max-h-none":""}`,children:[N.map((F,z)=>o.jsx("p",{className:"text-white/80 text-lg leading-relaxed mb-4",children:F},z)),!i&&P&&o.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-16 bg-gradient-to-t from-black/40 to-transparent pointer-events-none"})]}),P&&o.jsx("button",{onClick:()=>a(!i),className:"flex items-center gap-2 text-[hsl(142,76%,45%)] hover:text-[hsl(142,76%,55%)] transition-colors font-medium mt-2 py-2 pr-4",children:i?o.jsxs(o.Fragment,{children:[o.jsx(ix,{size:20}),"Read less"]}):o.jsxs(o.Fragment,{children:[o.jsx(ao,{size:20}),"Read more"]})})]})})():o.jsx("p",{className:"text-white/60 text-lg",children:"As a Premier member, you receive exclusive rebates at all partner brands. Present your ChronicID at participating locations to receive your rebate on every transaction."})]})})}),o.jsx("section",{className:"py-16 px-4 bg-black",children:o.jsxs("div",{className:"max-w-7xl mx-auto",children:[o.jsxs("div",{className:"text-center mb-12",children:[o.jsxs("h2",{className:"text-3xl md:text-4xl font-bold mb-4",children:[o.jsx("span",{className:"text-white",children:"Premier Member "}),o.jsx("span",{className:"text-[hsl(142,76%,45%)]",children:"Rebates"})]}),o.jsx("p",{className:"text-white/60 text-lg",children:"Exclusive rebates for Premier members at our partner brands"})]}),M.length>0?o.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 md:gap-6",children:M.map((I,k)=>o.jsxs("div",{className:"bg-[hsl(0,0%,8%)] rounded-xl border border-white/10 p-4 md:p-6 hover:border-[hsl(142,76%,45%)]/30 transition-colors","data-testid":`rebate-card-${k}`,children:[(I.logoUrl||I.imageUrl)&&o.jsx("div",{className:"h-24 mb-4 rounded-lg bg-white flex items-center justify-center overflow-hidden",children:o.jsx("img",{src:I.logoUrl||I.imageUrl||"",alt:`${I.brandName} logo`,className:"max-h-full max-w-full object-contain p-2"})}),o.jsx("span",{className:"inline-block bg-[hsl(142,76%,45%)]/20 text-[hsl(142,76%,45%)] px-3 py-1 rounded-full text-sm font-bold mb-3",children:I.discount}),o.jsx("h3",{className:"text-lg font-bold text-white mb-1",children:I.brandName}),o.jsx("p",{className:"text-white/60 text-sm mb-4 leading-relaxed",children:I.shortInfo}),I.referralLink&&(e?o.jsxs("a",{href:I.referralLink,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-[hsl(45,93%,47%)] hover:text-[hsl(45,93%,57%)] transition-colors text-sm font-medium py-1","data-testid":`take-advantage-${k}`,children:[o.jsx(t4,{size:16}),"Take Advantage"]}):o.jsxs("span",{className:"inline-flex items-center gap-2 text-white/40 text-sm font-medium","data-testid":`locked-rebate-${k}`,children:[o.jsx(Gh,{size:16}),"Premier members only"]}))]},k))}):o.jsx("div",{className:"text-center py-12",children:o.jsx("p",{className:"text-white/60",children:"No partner rebates available at this time."})})]})}),o.jsx("section",{className:"py-16 px-4 bg-gradient-to-b from-black to-[hsl(0,0%,5%)]",children:o.jsx("div",{className:"max-w-2xl mx-auto",children:o.jsxs("div",{className:"bg-gradient-to-br from-[hsl(45,93%,47%)]/20 to-[hsl(142,76%,45%)]/10 rounded-2xl border border-[hsl(45,93%,47%)]/30 p-8 md:p-12 text-center",children:[o.jsx(gF,{className:"mx-auto mb-4 text-[hsl(45,93%,47%)]",size:48}),o.jsx("h2",{className:"text-2xl md:text-3xl font-bold text-white mb-2",children:"Your Potential Monthly Rebate"}),o.jsxs("p",{className:"text-white/60 mb-6",children:["Based on ",M.length," partner brands with active rebates"]}),o.jsxs("div",{className:"text-5xl md:text-6xl font-bold text-[hsl(142,76%,45%)]","data-testid":"total-rebate",children:["$",W.toFixed(2),o.jsx("span",{className:"text-xl text-white/60 font-normal",children:"/month*"})]}),o.jsx("p",{className:"text-white/40 text-sm mt-6",children:"*Estimated based on average monthly spending at partner brands. Actual rebates depend on your purchases."})]})})}),!s&&o.jsx("section",{className:"py-16 px-4 bg-[hsl(0,0%,5%)]",children:o.jsxs("div",{className:"max-w-4xl mx-auto text-center",children:[o.jsxs("h2",{className:"text-3xl md:text-4xl font-bold mb-4",children:[o.jsx("span",{className:"text-white",children:"Become a "}),o.jsx("span",{className:"text-[hsl(142,76%,45%)]",children:"Premier Member"})]}),o.jsxs("p",{className:"text-white/60 text-base md:text-lg mb-8 max-w-2xl mx-auto inline-flex flex-wrap items-center justify-center gap-1",children:[o.jsx("span",{children:"Join"}),o.jsx(Is,{size:"sm",color:"#4ade80",suffix:" Brands",className:"translate-y-0.5"}),o.jsx("span",{children:"Premier membership to unlock exclusive rebates at all our partner brands."})]}),o.jsxs("button",{onClick:()=>{m("signup"),h(!0)},className:"inline-flex items-center gap-2 bg-[hsl(45,93%,47%)] text-black px-8 py-4 rounded-full font-bold text-lg hover:bg-[hsl(45,93%,57%)] transition-colors cursor-pointer","data-testid":"cta-become-member",children:[o.jsx(xh,{size:20}),"Join Premier Today"]})]})}),o.jsx(my,{isOpen:d,onClose:()=>h(!1),initialMode:p})]})}function Bue({isPremier:n}){const[,e]=Xl(),t=sx(),[s,r]=T.useState(new Date().getMonth()+1),[i,a]=T.useState(new Date().getFullYear()),[l,c]=T.useState(null),[d,h]=T.useState(null),[p,m]=T.useState(null),[y,x]=T.useState(!1),[w,S]=T.useState(!1);T.useEffect(()=>{const X=Md(Q=>m(Q));return()=>X()},[]),T.useEffect(()=>{if(y)return;const Q=new URLSearchParams(window.location.search).get("event"),G=Q?Q.split("-")[0]:null;G&&(fetch(`/api/calendar-events/${G}`).then(Y=>Y.ok?Y.json():null).then(Y=>{if(Y){c(Y);const ee=new Date(Y.eventDate||Y.event_date);r(ee.getMonth()+1),a(ee.getFullYear())}}).catch(()=>{}),x(!0))},[y]);const{data:_=[],isLoading:L}=gn({queryKey:["/api/calendar-events/public",s,i],queryFn:()=>fetch(`/api/calendar-events/public?month=${s}&year=${i}`).then(X=>X.json())}),{data:R}=gn({queryKey:["/api/admin/settings","hide_public_calendar"],queryFn:()=>fetch("/api/admin/settings/hide_public_calendar").then(X=>X.json())}),M=R?.content==="true",V=C7({mutationFn:async({eventId:X,action:Q})=>
267{if(!p)throw new Error("Must be signed in");const G=p.displayName||p.email?.split("@")[0]||"Member";return Q==="add"?P1(`/api/calendar-events/${X}/rsvp`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({firebaseUid:p.uid,displayName:G})}):P1(`/api/calendar-events/${X}/rsvp`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({firebaseUid:p.uid})})},onSuccess:async(X,Q)=>{if(await t.invalidateQueries({queryKey:["/api/calendar-events/public",s,i]}),l&&l.id===Q.eventId)try{const G=await fetch(`/api/calendar-events/${Q.eventId}`);if(G.ok){const Y=await G.json();c(Y)}}catch{}}}),W=new Date(i,s,0).getDate(),I=new Date(i,s-1,1).getDay(),k=new Date(i,s-1).toLocaleDateString("en-US",{month:"long",year:"numeric"}),P=T.useMemo(()=>{const X={};return _.forEach(Q=>{const G=Q.eventDate||Q.event_date;X[G]||(X[G]=[]),X[G].push(Q)}),X},[_]),N=()=>{s===1?(r(12),a(X=>X-1)):r(X=>X-1)},F=()=>{s===12?(r(1),a(X=>X+1)):r(X=>X+1)},z=X=>{if(!X)return"";const[Q,G]=X.split(":").map(Number),Y=new Date;return Y.setHours(Q,G),Y.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0})},U=X=>new Date(X+"T00:00:00").toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric"}),fe=X=>!p||!X.rsvps?!1:X.rsvps.some(Q=>Q.firebaseUid===p.uid),oe=new Date().toISOString().split("T")[0];return M?null:o.jsx("section",{className:"py-16 px-4 bg-[hsl(0,0%,5%)]",children:o.jsxs("div",{className:"max-w-7xl mx-auto",children:[o.jsxs("div",{className:"text-center mb-12",children:[o.jsx(Xc,{className:"mx-auto mb-4 text-[hsl(142,76%,45%)]",size:40}),o.jsxs("h2",{className:"text-3xl md:text-4xl font-bold mb-4",children:[o.jsx("span",{className:"text-white",children:"Event "}),o.jsx("span",{className:"text-[hsl(142,76%,45%)]",children:"Calendar"})]}),o.jsx("p",{className:"text-white/60 text-lg",children:"Browse upcoming events â click any event to see details and RSVP"})]}),o.jsxs("div",{className:"bg-black/40 rounded-2xl border border-white/10 p-4 md:p-6 max-w-5xl mx-auto",children:[o.jsxs("div",{className:"flex items-center justify-between mb-6",children:[o.jsx("button",{onClick:N,className:"p-2 rounded-lg hover:bg-white/10 text-white/70 hover:text-white transition-colors",children:o.jsx(md,{size:24})}),o.jsx("h3",{className:"text-xl md:text-2xl font-bold text-white",children:k}),o.jsx("button",{onClick:F,className:"p-2 rounded-lg hover:bg-white/10 text-white/70 hover:text-white transition-colors",children:o.jsx(Uc,{size:24})})]}),o.jsx("div",{className:"grid grid-cols-7 gap-1 mb-2",children:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map(X=>o.jsx("div",{className:"text-center text-xs font-medium text-white/40 py-2",children:X},X))}),o.jsxs("div",{className:"grid grid-cols-7 gap-1",children:[Array.from({length:I}).map((X,Q)=>o.jsx("div",{className:"aspect-square"},`empty-${Q}`)),Array.from({length:W}).map((X,Q)=>{const G=Q+1,Y=`${i}-${String(s).padStart(2,"0")}-${String(G).padStart(2,"0")}`,ee=P[Y]||[],H=Y===oe,K=ee.length>0,pe=ee.some(_e=>_e.isShowEvent),Fe=ee.some(_e=>!_e.isShowEvent);return o.jsxs("div",{onClick:()=>{K&&(ee.length===1?c(ee[0]):h(ee))},className:`aspect-square rounded-lg flex flex-col items-center justify-center relative transition-all ${K?"cursor-pointer hover:bg-[hsl(142,76%,45%)]/20 border border-[hsl(142,76%,45%)]/30 hover:border-[hsl(142,76%,45%)]/60":"border border-transparent"} ${H?"bg-white/5 ring-1 ring-[hsl(142,76%,45%)]/50":""}`,children:[o.jsx("span",{className:`text-sm md:text-base font-medium ${H?"text-[hsl(142,76%,45%)]":K?"text-white":"text-white/30"}`,children:G}),K&&o.jsxs("div",{className:"flex gap-0.5 mt-0.5",children:[Fe&&o.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[hsl(142,76%,45%)]"}),pe&&o.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-purple-400"})]}),ee.length>1&&o.jsx("span",{className:"absolute -top-1 -right-1 bg-[hsl(142,76%,45%)] text-black text-[10px] font-bold w-4 h-4 rounded-full flex items-center justify-center",children:ee.length})]},G)})]}),o.jsxs("div",{className:"flex items-center gap-4 mt-3 px-1",children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("div",{className:"w-2 h-2 rounded-full bg-[hsl(142,76%,45%)]"}),o.jsx("span",{className:"text-white/40 text-xs",children:"Events"})]}),o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("div",{className:"w-2 h-2 rounded-full bg-purple-400"}),o.jsx("span",{className:"text-white/40 text-xs",children:"New Episodes / Live"})]})]}),L&&o.jsx("div",{className:"flex items-center justify-center py-8",children:o.jsx(Nn,{className:"animate-spin text-[hsl(142,76%,45%)]",size:24})}),!L&&_.length>0&&o.jsxs("div",{className:"mt-6 pt-6 border-t border-white/10",children:[o.jsx("h4",{className:"text-sm font-medium text-white/50 mb-3",children:"This month"}),o.jsx("div",{className:"space-y-2",children:_.map(X=>{const Q=X.eventType||X.event_type||"event",G=X.eventDate||X.event_date,Y=X.startTime||X.start_time,ee=!!X.isShowEvent;return o.jsxs("button",{onClick:()=>c(X),className:"w-full flex items-center gap-3 p-3 rounded-lg hover:bg-white/5 transition-colors text-left",children:[o.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${ee?"bg-purple-400":Q==="meetup"?"bg-blue-400":"bg-[hsl(142,76%,45%)]"}`}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("p",{className:"text-white font-medium text-sm truncate",children:[ee?"ðº ":"",X.title,X.episodeTitle?o.jsxs("span",{className:"text-purple-300 font-normal",children:[" â ",X.episodeTitle==="TBD"?"Topic to be determined":X.episodeTitle]}):null]}),o.jsxs("p",{className:"text-white/40 text-xs",children:[U(G),Y?` at ${z(Y)}`:"",ee&&o.jsx("span",{className:"ml-2 text-purple-400/70",children:Q==="live_stream"?"· Live Stream":"· New Episode"})]})]}),!ee&&o.jsxs("div",{className:"flex items-center gap-1 text-white/30 text-xs flex-shrink-0",children:[o.jsx(ff,{size:12}),o.jsx("span",{children:X.rsvpCount||0})]})]},X.id)})})]})]}),d&&o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",onClick:()=>h(null),children:o.jsxs("div",{className:"bg-zinc-900 border border-white/10 rounded-2xl p-6 w-full max-w-sm shadow-2xl",onClick:X=>X.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsx("h3",{className:"text-white font-bold text-lg",children:d[0]&&(()=>{const X=d[0].eventDate||d[0].event_date;return X?new Date(X+"T00:00:00").toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric"}):"Events"})()}),o.jsx("button",{onClick:()=>h(null),className:"p-1.5 rounded-full bg-zinc-800 text-zinc-400 hover:text-white transition-colors",children:o.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:o.jsx("path",{d:"M18 6 6 18M6 6l12 12"})})})]}),o.jsx("div",{className:"space-y-2",children:d.map(X=>{const Q=!!X.isShowEvent,G=X.eventType||X.event_type||"",Y=X.startTime||X.start_time;return o.jsxs("button",{onClick:()=>{h(null),c(X)},className:"w-full flex items-center gap-3 p-3 rounded-xl bg-zinc-800 hover:bg-zinc-700 transition-colors text-left",children:[o.jsx("div",{className:`w-2.5 h-2.5 rounded-full flex-shrink-0 ${Q?"bg-purple-400":"bg-[hsl(142,76%,45%)]"}`}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("p",{className:"text-white text-sm font-semibold truncate",children:[Q?"ðº ":"",X.title]}),o.jsxs("p",{className:"text-white/40 text-xs mt-0.5",children:[Y?z(Y):"",Q&&o.jsx("span",{className:"ml-1 text-purple-400/70",children:G==="live_stream"?"· Live Stream":"· New Episode"})]})]}),o.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-white/30 flex-shrink-0",children:o.jsx("path",{d:"M9 18l6-6-6-6"})})]},X.id)})})]})}),l&&o.jsx(zue,{event:l,onClose:()=>c(null),isPremier:n,firebaseUser:p,isUserRsvped:fe(l),onRsvp:X=>V.mutate({eventId:l.id,action:X}),rsvpLoading:V.isPending,formatTime:z,formatEventDate:U,navigate:e,onSignIn:()=>S(!0)}),o.jsx(my,{isOpen:w,onClose:()=>S(!1),initialMode:"signin"})]})})}function zue({event:n,onClose:e,isPremier:t,firebaseUser:s,isUserRsvped:r,onRsvp:i,rsvpLoading:a,formatTime:l,formatEventDate:c,navigate:d,onSignIn:h}){const[p,m]=T.useState(null),[y,x]=T.useState(!1),[w,S]=T.useState(!1),[_,L]=T.useState(null),R=n.eventDate||n.event_date,M=n.startTime||n.start_time,V=n.endTime||n.end_time,W=n.eventType||n.event_type||"event",I=n.memberDiscount||n.member_discount,k=n.imageUrl||n.image_url,P=n.mediaImages||n.media_images||[],N=n.videoUrl||n.video_url||"",z=(X=>{if(!X)return null;const Q=X.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([a-zA-Z0-9_-]+)/);if(Q)return`https://www.youtube.com/embed/${Q[1]}`;const G=X.match(/(?:vimeo\.com\/)(\d+)/);return G?`https://player.vimeo.com/video/${G[1]}`:null})(N),U=n.vendorSlug||n.vendor_slug,{data:fe}=gn({queryKey:["/api/events",n.id,"vendors"],queryFn:()=>fetch(`/api/events/${n.id}/vendors`).then(X=>X.json()),enabled:!!n.id}),oe=fe?.vendors||[];return o.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",onClick:e,children:[o.jsx("div",{className:"absolute inset-0 bg-black/80 backdrop-blur-sm"}),o.jsxs("div",{className:"relative bg-zinc-900 rounded-2xl border border-white/10 w-full max-w-lg max-h-[90vh] overflow-y-auto",onClick:X=>X.stopPropagation(),children:[o.jsxs("div",{className:"absolute top-4 right-4 flex items-center gap-2 z-10",children:[o.jsx("button",{onClick:()=>{const X=(n.title||"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""),Q=`${window.location.origin}/${X}`;navigator.clipboard.writeText(Q).then(()=>{x(!0),setTimeout(()=>x(!1),2e3)})},className:"p-2 rounded-full bg-black/60 text-white/70 hover:text-white hover:bg-black/80 transition-colors",title:"Copy event link",children:y?o.jsx(_a,{size:18,className:"text-[hsl(142,76%,45%)]"}):o.jsx(Jc,{size:18})}),o.jsx("button",{onClick:e,className:"p-2 rounded-full bg-black/60 text-white/70 hover:text-white hover:bg-black/80 transition-colors",children:o.jsx(Mr,{size:18})})]}),o.jsxs("div",{className:"p-6",children:[o.jsxs("div",{className:"mb-4 flex items-center gap-2 flex-wrap",children:[o.jsx("span",{className:`px-2.5 py-1 rounded-full text-xs font-medium ${n.isShowEvent?"bg-purple-500/20 text-purple-400":W==="meetup"?"bg-blue-500/20 text-blue-400":"bg-[hsl(142,76%,45%)]/20 text-[hsl(142,76%,45%)]"}`,children:n.isShowEvent?W==="live_stream"?"ðº Live Stream":"ðº New Episode":W.charAt(0).toUpperCase()+W.slice(1)}),n.isShowEvent&&n.showName&&n.showName!==n.title&&o.jsx("span",{className:"text-purple-400/60 text-xs",children:n.showName})]}),o.jsx("h2",{className:"text-2xl font-bold text-white mb-1",children:n.title}),n.episodeTitle&&o.jsx("p",{className:"text-purple-300 text-sm mb-4 font-medium",children:n.episodeTitle==="TBD"?"Topic to be determined":n.episodeTitle}),n.description&&o.jsx("p",{className:"text-white/60 text-sm mb-6 leading-relaxed",children:n.description.split(/(https?:\/\/[^\s]+)/g).map((X,Q)=>/^https?:\/\//.test(X)?o.jsx("a",{href:X,target:"_blank",rel:"noopener noreferrer",className:"text-green-400 underline break-all hover:text-green-300",children:X},Q):X)}),z?o.jsx("div",{className:"mb-6 flex justify-center",children:o.jsx("div",{className:"max-w-[50%] w-full rounded-lg border border-white/10 overflow-hidden",style:{aspectRatio:"3/4"},children:o.jsx("iframe",{src:z,className:"w-full h-full",allow:"autoplay; fullscreen; picture-in-picture",allowFullScreen:!0,title:"Event video"})})}):k?o.jsx("div",{className:"mb-6 flex justify-center",children:/\.(mp4|webm|mov)$/i.test(k)||k.includes("video")?o.jsx("video",{src:k,className:"max-w-[50%] h-auto rounded-lg border border-white/10 object-contain",controls:!0,autoPlay:!0,muted:!0,loop:!0,playsInl
267ine:!0}):o.jsx("img",{src:k,alt:n.title,className:"max-w-[50%] h-auto rounded-lg border border-white/10 object-contain"})}):null,P.length>0&&o.jsxs("div",{className:"mb-6",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[o.jsx(SF,{size:14,className:"text-[hsl(142,76%,45%)]"}),o.jsx("span",{className:"text-xs font-medium text-white/40 uppercase tracking-wider",children:"Event Photos"})]}),o.jsx("div",{className:"grid grid-cols-3 gap-2",children:P.map((X,Q)=>o.jsx("button",{onClick:()=>m(X),className:"aspect-square rounded-lg overflow-hidden border border-white/10 hover:border-[hsl(142,76%,45%)]/50 transition-colors",children:o.jsx("img",{src:X,alt:`Event photo ${Q+1}`,className:"w-full h-full object-cover"})},Q))})]}),p&&o.jsxs("div",{className:"fixed inset-0 z-[60] flex items-center justify-center p-4 bg-black/90",onClick:()=>m(null),children:[o.jsx("button",{onClick:()=>m(null),className:"absolute top-4 right-4 p-2 rounded-full bg-black/60 text-white/70 hover:text-white z-10",children:o.jsx(Mr,{size:20})}),o.jsx("img",{src:p,alt:"Full size",className:"max-w-full max-h-[85vh] object-contain rounded-lg",onClick:X=>X.stopPropagation()})]}),o.jsxs("div",{className:"space-y-3 mb-6",children:[o.jsxs("div",{className:"flex items-center gap-3 text-white/70",children:[o.jsx(Xc,{size:16,className:"text-[hsl(142,76%,45%)] flex-shrink-0"}),o.jsx("span",{className:"text-sm",children:c(R)})]}),o.jsxs("div",{className:"flex items-center gap-3 text-white/70",children:[o.jsx(uo,{size:16,className:"text-[hsl(142,76%,45%)] flex-shrink-0"}),o.jsxs("span",{className:"text-sm",children:[l(M),V?` - ${l(V)}`:""]})]}),n.location&&o.jsxs("div",{className:"flex items-center gap-3 text-white/70",children:[o.jsx(z7,{size:16,className:"text-[hsl(142,76%,45%)] flex-shrink-0"}),o.jsx("span",{className:"text-sm",children:n.location})]}),o.jsxs("div",{className:"flex items-center gap-3 text-white/70",children:[o.jsx(ff,{size:16,className:"text-[hsl(142,76%,45%)] flex-shrink-0"}),o.jsxs("span",{className:"text-sm",children:[n.rsvpCount||0," attending"]})]})]}),U&&o.jsxs("div",{className:"mb-4 p-3 rounded-lg bg-purple-500/10 border border-purple-500/20 flex items-center justify-between gap-3",children:[o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o.jsx(z2,{size:14,className:"text-purple-400 flex-shrink-0"}),o.jsx("span",{className:"text-sm text-purple-300 font-medium",children:"Vendor Registration"}),o.jsxs("span",{className:"text-xs text-purple-400/60 truncate hidden sm:block",children:[window.location.origin,"/vendor/",U]})]}),o.jsxs("button",{onClick:()=>{navigator.clipboard.writeText(`${window.location.origin}/vendor/${U}`),S(!0),setTimeout(()=>S(!1),2e3)},className:"flex items-center gap-1.5 px-2.5 py-1 rounded-lg bg-purple-500/20 hover:bg-purple-500/30 text-purple-300 text-xs font-medium transition-colors flex-shrink-0",children:[w?o.jsx(_a,{size:12}):o.jsx(TF,{size:12}),w?"Copied!":"Copy Link"]})]}),oe.length>0&&o.jsxs("div",{className:"mb-6",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[o.jsx(z2,{size:14,className:"text-[hsl(142,76%,45%)]"}),o.jsx("span",{className:"text-xs font-medium text-white/40 uppercase tracking-wider",children:"Vendors at this Event"})]}),o.jsx("div",{className:"flex flex-wrap gap-2",children:oe.map(X=>o.jsx("button",{onClick:()=>L(X),className:"px-3 py-1.5 rounded-full bg-zinc-800 border border-zinc-700 hover:border-[hsl(142,76%,45%)]/50 text-white/80 hover:text-white text-xs font-medium transition-colors",children:X.companyName},X.id))})]}),_&&(()=>{const X=(()=>{try{return JSON.parse(_.socialHandles||"{}")}catch{return{}}})(),Q=_.media?.find(Y=>Y.mediaType==="logo"),G=_.media?.filter(Y=>Y.mediaType==="image")||[];return o.jsx("div",{className:"fixed inset-0 z-[60] flex items-end sm:items-center justify-center p-4 bg-black/70",onClick:()=>L(null),children:o.jsxs("div",{className:"bg-zinc-900 rounded-2xl border border-white/10 w-full max-w-sm p-5",onClick:Y=>Y.stopPropagation(),children:[o.jsxs("div",{className:"flex items-start justify-between mb-4",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[Q?.url?o.jsx("img",{src:Q.url,alt:"logo",className:"w-12 h-12 rounded-xl object-cover border border-white/10"}):o.jsx("div",{className:"w-12 h-12 rounded-xl bg-zinc-800 flex items-center justify-center",children:o.jsx(z2,{size:20,className:"text-zinc-500"})}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-white font-bold",children:_.companyName}),_.ownerNames&&o.jsx("p",{className:"text-zinc-400 text-xs",children:_.ownerNames})]})]}),o.jsx("button",{onClick:()=>L(null),className:"p-1.5 rounded-full bg-zinc-800 text-zinc-400 hover:text-white",children:o.jsx(Mr,{size:16})})]}),_.bio&&o.jsx("p",{className:"text-zinc-300 text-sm mb-4 leading-relaxed",children:_.bio}),G.length>0&&o.jsx("div",{className:"grid grid-cols-3 gap-1.5 mb-4",children:G.slice(0,3).map((Y,ee)=>o.jsx("img",{src:Y.url,alt:"",className:"w-full aspect-square object-cover rounded-lg border border-white/10"},ee))}),o.jsxs("div",{className:"flex flex-wrap gap-2",children:[X.website&&o.jsxs("a",{href:X.website,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-zinc-800 hover:bg-zinc-700 text-zinc-300 text-xs transition-colors",children:[o.jsx(bF,{size:12})," Website"]}),X.instagram&&o.jsxs("a",{href:`https://instagram.com/${X.instagram.replace("@","")}`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-zinc-800 hover:bg-zinc-700 text-zinc-300 text-xs transition-colors",children:[o.jsx(EF,{size:12})," @",X.instagram.replace("@","")]}),_.phone&&o.jsxs("a",{href:`tel:${_.phone}`,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-zinc-800 hover:bg-zinc-700 text-zinc-300 text-xs transition-colors",children:[o.jsx(yh,{size:12})," ",_.phone]}
267)]})]})})})(),I&&o.jsxs("div",{className:`rounded-lg p-3 mb-6 ${t?"bg-[hsl(45,93%,47%)]/10 border border-[hsl(45,93%,47%)]/30":"bg-white/5 border border-white/10"}`,children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(ox,{size:14,className:t?"text-[hsl(45,93%,47%)]":"text-white/40"}),o.jsx("span",{className:`text-sm font-medium ${t?"text-[hsl(45,93%,47%)]":"text-white/40"}`,children:t?`Member Discount: ${I}`:"Premier members save on this event"})]}),!t&&o.jsx("button",{onClick:()=>d("/my-account"),className:"text-xs text-[hsl(142,76%,45%)] hover:underline mt-1 block bg-transparent border-none cursor-pointer p-0",children:"Join Premier to unlock"})]}),o.jsx("div",{className:"pt-4 border-t border-white/10",children:n.isShowEvent?o.jsxs("div",{className:"rounded-xl bg-purple-500/10 border border-purple-500/20 p-4 text-center",children:[o.jsx("p",{className:"text-purple-300 font-semibold mb-1",children:W==="live_stream"?"ðº Tune in Live":"ðº New Episode Drops"}),o.jsxs("p",{className:"text-white/50 text-sm",children:[c(R),M?` at ${l(M)}`:""]}),o.jsxs("div",{className:"mt-3 flex flex-col sm:flex-row gap-2 justify-center",children:[o.jsx("a",{href:"/chronic-tv",className:"inline-flex items-center justify-center gap-2 bg-purple-600 hover:bg-purple-500 text-white px-5 py-2 rounded-full font-bold text-sm transition-colors",children:"Watch on ChronicTV â"}),o.jsx("a",{href:`/guest-signup?show=${encodeURIComponent(n.showName||n.title||"")}`,className:"inline-flex items-center justify-center gap-2 bg-white/10 hover:bg-white/20 text-white px-5 py-2 rounded-full font-bold text-sm transition-colors border border-white/20",children:"ðï¸ Apply to Be a Guest"})]})]}):s?r?o.jsxs("button",{onClick:()=>i("remove"),disabled:a,className:"w-full flex items-center justify-center gap-2 bg-[hsl(142,76%,45%)]/20 border border-[hsl(142,76%,45%)]/30 text-[hsl(142,76%,45%)] px-6 py-3 rounded-full font-bold text-sm hover:bg-red-500/20 hover:border-red-500/30 hover:text-red-400 transition-colors",children:[a?o.jsx(Nn,{size:16,className:"animate-spin"}):o.jsx(HF,{size:16}),a?"Updating...":"You're Going - Click to Cancel"]}):o.jsxs("button",{onClick:()=>i("add"),disabled:a,className:"w-full flex items-center justify-center gap-2 bg-[hsl(142,76%,45%)] text-black px-6 py-3 rounded-full font-bold text-sm hover:bg-[hsl(142,76%,50%)] transition-colors",children:[a?o.jsx(Nn,{size:16,className:"animate-spin"}):o.jsx(lx,{size:16}),a?"Updating...":"RSVP - Count Me In"]}):o.jsxs("div",{className:"text-center",children:[o.jsx("p",{className:"text-white/40 text-sm mb-3",children:"Sign in to RSVP for this event"}),o.jsxs("button",{onClick:h,className:"inline-flex items-center gap-2 bg-[hsl(142,76%,45%)] text-black px-6 py-2.5 rounded-full font-bold text-sm hover:bg-[hsl(142,76%,50%)] transition-colors cursor-pointer",children:[o.jsx(Gh,{size:14}),"Sign In"]})]})})]})]})]})}const $ue=["Instagram","TikTok","YouTube","X (Twitter)","Facebook","LinkedIn","Snapchat","Other"];function r7(){return $V().length===0&&d4({apiKey:"AIzaSyCWTiwkXtJZk3ZIOeJ8EosaGVh9ONK0DNQ",authDomain:"chronictv-baffe.firebaseapp.com",projectId:"chronictv-baffe",storageBucket:"chronictv-baffe.firebasestorage.app",messagingSenderId:"1044709116948",appId:"1:1044709116948:web:505b5acbef6d437421ab01"}),yd()}function Hue(){const[n,e]=T.useState(void 0),[t,s]=T.useState(""),[r,i]=T.useState([]),[a,l]=T.useState(""),[c,d]=T.useState(""),[h,p]=T.useState(!1),[m,y]=T.useState(null),[x,w]=T.useState(!1),_=(new URLSearchParams(window.location.search).get("show")||"").replace(/-/g," ");T.useEffect(()=>{const P=r7();return Rd(P,F=>{e(F),F?.displayName&&s(F.displayName)})},[]);const{data:L}=gn({queryKey:["/api/startup-bundle"]}),R=[...L?.channelsCategories||[],...L?.originalsCategories||[]].filter(P=>!P.isSeasonFolder).sort((P,N)=>P.name.localeCompare(N.name));T.useEffect(()=>{if(!_||!R.length||a)return;const P=R.find(N=>N.name?.toLowerCase()===_.toLowerCase());P&&(l(String(P.id)),d(P.name))},[R.length,_]);const M=C7({mutationFn:async()=>{const N=await r7().currentUser?.getIdToken(),F=await fetch("/api/guest-applications",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${N}`},body:JSON.stringify({name:t,socials:r.filter(z=>z.handle.trim()),channelId:a,channelName:c})});if(!F.ok){const z=await F.json();throw new Error(z.error||"Submission failed")}return F.json()},onSuccess:()=>p(!0),onError:P=>y(P.message)}),V=()=>i(P=>[...P,{platform:"Instagram",handle:""}]),W=P=>i(N=>N.filter((F,z)=>z!==P)),I=(P,N,F)=>i(z=>z.map((U,fe)=>fe===P?{...U,[N]:F}:U)),k=()=>
267{if(y(null),!t.trim()){y("Please enter your name");return}if(!a){y("Please select a channel");return}M.mutate()};return n===void 0?o.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:o.jsx(Nn,{className:"h-8 w-8 animate-spin text-green-400"})}):o.jsxs("div",{className:"min-h-screen bg-black text-white",children:[o.jsx("div",{className:"border-b border-white/10 bg-black/80 backdrop-blur sticky top-0 z-10",children:o.jsxs("div",{className:"max-w-2xl mx-auto px-4 py-4 flex items-center gap-4",children:[o.jsx(Et,{href:"/",className:"text-white/50 hover:text-white transition-colors",children:o.jsx(Fr,{className:"h-5 w-5"})}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(V2,{className:"h-5 w-5 text-green-400"}),o.jsx("span",{className:"font-bold text-lg",children:"Guest Application"})]})]})}),o.jsxs("div",{className:"max-w-2xl mx-auto px-4 py-10",children:[c?(()=>{const P=R.find(z=>String(z.id)===a),N=P?.thumbnailUrl||null,F=(P?.summaryContent||P?.description||"").replace(/<[^>]+>/g,"").trim();return o.jsxs("div",{className:"text-center mb-10",children:[N?o.jsx("img",{src:N,alt:c,className:"w-28 h-28 rounded-2xl object-cover mx-auto mb-4 shadow-xl border border-white/10"}):o.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-green-400/10 border border-green-400/30 mb-4",children:o.jsx(V2,{className:"h-8 w-8 text-green-400"})}),o.jsx("h1",{className:"text-3xl font-bold mb-2",children:c}),o.jsx("p",{className:"text-green-400 font-medium mb-2",children:"Apply to be a Guest"}),F&&o.jsx("p",{className:"text-white/50 text-sm max-w-lg mx-auto leading-relaxed",children:F.length>240?F.slice(0,240)+"â¦":F})]})})():o.jsxs("div",{className:"text-center mb-10",children:[o.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-green-400/10 border border-green-400/30 mb-4",children:o.jsx(V2,{className:"h-8 w-8 text-green-400"})}),o.jsxs("h1",{className:"text-3xl font-bold mb-2",children:["Apply to Be a ",o.jsx("span",{className:"text-green-400",children:"Show Guest"})]}),o.jsx("p",{className:"text-white/60 text-lg",children:"Pick a show and submit your application. The creator will reach out if you're selected."})]}),h?o.jsxs("div",{className:"bg-green-500/10 border border-green-500/30 rounded-2xl p-10 text-center",children:[o.jsx(Vc,{className:"h-14 w-14 text-green-400 mx-auto mb-4"}),o.jsx("h2",{className:"text-2xl font-bold mb-2",children:"Application Submitted!"}),o.jsx("p",{className:"text-white/60 mb-6",children:"We've sent a confirmation to your email. The creator will review your application and reach out if you're selected."}),o.jsx(Et,{href:"/membership",className:"inline-block bg-green-400 text-black px-6 py-3 rounded-full font-bold hover:bg-green-300 transition-colors",children:"Back to Membership"})]}):n?o.jsxs("div",{className:"space-y-6",children:[m&&o.jsx("div",{className:"bg-red-500/10 border border-red-500/30 text-red-400 rounded-xl px-4 py-3 text-sm",children:m}),o.jsxs("div",{className:"bg-zinc-900 border border-white/10 rounded-2xl p-6",children:[o.jsx("label",{className:"block text-sm font-medium text-white/60 mb-2",children:"Your Name *"}),o.jsx("input",{type:"text",value:t,onChange:P=>s(P.target.value),placeholder:"Full name",className:"w-full bg-zinc-800 border border-white/10 rounded-xl px-4 py-3 text-white placeholder-white/30 focus:outline-none focus:border-green-400/50 transition-colors"})]}),o.jsxs("div",{className:"bg-zinc-900 border border-white/10 rounded-2xl p-6",children:[o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsxs("div",{children:[o.jsxs("h3",{className:"font-semibold",children:["Social Media ",o.jsx("span",{className:"text-white/40 font-normal text-sm",children:"(optional)"})]}),o.jsx("p",{className:"text-white/40 text-xs mt-0.5",children:"Add as many as you have"})]}),o.jsxs("button",{onClick:V,className:"flex items-center gap-1.5 px-3 py-1.5 bg-green-400/10 border border-green-400/30 text-green-400 rounded-lg text-sm font-medium hover:bg-green-400/20 transition-colors",children:[o.jsx(b0,{className:"h-4 w-4"})," Add Social"]})]}),r.length===0&&o.jsx("p",{className:"text-white/30 text-sm text-center py-4",children:'No socials added yet â click "Add Social" to include them'}),o.jsx("div",{className:"space-y-3",children:r.map((P,N)=>o.jsxs("div",{className:"flex gap-2 items-center",children:[o.jsxs("div",{className:"relative",children:[o.jsx("select",{value:P.platform,onChange:F=>I(N,"platform",F.target.value),className:"appearance-none bg-zinc-800 border border-white/10 rounded-lg pl-3 pr-8 py-2.5 text-white text-sm focus:outline-none focus:border-green-400/50",children:$ue.map(F=>o.jsx("option",{value:F,children:F},F))}),o.jsx(ao,{className:"absolute right-2 top-1/2 -translate-y-1/2 h-3 w-3 text-white/40 pointer-events-none"})]}),o.jsx("input",{type:"text",value:P.handle,onChange:F=>I(N,"handle",F.target.value),placeholder:"@handle or URL",className:"flex-1 bg-zinc-800 border border-white/10 rounded-lg px-3 py-2.5 text-white text-sm placeholder-white/30 focus:outline-none focus:border-green-400/50"}),o.jsx("button",{onClick:()=>W(N),className:"p-2 text-white/30 hover:text-red-400 transition-colors",children:o.jsx(Kp,{className:"h-4 w-4"})})]},N))})]}),o.jsxs("div",{className:"bg-zinc-900 border border-white/10 rounded-2xl p-6",children:[o.jsx("label",{className:"block text-sm font-medium text-white/60 mb-2",children:"Which channel do you want to guest on? *"}),o.jsxs("div",{className:"relative",children:[o.jsxs("select",{value:a,onChange:P=>{const N=R.find(F=>String(F.id)===P.target.value);l(P.target.value),d(N?.name||"")},className:"w-full appearance-none bg-zinc-800 border border-white/10 rounded-xl px-4 py-3 text-white focus:outline-none focus:border-green-400/50 transition-colors pr-10",children:[o.jsx("option",{value:"",children:"â Select a channel â"}),[...R].sort((P,N)=>P.name.localeCompare(N.name)).map(P=>o.jsx("option",{value:String(P.id),children:P.name},P.id))]}),o.jsx(ao,{className:"absolute right-3 top-1/2 -translate-y-1/2 h-4 w-4 text-white/40 pointer-events-none"})]})]}),o.jsxs("button",{onClick:k,disabled:M.isPending,className:"w-full flex items-center justify-center gap-2 bg-green-400 hover:bg-green-300 text-black font-bold py-4 rounded-2xl text-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[M.isPending?o.jsx(Nn,{className:"h-5 w-5 animate-spin"}):o.jsx(s4,{className:"h-5 w-5"}),M.isPending?"Submittingâ¦":"Submit Guest Application"]}),o.jsxs("p",{className:"text-center text-white/30 text-xs",children:["A confirmation email will be sent to ",n.email]})]}):o.jsxs("div",{className:"bg-zinc-900 border border-white/10 rounded-2xl p-10 text-center",children:[o.jsx(Gh,{className:"h-12 w-12 text-white/30 mx-auto mb-4"}),o.jsx("h2",{className:"text-xl font-bold mb-2",children:"Members Only"}),o.jsx("p",{className:"text-white/50 mb-6",children:"You need to be a Chronic Brands USA member to apply as a
267show guest."}),o.jsx("button",{onClick:()=>w(!0),className:"inline-block bg-green-400 text-black px-6 py-3 rounded-full font-bold hover:bg-green-300 transition-colors",children:"Sign In / Join"})]})]}),o.jsx(my,{isOpen:x,onClose:()=>w(!1),initialMode:"signup"})]})}vu();function Wue(){const[,n]=Xl(),[e,t]=T.useState(void 0),[s,r]=T.useState(void 0);if(T.useEffect(()=>{const a=Rd(It,l=>t(l));return()=>a()},[]),T.useEffect(()=>{fetch("/api/games/chronic-combat/profile").then(a=>a.ok?a.json():null).then(a=>r(a?.success?a.profile:null)).catch(()=>r(null))},[]),T.useEffect(()=>{const a=l=>{l.data?.type==="navigate"&&n(l.data.path)};return window.addEventListener("message",a),()=>window.removeEventListener("message",a)},[n]),e===void 0)return o.jsxs("div",{style:{width:"100%",height:"100vh",background:"#0a0a0a",display:"flex",alignItems:"center",justifyContent:"center"},children:[o.jsx("div",{style:{width:40,height:40,border:"3px solid #4ade80",borderTopColor:"transparent",borderRadius:"50%",animation:"spin 0.8s linear infinite"}}),o.jsx("style",{children:"@keyframes spin { to { transform: rotate(360deg); } }"})]});if(!e)return o.jsx("div",{style:{width:"100%",minHeight:"100vh",background:"linear-gradient(135deg, #0a0a0a 0%, #0f1a0f 50%, #0a0a0a 100%)",display:"flex",alignItems:"center",justifyContent:"center",fontFamily:"system-ui, -apple-system, sans-serif",padding:"20px"},children:o.jsxs("div",{style:{maxWidth:480,width:"100%",textAlign:"center"},children:[o.jsx("div",{style:{width:96,height:96,background:"linear-gradient(135deg, #4ade80, #22c55e)",borderRadius:24,display:"flex",alignItems:"center",justifyContent:"center",margin:"0 auto 28px",boxShadow:"0 0 40px rgba(74,222,128,0.4)"},children:o.jsx(vb,{size:48,color:"#000"})}),o.jsx("h1",{style:{color:"#4ade80",fontSize:32,fontWeight:900,letterSpacing:3,margin:"0 0 8px"},children:"CHRONIC COMBAT"}),o.jsxs("p",{style:{color:"#888",fontSize:15,margin:"0 0 36px",lineHeight:1.6},children:["Sign in to your Chronic Brands account to play.",o.jsx("br",{}),"Your match stats are tracked to your profile."]}),o.jsxs("div",{style:{background:"rgba(74,222,128,0.06)",border:"1px solid rgba(74,222,128,0.2)",borderRadius:16,padding:"24px",marginBottom:32},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:14},children:[o.jsx(hf,{size:20,color:"#4ade80"}),o.jsx("span",{style:{color:"#ccc",fontSize:14},children:"2-Player local fighting game"})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:14},children:[o.jsx(vb,{size:20,color:"#4ade80"}),o.jsx("span",{style:{color:"#ccc",fontSize:14},children:"Special moves, combos & projectiles"})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[o.jsx("svg",{width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"#4ade80",strokeWidth:2,children:o.jsx("path",{d:"M12 2L15.09 8.26L22 9.27L17 14.14L18.18 21.02L12 17.77L5.82 21.02L7 14.14L2 9.27L8.91 8.26L12 2Z"})}),o.jsx("span",{style:{color:"#ccc",fontSize:14},children:"Match stats saved to your account"})]})]}),o.jsxs("div",{style:{display:"flex",gap:12,flexDirection:"column"},children:[o.jsxs("button",{onClick:()=>n("/membership"),style:{display:"flex",alignItems:"center",justifyContent:"center",gap:10,width:"100%",padding:"14px 24px",background:"linear-gradient(135deg, #4ade80, #22c55e)",border:"none",borderRadius:10,color:"#000",fontWeight:800,fontSize:16,cursor:"pointer",letterSpacing:1},children:[o.jsx(B7,{size:20}),"SIGN IN TO PLAY"]}),o.jsxs("button",{onClick:()=>n("/membership"),style:{display:"flex",alignItems:"center",justifyContent:"center",gap:10,width:"100%",padding:"14px 24px",background:"transparent",border:"1px solid rgba(74,222,128,0.4)",borderRadius:10,color:"#4ade80",fontWeight:600,fontSize:15,cursor:"pointer"},children:[o.jsx(lx,{size:18}),"Create Free Account"]}),o.jsx("button",{onClick:()=>n("/chronic-games"),style:{background:"none",border:"none",color:"#555",fontSize:13,cursor:"pointer",marginTop:4},children:"â Back to Chronic Games"})]})]})});const i=s?`${s.buildPath}${s.entryFile}`:"/game/chronic-combat.html";return o.jsx("div",{style:{width:"100%",height:"100vh",background:"#0a0a0a"},children:o.jsx("iframe",{src:i,style:{width:"100%",height:"100%",border:"none"},title:"Chronic Combat","data-testid":"iframe-chronic-combat"})})}vu();function Gue(){const[,n]=Xl(),[e,t]=T.useState(void 0),[s,r]=T.useState(void 0);if(T.useEffect(()=>{const a=Rd(It,l=>t(l));return()=>a()},[]),T.useEffect(()=>{fetch("/api/games/chronic-nbl/profile").then(a=>a.ok?a.json():null).then(a=>r(a?.success?a.profile:null)).catch(()=>r(null))},[]),T.useEffect(()=>{const a=l=>{l.data?.type==="navigate"&&n(l.data.path)};return window.addEventListener("message",a),()=>window.removeEventListener("message",a)},[n]),e===void 0)return o.jsxs("div",{style:{width:"100%",height:"100vh",background:"#0a0a0a",display:"flex",alignItems:"center",justifyContent:"center"},children:[o.jsx("div",{style:{width:40,height:40,border:"3px solid #4ade80",borderTopColor:"transparent",borderRadius:"50%",animation:"spin 0.8s linear infinite"}}),o.jsx("style",{children:"@keyframes spin { to { transform: rotate(360deg); } }"})]});if(!e)return o.jsx("div",{style:{width:"100%",minHeight:"100vh",background:"linear-gradient(135deg, #0a0a0a 0%, #0a0f1
267a 50%, #0a0a0a 100%)",display:"flex",alignItems:"center",justifyContent:"center",fontFamily:"system-ui, -apple-system, sans-serif",padding:"20px"},children:o.jsxs("div",{style:{maxWidth:480,width:"100%",textAlign:"center"},children:[o.jsx("div",{style:{width:96,height:96,background:"linear-gradient(135deg, #4ade80, #22c55e)",borderRadius:24,display:"flex",alignItems:"center",justifyContent:"center",margin:"0 auto 28px",boxShadow:"0 0 40px rgba(74,222,128,0.4)"},children:o.jsxs("svg",{width:48,height:48,viewBox:"0 0 48 48",fill:"none",children:[o.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"#000",strokeWidth:"3",fill:"none"}),o.jsx("path",{d:"M24 4 C24 4 24 44 24 44",stroke:"#000",strokeWidth:"2.5"}),o.jsx("path",{d:"M4 24 C4 24 44 24 44 24",stroke:"#000",strokeWidth:"2.5"}),o.jsx("path",{d:"M8 11 C14 18 14 30 8 37",stroke:"#000",strokeWidth:"2.5",fill:"none"}),o.jsx("path",{d:"M40 11 C34 18 34 30 40 37",stroke:"#000",strokeWidth:"2.5",fill:"none"})]})}),o.jsx("h1",{style:{color:"#4ade80",fontSize:32,fontWeight:900,letterSpacing:3,margin:"0 0 8px"},children:"CHRONIC NBL"}),o.jsxs("p",{style:{color:"#888",fontSize:15,margin:"0 0 36px",lineHeight:1.6},children:["Sign in to your Chronic Brands account to play.",o.jsx("br",{}),"Your stats are tracked to your profile."]}),o.jsxs("div",{style:{background:"rgba(74,222,128,0.06)",border:"1px solid rgba(74,222,128,0.2)",borderRadius:16,padding:"24px",marginBottom:32},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:14},children:[o.jsx(hf,{size:20,color:"#4ade80"}),o.jsx("span",{style:{color:"#ccc",fontSize:14},children:"2-Player local basketball game"})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:14},children:[o.jsxs("svg",{width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"#4ade80",strokeWidth:2,children:[o.jsx("circle",{cx:"12",cy:"12",r:"9"}),o.jsx("path",{d:"M12 3v18M3 12h18"}),o.jsx("path",{d:"M5.5 6C8 9 8 15 5.5 18M18.5 6C16 9 16 15 18.5 18"})]}),o.jsx("span",{style:{color:"#ccc",fontSize:14},children:"NBA Jamâstyle arcade basketball"})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[o.jsx("svg",{width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"#4ade80",strokeWidth:2,children:o.jsx("path",{d:"M12 2L15.09 8.26L22 9.27L17 14.14L18.18 21.02L12 17.77L5.82 21.02L7 14.14L2 9.27L8.91 8.26L12 2Z"})}),o.jsx("span",{style:{color:"#ccc",fontSize:14},children:"Stats & highlights saved to your account"})]})]}),o.jsxs("div",{style:{display:"flex",gap:12,flexDirection:"column"},children:[o.jsxs("button",{onClick:()=>n("/membership"),style:{display:"flex",alignItems:"center",justifyContent:"center",gap:10,width:"100%",padding:"14px 24px",background:"linear-gradient(135deg, #4ade80, #22c55e)",border:"none",borderRadius:10,color:"#000",fontWeight:800,fontSize:16,cursor:"pointer",letterSpacing:1},children:[o.jsx(B7,{size:20}),"SIGN IN TO PLAY"]}),o.jsxs("button",{onClick:()=>n("/membership"),style:{display:"flex",alignItems:"center",justifyContent:"center",gap:10,width:"100%",padding:"14px 24px",background:"transparent",border:"1px solid rgba(74,222,128,0.4)",borderRadius:10,color:"#4ade80",fontWeight:600,fontSize:15,cursor:"pointer"},children:[o.jsx(lx,{size:18}),"Create Free Account"]}),o.jsx("button",{onClick:()=>n("/chronic-games"),style:{background:"none",border:"none",color:"#555",fontSize:13,cursor:"pointer",marginTop:4},children:"â Back to Chronic Games"})]})]})});const i=s?`${s.buildPath}${s.entryFile}`:"/game/chronic-nbl.html";return o.jsx("div",{style:{width:"100%",height:"100vh",background:"#0a0a0a"},children:o.jsx("iframe",{src:i,style:{width:"100%",height:"100%",border:"none"},title:"Chronic NBL","data-testid":"iframe-chronic-nbl"})})}function Kue(){const[n,e]=T.useState(!1),t=()=>{const s=document.getElementById("chronic-kart-iframe");s&&(document.fullscreenElement?document.exitFullscreen().then(()=>e(!1)).catch(()=>{}):s.requestFullscreen().then(()=>e(!0)).catch(()=>{}))};return o.jsxs("div",{style:{minHeight:"100vh",background:"#000",color:"white",fontFamily:"system-ui, -apple-system, sans-serif",display:"flex",flexDirection:"column"},children:[o.jsxs("header",{style:{padding:"15px 20px",borderBottom:"1px solid #222",display:"flex",alignItems:"center",justifyContent:"space-between",background:"rgba(0,0,0,0.9)"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"20px"},children:[o.jsx(Et,{href:"/chronic-games",children:o.jsxs("a",{style:{display:"flex",alignItems:"center",gap:"8px",color:"#4ade80",textDecoration:"none",fontSize:"14px"},"data-testid":"link-back-games",children:[o.jsx(Fr,{size:20}),"Back to Games"]})}),o.jsx("h1",{style:{fontSize:"20px",fontWeight:"bold",margin:0,color:"#4ade80"},children:"Chronic Kart"})]}),o.jsxs("button",{onClick:t,style:{background:"rgba(74, 222, 128, 0.2)",border:"1px solid #4ade80",borderRadius:"8px",padding:"8px 16px",color:"#4ade80",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px",fontSize:"14px"},"data-testid":"button-fullscreen",children:[n?o.jsx(kF,{size:18}):o.jsx(_F,{size:18}),n?"Exit Fullscreen":"Fullscreen"]})]}),o.jsx("main",{style:{flex:1,display:"flex",flexDirection:"column"},children:o.jsx("iframe",{id:"chronic-kart-iframe",src:"/game/chronic-kart/viewport.html",style:{flex:1,width:"100%",border:"none",background:"#000"},title:"Chronic Kart","data-testid":"game-iframe"})}),o.jsx("footer",{style:{padding:"15px 20px",borderTop:"1px solid #222",background:"rgba(0,0,0,0.9)"},children:o.jsxs("div",{style:{maxWidth:"1000px",margin:"0 auto"},children:[o.jsx("h3",{style:{color:"#4ade80",marginBottom:"10px",fontSize:"16px"},children:"Controls"}),o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:"15p
267x",fontSize:"14px",color:"#888"},children:[o.jsxs("div",{children:[o.jsx("strong",{style:{color:"#fff"},children:"Accelerate:"})," Up Arrow / W"]}),o.jsxs("div",{children:[o.jsx("strong",{style:{color:"#fff"},children:"Brake:"})," Down Arrow / S"]}),o.jsxs("div",{children:[o.jsx("strong",{style:{color:"#fff"},children:"Steer:"})," Left/Right Arrows or A/D"]}),o.jsxs("div",{children:[o.jsx("strong",{style:{color:"#fff"},children:"Use Item:"})," Space"]})]})]})})]})}function que({size:n=40}){return o.jsxs("svg",{width:n,height:n,viewBox:"0 0 48 48",fill:"none",children:[o.jsx("circle",{cx:"24",cy:"24",r:"20",fill:"none",stroke:"currentColor",strokeWidth:"3.5"}),o.jsx("path",{d:"M24 4v40M4 24h40",stroke:"currentColor",strokeWidth:"3"}),o.jsx("path",{d:"M9 11C15 18 15 30 9 37M39 11C33 18 33 30 39 37",stroke:"currentColor",strokeWidth:"3",fill:"none"})]})}const Yue=[{id:"chronic-combat",title:"Chronic Combat",description:"A 2-player local fighting game inspired by classic arcade fighters. Battle with special moves, combos, and projectiles!",icon:vb,route:"/chronic-combat",players:"2 Players (Local)",controls:"Keyboard / Gamepad",comingSoon:!1},{id:"chronic-nbl",title:"Chronic NBL",description:"NBA Jamâstyle arcade basketball. Pick your favorite Chronic Brands characters and ball out on the court!",icon:que,route:"/chronic-nbl",players:"2 Players (Local)",controls:"Keyboard / Gamepad",comingSoon:!0}];function Que(){return o.jsxs("div",{style:{minHeight:"100vh",background:"linear-gradient(180deg, #0a0a0a 0%, #111 100%)",color:"white",fontFamily:"system-ui, -apple-system, sans-serif"},children:[o.jsx("header",{style:{padding:"20px",borderBottom:"1px solid #222",display:"flex",alignItems:"center",gap:"20px"},children:o.jsx(Et,{href:"/",children:o.jsxs("a",{style:{display:"flex",alignItems:"center",gap:"8px",color:"#4ade80",textDecoration:"none",fontSize:"14px"},"data-testid":"link-back-home",children:[o.jsx(Fr,{size:20}),"Back to Chronic Brands"]})})}),o.jsxs("main",{style:{padding:"40px 20px",maxWidth:"1200px",margin:"0 auto"},children:[o.jsxs("div",{style:{textAlign:"center",marginBottom:"50px"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"15px",marginBottom:"15px"},children:[o.jsx(hf,{size:48,color:"#4ade80"}),o.jsxs("h1",{style:{fontSize:"clamp(28px, 5vw, 48px)",fontWeight:"bold",margin:0},children:[o.jsx("span",{style:{color:"#4ade80"},children:"Chronic"})," Games"]})]}),o.jsx("p",{style:{color:"#888",fontSize:"18px",maxWidth:"600px",margin:"0 auto"},children:"Play exclusive games from Chronic Brands. More games coming soon!"})]}),o.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(320px, 1fr))",gap:"30px"},children:Yue.map(n=>{const e=n.icon;return o.jsx(Et,{href:n.route,children:o.jsx("a",{style:{textDecoration:"none"},"data-testid":`game-card-${n.id}`,children:o.jsxs("div",{style:{background:"linear-gradient(135deg, #1a1a1a 0%, #222 100%)",borderRadius:"16px",padding:"30px",border:"1px solid #333",cursor:"pointer",transition:"all 0.3s ease",height:"100%"},onMouseEnter:t=>{t.currentTarget.style.borderColor="#4ade80",t.currentTarget.style.transform="translateY(-5px)",t.currentTarget.style.boxShadow="0 10px 40px rgba(74, 222, 128, 0.2)"},onMouseLeave:t=>{t.currentTarget.style.borderColor="#333",t.currentTarget.style.transform="translateY(0)",t.currentTarget.style.boxShadow="none"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",marginBottom:"20px"},children:[o.jsx("div",{style:{width:"80px",height:"80px",borderRadius:"16px",background:"linear-gradient(135deg, #4ade80 0%, #22c55e 100%)",display:"flex",alignItems:"center",justifyContent:"center",color:"#000",flexShrink:0},children:o.jsx(e,{size:40,color:"#000"})}),n.comingSoon&&o.jsx("span",{style:{background:"rgba(251,191,36,0.15)",color:"#fbbf24",border:"1px solid rgba(251,191,36,0.3)",padding:"4px 10px",borderRadius:"20px",fontSize:"11px",fontWeight:"700",letterSpacing:"0.5px"},children:"COMING SOON"})]}),o.jsx("h2",{style:{fontSize:"24px",fontWeight:"bold",color:"white",margin:"0 0 10px 0"},children:n.title}),o.jsx("p",{style:{color:"#888",fontSize:"14px",lineHeight:1.6,margin:"0 0 20px 0"},children:n.description}
267),o.jsxs("div",{style:{display:"flex",gap:"15px",flexWrap:"wrap"},children:[o.jsx("span",{style:{background:"rgba(74, 222, 128, 0.1)",color:"#4ade80",padding:"6px 12px",borderRadius:"20px",fontSize:"12px",fontWeight:"500"},children:n.players}),o.jsx("span",{style:{background:"rgba(255, 255, 255, 0.1)",color:"#ccc",padding:"6px 12px",borderRadius:"20px",fontSize:"12px",fontWeight:"500"},children:n.controls})]}),o.jsx("div",{style:{marginTop:"25px",padding:"12px 24px",background:n.comingSoon?"rgba(255,255,255,0.06)":"linear-gradient(135deg, #4ade80 0%, #22c55e 100%)",borderRadius:"8px",textAlign:"center",color:n.comingSoon?"#555":"#000",fontWeight:"bold",fontSize:"14px",border:n.comingSoon?"1px solid #333":"none"},children:n.comingSoon?"COMING SOON":"PLAY NOW"})]})})},n.id)})}),o.jsxs("div",{style:{marginTop:"60px",padding:"40px",background:"rgba(74, 222, 128, 0.05)",borderRadius:"16px",border:"1px solid rgba(74, 222, 128, 0.2)",textAlign:"center"},children:[o.jsx("h3",{style:{color:"#4ade80",marginBottom:"10px"},children:"More Games Coming Soon!"}),o.jsx("p",{style:{color:"#888",margin:0},children:"We're working on bringing you more exciting games. Stay tuned!"})]})]}),o.jsx("footer",{style:{padding:"30px 20px",borderTop:"1px solid #222",textAlign:"center",color:"#666",fontSize:"14px"},children:"© 2025 Chronic Games. A division of Chronic Brands USA."})]})}vu();function Xue(){const[n,e]=T.useState("login"),[t,s]=T.useState(null),[r,i]=T.useState(""),[a,l]=T.useState(!1),[c,d]=T.useState(""),[h,p]=T.useState(""),[m,y]=T.useState(null),[x,w]=T.useState(""),[S,_]=T.useState(""),[L,R]=T.useState(""),[M,V]=T.useState(""),[W,I]=T.useState(""),[k,P]=T.useState(!1),[N,F]=T.useState(!1),[z,U]=T.useState(!1);T.useEffect(()=>{ey().catch(ee=>{});const Y=Md(ee=>{s(ee),ee&&e("enter-code")});return()=>Y()},[]);const fe=async()=>{l(!0),d("");try{await IP()}catch(Y){d(Y.message||"Failed to sign in with Google"),l(!1)}},oe=async Y=>{Y.preventDefault(),l(!0),d("");try{if(N){if(!k){d("Please read and agree to all membership agreements"),l(!1);return}const ee=await kf(x,S,L,M,W);ee.error&&d(ee.error)}else{const ee=await Rf(x,S);ee.error&&d(ee.error)}}catch(ee){d(ee.message||"Authentication failed")}finally{l(!1)}},X=async Y=>{Y.preventDefault(),l(!0),d("");try{const ee=await Pf(x);ee.success?(d(""),U(!1),alert("Password reset email sent! Check your inbox.")):ee.error&&d(ee.error)}catch(ee){d(ee.message||"Failed to send reset email")}finally{l(!1)}},Q=async Y=>{if(Y.preventDefault(),!(!t||!r.trim())){l(!0),d("");try{const ee=await fetch("https://chronictvfinal.onrender.com/api/tv/activate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:r.trim().toUpperCase(),firebaseUid:t.uid,userDisplayName:t.displayName,userEmail:t.email})}),H=await ee.json();if(!ee.ok){d(H.error||"Failed to activate device");return}y({deviceName:H.deviceName,platform:H.platform}),p(`Your ${H.platform} device is now linked to your account!`),e("success")}catch(ee){d(ee.message||"Failed to activate device")}finally{l(!1)}}},G=Y=>Y.toUpperCase().replace(/[^A-Z0-9]/g,"").slice(0,6);return o.jsxs("div",{style:{minHeight:"100vh",background:"linear-gradient(180deg, #0a0a0a 0%, #111 100%)",color:"white",fontFamily:"system-ui, -apple-system, sans-serif",display:"flex",flexDirection:"column",alignItems:"center",padding:"40px 20px"},children:[o.jsxs(Et,{href:"/",style:{position:"absolute",top:"20px",left:"20px",display:"flex",alignItems:"center",gap:"8px",color:"#4ade80",textDecoration:"none",fontSize:"14px"},"data-testid":"link-back-home",children:[o.jsx(Fr,{size:20}),"Back to Home"]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginBottom:"10px",marginTop:"40px"},children:[o.jsx(oo,{size:48,color:"#4ade80"}),o.jsxs("h1",{style:{fontSize:"32px",fontWeight:"bold",margin:0},children:["Activate ",o.jsx("span",{style:{color:"#4ade80"},children:"ChronicTV"})]})]}),o.jsx("p",{style:{color:"#888",marginBottom:"40px",textAlign:"center",maxWidth:"400px"},children:"Link your TV device to your account to sync watch history and access your profile."}),o.jsxs("div",{style:{background:"rgba(30, 30, 30, 0.8)",borderRadius:"16px",padding:"40px",width:"100%",maxWidth:"420px",border:"1px solid #333"},children:[n==="login"&&o.jsxs(o.Fragment,{children:[o.jsx("h2",{style:{fontSize:"20px",marginBottom:"25px",textAlign:"center"},children:z?"Reset Password":N?"Create Account":"Sign In"}),c&&o.jsxs("div",{style:{background:"rgba(239, 68, 68, 0.1)",border:"1px solid #ef4444",borderRadius:"8px",padding:"12px",marginBottom:"20px",display:"flex",alignItems:"center",gap:"10px",color:"#ef4444",fontSize:"14px"},children:[o.jsx(Lh,{size:18}),c]}),z?o.jsxs("form",{onSubmit:X,children:[o.jsx("input",{type:"email",placeholder:"Email address",value:x,onChange:Y=>w(Y.target.value),required:!0,style:{width:"100%",padding:"14px 16px",background:"rgba(50, 50, 50, 0.8)",border:"1px solid #444",borderRadius:"8px",color:"white",fontSize:"16px",marginBottom:"15px",boxSizing:"border-box"},"data-testid":"input-email"}),o.jsx("button",{type:"submit",disabled:a,style:{width:"100%",padding:"14px",background:"linear-gradient(135deg, #4ade80 0%, #22c55e 100%)",border:"none",borderRadius:"8px",color:"#000",fontSize:"16px",fontWeight:"bold",cursor:a?"not-allowed":"pointer",opacity:a?.7:1,marginBottom:"15px"},"data-testid":"button-reset-password",children:a?"Sending...":"Send Reset Email"}),o.jsx("button",{type:"button",onClick:()=>U(!1),style:{background:"transparent",border:"none",color:"#4ade80",cursor:"pointer",fontSize:"14px",width:"100%"},children:"Back to Sign In"})]}):o.jsxs(o.Fragment,{children:[o.jsxs("form",{onSubmit:oe,children:[N&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{display:"flex",gap:"10px",marginBottom:"15px"},children:[o.jsx("input",{type:"text",placeholder:"First Name",value:L,onChange:Y=>R(Y.target.value),required:!0,style:{flex:1,padding:"14px 16px",background:"rgba(50, 50, 50, 0.8)",border:"1px solid #444",borderRadius:"8px",color:"white",fontSize:"16px",boxSizing:"border-box"},"data-testid":"input-first-name"}),o.jsx("input",{type:"text",placeholder:"Last Name",value:M,onChange:Y=>V(Y.target.value),required:!0,style:{flex:1,padding:"14px 16px",background:"rgba(50, 50, 50, 0.8)",border:"1px solid #444",borderRadius:"8px",color:"white",fontSize:"16px",boxSizing:"border-box"},"data-testid":"input-last-name"})]}),o.jsx("input",{type:"tel",placeholder:"Phone Number",value:W,onChange:Y=>I(Y.target.value),style:{width:"100%",padding:"14px 16px",background:"rgba(50, 50, 50, 0.8)",border:"1px solid #444",borderRadius:"8px",color:"white",fontSize:"16px",marginBottom:"15px",boxSizing:"border-box"},"data-testid":"input-phone-number"})]}),o.jsx("input",{type:"email",placeholder:"Email address",value:x,onChange:Y=>w(Y.target.value),required:!0,style:{width:"100%",padding:"14px 16px",background:"rgba(50, 50, 50, 0.8)",border:"1px solid #444",borderRadius:"8px",color:"white",fontSize:"16px",marginBottom:"15px",boxSizing:"border-box"},"data-testid":"input-email"}),o.jsx("input",{type:"password",placeholder:"Password",value:S,onChange:Y=>_(Y.target.value),required:!0,autoComplete:"current-password",style:{width:"100%",padding:"14px 16px",background:"rgba(50, 50, 50, 0.8)",border:"1px solid #444",borderRadius:"8px",color:"white",fontSize:"16px",marginBottom:N?"15px":"20px",boxSizing:"border-box"},"data-testid":"input-password"}),N&&o.jsx("div",{style:{marginBottom:"20px"},children:o.jsx(Vj,{onChange:P})}),o.jsx("button",{type:"submit",disabled:a||N&&!k,style:{width:"100%",padding:"14px",background:"linear-gradient(135deg, #4ade80 0%, #22c55e 100%)",border:"none",borderRadius:"8px",color:"#000",fontSize:"16px",fontWeight:"bold",cursor:a||N&&!k?"not-allowed":"pointer",opacity:a||N&&!k?.7:1},"data-testid":"button-sign-in",children:a?"Please wait...":N?"Sign Up":"Sign In"})]}),!N&&o.jsx("button",{type:"button",onClick:()=>U(!0),style:{background:"transparent",border:"none",color:"#888",cursor:"pointer",fontSize:"14px",width:"100%",marginTop:"15p
267x"},"data-testid":"button-forgot-password",children:"Forgot password?"}),o.jsxs("div",{style:{display:"flex",alignItems:"center",margin:"25px 0",gap:"15px"},children:[o.jsx("div",{style:{flex:1,height:"1px",background:"#444"}}),o.jsx("span",{style:{color:"#666",fontSize:"14px"},children:"or"}),o.jsx("div",{style:{flex:1,height:"1px",background:"#444"}})]}),o.jsxs("button",{onClick:fe,disabled:a,style:{width:"100%",padding:"14px",background:"white",border:"none",borderRadius:"8px",color:"#333",fontSize:"16px",fontWeight:"500",cursor:a?"not-allowed":"pointer",opacity:a?.7:1,display:"flex",alignItems:"center",justifyContent:"center",gap:"10px"},"data-testid":"button-google-sign-in",children:[o.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",children:[o.jsx("path",{fill:"#4285F4",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"}),o.jsx("path",{fill:"#34A853",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),o.jsx("path",{fill:"#FBBC05",d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"}),o.jsx("path",{fill:"#EA4335",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})]}),"Continue with Google"]}),o.jsxs("p",{style:{textAlign:"center",marginTop:"25px",color:"#888",fontSize:"14px"},children:[N?"Already have an account? ":"Don't have an account? ",o.jsx("button",{type:"button",onClick:()=>F(!N),style:{background:"transparent",border:"none",color:"#4ade80",cursor:"pointer",fontSize:"14px"},"data-testid":"button-toggle-auth-mode",children:N?"Sign in":"Sign up"})]})]})]}),n==="enter-code"&&t&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{textAlign:"center",marginBottom:"25px"},children:[o.jsx("p",{style:{color:"#4ade80",marginBottom:"5px"},children:"Signed in as"}),o.jsx("p",{style:{fontSize:"18px",fontWeight:"bold"},children:t.displayName||t.email})]}),o.jsx("h2",{style:{fontSize:"18px",marginBottom:"15px",textAlign:"center"},children:"Enter the code from your TV"}),o.jsx("p",{style:{color:"#888",fontSize:"14px",textAlign:"center",marginBottom:"25px"},children:"The 6-character code is displayed on your Roku, Google TV, Android TV, or Fire TV."}),c&&o.jsxs("div",{style:{background:"rgba(239, 68, 68, 0.1)",border:"1px solid #ef4444",borderRadius:"8px",padding:"12px",marginBottom:"20px",display:"flex",alignItems:"center",gap:"10px",color:"#ef4444",fontSize:"14px"},children:[o.jsx(Lh,{size:18}),c]}),o.jsxs("form",{onSubmit:Q,children:[o.jsx("input",{type:"text",placeholder:"ABC123",value:r,onChange:Y=>i(G(Y.target.value)),maxLength:6,style:{width:"100%",padding:"20px",background:"rgba(50, 50, 50, 0.8)",border:"1px solid #444",borderRadius:"8px",color:"white",fontSize:"32px",fontWeight:"bold",textAlign:"center",letterSpacing:"8px",marginBottom:"20px",boxSizing:"border-box",textTransform:"uppercase"},autoFocus:!0,"data-testid":"input-activation-code"}),o.jsx("button",{type:"submit",disabled:a||r.length!==6,style:{width:"100%",padding:"16px",background:r.length===6?"linear-gradient(135deg, #4ade80 0%, #22c55e 100%)":"rgba(100, 100, 100, 0.5)",border:"none",borderRadius:"8px",color:r.length===6?"#000":"#666",fontSize:"16px",fontWeight:"bold",cursor:a||r.length!==6?"not-allowed":"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"10px"},"data-testid":"button-activate",children:a?o.jsxs(o.Fragment,{children:[o.jsx(Nn,{size:20,className:"animate-spin"}),"Activating..."]}):"Activate Device"})]})]}),n==="success"&&o.jsxs("div",{style:{textAlign:"center"},children:[o.jsx(Vc,{size:64,color:"#4ade80",style:{marginBottom:"20px"}}),o.jsx("h2",{style:{fontSize:"24px",marginBottom:"15px",color:"#4ade80"},children:"Device Activated!"}),o.jsx("p",{style:{color:"#ccc",marginBottom:"25px"},children:h}),o.jsx("p",{style:{color:"#888",fontSize:"14px",marginBottom:"30px"},children:"Your watch history and profile are now synced. You can close this page and return to your TV."}),o.jsx(Et,{href:"/",style:{display:"inline-block",padding:"14px 30px",background:"linear-gradient(135deg, #4ade80 0%, #22c55e 100%)",borderRadius:"8px",color:"#000",textDecoration:"none",fontWeight:"bold"},"data-testid":"link-go-home",children:"Go to Homepage"})]})]}),o.jsxs("div",{style:{marginTop:"40px",padding:"30px",background:"rgba(74, 222, 128, 0.05)",borderRadius:"12px",border:"1px solid rgba(74, 222, 128, 0.2)",maxWidth:"500px",width:"100%"},children:[o.jsx("h3",{style:{color:"#4ade80",marginBottom:"15px",fontSize:"16px"},children:"Supported Devices"}),o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:"15p
267x",color:"#888",fontSize:"14px"},children:[o.jsx("div",{children:"â Roku TV & Streaming Sticks"}),o.jsx("div",{children:"â Google TV"}),o.jsx("div",{children:"â Android TV"}),o.jsx("div",{children:"â Amazon Fire TV"})]})]}),o.jsx("footer",{style:{marginTop:"60px",color:"#666",fontSize:"12px",textAlign:"center"},children:"© 2025 Chronic Brands USA. All rights reserved."})]})}const i7=[{category:"Account",question:"How do I create an account?",answer:'Click the "Sign In" button in the top right corner and select "Create Account". You can sign up with your email or use Google Sign-In for faster access.'},{category:"Account",question:"How do I reset my password?",answer:`On the sign-in screen, click "Forgot Password" and enter your email address. You'll receive a password reset link within a few minutes.`},{category:"Account",question:"Can I link my Google account?",answer:"Yes! If you created an account with email, you can link your Google account from your profile settings for easier sign-in."},{category:"Membership",question:"What membership tiers are available?",answer:"We offer Cultured (Free), Chronic (monthly), and Premier (annual) tiers. Each tier provides different levels of access to content and partner discounts."},{category:"Membership",question:"How do I upgrade my membership?",answer:"Visit the Membership Details page and select the tier you want. You'll need to add a payment method if you haven't already."},{category:"Membership",question:"How do I cancel my subscription?",answer:"You can manage your subscription from the Membership Status page in your account. Cancellation takes effect at the end of your current billing period."},{category:"TV Devices",question:"How do I connect my Roku or Smart TV?",answer:'On your TV, open the ChronicTV app and select "Sign In". A 6-character code will appear. Then visit chronicbrandsusa.com/activate-chronictv on your phone or computer, sign in, and enter the code.'},{category:"TV Devices",question:"Why isn't my activation code working?",answer:`Activation codes expire after 15 minutes. Make sure you're entering the code exactly as shown on your TV. If it expired, select "Get New Code" on your TV to generate a fresh code.`},{category:"TV Devices",question:"What devices are supported?",answer:"ChronicTV is available on Roku, Google TV, Android TV, and Amazon Fire TV. We're also working on apps for Apple TV and gaming consoles."},{category:"Playback",question:"Videos aren't playing. What should I do?",answer:"Try refreshing the page or clearing your browser cache. If the issue persists, check your internet connection. For TV apps, try restarting the app or your device."},{category:"Playback",question:"How do I access my watch history?",answer:"Your watch history syncs automatically when you're signed in. On TV devices, sign in using the activation code to access your history across all devices."},{category:"Billing",question:"What payment methods do you accept?",answer:"We accept all major credit and debit cards including Visa, Mastercard, American Express, and Discover."},{category:"Billing",question:"How do I update my payment method?",answer:'Go to the Membership Status page and select "Manage Payment Methods" to add, update, or remove your payment information.'}],Jue=["All","Account","Membership","TV Devices","Playback","Billing"];function Zue(){const[n,e]=T.useState("All"),[t,s]=T.useState(null),r=n==="All"?i7:i7.filter(a=>a.category===n),i=a=>{switch(a){case"TV Devices":return o.jsx(oo,{className:"w-4 h-4"});case"Account":return o.jsx(FF,{className:"w-4 h-4"});case"Playback":return o.jsx(PF,{className:"w-4 h-4"});case"Billing":return o.jsx(v0,{className:"w-4 h-4"});case"Membership":return o.jsx(gb,{className:"w-4 h-4"});default:return o.jsx(hF,{className:"w-4 h-4"})}};return o.jsx("div",{className:"min-h-screen bg-black text-white",children:o.jsxs("div",{className:"max-w-4xl mx-auto px-4 py-12 md:py-20",children:[o.jsxs("div",{className:"text-center mb-12",children:[o.jsx("h1",{className:"text-3xl md:text-4xl font-bold mb-4",children:o.jsx(Is,{suffix:" Support",size:"lg"})}),o.jsx("p",{className:"text-white/60 text-lg",children:"Find answers to common questions or get in touch with our team"})]}),o.jsxs("div",{className:"grid md:grid-cols-3 gap-6 mb-12",children:[o.jsxs("a",{href:"/contact",className:"bg-white/5 border border-white/10 rounded-xl p-6 hover:bg-white/10 hover:border-[hsl(142,76%,45%)]/50 transition-all group","data-testid":"support-contact-card",children:[o.jsx(xb,{className:"w-8 h-8 text-[hsl(142,76%,45%)] mb-4"}),o.jsx("h3",{className:"text-lg font-semibold mb-2 group-hover:text-[hsl(142,76%,45%)] transition-colors",children:"Contact Us"}),o.jsx("p",{className:"text-white/60 text-sm",children:"Send us a message and we'll get back to you"})]}),o.jsxs("a",{href:"/activate-chronictv",className:"bg-white/5 border border-white/10 rounded-xl p-6 hover:bg-white/10 hover:border-[hsl(142,76%,45%)]/50 transition-all group","data-testid":"support-activate-card",children:[o.jsx(oo,{className:"w-8 h-8 text-[hsl(142,76%,45%)] mb-4"}),o.jsx("h3",{className:"text-lg font-semibold mb-2 group-hover:text-[hsl(142,76%,45%)] transition-colors",children:"Activate TV"}),o.jsx("p",{className:"text-white/60 text-sm",children:"Link your Roku or Smart TV device"})]}),o.jsxs("a",{href:"/membership",className:"bg-white/5 border border-white/10 rounded-xl p-6 hover:bg-white/10 hover:border-[hsl(142,76%,45%)]/50 transition-all group","data-testid":"support-membership-card",children:[o.jsx(gb,{className:"w-8 h-8 text-[hsl(142,76%,45%)] mb-4"}),o.jsx("h3",{className:"text-lg font-semibold mb-2 group-hover:text-[hsl(142,76%,45%)] transition-colors",children:"Membership"}),o.jsx("p",{className:"text-white/60 text-sm",children:"Manage your subscription and billing"})]})]}),o.jsxs("div",{className:"mb-8",children:[o.jsxs("h2",{className:"text-2xl font-bold mb-6 flex items-center gap-2",children:[o.jsx(IF,{className:"w-6 h-6 text-[hsl(142,76%,45%)]"}),"Frequently Asked Questions"]}),o.jsx("div",{className:"flex flex-wrap gap-2 mb-6",children:Jue.map(a=>o.jsxs("button",{onClick:()=>e(a),className:`px-4 py-2 rounded-full text-sm font-medium transition-all flex items-center gap-2 ${n===a?"bg-[hsl(142,76%,45%)] text-black":"bg-white/10 text-white/80 hover:bg-white/20"}`,"data-testid":`faq-category-${a.toLowerCase().replace(" ","-")}`,children:[i(a),a]},a))}),o.jsx("div",{className:"space-y-3",children:r.map((a,l)=>o.jsxs("div",{className:"bg-white/5 border border-white/10 rounded-xl overflow-hidden",children:[o.jsxs("button",{onClick:()=>s(t===l?null:l),className:"w-full px-6 py-4 text-left flex items-center justify-between hover:bg-white/5 transition-colors","data-testid":`faq-question-${l}`,children:[o.jsx("span",{className:"font-medium pr-4",children:a.question}),t===l?o.jsx(ix,{className:"w-5 h-5 text-[hsl(142,76%,45%)] flex-shrink-0"}):o.jsx(ao,{className:"w-5 h-5 text-white/40 flex-shrink-0"})]}),t===l&&o.jsx("div",{className:"px-6 pb-4 text-white/70",children:a.answer})]},l))})]}),o.jsxs("div",{className:"bg-gradient-to-r from-[hsl(142,76%,45%)]/20 to-transparent border border-[hsl(142,76%,45%)]/30 rounded-xl p-6 md:p-8",children:[o.jsx("h3",{className:"text-xl font-bold mb-3",children:"Still need help?"}),o.jsx("p",{className:"text-white/70 mb-4",children:"Our support team is here to assist you. Reach out and we'll get back to you as soon as possible."}),o.jsxs("a",{href:"/contact",className:"inline-flex items-center gap-2 bg-[hsl(142,76%,45%)] text-black px-6 py-3 rounded-lg font-semibold hover:bg-[hsl(142,76%,55%)] transition-colors","data-testid":"support-contact-button",children:[o.jsx(xb,{className:"w-5 h-5"}),"Contact Support"]})]})]})})}function ede({title:n,text:e}){return o.jsxs("div",{className:"mt-10 pt-10 border-t border-white/10",children:[o.jsx("h2",{className:"text-2xl font-bold text-green-400 mb-6",children:n}),o.jsx("div",{className:"text-gray-300 whitespace-pre-wrap leading-relaxed text-sm",children:e})]})}function a7(){const{data:n,isLoading:e,error:t}=gn({queryKey:["/api/startup-bundle"],staleTime:0,refetchOnMount:!0});if(e)return o.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:o.jsx("div",{className:"animate-spin w-8 h-8 border-4 border-green-500 border-t-transparent roun
267ded-full"})});if(t)return o.jsx("div",{className:"min-h-screen bg-black text-white flex items-center justify-center",children:o.jsxs("div",{className:"text-center",children:[o.jsx("h1",{className:"text-xl text-red-400",children:"Error loading content"}),o.jsx("p",{className:"text-gray-400",children:String(t)})]})});const i=n?.footerLinksData?.data?.legal?.privacy,a=typeof i=="string"?i:i?.text||"Privacy Policy information is not available.",l=typeof a=="string"&&a.includes("<");return o.jsx("div",{className:"min-h-screen bg-black text-white",children:o.jsxs("div",{className:"max-w-4xl mx-auto px-4 py-8",children:[o.jsxs(Et,{href:"/",className:"inline-flex items-center gap-2 text-green-400 hover:text-green-300 mb-8",children:[o.jsx(Fr,{className:"w-5 h-5"}),"Back to Home"]}),o.jsx("h1",{className:"text-3xl font-bold text-green-400 mb-8",children:"Privacy Policy"}),o.jsx("div",{className:"prose prose-invert max-w-none",children:l?o.jsx("div",{className:"text-gray-300 leading-relaxed [&_h1]:text-2xl [&_h1]:font-bold [&_h1]:text-white [&_h1]:mt-6 [&_h1]:mb-4 [&_h2]:text-xl [&_h2]:font-semibold [&_h2]:text-white [&_h2]:mt-5 [&_h2]:mb-3 [&_p]:mb-4 [&_ul]:list-disc [&_ul]:pl-6 [&_li]:mb-2",dangerouslySetInnerHTML:{__html:a}}):o.jsx("div",{className:"text-gray-300 whitespace-pre-wrap leading-relaxed",children:a})}),o.jsx(ede,{title:"Private Membership Agreement",text:Uj})]})})}function tde(n){const e=n.split(` 268`).map(i=>i.trim()).filter(Boolean),t=[];let s=0,r=0;for(;r<e.length;){const i=e[r];if(i==="ChronicTV Terms and Conditions"){r++;continue}if(i.startsWith("Last Updated:")){t.push(o.jsx("p",{className:"text-sm text-zinc-500 mb-8 mt-1",children:i},s++)),r++;continue}if(/^\d+\.\s+[A-Z]/.test(i)&&!/^\d+\.\d+/.test(i)){t.push(o.jsx("div",{className:"mt-10 mb-3 pb-2 border-b border-zinc-800",children:o.jsx("h2",{className:"text-xl font-bold text-white",children:i})},s++)),r++;continue}if(/^\d+\.\d+\s+/.test(i)){t.push(o.jsx("h3",{className:"text-base font-semibold text-green-400 mt-6 mb-3",children:i},s++)),r++;continue}if(i.startsWith("*")){const a=[];for(;r<e.length&&e[r].startsWith("*");)a.push(e[r].replace(/^\*\s*/,"")),r++;t.push(o.jsx("ul",{className:"space-y-2 mb-5 pl-1",children:a.map((l,c)=>o.jsxs("li",{className:"flex gap-2 text-zinc-300 leading-relaxed text-sm",children:[o.jsx("span",{className:"text-green-500 mt-0.5 shrink-0",children:"âº"}),o.jsx("span",{children:l})]},c))},s++));continue}t.push(o.jsx("p",{className:"text-zinc-300 leading-relaxed mb-4 text-sm",children:i},s++)),r++}return t}function lb(){const{data:n,isLoading:e,error:t}=gn({queryKey:["/api/legal/terms"],staleTime:3e5}),s=n?.content||"",r=s.includes("<");return o.jsx("div",{className:"min-h-screen bg-black text-white",children:o.jsxs("div",{className:"max-w-3xl mx-auto px-4 py-10",children:[o.jsxs(Et,{href:"/",className:"inline-flex items-center gap-2 text-green-400 hover:text-green-300 mb-8",children:[o.jsx(Fr,{className:"w-5 h-5"}),"Back to Home"]}),o.jsx("h1",{className:"text-3xl font-bold text-green-400 mb-2",children:"Terms and Conditions"}),o.jsx("div",{className:"mt-6",children:e?o.jsx("div",{className:"space-y-3",children:[...Array(6)].map((i,a)=>o.jsx("div",{className:`h-4 bg-zinc-800 rounded animate-pulse ${a%3===0?"w-1/3":"w-full"}`},a))}):t?o.jsx("p",{className:"text-red-400 text-sm",children:"Unable to load terms content."}):s?r?o.jsx("div",{className:"text-zinc-300 leading-relaxed [&_h1]:text-2xl [&_h1]:font-bold [&_h1]:text-white [&_h1]:mt-10 [&_h1]:mb-4 [&_h2]:text-xl [&_h2]:font-bold [&_h2]:text-white [&_h2]:mt-10 [&_h2]:mb-3 [&_h2]:border-b [&_h2]:border-zinc-800 [&_h2]:pb-2 [&_h3]:text-base [&_h3]:font-semibold [&_h3]:text-green-400 [&_h3]:mt-6 [&_h3]:mb-2 [&_p]:mb-4 [&_p]:text-sm [&_ul]:space-y-2 [&_ul]:mb-4 [&_li]:text-sm [&_li]:text-zinc-300",dangerouslySetInnerHTML:{__html:s}}):o.jsx("div",{children:tde(s)}):o.jsx("p",{className:"text-zinc-500 text-sm",children:"Terms and Conditions information is not available."})})]})})}function o7({title:n,text:e}){return o.jsxs("div",{className:"mt-10 pt-10 border-t border-white/10",children:[o.jsx("h2",{className:"text-2xl font-bold text-green-400 mb-6",children:n}),o.jsx("div",{className:"text-gray-300 whitespace-pre-wrap leading-relaxed text-sm",children:e})]})}function l7(){const{data:n,isLoading:e,error:t}=gn({queryKey:["/api/startup-bundle"],staleTime:0,refetchOnMount:!0});if(e)return o.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:o.jsx("div",{className:"animate-spin w-8 h-8 border-4 border-green-500 border-t-transparent roun
268ded-full"})});if(t)return o.jsx("div",{className:"min-h-screen bg-black text-white flex items-center justify-center",children:o.jsxs("div",{className:"text-center",children:[o.jsx("h1",{className:"text-xl text-red-400",children:"Error loading content"}),o.jsx("p",{className:"text-gray-400",children:String(t)})]})});const r=n?.footerLinksData?.data?.legal,i=r?.userSafety||r?.user_safety,a=typeof i=="string"?i:i?.text||"User Safety information is not available.",l=typeof a=="string"&&a.includes("<");return o.jsx("div",{className:"min-h-screen bg-black text-white",children:o.jsxs("div",{className:"max-w-4xl mx-auto px-4 py-8",children:[o.jsxs(Et,{href:"/",className:"inline-flex items-center gap-2 text-green-400 hover:text-green-300 mb-8",children:[o.jsx(Fr,{className:"w-5 h-5"}),"Back to Home"]}),o.jsx("h1",{className:"text-3xl font-bold text-green-400 mb-8",children:"User Safety"}),o.jsx("div",{className:"prose prose-invert max-w-none",children:l?o.jsx("div",{className:"text-gray-300 leading-relaxed [&_h1]:text-2xl [&_h1]:font-bold [&_h1]:text-white [&_h1]:mt-6 [&_h1]:mb-4 [&_h2]:text-xl [&_h2]:font-semibold [&_h2]:text-white [&_h2]:mt-5 [&_h2]:mb-3 [&_p]:mb-4 [&_ul]:list-disc [&_ul]:pl-6 [&_li]:mb-2",dangerouslySetInnerHTML:{__html:a}}):o.jsx("div",{className:"text-gray-300 whitespace-pre-wrap leading-relaxed",children:a})}),o.jsx(o7,{title:"Liability Waiver & Release of Claims",text:Mj}),o.jsx(o7,{title:"Member Code of Conduct",text:Fj})]})})}function c7(){const[n,e]=T.useState(""),[t,s]=T.useState(""),[r,i]=T.useState(!1),[a,l]=T.useState(!1),c=async d=>{d.preventDefault(),t==="DELETE"&&(i(!0),setTimeout(()=>{l(!0),i(!1)},1500))};return a?o.jsx("div",{className:"min-h-screen bg-black text-white flex items-center justify-center",children:o.jsxs("div",{className:"max-w-md mx-auto px-4 text-center",children:[o.jsx("div",{className:"w-16 h-16 bg-green-500/20 rounded-full flex items-center justify-center mx-auto mb-6",children:o.jsx(Kp,{className:"w-8 h-8 text-green-400"})}),o.jsx("h1",{className:"text-2xl font-bold text-white mb-4",children:"Request Submitted"}),o.jsx("p",{className:"text-gray-300 mb-8",children:"Your account deletion request has been received. You will receive a confirmation email within 24-48 hours. Your account and all associated data will be permanently deleted within 30 days."}),o.jsxs(Et,{href:"/",className:"inline-flex items-center gap-2 text-green-400 hover:text-green-300",children:[o.jsx(Fr,{className:"w-5 h-5"}),"Return to Home"]})]})}):o.jsx("div",{className:"min-h-screen bg-black text-white",children:o.jsxs("div",{className:"max-w-2xl mx-auto px-4 py-8",children:[o.jsxs(Et,{href:"/",className:"inline-flex items-center gap-2 text-green-400 hover:text-green-300 mb-8",children:[o.jsx(Fr,{className:"w-5 h-5"}),"Back to Home"]}),o.jsx("h1",{className:"text-3xl font-bold text-red-400 mb-8",children:"Delete ChronicTV Account"}),o.jsx("div",{className:"bg-red-500/10 border border-red-500/30 rounded-lg p-6 mb-8",children:o.jsxs("div",{className:"flex items-start gap-4",children:[o.jsx(zF,{className:"w-6 h-6 text-red-400 flex-shrink-0 mt-1"}),o.jsxs("div",{children:[o.jsx("h2",{className:"text-lg font-semibold text-red-400 mb-2",children:"Warning: This action is permanent"}),o.jsx("p",{className:"text-gray-300",children:"Deleting your ChronicTV account will permanently remove all your data, including:"}),o.jsxs("ul",{className:"text-gray-300 mt-3 space-y-1 list-disc list-inside",children:[o.jsx("li",{children:"Your profile and account information"}),o.jsx("li",{children:"Watch history and preferences"}),o.jsx("li",{children:"Saved content and playlists"}),o.jsx("li",{children:"Subscription and payment history"}),o.jsx("li",{children:"All linked devices"})]})]})]})}),o.jsxs("form",{onSubmit:c,className:"space-y-6",children:[o.jsxs("div",{children:[o.jsx("label",{htmlFor:"email",className:"block text-sm font-medium text-gray-300 mb-2",children:"Enter your email address"}),o.jsx("input",{type:"email",id:"email",value:n,onChange:d=>e(d.target.value),placeholder:"[email protected]",required:!0,className:"w-full px-4 py-3 bg-zinc-900 border border-zinc-700 rounded-lg text-white placeholder-gray-500 focus:outline-none focus:border-red-500"})]}),o.jsxs("div",{children:[o.jsx("label",{htmlFor:"confirm",className:"block text-sm font-medium text-gray-300 mb-2",children:"Type DELETE to confirm"}),o.jsx("input",{type:"text",id:"confirm",value:t,onChange:d=>s(d.target.value),placeholder:"DELETE",required:!0,className:"w-full px-4 py-3 bg-zinc-900 border border-zinc-700 rounded-lg text-white placeholder-gray-500 focus:outline-none focus:border-red-500"})]}),o.jsx("button",{type:"submit",disabled:t!=="DELETE"||!n||r,className:"w-full py-3 px-6 bg-red-600 hover:bg-red-700 disabled:bg-zinc-700 disabled:cursor-not-allowed text-white font-semibold rounded-lg transition-colors flex items-center justify-center gap-2",children:r?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"w-5 h-5 border-2 border-white border-t-transparent roun
268ded-full animate-spin"}),"Processing..."]}):o.jsxs(o.Fragment,{children:[o.jsx(Kp,{className:"w-5 h-5"}),"Delete My ChronicTV Account"]})})]}),o.jsx("p",{className:"text-gray-500 text-sm mt-8",children:"If you have any questions or need assistance, please contact us at [email protected] before proceeding with account deletion."})]})})}const u7={active:{bg:"bg-green-500/20",text:"text-green-400",icon:o.jsx(F7,{className:"h-4 w-4"})},suspended:{bg:"bg-yellow-500/20",text:"text-yellow-400",icon:o.jsx(uo,{className:"h-4 w-4"})},cancelled:{bg:"bg-red-500/20",text:"text-red-400",icon:o.jsx(ax,{className:"h-4 w-4"})},pending:{bg:"bg-zinc-500/20",text:"text-zinc-400",icon:o.jsx(uo,{className:"h-4 w-4"})}};function cb(n){return n?new Date(n).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}):"â"}function nde({used:n,quota:e}){const t=e>0?Math.min(100,n/e*100):0,s=t>90?"bg-red-500":t>70?"bg-yellow-500":"bg-green-500";return o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs("div",{className:"flex justify-between text-sm",children:[o.jsxs("span",{className:"text-zinc-400",children:[n.toFixed(1)," GB used"]}),o.jsxs("span",{className:"text-zinc-400",children:[e," GB total"]})]}),o.jsx("div",{className:"h-2.5 bg-zinc-700 rounded-full overflow-hidden",children:o.jsx("div",{className:`h-full ${s} rounded-full transition-all`,style:{width:`${t}%`}})}),o.jsxs("p",{className:"text-xs text-zinc-500",children:[(e-n).toFixed(1)," GB available"]})]})}function sde(){const[n,e]=T.useState(null),[t,s]=T.useState(!0),[r,i]=T.useState(null),[a,l]=T.useState(null),[c,d]=T.useState(!1),[h,p]=T.useState(null),[m,y]=T.useState(!1);T.useEffect(()=>{async function M(){try{const W=yd().currentUser;if(!W){i("Please sign in to view your creator channel."),s(!1);return}const I=await W.getIdToken(),k=await fetch(lo("/api/creator-channel"),{headers:{Authorization:`Bearer ${I}`}}),P=await k.json();if(!k.ok)throw new Error(P.error||"Failed to load channel");e(P.channel),d(!0);try{const N=await fetch(lo("/api/creator/streamlabs-config"),{headers:{Authorization:`Bearer ${I}`}}),F=await N.json();N.ok&&F.success?l(F):N.status!==404&&p(F.error||"Could not load Streamlabs config")}catch(N){p(N.message)}finally{d(!1)}}catch(V){i(V.message)}finally{s(!1)}}M()},[]);async function x(){y(!0);try{const V=yd().currentUser;if(!V)return;const W=await V.getIdToken();await fetch(lo("/api/creator/streamlabs-config/end-stream"),{method:"POST",headers:{Authorization:`Bearer ${W}`}}),l(I=>I&&{...I,isLive:!1,liveTitle:null,liveStartedAt:null})}catch{}y(!1)}function w(M){M&&navigator.clipboard.writeText(M).catch(()=>{})}if(t)return o.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:o.jsxs("div",{className:"text-center space-y-3",children:[o.jsx("div",{className:"h-10 w-10 border-2 border-green-400 border-t-transparent rounded-full animate-spin mx-auto"}),o.jsx("p",{className:"text-zinc-400 text-sm",children:"Loading your channelâ¦"})]})});if(r)return o.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center p-6",children:o.jsxs("div",{className:"text-center space-y-4 max-w-sm",children:[o.jsx(ax,{className:"h-12 w-12 text-red-500 mx-auto"}),o.jsx("h2",{className:"text-white text-xl font-semibold",children:"Unable to load channel"}),o.jsx("p",{className:"text-zinc-400 text-sm",children:r}),o.jsx("a",{href:"/shop",className:"inline-block mt-2 px-5 py-2.5 bg-green-500 hover:bg-green-400 text-black font-semibold rounded-lg transition-colors text-sm",children:"Browse Plans"})]})});if(!n)return o.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center p-6",children:o.jsxs("div",{className:"text-center space-y-5 max-w-md",children:[o.jsx(NT,{className:"h-16 w-16 text-zinc-600 mx-auto"}),o.jsx("h2",{className:"text-white text-2xl font-bold",children:"No Channel Found"}),o.jsx("p",{className:"text-zinc-400",children:"You don't have an active Chronic TV Network channel yet. Purchase a Basic or Premier Bundle to get started."}),o.jsx("a",{href:"/shop",className:"inline-block px-6 py-3 bg-green-500 hover:bg-green-400 text-black font-bold rounded-xl transition-colors",children:"Get Started â"})]})});const S=u7[n.status]||u7.pending,_=parseFloat(n.storageUsedGb||"0"),L=Array.isArray(n.addons)?n.addons:[],R=parseFloat(n.monthlyPrice)+L.reduce((M,V)=>M+V.monthlyPrice,0);return o.jsx("div",{className:"min-h-screen bg-black text-white",children:o.jsxs("div",{className:"max-w-3xl mx-auto px-4 py-8 space-y-6",children:[o.jsxs("a",{href:"/",className:"inline-flex items-center gap-2 text-green-400 hover:text-green-300 text-sm transition-colors",children:[o.jsx(md,{className:"h-4 w-4"})," Back to Home"]}),o.jsxs("div",{className:"flex items-start justify-between gap-4",children:[o.jsxs("div",{children:[o.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[o.jsx(NT,{className:"h-7 w-7 text-green-400"}),"My Creator Channel"]}),o.jsx("p",{className:"text-zinc-400 text-sm mt-1",children:n.email})]}),o.jsxs("span",{className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full text-sm font-medium ${S.bg} ${S.text}`,children:[S.icon,n.status.charAt(0).toUpperCase()+n.status.slice(1)]})]}),o.jsxs("div",{className:"bg-zinc-900 border border-zinc-800 rounded-2xl p-6 space-y-6",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-xs font-medium uppercase tracking-wider text-zinc-500 mb-1",children:"Current Plan"}),o.jsxs("h2",{className:"text-xl font-bold capitalize text-green-400",children:[n.planType," Bundle"]})]}),o.jsxs("div",{className:"text-right",children:[o.jsx("p",{className:"text-xs text-zinc-500 uppercase tracking-wider mb-1",children:"Monthly Total"}),o.jsxs("p",{className:"text-2xl font-bold text-white",children:["$",R.toFixed(0),o.jsx("span",{className:"text-sm font-normal text-zinc-400",children:"/mo"})]})]})]}),o.jsxs("div",{className:"bg-zinc-800/60 rounded-xl p-4 space-y-3",children:[o.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-zinc-300",children:[o.jsx(V7,{className:"h-4 w-4 text-green-400"}),"Storage"]}),o.jsx(nde,{used:_,quota:n.storageQuotaGb})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"bg-zinc-800/60 rounded-xl p-4",children:[o.jsxs("div",{className:"flex items-center gap-2 text-xs text-zinc-500 uppercase tracking-wider mb-1.5",children:[o.jsx(Xc,{className:"h-3.5 w-3.5"})," Billing Started"]}),o.jsx("p",{className:"text-white text-sm font-medium",children:cb(n.billingStartDate)})]}),o.jsxs("div",{className:"bg-zinc-800/60 rounded-xl p-4",children:[o.jsxs("div",{className:"flex items-center gap-2 text-xs text-zinc-500 uppercase tracking-wider mb-1.5",children:[o.jsx(Xc,{className:"h-3.5 w-3.5"})," Next Renewal"]}),o.jsx("p",{className:"text-green-400 text-sm font-medium",children:cb(n.nextBillingDate)})]})]})]}),o.jsxs("div",{className:"bg-zinc-900 border border-zinc-800 rounded-2xl p-6",children:[o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsxs("h3",{className:"font-semibold flex items-center gap-2",children:[o.jsx(pF,{className:"h-5 w-5 text-green-400"}),"Active Add-Ons"]}),o.jsx("a",{href:"/shop",className:"text-xs text-green-400 hover:text-green-300 font-medium transition-colors",children:"+ Add More"})]}),L.length===0?o.jsxs("div",{className:"text-center py-6 text-zinc-500 text-sm",children:["No add-ons yet."," ",o.jsx("a",{href:"/shop",className:"text-green-400 hover:underline",children:"Browse the shop"})," to add storage or content engineer support."]}
268):o.jsx("div",{className:"space-y-3",children:L.map((M,V)=>o.jsxs("div",{className:"flex items-center justify-between bg-zinc-800/60 rounded-xl px-4 py-3",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[M.name.includes("Engineer")?o.jsx(U7,{className:"h-4 w-4 text-green-400"}):o.jsx(q7,{className:"h-4 w-4 text-green-400"}),o.jsxs("div",{children:[o.jsx("p",{className:"text-sm font-medium text-white",children:M.name}),o.jsxs("p",{className:"text-xs text-zinc-500",children:["Added ",cb(M.addedAt)]})]})]}),o.jsxs("span",{className:"text-sm font-semibold text-green-400",children:["$",M.monthlyPrice,M.name.includes("Engineer")?"/per edit":"/mo"]})]},V))})]}),n.setupTransactionId&&o.jsxs("div",{className:"bg-zinc-900 border border-zinc-800 rounded-2xl p-5",children:[o.jsx("p",{className:"text-xs text-zinc-500 uppercase tracking-wider mb-1",children:"Setup Transaction ID"}),o.jsx("p",{className:"text-zinc-300 text-sm font-mono break-all",children:n.setupTransactionId})]}),n.notes&&o.jsxs("div",{className:"bg-zinc-900 border border-yellow-500/30 rounded-2xl p-5",children:[o.jsx("p",{className:"text-xs text-yellow-500 uppercase tracking-wider mb-1.5",children:"Admin Notes"}),o.jsx("p",{className:"text-zinc-300 text-sm",children:n.notes})]}),o.jsxs("div",{className:"bg-zinc-900 border border-zinc-800 rounded-2xl p-6 space-y-5",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(n4,{className:"h-5 w-5 text-red-500"}),o.jsx("h3",{className:"font-semibold text-white",children:"Streamlabs Live Streaming"}),a?.isLive&&o.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full bg-red-500/20 text-red-400 text-xs font-bold",children:[o.jsx("span",{className:"w-2 h-2 rounded-full bg-red-500 animate-pulse inline-block"}),"LIVE NOW"]})]}),c?o.jsxs("div",{className:"flex items-center gap-2 text-zinc-500 text-sm py-2",children:[o.jsx("div",{className:"h-4 w-4 border-2 border-zinc-500 border-t-transparent rounded-full animate-spin"}),"Loading live configâ¦"]}):h?o.jsxs("div",{className:"bg-yellow-500/10 border border-yellow-500/30 rounded-xl p-4",children:[o.jsx("p",{className:"text-yellow-400 text-sm",children:h}),o.jsx("p",{className:"text-zinc-500 text-xs mt-1",children:"Contact support to link your creator account to your ChronicTV channel."})]}):a?o.jsxs("div",{className:"space-y-4",children:[o.jsxs("p",{className:"text-zinc-400 text-sm",children:["Use Streamlabs ",o.jsx("span",{className:"text-white font-medium",children:"Custom Ingest"})," for your ",o.jsx("span",{className:"text-green-400 font-medium",children:a.channelName})," channel. ChronicTV detects the actual media connection automatically; no webhook or third-party playback URL is required."]}),o.jsxs("div",{className:"space-y-1.5",children:[o.jsx("p",{className:"text-xs font-medium uppercase tracking-wider text-zinc-500",children:"Name"}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx("div",{className:"flex-1 bg-zinc-800 border border-zinc-700 rounded-lg px-3 py-2.5 font-mono text-xs text-zinc-300 overflow-hidden text-ellipsis whitespace-nowrap",children:a.ingestName}),o.jsx("button",{onClick:()=>w(a.ingestName),className:"flex items-center gap-1.5 px-3 py-2 bg-zinc-700 hover:bg-zinc-600 border border-zinc-600 rounded-lg text-sm font-medium transition-colors text-white shrink-0",children:o.jsxs(o.Fragment,{children:[o.jsx(Dh,{className:"h-4 w-4"})," Copy"]})})]})]}),o.jsxs("div",{className:"space-y-1.5",children:[o.jsx("p",{className:"text-xs font-medium uppercase tracking-wider text-zinc-500",children:"ChronicTV Server URL"}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx("div",{className:"flex-1 bg-zinc-800 border border-zinc-700 rounded-lg px-3 py-2.5 font-mono text-xs text-zinc-300 overflow-hidden text-ellipsis whitespace-nowrap",children:a.ingestServerUrl||"Live ingest endpoint is being provisioned"}),o.jsx("button",{onClick:()=>w(a.ingestServerUrl),disabled:!a.ingestServerUrl,className:"flex items-center gap-1.5 px-3 py-2 bg-green-500 hover:bg-green-400 disabled:opacity-50 rounded-lg text-sm font-bold text-black transition-colors shrink-0",children:o.jsxs(o.Fragment,{children:[o.jsx(Dh,{className:"h-4 w-4"})," Copy"]})})]})]}),o.jsxs("div",{className:"space-y-1.5",children:[o.jsx("p",{className:"text-xs font-medium uppercase tracking-wider text-zinc-500",children:"Private Stream Key"}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx("div",{className:"flex-1 bg-zinc-800 border border-zinc-700 rounded-lg px-3 py-2.5 font-mono text-xs text-zinc-300 overflow-hidden text-ellipsis whitespace-nowrap",children:a.streamKey}),o.jsx("button",{onClick:()=>w(a.streamKey),className:"flex items-center gap-1.5 px-3 py-2 bg-zinc-700 hover:bg-zinc-600 border border-zinc-600 rounded-lg text-sm font-medium transition-colors text-white shrink-0",children:o.jsxs(o.Fragment,{children:[o.jsx(Dh,{className:"h-4 w-4"})," Copy"]})})]}),o.jsx("p",{className:"text-xs text-amber-400/80",children:"Keep this key private. Anyone with it can broadcast to your channel."})]}),(a.isLive||a.health?.status==="reconnecting")&&o.jsxs("div",{className:"bg-red-500/10 border border-red-500/30 rounded-xl p-4 flex items-start justify-between gap-4",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-red-400 font-semibold text-sm",children:a.health?.status==="reconnecting"?"Reconnecting to ChronicTV":"Stream is live"}),a.liveTitle&&o.jsx("p",{className:"text-zinc-300 text-xs mt-0.5",children:a.liveTitle}),a.health?.lastMediaAt&&o.jsxs("p",{className:"text-zinc-500 text-xs mt-0.5",children:["Last media ",new Date(a.health.lastMediaAt).toLocaleTimeString()]}),a.liveStartedAt&&o.jsxs("p",{className:"text-zinc-500 text-xs mt-0.5",children:["Started ",new Date(a.liveStartedAt).toLocaleTimeString()]})]}),o.jsx("button",{onClick:x,disabled:m,className:"flex items-center gap-1.5 px-3 py-2 bg-zinc-700 hover:bg-zinc-600 border border-zinc-600 rounded-lg text-xs font-medium text-white transition-colors shrink-0",children:m?o.jsx("div",{className:"h-3.5 w-3.5 border-2 border-white border-t-transparent roun
268ded-full animate-spin"}):o.jsxs(o.Fragment,{children:[o.jsx(WF,{className:"h-3.5 w-3.5"})," End Stream"]})})]}),o.jsxs("div",{className:"bg-zinc-800/60 rounded-xl p-4 space-y-2",children:[o.jsx("p",{className:"text-xs font-medium text-zinc-400",children:"How it works"}),o.jsxs("ol",{className:"text-xs text-zinc-500 space-y-1 list-decimal list-inside",children:[o.jsx("li",{children:"Open Streamlabs and choose Custom Ingest"}),o.jsx("li",{children:"Copy the Name, ChronicTV Server URL, and Private Stream Key above"}),o.jsx("li",{children:"Start streaming â ChronicTV verifies the incoming media before showing LIVE"}),o.jsx("li",{children:"Viewers click Watch Live on your channel to watch inside ChronicTV"}),o.jsx("li",{children:"When you stop streaming, ChronicTV restores the channel thumbnail after the reconnect grace period"})]})]})]}):o.jsx("p",{className:"text-zinc-500 text-sm",children:"No linked ChronicTV channel. Contact support to connect your creator account."})]}),o.jsxs("div",{className:"text-center text-sm text-zinc-500 pb-6",children:["Questions about your channel?"," ",o.jsx("a",{href:"mailto:[email protected]",className:"text-green-400 hover:underline",children:"Contact support"})]})]})})}const d7="Chronic Brand USA",h7="[email protected]";function fp(){const[n,e]=T.useState(!1),[t,s]=T.useState(""),[r,i]=T.useState(!1),[a,l]=T.useState(""),[c,d]=T.useState(!1),[h,p]=T.useState({firstName:"",lastName:"",stageName:"",email:"",phone:"",address:"",role:"Guest",project:"",guardianEmail:"",signature:"",signatureDate:new Date().toISOString().slice(0,10),guardianName:"",guardianSignature:""}),m=(w,S)=>p(_=>({..._,[w]:S}));async function y(w){if(w.preventDefault(),l(""),!h.firstName.trim()||!h.lastName.trim()||!h.email.trim()||!h.phone.trim()||!h.project.trim()||!h.signature.trim()||!h.signatureDate){l("Please complete all required participant and signature fields.");return}if(c&&(!h.guardianName.trim()||!h.guardianSignature.trim())){l("A parent or legal guardian must complete the minor consent section.");return}i(!0);try{const S=await fetch("/api/legal/chronictv-release",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...h,isMinor:c})}),_=await S.json();if(!S.ok)throw new Error(_.error||"Unable to submit release.");s(_.releaseId),e(!0)}catch(S){l(S.message||"Unable to submit release.")}finally{i(!1)}}if(n)return o.jsx("main",{className:"min-h-screen bg-zinc-950 text-white px-4 py-10",children:o.jsxs("div",{className:"max-w-2xl mx-auto bg-zinc-900 border border-green-500/30 rounded-2xl p-8 text-center shadow-2xl",children:[o.jsx(F7,{className:"w-16 h-16 text-green-400 mx-auto mb-5"}),o.jsx("h1",{className:"text-2xl font-bold mb-3",children:"Release Submitted"}),o.jsx("p",{className:"text-zinc-300 leading-relaxed",children:"Your ChronicTV appearance and media release has been recorded. Keep this confirmation number for your records."}),o.jsx("p",{className:"mt-5 text-green-300 font-mono text-sm",children:t}),o.jsxs("button",{onClick:()=>window.print(),className:"mt-7 inline-flex items-center gap-2 px-5 py-3 rounded-lg bg-green-600 hover:bg-green-500 font-semibold print:hidden",children:[o.jsx(DF,{className:"w-4 h-4"})," Print / Save Copy"]})]})});const x="mt-1.5 w-full rounded-lg border border-zinc-700 bg-zinc-800 px-3 py-3 text-white outline-none focus:border-green-400 focus:ring-2 focus:ring-green-400/20";return`${h.firstName} ${h.lastName}`.trim(),h.email.trim(),o.jsx("main",{className:"min-h-screen bg-zinc-950 text-white px-4 py-8 md:py-12",children:o.jsxs("article",{className:"max-w-4xl mx-auto",children:[o.jsxs("header",{className:"text-center mb-8",children:[o.jsx("div",{className:"inline-flex items-center justify-center w-14 h-14 rounded-2xl bg-green-500/15 border border-green-500/30 mb-4",children:o.jsx(yF,{className:"w-7 h-7 text-green-400"})}),o.jsx("h1",{className:"text-3xl md:text-4xl font-black tracking-tight",children:"ChronicTV Appearance & Media Release"}),o.jsx("p",{className:"text-zinc-400 mt-3",children:"For cast members, guests, contributors, and participating talent"})]}),o.jsxs("div",{className:"mb-8 rounded-xl border border-amber-500/40 bg-amber-500/10 p-4 text-sm text-amber-200 leading-relaxed",children:[o.jsx("strong",{children:"Notice:"})," This is a legal agreement. Read carefully before signing. Have an Oklahoma entertainment attorney review this document before production use."]}),o.jsxs("section",{className:"rounded-2xl border border-zinc-800 bg-zinc-900/80 p-5 md:p-8 shadow-xl",children:[o.jsxs("div",{className:"prose prose-invert max-w-none text-sm leading-relaxed text-zinc-300",children:[o.jsxs("p",{children:["This Appearance & Media Release (âReleaseâ) is entered into by the Participant named below in favor of ",o.jsx("strong",{className:"text-white",children:d7})," and its parent, subsidiaries, affiliates, successors, licensees, production partners, distributors, advertisers, and designees (collectively, âCompanyâ)."]}),o.jsx("h2",{className:"text-lg font-bold text-white mt-7 mb-2",children:"1. Grant of Rights & Media License"}),o.jsx("p",{children:"Participant grants Company a worldwide, perpetual, irrevocable, royalty-free, transferable, and sublicensable right to photograph, film, record, interview, livestream, edit, reproduce, publish, exhibit, distribute, advertise, promote, and otherwise use Participantâs name, image, likeness, voice, statements, performance, biography, and social media handles in connection with ChronicTV. This applies to all programming, advertising, social media, merchandise, and streaming platforms now known or hereafter developed."}),o.jsx("h2",{className:"text-lg font-bold text-white mt-7 mb-2",children:"2. Editorial & Commercial Control"}),o.jsx("p",{children:"Company retains full editorial and commercial control. Company may edit, adapt, dub, combine, rearrange, or create derivative works from the recordings. Participant waives any right to inspect or approve the finished production or promotional materials. Company is under no obligation to air, distribute, or use any re
268corded material. No additional compensation or royalties will be paid unless governed by a separate written agreement."}),o.jsx("h2",{className:"text-lg font-bold text-white mt-7 mb-2",children:"3. Assumption of Risk"}),o.jsx("p",{children:"Participant voluntarily participates with full knowledge that production activities may involve travel, physical movement, emotional subjects, dynamic studio or field locations, and standard production hazards. Participant assumes all risks, known or unknown, associated with their participation and agrees to follow all safety instructions given by Company staff."}),o.jsx("h2",{className:"text-lg font-bold text-white mt-7 mb-2",children:"4. Absolute Release & Hold Harmless"}),o.jsx("p",{children:"To the fullest extent permitted by Oklahoma law, Participant fully releases, waives, discharges, and holds harmless Company, its officers, agents, employees, and property owners from any and all claims, demands, liabilities, causes of action, damages, or costs (including legal fees) arising out of or related to participation, recording, editing, publication, or public portrayal. This includes, without limitation, claims for defamation, invasion of privacy, right of publicity, or emotional distress. This release does not extend to claims arising from gross negligence or intentional misconduct where prohibited by Oklahoma law."}),o.jsx("h2",{className:"text-lg font-bold text-white mt-7 mb-2",children:"5. Representations & Privacy"}),o.jsx("p",{children:"Participant confirms they are at least 18 years of age (or that a parent/legal guardian is executing on their behalf) and have full legal authority to sign. Participant warrants that any materials provided by them do not infringe on third-party rights. Participant consents to the storage and processing of their contact data for production administration."}),o.jsx("h2",{className:"text-lg font-bold text-white mt-7 mb-2",children:"6. Governing Law & Severability"}),o.jsx("p",{children:"This Release is governed by the laws of the State of Oklahoma. Venue for any legal proceedings shall lie exclusively in the state or federal courts serving Oklahoma. If any provision is deemed unenforceable, all remaining provisions shall remain in full force and effect."})]}),o.jsxs("form",{onSubmit:y,className:"mt-9 border-t border-zinc-800 pt-8 space-y-5",children:[o.jsxs("h2",{className:"text-xl font-bold flex items-center gap-2",children:[o.jsx(OF,{className:"w-5 h-5 text-green-400"})," Participant Information"]}),o.jsxs("div",{className:"grid md:grid-cols-2 gap-4",children:[o.jsxs("label",{className:"text-sm text-zinc-300",children:["First name *",o.jsx("input",{className:x,value:h.firstName,onChange:w=>m("firstName",w.target.value),autoComplete:"given-name",required:!0})]}),o.jsxs("label",{className:"text-sm text-zinc-300",children:["Last name *",o.jsx("input",{className:x,value:h.lastName,onChange:w=>m("lastName",w.target.value),autoComplete:"family-name",required:!0})]}),o.jsxs("label",{className:"text-sm text-zinc-300",children:["Stage/professional name",o.jsx("input",{className:x,value:h.stageName,onChange:w=>m("stageName",w.target.value)})]}),o.jsxs("label",{className:"text-sm text-zinc-300",children:["Email *",o.jsx("input",{type:"email",className:x,value:h.email,onChange:w=>m("email",w.target.value),autoComplete:"email",required:!0})]}),o.jsxs("label",{className:"text-sm text-zinc-300",children:["Phone number *",o.jsx("input",{className:x,value:h.phone,onChange:w=>m("phone",w.target.value),autoComplete:"tel",required:!0})]}),o.jsxs("label",{className:"text-sm text-zinc-300",children:["Role / title",o.jsx("input",{className:x,value:h.role,onChange:w=>m("role",w.target.value),placeholder:"Guest, Host, Interviewee"})]}),o.jsxs("label",{className:"text-sm text-zinc-300",children:["Show / project name *",o.jsx("input",{className:x,value:h.project,onChange:w=>m("project",w.target.value),required:!0})]})]}),o.jsxs("div",{className:"rounded-lg border border-green-500/25 bg-green-500/5 p-4 text-sm text-zinc-300 leading-relaxed",children:["By submitting this signed waiver, you authorize ",d7," to create or link a free Chronic Brands account associated with your email and grant you free Cultured membership access. A one-time activation link
268will be sent to set your password. Existing account holders will have this release appended to their current profile."]}),o.jsxs("label",{className:"text-sm text-zinc-300 block",children:["Mailing address",o.jsx("input",{className:x,value:h.address,onChange:w=>m("address",w.target.value),autoComplete:"street-address"})]}),o.jsxs("label",{className:"flex items-start gap-3 text-sm text-zinc-300",children:[o.jsx("input",{type:"checkbox",checked:c,onChange:w=>d(w.target.checked),className:"mt-1 h-4 w-4 accent-green-500"}),"Participant is under 18 years old."]}),c&&o.jsxs("div",{className:"rounded-xl border border-amber-500/30 bg-amber-500/5 p-4 grid md:grid-cols-2 gap-4",children:[o.jsxs("label",{className:"text-sm text-zinc-300",children:["Parent/legal guardian full name *",o.jsx("input",{className:x,value:h.guardianName,onChange:w=>m("guardianName",w.target.value),required:!0})]}),o.jsxs("label",{className:"text-sm text-zinc-300",children:["Parent/legal guardian email",o.jsx("input",{type:"email",className:x,value:h.guardianEmail,onChange:w=>m("guardianEmail",w.target.value)})]}),o.jsxs("label",{className:"text-sm text-zinc-300",children:["Parent/legal guardian electronic signature *",o.jsx("input",{className:x,value:h.guardianSignature,onChange:w=>m("guardianSignature",w.target.value),required:!0})]})]}),o.jsxs("label",{className:"block text-sm text-zinc-300",children:["Electronic signature *",o.jsx("span",{className:"block text-xs text-zinc-500 mt-1",children:"Type your legal name. This is intended to function as your electronic signature."}),o.jsx("input",{className:`${x} font-serif italic`,value:h.signature,onChange:w=>m("signature",w.target.value),required:!0})]}),o.jsxs("label",{className:"block text-sm text-zinc-300",children:["Date *",o.jsx("input",{type:"date",className:x,value:h.signatureDate,onChange:w=>m("signatureDate",w.target.value),required:!0})]}),o.jsxs("label",{className:"flex items-start gap-3 text-sm text-zinc-300",children:[o.jsx("input",{type:"checkbox",required:!0,className:"mt-1 h-4 w-4 accent-green-500"}),"I have read and understood this Release, I am signing voluntarily, and I agree to its terms."]}),a&&o.jsx("p",{className:"text-sm text-red-300 bg-red-500/10 border border-red-500/30 rounded-lg p-3",children:a}),o.jsx("button",{disabled:r,className:"w-full rounded-lg bg-green-600 hover:bg-green-500 disabled:opacity-50 px-5 py-3.5 font-bold text-white",children:r?"Submittingâ¦":"Sign and Submit Release"}),o.jsxs("p",{className:"text-xs text-zinc-500 text-center",children:["Questions about this Release? Contact ",o.jsx("a",{className:"text-green-400 hover:underline",href:`mailto:${h7}`,children:h7}),"."]})]})]})]})})}const f7=T.lazy(()=>ps(()=>import("./AdminLoginPage-Baf5BaEO.js"),__vite__mapDeps([0,1,2]))),p7=T.lazy(()=>ps(()=>import("./AdminDashboardPage-BFsd-QSt.js"),__vite__mapDeps([3,4,5,6,7,1,8]))),m7=T.lazy(()=>ps(()=>import("./LoungeInventoryPage-DbG5a6GG.js"),__vite__mapDeps([9,4,1,8]))),g7=T.lazy(()=>ps(()=>import("./LoungeMenuPage-CDNTa4wW.js"),__vite__mapDeps([10,1,6]))),rde=T.lazy(()=>ps(()=>import("./VendorPortalPage-Dg7f_w8c.js"),__vite__mapDeps([11,2,5,8,12]))),ide=T.lazy(()=>ps(()=>import("./VendorInvitePage-CBTY-CAk.js"),[])),ade=T.lazy(()=>ps(()=>import("./BusinessPage-C3uS2onk.js"),__vite__mapDeps([13,12,7,14]))),ode=T.lazy(()=>ps(()=>import("./LaunchpadPage-D-WOgt2A.js"),__vite__mapDeps([15,14,7]))),Za=o.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:o.jsx("div",{className:"animate-spin w-8 h-8 border-4 border-green-500 border-t-transparent rounded-full"})});function lde(){const{data:n}=gn({queryKey:["/api/startup-bundle"]});Xl(),T.useEffect(()=>{},[n]);const e=window.location.pathname.replace(/\/$/,"")||"/";if(e==="/lounge-menu")return o.jsx(T.Suspense,{fallback:Za,children:o.jsx(g7,{})});if(e==="/LoungeInventory"||e==="/lounge-inventory")return o.jsx(T.Suspense,{fallback:Za,children:o.jsx(m7,{})});if(e==="/adminportal"||e.startsWith("/admin-"))return o.jsx(T.Suspense,{fallback:Za,children:e==="/adminportal"?o.jsx(f7,{}):o.jsx(p7,{})});if(e==="/chronictv-release"||e==="/chronictv-waiver")return o.jsx(fp,{});if(e==="/contentwaiver")return o.jsx(fp,{});if(e==="/ArtistDevelopment/launchpad")return o.jsx(T.Suspense,{fallback:Za,children:o.jsx(ode,{})});if(e==="/business"||e==="/ArtistDevelopment")return o.jsx(T.Suspense,{fallback:Za,children:o.jsx(ade,{})});if(e.startsWith("/p/")){const t=T.lazy(()=>ps(()=>import("./VendorProfilePage-CekWvUeT.js"),[]));return o.jsx(T.Suspense,{fallback:Za,children:o.jsx(t,{})})}if(e.startsWith("/guest-invite/")){const t=T.lazy(()=>ps(()=>import("./GuestProfilePage-bHMpfVUN.js"),__vite__mapDeps([16,1])));return o.jsx(T.Suspense,{fallback:Za,children:o.jsx(t,{})})}if(e.startsWith("/show/")){const t=T.lazy(()=>ps(()=>import("./ShowApplyPage-DwbgRLwc.js"),[]));return o.jsx(T.Suspense,{fallback:Za,children:o.jsx(t,{})})}return e.startsWith("/vendor/")&&e.endsWith("-invite")?o.jsx(T.Suspense,{fallback:Za,children:o.jsx(ide,{})}):e==="/vendor"||e.startsWith("/vendor/")?o.jsx(T.Suspense,{fallback:Za,children:o.jsx(rde,{})}):e.endsWith("/MembershipStatus")?o.jsx(QL,{}):o.jsx(T.Suspense,{fallback:Za,children:o.jsxs(wT,{children:[o.jsx(Ht,{path:"/lounge-menu",children:o.jsx(g7,{})}),o.jsx(Ht,{path:"/LoungeInventory",children:o.jsx(m7,{})}),o.jsx(Ht,{path:"/admin-:slug",children:o.jsx(p7,{})}),o.jsx(Ht,{path:"/adminportal",children:o.jsx(f7,{})}),o.jsx(Ht,{path:"/chronic-games",children:o.jsx(Que,{})}),o.jsx(Ht,{path:"/chronic-combat",children:o.jsx(Wue,{})}),o.jsx(Ht,{path:"/chronic-nbl",children:o.jsx(Gue,{})}),o.jsx(Ht,{path:"/chronic-kart",children:o.jsx(Kue,{})}),o.jsx(Ht,{path:"/activate-chronictv",children:o.jsx(Xue,{})}),o.jsx(Ht,{path:"/chronictv-release",children:o.jsx(fp,{})}),o.jsx(Ht,{path:"/chronictv-waiver",children:o.jsx(fp,{})}),o.jsx(Ht,{path:"/contentwaiver",children:o.jsx(fp,{})}),o.jsx(Ht,{path:"/privacy-policy",children:o.jsx(a7,{})}),o.jsx(Ht,{path:"/privacypolicy",children:o.jsx(a7,{})}),o.jsx(Ht,{path:"/terms",children:o.jsx(lb,{})}),o.jsx(Ht,{path:"/terms-of-service",children:o.jsx(lb,{})}),o.jsx(Ht,{path:"/termsofservice",children:o.jsx(lb,{})}),o.jsx(Ht,{path:"/user-safety",children:o.jsx(l7,{})}),o.jsx(Ht,{path:"/usersafety",children:o.jsx(l7,{})}),o.jsx(Ht,{path:"/delete-account",children:o.jsx(c7,{})}),o.jsx(Ht,{path:"/deleteaccount",children:o.jsx(c7,{})}),o.jsx(Ht,{path:"/chronictv/watch/:showSlug/:videoId",children:t=>o.jsx(gh,{initialShowSlug:t?.showSlug,initialVideoId:t?.videoId})}),o.jsx(Ht,{path:"/chronictv/:showSlug/:episodeSlug",children:t=>o.jsx(gh,{initialShowSlug:t?.showSlug,initialVideoId:t?.episodeSlug})}),o.jsx(Ht,{path:"/chronictv/:showSlug",children:t=>o.jsx(gh,{initialShowSlug:t?.showSlug})}),o.jsx(Ht,{path:"/chronictv",children:o.jsx(gh,{})}),o.jsx(Ht,{path:"/chronic-tv/:showSlug",children:t=>o.jsx(gh,{initialShowSlug:t?.showSlug})}),o.jsx(Ht,{path:"/chronic-tv",children:o.jsx(gh,{})}),o.jsx(Ht,{children:o.jsx(N0,{children:o.jsxs(wT,{children:[o.jsx(Ht,{path:"/",component:YJ}),o.jsx(Ht,{path:"/about",component:ZJ}),o.jsx(Ht,{path:"/brands",component:tZ}),o.jsx(Ht,{path:"/shop",children:o.jsx(o_,{})}),o.jsx(Ht,{path:"/ChronicTV-Network-Shop",children:o.jsx(o_,{defaultTab:"network"})}),o.jsx(Ht,{path:"/cart",component:hZ}),o.jsx(Ht,{path:"/orders",component:Tee}),o.jsx(Ht,{path:"/contact",component:_ee}),o.jsx(Ht,{path:"/membership",component:Vue}),o.jsx(Ht,{path:"/guest-signup",component:Hue}),o.jsx(Ht,{path:"/support",component:Zue}),o.jsx(Ht,{path:"/creator-portal",component:sde}),o.jsx(Ht,{path:"/my-account",children:o.jsx(XL,{onClose:()=>window.location.href="/"})}),o.jsx(Ht,{path:"/:brandSlug",component:Mue})]})})})]})})}async function Bj(n,e){try{const t=n.error?.stack||void 0,s={...n.context,errorName:n.error?.name,errorMessage:n.error?.message,url:window.location.href,userAgent:navigator.userAgent.
268substring(0,200),timestamp:new Date().toISOString()};await fetch("/api/error/log-client-error",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({errorType:n.errorType,severity:n.severity,message:n.message,stackTrace:t,userUid:e?.uid,userName:e?.displayName,userEmail:e?.email,endpoint:window.location.pathname,context:s,wasShownToUser:n.wasShownToUser??!0})})}catch{}}const cde=Object.freeze(Object.defineProperty({__proto__:null,logClientError:Bj},Symbol.toStringTag,{value:"Module"}));class ude extends T.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){Bj({errorType:"client",severity:"critical",message:e.message||"React render error",error:e,context:{componentStack:t.componentStack?.substring(0,500)},wasShownToUser:!0}).catch(()=>{}),setTimeout(()=>{this.setState({hasError:!1,error:void 0})},5e3)}render(){return this.state.hasError?this.props.fallback||o.jsx("div",{className:"flex items-center justify-center min-h-screen bg-gray-900 text-white",children:o.jsxs("div",{className:"text-center p-8",children:[o.jsx("h2",{className:"text-xl font-bold mb-4",children:"Something went wrong"}),o.jsx("p",{className:"text-gray-400 mb-4",children:"The app will recover automatically in a few seconds"}),o.jsx("button",{onClick:()=>this.setState({hasError:!1,error:void 0}),className:"px-4 py-2 bg-green-600 text-white rounded hover:bg-green-700",children:"Try Again"})]})}):this.props.children}}const dde=Date.now().toString(36),hde=async({queryKey:n})=>{let e=n[0];if(e.includes("website-brands")){const s=e.includes("?")?"&":"?";e=`${e}${s}_cb=${dde}`}const t=await P1(e);if(!t.ok)throw new Error(`Request failed: ${t.status}`);return t.json()},fde=new SM({defaultOptions:{queries:{queryFn:hde,refetchOnWindowFocus:!1,retry:(n,e)=>e?.name==="AbortError"?!1:n<1,retryDelay:n=>Math.min(1e3*2**n,3e3),staleTime:1e3*60*60,gcTime:1e3*60*60*2,refetchOnMount:!1,refetchOnReconnect:!1,refetchInterval:!1,refetchIntervalInBackground:!1},mutations:{retry:1,retryDelay:n=>Math.min(1e3*2**n,3e3)}}});window.addEventListener("unhandledrejection",n=>{const e=n.reason;if(e?.name==="AbortError"){n.preventDefault();return}ps(async()=>{const{logClientError:t}=await Promise.resolve().then(()=>cde);return{logClientError:t}},void 0).then(({logClientError:t})=>{t({errorType:"network",severity:"error",message:e?.message||String(e)||"Unhandled promise rejection",error:e instanceof Error?e:void 0,context:{type:e?.name||typeof e},wasShownToUser:!1}).catch(()=>{})}).catch(()=>{}),n.preventDefault()});QO.createRoot(document.getElementById("root")).render(o.jsx(Tn.StrictMode,{children:o.jsx(ude,{children:o.jsx(EM,{client:fde,children:o.jsx(WJ,{children:o.jsx(lde,{})})})})}));export{C7 as $,Fr as A,d4 as B,F7 as C,yd as D,yh as E,MF as F,xb as G,wF as H,kf as I,Pf as J,vu as K,B7 as L,V2 as M,uF as N,cF as O,gd as P,X0 as Q,z2 as R,H7 as S,Kp as T,jh as U,G7 as V,TP as W,Mr as X,sx as Y,q7 as Z,ps as _,gn as a,P1 as a0,uo as a1,l4 as a2,lU as a3,DF as a4,xF as a5,ax as a6,Xc as a7,gb as a8,NT as a9,IF as aA,SF as aB,Tn as aC,lx as aD,HF as aE,hf as aF,U7 as aG,NF as aH,V7 as aI,Sde as aJ,wde as aK,bde as aL,vde as aM,yde as aN,W7 as aO,vb as aP,n4 as aQ,kb as aR,HJ as aS,bF as aa,It as ab,rF as ac,hk as ad,LF as ae,EF as af,Dh as ag,TT as ah,Rf as ai,gF as aj,$F as ak,TF as al,ix as am,Yu as an,ff as ao,mF as ap,zF as aq,jF as ar,fF as as,BF as at,VF as au,ET as av,xh as aw,B2 as ax,UF as ay,ox as az,v0 as b,Nn as c,Vc as d,my as e,Oe as f,Et as g,md as h,Uc as i,o as j,_a as k,Lh as l,lF as m,z7 as n,Bc as o,Xl as p,oo as q,T as r,kT as s,Rd as t,ty as u,Gh as v,b0 as w,ao as x,s4 as y,$V as z};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.