@imtbl/audience 2.20.1-alpha.2 → 2.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/browser/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var vn=Object.create;var pt=Object.defineProperty;var En=Object.getOwnPropertyDescriptor;var In=Object.getOwnPropertyNames;var _n=Object.getPrototypeOf,An=Object.prototype.hasOwnProperty;var gt=(r,i)=>()=>(r&&(i=r(r=0)),i);var Sn=(r,i)=>()=>(i||r((i={exports:{}}).exports,i),i.exports);var xn=(r,i,s,f)=>{if(i&&typeof i=="object"||typeof i=="function")for(let h of In(i))!An.call(r,h)&&h!==s&&pt(r,h,{get:()=>i[h],enumerable:!(f=En(i,h))||f.enumerable});return r};var Bn=(r,i,s)=>(s=r!=null?vn(_n(r)):{},xn(pt(s,"default",{value:r,enumerable:!0}),r));var A=gt(()=>{});var S=gt(()=>{});var _t=Sn(ce=>{S();A();Object.defineProperty(ce,"__esModule",{value:!0});ce.clearGlobalNamespace=ce.getGlobalisedValue=void 0;var Un="globalise__singleton__",On={},vt=()=>typeof window<"u"?window:typeof globalThis<"u"?globalThis:On,Pn=(r,i)=>{if(typeof r!="string")throw "Invalid namespace key";if(typeof i!="string")throw "Invalid item key"},Et=r=>`${Un}${r}`,It=r=>{let i=vt(),s=Et(r);return i[s]||(i[s]={}),i[s]},Nn=(r,i)=>It(r)[i]||void 0,Rn=(r,i,s)=>{let f=It(r);f[i]=s;},Cn=(r,i,s)=>{Pn(r,i);let f=Nn(r,i);return f!==void 0?f:(Rn(r,i,s),s)};ce.getGlobalisedValue=Cn;var Ln=r=>{let i=vt(),s=Et(r);i[s]!==void 0&&delete i[s];};ce.clearGlobalNamespace=Ln;});S();A();S();A();S();A();S();A();var Oe="https://api.immutable.com",mt="/v1/audience/messages",yt="/v1/audience/tracking-consent",z="imtbl_anon_id",H="_imtbl_sid",Pe="session_start",Ne="session_end",q=()=>typeof window<"u"&&typeof document<"u",W=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,r=>{let i=Math.trunc(Math.random()*16);return (r==="x"?i:i%4+8).toString(16)}),Re=()=>new Date().toISOString();function le(r){if(!q())return;let i=document.cookie.match(new RegExp(`(?:^|; )${r}=([^;]*)`));return i?decodeURIComponent(i[1]):void 0}function fe(r,i,s,f){if(!q())return;let h=window.location.protocol==="https:"?"; Secure":"",d=f?`; domain=${f}`:"";document.cookie=`${r}=${encodeURIComponent(i)}; path=/; max-age=${s}; SameSite=Lax${d}${h}`;}function he(r,i){fe(r,"",0,i);}function ye(r){let i=le(z);if(i)return i;let s=W();return fe(z,s,63072e3,r),s}function Ce(r,i){fe(z,r,63072e3,i);}S();A();S();A();S();A();var Le=class{constructor(i=0,s=0,f=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=i,this.resetTtl=f,this.size=0,this.ttl=s;}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(i){if(this.has(i)){let s=this.items[i];delete this.items[i],this.size--,s.prev!==null&&(s.prev.next=s.next),s.next!==null&&(s.next.prev=s.prev),this.first===s&&(this.first=s.next),this.last===s&&(this.last=s.prev);}return this}entries(i=this.keys()){return i.map(s=>[s,this.get(s)])}evict(i=!1){if(i||this.size>0){let s=this.first;delete this.items[s.key],--this.size===0?(this.first=null,this.last=null):(this.first=s.next,this.first.prev=null);}return this}expiresAt(i){let s;return this.has(i)&&(s=this.items[i].expiry),s}get(i){let s;if(this.has(i)){let f=this.items[i];this.ttl>0&&f.expiry<=Date.now()?this.delete(i):(s=f.value,this.set(i,s,!0));}return s}has(i){return i in this.items}keys(){let i=[],s=this.first;for(;s!==null;)i.push(s.key),s=s.next;return i}set(i,s,f=!1,h=this.resetTtl){let d;if(f||this.has(i)){if(d=this.items[i],d.value=s,f===!1&&h&&(d.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.last!==d){let a=this.last,g=d.next,m=d.prev;this.first===d&&(this.first=d.next),d.next=null,d.prev=this.last,a.next=d,m!==null&&(m.next=g),g!==null&&(g.prev=m);}}else this.max>0&&this.size===this.max&&this.evict(!0),d=this.items[i]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:i,prev:this.last,next:null,value:s},++this.size===1?this.first=d:this.last.next=d;return this.last=d,this}values(i=this.keys()){return i.map(s=>this.get(s))}};function wt(r=1e3,i=0,s=!1){if(isNaN(r)||r<0)throw new TypeError("Invalid max value");if(isNaN(i)||i<0)throw new TypeError("Invalid ttl value");if(typeof s!="boolean")throw new TypeError("Invalid resetTtl value");return new Le(r,i,s)}var Tn={max:1e3},bt=(r,i={})=>{let{cache:s,cacheKeyResolver:f=Me,onHit:h,lruOptions:d={}}=i,a={...Tn,...d},g=s||wt(a.max,a.ttl);function m(...B){let b=f(...B),w=g.get(b);if(g.has(b))return h&&h(b,w,g),w;let p=r.apply(this,B);return g.set(b,p),p}return m._cache=g,m},Me=(...r)=>r.length===0?"no-args":r.map(i=>i===void 0?"undefined":i===null?"null":Array.isArray(i)?`[${Me(...i)}]`:typeof i=="object"?`{${Me(...kn(i))}}`:JSON.stringify(i)).join(","),kn=r=>Object.entries(r).sort((i,s)=>i[0]<s[0]?-1:1);var He=Bn(_t()),Mn=Object.defineProperty,$n=(r,i)=>{for(var s in i)Mn(r,s,{get:i[s],enumerable:!0});};function We(r){throw new Error("Node.js process "+r+" is not supported by JSPM core outside of Node.js")}var V=[],de=!1,ee,_e=-1;function Dn(){!de||!ee||(de=!1,ee.length?V=ee.concat(V):_e=-1,V.length&&kt());}function kt(){if(!de){var r=setTimeout(Dn,0);de=!0;for(var i=V.length;i;){for(ee=V,V=[];++_e<i;)ee&&ee[_e].run();_e=-1,i=V.length;}ee=null,de=!1,clearTimeout(r);}}function Fn(r){var i=new Array(arguments.length-1);if(arguments.length>1)for(var s=1;s<arguments.length;s++)i[s-1]=arguments[s];V.push(new Ut(r,i)),V.length===1&&!de&&setTimeout(kt,0);}function Ut(r,i){this.fun=r,this.array=i;}Ut.prototype.run=function(){this.fun.apply(null,this.array);};var jn="browser",Gn="x64",qn="browser",Vn={PATH:"/usr/bin",LANG:navigator.language+".UTF-8",PWD:"/",HOME:"/home",TMP:"/tmp"},Kn=["/usr/bin/node"],zn=[],Hn="v16.8.0",Wn={},Yn=function(r,i){console.warn((i?i+": ":"")+r);},Jn=function(r){We("binding");},Xn=function(r){return 0},Qn=function(){return "/"},Zn=function(r){},er={name:"node",sourceUrl:"",headersUrl:"",libUrl:""};function R(){}var tr=R,nr=[];function rr(r){We("_linkedBinding");}var ir={},sr=!1,or={};function ar(r){We("dlopen");}function ur(){return []}function lr(){return []}var fr=R,hr=R,Ye=function(){return {}},cr=Ye,dr=Ye,pr=R,gr=R,mr=R,yr={};function wr(r,i){if(!r)throw new Error(i||"assertion error")}var br={inspector:!1,debug:!1,uv:!1,ipv6:!1,tls_alpn:!1,tls_sni:!1,tls_ocsp:!1,tls:!1,cached_builtins:!0},vr=R,Er=R;function Ir(){return !1}var _r=R,Ar=R,Sr=R,xr=R,Br=R,Tr=void 0,kr=void 0,Ur=void 0,Or=R,Pr=2,Nr=1,Rr="/bin/usr/node",Cr=9229,Lr="node",Mr=[],$r=R,Y={now:typeof performance<"u"?performance.now.bind(performance):void 0,timing:typeof performance<"u"?performance.timing:void 0};Y.now===void 0&&($e=Date.now(),Y.timing&&Y.timing.navigationStart&&($e=Y.timing.navigationStart),Y.now=()=>Date.now()-$e);var $e;function Dr(){return Y.now()/1e3}var Fe=1e9;function je(r){var i=Math.floor((Date.now()-Y.now())*.001),s=Y.now()*.001,f=Math.floor(s)+i,h=Math.floor(s%1*1e9);return r&&(f=f-r[0],h=h-r[1],h<0&&(f--,h+=Fe)),[f,h]}je.bigint=function(r){var i=je(r);return typeof BigInt>"u"?i[0]*Fe+i[1]:BigInt(i[0]*Fe)+BigInt(i[1])};var Fr=10,jr={},Gr=0;function J(){return Ge}var qr=J,Vr=J,Kr=J,zr=J,Hr=J,Wr=R,Yr=J,Jr=J;function Xr(r){return []}var Ge={version:Hn,versions:Wn,arch:Gn,platform:qn,release:er,_rawDebug:tr,moduleLoadList:nr,binding:Jn,_linkedBinding:rr,_events:jr,_eventsCount:Gr,_maxListeners:Fr,on:J,addListener:qr,once:Vr,off:Kr,removeListener:zr,removeAllListeners:Hr,emit:Wr,prependListener:Yr,prependOnceListener:Jr,listeners:Xr,domain:ir,_exiting:sr,config:or,dlopen:ar,uptime:Dr,_getActiveRequests:ur,_getActiveHandles:lr,reallyExit:fr,_kill:hr,cpuUsage:Ye,resourceUsage:cr,memoryUsage:dr,kill:pr,exit:gr,openStdin:mr,allowedNodeEnvironmentFlags:yr,assert:wr,features:br,_fatalExceptions:vr,setUncaughtExceptionCaptureCallback:Er,hasUncaughtExceptionCaptureCallback:Ir,emitWarning:Yn,nextTick:Fn,_tickCallback:_r,_debugProcess:Ar,_debugEnd:Sr,_startProfilerIdleNotifier:xr,_stopProfilerIdleNotifier:Br,stdout:Tr,stdin:Ur,stderr:kr,abort:Or,umask:Xn,chdir:Zn,cwd:Qn,env:Vn,title:jn,argv:Kn,execArgv:zn,pid:Pr,ppid:Nr,execPath:Rr,debugPort:Cr,hrtime:je,argv0:Lr,_preload_modules:Mr,setSourceMapsEnabled:$r},we={},At=!1;function Qr(){if(At)return we;At=!0,we.byteLength=g,we.toByteArray=B,we.fromByteArray=v;for(var r=[],i=[],s=typeof Uint8Array<"u"?Uint8Array:Array,f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",h=0,d=f.length;h<d;++h)r[h]=f[h],i[f.charCodeAt(h)]=h;i[45]=62,i[95]=63;function a(p){var y=p.length;if(y%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var E=p.indexOf("=");E===-1&&(E=y);var T=E===y?0:4-E%4;return [E,T]}function g(p){var y=a(p),E=y[0],T=y[1];return (E+T)*3/4-T}function m(p,y,E){return (y+E)*3/4-E}function B(p){var y,E=a(p),T=E[0],N=E[1],k=new s(m(p,T,N)),L=0,$=N>0?T-4:T,C;for(C=0;C<$;C+=4)y=i[p.charCodeAt(C)]<<18|i[p.charCodeAt(C+1)]<<12|i[p.charCodeAt(C+2)]<<6|i[p.charCodeAt(C+3)],k[L++]=y>>16&255,k[L++]=y>>8&255,k[L++]=y&255;return N===2&&(y=i[p.charCodeAt(C)]<<2|i[p.charCodeAt(C+1)]>>4,k[L++]=y&255),N===1&&(y=i[p.charCodeAt(C)]<<10|i[p.charCodeAt(C+1)]<<4|i[p.charCodeAt(C+2)]>>2,k[L++]=y>>8&255,k[L++]=y&255),k}function b(p){return r[p>>18&63]+r[p>>12&63]+r[p>>6&63]+r[p&63]}function w(p,y,E){for(var T,N=[],k=y;k<E;k+=3)T=(p[k]<<16&16711680)+(p[k+1]<<8&65280)+(p[k+2]&255),N.push(b(T));return N.join("")}function v(p){for(var y,E=p.length,T=E%3,N=[],k=16383,L=0,$=E-T;L<$;L+=k)N.push(w(p,L,L+k>$?$:L+k));return T===1?(y=p[E-1],N.push(r[y>>2]+r[y<<4&63]+"==")):T===2&&(y=(p[E-2]<<8)+p[E-1],N.push(r[y>>10]+r[y>>4&63]+r[y<<2&63]+"=")),N.join("")}return we}var Ie={},St=!1;function Zr(){return St?Ie:(St=!0,Ie.read=function(r,i,s,f,h){var d,a,g=h*8-f-1,m=(1<<g)-1,B=m>>1,b=-7,w=s?h-1:0,v=s?-1:1,p=r[i+w];for(w+=v,d=p&(1<<-b)-1,p>>=-b,b+=g;b>0;d=d*256+r[i+w],w+=v,b-=8);for(a=d&(1<<-b)-1,d>>=-b,b+=f;b>0;a=a*256+r[i+w],w+=v,b-=8);if(d===0)d=1-B;else {if(d===m)return a?NaN:(p?-1:1)*(1/0);a=a+Math.pow(2,f),d=d-B;}return (p?-1:1)*a*Math.pow(2,d-f)},Ie.write=function(r,i,s,f,h,d){var a,g,m,B=d*8-h-1,b=(1<<B)-1,w=b>>1,v=h===23?Math.pow(2,-24)-Math.pow(2,-77):0,p=f?0:d-1,y=f?1:-1,E=i<0||i===0&&1/i<0?1:0;for(i=Math.abs(i),isNaN(i)||i===1/0?(g=isNaN(i)?1:0,a=b):(a=Math.floor(Math.log(i)/Math.LN2),i*(m=Math.pow(2,-a))<1&&(a--,m*=2),a+w>=1?i+=v/m:i+=v*Math.pow(2,1-w),i*m>=2&&(a++,m/=2),a+w>=b?(g=0,a=b):a+w>=1?(g=(i*m-1)*Math.pow(2,h),a=a+w):(g=i*Math.pow(2,w-1)*Math.pow(2,h),a=0));h>=8;r[s+p]=g&255,p+=y,g/=256,h-=8);for(a=a<<h|g,B+=h;B>0;r[s+p]=a&255,p+=y,a/=256,B-=8);r[s+p-y]|=E*128;},Ie)}var Z={},xt=!1;function ei(){if(xt)return Z;xt=!0;let r=Qr(),i=Zr(),s=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;Z.Buffer=a,Z.SlowBuffer=N,Z.INSPECT_MAX_BYTES=50;let f=2147483647;Z.kMaxLength=f,a.TYPED_ARRAY_SUPPORT=h(),!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function h(){try{let e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return !1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function d(e){if(e>f)throw new RangeError('The value "'+e+'" is invalid for option "size"');let t=new Uint8Array(e);return Object.setPrototypeOf(t,a.prototype),t}function a(e,t,n){if(typeof e=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return b(e)}return g(e,t,n)}a.poolSize=8192;function g(e,t,n){if(typeof e=="string")return w(e,t);if(ArrayBuffer.isView(e))return p(e);if(e==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(G(e,ArrayBuffer)||e&&G(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(G(e,SharedArrayBuffer)||e&&G(e.buffer,SharedArrayBuffer)))return y(e,t,n);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let o=e.valueOf&&e.valueOf();if(o!=null&&o!==e)return a.from(o,t,n);let u=E(e);if(u)return u;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return a.from(e[Symbol.toPrimitive]("string"),t,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}a.from=function(e,t,n){return g(e,t,n)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function m(e){if(typeof e!="number")throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function B(e,t,n){return m(e),e<=0?d(e):t!==void 0?typeof n=="string"?d(e).fill(t,n):d(e).fill(t):d(e)}a.alloc=function(e,t,n){return B(e,t,n)};function b(e){return m(e),d(e<0?0:T(e)|0)}a.allocUnsafe=function(e){return b(e)},a.allocUnsafeSlow=function(e){return b(e)};function w(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!a.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let n=k(e,t)|0,o=d(n),u=o.write(e,t);return u!==n&&(o=o.slice(0,u)),o}function v(e){let t=e.length<0?0:T(e.length)|0,n=d(t);for(let o=0;o<t;o+=1)n[o]=e[o]&255;return n}function p(e){if(G(e,Uint8Array)){let t=new Uint8Array(e);return y(t.buffer,t.byteOffset,t.byteLength)}return v(e)}function y(e,t,n){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(n||0))throw new RangeError('"length" is outside of buffer bounds');let o;return t===void 0&&n===void 0?o=new Uint8Array(e):n===void 0?o=new Uint8Array(e,t):o=new Uint8Array(e,t,n),Object.setPrototypeOf(o,a.prototype),o}function E(e){if(a.isBuffer(e)){let t=T(e.length)|0,n=d(t);return n.length===0||e.copy(n,0,0,t),n}if(e.length!==void 0)return typeof e.length!="number"||Ue(e.length)?d(0):v(e);if(e.type==="Buffer"&&Array.isArray(e.data))return v(e.data)}function T(e){if(e>=f)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+f.toString(16)+" bytes");return e|0}function N(e){return +e!=e&&(e=0),a.alloc(+e)}a.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==a.prototype},a.compare=function(e,t){if(G(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),G(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(e)||!a.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let n=e.length,o=t.length;for(let u=0,l=Math.min(n,o);u<l;++u)if(e[u]!==t[u]){n=e[u],o=t[u];break}return n<o?-1:o<n?1:0},a.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return !0;default:return !1}},a.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return a.alloc(0);let n;if(t===void 0)for(t=0,n=0;n<e.length;++n)t+=e[n].length;let o=a.allocUnsafe(t),u=0;for(n=0;n<e.length;++n){let l=e[n];if(G(l,Uint8Array))u+l.length>o.length?(a.isBuffer(l)||(l=a.from(l)),l.copy(o,u)):Uint8Array.prototype.set.call(o,l,u);else if(a.isBuffer(l))l.copy(o,u);else throw new TypeError('"list" argument must be an Array of Buffers');u+=l.length;}return o};function k(e,t){if(a.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||G(e,ArrayBuffer))return e.byteLength;if(typeof e!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);let n=e.length,o=arguments.length>2&&arguments[2]===!0;if(!o&&n===0)return 0;let u=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return ke(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return n*2;case"hex":return n>>>1;case"base64":return dt(e).length;default:if(u)return o?-1:ke(e).length;t=(""+t).toLowerCase(),u=!0;}}a.byteLength=k;function L(e,t,n){let o=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,t>>>=0,n<=t))return "";for(e||(e="utf8");;)switch(e){case"hex":return hn(this,t,n);case"utf8":case"utf-8":return it(this,t,n);case"ascii":return ln(this,t,n);case"latin1":case"binary":return fn(this,t,n);case"base64":return an(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return cn(this,t,n);default:if(o)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),o=!0;}}a.prototype._isBuffer=!0;function $(e,t,n){let o=e[t];e[t]=e[n],e[n]=o;}a.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)$(this,t,t+1);return this},a.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)$(this,t,t+3),$(this,t+1,t+2);return this},a.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)$(this,t,t+7),$(this,t+1,t+6),$(this,t+2,t+5),$(this,t+3,t+4);return this},a.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?it(this,0,e):L.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(e){if(!a.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:a.compare(this,e)===0},a.prototype.inspect=function(){let e="",t=Z.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"},s&&(a.prototype[s]=a.prototype.inspect),a.prototype.compare=function(e,t,n,o,u){if(G(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(t===void 0&&(t=0),n===void 0&&(n=e?e.length:0),o===void 0&&(o=0),u===void 0&&(u=this.length),t<0||n>e.length||o<0||u>this.length)throw new RangeError("out of range index");if(o>=u&&t>=n)return 0;if(o>=u)return -1;if(t>=n)return 1;if(t>>>=0,n>>>=0,o>>>=0,u>>>=0,this===e)return 0;let l=u-o,c=n-t,_=Math.min(l,c),P=this.slice(o,u),x=e.slice(t,n);for(let I=0;I<_;++I)if(P[I]!==x[I]){l=P[I],c=x[I];break}return l<c?-1:c<l?1:0};function C(e,t,n,o,u){if(e.length===0)return -1;if(typeof n=="string"?(o=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,Ue(n)&&(n=u?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(u)return -1;n=e.length-1;}else if(n<0)if(u)n=0;else return -1;if(typeof t=="string"&&(t=a.from(t,o)),a.isBuffer(t))return t.length===0?-1:rt(e,t,n,o,u);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?u?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):rt(e,[t],n,o,u);throw new TypeError("val must be string, number or Buffer")}function rt(e,t,n,o,u){let l=1,c=e.length,_=t.length;if(o!==void 0&&(o=String(o).toLowerCase(),o==="ucs2"||o==="ucs-2"||o==="utf16le"||o==="utf-16le")){if(e.length<2||t.length<2)return -1;l=2,c/=2,_/=2,n/=2;}function P(I,U){return l===1?I[U]:I.readUInt16BE(U*l)}let x;if(u){let I=-1;for(x=n;x<c;x++)if(P(e,x)===P(t,I===-1?0:x-I)){if(I===-1&&(I=x),x-I+1===_)return I*l}else I!==-1&&(x-=x-I),I=-1;}else for(n+_>c&&(n=c-_),x=n;x>=0;x--){let I=!0;for(let U=0;U<_;U++)if(P(e,x+U)!==P(t,U)){I=!1;break}if(I)return x}return -1}a.prototype.includes=function(e,t,n){return this.indexOf(e,t,n)!==-1},a.prototype.indexOf=function(e,t,n){return C(this,e,t,n,!0)},a.prototype.lastIndexOf=function(e,t,n){return C(this,e,t,n,!1)};function tn(e,t,n,o){n=Number(n)||0;let u=e.length-n;o?(o=Number(o),o>u&&(o=u)):o=u;let l=t.length;o>l/2&&(o=l/2);let c;for(c=0;c<o;++c){let _=parseInt(t.substr(c*2,2),16);if(Ue(_))return c;e[n+c]=_;}return c}function nn(e,t,n,o){return Ee(ke(t,e.length-n),e,n,o)}function rn(e,t,n,o){return Ee(mn(t),e,n,o)}function sn(e,t,n,o){return Ee(dt(t),e,n,o)}function on(e,t,n,o){return Ee(yn(t,e.length-n),e,n,o)}a.prototype.write=function(e,t,n,o){if(t===void 0)o="utf8",n=this.length,t=0;else if(n===void 0&&typeof t=="string")o=t,n=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(n)?(n=n>>>0,o===void 0&&(o="utf8")):(o=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let u=this.length-t;if((n===void 0||n>u)&&(n=u),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");o||(o="utf8");let l=!1;for(;;)switch(o){case"hex":return tn(this,e,t,n);case"utf8":case"utf-8":return nn(this,e,t,n);case"ascii":case"latin1":case"binary":return rn(this,e,t,n);case"base64":return sn(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return on(this,e,t,n);default:if(l)throw new TypeError("Unknown encoding: "+o);o=(""+o).toLowerCase(),l=!0;}},a.prototype.toJSON=function(){return {type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function an(e,t,n){return t===0&&n===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,n))}function it(e,t,n){n=Math.min(e.length,n);let o=[],u=t;for(;u<n;){let l=e[u],c=null,_=l>239?4:l>223?3:l>191?2:1;if(u+_<=n){let P,x,I,U;switch(_){case 1:l<128&&(c=l);break;case 2:P=e[u+1],(P&192)===128&&(U=(l&31)<<6|P&63,U>127&&(c=U));break;case 3:P=e[u+1],x=e[u+2],(P&192)===128&&(x&192)===128&&(U=(l&15)<<12|(P&63)<<6|x&63,U>2047&&(U<55296||U>57343)&&(c=U));break;case 4:P=e[u+1],x=e[u+2],I=e[u+3],(P&192)===128&&(x&192)===128&&(I&192)===128&&(U=(l&15)<<18|(P&63)<<12|(x&63)<<6|I&63,U>65535&&U<1114112&&(c=U));}}c===null?(c=65533,_=1):c>65535&&(c-=65536,o.push(c>>>10&1023|55296),c=56320|c&1023),o.push(c),u+=_;}return un(o)}let st=4096;function un(e){let t=e.length;if(t<=st)return String.fromCharCode.apply(String,e);let n="",o=0;for(;o<t;)n+=String.fromCharCode.apply(String,e.slice(o,o+=st));return n}function ln(e,t,n){let o="";n=Math.min(e.length,n);for(let u=t;u<n;++u)o+=String.fromCharCode(e[u]&127);return o}function fn(e,t,n){let o="";n=Math.min(e.length,n);for(let u=t;u<n;++u)o+=String.fromCharCode(e[u]);return o}function hn(e,t,n){let o=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>o)&&(n=o);let u="";for(let l=t;l<n;++l)u+=wn[e[l]];return u}function cn(e,t,n){let o=e.slice(t,n),u="";for(let l=0;l<o.length-1;l+=2)u+=String.fromCharCode(o[l]+o[l+1]*256);return u}a.prototype.slice=function(e,t){let n=this.length;e=~~e,t=t===void 0?n:~~t,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<e&&(t=e);let o=this.subarray(e,t);return Object.setPrototypeOf(o,a.prototype),o};function O(e,t,n){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||O(e,t,this.length);let o=this[e],u=1,l=0;for(;++l<t&&(u*=256);)o+=this[e+l]*u;return o},a.prototype.readUintBE=a.prototype.readUIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||O(e,t,this.length);let o=this[e+--t],u=1;for(;t>0&&(u*=256);)o+=this[e+--t]*u;return o},a.prototype.readUint8=a.prototype.readUInt8=function(e,t){return e=e>>>0,t||O(e,1,this.length),this[e]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(e,t){return e=e>>>0,t||O(e,2,this.length),this[e]|this[e+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(e,t){return e=e>>>0,t||O(e,2,this.length),this[e]<<8|this[e+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(e,t){return e=e>>>0,t||O(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(e,t){return e=e>>>0,t||O(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])},a.prototype.readBigUInt64LE=K(function(e){e=e>>>0,ue(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&me(e,this.length-8);let o=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,u=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(o)+(BigInt(u)<<BigInt(32))}),a.prototype.readBigUInt64BE=K(function(e){e=e>>>0,ue(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&me(e,this.length-8);let o=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],u=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return (BigInt(o)<<BigInt(32))+BigInt(u)}),a.prototype.readIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||O(e,t,this.length);let o=this[e],u=1,l=0;for(;++l<t&&(u*=256);)o+=this[e+l]*u;return u*=128,o>=u&&(o-=Math.pow(2,8*t)),o},a.prototype.readIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||O(e,t,this.length);let o=t,u=1,l=this[e+--o];for(;o>0&&(u*=256);)l+=this[e+--o]*u;return u*=128,l>=u&&(l-=Math.pow(2,8*t)),l},a.prototype.readInt8=function(e,t){return e=e>>>0,t||O(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]},a.prototype.readInt16LE=function(e,t){e=e>>>0,t||O(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n},a.prototype.readInt16BE=function(e,t){e=e>>>0,t||O(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n},a.prototype.readInt32LE=function(e,t){return e=e>>>0,t||O(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},a.prototype.readInt32BE=function(e,t){return e=e>>>0,t||O(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},a.prototype.readBigInt64LE=K(function(e){e=e>>>0,ue(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&me(e,this.length-8);let o=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return (BigInt(o)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)}),a.prototype.readBigInt64BE=K(function(e){e=e>>>0,ue(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&me(e,this.length-8);let o=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return (BigInt(o)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)}),a.prototype.readFloatLE=function(e,t){return e=e>>>0,t||O(e,4,this.length),i.read(this,e,!0,23,4)},a.prototype.readFloatBE=function(e,t){return e=e>>>0,t||O(e,4,this.length),i.read(this,e,!1,23,4)},a.prototype.readDoubleLE=function(e,t){return e=e>>>0,t||O(e,8,this.length),i.read(this,e,!0,52,8)},a.prototype.readDoubleBE=function(e,t){return e=e>>>0,t||O(e,8,this.length),i.read(this,e,!1,52,8)};function M(e,t,n,o,u,l){if(!a.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>u||t<l)throw new RangeError('"value" argument is out of bounds');if(n+o>e.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(e,t,n,o){if(e=+e,t=t>>>0,n=n>>>0,!o){let c=Math.pow(2,8*n)-1;M(this,e,t,n,c,0);}let u=1,l=0;for(this[t]=e&255;++l<n&&(u*=256);)this[t+l]=e/u&255;return t+n},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(e,t,n,o){if(e=+e,t=t>>>0,n=n>>>0,!o){let c=Math.pow(2,8*n)-1;M(this,e,t,n,c,0);}let u=n-1,l=1;for(this[t+u]=e&255;--u>=0&&(l*=256);)this[t+u]=e/l&255;return t+n},a.prototype.writeUint8=a.prototype.writeUInt8=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,1,255,0),this[t]=e&255,t+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function ot(e,t,n,o,u){ct(t,o,u,e,n,7);let l=Number(t&BigInt(4294967295));e[n++]=l,l=l>>8,e[n++]=l,l=l>>8,e[n++]=l,l=l>>8,e[n++]=l;let c=Number(t>>BigInt(32)&BigInt(4294967295));return e[n++]=c,c=c>>8,e[n++]=c,c=c>>8,e[n++]=c,c=c>>8,e[n++]=c,n}function at(e,t,n,o,u){ct(t,o,u,e,n,7);let l=Number(t&BigInt(4294967295));e[n+7]=l,l=l>>8,e[n+6]=l,l=l>>8,e[n+5]=l,l=l>>8,e[n+4]=l;let c=Number(t>>BigInt(32)&BigInt(4294967295));return e[n+3]=c,c=c>>8,e[n+2]=c,c=c>>8,e[n+1]=c,c=c>>8,e[n]=c,n+8}a.prototype.writeBigUInt64LE=K(function(e,t=0){return ot(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=K(function(e,t=0){return at(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(e,t,n,o){if(e=+e,t=t>>>0,!o){let _=Math.pow(2,8*n-1);M(this,e,t,n,_-1,-_);}let u=0,l=1,c=0;for(this[t]=e&255;++u<n&&(l*=256);)e<0&&c===0&&this[t+u-1]!==0&&(c=1),this[t+u]=(e/l>>0)-c&255;return t+n},a.prototype.writeIntBE=function(e,t,n,o){if(e=+e,t=t>>>0,!o){let _=Math.pow(2,8*n-1);M(this,e,t,n,_-1,-_);}let u=n-1,l=1,c=0;for(this[t+u]=e&255;--u>=0&&(l*=256);)e<0&&c===0&&this[t+u+1]!==0&&(c=1),this[t+u]=(e/l>>0)-c&255;return t+n},a.prototype.writeInt8=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1},a.prototype.writeInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2},a.prototype.writeInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2},a.prototype.writeInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},a.prototype.writeInt32BE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4},a.prototype.writeBigInt64LE=K(function(e,t=0){return ot(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=K(function(e,t=0){return at(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function ut(e,t,n,o,u,l){if(n+o>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function lt(e,t,n,o,u){return t=+t,n=n>>>0,u||ut(e,t,n,4),i.write(e,t,n,o,23,4),n+4}a.prototype.writeFloatLE=function(e,t,n){return lt(this,e,t,!0,n)},a.prototype.writeFloatBE=function(e,t,n){return lt(this,e,t,!1,n)};function ft(e,t,n,o,u){return t=+t,n=n>>>0,u||ut(e,t,n,8),i.write(e,t,n,o,52,8),n+8}a.prototype.writeDoubleLE=function(e,t,n){return ft(this,e,t,!0,n)},a.prototype.writeDoubleBE=function(e,t,n){return ft(this,e,t,!1,n)},a.prototype.copy=function(e,t,n,o){if(!a.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!o&&o!==0&&(o=this.length),t>=e.length&&(t=e.length),t||(t=0),o>0&&o<n&&(o=n),o===n||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),e.length-t<o-n&&(o=e.length-t+n);let u=o-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,n,o):Uint8Array.prototype.set.call(e,this.subarray(n,o),t),u},a.prototype.fill=function(e,t,n,o){if(typeof e=="string"){if(typeof t=="string"?(o=t,t=0,n=this.length):typeof n=="string"&&(o=n,n=this.length),o!==void 0&&typeof o!="string")throw new TypeError("encoding must be a string");if(typeof o=="string"&&!a.isEncoding(o))throw new TypeError("Unknown encoding: "+o);if(e.length===1){let l=e.charCodeAt(0);(o==="utf8"&&l<128||o==="latin1")&&(e=l);}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;t=t>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let u;if(typeof e=="number")for(u=t;u<n;++u)this[u]=e;else {let l=a.isBuffer(e)?e:a.from(e,o),c=l.length;if(c===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(u=0;u<n-t;++u)this[u+t]=l[u%c];}return this};let ae={};function Te(e,t,n){ae[e]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name;}get code(){return e}set code(o){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:o,writable:!0});}toString(){return `${this.name} [${e}]: ${this.message}`}};}Te("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Te("ERR_INVALID_ARG_TYPE",function(e,t){return `The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError),Te("ERR_OUT_OF_RANGE",function(e,t,n){let o=`The value of "${e}" is out of range.`,u=n;return Number.isInteger(n)&&Math.abs(n)>2**32?u=ht(String(n)):typeof n=="bigint"&&(u=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(u=ht(u)),u+="n"),o+=` It must be ${t}. Received ${u}`,o},RangeError);function ht(e){let t="",n=e.length,o=e[0]==="-"?1:0;for(;n>=o+4;n-=3)t=`_${e.slice(n-3,n)}${t}`;return `${e.slice(0,n)}${t}`}function dn(e,t,n){ue(t,"offset"),(e[t]===void 0||e[t+n]===void 0)&&me(t,e.length-(n+1));}function ct(e,t,n,o,u,l){if(e>n||e<t){let c=typeof t=="bigint"?"n":"",_;throw t===0||t===BigInt(0)?_=`>= 0${c} and < 2${c} ** ${(l+1)*8}${c}`:_=`>= -(2${c} ** ${(l+1)*8-1}${c}) and < 2 ** ${(l+1)*8-1}${c}`,new ae.ERR_OUT_OF_RANGE("value",_,e)}dn(o,u,l);}function ue(e,t){if(typeof e!="number")throw new ae.ERR_INVALID_ARG_TYPE(t,"number",e)}function me(e,t,n){throw Math.floor(e)!==e?(ue(e,n),new ae.ERR_OUT_OF_RANGE("offset","an integer",e)):t<0?new ae.ERR_BUFFER_OUT_OF_BOUNDS:new ae.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${t}`,e)}let pn=/[^+/0-9A-Za-z-_]/g;function gn(e){if(e=e.split("=")[0],e=e.trim().replace(pn,""),e.length<2)return "";for(;e.length%4!==0;)e=e+"=";return e}function ke(e,t){t=t||1/0;let n,o=e.length,u=null,l=[];for(let c=0;c<o;++c){if(n=e.charCodeAt(c),n>55295&&n<57344){if(!u){if(n>56319){(t-=3)>-1&&l.push(239,191,189);continue}else if(c+1===o){(t-=3)>-1&&l.push(239,191,189);continue}u=n;continue}if(n<56320){(t-=3)>-1&&l.push(239,191,189),u=n;continue}n=(u-55296<<10|n-56320)+65536;}else u&&(t-=3)>-1&&l.push(239,191,189);if(u=null,n<128){if((t-=1)<0)break;l.push(n);}else if(n<2048){if((t-=2)<0)break;l.push(n>>6|192,n&63|128);}else if(n<65536){if((t-=3)<0)break;l.push(n>>12|224,n>>6&63|128,n&63|128);}else if(n<1114112){if((t-=4)<0)break;l.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128);}else throw new Error("Invalid code point")}return l}function mn(e){let t=[];for(let n=0;n<e.length;++n)t.push(e.charCodeAt(n)&255);return t}function yn(e,t){let n,o,u,l=[];for(let c=0;c<e.length&&!((t-=2)<0);++c)n=e.charCodeAt(c),o=n>>8,u=n%256,l.push(u),l.push(o);return l}function dt(e){return r.toByteArray(gn(e))}function Ee(e,t,n,o){let u;for(u=0;u<o&&!(u+n>=t.length||u>=e.length);++u)t[u+n]=e[u];return u}function G(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function Ue(e){return e!==e}let wn=function(){let e="0123456789abcdef",t=new Array(256);for(let n=0;n<16;++n){let o=n*16;for(let u=0;u<16;++u)t[o+u]=e[n]+e[u];}return t}();function K(e){return typeof BigInt>"u"?bn:e}function bn(){throw new Error("BigInt not supported")}return Z}var ie=ei();ie.Buffer;ie.SlowBuffer;ie.INSPECT_MAX_BYTES;ie.kMaxLength;var Bt=ie.Buffer;ie.INSPECT_MAX_BYTES;ie.kMaxLength;var ti={};$n(ti,{deleteItem:()=>si,getItem:()=>qe,setItem:()=>Se});var Ae=()=>typeof window>"u",Ot=()=>!Ae(),ni="__IMX-",Je=()=>Ot()&&window.localStorage,ri=r=>{if(r!==null)try{return JSON.parse(r)}catch{return r}},ii=r=>typeof r=="string"?r:JSON.stringify(r),Xe=r=>`${ni}${r}`;function qe(r){if(Je())return ri(window.localStorage.getItem(Xe(r)))}var Se=(r,i)=>Je()?(window.localStorage.setItem(Xe(r),ii(i)),!0):!1,si=r=>Je()?(window.localStorage.removeItem(Xe(r)),!0):!1,Ve=0,oi=r=>{let i=parseInt(r,10)*1e3,s=new Date(i),f=new Date;return Ve=s.getTime()-f.getTime(),Ve},ai=()=>{let r=new Date().getTime()+Ve;return new Date(r).toISOString()},ui=(r=>(r.RUNTIME_ID="rid",r.PASSPORT_CLIENT_ID="passportClientId",r.ENVIRONMENT="env",r.PUBLISHABLE_API_KEY="pak",r.IDENTITY="uid",r.DOMAIN="domain",r.SDK_VERSION="sdkVersion",r))(ui||{}),li="https://api.immutable.com",fi=r=>{if(typeof Bt<"u")return Bt.from(r,"utf-8").toString("base64");if(typeof btoa=="function")return btoa(unescape(encodeURIComponent(r)));throw new Error("Base64 encoding not supported in this environment")};async function Pt(r,i){let s=JSON.stringify(i),f={payload:fi(s)},h=await fetch(`${li}${r}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)});if(!h.ok){let d=await h.text().catch(()=>"");throw new Error(`Request failed (${h.status}): ${d||h.statusText}`)}return h.json()}var te,ne,hi=()=>{te=qe("metrics-events")||[],ne=qe("metrics-runtime")||{};};hi();var re=(r,i)=>{ne={...ne,[r]:i},Se("metrics-runtime",ne);},Ke=r=>{if(ne[r]!==void 0)return ne[r]},ci=()=>ne,di=()=>te,pi=r=>{te.push(r),Se("metrics-events",te);},gi=r=>{te=te.slice(r),Se("metrics-events",te);},Nt=r=>{let i=[];return Object.entries(r).forEach(([s,f])=>{(typeof s=="string"||typeof f=="string"||typeof f=="number"||typeof f=="boolean")&&i.push([s,f.toString()]);}),i},De="2.20.1-alpha.2",mi=()=>Ae()?"":window.location.ancestorOrigins&&window.location.ancestorOrigins.length>0?new URL(window.location.ancestorOrigins[0]).hostname:document.referrer?new URL(window.document.referrer).hostname:"",yi=()=>{if(Ae())return "";let r;try{window.self!==window.top&&(r=mi());}catch{}return r||(r=window.location.hostname),r},wi=()=>{if(re("sdkVersion",De),Ae())return {browser:"nodejs",sdkVersion:De};let r=yi();return r&&re("domain",r),{sdkVersion:De,browser:window.navigator.userAgent,domain:r,tz:Intl.DateTimeFormat().resolvedOptions().timeZone,screen:`${window.screen.width}x${window.screen.height}`}},ze=!1,bi=()=>ze,vi=async()=>{ze=!0;try{let r=Nt(wi()),i=Ke("rid"),s=Ke("uid"),f=await Pt("/v1/sdk/initialise",{version:1,data:{runtimeDetails:r,runtimeId:i,uId:s}}),{runtimeId:h,sTime:d}=f;re("rid",h),oi(d);}catch{ze=!1;}};function D(r,i){return (...s)=>{try{let f=r(...s);return f instanceof Promise?f.catch(()=>i):f}catch{return i}}}function Ei(){return Ot()||typeof Ge>"u"?!1:Ge.env.JEST_WORKER_ID!==void 0}var Ii=D(Ei,!1),Rt="imtbl__metrics",_i=5e3,Ai=1e3,be=(r,i)=>(0, He.getGlobalisedValue)(Rt,r,i),Si=(r,i)=>{let s=bt(i,{lruOptions:{ttl:_i,max:Ai}});return (0, He.getGlobalisedValue)(Rt,r,s)},xi=5e3,Bi=(r,i,s)=>{let f={event:`${r}.${i}`,time:ai(),...s&&{properties:Nt(s)}};pi(f);},se=D(Si("track",Bi)),Ti=async()=>{if(bi()===!1){await vi();return}let r=di();if(r.length===0)return;let i=r.length,s=ci();await Pt("/v1/sdk/metrics",{version:1,data:{events:r,details:s}})instanceof Error||gi(i);},ki=D(Ti),Ct=async()=>{await ki(),setTimeout(Ct,xi);},Tt=!1,Ui=()=>{Tt||(Tt=!0,Ct());};Ii()||D(be("startFlushing",Ui))();var Mi=(r,i,s,f)=>{let{message:h}=s,d=s.stack||"",{cause:a}=s;a instanceof Error&&(d=`${d}
|
|
1
|
+
var En=Object.create;var gt=Object.defineProperty;var In=Object.getOwnPropertyDescriptor;var _n=Object.getOwnPropertyNames;var An=Object.getPrototypeOf,Sn=Object.prototype.hasOwnProperty;var mt=(r,i)=>()=>(r&&(i=r(r=0)),i);var xn=(r,i)=>()=>(i||r((i={exports:{}}).exports,i),i.exports);var Bn=(r,i,s,f)=>{if(i&&typeof i=="object"||typeof i=="function")for(let h of _n(i))!Sn.call(r,h)&&h!==s&>(r,h,{get:()=>i[h],enumerable:!(f=In(i,h))||f.enumerable});return r};var Tn=(r,i,s)=>(s=r!=null?En(An(r)):{},Bn(gt(s,"default",{value:r,enumerable:!0}),r));var S=mt(()=>{});var x=mt(()=>{});var At=xn(ce=>{x();S();Object.defineProperty(ce,"__esModule",{value:!0});ce.clearGlobalNamespace=ce.getGlobalisedValue=void 0;var On="globalise__singleton__",Pn={},Et=()=>typeof window<"u"?window:typeof globalThis<"u"?globalThis:Pn,Nn=(r,i)=>{if(typeof r!="string")throw "Invalid namespace key";if(typeof i!="string")throw "Invalid item key"},It=r=>`${On}${r}`,_t=r=>{let i=Et(),s=It(r);return i[s]||(i[s]={}),i[s]},Rn=(r,i)=>_t(r)[i]||void 0,Cn=(r,i,s)=>{let f=_t(r);f[i]=s;},Ln=(r,i,s)=>{Nn(r,i);let f=Rn(r,i);return f!==void 0?f:(Cn(r,i,s),s)};ce.getGlobalisedValue=Ln;var Mn=r=>{let i=Et(),s=It(r);i[s]!==void 0&&delete i[s];};ce.clearGlobalNamespace=Mn;});x();S();x();S();x();S();x();S();var Oe="https://api.immutable.com",yt="/v1/audience/messages",wt="/v1/audience/tracking-consent",z="imtbl_anon_id",H="_imtbl_sid",Pe="session_start",Ne="session_end",q=()=>typeof window<"u"&&typeof document<"u",Y=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,r=>{let i=Math.trunc(Math.random()*16);return (r==="x"?i:i%4+8).toString(16)}),Re=()=>new Date().toISOString();function le(r){if(!q())return;let i=document.cookie.match(new RegExp(`(?:^|; )${r}=([^;]*)`));return i?decodeURIComponent(i[1]):void 0}function fe(r,i,s,f){if(!q())return;let h=window.location.protocol==="https:"?"; Secure":"",p=f?`; domain=${f}`:"";document.cookie=`${r}=${encodeURIComponent(i)}; path=/; max-age=${s}; SameSite=Lax${p}${h}`;}function he(r,i){fe(r,"",0,i);}function ye(r){let i=le(z);if(i)return i;let s=Y();return fe(z,s,63072e3,r),s}function Ce(r,i){fe(z,r,63072e3,i);}x();S();x();S();x();S();var Le=class{constructor(i=0,s=0,f=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=i,this.resetTtl=f,this.size=0,this.ttl=s;}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(i){if(this.has(i)){let s=this.items[i];delete this.items[i],this.size--,s.prev!==null&&(s.prev.next=s.next),s.next!==null&&(s.next.prev=s.prev),this.first===s&&(this.first=s.next),this.last===s&&(this.last=s.prev);}return this}entries(i=this.keys()){return i.map(s=>[s,this.get(s)])}evict(i=!1){if(i||this.size>0){let s=this.first;delete this.items[s.key],--this.size===0?(this.first=null,this.last=null):(this.first=s.next,this.first.prev=null);}return this}expiresAt(i){let s;return this.has(i)&&(s=this.items[i].expiry),s}get(i){let s;if(this.has(i)){let f=this.items[i];this.ttl>0&&f.expiry<=Date.now()?this.delete(i):(s=f.value,this.set(i,s,!0));}return s}has(i){return i in this.items}keys(){let i=[],s=this.first;for(;s!==null;)i.push(s.key),s=s.next;return i}set(i,s,f=!1,h=this.resetTtl){let p;if(f||this.has(i)){if(p=this.items[i],p.value=s,f===!1&&h&&(p.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.last!==p){let a=this.last,g=p.next,m=p.prev;this.first===p&&(this.first=p.next),p.next=null,p.prev=this.last,a.next=p,m!==null&&(m.next=g),g!==null&&(g.prev=m);}}else this.max>0&&this.size===this.max&&this.evict(!0),p=this.items[i]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:i,prev:this.last,next:null,value:s},++this.size===1?this.first=p:this.last.next=p;return this.last=p,this}values(i=this.keys()){return i.map(s=>this.get(s))}};function vt(r=1e3,i=0,s=!1){if(isNaN(r)||r<0)throw new TypeError("Invalid max value");if(isNaN(i)||i<0)throw new TypeError("Invalid ttl value");if(typeof s!="boolean")throw new TypeError("Invalid resetTtl value");return new Le(r,i,s)}var kn={max:1e3},bt=(r,i={})=>{let{cache:s,cacheKeyResolver:f=Me,onHit:h,lruOptions:p={}}=i,a={...kn,...p},g=s||vt(a.max,a.ttl);function m(...v){let b=f(...v),w=g.get(b);if(g.has(b))return h&&h(b,w,g),w;let d=r.apply(this,v);return g.set(b,d),d}return m._cache=g,m},Me=(...r)=>r.length===0?"no-args":r.map(i=>i===void 0?"undefined":i===null?"null":Array.isArray(i)?`[${Me(...i)}]`:typeof i=="object"?`{${Me(...Un(i))}}`:JSON.stringify(i)).join(","),Un=r=>Object.entries(r).sort((i,s)=>i[0]<s[0]?-1:1);var He=Tn(At()),$n=Object.defineProperty,Dn=(r,i)=>{for(var s in i)$n(r,s,{get:i[s],enumerable:!0});};function Ye(r){throw new Error("Node.js process "+r+" is not supported by JSPM core outside of Node.js")}var V=[],pe=!1,ee,_e=-1;function Fn(){!pe||!ee||(pe=!1,ee.length?V=ee.concat(V):_e=-1,V.length&&Ut());}function Ut(){if(!pe){var r=setTimeout(Fn,0);pe=!0;for(var i=V.length;i;){for(ee=V,V=[];++_e<i;)ee&&ee[_e].run();_e=-1,i=V.length;}ee=null,pe=!1,clearTimeout(r);}}function jn(r){var i=new Array(arguments.length-1);if(arguments.length>1)for(var s=1;s<arguments.length;s++)i[s-1]=arguments[s];V.push(new Ot(r,i)),V.length===1&&!pe&&setTimeout(Ut,0);}function Ot(r,i){this.fun=r,this.array=i;}Ot.prototype.run=function(){this.fun.apply(null,this.array);};var Gn="browser",qn="x64",Vn="browser",Kn={PATH:"/usr/bin",LANG:navigator.language+".UTF-8",PWD:"/",HOME:"/home",TMP:"/tmp"},zn=["/usr/bin/node"],Hn=[],Yn="v16.8.0",Wn={},Jn=function(r,i){console.warn((i?i+": ":"")+r);},Xn=function(r){Ye("binding");},Qn=function(r){return 0},Zn=function(){return "/"},er=function(r){},tr={name:"node",sourceUrl:"",headersUrl:"",libUrl:""};function R(){}var nr=R,rr=[];function ir(r){Ye("_linkedBinding");}var sr={},or=!1,ar={};function ur(r){Ye("dlopen");}function lr(){return []}function fr(){return []}var hr=R,cr=R,We=function(){return {}},pr=We,dr=We,gr=R,mr=R,yr=R,wr={};function vr(r,i){if(!r)throw new Error(i||"assertion error")}var br={inspector:!1,debug:!1,uv:!1,ipv6:!1,tls_alpn:!1,tls_sni:!1,tls_ocsp:!1,tls:!1,cached_builtins:!0},Er=R,Ir=R;function _r(){return !1}var Ar=R,Sr=R,xr=R,Br=R,Tr=R,kr=void 0,Ur=void 0,Or=void 0,Pr=R,Nr=2,Rr=1,Cr="/bin/usr/node",Lr=9229,Mr="node",$r=[],Dr=R,W={now:typeof performance<"u"?performance.now.bind(performance):void 0,timing:typeof performance<"u"?performance.timing:void 0};W.now===void 0&&($e=Date.now(),W.timing&&W.timing.navigationStart&&($e=W.timing.navigationStart),W.now=()=>Date.now()-$e);var $e;function Fr(){return W.now()/1e3}var Fe=1e9;function je(r){var i=Math.floor((Date.now()-W.now())*.001),s=W.now()*.001,f=Math.floor(s)+i,h=Math.floor(s%1*1e9);return r&&(f=f-r[0],h=h-r[1],h<0&&(f--,h+=Fe)),[f,h]}je.bigint=function(r){var i=je(r);return typeof BigInt>"u"?i[0]*Fe+i[1]:BigInt(i[0]*Fe)+BigInt(i[1])};var jr=10,Gr={},qr=0;function J(){return Ge}var Vr=J,Kr=J,zr=J,Hr=J,Yr=J,Wr=R,Jr=J,Xr=J;function Qr(r){return []}var Ge={version:Yn,versions:Wn,arch:qn,platform:Vn,release:tr,_rawDebug:nr,moduleLoadList:rr,binding:Xn,_linkedBinding:ir,_events:Gr,_eventsCount:qr,_maxListeners:jr,on:J,addListener:Vr,once:Kr,off:zr,removeListener:Hr,removeAllListeners:Yr,emit:Wr,prependListener:Jr,prependOnceListener:Xr,listeners:Qr,domain:sr,_exiting:or,config:ar,dlopen:ur,uptime:Fr,_getActiveRequests:lr,_getActiveHandles:fr,reallyExit:hr,_kill:cr,cpuUsage:We,resourceUsage:pr,memoryUsage:dr,kill:gr,exit:mr,openStdin:yr,allowedNodeEnvironmentFlags:wr,assert:vr,features:br,_fatalExceptions:Er,setUncaughtExceptionCaptureCallback:Ir,hasUncaughtExceptionCaptureCallback:_r,emitWarning:Jn,nextTick:jn,_tickCallback:Ar,_debugProcess:Sr,_debugEnd:xr,_startProfilerIdleNotifier:Br,_stopProfilerIdleNotifier:Tr,stdout:kr,stdin:Or,stderr:Ur,abort:Pr,umask:Qn,chdir:er,cwd:Zn,env:Kn,title:Gn,argv:zn,execArgv:Hn,pid:Nr,ppid:Rr,execPath:Cr,debugPort:Lr,hrtime:je,argv0:Mr,_preload_modules:$r,setSourceMapsEnabled:Dr},we={},St=!1;function Zr(){if(St)return we;St=!0,we.byteLength=g,we.toByteArray=v,we.fromByteArray=E;for(var r=[],i=[],s=typeof Uint8Array<"u"?Uint8Array:Array,f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",h=0,p=f.length;h<p;++h)r[h]=f[h],i[f.charCodeAt(h)]=h;i[45]=62,i[95]=63;function a(d){var y=d.length;if(y%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var I=d.indexOf("=");I===-1&&(I=y);var T=I===y?0:4-I%4;return [I,T]}function g(d){var y=a(d),I=y[0],T=y[1];return (I+T)*3/4-T}function m(d,y,I){return (y+I)*3/4-I}function v(d){var y,I=a(d),T=I[0],N=I[1],k=new s(m(d,T,N)),L=0,$=N>0?T-4:T,C;for(C=0;C<$;C+=4)y=i[d.charCodeAt(C)]<<18|i[d.charCodeAt(C+1)]<<12|i[d.charCodeAt(C+2)]<<6|i[d.charCodeAt(C+3)],k[L++]=y>>16&255,k[L++]=y>>8&255,k[L++]=y&255;return N===2&&(y=i[d.charCodeAt(C)]<<2|i[d.charCodeAt(C+1)]>>4,k[L++]=y&255),N===1&&(y=i[d.charCodeAt(C)]<<10|i[d.charCodeAt(C+1)]<<4|i[d.charCodeAt(C+2)]>>2,k[L++]=y>>8&255,k[L++]=y&255),k}function b(d){return r[d>>18&63]+r[d>>12&63]+r[d>>6&63]+r[d&63]}function w(d,y,I){for(var T,N=[],k=y;k<I;k+=3)T=(d[k]<<16&16711680)+(d[k+1]<<8&65280)+(d[k+2]&255),N.push(b(T));return N.join("")}function E(d){for(var y,I=d.length,T=I%3,N=[],k=16383,L=0,$=I-T;L<$;L+=k)N.push(w(d,L,L+k>$?$:L+k));return T===1?(y=d[I-1],N.push(r[y>>2]+r[y<<4&63]+"==")):T===2&&(y=(d[I-2]<<8)+d[I-1],N.push(r[y>>10]+r[y>>4&63]+r[y<<2&63]+"=")),N.join("")}return we}var Ie={},xt=!1;function ei(){return xt?Ie:(xt=!0,Ie.read=function(r,i,s,f,h){var p,a,g=h*8-f-1,m=(1<<g)-1,v=m>>1,b=-7,w=s?h-1:0,E=s?-1:1,d=r[i+w];for(w+=E,p=d&(1<<-b)-1,d>>=-b,b+=g;b>0;p=p*256+r[i+w],w+=E,b-=8);for(a=p&(1<<-b)-1,p>>=-b,b+=f;b>0;a=a*256+r[i+w],w+=E,b-=8);if(p===0)p=1-v;else {if(p===m)return a?NaN:(d?-1:1)*(1/0);a=a+Math.pow(2,f),p=p-v;}return (d?-1:1)*a*Math.pow(2,p-f)},Ie.write=function(r,i,s,f,h,p){var a,g,m,v=p*8-h-1,b=(1<<v)-1,w=b>>1,E=h===23?Math.pow(2,-24)-Math.pow(2,-77):0,d=f?0:p-1,y=f?1:-1,I=i<0||i===0&&1/i<0?1:0;for(i=Math.abs(i),isNaN(i)||i===1/0?(g=isNaN(i)?1:0,a=b):(a=Math.floor(Math.log(i)/Math.LN2),i*(m=Math.pow(2,-a))<1&&(a--,m*=2),a+w>=1?i+=E/m:i+=E*Math.pow(2,1-w),i*m>=2&&(a++,m/=2),a+w>=b?(g=0,a=b):a+w>=1?(g=(i*m-1)*Math.pow(2,h),a=a+w):(g=i*Math.pow(2,w-1)*Math.pow(2,h),a=0));h>=8;r[s+d]=g&255,d+=y,g/=256,h-=8);for(a=a<<h|g,v+=h;v>0;r[s+d]=a&255,d+=y,a/=256,v-=8);r[s+d-y]|=I*128;},Ie)}var Z={},Bt=!1;function ti(){if(Bt)return Z;Bt=!0;let r=Zr(),i=ei(),s=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;Z.Buffer=a,Z.SlowBuffer=N,Z.INSPECT_MAX_BYTES=50;let f=2147483647;Z.kMaxLength=f,a.TYPED_ARRAY_SUPPORT=h(),!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function h(){try{let e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return !1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function p(e){if(e>f)throw new RangeError('The value "'+e+'" is invalid for option "size"');let t=new Uint8Array(e);return Object.setPrototypeOf(t,a.prototype),t}function a(e,t,n){if(typeof e=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return b(e)}return g(e,t,n)}a.poolSize=8192;function g(e,t,n){if(typeof e=="string")return w(e,t);if(ArrayBuffer.isView(e))return d(e);if(e==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(G(e,ArrayBuffer)||e&&G(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(G(e,SharedArrayBuffer)||e&&G(e.buffer,SharedArrayBuffer)))return y(e,t,n);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let o=e.valueOf&&e.valueOf();if(o!=null&&o!==e)return a.from(o,t,n);let u=I(e);if(u)return u;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return a.from(e[Symbol.toPrimitive]("string"),t,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}a.from=function(e,t,n){return g(e,t,n)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function m(e){if(typeof e!="number")throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function v(e,t,n){return m(e),e<=0?p(e):t!==void 0?typeof n=="string"?p(e).fill(t,n):p(e).fill(t):p(e)}a.alloc=function(e,t,n){return v(e,t,n)};function b(e){return m(e),p(e<0?0:T(e)|0)}a.allocUnsafe=function(e){return b(e)},a.allocUnsafeSlow=function(e){return b(e)};function w(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!a.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let n=k(e,t)|0,o=p(n),u=o.write(e,t);return u!==n&&(o=o.slice(0,u)),o}function E(e){let t=e.length<0?0:T(e.length)|0,n=p(t);for(let o=0;o<t;o+=1)n[o]=e[o]&255;return n}function d(e){if(G(e,Uint8Array)){let t=new Uint8Array(e);return y(t.buffer,t.byteOffset,t.byteLength)}return E(e)}function y(e,t,n){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(n||0))throw new RangeError('"length" is outside of buffer bounds');let o;return t===void 0&&n===void 0?o=new Uint8Array(e):n===void 0?o=new Uint8Array(e,t):o=new Uint8Array(e,t,n),Object.setPrototypeOf(o,a.prototype),o}function I(e){if(a.isBuffer(e)){let t=T(e.length)|0,n=p(t);return n.length===0||e.copy(n,0,0,t),n}if(e.length!==void 0)return typeof e.length!="number"||Ue(e.length)?p(0):E(e);if(e.type==="Buffer"&&Array.isArray(e.data))return E(e.data)}function T(e){if(e>=f)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+f.toString(16)+" bytes");return e|0}function N(e){return +e!=e&&(e=0),a.alloc(+e)}a.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==a.prototype},a.compare=function(e,t){if(G(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),G(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(e)||!a.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let n=e.length,o=t.length;for(let u=0,l=Math.min(n,o);u<l;++u)if(e[u]!==t[u]){n=e[u],o=t[u];break}return n<o?-1:o<n?1:0},a.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return !0;default:return !1}},a.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return a.alloc(0);let n;if(t===void 0)for(t=0,n=0;n<e.length;++n)t+=e[n].length;let o=a.allocUnsafe(t),u=0;for(n=0;n<e.length;++n){let l=e[n];if(G(l,Uint8Array))u+l.length>o.length?(a.isBuffer(l)||(l=a.from(l)),l.copy(o,u)):Uint8Array.prototype.set.call(o,l,u);else if(a.isBuffer(l))l.copy(o,u);else throw new TypeError('"list" argument must be an Array of Buffers');u+=l.length;}return o};function k(e,t){if(a.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||G(e,ArrayBuffer))return e.byteLength;if(typeof e!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);let n=e.length,o=arguments.length>2&&arguments[2]===!0;if(!o&&n===0)return 0;let u=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return ke(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return n*2;case"hex":return n>>>1;case"base64":return dt(e).length;default:if(u)return o?-1:ke(e).length;t=(""+t).toLowerCase(),u=!0;}}a.byteLength=k;function L(e,t,n){let o=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,t>>>=0,n<=t))return "";for(e||(e="utf8");;)switch(e){case"hex":return cn(this,t,n);case"utf8":case"utf-8":return st(this,t,n);case"ascii":return fn(this,t,n);case"latin1":case"binary":return hn(this,t,n);case"base64":return un(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pn(this,t,n);default:if(o)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),o=!0;}}a.prototype._isBuffer=!0;function $(e,t,n){let o=e[t];e[t]=e[n],e[n]=o;}a.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)$(this,t,t+1);return this},a.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)$(this,t,t+3),$(this,t+1,t+2);return this},a.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)$(this,t,t+7),$(this,t+1,t+6),$(this,t+2,t+5),$(this,t+3,t+4);return this},a.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?st(this,0,e):L.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(e){if(!a.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:a.compare(this,e)===0},a.prototype.inspect=function(){let e="",t=Z.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"},s&&(a.prototype[s]=a.prototype.inspect),a.prototype.compare=function(e,t,n,o,u){if(G(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(t===void 0&&(t=0),n===void 0&&(n=e?e.length:0),o===void 0&&(o=0),u===void 0&&(u=this.length),t<0||n>e.length||o<0||u>this.length)throw new RangeError("out of range index");if(o>=u&&t>=n)return 0;if(o>=u)return -1;if(t>=n)return 1;if(t>>>=0,n>>>=0,o>>>=0,u>>>=0,this===e)return 0;let l=u-o,c=n-t,A=Math.min(l,c),P=this.slice(o,u),B=e.slice(t,n);for(let _=0;_<A;++_)if(P[_]!==B[_]){l=P[_],c=B[_];break}return l<c?-1:c<l?1:0};function C(e,t,n,o,u){if(e.length===0)return -1;if(typeof n=="string"?(o=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,Ue(n)&&(n=u?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(u)return -1;n=e.length-1;}else if(n<0)if(u)n=0;else return -1;if(typeof t=="string"&&(t=a.from(t,o)),a.isBuffer(t))return t.length===0?-1:it(e,t,n,o,u);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?u?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):it(e,[t],n,o,u);throw new TypeError("val must be string, number or Buffer")}function it(e,t,n,o,u){let l=1,c=e.length,A=t.length;if(o!==void 0&&(o=String(o).toLowerCase(),o==="ucs2"||o==="ucs-2"||o==="utf16le"||o==="utf-16le")){if(e.length<2||t.length<2)return -1;l=2,c/=2,A/=2,n/=2;}function P(_,U){return l===1?_[U]:_.readUInt16BE(U*l)}let B;if(u){let _=-1;for(B=n;B<c;B++)if(P(e,B)===P(t,_===-1?0:B-_)){if(_===-1&&(_=B),B-_+1===A)return _*l}else _!==-1&&(B-=B-_),_=-1;}else for(n+A>c&&(n=c-A),B=n;B>=0;B--){let _=!0;for(let U=0;U<A;U++)if(P(e,B+U)!==P(t,U)){_=!1;break}if(_)return B}return -1}a.prototype.includes=function(e,t,n){return this.indexOf(e,t,n)!==-1},a.prototype.indexOf=function(e,t,n){return C(this,e,t,n,!0)},a.prototype.lastIndexOf=function(e,t,n){return C(this,e,t,n,!1)};function nn(e,t,n,o){n=Number(n)||0;let u=e.length-n;o?(o=Number(o),o>u&&(o=u)):o=u;let l=t.length;o>l/2&&(o=l/2);let c;for(c=0;c<o;++c){let A=parseInt(t.substr(c*2,2),16);if(Ue(A))return c;e[n+c]=A;}return c}function rn(e,t,n,o){return Ee(ke(t,e.length-n),e,n,o)}function sn(e,t,n,o){return Ee(yn(t),e,n,o)}function on(e,t,n,o){return Ee(dt(t),e,n,o)}function an(e,t,n,o){return Ee(wn(t,e.length-n),e,n,o)}a.prototype.write=function(e,t,n,o){if(t===void 0)o="utf8",n=this.length,t=0;else if(n===void 0&&typeof t=="string")o=t,n=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(n)?(n=n>>>0,o===void 0&&(o="utf8")):(o=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let u=this.length-t;if((n===void 0||n>u)&&(n=u),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");o||(o="utf8");let l=!1;for(;;)switch(o){case"hex":return nn(this,e,t,n);case"utf8":case"utf-8":return rn(this,e,t,n);case"ascii":case"latin1":case"binary":return sn(this,e,t,n);case"base64":return on(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return an(this,e,t,n);default:if(l)throw new TypeError("Unknown encoding: "+o);o=(""+o).toLowerCase(),l=!0;}},a.prototype.toJSON=function(){return {type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function un(e,t,n){return t===0&&n===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,n))}function st(e,t,n){n=Math.min(e.length,n);let o=[],u=t;for(;u<n;){let l=e[u],c=null,A=l>239?4:l>223?3:l>191?2:1;if(u+A<=n){let P,B,_,U;switch(A){case 1:l<128&&(c=l);break;case 2:P=e[u+1],(P&192)===128&&(U=(l&31)<<6|P&63,U>127&&(c=U));break;case 3:P=e[u+1],B=e[u+2],(P&192)===128&&(B&192)===128&&(U=(l&15)<<12|(P&63)<<6|B&63,U>2047&&(U<55296||U>57343)&&(c=U));break;case 4:P=e[u+1],B=e[u+2],_=e[u+3],(P&192)===128&&(B&192)===128&&(_&192)===128&&(U=(l&15)<<18|(P&63)<<12|(B&63)<<6|_&63,U>65535&&U<1114112&&(c=U));}}c===null?(c=65533,A=1):c>65535&&(c-=65536,o.push(c>>>10&1023|55296),c=56320|c&1023),o.push(c),u+=A;}return ln(o)}let ot=4096;function ln(e){let t=e.length;if(t<=ot)return String.fromCharCode.apply(String,e);let n="",o=0;for(;o<t;)n+=String.fromCharCode.apply(String,e.slice(o,o+=ot));return n}function fn(e,t,n){let o="";n=Math.min(e.length,n);for(let u=t;u<n;++u)o+=String.fromCharCode(e[u]&127);return o}function hn(e,t,n){let o="";n=Math.min(e.length,n);for(let u=t;u<n;++u)o+=String.fromCharCode(e[u]);return o}function cn(e,t,n){let o=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>o)&&(n=o);let u="";for(let l=t;l<n;++l)u+=vn[e[l]];return u}function pn(e,t,n){let o=e.slice(t,n),u="";for(let l=0;l<o.length-1;l+=2)u+=String.fromCharCode(o[l]+o[l+1]*256);return u}a.prototype.slice=function(e,t){let n=this.length;e=~~e,t=t===void 0?n:~~t,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<e&&(t=e);let o=this.subarray(e,t);return Object.setPrototypeOf(o,a.prototype),o};function O(e,t,n){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||O(e,t,this.length);let o=this[e],u=1,l=0;for(;++l<t&&(u*=256);)o+=this[e+l]*u;return o},a.prototype.readUintBE=a.prototype.readUIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||O(e,t,this.length);let o=this[e+--t],u=1;for(;t>0&&(u*=256);)o+=this[e+--t]*u;return o},a.prototype.readUint8=a.prototype.readUInt8=function(e,t){return e=e>>>0,t||O(e,1,this.length),this[e]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(e,t){return e=e>>>0,t||O(e,2,this.length),this[e]|this[e+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(e,t){return e=e>>>0,t||O(e,2,this.length),this[e]<<8|this[e+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(e,t){return e=e>>>0,t||O(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(e,t){return e=e>>>0,t||O(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])},a.prototype.readBigUInt64LE=K(function(e){e=e>>>0,ue(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&me(e,this.length-8);let o=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,u=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(o)+(BigInt(u)<<BigInt(32))}),a.prototype.readBigUInt64BE=K(function(e){e=e>>>0,ue(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&me(e,this.length-8);let o=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],u=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return (BigInt(o)<<BigInt(32))+BigInt(u)}),a.prototype.readIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||O(e,t,this.length);let o=this[e],u=1,l=0;for(;++l<t&&(u*=256);)o+=this[e+l]*u;return u*=128,o>=u&&(o-=Math.pow(2,8*t)),o},a.prototype.readIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||O(e,t,this.length);let o=t,u=1,l=this[e+--o];for(;o>0&&(u*=256);)l+=this[e+--o]*u;return u*=128,l>=u&&(l-=Math.pow(2,8*t)),l},a.prototype.readInt8=function(e,t){return e=e>>>0,t||O(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]},a.prototype.readInt16LE=function(e,t){e=e>>>0,t||O(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n},a.prototype.readInt16BE=function(e,t){e=e>>>0,t||O(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n},a.prototype.readInt32LE=function(e,t){return e=e>>>0,t||O(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},a.prototype.readInt32BE=function(e,t){return e=e>>>0,t||O(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},a.prototype.readBigInt64LE=K(function(e){e=e>>>0,ue(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&me(e,this.length-8);let o=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return (BigInt(o)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)}),a.prototype.readBigInt64BE=K(function(e){e=e>>>0,ue(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&me(e,this.length-8);let o=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return (BigInt(o)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)}),a.prototype.readFloatLE=function(e,t){return e=e>>>0,t||O(e,4,this.length),i.read(this,e,!0,23,4)},a.prototype.readFloatBE=function(e,t){return e=e>>>0,t||O(e,4,this.length),i.read(this,e,!1,23,4)},a.prototype.readDoubleLE=function(e,t){return e=e>>>0,t||O(e,8,this.length),i.read(this,e,!0,52,8)},a.prototype.readDoubleBE=function(e,t){return e=e>>>0,t||O(e,8,this.length),i.read(this,e,!1,52,8)};function M(e,t,n,o,u,l){if(!a.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>u||t<l)throw new RangeError('"value" argument is out of bounds');if(n+o>e.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(e,t,n,o){if(e=+e,t=t>>>0,n=n>>>0,!o){let c=Math.pow(2,8*n)-1;M(this,e,t,n,c,0);}let u=1,l=0;for(this[t]=e&255;++l<n&&(u*=256);)this[t+l]=e/u&255;return t+n},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(e,t,n,o){if(e=+e,t=t>>>0,n=n>>>0,!o){let c=Math.pow(2,8*n)-1;M(this,e,t,n,c,0);}let u=n-1,l=1;for(this[t+u]=e&255;--u>=0&&(l*=256);)this[t+u]=e/l&255;return t+n},a.prototype.writeUint8=a.prototype.writeUInt8=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,1,255,0),this[t]=e&255,t+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function at(e,t,n,o,u){pt(t,o,u,e,n,7);let l=Number(t&BigInt(4294967295));e[n++]=l,l=l>>8,e[n++]=l,l=l>>8,e[n++]=l,l=l>>8,e[n++]=l;let c=Number(t>>BigInt(32)&BigInt(4294967295));return e[n++]=c,c=c>>8,e[n++]=c,c=c>>8,e[n++]=c,c=c>>8,e[n++]=c,n}function ut(e,t,n,o,u){pt(t,o,u,e,n,7);let l=Number(t&BigInt(4294967295));e[n+7]=l,l=l>>8,e[n+6]=l,l=l>>8,e[n+5]=l,l=l>>8,e[n+4]=l;let c=Number(t>>BigInt(32)&BigInt(4294967295));return e[n+3]=c,c=c>>8,e[n+2]=c,c=c>>8,e[n+1]=c,c=c>>8,e[n]=c,n+8}a.prototype.writeBigUInt64LE=K(function(e,t=0){return at(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=K(function(e,t=0){return ut(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(e,t,n,o){if(e=+e,t=t>>>0,!o){let A=Math.pow(2,8*n-1);M(this,e,t,n,A-1,-A);}let u=0,l=1,c=0;for(this[t]=e&255;++u<n&&(l*=256);)e<0&&c===0&&this[t+u-1]!==0&&(c=1),this[t+u]=(e/l>>0)-c&255;return t+n},a.prototype.writeIntBE=function(e,t,n,o){if(e=+e,t=t>>>0,!o){let A=Math.pow(2,8*n-1);M(this,e,t,n,A-1,-A);}let u=n-1,l=1,c=0;for(this[t+u]=e&255;--u>=0&&(l*=256);)e<0&&c===0&&this[t+u+1]!==0&&(c=1),this[t+u]=(e/l>>0)-c&255;return t+n},a.prototype.writeInt8=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1},a.prototype.writeInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2},a.prototype.writeInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2},a.prototype.writeInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},a.prototype.writeInt32BE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4},a.prototype.writeBigInt64LE=K(function(e,t=0){return at(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=K(function(e,t=0){return ut(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function lt(e,t,n,o,u,l){if(n+o>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function ft(e,t,n,o,u){return t=+t,n=n>>>0,u||lt(e,t,n,4),i.write(e,t,n,o,23,4),n+4}a.prototype.writeFloatLE=function(e,t,n){return ft(this,e,t,!0,n)},a.prototype.writeFloatBE=function(e,t,n){return ft(this,e,t,!1,n)};function ht(e,t,n,o,u){return t=+t,n=n>>>0,u||lt(e,t,n,8),i.write(e,t,n,o,52,8),n+8}a.prototype.writeDoubleLE=function(e,t,n){return ht(this,e,t,!0,n)},a.prototype.writeDoubleBE=function(e,t,n){return ht(this,e,t,!1,n)},a.prototype.copy=function(e,t,n,o){if(!a.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!o&&o!==0&&(o=this.length),t>=e.length&&(t=e.length),t||(t=0),o>0&&o<n&&(o=n),o===n||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),e.length-t<o-n&&(o=e.length-t+n);let u=o-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,n,o):Uint8Array.prototype.set.call(e,this.subarray(n,o),t),u},a.prototype.fill=function(e,t,n,o){if(typeof e=="string"){if(typeof t=="string"?(o=t,t=0,n=this.length):typeof n=="string"&&(o=n,n=this.length),o!==void 0&&typeof o!="string")throw new TypeError("encoding must be a string");if(typeof o=="string"&&!a.isEncoding(o))throw new TypeError("Unknown encoding: "+o);if(e.length===1){let l=e.charCodeAt(0);(o==="utf8"&&l<128||o==="latin1")&&(e=l);}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;t=t>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let u;if(typeof e=="number")for(u=t;u<n;++u)this[u]=e;else {let l=a.isBuffer(e)?e:a.from(e,o),c=l.length;if(c===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(u=0;u<n-t;++u)this[u+t]=l[u%c];}return this};let ae={};function Te(e,t,n){ae[e]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name;}get code(){return e}set code(o){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:o,writable:!0});}toString(){return `${this.name} [${e}]: ${this.message}`}};}Te("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Te("ERR_INVALID_ARG_TYPE",function(e,t){return `The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError),Te("ERR_OUT_OF_RANGE",function(e,t,n){let o=`The value of "${e}" is out of range.`,u=n;return Number.isInteger(n)&&Math.abs(n)>2**32?u=ct(String(n)):typeof n=="bigint"&&(u=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(u=ct(u)),u+="n"),o+=` It must be ${t}. Received ${u}`,o},RangeError);function ct(e){let t="",n=e.length,o=e[0]==="-"?1:0;for(;n>=o+4;n-=3)t=`_${e.slice(n-3,n)}${t}`;return `${e.slice(0,n)}${t}`}function dn(e,t,n){ue(t,"offset"),(e[t]===void 0||e[t+n]===void 0)&&me(t,e.length-(n+1));}function pt(e,t,n,o,u,l){if(e>n||e<t){let c=typeof t=="bigint"?"n":"",A;throw t===0||t===BigInt(0)?A=`>= 0${c} and < 2${c} ** ${(l+1)*8}${c}`:A=`>= -(2${c} ** ${(l+1)*8-1}${c}) and < 2 ** ${(l+1)*8-1}${c}`,new ae.ERR_OUT_OF_RANGE("value",A,e)}dn(o,u,l);}function ue(e,t){if(typeof e!="number")throw new ae.ERR_INVALID_ARG_TYPE(t,"number",e)}function me(e,t,n){throw Math.floor(e)!==e?(ue(e,n),new ae.ERR_OUT_OF_RANGE("offset","an integer",e)):t<0?new ae.ERR_BUFFER_OUT_OF_BOUNDS:new ae.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${t}`,e)}let gn=/[^+/0-9A-Za-z-_]/g;function mn(e){if(e=e.split("=")[0],e=e.trim().replace(gn,""),e.length<2)return "";for(;e.length%4!==0;)e=e+"=";return e}function ke(e,t){t=t||1/0;let n,o=e.length,u=null,l=[];for(let c=0;c<o;++c){if(n=e.charCodeAt(c),n>55295&&n<57344){if(!u){if(n>56319){(t-=3)>-1&&l.push(239,191,189);continue}else if(c+1===o){(t-=3)>-1&&l.push(239,191,189);continue}u=n;continue}if(n<56320){(t-=3)>-1&&l.push(239,191,189),u=n;continue}n=(u-55296<<10|n-56320)+65536;}else u&&(t-=3)>-1&&l.push(239,191,189);if(u=null,n<128){if((t-=1)<0)break;l.push(n);}else if(n<2048){if((t-=2)<0)break;l.push(n>>6|192,n&63|128);}else if(n<65536){if((t-=3)<0)break;l.push(n>>12|224,n>>6&63|128,n&63|128);}else if(n<1114112){if((t-=4)<0)break;l.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128);}else throw new Error("Invalid code point")}return l}function yn(e){let t=[];for(let n=0;n<e.length;++n)t.push(e.charCodeAt(n)&255);return t}function wn(e,t){let n,o,u,l=[];for(let c=0;c<e.length&&!((t-=2)<0);++c)n=e.charCodeAt(c),o=n>>8,u=n%256,l.push(u),l.push(o);return l}function dt(e){return r.toByteArray(mn(e))}function Ee(e,t,n,o){let u;for(u=0;u<o&&!(u+n>=t.length||u>=e.length);++u)t[u+n]=e[u];return u}function G(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function Ue(e){return e!==e}let vn=function(){let e="0123456789abcdef",t=new Array(256);for(let n=0;n<16;++n){let o=n*16;for(let u=0;u<16;++u)t[o+u]=e[n]+e[u];}return t}();function K(e){return typeof BigInt>"u"?bn:e}function bn(){throw new Error("BigInt not supported")}return Z}var ie=ti();ie.Buffer;ie.SlowBuffer;ie.INSPECT_MAX_BYTES;ie.kMaxLength;var Tt=ie.Buffer;ie.INSPECT_MAX_BYTES;ie.kMaxLength;var ni={};Dn(ni,{deleteItem:()=>oi,getItem:()=>qe,setItem:()=>Se});var Ae=()=>typeof window>"u",Pt=()=>!Ae(),ri="__IMX-",Je=()=>Pt()&&window.localStorage,ii=r=>{if(r!==null)try{return JSON.parse(r)}catch{return r}},si=r=>typeof r=="string"?r:JSON.stringify(r),Xe=r=>`${ri}${r}`;function qe(r){if(Je())return ii(window.localStorage.getItem(Xe(r)))}var Se=(r,i)=>Je()?(window.localStorage.setItem(Xe(r),si(i)),!0):!1,oi=r=>Je()?(window.localStorage.removeItem(Xe(r)),!0):!1,Ve=0,ai=r=>{let i=parseInt(r,10)*1e3,s=new Date(i),f=new Date;return Ve=s.getTime()-f.getTime(),Ve},ui=()=>{let r=new Date().getTime()+Ve;return new Date(r).toISOString()},li=(r=>(r.RUNTIME_ID="rid",r.PASSPORT_CLIENT_ID="passportClientId",r.ENVIRONMENT="env",r.PUBLISHABLE_API_KEY="pak",r.IDENTITY="uid",r.DOMAIN="domain",r.SDK_VERSION="sdkVersion",r))(li||{}),fi="https://api.immutable.com",hi=r=>{if(typeof Tt<"u")return Tt.from(r,"utf-8").toString("base64");if(typeof btoa=="function")return btoa(unescape(encodeURIComponent(r)));throw new Error("Base64 encoding not supported in this environment")};async function Nt(r,i){let s=JSON.stringify(i),f={payload:hi(s)},h=await fetch(`${fi}${r}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)});if(!h.ok){let p=await h.text().catch(()=>"");throw new Error(`Request failed (${h.status}): ${p||h.statusText}`)}return h.json()}var te,ne,ci=()=>{te=qe("metrics-events")||[],ne=qe("metrics-runtime")||{};};ci();var re=(r,i)=>{ne={...ne,[r]:i},Se("metrics-runtime",ne);},Ke=r=>{if(ne[r]!==void 0)return ne[r]},pi=()=>ne,di=()=>te,gi=r=>{te.push(r),Se("metrics-events",te);},mi=r=>{te=te.slice(r),Se("metrics-events",te);},Rt=r=>{let i=[];return Object.entries(r).forEach(([s,f])=>{(typeof s=="string"||typeof f=="string"||typeof f=="number"||typeof f=="boolean")&&i.push([s,f.toString()]);}),i},De="2.20.1",yi=()=>Ae()?"":window.location.ancestorOrigins&&window.location.ancestorOrigins.length>0?new URL(window.location.ancestorOrigins[0]).hostname:document.referrer?new URL(window.document.referrer).hostname:"",wi=()=>{if(Ae())return "";let r;try{window.self!==window.top&&(r=yi());}catch{}return r||(r=window.location.hostname),r},vi=()=>{if(re("sdkVersion",De),Ae())return {browser:"nodejs",sdkVersion:De};let r=wi();return r&&re("domain",r),{sdkVersion:De,browser:window.navigator.userAgent,domain:r,tz:Intl.DateTimeFormat().resolvedOptions().timeZone,screen:`${window.screen.width}x${window.screen.height}`}},ze=!1,bi=()=>ze,Ei=async()=>{ze=!0;try{let r=Rt(vi()),i=Ke("rid"),s=Ke("uid"),f=await Nt("/v1/sdk/initialise",{version:1,data:{runtimeDetails:r,runtimeId:i,uId:s}}),{runtimeId:h,sTime:p}=f;re("rid",h),ai(p);}catch{ze=!1;}};function D(r,i){return (...s)=>{try{let f=r(...s);return f instanceof Promise?f.catch(()=>i):f}catch{return i}}}function Ii(){return Pt()||typeof Ge>"u"?!1:Ge.env.JEST_WORKER_ID!==void 0}var _i=D(Ii,!1),Ct="imtbl__metrics",Ai=5e3,Si=1e3,ve=(r,i)=>(0, He.getGlobalisedValue)(Ct,r,i),xi=(r,i)=>{let s=bt(i,{lruOptions:{ttl:Ai,max:Si}});return (0, He.getGlobalisedValue)(Ct,r,s)},Bi=5e3,Ti=(r,i,s)=>{let f={event:`${r}.${i}`,time:ui(),...s&&{properties:Rt(s)}};gi(f);},se=D(xi("track",Ti)),ki=async()=>{if(bi()===!1){await Ei();return}let r=di();if(r.length===0)return;let i=r.length,s=pi();await Nt("/v1/sdk/metrics",{version:1,data:{events:r,details:s}})instanceof Error||mi(i);},Ui=D(ki),Lt=async()=>{await Ui(),setTimeout(Lt,Bi);},kt=!1,Oi=()=>{kt||(kt=!0,Lt());};_i()||D(ve("startFlushing",Oi))();var $i=(r,i,s,f)=>{let{message:h}=s,p=s.stack||"",{cause:a}=s;a instanceof Error&&(p=`${p}
|
|
2
2
|
Cause: ${a.message}
|
|
3
|
-
${a.stack}`),se(r,`trackError_${i}`,{...f||{},errorMessage:h,errorStack:d,isTrackError:!0});},Lt=D(Mi),Fi=r=>{re("env",r);};D(be("setEnvironment",Fi));var ji=r=>{re("passportClientId",r);};D(be("setPassportClientId",ji));var Gi=r=>{re("pak",r);};D(be("setPublishableApiKey",Gi));D(be("getDetail",Ke));var qi={Passport:"passport",Steam:"steam",Epic:"epic",Google:"google",Apple:"apple",Discord:"discord",Email:"email",Custom:"custom"},xe=class extends Error{status;endpoint;body;constructor(r){super(`audience transport failed: ${r.status||"network error"} ${r.endpoint}`,r.cause!==void 0?{cause:r.cause}:void 0),this.name="TransportError",this.status=r.status,this.endpoint=r.endpoint,this.body=r.body;}},pe=class extends Error{code;status;endpoint;responseBody;cause;constructor(r){super(r.message),this.name="AudienceError",this.code=r.code,this.status=r.status,this.endpoint=r.endpoint,this.responseBody=r.responseBody,this.cause=r.cause;}};function Dt(r,i,s){if(r.status===0)return new pe({code:"NETWORK_ERROR",message:i==="flush"?`Network error sending ${s??0} messages`:"Network error syncing consent",status:0,endpoint:r.endpoint,cause:r.cause});if(r.status>=200&&r.status<300){let f=r.body,h=f?.rejected??0,d=f?.accepted??0;return new pe({code:"VALIDATION_REJECTED",message:`Backend rejected ${h} of ${h+d} messages`,status:r.status,endpoint:r.endpoint,responseBody:r.body})}return r.status===429?new pe({code:"RATE_LIMITED",message:i==="flush"?"Flush rate limited (429)":"Consent sync rate limited (429)",status:r.status,endpoint:r.endpoint,responseBody:r.body}):r.status>=400&&r.status<500?new pe({code:i==="flush"?"VALIDATION_REJECTED":"CONSENT_SYNC_FAILED",message:i==="flush"?`Flush rejected with status ${r.status}`:`Consent sync failed with status ${r.status}`,status:r.status,endpoint:r.endpoint,responseBody:r.body}):new pe({code:i==="flush"?"FLUSH_FAILED":"CONSENT_SYNC_FAILED",message:i==="flush"?`Flush failed with status ${r.status}`:`Consent sync failed with status ${r.status}`,status:r.status,endpoint:r.endpoint,responseBody:r.body,cause:r.cause})}function Ft(r,i){if(r)try{r(i);}catch{}}var Vi=3e4;function Ki(r){let i=r.get?.("retry-after");if(!i)return null;let s=Number(i.trim());if(!Number.isNaN(s)&&s>=0)return Math.round(s*1e3);let f=new Date(i);if(!Number.isNaN(f.getTime())){let h=f.getTime()-Date.now();return h>0?h:null}return null}async function Mt(r){let i=r.headers?.get?.("content-type")??"";try{return i.includes("application/json")?await r.json():await r.text()}catch{return}}var Ze=async(r,i,s,f)=>{let h=new AbortController,d=setTimeout(()=>h.abort(),Vi);try{let a=await fetch(r,{method:f?.method??"POST",headers:{"Content-Type":"application/json","x-immutable-publishable-key":i},body:JSON.stringify(s),keepalive:f?.keepalive,signal:h.signal});if(a.status===429){se("audience","transport_send_failed",{status:429});let m=Ki(a.headers);return {ok:!1,error:new xe({status:429,endpoint:r}),...m!==null?{retryAfterMs:m}:{}}}if(!a.ok){let m=await Mt(a);return se("audience","transport_send_failed",{status:a.status}),{ok:!1,error:new xe({status:a.status,endpoint:r,body:m})}}let g=await Mt(a);if(typeof g=="object"&&g!==null&&"rejected"in g){let m=g.rejected??0;if(m>0)return se("audience","transport_partial_rejected",{status:a.status,rejected:m}),{ok:!1,error:new xe({status:a.status,endpoint:r,body:g})}}return {ok:!0}}catch(a){let g=new xe({status:0,endpoint:r,cause:a});return Lt("audience","transport_send",g),{ok:!1,error:g}}finally{clearTimeout(d);}},et="__imtbl_audience_";function tt(){try{return q()&&typeof localStorage<"u"}catch{return !1}}function zi(r,i=et){if(tt())try{let s=localStorage.getItem(`${i}${r}`);return s?JSON.parse(s):void 0}catch{return}}function Hi(r,i,s=et){if(tt())try{localStorage.setItem(`${s}${r}`,JSON.stringify(i));}catch{}}function Wi(r,i=et){if(tt())try{localStorage.removeItem(`${i}${r}`);}catch{}}var Qe="queue",$t=100,jt=class{constructor(r,i,s){this.send=r,this.publishableKey=i,this.endpointUrl=`${s?.baseUrl??Oe}${mt}`,this.flushIntervalMs=s?.flushIntervalMs??5e3,this.flushSize=s?.flushSize??20,this.onFlush=s?.onFlush,this.onError=s?.onError,this.storagePrefix=s?.storagePrefix;let f=zi(Qe,this.storagePrefix)??[];this.messages=s?.staleFilter?f.filter(s.staleFilter):f;}messages;timer=null;flushing=!1;unloadBound=!1;visibilityHandler;pagehideHandler;onFlush;onError;storagePrefix;endpointUrl;flushIntervalMs;flushSize;consecutiveFailures=0;nextAttemptAt=0;start(){this.timer||(this.timer=setInterval(()=>this.flush(),this.flushIntervalMs),this.registerUnload());}stop(){this.timer&&(clearInterval(this.timer),this.timer=null),this.removeUnload();}destroy(){this.stop(),this.flushUnload();}enqueue(r){this.messages.push(r),this.persist(),this.messages.length>=this.flushSize&&this.flush();}async flush(){if(!(this.flushing||this.messages.length===0)&&!(Date.now()<this.nextAttemptAt)){this.flushing=!0;try{let r=this.messages.slice(0,$t),i={messages:r},s=await this.send(this.endpointUrl,this.publishableKey,i),f;!s.ok&&s.error&&(f=Dt(s.error,"flush",r.length));let h=f?.code==="VALIDATION_REJECTED";s.ok||h?(this.messages=this.messages.slice(r.length),this.persist(),this.resetBackoff()):f&&(s.retryAfterMs!==void 0?this.setBackoffUntil(Date.now()+s.retryAfterMs):this.recordFailure()),this.onFlush?.(s.ok,r.length),f&&Ft(this.onError,f);}finally{this.flushing=!1;}}}flushUnload(){if(this.flushing||this.messages.length===0)return;let r=this.messages.slice(0,$t),i={messages:r};this.send(this.endpointUrl,this.publishableKey,i,{keepalive:!0}),this.messages=this.messages.slice(r.length),this.persist();}purge(r){this.messages=this.messages.filter(i=>!r(i)),this.persist();}transform(r){this.messages=this.messages.map(r),this.persist();}get length(){return this.messages.length}clear(){this.messages=[],Wi(Qe,this.storagePrefix);}registerUnload(){!q()||this.unloadBound||(this.unloadBound=!0,this.pagehideHandler=()=>this.flushUnload(),this.visibilityHandler=()=>{document.visibilityState==="hidden"&&this.flushUnload();},document.addEventListener("visibilitychange",this.visibilityHandler),window.addEventListener("pagehide",this.pagehideHandler));}removeUnload(){this.unloadBound&&(this.visibilityHandler&&document.removeEventListener("visibilitychange",this.visibilityHandler),this.pagehideHandler&&window.removeEventListener("pagehide",this.pagehideHandler),this.unloadBound=!1);}backoffDelayMs(){switch(this.consecutiveFailures){case 0:return 0;case 1:return 5e3;case 2:return 1e4;case 3:return 2e4;case 4:return 4e4;default:return 6e4}}recordFailure(){let r=Date.now();r<this.nextAttemptAt||(this.consecutiveFailures++,this.nextAttemptAt=r+this.backoffDelayMs());}setBackoffUntil(r){this.consecutiveFailures++,this.nextAttemptAt=r;}resetBackoff(){this.consecutiveFailures=0,this.nextAttemptAt=0;}persist(){Hi(Qe,this.messages,this.storagePrefix);}},Yi="2.20.1-alpha.2";function Gt(r="@imtbl/audience",i=Yi){let s={library:r,libraryVersion:i};return q()&&(s.userAgent=navigator.userAgent,s.locale=navigator.language,s.timezone=Intl.DateTimeFormat().resolvedOptions().timeZone,s.screen=`${window.screen.width}x${window.screen.height}`,s.pageUrl=window.location.href,s.pagePath=window.location.pathname,s.pageReferrer=document.referrer,s.pageTitle=document.title),s}function qt(r){let i=new Date(r).getTime();if(Number.isNaN(i))return !1;let s=Date.now();return i<=s+864e5&&i>=s-2592e6}function Vt(r,i,s,f){return r!==s||i!==f}function ve(r,i=256){return r.length>i?r.slice(0,i):r}function ge(r){let i=le(H);if(i)return fe(H,i,1800,r),{sessionId:i,isNew:!1};let s=W();return fe(H,s,1800,r),{sessionId:s,isNew:!0}}var Kt=["utm_source","utm_medium","utm_campaign","utm_content","utm_term"],zt=["gclid","dclid","fbclid","ttclid","msclkid","li_fat_id"],Ht="__imtbl_attribution";function Ji(r){let i;try{i=new URL(r).searchParams;}catch{return {}}let s={};for(let h of [...Kt,...zt]){let d=i.get(h);d&&(s[h]=d);}let f=i.get("referral_code");return f&&(s.referral_code=f),s}function Xi(){try{let r=sessionStorage.getItem(Ht);return r?JSON.parse(r):null}catch{return null}}function Qi(r){try{sessionStorage.setItem(Ht,JSON.stringify(r));}catch{}}function Wt(){let r=typeof window<"u"&&window.location?Ji(window.location.href):{},i=typeof document<"u"&&document.referrer||void 0,s=zt.some(h=>h in r),f=Kt.some(h=>h in r);return {...r,referrer:i,touchpoint_type:s||f?"click":void 0}}function Yt(){let r=Xi();if(r)return r;let i=typeof window<"u"&&window.location?window.location.href:void 0,s={...Wt(),landing_page:i};return Qi(s),s}function Jt(){return Wt()}function X(r){return r!=="none"}function oe(r){return r==="full"}function Xt(r,i,s,f,h,d,a,g){let m=d??"none",B={none:0,anonymous:1,full:2};function b(w){let v=`${g??Oe}${yt}`;i(v,s,{anonymousId:f,status:w,source:h},{method:"PUT",keepalive:!0}).then(p=>{!p.ok&&p.error&&Ft(a,Dt(p.error,"consent"));});}return {get level(){return m},setLevel(w){w!==m&&(B[w]<B[m]&&(w==="none"?r.purge(()=>!0):w==="anonymous"&&(r.purge(v=>v.type==="identify"||v.type==="alias"),r.transform(v=>{if("userId"in v){let{userId:p,...y}=v;return y}return v}))),m=w,b(w));}}}S();A();S();A();S();A();var Qt="@imtbl/audience",Zt="2.20.1-alpha.2",Q="[audience]",en="WebSDK";var Be=class{enabled;constructor(i=!1){this.enabled=i;}logEvent(i,s){this.enabled&&console.log(`${Q} ${i}`,s);}logFlush(i,s){this.enabled&&console.log(`${Q} flush ${i?"ok":"failed"} (${s} messages)`);}logConsent(i,s){this.enabled&&console.log(`${Q} consent ${i} \u2192 ${s}`);}logWarning(i){this.enabled&&console.warn(`${Q} ${i}`);}};var Zi=new Set(["sign_up","link_clicked"]),nt=class r{static liveInstances=0;queue;consent;attribution;debug;cookieDomain;testMode;anonymousId;sessionId;sessionStartTime;userId;isFirstPage=!0;destroyed=!1;static UUID_RE=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;static readAndStripAidParam(){if(!q())return null;let i=new URLSearchParams(window.location.search),s=i.get("imtbl_aid");if(s!==null){i.delete("imtbl_aid");let f=i.toString(),h=`${window.location.pathname}${f?`?${f}`:""}${window.location.hash}`;window.history.replaceState(window.history.state,"",h);}return s&&r.UUID_RE.test(s)?s:null}constructor(i){let{cookieDomain:s,publishableKey:f}=i,h=i.consent??"none",d=en;this.cookieDomain=s,this.testMode=i.testMode??!1,this.debug=new Be(i.debug??!1);let a=r.readAndStripAidParam(),g=!1;X(h)?(a?(Ce(a,s),this.anonymousId=a):this.anonymousId=ye(s),g=this.startSession()):this.anonymousId=le(z)??W(),this.queue=new jt(Ze,f,{baseUrl:i.baseUrl,flushIntervalMs:i.flushInterval,flushSize:i.flushSize,onFlush:(m,B)=>this.debug.logFlush(m,B),onError:i.onError,staleFilter:m=>qt(m.eventTimestamp),storagePrefix:"__imtbl_web_"}),this.consent=Xt(this.queue,Ze,f,this.anonymousId,d,h,i.onError,i.baseUrl),this.attribution=Yt(),this.isTrackingDisabled()||(this.queue.start(),g&&this.trackSessionStart());}static init(i){if(!i.publishableKey?.trim())throw new Error(`${Q} publishableKey is required`);return r.liveInstances>0&&console.warn(`${Q} Multiple SDK instances detected. Ensure previous instances are shut down to avoid duplicate events.`),r.liveInstances+=1,new r(i)}getAnonymousId(){return this.anonymousId}isTrackingDisabled(){return !X(this.consent.level)}effectiveUserId(){return oe(this.consent.level)?this.userId:void 0}startSession(){let i=ge(this.cookieDomain);return this.sessionId=i.sessionId,this.sessionStartTime=Date.now(),i.isNew}baseMessage(){return {messageId:W(),eventTimestamp:Re(),anonymousId:this.anonymousId,surface:"web",context:Gt(Qt,Zt),...this.testMode&&{test:!0}}}enqueue(i,s){this.queue.enqueue(s),this.debug.logEvent(i,s);}trackSessionStart(){this.sessionId&&this.enqueue("track(session_start)",{...this.baseMessage(),type:"track",eventName:Pe,properties:{session_id:this.sessionId,...this.attribution}});}trackSessionEnd(){this.sessionId&&this.enqueue("track(session_end)",{...this.baseMessage(),type:"track",eventName:Ne,properties:{session_id:this.sessionId,...this.sessionStartTime&&{duration:Math.round((Date.now()-this.sessionStartTime)/1e3)}}});}page(i){if(this.isTrackingDisabled())return;ge(this.cookieDomain);let s={session_id:this.sessionId,...i};this.isFirstPage&&(Object.assign(s,this.attribution),this.isFirstPage=!1),this.enqueue("page",{...this.baseMessage(),type:"page",properties:s,userId:this.effectiveUserId()});}track(i,...s){if(this.isTrackingDisabled())return;ge(this.cookieDomain);let[f]=s,h={session_id:this.sessionId,...Zi.has(i)?Jt():{},...f};this.enqueue("track",{...this.baseMessage(),type:"track",eventName:ve(i),properties:h,userId:this.effectiveUserId()});}identify(i,s,f){if(!oe(this.consent.level)){this.debug.logWarning("identify() requires full consent \u2014 call ignored.");return}ge(this.cookieDomain);let h=ve(i);this.userId=h,this.enqueue("identify",{...this.baseMessage(),type:"identify",userId:h,identityType:s,traits:f});}alias(i,s){if(!oe(this.consent.level)){this.debug.logWarning("alias() requires full consent \u2014 call ignored.");return}if(!Vt(i.id,i.identityType,s.id,s.identityType)){this.debug.logWarning("alias() from and to are identical \u2014 call ignored.");return}ge(this.cookieDomain),this.enqueue("alias",{...this.baseMessage(),type:"alias",fromId:ve(i.id),fromType:i.identityType,toId:ve(s.id),toType:s.identityType});}setConsent(i){let s=this.consent.level;if(i===s)return;this.debug.logConsent(s,i);let f=!X(s)&&X(i);if(f&&(this.anonymousId=ye(this.cookieDomain)),X(i)||this.queue.stop(),this.consent.setLevel(i),X(i)?oe(s)&&!oe(i)&&(this.userId=void 0):(he(z,this.cookieDomain),he(H,this.cookieDomain)),f){this.isFirstPage=!0;let h=this.startSession();this.queue.start(),h&&this.trackSessionStart();}}reset(){this.userId=void 0,this.queue.clear(),he(z,this.cookieDomain),he(H,this.cookieDomain),this.isTrackingDisabled()?(this.anonymousId=W(),this.sessionId=void 0,this.sessionStartTime=void 0):(this.anonymousId=ye(this.cookieDomain),this.startSession()&&this.trackSessionStart()),this.isFirstPage=!0;}async flush(){await this.queue.flush();}shutdown(){this.destroyed||(this.destroyed=!0,this.isTrackingDisabled()||this.trackSessionEnd(),this.queue.destroy(),r.liveInstances=Math.max(0,r.liveInstances-1));}};S();A();var es={SIGN_UP:"sign_up",SIGN_IN:"sign_in",WISHLIST_ADD:"wishlist_add",WISHLIST_REMOVE:"wishlist_remove",PURCHASE:"purchase",GAME_LAUNCH:"game_launch",PROGRESSION:"progression",RESOURCE:"resource",EMAIL_ACQUIRED:"email_acquired",GAME_PAGE_VIEWED:"game_page_viewed",LINK_CLICKED:"link_clicked",BUTTON_CLICKED:"button_clicked"};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
3
|
+
${a.stack}`),se(r,`trackError_${i}`,{...f||{},errorMessage:h,errorStack:p,isTrackError:!0});},Mt=D($i),ji=r=>{re("env",r);};D(ve("setEnvironment",ji));var Gi=r=>{re("passportClientId",r);};D(ve("setPassportClientId",Gi));var qi=r=>{re("pak",r);};D(ve("setPublishableApiKey",qi));D(ve("getDetail",Ke));var Vi={Passport:"passport",Steam:"steam",Epic:"epic",Google:"google",Apple:"apple",Discord:"discord",Email:"email",Custom:"custom"},xe=class extends Error{status;endpoint;body;constructor(r){super(`audience transport failed: ${r.status||"network error"} ${r.endpoint}`,r.cause!==void 0?{cause:r.cause}:void 0),this.name="TransportError",this.status=r.status,this.endpoint=r.endpoint,this.body=r.body;}},de=class extends Error{code;status;endpoint;responseBody;cause;constructor(r){super(r.message),this.name="AudienceError",this.code=r.code,this.status=r.status,this.endpoint=r.endpoint,this.responseBody=r.responseBody,this.cause=r.cause;}};function Ft(r,i,s){if(r.status===0)return new de({code:"NETWORK_ERROR",message:i==="flush"?`Network error sending ${s??0} messages`:"Network error syncing consent",status:0,endpoint:r.endpoint,cause:r.cause});if(r.status>=200&&r.status<300){let f=r.body,h=f?.rejected??0,p=f?.accepted??0;return new de({code:"VALIDATION_REJECTED",message:`Backend rejected ${h} of ${h+p} messages`,status:r.status,endpoint:r.endpoint,responseBody:r.body})}return r.status===429?new de({code:"RATE_LIMITED",message:i==="flush"?"Flush rate limited (429)":"Consent sync rate limited (429)",status:r.status,endpoint:r.endpoint,responseBody:r.body}):r.status>=400&&r.status<500?new de({code:i==="flush"?"VALIDATION_REJECTED":"CONSENT_SYNC_FAILED",message:i==="flush"?`Flush rejected with status ${r.status}`:`Consent sync failed with status ${r.status}`,status:r.status,endpoint:r.endpoint,responseBody:r.body}):new de({code:i==="flush"?"FLUSH_FAILED":"CONSENT_SYNC_FAILED",message:i==="flush"?`Flush failed with status ${r.status}`:`Consent sync failed with status ${r.status}`,status:r.status,endpoint:r.endpoint,responseBody:r.body,cause:r.cause})}function jt(r,i){if(r)try{r(i);}catch{}}var Ki=3e4;function zi(r){let i=r.get?.("retry-after");if(!i)return null;let s=Number(i.trim());if(!Number.isNaN(s)&&s>=0)return Math.round(s*1e3);let f=new Date(i);if(!Number.isNaN(f.getTime())){let h=f.getTime()-Date.now();return h>0?h:null}return null}function Qe(){try{return q()?navigator.onLine:void 0}catch{return}}async function $t(r){let i=r.headers?.get?.("content-type")??"";try{return i.includes("application/json")?await r.json():await r.text()}catch{return}}var et=async(r,i,s,f)=>{let h=new AbortController,p=setTimeout(()=>h.abort(),Ki),a=Date.now();try{let g=await fetch(r,{method:f?.method??"POST",headers:{"Content-Type":"application/json","x-immutable-publishable-key":i},body:JSON.stringify(s),keepalive:f?.keepalive,signal:h.signal});if(g.status===429){se("audience","transport_send_failed",{status:429,online:Qe(),timeToFailureMs:Date.now()-a});let v=zi(g.headers);return {ok:!1,error:new xe({status:429,endpoint:r}),...v!==null?{retryAfterMs:v}:{}}}if(!g.ok){let v=await $t(g);return se("audience","transport_send_failed",{status:g.status,online:Qe(),timeToFailureMs:Date.now()-a}),{ok:!1,error:new xe({status:g.status,endpoint:r,body:v})}}let m=await $t(g);if(typeof m=="object"&&m!==null&&"rejected"in m){let v=m.rejected??0;if(v>0)return se("audience","transport_partial_rejected",{status:g.status,rejected:v}),{ok:!1,error:new xe({status:g.status,endpoint:r,body:m})}}return {ok:!0}}catch(g){let m=new xe({status:0,endpoint:r,cause:g});return Mt("audience","transport_send",m,{errorName:g instanceof Error?g.name:void 0,online:Qe(),timeToFailureMs:Date.now()-a}),{ok:!1,error:m}}finally{clearTimeout(p);}},tt="__imtbl_audience_";function nt(){try{return q()&&typeof localStorage<"u"}catch{return !1}}function Hi(r,i=tt){if(nt())try{let s=localStorage.getItem(`${i}${r}`);return s?JSON.parse(s):void 0}catch{return}}function Yi(r,i,s=tt){if(nt())try{localStorage.setItem(`${s}${r}`,JSON.stringify(i));}catch{}}function Wi(r,i=tt){if(nt())try{localStorage.removeItem(`${i}${r}`);}catch{}}var Ze="queue",Dt=100,Gt=class{constructor(r,i,s){this.send=r,this.publishableKey=i,this.endpointUrl=`${s?.baseUrl??Oe}${yt}`,this.flushIntervalMs=s?.flushIntervalMs??5e3,this.flushSize=s?.flushSize??20,this.onFlush=s?.onFlush,this.onError=s?.onError,this.storagePrefix=s?.storagePrefix;let f=Hi(Ze,this.storagePrefix)??[];this.messages=s?.staleFilter?f.filter(s.staleFilter):f;}messages;timer=null;flushing=!1;unloadBound=!1;visibilityHandler;pagehideHandler;onFlush;onError;storagePrefix;endpointUrl;flushIntervalMs;flushSize;consecutiveFailures=0;nextAttemptAt=0;start(){this.timer||(this.timer=setInterval(()=>this.flush(),this.flushIntervalMs),this.registerUnload());}stop(){this.timer&&(clearInterval(this.timer),this.timer=null),this.removeUnload();}destroy(){this.stop(),this.flushUnload();}enqueue(r){this.messages.push(r),this.persist(),this.messages.length>=this.flushSize&&this.flush();}async flush(){if(!(this.flushing||this.messages.length===0)&&!(Date.now()<this.nextAttemptAt)){this.flushing=!0;try{let r=this.messages.slice(0,Dt),i={messages:r},s=await this.send(this.endpointUrl,this.publishableKey,i),f;!s.ok&&s.error&&(f=Ft(s.error,"flush",r.length));let h=f?.code==="VALIDATION_REJECTED";s.ok||h?(this.messages=this.messages.slice(r.length),this.persist(),this.resetBackoff()):f&&(s.retryAfterMs!==void 0?this.setBackoffUntil(Date.now()+s.retryAfterMs):this.recordFailure()),this.onFlush?.(s.ok,r.length),f&&jt(this.onError,f);}finally{this.flushing=!1;}}}flushUnload(){if(this.flushing||this.messages.length===0)return;let r=this.messages.slice(0,Dt),i={messages:r};this.send(this.endpointUrl,this.publishableKey,i,{keepalive:!0}),this.messages=this.messages.slice(r.length),this.persist();}purge(r){this.messages=this.messages.filter(i=>!r(i)),this.persist();}transform(r){this.messages=this.messages.map(r),this.persist();}get length(){return this.messages.length}clear(){this.messages=[],Wi(Ze,this.storagePrefix);}registerUnload(){!q()||this.unloadBound||(this.unloadBound=!0,this.pagehideHandler=()=>this.flushUnload(),this.visibilityHandler=()=>{document.visibilityState==="hidden"&&this.flushUnload();},document.addEventListener("visibilitychange",this.visibilityHandler),window.addEventListener("pagehide",this.pagehideHandler));}removeUnload(){this.unloadBound&&(this.visibilityHandler&&document.removeEventListener("visibilitychange",this.visibilityHandler),this.pagehideHandler&&window.removeEventListener("pagehide",this.pagehideHandler),this.unloadBound=!1);}backoffDelayMs(){switch(this.consecutiveFailures){case 0:return 0;case 1:return 5e3;case 2:return 1e4;case 3:return 2e4;case 4:return 4e4;default:return 6e4}}recordFailure(){let r=Date.now();r<this.nextAttemptAt||(this.consecutiveFailures++,this.nextAttemptAt=r+this.backoffDelayMs());}setBackoffUntil(r){this.consecutiveFailures++,this.nextAttemptAt=r;}resetBackoff(){this.consecutiveFailures=0,this.nextAttemptAt=0;}persist(){Yi(Ze,this.messages,this.storagePrefix);}},Ji="2.20.1";function qt(r="@imtbl/audience",i=Ji){let s={library:r,libraryVersion:i};return q()&&(s.userAgent=navigator.userAgent,s.locale=navigator.language,s.timezone=Intl.DateTimeFormat().resolvedOptions().timeZone,s.screen=`${window.screen.width}x${window.screen.height}`,s.pageUrl=window.location.href,s.pagePath=window.location.pathname,s.pageReferrer=document.referrer,s.pageTitle=document.title),s}function Vt(r){let i=new Date(r).getTime();if(Number.isNaN(i))return !1;let s=Date.now();return i<=s+864e5&&i>=s-2592e6}function Kt(r,i,s,f){return r!==s||i!==f}function be(r,i=256){return r.length>i?r.slice(0,i):r}function ge(r){let i=le(H);if(i)return fe(H,i,1800,r),{sessionId:i,isNew:!1};let s=Y();return fe(H,s,1800,r),{sessionId:s,isNew:!0}}var zt=["utm_source","utm_medium","utm_campaign","utm_content","utm_term"],Ht=["gclid","dclid","fbclid","ttclid","msclkid","li_fat_id"],Yt="__imtbl_attribution";function Xi(r){let i;try{i=new URL(r).searchParams;}catch{return {}}let s={};for(let h of [...zt,...Ht]){let p=i.get(h);p&&(s[h]=p);}let f=i.get("referral_code");return f&&(s.referral_code=f),s}function Qi(){try{let r=sessionStorage.getItem(Yt);return r?JSON.parse(r):null}catch{return null}}function Zi(r){try{sessionStorage.setItem(Yt,JSON.stringify(r));}catch{}}function Wt(){let r=typeof window<"u"&&window.location?Xi(window.location.href):{},i=typeof document<"u"&&document.referrer||void 0,s=Ht.some(h=>h in r),f=zt.some(h=>h in r);return {...r,referrer:i,touchpoint_type:s||f?"click":void 0}}function Jt(){let r=Qi();if(r)return r;let i=typeof window<"u"&&window.location?window.location.href:void 0,s={...Wt(),landing_page:i};return Zi(s),s}function Xt(){return Wt()}function X(r){return r!=="none"}function oe(r){return r==="full"}function Qt(r,i,s,f,h,p,a,g){let m=p??"none",v={none:0,anonymous:1,full:2};function b(w){let E=`${g??Oe}${wt}`;i(E,s,{anonymousId:f,status:w,source:h},{method:"PUT",keepalive:!0}).then(d=>{!d.ok&&d.error&&jt(a,Ft(d.error,"consent"));});}return {get level(){return m},setLevel(w){w!==m&&(v[w]<v[m]&&(w==="none"?r.purge(()=>!0):w==="anonymous"&&(r.purge(E=>E.type==="identify"||E.type==="alias"),r.transform(E=>{if("userId"in E){let{userId:d,...y}=E;return y}return E}))),m=w,b(w));}}}x();S();x();S();x();S();var Zt="@imtbl/audience",en="2.20.1",Q="[audience]",tn="WebSDK";var Be=class{enabled;constructor(i=!1){this.enabled=i;}logEvent(i,s){this.enabled&&console.log(`${Q} ${i}`,s);}logFlush(i,s){this.enabled&&console.log(`${Q} flush ${i?"ok":"failed"} (${s} messages)`);}logConsent(i,s){this.enabled&&console.log(`${Q} consent ${i} \u2192 ${s}`);}logWarning(i){this.enabled&&console.warn(`${Q} ${i}`);}};var es=new Set(["sign_up","link_clicked"]),rt=class r{static liveInstances=0;queue;consent;attribution;debug;cookieDomain;testMode;anonymousId;sessionId;sessionStartTime;userId;isFirstPage=!0;destroyed=!1;static UUID_RE=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;static readAndStripAidParam(){if(!q())return null;let i=new URLSearchParams(window.location.search),s=i.get("imtbl_aid");if(s!==null){i.delete("imtbl_aid");let f=i.toString(),h=`${window.location.pathname}${f?`?${f}`:""}${window.location.hash}`;window.history.replaceState(window.history.state,"",h);}return s&&r.UUID_RE.test(s)?s:null}constructor(i){let{cookieDomain:s,publishableKey:f}=i,h=i.consent??"none",p=tn;this.cookieDomain=s,this.testMode=i.testMode??!1,this.debug=new Be(i.debug??!1);let a=r.readAndStripAidParam(),g=!1;X(h)?(a?(Ce(a,s),this.anonymousId=a):this.anonymousId=ye(s),g=this.startSession()):this.anonymousId=le(z)??Y(),this.queue=new Gt(et,f,{baseUrl:i.baseUrl,flushIntervalMs:i.flushInterval,flushSize:i.flushSize,onFlush:(m,v)=>this.debug.logFlush(m,v),onError:i.onError,staleFilter:m=>Vt(m.eventTimestamp),storagePrefix:"__imtbl_web_"}),this.consent=Qt(this.queue,et,f,this.anonymousId,p,h,i.onError,i.baseUrl),this.attribution=Jt(),this.isTrackingDisabled()||(this.queue.start(),g&&this.trackSessionStart());}static init(i){if(!i.publishableKey?.trim())throw new Error(`${Q} publishableKey is required`);return r.liveInstances>0&&console.warn(`${Q} Multiple SDK instances detected. Ensure previous instances are shut down to avoid duplicate events.`),r.liveInstances+=1,new r(i)}getAnonymousId(){return this.anonymousId}isTrackingDisabled(){return !X(this.consent.level)}effectiveUserId(){return oe(this.consent.level)?this.userId:void 0}startSession(){let i=ge(this.cookieDomain);return this.sessionId=i.sessionId,this.sessionStartTime=Date.now(),i.isNew}baseMessage(){return {messageId:Y(),eventTimestamp:Re(),anonymousId:this.anonymousId,surface:"web",context:qt(Zt,en),...this.testMode&&{test:!0}}}enqueue(i,s){this.queue.enqueue(s),this.debug.logEvent(i,s);}trackSessionStart(){this.sessionId&&this.enqueue("track(session_start)",{...this.baseMessage(),type:"track",eventName:Pe,properties:{session_id:this.sessionId,...this.attribution}});}trackSessionEnd(){this.sessionId&&this.enqueue("track(session_end)",{...this.baseMessage(),type:"track",eventName:Ne,properties:{session_id:this.sessionId,...this.sessionStartTime&&{duration:Math.round((Date.now()-this.sessionStartTime)/1e3)}}});}page(i){if(this.isTrackingDisabled())return;ge(this.cookieDomain);let s={session_id:this.sessionId,...i};this.isFirstPage&&(Object.assign(s,this.attribution),this.isFirstPage=!1),this.enqueue("page",{...this.baseMessage(),type:"page",properties:s,userId:this.effectiveUserId()});}track(i,...s){if(this.isTrackingDisabled())return;ge(this.cookieDomain);let[f]=s,h={session_id:this.sessionId,...es.has(i)?Xt():{},...f};this.enqueue("track",{...this.baseMessage(),type:"track",eventName:be(i),properties:h,userId:this.effectiveUserId()});}identify(i,s,f){if(!oe(this.consent.level)){this.debug.logWarning("identify() requires full consent \u2014 call ignored.");return}ge(this.cookieDomain);let h=be(i);this.userId=h,this.enqueue("identify",{...this.baseMessage(),type:"identify",userId:h,identityType:s,traits:f});}alias(i,s){if(!oe(this.consent.level)){this.debug.logWarning("alias() requires full consent \u2014 call ignored.");return}if(!Kt(i.id,i.identityType,s.id,s.identityType)){this.debug.logWarning("alias() from and to are identical \u2014 call ignored.");return}ge(this.cookieDomain),this.enqueue("alias",{...this.baseMessage(),type:"alias",fromId:be(i.id),fromType:i.identityType,toId:be(s.id),toType:s.identityType});}setConsent(i){let s=this.consent.level;if(i===s)return;this.debug.logConsent(s,i);let f=!X(s)&&X(i);if(f&&(this.anonymousId=ye(this.cookieDomain)),X(i)||this.queue.stop(),this.consent.setLevel(i),X(i)?oe(s)&&!oe(i)&&(this.userId=void 0):(he(z,this.cookieDomain),he(H,this.cookieDomain)),f){this.isFirstPage=!0;let h=this.startSession();this.queue.start(),h&&this.trackSessionStart();}}reset(){this.userId=void 0,this.queue.clear(),he(z,this.cookieDomain),he(H,this.cookieDomain),this.isTrackingDisabled()?(this.anonymousId=Y(),this.sessionId=void 0,this.sessionStartTime=void 0):(this.anonymousId=ye(this.cookieDomain),this.startSession()&&this.trackSessionStart()),this.isFirstPage=!0;}async flush(){await this.queue.flush();}shutdown(){this.destroyed||(this.destroyed=!0,this.isTrackingDisabled()||this.trackSessionEnd(),this.queue.destroy(),r.liveInstances=Math.max(0,r.liveInstances-1));}};x();S();var ts={SIGN_UP:"sign_up",SIGN_IN:"sign_in",WISHLIST_ADD:"wishlist_add",WISHLIST_REMOVE:"wishlist_remove",PURCHASE:"purchase",GAME_LAUNCH:"game_launch",PROGRESSION:"progression",RESOURCE:"resource",EMAIL_ACQUIRED:"email_acquired",GAME_PAGE_VIEWED:"game_page_viewed",LINK_CLICKED:"link_clicked",BUTTON_CLICKED:"button_clicked"};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
4
4
|
/*! Bundled license information:
|
|
5
5
|
|
|
6
6
|
tiny-lru/dist/tiny-lru.js:
|
|
@@ -13,4 +13,4 @@ tiny-lru/dist/tiny-lru.js:
|
|
|
13
13
|
*)
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
export {
|
|
16
|
+
export { rt as Audience, de as AudienceError, ts as AudienceEvents, Vi as IdentityType, oe as canIdentify, X as canTrack };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
(function () {
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var En=Object.create;var Oe=Object.defineProperty;var In=Object.getOwnPropertyDescriptor;var An=Object.getOwnPropertyNames;var _n=Object.getPrototypeOf,Sn=Object.prototype.hasOwnProperty;var Bn=(r,i,s)=>i in r?Oe(r,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[i]=s;var xn=(r,i)=>()=>(i||r((i={exports:{}}).exports,i),i.exports);var Tn=(r,i,s,f)=>{if(i&&typeof i=="object"||typeof i=="function")for(let h of An(i))!Sn.call(r,h)&&h!==s&&Oe(r,h,{get:()=>i[h],enumerable:!(f=In(i,h))||f.enumerable});return r};var kn=(r,i,s)=>(s=r!=null?En(_n(r)):{},Tn(Oe(s,"default",{value:r,enumerable:!0}),r));var w=(r,i,s)=>Bn(r,typeof i!="symbol"?i+"":i,s);var It=xn(he=>{Object.defineProperty(he,"__esModule",{value:!0});he.clearGlobalNamespace=he.getGlobalisedValue=void 0;var Nn="globalise__singleton__",Rn={},bt=()=>typeof window!="undefined"?window:typeof globalThis!="undefined"?globalThis:Rn,Cn=(r,i)=>{if(typeof r!="string")throw "Invalid namespace key";if(typeof i!="string")throw "Invalid item key"},vt=r=>`${Nn}${r}`,Et=r=>{let i=bt(),s=vt(r);return i[s]||(i[s]={}),i[s]},Ln=(r,i)=>Et(r)[i]||void 0,Pn=(r,i,s)=>{let f=Et(r);f[i]=s;},Mn=(r,i,s)=>{Cn(r,i);let f=Ln(r,i);return f!==void 0?f:(Pn(r,i,s),s)};he.getGlobalisedValue=Mn;var $n=r=>{let i=bt(),s=vt(r);i[s]!==void 0&&delete i[s];};he.clearGlobalNamespace=$n;});var Ne="https://api.immutable.com",gt="/v1/audience/messages",mt="/v1/audience/tracking-consent",K="imtbl_anon_id",z="_imtbl_sid",Re="session_start",Ce="session_end",j=()=>typeof window<"u"&&typeof document<"u",Y=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,r=>{let i=Math.trunc(Math.random()*16);return (r==="x"?i:i%4+8).toString(16)}),Le=()=>new Date().toISOString();function ue(r){if(!j())return;let i=document.cookie.match(new RegExp(`(?:^|; )${r}=([^;]*)`));return i?decodeURIComponent(i[1]):void 0}function le(r,i,s,f){if(!j())return;let h=window.location.protocol==="https:"?"; Secure":"",c=f?`; domain=${f}`:"";document.cookie=`${r}=${encodeURIComponent(i)}; path=/; max-age=${s}; SameSite=Lax${c}${h}`;}function fe(r,i){le(r,"",0,i);}function ge(r){let i=ue(K);if(i)return i;let s=Y();return le(K,s,63072e3,r),s}function Pe(r,i){le(K,r,63072e3,i);}var Me=class{constructor(i=0,s=0,f=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=i,this.resetTtl=f,this.size=0,this.ttl=s;}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(i){if(this.has(i)){let s=this.items[i];delete this.items[i],this.size--,s.prev!==null&&(s.prev.next=s.next),s.next!==null&&(s.next.prev=s.prev),this.first===s&&(this.first=s.next),this.last===s&&(this.last=s.prev);}return this}entries(i=this.keys()){return i.map(s=>[s,this.get(s)])}evict(i=!1){if(i||this.size>0){let s=this.first;delete this.items[s.key],--this.size===0?(this.first=null,this.last=null):(this.first=s.next,this.first.prev=null);}return this}expiresAt(i){let s;return this.has(i)&&(s=this.items[i].expiry),s}get(i){let s;if(this.has(i)){let f=this.items[i];this.ttl>0&&f.expiry<=Date.now()?this.delete(i):(s=f.value,this.set(i,s,!0));}return s}has(i){return i in this.items}keys(){let i=[],s=this.first;for(;s!==null;)i.push(s.key),s=s.next;return i}set(i,s,f=!1,h=this.resetTtl){let c;if(f||this.has(i)){if(c=this.items[i],c.value=s,f===!1&&h&&(c.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.last!==c){let a=this.last,m=c.next,g=c.prev;this.first===c&&(this.first=c.next),c.next=null,c.prev=this.last,a.next=c,g!==null&&(g.next=m),m!==null&&(m.prev=g);}}else this.max>0&&this.size===this.max&&this.evict(!0),c=this.items[i]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:i,prev:this.last,next:null,value:s},++this.size===1?this.first=c:this.last.next=c;return this.last=c,this}values(i=this.keys()){return i.map(s=>this.get(s))}};function yt(r=1e3,i=0,s=!1){if(isNaN(r)||r<0)throw new TypeError("Invalid max value");if(isNaN(i)||i<0)throw new TypeError("Invalid ttl value");if(typeof s!="boolean")throw new TypeError("Invalid resetTtl value");return new Me(r,i,s)}var Un={max:1e3},wt=(r,i={})=>{let{cache:s,cacheKeyResolver:f=$e,onHit:h,lruOptions:c={}}=i,a={...Un,...c},m=s||yt(a.max,a.ttl);function g(...I){let y=f(...I),v=m.get(y);if(m.has(y))return h&&h(y,v,m),v;let p=r.apply(this,I);return m.set(y,p),p}return g._cache=m,g},$e=(...r)=>r.length===0?"no-args":r.map(i=>i===void 0?"undefined":i===null?"null":Array.isArray(i)?`[${$e(...i)}]`:typeof i=="object"?`{${$e(...On(i))}}`:JSON.stringify(i)).join(","),On=r=>Object.entries(r).sort((i,s)=>i[0]<s[0]?-1:1);var He=kn(It()),Dn=Object.defineProperty,Fn=(r,i)=>{for(var s in i)Dn(r,s,{get:i[s],enumerable:!0});};function We(r){throw new Error("Node.js process "+r+" is not supported by JSPM core outside of Node.js")}var G=[],ce=!1,Z,Ie=-1;function jn(){!ce||!Z||(ce=!1,Z.length?G=Z.concat(G):Ie=-1,G.length&&Tt());}function Tt(){if(!ce){var r=setTimeout(jn,0);ce=!0;for(var i=G.length;i;){for(Z=G,G=[];++Ie<i;)Z&&Z[Ie].run();Ie=-1,i=G.length;}Z=null,ce=!1,clearTimeout(r);}}function Gn(r){var i=new Array(arguments.length-1);if(arguments.length>1)for(var s=1;s<arguments.length;s++)i[s-1]=arguments[s];G.push(new kt(r,i)),G.length===1&&!ce&&setTimeout(Tt,0);}function kt(r,i){this.fun=r,this.array=i;}kt.prototype.run=function(){this.fun.apply(null,this.array);};var qn="browser",Vn="x64",Kn="browser",zn={PATH:"/usr/bin",LANG:navigator.language+".UTF-8",PWD:"/",HOME:"/home",TMP:"/tmp"},Yn=["/usr/bin/node"],Hn=[],Wn="v16.8.0",Jn={},Xn=function(r,i){console.warn((i?i+": ":"")+r);},Qn=function(r){We("binding");},Zn=function(r){return 0},ei=function(){return "/"},ti=function(r){},ni={name:"node",sourceUrl:"",headersUrl:"",libUrl:""};function R(){}var ii=R,ri=[];function si(r){We("_linkedBinding");}var oi={},ai=!1,ui={};function li(r){We("dlopen");}function fi(){return []}function hi(){return []}var ci=R,di=R,Je=function(){return {}},pi=Je,gi=Je,mi=R,yi=R,wi=R,bi={};function vi(r,i){if(!r)throw new Error(i||"assertion error")}var Ei={inspector:!1,debug:!1,uv:!1,ipv6:!1,tls_alpn:!1,tls_sni:!1,tls_ocsp:!1,tls:!1,cached_builtins:!0},Ii=R,Ai=R;function _i(){return !1}var Si=R,Bi=R,xi=R,Ti=R,ki=R,Ui=void 0,Oi=void 0,Ni=void 0,Ri=R,Ci=2,Li=1,Pi="/bin/usr/node",Mi=9229,$i="node",Di=[],Fi=R,H={now:typeof performance<"u"?performance.now.bind(performance):void 0,timing:typeof performance<"u"?performance.timing:void 0};H.now===void 0&&(De=Date.now(),H.timing&&H.timing.navigationStart&&(De=H.timing.navigationStart),H.now=()=>Date.now()-De);var De;function ji(){return H.now()/1e3}var je=1e9;function Ge(r){var i=Math.floor((Date.now()-H.now())*.001),s=H.now()*.001,f=Math.floor(s)+i,h=Math.floor(s%1*1e9);return r&&(f=f-r[0],h=h-r[1],h<0&&(f--,h+=je)),[f,h]}Ge.bigint=function(r){var i=Ge(r);return typeof BigInt>"u"?i[0]*je+i[1]:BigInt(i[0]*je)+BigInt(i[1])};var Gi=10,qi={},Vi=0;function W(){return qe}var Ki=W,zi=W,Yi=W,Hi=W,Wi=W,Ji=R,Xi=W,Qi=W;function Zi(r){return []}var qe={version:Wn,versions:Jn,arch:Vn,platform:Kn,release:ni,_rawDebug:ii,moduleLoadList:ri,binding:Qn,_linkedBinding:si,_events:qi,_eventsCount:Vi,_maxListeners:Gi,on:W,addListener:Ki,once:zi,off:Yi,removeListener:Hi,removeAllListeners:Wi,emit:Ji,prependListener:Xi,prependOnceListener:Qi,listeners:Zi,domain:oi,_exiting:ai,config:ui,dlopen:li,uptime:ji,_getActiveRequests:fi,_getActiveHandles:hi,reallyExit:ci,_kill:di,cpuUsage:Je,resourceUsage:pi,memoryUsage:gi,kill:mi,exit:yi,openStdin:wi,allowedNodeEnvironmentFlags:bi,assert:vi,features:Ei,_fatalExceptions:Ii,setUncaughtExceptionCaptureCallback:Ai,hasUncaughtExceptionCaptureCallback:_i,emitWarning:Xn,nextTick:Gn,_tickCallback:Si,_debugProcess:Bi,_debugEnd:xi,_startProfilerIdleNotifier:Ti,_stopProfilerIdleNotifier:ki,stdout:Ui,stdin:Ni,stderr:Oi,abort:Ri,umask:Zn,chdir:ti,cwd:ei,env:zn,title:qn,argv:Yn,execArgv:Hn,pid:Ci,ppid:Li,execPath:Pi,debugPort:Mi,hrtime:Ge,argv0:$i,_preload_modules:Di,setSourceMapsEnabled:Fi},me={},At=!1;function er(){if(At)return me;At=!0,me.byteLength=m,me.toByteArray=I,me.fromByteArray=E;for(var r=[],i=[],s=typeof Uint8Array<"u"?Uint8Array:Array,f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",h=0,c=f.length;h<c;++h)r[h]=f[h],i[f.charCodeAt(h)]=h;i[45]=62,i[95]=63;function a(p){var b=p.length;if(b%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var A=p.indexOf("=");A===-1&&(A=b);var x=A===b?0:4-A%4;return [A,x]}function m(p){var b=a(p),A=b[0],x=b[1];return (A+x)*3/4-x}function g(p,b,A){return (b+A)*3/4-A}function I(p){var b,A=a(p),x=A[0],N=A[1],T=new s(g(p,x,N)),L=0,M=N>0?x-4:x,C;for(C=0;C<M;C+=4)b=i[p.charCodeAt(C)]<<18|i[p.charCodeAt(C+1)]<<12|i[p.charCodeAt(C+2)]<<6|i[p.charCodeAt(C+3)],T[L++]=b>>16&255,T[L++]=b>>8&255,T[L++]=b&255;return N===2&&(b=i[p.charCodeAt(C)]<<2|i[p.charCodeAt(C+1)]>>4,T[L++]=b&255),N===1&&(b=i[p.charCodeAt(C)]<<10|i[p.charCodeAt(C+1)]<<4|i[p.charCodeAt(C+2)]>>2,T[L++]=b>>8&255,T[L++]=b&255),T}function y(p){return r[p>>18&63]+r[p>>12&63]+r[p>>6&63]+r[p&63]}function v(p,b,A){for(var x,N=[],T=b;T<A;T+=3)x=(p[T]<<16&16711680)+(p[T+1]<<8&65280)+(p[T+2]&255),N.push(y(x));return N.join("")}function E(p){for(var b,A=p.length,x=A%3,N=[],T=16383,L=0,M=A-x;L<M;L+=T)N.push(v(p,L,L+T>M?M:L+T));return x===1?(b=p[A-1],N.push(r[b>>2]+r[b<<4&63]+"==")):x===2&&(b=(p[A-2]<<8)+p[A-1],N.push(r[b>>10]+r[b>>4&63]+r[b<<2&63]+"=")),N.join("")}return me}var Ee={},_t=!1;function tr(){return _t?Ee:(_t=!0,Ee.read=function(r,i,s,f,h){var c,a,m=h*8-f-1,g=(1<<m)-1,I=g>>1,y=-7,v=s?h-1:0,E=s?-1:1,p=r[i+v];for(v+=E,c=p&(1<<-y)-1,p>>=-y,y+=m;y>0;c=c*256+r[i+v],v+=E,y-=8);for(a=c&(1<<-y)-1,c>>=-y,y+=f;y>0;a=a*256+r[i+v],v+=E,y-=8);if(c===0)c=1-I;else {if(c===g)return a?NaN:(p?-1:1)*(1/0);a=a+Math.pow(2,f),c=c-I;}return (p?-1:1)*a*Math.pow(2,c-f)},Ee.write=function(r,i,s,f,h,c){var a,m,g,I=c*8-h-1,y=(1<<I)-1,v=y>>1,E=h===23?Math.pow(2,-24)-Math.pow(2,-77):0,p=f?0:c-1,b=f?1:-1,A=i<0||i===0&&1/i<0?1:0;for(i=Math.abs(i),isNaN(i)||i===1/0?(m=isNaN(i)?1:0,a=y):(a=Math.floor(Math.log(i)/Math.LN2),i*(g=Math.pow(2,-a))<1&&(a--,g*=2),a+v>=1?i+=E/g:i+=E*Math.pow(2,1-v),i*g>=2&&(a++,g/=2),a+v>=y?(m=0,a=y):a+v>=1?(m=(i*g-1)*Math.pow(2,h),a=a+v):(m=i*Math.pow(2,v-1)*Math.pow(2,h),a=0));h>=8;r[s+p]=m&255,p+=b,m/=256,h-=8);for(a=a<<h|m,I+=h;I>0;r[s+p]=a&255,p+=b,a/=256,I-=8);r[s+p-b]|=A*128;},Ee)}var Q={},St=!1;function nr(){if(St)return Q;St=!0;let r=er(),i=tr(),s=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;Q.Buffer=a,Q.SlowBuffer=N,Q.INSPECT_MAX_BYTES=50;let f=2147483647;Q.kMaxLength=f,a.TYPED_ARRAY_SUPPORT=h(),!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function h(){try{let e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch(e){return !1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function c(e){if(e>f)throw new RangeError('The value "'+e+'" is invalid for option "size"');let t=new Uint8Array(e);return Object.setPrototypeOf(t,a.prototype),t}function a(e,t,n){if(typeof e=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return y(e)}return m(e,t,n)}a.poolSize=8192;function m(e,t,n){if(typeof e=="string")return v(e,t);if(ArrayBuffer.isView(e))return p(e);if(e==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(F(e,ArrayBuffer)||e&&F(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(F(e,SharedArrayBuffer)||e&&F(e.buffer,SharedArrayBuffer)))return b(e,t,n);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let o=e.valueOf&&e.valueOf();if(o!=null&&o!==e)return a.from(o,t,n);let u=A(e);if(u)return u;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return a.from(e[Symbol.toPrimitive]("string"),t,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}a.from=function(e,t,n){return m(e,t,n)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function g(e){if(typeof e!="number")throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function I(e,t,n){return g(e),e<=0?c(e):t!==void 0?typeof n=="string"?c(e).fill(t,n):c(e).fill(t):c(e)}a.alloc=function(e,t,n){return I(e,t,n)};function y(e){return g(e),c(e<0?0:x(e)|0)}a.allocUnsafe=function(e){return y(e)},a.allocUnsafeSlow=function(e){return y(e)};function v(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!a.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let n=T(e,t)|0,o=c(n),u=o.write(e,t);return u!==n&&(o=o.slice(0,u)),o}function E(e){let t=e.length<0?0:x(e.length)|0,n=c(t);for(let o=0;o<t;o+=1)n[o]=e[o]&255;return n}function p(e){if(F(e,Uint8Array)){let t=new Uint8Array(e);return b(t.buffer,t.byteOffset,t.byteLength)}return E(e)}function b(e,t,n){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(n||0))throw new RangeError('"length" is outside of buffer bounds');let o;return t===void 0&&n===void 0?o=new Uint8Array(e):n===void 0?o=new Uint8Array(e,t):o=new Uint8Array(e,t,n),Object.setPrototypeOf(o,a.prototype),o}function A(e){if(a.isBuffer(e)){let t=x(e.length)|0,n=c(t);return n.length===0||e.copy(n,0,0,t),n}if(e.length!==void 0)return typeof e.length!="number"||Ue(e.length)?c(0):E(e);if(e.type==="Buffer"&&Array.isArray(e.data))return E(e.data)}function x(e){if(e>=f)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+f.toString(16)+" bytes");return e|0}function N(e){return +e!=e&&(e=0),a.alloc(+e)}a.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==a.prototype},a.compare=function(e,t){if(F(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),F(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(e)||!a.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let n=e.length,o=t.length;for(let u=0,l=Math.min(n,o);u<l;++u)if(e[u]!==t[u]){n=e[u],o=t[u];break}return n<o?-1:o<n?1:0},a.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return !0;default:return !1}},a.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return a.alloc(0);let n;if(t===void 0)for(t=0,n=0;n<e.length;++n)t+=e[n].length;let o=a.allocUnsafe(t),u=0;for(n=0;n<e.length;++n){let l=e[n];if(F(l,Uint8Array))u+l.length>o.length?(a.isBuffer(l)||(l=a.from(l)),l.copy(o,u)):Uint8Array.prototype.set.call(o,l,u);else if(a.isBuffer(l))l.copy(o,u);else throw new TypeError('"list" argument must be an Array of Buffers');u+=l.length;}return o};function T(e,t){if(a.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||F(e,ArrayBuffer))return e.byteLength;if(typeof e!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);let n=e.length,o=arguments.length>2&&arguments[2]===!0;if(!o&&n===0)return 0;let u=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return ke(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return n*2;case"hex":return n>>>1;case"base64":return pt(e).length;default:if(u)return o?-1:ke(e).length;t=(""+t).toLowerCase(),u=!0;}}a.byteLength=T;function L(e,t,n){let o=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,t>>>=0,n<=t))return "";for(e||(e="utf8");;)switch(e){case"hex":return cn(this,t,n);case"utf8":case"utf-8":return st(this,t,n);case"ascii":return fn(this,t,n);case"latin1":case"binary":return hn(this,t,n);case"base64":return un(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return dn(this,t,n);default:if(o)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),o=!0;}}a.prototype._isBuffer=!0;function M(e,t,n){let o=e[t];e[t]=e[n],e[n]=o;}a.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)M(this,t,t+1);return this},a.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)M(this,t,t+3),M(this,t+1,t+2);return this},a.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)M(this,t,t+7),M(this,t+1,t+6),M(this,t+2,t+5),M(this,t+3,t+4);return this},a.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?st(this,0,e):L.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(e){if(!a.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:a.compare(this,e)===0},a.prototype.inspect=function(){let e="",t=Q.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"},s&&(a.prototype[s]=a.prototype.inspect),a.prototype.compare=function(e,t,n,o,u){if(F(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(t===void 0&&(t=0),n===void 0&&(n=e?e.length:0),o===void 0&&(o=0),u===void 0&&(u=this.length),t<0||n>e.length||o<0||u>this.length)throw new RangeError("out of range index");if(o>=u&&t>=n)return 0;if(o>=u)return -1;if(t>=n)return 1;if(t>>>=0,n>>>=0,o>>>=0,u>>>=0,this===e)return 0;let l=u-o,d=n-t,S=Math.min(l,d),O=this.slice(o,u),B=e.slice(t,n);for(let _=0;_<S;++_)if(O[_]!==B[_]){l=O[_],d=B[_];break}return l<d?-1:d<l?1:0};function C(e,t,n,o,u){if(e.length===0)return -1;if(typeof n=="string"?(o=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,Ue(n)&&(n=u?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(u)return -1;n=e.length-1;}else if(n<0)if(u)n=0;else return -1;if(typeof t=="string"&&(t=a.from(t,o)),a.isBuffer(t))return t.length===0?-1:rt(e,t,n,o,u);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?u?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):rt(e,[t],n,o,u);throw new TypeError("val must be string, number or Buffer")}function rt(e,t,n,o,u){let l=1,d=e.length,S=t.length;if(o!==void 0&&(o=String(o).toLowerCase(),o==="ucs2"||o==="ucs-2"||o==="utf16le"||o==="utf-16le")){if(e.length<2||t.length<2)return -1;l=2,d/=2,S/=2,n/=2;}function O(_,k){return l===1?_[k]:_.readUInt16BE(k*l)}let B;if(u){let _=-1;for(B=n;B<d;B++)if(O(e,B)===O(t,_===-1?0:B-_)){if(_===-1&&(_=B),B-_+1===S)return _*l}else _!==-1&&(B-=B-_),_=-1;}else for(n+S>d&&(n=d-S),B=n;B>=0;B--){let _=!0;for(let k=0;k<S;k++)if(O(e,B+k)!==O(t,k)){_=!1;break}if(_)return B}return -1}a.prototype.includes=function(e,t,n){return this.indexOf(e,t,n)!==-1},a.prototype.indexOf=function(e,t,n){return C(this,e,t,n,!0)},a.prototype.lastIndexOf=function(e,t,n){return C(this,e,t,n,!1)};function nn(e,t,n,o){n=Number(n)||0;let u=e.length-n;o?(o=Number(o),o>u&&(o=u)):o=u;let l=t.length;o>l/2&&(o=l/2);let d;for(d=0;d<o;++d){let S=parseInt(t.substr(d*2,2),16);if(Ue(S))return d;e[n+d]=S;}return d}function rn(e,t,n,o){return ve(ke(t,e.length-n),e,n,o)}function sn(e,t,n,o){return ve(yn(t),e,n,o)}function on(e,t,n,o){return ve(pt(t),e,n,o)}function an(e,t,n,o){return ve(wn(t,e.length-n),e,n,o)}a.prototype.write=function(e,t,n,o){if(t===void 0)o="utf8",n=this.length,t=0;else if(n===void 0&&typeof t=="string")o=t,n=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(n)?(n=n>>>0,o===void 0&&(o="utf8")):(o=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let u=this.length-t;if((n===void 0||n>u)&&(n=u),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");o||(o="utf8");let l=!1;for(;;)switch(o){case"hex":return nn(this,e,t,n);case"utf8":case"utf-8":return rn(this,e,t,n);case"ascii":case"latin1":case"binary":return sn(this,e,t,n);case"base64":return on(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return an(this,e,t,n);default:if(l)throw new TypeError("Unknown encoding: "+o);o=(""+o).toLowerCase(),l=!0;}},a.prototype.toJSON=function(){return {type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function un(e,t,n){return t===0&&n===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,n))}function st(e,t,n){n=Math.min(e.length,n);let o=[],u=t;for(;u<n;){let l=e[u],d=null,S=l>239?4:l>223?3:l>191?2:1;if(u+S<=n){let O,B,_,k;switch(S){case 1:l<128&&(d=l);break;case 2:O=e[u+1],(O&192)===128&&(k=(l&31)<<6|O&63,k>127&&(d=k));break;case 3:O=e[u+1],B=e[u+2],(O&192)===128&&(B&192)===128&&(k=(l&15)<<12|(O&63)<<6|B&63,k>2047&&(k<55296||k>57343)&&(d=k));break;case 4:O=e[u+1],B=e[u+2],_=e[u+3],(O&192)===128&&(B&192)===128&&(_&192)===128&&(k=(l&15)<<18|(O&63)<<12|(B&63)<<6|_&63,k>65535&&k<1114112&&(d=k));}}d===null?(d=65533,S=1):d>65535&&(d-=65536,o.push(d>>>10&1023|55296),d=56320|d&1023),o.push(d),u+=S;}return ln(o)}let ot=4096;function ln(e){let t=e.length;if(t<=ot)return String.fromCharCode.apply(String,e);let n="",o=0;for(;o<t;)n+=String.fromCharCode.apply(String,e.slice(o,o+=ot));return n}function fn(e,t,n){let o="";n=Math.min(e.length,n);for(let u=t;u<n;++u)o+=String.fromCharCode(e[u]&127);return o}function hn(e,t,n){let o="";n=Math.min(e.length,n);for(let u=t;u<n;++u)o+=String.fromCharCode(e[u]);return o}function cn(e,t,n){let o=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>o)&&(n=o);let u="";for(let l=t;l<n;++l)u+=bn[e[l]];return u}function dn(e,t,n){let o=e.slice(t,n),u="";for(let l=0;l<o.length-1;l+=2)u+=String.fromCharCode(o[l]+o[l+1]*256);return u}a.prototype.slice=function(e,t){let n=this.length;e=~~e,t=t===void 0?n:~~t,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<e&&(t=e);let o=this.subarray(e,t);return Object.setPrototypeOf(o,a.prototype),o};function U(e,t,n){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||U(e,t,this.length);let o=this[e],u=1,l=0;for(;++l<t&&(u*=256);)o+=this[e+l]*u;return o},a.prototype.readUintBE=a.prototype.readUIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||U(e,t,this.length);let o=this[e+--t],u=1;for(;t>0&&(u*=256);)o+=this[e+--t]*u;return o},a.prototype.readUint8=a.prototype.readUInt8=function(e,t){return e=e>>>0,t||U(e,1,this.length),this[e]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(e,t){return e=e>>>0,t||U(e,2,this.length),this[e]|this[e+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(e,t){return e=e>>>0,t||U(e,2,this.length),this[e]<<8|this[e+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(e,t){return e=e>>>0,t||U(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(e,t){return e=e>>>0,t||U(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])},a.prototype.readBigUInt64LE=V(function(e){e=e>>>0,ae(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&pe(e,this.length-8);let o=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,u=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(o)+(BigInt(u)<<BigInt(32))}),a.prototype.readBigUInt64BE=V(function(e){e=e>>>0,ae(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&pe(e,this.length-8);let o=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],u=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return (BigInt(o)<<BigInt(32))+BigInt(u)}),a.prototype.readIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||U(e,t,this.length);let o=this[e],u=1,l=0;for(;++l<t&&(u*=256);)o+=this[e+l]*u;return u*=128,o>=u&&(o-=Math.pow(2,8*t)),o},a.prototype.readIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||U(e,t,this.length);let o=t,u=1,l=this[e+--o];for(;o>0&&(u*=256);)l+=this[e+--o]*u;return u*=128,l>=u&&(l-=Math.pow(2,8*t)),l},a.prototype.readInt8=function(e,t){return e=e>>>0,t||U(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]},a.prototype.readInt16LE=function(e,t){e=e>>>0,t||U(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n},a.prototype.readInt16BE=function(e,t){e=e>>>0,t||U(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n},a.prototype.readInt32LE=function(e,t){return e=e>>>0,t||U(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},a.prototype.readInt32BE=function(e,t){return e=e>>>0,t||U(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},a.prototype.readBigInt64LE=V(function(e){e=e>>>0,ae(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&pe(e,this.length-8);let o=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return (BigInt(o)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)}),a.prototype.readBigInt64BE=V(function(e){e=e>>>0,ae(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&pe(e,this.length-8);let o=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return (BigInt(o)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)}),a.prototype.readFloatLE=function(e,t){return e=e>>>0,t||U(e,4,this.length),i.read(this,e,!0,23,4)},a.prototype.readFloatBE=function(e,t){return e=e>>>0,t||U(e,4,this.length),i.read(this,e,!1,23,4)},a.prototype.readDoubleLE=function(e,t){return e=e>>>0,t||U(e,8,this.length),i.read(this,e,!0,52,8)},a.prototype.readDoubleBE=function(e,t){return e=e>>>0,t||U(e,8,this.length),i.read(this,e,!1,52,8)};function P(e,t,n,o,u,l){if(!a.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>u||t<l)throw new RangeError('"value" argument is out of bounds');if(n+o>e.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(e,t,n,o){if(e=+e,t=t>>>0,n=n>>>0,!o){let d=Math.pow(2,8*n)-1;P(this,e,t,n,d,0);}let u=1,l=0;for(this[t]=e&255;++l<n&&(u*=256);)this[t+l]=e/u&255;return t+n},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(e,t,n,o){if(e=+e,t=t>>>0,n=n>>>0,!o){let d=Math.pow(2,8*n)-1;P(this,e,t,n,d,0);}let u=n-1,l=1;for(this[t+u]=e&255;--u>=0&&(l*=256);)this[t+u]=e/l&255;return t+n},a.prototype.writeUint8=a.prototype.writeUInt8=function(e,t,n){return e=+e,t=t>>>0,n||P(this,e,t,1,255,0),this[t]=e&255,t+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||P(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||P(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||P(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(e,t,n){return e=+e,t=t>>>0,n||P(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function at(e,t,n,o,u){dt(t,o,u,e,n,7);let l=Number(t&BigInt(4294967295));e[n++]=l,l=l>>8,e[n++]=l,l=l>>8,e[n++]=l,l=l>>8,e[n++]=l;let d=Number(t>>BigInt(32)&BigInt(4294967295));return e[n++]=d,d=d>>8,e[n++]=d,d=d>>8,e[n++]=d,d=d>>8,e[n++]=d,n}function ut(e,t,n,o,u){dt(t,o,u,e,n,7);let l=Number(t&BigInt(4294967295));e[n+7]=l,l=l>>8,e[n+6]=l,l=l>>8,e[n+5]=l,l=l>>8,e[n+4]=l;let d=Number(t>>BigInt(32)&BigInt(4294967295));return e[n+3]=d,d=d>>8,e[n+2]=d,d=d>>8,e[n+1]=d,d=d>>8,e[n]=d,n+8}a.prototype.writeBigUInt64LE=V(function(e,t=0){return at(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=V(function(e,t=0){return ut(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(e,t,n,o){if(e=+e,t=t>>>0,!o){let S=Math.pow(2,8*n-1);P(this,e,t,n,S-1,-S);}let u=0,l=1,d=0;for(this[t]=e&255;++u<n&&(l*=256);)e<0&&d===0&&this[t+u-1]!==0&&(d=1),this[t+u]=(e/l>>0)-d&255;return t+n},a.prototype.writeIntBE=function(e,t,n,o){if(e=+e,t=t>>>0,!o){let S=Math.pow(2,8*n-1);P(this,e,t,n,S-1,-S);}let u=n-1,l=1,d=0;for(this[t+u]=e&255;--u>=0&&(l*=256);)e<0&&d===0&&this[t+u+1]!==0&&(d=1),this[t+u]=(e/l>>0)-d&255;return t+n},a.prototype.writeInt8=function(e,t,n){return e=+e,t=t>>>0,n||P(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1},a.prototype.writeInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||P(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2},a.prototype.writeInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||P(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2},a.prototype.writeInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||P(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},a.prototype.writeInt32BE=function(e,t,n){return e=+e,t=t>>>0,n||P(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4},a.prototype.writeBigInt64LE=V(function(e,t=0){return at(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=V(function(e,t=0){return ut(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function lt(e,t,n,o,u,l){if(n+o>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function ft(e,t,n,o,u){return t=+t,n=n>>>0,u||lt(e,t,n,4),i.write(e,t,n,o,23,4),n+4}a.prototype.writeFloatLE=function(e,t,n){return ft(this,e,t,!0,n)},a.prototype.writeFloatBE=function(e,t,n){return ft(this,e,t,!1,n)};function ht(e,t,n,o,u){return t=+t,n=n>>>0,u||lt(e,t,n,8),i.write(e,t,n,o,52,8),n+8}a.prototype.writeDoubleLE=function(e,t,n){return ht(this,e,t,!0,n)},a.prototype.writeDoubleBE=function(e,t,n){return ht(this,e,t,!1,n)},a.prototype.copy=function(e,t,n,o){if(!a.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!o&&o!==0&&(o=this.length),t>=e.length&&(t=e.length),t||(t=0),o>0&&o<n&&(o=n),o===n||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),e.length-t<o-n&&(o=e.length-t+n);let u=o-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,n,o):Uint8Array.prototype.set.call(e,this.subarray(n,o),t),u},a.prototype.fill=function(e,t,n,o){if(typeof e=="string"){if(typeof t=="string"?(o=t,t=0,n=this.length):typeof n=="string"&&(o=n,n=this.length),o!==void 0&&typeof o!="string")throw new TypeError("encoding must be a string");if(typeof o=="string"&&!a.isEncoding(o))throw new TypeError("Unknown encoding: "+o);if(e.length===1){let l=e.charCodeAt(0);(o==="utf8"&&l<128||o==="latin1")&&(e=l);}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;t=t>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let u;if(typeof e=="number")for(u=t;u<n;++u)this[u]=e;else {let l=a.isBuffer(e)?e:a.from(e,o),d=l.length;if(d===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(u=0;u<n-t;++u)this[u+t]=l[u%d];}return this};let oe={};function Te(e,t,n){oe[e]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name;}get code(){return e}set code(o){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:o,writable:!0});}toString(){return `${this.name} [${e}]: ${this.message}`}};}Te("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Te("ERR_INVALID_ARG_TYPE",function(e,t){return `The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError),Te("ERR_OUT_OF_RANGE",function(e,t,n){let o=`The value of "${e}" is out of range.`,u=n;return Number.isInteger(n)&&Math.abs(n)>2**32?u=ct(String(n)):typeof n=="bigint"&&(u=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(u=ct(u)),u+="n"),o+=` It must be ${t}. Received ${u}`,o},RangeError);function ct(e){let t="",n=e.length,o=e[0]==="-"?1:0;for(;n>=o+4;n-=3)t=`_${e.slice(n-3,n)}${t}`;return `${e.slice(0,n)}${t}`}function pn(e,t,n){ae(t,"offset"),(e[t]===void 0||e[t+n]===void 0)&&pe(t,e.length-(n+1));}function dt(e,t,n,o,u,l){if(e>n||e<t){let d=typeof t=="bigint"?"n":"",S;throw t===0||t===BigInt(0)?S=`>= 0${d} and < 2${d} ** ${(l+1)*8}${d}`:S=`>= -(2${d} ** ${(l+1)*8-1}${d}) and < 2 ** ${(l+1)*8-1}${d}`,new oe.ERR_OUT_OF_RANGE("value",S,e)}pn(o,u,l);}function ae(e,t){if(typeof e!="number")throw new oe.ERR_INVALID_ARG_TYPE(t,"number",e)}function pe(e,t,n){throw Math.floor(e)!==e?(ae(e,n),new oe.ERR_OUT_OF_RANGE("offset","an integer",e)):t<0?new oe.ERR_BUFFER_OUT_OF_BOUNDS:new oe.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${t}`,e)}let gn=/[^+/0-9A-Za-z-_]/g;function mn(e){if(e=e.split("=")[0],e=e.trim().replace(gn,""),e.length<2)return "";for(;e.length%4!==0;)e=e+"=";return e}function ke(e,t){t=t||1/0;let n,o=e.length,u=null,l=[];for(let d=0;d<o;++d){if(n=e.charCodeAt(d),n>55295&&n<57344){if(!u){if(n>56319){(t-=3)>-1&&l.push(239,191,189);continue}else if(d+1===o){(t-=3)>-1&&l.push(239,191,189);continue}u=n;continue}if(n<56320){(t-=3)>-1&&l.push(239,191,189),u=n;continue}n=(u-55296<<10|n-56320)+65536;}else u&&(t-=3)>-1&&l.push(239,191,189);if(u=null,n<128){if((t-=1)<0)break;l.push(n);}else if(n<2048){if((t-=2)<0)break;l.push(n>>6|192,n&63|128);}else if(n<65536){if((t-=3)<0)break;l.push(n>>12|224,n>>6&63|128,n&63|128);}else if(n<1114112){if((t-=4)<0)break;l.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128);}else throw new Error("Invalid code point")}return l}function yn(e){let t=[];for(let n=0;n<e.length;++n)t.push(e.charCodeAt(n)&255);return t}function wn(e,t){let n,o,u,l=[];for(let d=0;d<e.length&&!((t-=2)<0);++d)n=e.charCodeAt(d),o=n>>8,u=n%256,l.push(u),l.push(o);return l}function pt(e){return r.toByteArray(mn(e))}function ve(e,t,n,o){let u;for(u=0;u<o&&!(u+n>=t.length||u>=e.length);++u)t[u+n]=e[u];return u}function F(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function Ue(e){return e!==e}let bn=function(){let e="0123456789abcdef",t=new Array(256);for(let n=0;n<16;++n){let o=n*16;for(let u=0;u<16;++u)t[o+u]=e[n]+e[u];}return t}();function V(e){return typeof BigInt>"u"?vn:e}function vn(){throw new Error("BigInt not supported")}return Q}var ie=nr();ie.Buffer;ie.SlowBuffer;ie.INSPECT_MAX_BYTES;ie.kMaxLength;var Bt=ie.Buffer;ie.INSPECT_MAX_BYTES;ie.kMaxLength;var ir={};Fn(ir,{deleteItem:()=>ar,getItem:()=>Ve,setItem:()=>_e});var Ae=()=>typeof window>"u",Ut=()=>!Ae(),rr="__IMX-",Xe=()=>Ut()&&window.localStorage,sr=r=>{if(r!==null)try{return JSON.parse(r)}catch(i){return r}},or=r=>typeof r=="string"?r:JSON.stringify(r),Qe=r=>`${rr}${r}`;function Ve(r){if(Xe())return sr(window.localStorage.getItem(Qe(r)))}var _e=(r,i)=>Xe()?(window.localStorage.setItem(Qe(r),or(i)),!0):!1,ar=r=>Xe()?(window.localStorage.removeItem(Qe(r)),!0):!1,Ke=0,ur=r=>{let i=parseInt(r,10)*1e3,s=new Date(i),f=new Date;return Ke=s.getTime()-f.getTime(),Ke},lr=()=>{let r=new Date().getTime()+Ke;return new Date(r).toISOString()},fr=(r=>(r.RUNTIME_ID="rid",r.PASSPORT_CLIENT_ID="passportClientId",r.ENVIRONMENT="env",r.PUBLISHABLE_API_KEY="pak",r.IDENTITY="uid",r.DOMAIN="domain",r.SDK_VERSION="sdkVersion",r))(fr||{}),hr="https://api.immutable.com",cr=r=>{if(typeof Bt<"u")return Bt.from(r,"utf-8").toString("base64");if(typeof btoa=="function")return btoa(unescape(encodeURIComponent(r)));throw new Error("Base64 encoding not supported in this environment")};async function Ot(r,i){let s=JSON.stringify(i),f={payload:cr(s)},h=await fetch(`${hr}${r}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)});if(!h.ok){let c=await h.text().catch(()=>"");throw new Error(`Request failed (${h.status}): ${c||h.statusText}`)}return h.json()}var ee,te,dr=()=>{ee=Ve("metrics-events")||[],te=Ve("metrics-runtime")||{};};dr();var ne=(r,i)=>{te={...te,[r]:i},_e("metrics-runtime",te);},ze=r=>{if(te[r]!==void 0)return te[r]},pr=()=>te,gr=()=>ee,mr=r=>{ee.push(r),_e("metrics-events",ee);},yr=r=>{ee=ee.slice(r),_e("metrics-events",ee);},Nt=r=>{let i=[];return Object.entries(r).forEach(([s,f])=>{(typeof s=="string"||typeof f=="string"||typeof f=="number"||typeof f=="boolean")&&i.push([s,f.toString()]);}),i},Fe="2.20.1-alpha.2",wr=()=>Ae()?"":window.location.ancestorOrigins&&window.location.ancestorOrigins.length>0?new URL(window.location.ancestorOrigins[0]).hostname:document.referrer?new URL(window.document.referrer).hostname:"",br=()=>{if(Ae())return "";let r;try{window.self!==window.top&&(r=wr());}catch(i){}return r||(r=window.location.hostname),r},vr=()=>{if(ne("sdkVersion",Fe),Ae())return {browser:"nodejs",sdkVersion:Fe};let r=br();return r&&ne("domain",r),{sdkVersion:Fe,browser:window.navigator.userAgent,domain:r,tz:Intl.DateTimeFormat().resolvedOptions().timeZone,screen:`${window.screen.width}x${window.screen.height}`}},Ye=!1,Er=()=>Ye,Ir=async()=>{Ye=!0;try{let r=Nt(vr()),i=ze("rid"),s=ze("uid"),f=await Ot("/v1/sdk/initialise",{version:1,data:{runtimeDetails:r,runtimeId:i,uId:s}}),{runtimeId:h,sTime:c}=f;ne("rid",h),ur(c);}catch(r){Ye=!1;}};function $(r,i){return (...s)=>{try{let f=r(...s);return f instanceof Promise?f.catch(()=>i):f}catch(f){return i}}}function Ar(){return Ut()||typeof qe>"u"?!1:qe.env.JEST_WORKER_ID!==void 0}var _r=$(Ar,!1),Rt="imtbl__metrics",Sr=5e3,Br=1e3,ye=(r,i)=>(0, He.getGlobalisedValue)(Rt,r,i),xr=(r,i)=>{let s=wt(i,{lruOptions:{ttl:Sr,max:Br}});return (0, He.getGlobalisedValue)(Rt,r,s)},Tr=5e3,kr=(r,i,s)=>{let f={event:`${r}.${i}`,time:lr(),...s&&{properties:Nt(s)}};mr(f);},re=$(xr("track",kr)),Ur=async()=>{if(Er()===!1){await Ir();return}let r=gr();if(r.length===0)return;let i=r.length,s=pr();await Ot("/v1/sdk/metrics",{version:1,data:{events:r,details:s}})instanceof Error||yr(i);},Or=$(Ur),Ct=async()=>{await Or(),setTimeout(Ct,Tr);},xt=!1,Nr=()=>{xt||(xt=!0,Ct());};_r()||$(ye("startFlushing",Nr))();var Dr=(r,i,s,f)=>{let{message:h}=s,c=s.stack||"",{cause:a}=s;a instanceof Error&&(c=`${c}
|
|
4
|
+
var In=Object.create;var Oe=Object.defineProperty;var An=Object.getOwnPropertyDescriptor;var _n=Object.getOwnPropertyNames;var Sn=Object.getPrototypeOf,Bn=Object.prototype.hasOwnProperty;var xn=(r,i,s)=>i in r?Oe(r,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[i]=s;var Tn=(r,i)=>()=>(i||r((i={exports:{}}).exports,i),i.exports);var kn=(r,i,s,f)=>{if(i&&typeof i=="object"||typeof i=="function")for(let c of _n(i))!Bn.call(r,c)&&c!==s&&Oe(r,c,{get:()=>i[c],enumerable:!(f=An(i,c))||f.enumerable});return r};var Un=(r,i,s)=>(s=r!=null?In(Sn(r)):{},kn(Oe(s,"default",{value:r,enumerable:!0}),r));var w=(r,i,s)=>xn(r,typeof i!="symbol"?i+"":i,s);var At=Tn(ce=>{Object.defineProperty(ce,"__esModule",{value:!0});ce.clearGlobalNamespace=ce.getGlobalisedValue=void 0;var Rn="globalise__singleton__",Cn={},vt=()=>typeof window!="undefined"?window:typeof globalThis!="undefined"?globalThis:Cn,Ln=(r,i)=>{if(typeof r!="string")throw "Invalid namespace key";if(typeof i!="string")throw "Invalid item key"},Et=r=>`${Rn}${r}`,It=r=>{let i=vt(),s=Et(r);return i[s]||(i[s]={}),i[s]},Pn=(r,i)=>It(r)[i]||void 0,Mn=(r,i,s)=>{let f=It(r);f[i]=s;},$n=(r,i,s)=>{Ln(r,i);let f=Pn(r,i);return f!==void 0?f:(Mn(r,i,s),s)};ce.getGlobalisedValue=$n;var Dn=r=>{let i=vt(),s=Et(r);i[s]!==void 0&&delete i[s];};ce.clearGlobalNamespace=Dn;});var Ne="https://api.immutable.com",mt="/v1/audience/messages",yt="/v1/audience/tracking-consent",K="imtbl_anon_id",z="_imtbl_sid",Re="session_start",Ce="session_end",j=()=>typeof window<"u"&&typeof document<"u",Y=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,r=>{let i=Math.trunc(Math.random()*16);return (r==="x"?i:i%4+8).toString(16)}),Le=()=>new Date().toISOString();function ue(r){if(!j())return;let i=document.cookie.match(new RegExp(`(?:^|; )${r}=([^;]*)`));return i?decodeURIComponent(i[1]):void 0}function le(r,i,s,f){if(!j())return;let c=window.location.protocol==="https:"?"; Secure":"",h=f?`; domain=${f}`:"";document.cookie=`${r}=${encodeURIComponent(i)}; path=/; max-age=${s}; SameSite=Lax${h}${c}`;}function fe(r,i){le(r,"",0,i);}function ge(r){let i=ue(K);if(i)return i;let s=Y();return le(K,s,63072e3,r),s}function Pe(r,i){le(K,r,63072e3,i);}var Me=class{constructor(i=0,s=0,f=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=i,this.resetTtl=f,this.size=0,this.ttl=s;}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(i){if(this.has(i)){let s=this.items[i];delete this.items[i],this.size--,s.prev!==null&&(s.prev.next=s.next),s.next!==null&&(s.next.prev=s.prev),this.first===s&&(this.first=s.next),this.last===s&&(this.last=s.prev);}return this}entries(i=this.keys()){return i.map(s=>[s,this.get(s)])}evict(i=!1){if(i||this.size>0){let s=this.first;delete this.items[s.key],--this.size===0?(this.first=null,this.last=null):(this.first=s.next,this.first.prev=null);}return this}expiresAt(i){let s;return this.has(i)&&(s=this.items[i].expiry),s}get(i){let s;if(this.has(i)){let f=this.items[i];this.ttl>0&&f.expiry<=Date.now()?this.delete(i):(s=f.value,this.set(i,s,!0));}return s}has(i){return i in this.items}keys(){let i=[],s=this.first;for(;s!==null;)i.push(s.key),s=s.next;return i}set(i,s,f=!1,c=this.resetTtl){let h;if(f||this.has(i)){if(h=this.items[i],h.value=s,f===!1&&c&&(h.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.last!==h){let a=this.last,g=h.next,E=h.prev;this.first===h&&(this.first=h.next),h.next=null,h.prev=this.last,a.next=h,E!==null&&(E.next=g),g!==null&&(g.prev=E);}}else this.max>0&&this.size===this.max&&this.evict(!0),h=this.items[i]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:i,prev:this.last,next:null,value:s},++this.size===1?this.first=h:this.last.next=h;return this.last=h,this}values(i=this.keys()){return i.map(s=>this.get(s))}};function wt(r=1e3,i=0,s=!1){if(isNaN(r)||r<0)throw new TypeError("Invalid max value");if(isNaN(i)||i<0)throw new TypeError("Invalid ttl value");if(typeof s!="boolean")throw new TypeError("Invalid resetTtl value");return new Me(r,i,s)}var On={max:1e3},bt=(r,i={})=>{let{cache:s,cacheKeyResolver:f=$e,onHit:c,lruOptions:h={}}=i,a={...On,...h},g=s||wt(a.max,a.ttl);function E(...v){let y=f(...v),m=g.get(y);if(g.has(y))return c&&c(y,m,g),m;let p=r.apply(this,v);return g.set(y,p),p}return E._cache=g,E},$e=(...r)=>r.length===0?"no-args":r.map(i=>i===void 0?"undefined":i===null?"null":Array.isArray(i)?`[${$e(...i)}]`:typeof i=="object"?`{${$e(...Nn(i))}}`:JSON.stringify(i)).join(","),Nn=r=>Object.entries(r).sort((i,s)=>i[0]<s[0]?-1:1);var He=Un(At()),Fn=Object.defineProperty,jn=(r,i)=>{for(var s in i)Fn(r,s,{get:i[s],enumerable:!0});};function We(r){throw new Error("Node.js process "+r+" is not supported by JSPM core outside of Node.js")}var G=[],he=!1,Z,Ie=-1;function Gn(){!he||!Z||(he=!1,Z.length?G=Z.concat(G):Ie=-1,G.length&&kt());}function kt(){if(!he){var r=setTimeout(Gn,0);he=!0;for(var i=G.length;i;){for(Z=G,G=[];++Ie<i;)Z&&Z[Ie].run();Ie=-1,i=G.length;}Z=null,he=!1,clearTimeout(r);}}function qn(r){var i=new Array(arguments.length-1);if(arguments.length>1)for(var s=1;s<arguments.length;s++)i[s-1]=arguments[s];G.push(new Ut(r,i)),G.length===1&&!he&&setTimeout(kt,0);}function Ut(r,i){this.fun=r,this.array=i;}Ut.prototype.run=function(){this.fun.apply(null,this.array);};var Vn="browser",Kn="x64",zn="browser",Yn={PATH:"/usr/bin",LANG:navigator.language+".UTF-8",PWD:"/",HOME:"/home",TMP:"/tmp"},Hn=["/usr/bin/node"],Wn=[],Jn="v16.8.0",Xn={},Qn=function(r,i){console.warn((i?i+": ":"")+r);},Zn=function(r){We("binding");},ei=function(r){return 0},ti=function(){return "/"},ni=function(r){},ii={name:"node",sourceUrl:"",headersUrl:"",libUrl:""};function R(){}var ri=R,si=[];function oi(r){We("_linkedBinding");}var ai={},ui=!1,li={};function fi(r){We("dlopen");}function ci(){return []}function hi(){return []}var di=R,pi=R,Je=function(){return {}},gi=Je,mi=Je,yi=R,wi=R,bi=R,vi={};function Ei(r,i){if(!r)throw new Error(i||"assertion error")}var Ii={inspector:!1,debug:!1,uv:!1,ipv6:!1,tls_alpn:!1,tls_sni:!1,tls_ocsp:!1,tls:!1,cached_builtins:!0},Ai=R,_i=R;function Si(){return !1}var Bi=R,xi=R,Ti=R,ki=R,Ui=R,Oi=void 0,Ni=void 0,Ri=void 0,Ci=R,Li=2,Pi=1,Mi="/bin/usr/node",$i=9229,Di="node",Fi=[],ji=R,H={now:typeof performance<"u"?performance.now.bind(performance):void 0,timing:typeof performance<"u"?performance.timing:void 0};H.now===void 0&&(De=Date.now(),H.timing&&H.timing.navigationStart&&(De=H.timing.navigationStart),H.now=()=>Date.now()-De);var De;function Gi(){return H.now()/1e3}var je=1e9;function Ge(r){var i=Math.floor((Date.now()-H.now())*.001),s=H.now()*.001,f=Math.floor(s)+i,c=Math.floor(s%1*1e9);return r&&(f=f-r[0],c=c-r[1],c<0&&(f--,c+=je)),[f,c]}Ge.bigint=function(r){var i=Ge(r);return typeof BigInt>"u"?i[0]*je+i[1]:BigInt(i[0]*je)+BigInt(i[1])};var qi=10,Vi={},Ki=0;function W(){return qe}var zi=W,Yi=W,Hi=W,Wi=W,Ji=W,Xi=R,Qi=W,Zi=W;function er(r){return []}var qe={version:Jn,versions:Xn,arch:Kn,platform:zn,release:ii,_rawDebug:ri,moduleLoadList:si,binding:Zn,_linkedBinding:oi,_events:Vi,_eventsCount:Ki,_maxListeners:qi,on:W,addListener:zi,once:Yi,off:Hi,removeListener:Wi,removeAllListeners:Ji,emit:Xi,prependListener:Qi,prependOnceListener:Zi,listeners:er,domain:ai,_exiting:ui,config:li,dlopen:fi,uptime:Gi,_getActiveRequests:ci,_getActiveHandles:hi,reallyExit:di,_kill:pi,cpuUsage:Je,resourceUsage:gi,memoryUsage:mi,kill:yi,exit:wi,openStdin:bi,allowedNodeEnvironmentFlags:vi,assert:Ei,features:Ii,_fatalExceptions:Ai,setUncaughtExceptionCaptureCallback:_i,hasUncaughtExceptionCaptureCallback:Si,emitWarning:Qn,nextTick:qn,_tickCallback:Bi,_debugProcess:xi,_debugEnd:Ti,_startProfilerIdleNotifier:ki,_stopProfilerIdleNotifier:Ui,stdout:Oi,stdin:Ri,stderr:Ni,abort:Ci,umask:ei,chdir:ni,cwd:ti,env:Yn,title:Vn,argv:Hn,execArgv:Wn,pid:Li,ppid:Pi,execPath:Mi,debugPort:$i,hrtime:Ge,argv0:Di,_preload_modules:Fi,setSourceMapsEnabled:ji},me={},_t=!1;function tr(){if(_t)return me;_t=!0,me.byteLength=g,me.toByteArray=v,me.fromByteArray=I;for(var r=[],i=[],s=typeof Uint8Array<"u"?Uint8Array:Array,f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=0,h=f.length;c<h;++c)r[c]=f[c],i[f.charCodeAt(c)]=c;i[45]=62,i[95]=63;function a(p){var b=p.length;if(b%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var A=p.indexOf("=");A===-1&&(A=b);var x=A===b?0:4-A%4;return [A,x]}function g(p){var b=a(p),A=b[0],x=b[1];return (A+x)*3/4-x}function E(p,b,A){return (b+A)*3/4-A}function v(p){var b,A=a(p),x=A[0],N=A[1],T=new s(E(p,x,N)),L=0,M=N>0?x-4:x,C;for(C=0;C<M;C+=4)b=i[p.charCodeAt(C)]<<18|i[p.charCodeAt(C+1)]<<12|i[p.charCodeAt(C+2)]<<6|i[p.charCodeAt(C+3)],T[L++]=b>>16&255,T[L++]=b>>8&255,T[L++]=b&255;return N===2&&(b=i[p.charCodeAt(C)]<<2|i[p.charCodeAt(C+1)]>>4,T[L++]=b&255),N===1&&(b=i[p.charCodeAt(C)]<<10|i[p.charCodeAt(C+1)]<<4|i[p.charCodeAt(C+2)]>>2,T[L++]=b>>8&255,T[L++]=b&255),T}function y(p){return r[p>>18&63]+r[p>>12&63]+r[p>>6&63]+r[p&63]}function m(p,b,A){for(var x,N=[],T=b;T<A;T+=3)x=(p[T]<<16&16711680)+(p[T+1]<<8&65280)+(p[T+2]&255),N.push(y(x));return N.join("")}function I(p){for(var b,A=p.length,x=A%3,N=[],T=16383,L=0,M=A-x;L<M;L+=T)N.push(m(p,L,L+T>M?M:L+T));return x===1?(b=p[A-1],N.push(r[b>>2]+r[b<<4&63]+"==")):x===2&&(b=(p[A-2]<<8)+p[A-1],N.push(r[b>>10]+r[b>>4&63]+r[b<<2&63]+"=")),N.join("")}return me}var Ee={},St=!1;function nr(){return St?Ee:(St=!0,Ee.read=function(r,i,s,f,c){var h,a,g=c*8-f-1,E=(1<<g)-1,v=E>>1,y=-7,m=s?c-1:0,I=s?-1:1,p=r[i+m];for(m+=I,h=p&(1<<-y)-1,p>>=-y,y+=g;y>0;h=h*256+r[i+m],m+=I,y-=8);for(a=h&(1<<-y)-1,h>>=-y,y+=f;y>0;a=a*256+r[i+m],m+=I,y-=8);if(h===0)h=1-v;else {if(h===E)return a?NaN:(p?-1:1)*(1/0);a=a+Math.pow(2,f),h=h-v;}return (p?-1:1)*a*Math.pow(2,h-f)},Ee.write=function(r,i,s,f,c,h){var a,g,E,v=h*8-c-1,y=(1<<v)-1,m=y>>1,I=c===23?Math.pow(2,-24)-Math.pow(2,-77):0,p=f?0:h-1,b=f?1:-1,A=i<0||i===0&&1/i<0?1:0;for(i=Math.abs(i),isNaN(i)||i===1/0?(g=isNaN(i)?1:0,a=y):(a=Math.floor(Math.log(i)/Math.LN2),i*(E=Math.pow(2,-a))<1&&(a--,E*=2),a+m>=1?i+=I/E:i+=I*Math.pow(2,1-m),i*E>=2&&(a++,E/=2),a+m>=y?(g=0,a=y):a+m>=1?(g=(i*E-1)*Math.pow(2,c),a=a+m):(g=i*Math.pow(2,m-1)*Math.pow(2,c),a=0));c>=8;r[s+p]=g&255,p+=b,g/=256,c-=8);for(a=a<<c|g,v+=c;v>0;r[s+p]=a&255,p+=b,a/=256,v-=8);r[s+p-b]|=A*128;},Ee)}var Q={},Bt=!1;function ir(){if(Bt)return Q;Bt=!0;let r=tr(),i=nr(),s=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;Q.Buffer=a,Q.SlowBuffer=N,Q.INSPECT_MAX_BYTES=50;let f=2147483647;Q.kMaxLength=f,a.TYPED_ARRAY_SUPPORT=c(),!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function c(){try{let e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch(e){return !1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function h(e){if(e>f)throw new RangeError('The value "'+e+'" is invalid for option "size"');let t=new Uint8Array(e);return Object.setPrototypeOf(t,a.prototype),t}function a(e,t,n){if(typeof e=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return y(e)}return g(e,t,n)}a.poolSize=8192;function g(e,t,n){if(typeof e=="string")return m(e,t);if(ArrayBuffer.isView(e))return p(e);if(e==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(F(e,ArrayBuffer)||e&&F(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(F(e,SharedArrayBuffer)||e&&F(e.buffer,SharedArrayBuffer)))return b(e,t,n);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let o=e.valueOf&&e.valueOf();if(o!=null&&o!==e)return a.from(o,t,n);let u=A(e);if(u)return u;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return a.from(e[Symbol.toPrimitive]("string"),t,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}a.from=function(e,t,n){return g(e,t,n)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function E(e){if(typeof e!="number")throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function v(e,t,n){return E(e),e<=0?h(e):t!==void 0?typeof n=="string"?h(e).fill(t,n):h(e).fill(t):h(e)}a.alloc=function(e,t,n){return v(e,t,n)};function y(e){return E(e),h(e<0?0:x(e)|0)}a.allocUnsafe=function(e){return y(e)},a.allocUnsafeSlow=function(e){return y(e)};function m(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!a.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let n=T(e,t)|0,o=h(n),u=o.write(e,t);return u!==n&&(o=o.slice(0,u)),o}function I(e){let t=e.length<0?0:x(e.length)|0,n=h(t);for(let o=0;o<t;o+=1)n[o]=e[o]&255;return n}function p(e){if(F(e,Uint8Array)){let t=new Uint8Array(e);return b(t.buffer,t.byteOffset,t.byteLength)}return I(e)}function b(e,t,n){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(n||0))throw new RangeError('"length" is outside of buffer bounds');let o;return t===void 0&&n===void 0?o=new Uint8Array(e):n===void 0?o=new Uint8Array(e,t):o=new Uint8Array(e,t,n),Object.setPrototypeOf(o,a.prototype),o}function A(e){if(a.isBuffer(e)){let t=x(e.length)|0,n=h(t);return n.length===0||e.copy(n,0,0,t),n}if(e.length!==void 0)return typeof e.length!="number"||Ue(e.length)?h(0):I(e);if(e.type==="Buffer"&&Array.isArray(e.data))return I(e.data)}function x(e){if(e>=f)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+f.toString(16)+" bytes");return e|0}function N(e){return +e!=e&&(e=0),a.alloc(+e)}a.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==a.prototype},a.compare=function(e,t){if(F(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),F(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(e)||!a.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let n=e.length,o=t.length;for(let u=0,l=Math.min(n,o);u<l;++u)if(e[u]!==t[u]){n=e[u],o=t[u];break}return n<o?-1:o<n?1:0},a.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return !0;default:return !1}},a.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return a.alloc(0);let n;if(t===void 0)for(t=0,n=0;n<e.length;++n)t+=e[n].length;let o=a.allocUnsafe(t),u=0;for(n=0;n<e.length;++n){let l=e[n];if(F(l,Uint8Array))u+l.length>o.length?(a.isBuffer(l)||(l=a.from(l)),l.copy(o,u)):Uint8Array.prototype.set.call(o,l,u);else if(a.isBuffer(l))l.copy(o,u);else throw new TypeError('"list" argument must be an Array of Buffers');u+=l.length;}return o};function T(e,t){if(a.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||F(e,ArrayBuffer))return e.byteLength;if(typeof e!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);let n=e.length,o=arguments.length>2&&arguments[2]===!0;if(!o&&n===0)return 0;let u=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return ke(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return n*2;case"hex":return n>>>1;case"base64":return gt(e).length;default:if(u)return o?-1:ke(e).length;t=(""+t).toLowerCase(),u=!0;}}a.byteLength=T;function L(e,t,n){let o=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,t>>>=0,n<=t))return "";for(e||(e="utf8");;)switch(e){case"hex":return dn(this,t,n);case"utf8":case"utf-8":return ot(this,t,n);case"ascii":return cn(this,t,n);case"latin1":case"binary":return hn(this,t,n);case"base64":return ln(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pn(this,t,n);default:if(o)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),o=!0;}}a.prototype._isBuffer=!0;function M(e,t,n){let o=e[t];e[t]=e[n],e[n]=o;}a.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)M(this,t,t+1);return this},a.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)M(this,t,t+3),M(this,t+1,t+2);return this},a.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)M(this,t,t+7),M(this,t+1,t+6),M(this,t+2,t+5),M(this,t+3,t+4);return this},a.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?ot(this,0,e):L.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(e){if(!a.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:a.compare(this,e)===0},a.prototype.inspect=function(){let e="",t=Q.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"},s&&(a.prototype[s]=a.prototype.inspect),a.prototype.compare=function(e,t,n,o,u){if(F(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(t===void 0&&(t=0),n===void 0&&(n=e?e.length:0),o===void 0&&(o=0),u===void 0&&(u=this.length),t<0||n>e.length||o<0||u>this.length)throw new RangeError("out of range index");if(o>=u&&t>=n)return 0;if(o>=u)return -1;if(t>=n)return 1;if(t>>>=0,n>>>=0,o>>>=0,u>>>=0,this===e)return 0;let l=u-o,d=n-t,S=Math.min(l,d),O=this.slice(o,u),B=e.slice(t,n);for(let _=0;_<S;++_)if(O[_]!==B[_]){l=O[_],d=B[_];break}return l<d?-1:d<l?1:0};function C(e,t,n,o,u){if(e.length===0)return -1;if(typeof n=="string"?(o=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,Ue(n)&&(n=u?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(u)return -1;n=e.length-1;}else if(n<0)if(u)n=0;else return -1;if(typeof t=="string"&&(t=a.from(t,o)),a.isBuffer(t))return t.length===0?-1:st(e,t,n,o,u);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?u?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):st(e,[t],n,o,u);throw new TypeError("val must be string, number or Buffer")}function st(e,t,n,o,u){let l=1,d=e.length,S=t.length;if(o!==void 0&&(o=String(o).toLowerCase(),o==="ucs2"||o==="ucs-2"||o==="utf16le"||o==="utf-16le")){if(e.length<2||t.length<2)return -1;l=2,d/=2,S/=2,n/=2;}function O(_,k){return l===1?_[k]:_.readUInt16BE(k*l)}let B;if(u){let _=-1;for(B=n;B<d;B++)if(O(e,B)===O(t,_===-1?0:B-_)){if(_===-1&&(_=B),B-_+1===S)return _*l}else _!==-1&&(B-=B-_),_=-1;}else for(n+S>d&&(n=d-S),B=n;B>=0;B--){let _=!0;for(let k=0;k<S;k++)if(O(e,B+k)!==O(t,k)){_=!1;break}if(_)return B}return -1}a.prototype.includes=function(e,t,n){return this.indexOf(e,t,n)!==-1},a.prototype.indexOf=function(e,t,n){return C(this,e,t,n,!0)},a.prototype.lastIndexOf=function(e,t,n){return C(this,e,t,n,!1)};function rn(e,t,n,o){n=Number(n)||0;let u=e.length-n;o?(o=Number(o),o>u&&(o=u)):o=u;let l=t.length;o>l/2&&(o=l/2);let d;for(d=0;d<o;++d){let S=parseInt(t.substr(d*2,2),16);if(Ue(S))return d;e[n+d]=S;}return d}function sn(e,t,n,o){return ve(ke(t,e.length-n),e,n,o)}function on(e,t,n,o){return ve(wn(t),e,n,o)}function an(e,t,n,o){return ve(gt(t),e,n,o)}function un(e,t,n,o){return ve(bn(t,e.length-n),e,n,o)}a.prototype.write=function(e,t,n,o){if(t===void 0)o="utf8",n=this.length,t=0;else if(n===void 0&&typeof t=="string")o=t,n=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(n)?(n=n>>>0,o===void 0&&(o="utf8")):(o=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let u=this.length-t;if((n===void 0||n>u)&&(n=u),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");o||(o="utf8");let l=!1;for(;;)switch(o){case"hex":return rn(this,e,t,n);case"utf8":case"utf-8":return sn(this,e,t,n);case"ascii":case"latin1":case"binary":return on(this,e,t,n);case"base64":return an(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return un(this,e,t,n);default:if(l)throw new TypeError("Unknown encoding: "+o);o=(""+o).toLowerCase(),l=!0;}},a.prototype.toJSON=function(){return {type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ln(e,t,n){return t===0&&n===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,n))}function ot(e,t,n){n=Math.min(e.length,n);let o=[],u=t;for(;u<n;){let l=e[u],d=null,S=l>239?4:l>223?3:l>191?2:1;if(u+S<=n){let O,B,_,k;switch(S){case 1:l<128&&(d=l);break;case 2:O=e[u+1],(O&192)===128&&(k=(l&31)<<6|O&63,k>127&&(d=k));break;case 3:O=e[u+1],B=e[u+2],(O&192)===128&&(B&192)===128&&(k=(l&15)<<12|(O&63)<<6|B&63,k>2047&&(k<55296||k>57343)&&(d=k));break;case 4:O=e[u+1],B=e[u+2],_=e[u+3],(O&192)===128&&(B&192)===128&&(_&192)===128&&(k=(l&15)<<18|(O&63)<<12|(B&63)<<6|_&63,k>65535&&k<1114112&&(d=k));}}d===null?(d=65533,S=1):d>65535&&(d-=65536,o.push(d>>>10&1023|55296),d=56320|d&1023),o.push(d),u+=S;}return fn(o)}let at=4096;function fn(e){let t=e.length;if(t<=at)return String.fromCharCode.apply(String,e);let n="",o=0;for(;o<t;)n+=String.fromCharCode.apply(String,e.slice(o,o+=at));return n}function cn(e,t,n){let o="";n=Math.min(e.length,n);for(let u=t;u<n;++u)o+=String.fromCharCode(e[u]&127);return o}function hn(e,t,n){let o="";n=Math.min(e.length,n);for(let u=t;u<n;++u)o+=String.fromCharCode(e[u]);return o}function dn(e,t,n){let o=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>o)&&(n=o);let u="";for(let l=t;l<n;++l)u+=vn[e[l]];return u}function pn(e,t,n){let o=e.slice(t,n),u="";for(let l=0;l<o.length-1;l+=2)u+=String.fromCharCode(o[l]+o[l+1]*256);return u}a.prototype.slice=function(e,t){let n=this.length;e=~~e,t=t===void 0?n:~~t,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<e&&(t=e);let o=this.subarray(e,t);return Object.setPrototypeOf(o,a.prototype),o};function U(e,t,n){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||U(e,t,this.length);let o=this[e],u=1,l=0;for(;++l<t&&(u*=256);)o+=this[e+l]*u;return o},a.prototype.readUintBE=a.prototype.readUIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||U(e,t,this.length);let o=this[e+--t],u=1;for(;t>0&&(u*=256);)o+=this[e+--t]*u;return o},a.prototype.readUint8=a.prototype.readUInt8=function(e,t){return e=e>>>0,t||U(e,1,this.length),this[e]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(e,t){return e=e>>>0,t||U(e,2,this.length),this[e]|this[e+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(e,t){return e=e>>>0,t||U(e,2,this.length),this[e]<<8|this[e+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(e,t){return e=e>>>0,t||U(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(e,t){return e=e>>>0,t||U(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])},a.prototype.readBigUInt64LE=V(function(e){e=e>>>0,ae(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&pe(e,this.length-8);let o=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,u=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(o)+(BigInt(u)<<BigInt(32))}),a.prototype.readBigUInt64BE=V(function(e){e=e>>>0,ae(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&pe(e,this.length-8);let o=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],u=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return (BigInt(o)<<BigInt(32))+BigInt(u)}),a.prototype.readIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||U(e,t,this.length);let o=this[e],u=1,l=0;for(;++l<t&&(u*=256);)o+=this[e+l]*u;return u*=128,o>=u&&(o-=Math.pow(2,8*t)),o},a.prototype.readIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||U(e,t,this.length);let o=t,u=1,l=this[e+--o];for(;o>0&&(u*=256);)l+=this[e+--o]*u;return u*=128,l>=u&&(l-=Math.pow(2,8*t)),l},a.prototype.readInt8=function(e,t){return e=e>>>0,t||U(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]},a.prototype.readInt16LE=function(e,t){e=e>>>0,t||U(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n},a.prototype.readInt16BE=function(e,t){e=e>>>0,t||U(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n},a.prototype.readInt32LE=function(e,t){return e=e>>>0,t||U(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},a.prototype.readInt32BE=function(e,t){return e=e>>>0,t||U(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},a.prototype.readBigInt64LE=V(function(e){e=e>>>0,ae(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&pe(e,this.length-8);let o=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return (BigInt(o)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)}),a.prototype.readBigInt64BE=V(function(e){e=e>>>0,ae(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&pe(e,this.length-8);let o=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return (BigInt(o)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)}),a.prototype.readFloatLE=function(e,t){return e=e>>>0,t||U(e,4,this.length),i.read(this,e,!0,23,4)},a.prototype.readFloatBE=function(e,t){return e=e>>>0,t||U(e,4,this.length),i.read(this,e,!1,23,4)},a.prototype.readDoubleLE=function(e,t){return e=e>>>0,t||U(e,8,this.length),i.read(this,e,!0,52,8)},a.prototype.readDoubleBE=function(e,t){return e=e>>>0,t||U(e,8,this.length),i.read(this,e,!1,52,8)};function P(e,t,n,o,u,l){if(!a.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>u||t<l)throw new RangeError('"value" argument is out of bounds');if(n+o>e.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(e,t,n,o){if(e=+e,t=t>>>0,n=n>>>0,!o){let d=Math.pow(2,8*n)-1;P(this,e,t,n,d,0);}let u=1,l=0;for(this[t]=e&255;++l<n&&(u*=256);)this[t+l]=e/u&255;return t+n},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(e,t,n,o){if(e=+e,t=t>>>0,n=n>>>0,!o){let d=Math.pow(2,8*n)-1;P(this,e,t,n,d,0);}let u=n-1,l=1;for(this[t+u]=e&255;--u>=0&&(l*=256);)this[t+u]=e/l&255;return t+n},a.prototype.writeUint8=a.prototype.writeUInt8=function(e,t,n){return e=+e,t=t>>>0,n||P(this,e,t,1,255,0),this[t]=e&255,t+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||P(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||P(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||P(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(e,t,n){return e=+e,t=t>>>0,n||P(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function ut(e,t,n,o,u){pt(t,o,u,e,n,7);let l=Number(t&BigInt(4294967295));e[n++]=l,l=l>>8,e[n++]=l,l=l>>8,e[n++]=l,l=l>>8,e[n++]=l;let d=Number(t>>BigInt(32)&BigInt(4294967295));return e[n++]=d,d=d>>8,e[n++]=d,d=d>>8,e[n++]=d,d=d>>8,e[n++]=d,n}function lt(e,t,n,o,u){pt(t,o,u,e,n,7);let l=Number(t&BigInt(4294967295));e[n+7]=l,l=l>>8,e[n+6]=l,l=l>>8,e[n+5]=l,l=l>>8,e[n+4]=l;let d=Number(t>>BigInt(32)&BigInt(4294967295));return e[n+3]=d,d=d>>8,e[n+2]=d,d=d>>8,e[n+1]=d,d=d>>8,e[n]=d,n+8}a.prototype.writeBigUInt64LE=V(function(e,t=0){return ut(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=V(function(e,t=0){return lt(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(e,t,n,o){if(e=+e,t=t>>>0,!o){let S=Math.pow(2,8*n-1);P(this,e,t,n,S-1,-S);}let u=0,l=1,d=0;for(this[t]=e&255;++u<n&&(l*=256);)e<0&&d===0&&this[t+u-1]!==0&&(d=1),this[t+u]=(e/l>>0)-d&255;return t+n},a.prototype.writeIntBE=function(e,t,n,o){if(e=+e,t=t>>>0,!o){let S=Math.pow(2,8*n-1);P(this,e,t,n,S-1,-S);}let u=n-1,l=1,d=0;for(this[t+u]=e&255;--u>=0&&(l*=256);)e<0&&d===0&&this[t+u+1]!==0&&(d=1),this[t+u]=(e/l>>0)-d&255;return t+n},a.prototype.writeInt8=function(e,t,n){return e=+e,t=t>>>0,n||P(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1},a.prototype.writeInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||P(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2},a.prototype.writeInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||P(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2},a.prototype.writeInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||P(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},a.prototype.writeInt32BE=function(e,t,n){return e=+e,t=t>>>0,n||P(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4},a.prototype.writeBigInt64LE=V(function(e,t=0){return ut(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=V(function(e,t=0){return lt(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function ft(e,t,n,o,u,l){if(n+o>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function ct(e,t,n,o,u){return t=+t,n=n>>>0,u||ft(e,t,n,4),i.write(e,t,n,o,23,4),n+4}a.prototype.writeFloatLE=function(e,t,n){return ct(this,e,t,!0,n)},a.prototype.writeFloatBE=function(e,t,n){return ct(this,e,t,!1,n)};function ht(e,t,n,o,u){return t=+t,n=n>>>0,u||ft(e,t,n,8),i.write(e,t,n,o,52,8),n+8}a.prototype.writeDoubleLE=function(e,t,n){return ht(this,e,t,!0,n)},a.prototype.writeDoubleBE=function(e,t,n){return ht(this,e,t,!1,n)},a.prototype.copy=function(e,t,n,o){if(!a.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!o&&o!==0&&(o=this.length),t>=e.length&&(t=e.length),t||(t=0),o>0&&o<n&&(o=n),o===n||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),e.length-t<o-n&&(o=e.length-t+n);let u=o-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,n,o):Uint8Array.prototype.set.call(e,this.subarray(n,o),t),u},a.prototype.fill=function(e,t,n,o){if(typeof e=="string"){if(typeof t=="string"?(o=t,t=0,n=this.length):typeof n=="string"&&(o=n,n=this.length),o!==void 0&&typeof o!="string")throw new TypeError("encoding must be a string");if(typeof o=="string"&&!a.isEncoding(o))throw new TypeError("Unknown encoding: "+o);if(e.length===1){let l=e.charCodeAt(0);(o==="utf8"&&l<128||o==="latin1")&&(e=l);}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;t=t>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let u;if(typeof e=="number")for(u=t;u<n;++u)this[u]=e;else {let l=a.isBuffer(e)?e:a.from(e,o),d=l.length;if(d===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(u=0;u<n-t;++u)this[u+t]=l[u%d];}return this};let oe={};function Te(e,t,n){oe[e]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name;}get code(){return e}set code(o){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:o,writable:!0});}toString(){return `${this.name} [${e}]: ${this.message}`}};}Te("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Te("ERR_INVALID_ARG_TYPE",function(e,t){return `The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError),Te("ERR_OUT_OF_RANGE",function(e,t,n){let o=`The value of "${e}" is out of range.`,u=n;return Number.isInteger(n)&&Math.abs(n)>2**32?u=dt(String(n)):typeof n=="bigint"&&(u=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(u=dt(u)),u+="n"),o+=` It must be ${t}. Received ${u}`,o},RangeError);function dt(e){let t="",n=e.length,o=e[0]==="-"?1:0;for(;n>=o+4;n-=3)t=`_${e.slice(n-3,n)}${t}`;return `${e.slice(0,n)}${t}`}function gn(e,t,n){ae(t,"offset"),(e[t]===void 0||e[t+n]===void 0)&&pe(t,e.length-(n+1));}function pt(e,t,n,o,u,l){if(e>n||e<t){let d=typeof t=="bigint"?"n":"",S;throw t===0||t===BigInt(0)?S=`>= 0${d} and < 2${d} ** ${(l+1)*8}${d}`:S=`>= -(2${d} ** ${(l+1)*8-1}${d}) and < 2 ** ${(l+1)*8-1}${d}`,new oe.ERR_OUT_OF_RANGE("value",S,e)}gn(o,u,l);}function ae(e,t){if(typeof e!="number")throw new oe.ERR_INVALID_ARG_TYPE(t,"number",e)}function pe(e,t,n){throw Math.floor(e)!==e?(ae(e,n),new oe.ERR_OUT_OF_RANGE("offset","an integer",e)):t<0?new oe.ERR_BUFFER_OUT_OF_BOUNDS:new oe.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${t}`,e)}let mn=/[^+/0-9A-Za-z-_]/g;function yn(e){if(e=e.split("=")[0],e=e.trim().replace(mn,""),e.length<2)return "";for(;e.length%4!==0;)e=e+"=";return e}function ke(e,t){t=t||1/0;let n,o=e.length,u=null,l=[];for(let d=0;d<o;++d){if(n=e.charCodeAt(d),n>55295&&n<57344){if(!u){if(n>56319){(t-=3)>-1&&l.push(239,191,189);continue}else if(d+1===o){(t-=3)>-1&&l.push(239,191,189);continue}u=n;continue}if(n<56320){(t-=3)>-1&&l.push(239,191,189),u=n;continue}n=(u-55296<<10|n-56320)+65536;}else u&&(t-=3)>-1&&l.push(239,191,189);if(u=null,n<128){if((t-=1)<0)break;l.push(n);}else if(n<2048){if((t-=2)<0)break;l.push(n>>6|192,n&63|128);}else if(n<65536){if((t-=3)<0)break;l.push(n>>12|224,n>>6&63|128,n&63|128);}else if(n<1114112){if((t-=4)<0)break;l.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128);}else throw new Error("Invalid code point")}return l}function wn(e){let t=[];for(let n=0;n<e.length;++n)t.push(e.charCodeAt(n)&255);return t}function bn(e,t){let n,o,u,l=[];for(let d=0;d<e.length&&!((t-=2)<0);++d)n=e.charCodeAt(d),o=n>>8,u=n%256,l.push(u),l.push(o);return l}function gt(e){return r.toByteArray(yn(e))}function ve(e,t,n,o){let u;for(u=0;u<o&&!(u+n>=t.length||u>=e.length);++u)t[u+n]=e[u];return u}function F(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function Ue(e){return e!==e}let vn=function(){let e="0123456789abcdef",t=new Array(256);for(let n=0;n<16;++n){let o=n*16;for(let u=0;u<16;++u)t[o+u]=e[n]+e[u];}return t}();function V(e){return typeof BigInt>"u"?En:e}function En(){throw new Error("BigInt not supported")}return Q}var ie=ir();ie.Buffer;ie.SlowBuffer;ie.INSPECT_MAX_BYTES;ie.kMaxLength;var xt=ie.Buffer;ie.INSPECT_MAX_BYTES;ie.kMaxLength;var rr={};jn(rr,{deleteItem:()=>ur,getItem:()=>Ve,setItem:()=>_e});var Ae=()=>typeof window>"u",Ot=()=>!Ae(),sr="__IMX-",Xe=()=>Ot()&&window.localStorage,or=r=>{if(r!==null)try{return JSON.parse(r)}catch(i){return r}},ar=r=>typeof r=="string"?r:JSON.stringify(r),Qe=r=>`${sr}${r}`;function Ve(r){if(Xe())return or(window.localStorage.getItem(Qe(r)))}var _e=(r,i)=>Xe()?(window.localStorage.setItem(Qe(r),ar(i)),!0):!1,ur=r=>Xe()?(window.localStorage.removeItem(Qe(r)),!0):!1,Ke=0,lr=r=>{let i=parseInt(r,10)*1e3,s=new Date(i),f=new Date;return Ke=s.getTime()-f.getTime(),Ke},fr=()=>{let r=new Date().getTime()+Ke;return new Date(r).toISOString()},cr=(r=>(r.RUNTIME_ID="rid",r.PASSPORT_CLIENT_ID="passportClientId",r.ENVIRONMENT="env",r.PUBLISHABLE_API_KEY="pak",r.IDENTITY="uid",r.DOMAIN="domain",r.SDK_VERSION="sdkVersion",r))(cr||{}),hr="https://api.immutable.com",dr=r=>{if(typeof xt<"u")return xt.from(r,"utf-8").toString("base64");if(typeof btoa=="function")return btoa(unescape(encodeURIComponent(r)));throw new Error("Base64 encoding not supported in this environment")};async function Nt(r,i){let s=JSON.stringify(i),f={payload:dr(s)},c=await fetch(`${hr}${r}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)});if(!c.ok){let h=await c.text().catch(()=>"");throw new Error(`Request failed (${c.status}): ${h||c.statusText}`)}return c.json()}var ee,te,pr=()=>{ee=Ve("metrics-events")||[],te=Ve("metrics-runtime")||{};};pr();var ne=(r,i)=>{te={...te,[r]:i},_e("metrics-runtime",te);},ze=r=>{if(te[r]!==void 0)return te[r]},gr=()=>te,mr=()=>ee,yr=r=>{ee.push(r),_e("metrics-events",ee);},wr=r=>{ee=ee.slice(r),_e("metrics-events",ee);},Rt=r=>{let i=[];return Object.entries(r).forEach(([s,f])=>{(typeof s=="string"||typeof f=="string"||typeof f=="number"||typeof f=="boolean")&&i.push([s,f.toString()]);}),i},Fe="2.20.1",br=()=>Ae()?"":window.location.ancestorOrigins&&window.location.ancestorOrigins.length>0?new URL(window.location.ancestorOrigins[0]).hostname:document.referrer?new URL(window.document.referrer).hostname:"",vr=()=>{if(Ae())return "";let r;try{window.self!==window.top&&(r=br());}catch(i){}return r||(r=window.location.hostname),r},Er=()=>{if(ne("sdkVersion",Fe),Ae())return {browser:"nodejs",sdkVersion:Fe};let r=vr();return r&&ne("domain",r),{sdkVersion:Fe,browser:window.navigator.userAgent,domain:r,tz:Intl.DateTimeFormat().resolvedOptions().timeZone,screen:`${window.screen.width}x${window.screen.height}`}},Ye=!1,Ir=()=>Ye,Ar=async()=>{Ye=!0;try{let r=Rt(Er()),i=ze("rid"),s=ze("uid"),f=await Nt("/v1/sdk/initialise",{version:1,data:{runtimeDetails:r,runtimeId:i,uId:s}}),{runtimeId:c,sTime:h}=f;ne("rid",c),lr(h);}catch(r){Ye=!1;}};function $(r,i){return (...s)=>{try{let f=r(...s);return f instanceof Promise?f.catch(()=>i):f}catch(f){return i}}}function _r(){return Ot()||typeof qe>"u"?!1:qe.env.JEST_WORKER_ID!==void 0}var Sr=$(_r,!1),Ct="imtbl__metrics",Br=5e3,xr=1e3,ye=(r,i)=>(0, He.getGlobalisedValue)(Ct,r,i),Tr=(r,i)=>{let s=bt(i,{lruOptions:{ttl:Br,max:xr}});return (0, He.getGlobalisedValue)(Ct,r,s)},kr=5e3,Ur=(r,i,s)=>{let f={event:`${r}.${i}`,time:fr(),...s&&{properties:Rt(s)}};yr(f);},re=$(Tr("track",Ur)),Or=async()=>{if(Ir()===!1){await Ar();return}let r=mr();if(r.length===0)return;let i=r.length,s=gr();await Nt("/v1/sdk/metrics",{version:1,data:{events:r,details:s}})instanceof Error||wr(i);},Nr=$(Or),Lt=async()=>{await Nr(),setTimeout(Lt,kr);},Tt=!1,Rr=()=>{Tt||(Tt=!0,Lt());};Sr()||$(ye("startFlushing",Rr))();var Fr=(r,i,s,f)=>{let{message:c}=s,h=s.stack||"",{cause:a}=s;a instanceof Error&&(h=`${h}
|
|
5
5
|
Cause: ${a.message}
|
|
6
|
-
${a.stack}`),re(r,`trackError_${i}`,{...f||{},errorMessage:h,errorStack:c,isTrackError:!0});},Lt=$(Dr),Gr=r=>{ne("env",r);};$(ye("setEnvironment",Gr));var qr=r=>{ne("passportClientId",r);};$(ye("setPassportClientId",qr));var Vr=r=>{ne("pak",r);};$(ye("setPublishableApiKey",Vr));$(ye("getDetail",ze));var $t={Passport:"passport",Steam:"steam",Epic:"epic",Google:"google",Apple:"apple",Discord:"discord",Email:"email",Custom:"custom"},Se=class extends Error{constructor(i){super(`audience transport failed: ${i.status||"network error"} ${i.endpoint}`,i.cause!==void 0?{cause:i.cause}:void 0);w(this,"status");w(this,"endpoint");w(this,"body");this.name="TransportError",this.status=i.status,this.endpoint=i.endpoint,this.body=i.body;}},se=class extends Error{constructor(i){super(i.message);w(this,"code");w(this,"status");w(this,"endpoint");w(this,"responseBody");w(this,"cause");this.name="AudienceError",this.code=i.code,this.status=i.status,this.endpoint=i.endpoint,this.responseBody=i.responseBody,this.cause=i.cause;}};function Dt(r,i,s){var f,h;if(r.status===0)return new se({code:"NETWORK_ERROR",message:i==="flush"?`Network error sending ${s!=null?s:0} messages`:"Network error syncing consent",status:0,endpoint:r.endpoint,cause:r.cause});if(r.status>=200&&r.status<300){let c=r.body,a=(f=c==null?void 0:c.rejected)!=null?f:0,m=(h=c==null?void 0:c.accepted)!=null?h:0;return new se({code:"VALIDATION_REJECTED",message:`Backend rejected ${a} of ${a+m} messages`,status:r.status,endpoint:r.endpoint,responseBody:r.body})}return r.status===429?new se({code:"RATE_LIMITED",message:i==="flush"?"Flush rate limited (429)":"Consent sync rate limited (429)",status:r.status,endpoint:r.endpoint,responseBody:r.body}):r.status>=400&&r.status<500?new se({code:i==="flush"?"VALIDATION_REJECTED":"CONSENT_SYNC_FAILED",message:i==="flush"?`Flush rejected with status ${r.status}`:`Consent sync failed with status ${r.status}`,status:r.status,endpoint:r.endpoint,responseBody:r.body}):new se({code:i==="flush"?"FLUSH_FAILED":"CONSENT_SYNC_FAILED",message:i==="flush"?`Flush failed with status ${r.status}`:`Consent sync failed with status ${r.status}`,status:r.status,endpoint:r.endpoint,responseBody:r.body,cause:r.cause})}function Ft(r,i){if(r)try{r(i);}catch(s){}}var Kr=3e4;function zr(r){var h;let i=(h=r.get)==null?void 0:h.call(r,"retry-after");if(!i)return null;let s=Number(i.trim());if(!Number.isNaN(s)&&s>=0)return Math.round(s*1e3);let f=new Date(i);if(!Number.isNaN(f.getTime())){let c=f.getTime()-Date.now();return c>0?c:null}return null}async function Pt(r){var s,f,h;let i=(h=(f=(s=r.headers)==null?void 0:s.get)==null?void 0:f.call(s,"content-type"))!=null?h:"";try{return i.includes("application/json")?await r.json():await r.text()}catch(c){return}}var et=async(r,i,s,f)=>{var a,m;let h=new AbortController,c=setTimeout(()=>h.abort(),Kr);try{let g=await fetch(r,{method:(a=f==null?void 0:f.method)!=null?a:"POST",headers:{"Content-Type":"application/json","x-immutable-publishable-key":i},body:JSON.stringify(s),keepalive:f==null?void 0:f.keepalive,signal:h.signal});if(g.status===429){re("audience","transport_send_failed",{status:429});let y=zr(g.headers);return {ok:!1,error:new Se({status:429,endpoint:r}),...y!==null?{retryAfterMs:y}:{}}}if(!g.ok){let y=await Pt(g);return re("audience","transport_send_failed",{status:g.status}),{ok:!1,error:new Se({status:g.status,endpoint:r,body:y})}}let I=await Pt(g);if(typeof I=="object"&&I!==null&&"rejected"in I){let y=(m=I.rejected)!=null?m:0;if(y>0)return re("audience","transport_partial_rejected",{status:g.status,rejected:y}),{ok:!1,error:new Se({status:g.status,endpoint:r,body:I})}}return {ok:!0}}catch(g){let I=new Se({status:0,endpoint:r,cause:g});return Lt("audience","transport_send",I),{ok:!1,error:I}}finally{clearTimeout(c);}},tt="__imtbl_audience_";function nt(){try{return j()&&typeof localStorage<"u"}catch(r){return !1}}function Yr(r,i=tt){if(nt())try{let s=localStorage.getItem(`${i}${r}`);return s?JSON.parse(s):void 0}catch(s){return}}function Hr(r,i,s=tt){if(nt())try{localStorage.setItem(`${s}${r}`,JSON.stringify(i));}catch(f){}}function Wr(r,i=tt){if(nt())try{localStorage.removeItem(`${i}${r}`);}catch(s){}}var Ze="queue",Mt=100,jt=class{constructor(r,i,s){w(this,"messages");w(this,"timer",null);w(this,"flushing",!1);w(this,"unloadBound",!1);w(this,"visibilityHandler");w(this,"pagehideHandler");w(this,"onFlush");w(this,"onError");w(this,"storagePrefix");w(this,"endpointUrl");w(this,"flushIntervalMs");w(this,"flushSize");w(this,"consecutiveFailures",0);w(this,"nextAttemptAt",0);var h,c,a,m;this.send=r,this.publishableKey=i,this.endpointUrl=`${(h=s==null?void 0:s.baseUrl)!=null?h:Ne}${gt}`,this.flushIntervalMs=(c=s==null?void 0:s.flushIntervalMs)!=null?c:5e3,this.flushSize=(a=s==null?void 0:s.flushSize)!=null?a:20,this.onFlush=s==null?void 0:s.onFlush,this.onError=s==null?void 0:s.onError,this.storagePrefix=s==null?void 0:s.storagePrefix;let f=(m=Yr(Ze,this.storagePrefix))!=null?m:[];this.messages=s!=null&&s.staleFilter?f.filter(s.staleFilter):f;}start(){this.timer||(this.timer=setInterval(()=>this.flush(),this.flushIntervalMs),this.registerUnload());}stop(){this.timer&&(clearInterval(this.timer),this.timer=null),this.removeUnload();}destroy(){this.stop(),this.flushUnload();}enqueue(r){this.messages.push(r),this.persist(),this.messages.length>=this.flushSize&&this.flush();}async flush(){var r;if(!(this.flushing||this.messages.length===0)&&!(Date.now()<this.nextAttemptAt)){this.flushing=!0;try{let i=this.messages.slice(0,Mt),s={messages:i},f=await this.send(this.endpointUrl,this.publishableKey,s),h;!f.ok&&f.error&&(h=Dt(f.error,"flush",i.length));let c=(h==null?void 0:h.code)==="VALIDATION_REJECTED";f.ok||c?(this.messages=this.messages.slice(i.length),this.persist(),this.resetBackoff()):h&&(f.retryAfterMs!==void 0?this.setBackoffUntil(Date.now()+f.retryAfterMs):this.recordFailure()),(r=this.onFlush)==null||r.call(this,f.ok,i.length),h&&Ft(this.onError,h);}finally{this.flushing=!1;}}}flushUnload(){if(this.flushing||this.messages.length===0)return;let r=this.messages.slice(0,Mt),i={messages:r};this.send(this.endpointUrl,this.publishableKey,i,{keepalive:!0}),this.messages=this.messages.slice(r.length),this.persist();}purge(r){this.messages=this.messages.filter(i=>!r(i)),this.persist();}transform(r){this.messages=this.messages.map(r),this.persist();}get length(){return this.messages.length}clear(){this.messages=[],Wr(Ze,this.storagePrefix);}registerUnload(){!j()||this.unloadBound||(this.unloadBound=!0,this.pagehideHandler=()=>this.flushUnload(),this.visibilityHandler=()=>{document.visibilityState==="hidden"&&this.flushUnload();},document.addEventListener("visibilitychange",this.visibilityHandler),window.addEventListener("pagehide",this.pagehideHandler));}removeUnload(){this.unloadBound&&(this.visibilityHandler&&document.removeEventListener("visibilitychange",this.visibilityHandler),this.pagehideHandler&&window.removeEventListener("pagehide",this.pagehideHandler),this.unloadBound=!1);}backoffDelayMs(){switch(this.consecutiveFailures){case 0:return 0;case 1:return 5e3;case 2:return 1e4;case 3:return 2e4;case 4:return 4e4;default:return 6e4}}recordFailure(){let r=Date.now();r<this.nextAttemptAt||(this.consecutiveFailures++,this.nextAttemptAt=r+this.backoffDelayMs());}setBackoffUntil(r){this.consecutiveFailures++,this.nextAttemptAt=r;}resetBackoff(){this.consecutiveFailures=0,this.nextAttemptAt=0;}persist(){Hr(Ze,this.messages,this.storagePrefix);}},Jr="2.20.1-alpha.2";function Gt(r="@imtbl/audience",i=Jr){let s={library:r,libraryVersion:i};return j()&&(s.userAgent=navigator.userAgent,s.locale=navigator.language,s.timezone=Intl.DateTimeFormat().resolvedOptions().timeZone,s.screen=`${window.screen.width}x${window.screen.height}`,s.pageUrl=window.location.href,s.pagePath=window.location.pathname,s.pageReferrer=document.referrer,s.pageTitle=document.title),s}function qt(r){let i=new Date(r).getTime();if(Number.isNaN(i))return !1;let s=Date.now();return i<=s+864e5&&i>=s-2592e6}function Vt(r,i,s,f){return r!==s||i!==f}function we(r,i=256){return r.length>i?r.slice(0,i):r}function de(r){let i=ue(z);if(i)return le(z,i,1800,r),{sessionId:i,isNew:!1};let s=Y();return le(z,s,1800,r),{sessionId:s,isNew:!0}}var Kt=["utm_source","utm_medium","utm_campaign","utm_content","utm_term"],zt=["gclid","dclid","fbclid","ttclid","msclkid","li_fat_id"],Yt="__imtbl_attribution";function Xr(r){let i;try{i=new URL(r).searchParams;}catch(h){return {}}let s={};for(let h of [...Kt,...zt]){let c=i.get(h);c&&(s[h]=c);}let f=i.get("referral_code");return f&&(s.referral_code=f),s}function Qr(){try{let r=sessionStorage.getItem(Yt);return r?JSON.parse(r):null}catch(r){return null}}function Zr(r){try{sessionStorage.setItem(Yt,JSON.stringify(r));}catch(i){}}function Ht(){let r=typeof window<"u"&&window.location?Xr(window.location.href):{},i=typeof document<"u"&&document.referrer||void 0,s=zt.some(h=>h in r),f=Kt.some(h=>h in r);return {...r,referrer:i,touchpoint_type:s||f?"click":void 0}}function Wt(){let r=Qr();if(r)return r;let i=typeof window<"u"&&window.location?window.location.href:void 0,s={...Ht(),landing_page:i};return Zr(s),s}function Jt(){return Ht()}function q(r){return r!=="none"}function J(r){return r==="full"}function Xt(r,i,s,f,h,c,a,m){let g=c!=null?c:"none",I={none:0,anonymous:1,full:2};function y(v){let E=`${m!=null?m:Ne}${mt}`;i(E,s,{anonymousId:f,status:v,source:h},{method:"PUT",keepalive:!0}).then(p=>{!p.ok&&p.error&&Ft(a,Dt(p.error,"consent"));});}return {get level(){return g},setLevel(v){v!==g&&(I[v]<I[g]&&(v==="none"?r.purge(()=>!0):v==="anonymous"&&(r.purge(E=>E.type==="identify"||E.type==="alias"),r.transform(E=>{if("userId"in E){let{userId:p,...b}=E;return b}return E}))),g=v,y(v));}}}var Qt="@imtbl/audience",Be="2.20.1-alpha.2",X="[audience]",Zt="WebSDK";var xe=class{constructor(i=!1){w(this,"enabled");this.enabled=i;}logEvent(i,s){this.enabled&&console.log(`${X} ${i}`,s);}logFlush(i,s){this.enabled&&console.log(`${X} flush ${i?"ok":"failed"} (${s} messages)`);}logConsent(i,s){this.enabled&&console.log(`${X} consent ${i} \u2192 ${s}`);}logWarning(i){this.enabled&&console.warn(`${X} ${i}`);}};var es=new Set(["sign_up","link_clicked"]),D=class D{constructor(i){w(this,"queue");w(this,"consent");w(this,"attribution");w(this,"debug");w(this,"cookieDomain");w(this,"testMode");w(this,"anonymousId");w(this,"sessionId");w(this,"sessionStartTime");w(this,"userId");w(this,"isFirstPage",!0);w(this,"destroyed",!1);var g,I,y,v;let{cookieDomain:s,publishableKey:f}=i,h=(g=i.consent)!=null?g:"none",c=Zt;this.cookieDomain=s,this.testMode=(I=i.testMode)!=null?I:!1,this.debug=new xe((y=i.debug)!=null?y:!1);let a=D.readAndStripAidParam(),m=!1;q(h)?(a?(Pe(a,s),this.anonymousId=a):this.anonymousId=ge(s),m=this.startSession()):this.anonymousId=(v=ue(K))!=null?v:Y(),this.queue=new jt(et,f,{baseUrl:i.baseUrl,flushIntervalMs:i.flushInterval,flushSize:i.flushSize,onFlush:(E,p)=>this.debug.logFlush(E,p),onError:i.onError,staleFilter:E=>qt(E.eventTimestamp),storagePrefix:"__imtbl_web_"}),this.consent=Xt(this.queue,et,f,this.anonymousId,c,h,i.onError,i.baseUrl),this.attribution=Wt(),this.isTrackingDisabled()||(this.queue.start(),m&&this.trackSessionStart());}static readAndStripAidParam(){if(!j())return null;let i=new URLSearchParams(window.location.search),s=i.get("imtbl_aid");if(s!==null){i.delete("imtbl_aid");let f=i.toString(),h=`${window.location.pathname}${f?`?${f}`:""}${window.location.hash}`;window.history.replaceState(window.history.state,"",h);}return s&&D.UUID_RE.test(s)?s:null}static init(i){var s;if(!((s=i.publishableKey)!=null&&s.trim()))throw new Error(`${X} publishableKey is required`);return D.liveInstances>0&&console.warn(`${X} Multiple SDK instances detected. Ensure previous instances are shut down to avoid duplicate events.`),D.liveInstances+=1,new D(i)}getAnonymousId(){return this.anonymousId}isTrackingDisabled(){return !q(this.consent.level)}effectiveUserId(){return J(this.consent.level)?this.userId:void 0}startSession(){let i=de(this.cookieDomain);return this.sessionId=i.sessionId,this.sessionStartTime=Date.now(),i.isNew}baseMessage(){return {messageId:Y(),eventTimestamp:Le(),anonymousId:this.anonymousId,surface:"web",context:Gt(Qt,Be),...this.testMode&&{test:!0}}}enqueue(i,s){this.queue.enqueue(s),this.debug.logEvent(i,s);}trackSessionStart(){this.sessionId&&this.enqueue("track(session_start)",{...this.baseMessage(),type:"track",eventName:Re,properties:{session_id:this.sessionId,...this.attribution}});}trackSessionEnd(){this.sessionId&&this.enqueue("track(session_end)",{...this.baseMessage(),type:"track",eventName:Ce,properties:{session_id:this.sessionId,...this.sessionStartTime&&{duration:Math.round((Date.now()-this.sessionStartTime)/1e3)}}});}page(i){if(this.isTrackingDisabled())return;de(this.cookieDomain);let s={session_id:this.sessionId,...i};this.isFirstPage&&(Object.assign(s,this.attribution),this.isFirstPage=!1),this.enqueue("page",{...this.baseMessage(),type:"page",properties:s,userId:this.effectiveUserId()});}track(i,...s){if(this.isTrackingDisabled())return;de(this.cookieDomain);let[f]=s,h={session_id:this.sessionId,...es.has(i)?Jt():{},...f};this.enqueue("track",{...this.baseMessage(),type:"track",eventName:we(i),properties:h,userId:this.effectiveUserId()});}identify(i,s,f){if(!J(this.consent.level)){this.debug.logWarning("identify() requires full consent \u2014 call ignored.");return}de(this.cookieDomain);let h=we(i);this.userId=h,this.enqueue("identify",{...this.baseMessage(),type:"identify",userId:h,identityType:s,traits:f});}alias(i,s){if(!J(this.consent.level)){this.debug.logWarning("alias() requires full consent \u2014 call ignored.");return}if(!Vt(i.id,i.identityType,s.id,s.identityType)){this.debug.logWarning("alias() from and to are identical \u2014 call ignored.");return}de(this.cookieDomain),this.enqueue("alias",{...this.baseMessage(),type:"alias",fromId:we(i.id),fromType:i.identityType,toId:we(s.id),toType:s.identityType});}setConsent(i){let s=this.consent.level;if(i===s)return;this.debug.logConsent(s,i);let f=!q(s)&&q(i);if(f&&(this.anonymousId=ge(this.cookieDomain)),q(i)||this.queue.stop(),this.consent.setLevel(i),q(i)?J(s)&&!J(i)&&(this.userId=void 0):(fe(K,this.cookieDomain),fe(z,this.cookieDomain)),f){this.isFirstPage=!0;let h=this.startSession();this.queue.start(),h&&this.trackSessionStart();}}reset(){this.userId=void 0,this.queue.clear(),fe(K,this.cookieDomain),fe(z,this.cookieDomain),this.isTrackingDisabled()?(this.anonymousId=Y(),this.sessionId=void 0,this.sessionStartTime=void 0):(this.anonymousId=ge(this.cookieDomain),this.startSession()&&this.trackSessionStart()),this.isFirstPage=!0;}async flush(){await this.queue.flush();}shutdown(){this.destroyed||(this.destroyed=!0,this.isTrackingDisabled()||this.trackSessionEnd(),this.queue.destroy(),D.liveInstances=Math.max(0,D.liveInstances-1));}};w(D,"liveInstances",0),w(D,"UUID_RE",/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i);var be=D;var en={SIGN_UP:"sign_up",SIGN_IN:"sign_in",WISHLIST_ADD:"wishlist_add",WISHLIST_REMOVE:"wishlist_remove",PURCHASE:"purchase",GAME_LAUNCH:"game_launch",PROGRESSION:"progression",RESOURCE:"resource",EMAIL_ACQUIRED:"email_acquired",GAME_PAGE_VIEWED:"game_page_viewed",LINK_CLICKED:"link_clicked",BUTTON_CLICKED:"button_clicked"};var it=typeof globalThis!="undefined"?globalThis:window,tn;if(it.ImmutableAudience){let r=(tn=it.ImmutableAudience.version)!=null?tn:"unknown";console.warn(`[@imtbl/audience] CDN bundle loaded twice; keeping v${r}. Remove the old <script> tag to load a different version.`);}else it.ImmutableAudience={init:be.init.bind(be),AudienceError:se,AudienceEvents:en,IdentityType:$t,canIdentify:J,canTrack:q,version:Be};
|
|
6
|
+
${a.stack}`),re(r,`trackError_${i}`,{...f||{},errorMessage:c,errorStack:h,isTrackError:!0});},Pt=$(Fr),qr=r=>{ne("env",r);};$(ye("setEnvironment",qr));var Vr=r=>{ne("passportClientId",r);};$(ye("setPassportClientId",Vr));var Kr=r=>{ne("pak",r);};$(ye("setPublishableApiKey",Kr));$(ye("getDetail",ze));var Dt={Passport:"passport",Steam:"steam",Epic:"epic",Google:"google",Apple:"apple",Discord:"discord",Email:"email",Custom:"custom"},Se=class extends Error{constructor(i){super(`audience transport failed: ${i.status||"network error"} ${i.endpoint}`,i.cause!==void 0?{cause:i.cause}:void 0);w(this,"status");w(this,"endpoint");w(this,"body");this.name="TransportError",this.status=i.status,this.endpoint=i.endpoint,this.body=i.body;}},se=class extends Error{constructor(i){super(i.message);w(this,"code");w(this,"status");w(this,"endpoint");w(this,"responseBody");w(this,"cause");this.name="AudienceError",this.code=i.code,this.status=i.status,this.endpoint=i.endpoint,this.responseBody=i.responseBody,this.cause=i.cause;}};function Ft(r,i,s){var f,c;if(r.status===0)return new se({code:"NETWORK_ERROR",message:i==="flush"?`Network error sending ${s!=null?s:0} messages`:"Network error syncing consent",status:0,endpoint:r.endpoint,cause:r.cause});if(r.status>=200&&r.status<300){let h=r.body,a=(f=h==null?void 0:h.rejected)!=null?f:0,g=(c=h==null?void 0:h.accepted)!=null?c:0;return new se({code:"VALIDATION_REJECTED",message:`Backend rejected ${a} of ${a+g} messages`,status:r.status,endpoint:r.endpoint,responseBody:r.body})}return r.status===429?new se({code:"RATE_LIMITED",message:i==="flush"?"Flush rate limited (429)":"Consent sync rate limited (429)",status:r.status,endpoint:r.endpoint,responseBody:r.body}):r.status>=400&&r.status<500?new se({code:i==="flush"?"VALIDATION_REJECTED":"CONSENT_SYNC_FAILED",message:i==="flush"?`Flush rejected with status ${r.status}`:`Consent sync failed with status ${r.status}`,status:r.status,endpoint:r.endpoint,responseBody:r.body}):new se({code:i==="flush"?"FLUSH_FAILED":"CONSENT_SYNC_FAILED",message:i==="flush"?`Flush failed with status ${r.status}`:`Consent sync failed with status ${r.status}`,status:r.status,endpoint:r.endpoint,responseBody:r.body,cause:r.cause})}function jt(r,i){if(r)try{r(i);}catch(s){}}var zr=3e4;function Yr(r){var c;let i=(c=r.get)==null?void 0:c.call(r,"retry-after");if(!i)return null;let s=Number(i.trim());if(!Number.isNaN(s)&&s>=0)return Math.round(s*1e3);let f=new Date(i);if(!Number.isNaN(f.getTime())){let h=f.getTime()-Date.now();return h>0?h:null}return null}function Ze(){try{return j()?navigator.onLine:void 0}catch(r){return}}async function Mt(r){var s,f,c;let i=(c=(f=(s=r.headers)==null?void 0:s.get)==null?void 0:f.call(s,"content-type"))!=null?c:"";try{return i.includes("application/json")?await r.json():await r.text()}catch(h){return}}var tt=async(r,i,s,f)=>{var g,E;let c=new AbortController,h=setTimeout(()=>c.abort(),zr),a=Date.now();try{let v=await fetch(r,{method:(g=f==null?void 0:f.method)!=null?g:"POST",headers:{"Content-Type":"application/json","x-immutable-publishable-key":i},body:JSON.stringify(s),keepalive:f==null?void 0:f.keepalive,signal:c.signal});if(v.status===429){re("audience","transport_send_failed",{status:429,online:Ze(),timeToFailureMs:Date.now()-a});let m=Yr(v.headers);return {ok:!1,error:new Se({status:429,endpoint:r}),...m!==null?{retryAfterMs:m}:{}}}if(!v.ok){let m=await Mt(v);return re("audience","transport_send_failed",{status:v.status,online:Ze(),timeToFailureMs:Date.now()-a}),{ok:!1,error:new Se({status:v.status,endpoint:r,body:m})}}let y=await Mt(v);if(typeof y=="object"&&y!==null&&"rejected"in y){let m=(E=y.rejected)!=null?E:0;if(m>0)return re("audience","transport_partial_rejected",{status:v.status,rejected:m}),{ok:!1,error:new Se({status:v.status,endpoint:r,body:y})}}return {ok:!0}}catch(v){let y=new Se({status:0,endpoint:r,cause:v});return Pt("audience","transport_send",y,{errorName:v instanceof Error?v.name:void 0,online:Ze(),timeToFailureMs:Date.now()-a}),{ok:!1,error:y}}finally{clearTimeout(h);}},nt="__imtbl_audience_";function it(){try{return j()&&typeof localStorage<"u"}catch(r){return !1}}function Hr(r,i=nt){if(it())try{let s=localStorage.getItem(`${i}${r}`);return s?JSON.parse(s):void 0}catch(s){return}}function Wr(r,i,s=nt){if(it())try{localStorage.setItem(`${s}${r}`,JSON.stringify(i));}catch(f){}}function Jr(r,i=nt){if(it())try{localStorage.removeItem(`${i}${r}`);}catch(s){}}var et="queue",$t=100,Gt=class{constructor(r,i,s){w(this,"messages");w(this,"timer",null);w(this,"flushing",!1);w(this,"unloadBound",!1);w(this,"visibilityHandler");w(this,"pagehideHandler");w(this,"onFlush");w(this,"onError");w(this,"storagePrefix");w(this,"endpointUrl");w(this,"flushIntervalMs");w(this,"flushSize");w(this,"consecutiveFailures",0);w(this,"nextAttemptAt",0);var c,h,a,g;this.send=r,this.publishableKey=i,this.endpointUrl=`${(c=s==null?void 0:s.baseUrl)!=null?c:Ne}${mt}`,this.flushIntervalMs=(h=s==null?void 0:s.flushIntervalMs)!=null?h:5e3,this.flushSize=(a=s==null?void 0:s.flushSize)!=null?a:20,this.onFlush=s==null?void 0:s.onFlush,this.onError=s==null?void 0:s.onError,this.storagePrefix=s==null?void 0:s.storagePrefix;let f=(g=Hr(et,this.storagePrefix))!=null?g:[];this.messages=s!=null&&s.staleFilter?f.filter(s.staleFilter):f;}start(){this.timer||(this.timer=setInterval(()=>this.flush(),this.flushIntervalMs),this.registerUnload());}stop(){this.timer&&(clearInterval(this.timer),this.timer=null),this.removeUnload();}destroy(){this.stop(),this.flushUnload();}enqueue(r){this.messages.push(r),this.persist(),this.messages.length>=this.flushSize&&this.flush();}async flush(){var r;if(!(this.flushing||this.messages.length===0)&&!(Date.now()<this.nextAttemptAt)){this.flushing=!0;try{let i=this.messages.slice(0,$t),s={messages:i},f=await this.send(this.endpointUrl,this.publishableKey,s),c;!f.ok&&f.error&&(c=Ft(f.error,"flush",i.length));let h=(c==null?void 0:c.code)==="VALIDATION_REJECTED";f.ok||h?(this.messages=this.messages.slice(i.length),this.persist(),this.resetBackoff()):c&&(f.retryAfterMs!==void 0?this.setBackoffUntil(Date.now()+f.retryAfterMs):this.recordFailure()),(r=this.onFlush)==null||r.call(this,f.ok,i.length),c&&jt(this.onError,c);}finally{this.flushing=!1;}}}flushUnload(){if(this.flushing||this.messages.length===0)return;let r=this.messages.slice(0,$t),i={messages:r};this.send(this.endpointUrl,this.publishableKey,i,{keepalive:!0}),this.messages=this.messages.slice(r.length),this.persist();}purge(r){this.messages=this.messages.filter(i=>!r(i)),this.persist();}transform(r){this.messages=this.messages.map(r),this.persist();}get length(){return this.messages.length}clear(){this.messages=[],Jr(et,this.storagePrefix);}registerUnload(){!j()||this.unloadBound||(this.unloadBound=!0,this.pagehideHandler=()=>this.flushUnload(),this.visibilityHandler=()=>{document.visibilityState==="hidden"&&this.flushUnload();},document.addEventListener("visibilitychange",this.visibilityHandler),window.addEventListener("pagehide",this.pagehideHandler));}removeUnload(){this.unloadBound&&(this.visibilityHandler&&document.removeEventListener("visibilitychange",this.visibilityHandler),this.pagehideHandler&&window.removeEventListener("pagehide",this.pagehideHandler),this.unloadBound=!1);}backoffDelayMs(){switch(this.consecutiveFailures){case 0:return 0;case 1:return 5e3;case 2:return 1e4;case 3:return 2e4;case 4:return 4e4;default:return 6e4}}recordFailure(){let r=Date.now();r<this.nextAttemptAt||(this.consecutiveFailures++,this.nextAttemptAt=r+this.backoffDelayMs());}setBackoffUntil(r){this.consecutiveFailures++,this.nextAttemptAt=r;}resetBackoff(){this.consecutiveFailures=0,this.nextAttemptAt=0;}persist(){Wr(et,this.messages,this.storagePrefix);}},Xr="2.20.1";function qt(r="@imtbl/audience",i=Xr){let s={library:r,libraryVersion:i};return j()&&(s.userAgent=navigator.userAgent,s.locale=navigator.language,s.timezone=Intl.DateTimeFormat().resolvedOptions().timeZone,s.screen=`${window.screen.width}x${window.screen.height}`,s.pageUrl=window.location.href,s.pagePath=window.location.pathname,s.pageReferrer=document.referrer,s.pageTitle=document.title),s}function Vt(r){let i=new Date(r).getTime();if(Number.isNaN(i))return !1;let s=Date.now();return i<=s+864e5&&i>=s-2592e6}function Kt(r,i,s,f){return r!==s||i!==f}function we(r,i=256){return r.length>i?r.slice(0,i):r}function de(r){let i=ue(z);if(i)return le(z,i,1800,r),{sessionId:i,isNew:!1};let s=Y();return le(z,s,1800,r),{sessionId:s,isNew:!0}}var zt=["utm_source","utm_medium","utm_campaign","utm_content","utm_term"],Yt=["gclid","dclid","fbclid","ttclid","msclkid","li_fat_id"],Ht="__imtbl_attribution";function Qr(r){let i;try{i=new URL(r).searchParams;}catch(c){return {}}let s={};for(let c of [...zt,...Yt]){let h=i.get(c);h&&(s[c]=h);}let f=i.get("referral_code");return f&&(s.referral_code=f),s}function Zr(){try{let r=sessionStorage.getItem(Ht);return r?JSON.parse(r):null}catch(r){return null}}function es(r){try{sessionStorage.setItem(Ht,JSON.stringify(r));}catch(i){}}function Wt(){let r=typeof window<"u"&&window.location?Qr(window.location.href):{},i=typeof document<"u"&&document.referrer||void 0,s=Yt.some(c=>c in r),f=zt.some(c=>c in r);return {...r,referrer:i,touchpoint_type:s||f?"click":void 0}}function Jt(){let r=Zr();if(r)return r;let i=typeof window<"u"&&window.location?window.location.href:void 0,s={...Wt(),landing_page:i};return es(s),s}function Xt(){return Wt()}function q(r){return r!=="none"}function J(r){return r==="full"}function Qt(r,i,s,f,c,h,a,g){let E=h!=null?h:"none",v={none:0,anonymous:1,full:2};function y(m){let I=`${g!=null?g:Ne}${yt}`;i(I,s,{anonymousId:f,status:m,source:c},{method:"PUT",keepalive:!0}).then(p=>{!p.ok&&p.error&&jt(a,Ft(p.error,"consent"));});}return {get level(){return E},setLevel(m){m!==E&&(v[m]<v[E]&&(m==="none"?r.purge(()=>!0):m==="anonymous"&&(r.purge(I=>I.type==="identify"||I.type==="alias"),r.transform(I=>{if("userId"in I){let{userId:p,...b}=I;return b}return I}))),E=m,y(m));}}}var Zt="@imtbl/audience",Be="2.20.1",X="[audience]",en="WebSDK";var xe=class{constructor(i=!1){w(this,"enabled");this.enabled=i;}logEvent(i,s){this.enabled&&console.log(`${X} ${i}`,s);}logFlush(i,s){this.enabled&&console.log(`${X} flush ${i?"ok":"failed"} (${s} messages)`);}logConsent(i,s){this.enabled&&console.log(`${X} consent ${i} \u2192 ${s}`);}logWarning(i){this.enabled&&console.warn(`${X} ${i}`);}};var ts=new Set(["sign_up","link_clicked"]),D=class D{constructor(i){w(this,"queue");w(this,"consent");w(this,"attribution");w(this,"debug");w(this,"cookieDomain");w(this,"testMode");w(this,"anonymousId");w(this,"sessionId");w(this,"sessionStartTime");w(this,"userId");w(this,"isFirstPage",!0);w(this,"destroyed",!1);var E,v,y,m;let{cookieDomain:s,publishableKey:f}=i,c=(E=i.consent)!=null?E:"none",h=en;this.cookieDomain=s,this.testMode=(v=i.testMode)!=null?v:!1,this.debug=new xe((y=i.debug)!=null?y:!1);let a=D.readAndStripAidParam(),g=!1;q(c)?(a?(Pe(a,s),this.anonymousId=a):this.anonymousId=ge(s),g=this.startSession()):this.anonymousId=(m=ue(K))!=null?m:Y(),this.queue=new Gt(tt,f,{baseUrl:i.baseUrl,flushIntervalMs:i.flushInterval,flushSize:i.flushSize,onFlush:(I,p)=>this.debug.logFlush(I,p),onError:i.onError,staleFilter:I=>Vt(I.eventTimestamp),storagePrefix:"__imtbl_web_"}),this.consent=Qt(this.queue,tt,f,this.anonymousId,h,c,i.onError,i.baseUrl),this.attribution=Jt(),this.isTrackingDisabled()||(this.queue.start(),g&&this.trackSessionStart());}static readAndStripAidParam(){if(!j())return null;let i=new URLSearchParams(window.location.search),s=i.get("imtbl_aid");if(s!==null){i.delete("imtbl_aid");let f=i.toString(),c=`${window.location.pathname}${f?`?${f}`:""}${window.location.hash}`;window.history.replaceState(window.history.state,"",c);}return s&&D.UUID_RE.test(s)?s:null}static init(i){var s;if(!((s=i.publishableKey)!=null&&s.trim()))throw new Error(`${X} publishableKey is required`);return D.liveInstances>0&&console.warn(`${X} Multiple SDK instances detected. Ensure previous instances are shut down to avoid duplicate events.`),D.liveInstances+=1,new D(i)}getAnonymousId(){return this.anonymousId}isTrackingDisabled(){return !q(this.consent.level)}effectiveUserId(){return J(this.consent.level)?this.userId:void 0}startSession(){let i=de(this.cookieDomain);return this.sessionId=i.sessionId,this.sessionStartTime=Date.now(),i.isNew}baseMessage(){return {messageId:Y(),eventTimestamp:Le(),anonymousId:this.anonymousId,surface:"web",context:qt(Zt,Be),...this.testMode&&{test:!0}}}enqueue(i,s){this.queue.enqueue(s),this.debug.logEvent(i,s);}trackSessionStart(){this.sessionId&&this.enqueue("track(session_start)",{...this.baseMessage(),type:"track",eventName:Re,properties:{session_id:this.sessionId,...this.attribution}});}trackSessionEnd(){this.sessionId&&this.enqueue("track(session_end)",{...this.baseMessage(),type:"track",eventName:Ce,properties:{session_id:this.sessionId,...this.sessionStartTime&&{duration:Math.round((Date.now()-this.sessionStartTime)/1e3)}}});}page(i){if(this.isTrackingDisabled())return;de(this.cookieDomain);let s={session_id:this.sessionId,...i};this.isFirstPage&&(Object.assign(s,this.attribution),this.isFirstPage=!1),this.enqueue("page",{...this.baseMessage(),type:"page",properties:s,userId:this.effectiveUserId()});}track(i,...s){if(this.isTrackingDisabled())return;de(this.cookieDomain);let[f]=s,c={session_id:this.sessionId,...ts.has(i)?Xt():{},...f};this.enqueue("track",{...this.baseMessage(),type:"track",eventName:we(i),properties:c,userId:this.effectiveUserId()});}identify(i,s,f){if(!J(this.consent.level)){this.debug.logWarning("identify() requires full consent \u2014 call ignored.");return}de(this.cookieDomain);let c=we(i);this.userId=c,this.enqueue("identify",{...this.baseMessage(),type:"identify",userId:c,identityType:s,traits:f});}alias(i,s){if(!J(this.consent.level)){this.debug.logWarning("alias() requires full consent \u2014 call ignored.");return}if(!Kt(i.id,i.identityType,s.id,s.identityType)){this.debug.logWarning("alias() from and to are identical \u2014 call ignored.");return}de(this.cookieDomain),this.enqueue("alias",{...this.baseMessage(),type:"alias",fromId:we(i.id),fromType:i.identityType,toId:we(s.id),toType:s.identityType});}setConsent(i){let s=this.consent.level;if(i===s)return;this.debug.logConsent(s,i);let f=!q(s)&&q(i);if(f&&(this.anonymousId=ge(this.cookieDomain)),q(i)||this.queue.stop(),this.consent.setLevel(i),q(i)?J(s)&&!J(i)&&(this.userId=void 0):(fe(K,this.cookieDomain),fe(z,this.cookieDomain)),f){this.isFirstPage=!0;let c=this.startSession();this.queue.start(),c&&this.trackSessionStart();}}reset(){this.userId=void 0,this.queue.clear(),fe(K,this.cookieDomain),fe(z,this.cookieDomain),this.isTrackingDisabled()?(this.anonymousId=Y(),this.sessionId=void 0,this.sessionStartTime=void 0):(this.anonymousId=ge(this.cookieDomain),this.startSession()&&this.trackSessionStart()),this.isFirstPage=!0;}async flush(){await this.queue.flush();}shutdown(){this.destroyed||(this.destroyed=!0,this.isTrackingDisabled()||this.trackSessionEnd(),this.queue.destroy(),D.liveInstances=Math.max(0,D.liveInstances-1));}};w(D,"liveInstances",0),w(D,"UUID_RE",/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i);var be=D;var tn={SIGN_UP:"sign_up",SIGN_IN:"sign_in",WISHLIST_ADD:"wishlist_add",WISHLIST_REMOVE:"wishlist_remove",PURCHASE:"purchase",GAME_LAUNCH:"game_launch",PROGRESSION:"progression",RESOURCE:"resource",EMAIL_ACQUIRED:"email_acquired",GAME_PAGE_VIEWED:"game_page_viewed",LINK_CLICKED:"link_clicked",BUTTON_CLICKED:"button_clicked"};var rt=typeof globalThis!="undefined"?globalThis:window,nn;if(rt.ImmutableAudience){let r=(nn=rt.ImmutableAudience.version)!=null?nn:"unknown";console.warn(`[@imtbl/audience] CDN bundle loaded twice; keeping v${r}. Remove the old <script> tag to load a different version.`);}else rt.ImmutableAudience={init:be.init.bind(be),AudienceError:se,AudienceEvents:tn,IdentityType:Dt,canIdentify:J,canTrack:q,version:Be};
|
|
7
7
|
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
8
8
|
/*! Bundled license information:
|
|
9
9
|
|
package/dist/node/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
Cause: ${
|
|
5
|
-
${o.stack}`),_(e,`trackError_${t}`,{...i||{},errorMessage:r,errorStack:n,isTrackError:!0});},Se=d(Kt),zt=e=>{S("env",e);};d(C("setEnvironment",zt));var Wt=e=>{S("passportClientId",e);};d(C("setPassportClientId",Wt));var Jt=e=>{S("pak",e);};d(C("setPublishableApiKey",Jt));d(C("getDetail",Y));var Yt={Passport:"passport",Steam:"steam",Epic:"epic",Google:"google",Apple:"apple",Discord:"discord",Email:"email",Custom:"custom"},U=class extends Error{status;endpoint;body;constructor(e){super(`audience transport failed: ${e.status||"network error"} ${e.endpoint}`,e.cause!==void 0?{cause:e.cause}:void 0),this.name="TransportError",this.status=e.status,this.endpoint=e.endpoint,this.body=e.body;}},N=class extends Error{code;status;endpoint;responseBody;cause;constructor(e){super(e.message),this.name="AudienceError",this.code=e.code,this.status=e.status,this.endpoint=e.endpoint,this.responseBody=e.responseBody,this.cause=e.cause;}};function ke(e,t,s){if(e.status===0)return new N({code:"NETWORK_ERROR",message:t==="flush"?`Network error sending ${s??0} messages`:"Network error syncing consent",status:0,endpoint:e.endpoint,cause:e.cause});if(e.status>=200&&e.status<300){let i=e.body,r=i?.rejected??0,n=i?.accepted??0;return new N({code:"VALIDATION_REJECTED",message:`Backend rejected ${r} of ${r+n} messages`,status:e.status,endpoint:e.endpoint,responseBody:e.body})}return e.status===429?new N({code:"RATE_LIMITED",message:t==="flush"?"Flush rate limited (429)":"Consent sync rate limited (429)",status:e.status,endpoint:e.endpoint,responseBody:e.body}):e.status>=400&&e.status<500?new N({code:t==="flush"?"VALIDATION_REJECTED":"CONSENT_SYNC_FAILED",message:t==="flush"?`Flush rejected with status ${e.status}`:`Consent sync failed with status ${e.status}`,status:e.status,endpoint:e.endpoint,responseBody:e.body}):new N({code:t==="flush"?"FLUSH_FAILED":"CONSENT_SYNC_FAILED",message:t==="flush"?`Flush failed with status ${e.status}`:`Consent sync failed with status ${e.status}`,status:e.status,endpoint:e.endpoint,responseBody:e.body,cause:e.cause})}function Ae(e,t){if(e)try{e(t);}catch{}}var Xt=3e4;function Qt(e){let t=e.get?.("retry-after");if(!t)return null;let s=Number(t.trim());if(!Number.isNaN(s)&&s>=0)return Math.round(s*1e3);let i=new Date(t);if(!Number.isNaN(i.getTime())){let r=i.getTime()-Date.now();return r>0?r:null}return null}async function _e(e){let t=e.headers?.get?.("content-type")??"";try{return t.includes("application/json")?await e.json():await e.text()}catch{return}}var se=async(e,t,s,i)=>{let r=new AbortController,n=setTimeout(()=>r.abort(),Xt);try{let o=await fetch(e,{method:i?.method??"POST",headers:{"Content-Type":"application/json","x-immutable-publishable-key":t},body:JSON.stringify(s),keepalive:i?.keepalive,signal:r.signal});if(o.status===429){_("audience","transport_send_failed",{status:429});let a=Qt(o.headers);return {ok:!1,error:new U({status:429,endpoint:e}),...a!==null?{retryAfterMs:a}:{}}}if(!o.ok){let a=await _e(o);return _("audience","transport_send_failed",{status:o.status}),{ok:!1,error:new U({status:o.status,endpoint:e,body:a})}}let l=await _e(o);if(typeof l=="object"&&l!==null&&"rejected"in l){let a=l.rejected??0;if(a>0)return _("audience","transport_partial_rejected",{status:o.status,rejected:a}),{ok:!1,error:new U({status:o.status,endpoint:e,body:l})}}return {ok:!0}}catch(o){let l=new U({status:0,endpoint:e,cause:o});return Se("audience","transport_send",l),{ok:!1,error:l}}finally{clearTimeout(n);}},ie="__imtbl_audience_";function re(){try{return f()&&typeof localStorage<"u"}catch{return !1}}function Zt(e,t=ie){if(re())try{let s=localStorage.getItem(`${t}${e}`);return s?JSON.parse(s):void 0}catch{return}}function es(e,t,s=ie){if(re())try{localStorage.setItem(`${s}${e}`,JSON.stringify(t));}catch{}}function ts(e,t=ie){if(re())try{localStorage.removeItem(`${t}${e}`);}catch{}}var te="queue",xe=100,Pe=class{constructor(e,t,s){this.send=e,this.publishableKey=t,this.endpointUrl=`${s?.baseUrl??j}${ue}`,this.flushIntervalMs=s?.flushIntervalMs??5e3,this.flushSize=s?.flushSize??20,this.onFlush=s?.onFlush,this.onError=s?.onError,this.storagePrefix=s?.storagePrefix;let i=Zt(te,this.storagePrefix)??[];this.messages=s?.staleFilter?i.filter(s.staleFilter):i;}messages;timer=null;flushing=!1;unloadBound=!1;visibilityHandler;pagehideHandler;onFlush;onError;storagePrefix;endpointUrl;flushIntervalMs;flushSize;consecutiveFailures=0;nextAttemptAt=0;start(){this.timer||(this.timer=setInterval(()=>this.flush(),this.flushIntervalMs),this.registerUnload());}stop(){this.timer&&(clearInterval(this.timer),this.timer=null),this.removeUnload();}destroy(){this.stop(),this.flushUnload();}enqueue(e){this.messages.push(e),this.persist(),this.messages.length>=this.flushSize&&this.flush();}async flush(){if(!(this.flushing||this.messages.length===0)&&!(Date.now()<this.nextAttemptAt)){this.flushing=!0;try{let e=this.messages.slice(0,xe),t={messages:e},s=await this.send(this.endpointUrl,this.publishableKey,t),i;!s.ok&&s.error&&(i=ke(s.error,"flush",e.length));let r=i?.code==="VALIDATION_REJECTED";s.ok||r?(this.messages=this.messages.slice(e.length),this.persist(),this.resetBackoff()):i&&(s.retryAfterMs!==void 0?this.setBackoffUntil(Date.now()+s.retryAfterMs):this.recordFailure()),this.onFlush?.(s.ok,e.length),i&&Ae(this.onError,i);}finally{this.flushing=!1;}}}flushUnload(){if(this.flushing||this.messages.length===0)return;let e=this.messages.slice(0,xe),t={messages:e};this.send(this.endpointUrl,this.publishableKey,t,{keepalive:!0}),this.messages=this.messages.slice(e.length),this.persist();}purge(e){this.messages=this.messages.filter(t=>!e(t)),this.persist();}transform(e){this.messages=this.messages.map(e),this.persist();}get length(){return this.messages.length}clear(){this.messages=[],ts(te,this.storagePrefix);}registerUnload(){!f()||this.unloadBound||(this.unloadBound=!0,this.pagehideHandler=()=>this.flushUnload(),this.visibilityHandler=()=>{document.visibilityState==="hidden"&&this.flushUnload();},document.addEventListener("visibilitychange",this.visibilityHandler),window.addEventListener("pagehide",this.pagehideHandler));}removeUnload(){this.unloadBound&&(this.visibilityHandler&&document.removeEventListener("visibilitychange",this.visibilityHandler),this.pagehideHandler&&window.removeEventListener("pagehide",this.pagehideHandler),this.unloadBound=!1);}backoffDelayMs(){switch(this.consecutiveFailures){case 0:return 0;case 1:return 5e3;case 2:return 1e4;case 3:return 2e4;case 4:return 4e4;default:return 6e4}}recordFailure(){let e=Date.now();e<this.nextAttemptAt||(this.consecutiveFailures++,this.nextAttemptAt=e+this.backoffDelayMs());}setBackoffUntil(e){this.consecutiveFailures++,this.nextAttemptAt=e;}resetBackoff(){this.consecutiveFailures=0,this.nextAttemptAt=0;}persist(){es(te,this.messages,this.storagePrefix);}},ss="2.20.1-alpha.2";function Te(e="@imtbl/audience",t=ss){let s={library:e,libraryVersion:t};return f()&&(s.userAgent=navigator.userAgent,s.locale=navigator.language,s.timezone=Intl.DateTimeFormat().resolvedOptions().timeZone,s.screen=`${window.screen.width}x${window.screen.height}`,s.pageUrl=window.location.href,s.pagePath=window.location.pathname,s.pageReferrer=document.referrer,s.pageTitle=document.title),s}function Ne(e){let t=new Date(e).getTime();if(Number.isNaN(t))return !1;let s=Date.now();return t<=s+864e5&&t>=s-2592e6}function Oe(e,t,s,i){return e!==s||t!==i}function $(e,t=256){return e.length>t?e.slice(0,t):e}function O(e){let t=k(y);if(t)return A(y,t,1800,e),{sessionId:t,isNew:!1};let s=v();return A(y,s,1800,e),{sessionId:s,isNew:!0}}var De=["utm_source","utm_medium","utm_campaign","utm_content","utm_term"],Ce=["gclid","dclid","fbclid","ttclid","msclkid","li_fat_id"],$e="__imtbl_attribution";function is(e){let t;try{t=new URL(e).searchParams;}catch{return {}}let s={};for(let r of [...De,...Ce]){let n=t.get(r);n&&(s[r]=n);}let i=t.get("referral_code");return i&&(s.referral_code=i),s}function rs(){try{let e=sessionStorage.getItem($e);return e?JSON.parse(e):null}catch{return null}}function ns(e){try{sessionStorage.setItem($e,JSON.stringify(e));}catch{}}function Re(){let e=typeof window<"u"&&window.location?is(window.location.href):{},t=typeof document<"u"&&document.referrer||void 0,s=Ce.some(r=>r in e),i=De.some(r=>r in e);return {...e,referrer:t,touchpoint_type:s||i?"click":void 0}}function Me(){let e=rs();if(e)return e;let t=typeof window<"u"&&window.location?window.location.href:void 0,s={...Re(),landing_page:t};return ns(s),s}function Ue(){return Re()}function w(e){return e!=="none"}function x(e){return e==="full"}function Le(e,t,s,i,r,n,o,l){let a=n??"none",h={none:0,anonymous:1,full:2};function m(c){let u=`${l??j}${ce}`;t(u,s,{anonymousId:i,status:c,source:r},{method:"PUT",keepalive:!0}).then(p=>{!p.ok&&p.error&&Ae(o,ke(p.error,"consent"));});}return {get level(){return a},setLevel(c){c!==a&&(h[c]<h[a]&&(c==="none"?e.purge(()=>!0):c==="anonymous"&&(e.purge(u=>u.type==="identify"||u.type==="alias"),e.transform(u=>{if("userId"in u){let{userId:p,...F}=u;return F}return u}))),a=c,m(c));}}}var Fe="@imtbl/audience",je="2.20.1-alpha.2",b="[audience]",Be="WebSDK";var L=class{enabled;constructor(t=!1){this.enabled=t;}logEvent(t,s){this.enabled&&console.log(`${b} ${t}`,s);}logFlush(t,s){this.enabled&&console.log(`${b} flush ${t?"ok":"failed"} (${s} messages)`);}logConsent(t,s){this.enabled&&console.log(`${b} consent ${t} \u2192 ${s}`);}logWarning(t){this.enabled&&console.warn(`${b} ${t}`);}};var os=new Set(["sign_up","link_clicked"]),ne=class e{static liveInstances=0;queue;consent;attribution;debug;cookieDomain;testMode;anonymousId;sessionId;sessionStartTime;userId;isFirstPage=!0;destroyed=!1;static UUID_RE=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;static readAndStripAidParam(){if(!f())return null;let t=new URLSearchParams(window.location.search),s=t.get("imtbl_aid");if(s!==null){t.delete("imtbl_aid");let i=t.toString(),r=`${window.location.pathname}${i?`?${i}`:""}${window.location.hash}`;window.history.replaceState(window.history.state,"",r);}return s&&e.UUID_RE.test(s)?s:null}constructor(t){let{cookieDomain:s,publishableKey:i}=t,r=t.consent??"none",n=Be;this.cookieDomain=s,this.testMode=t.testMode??!1,this.debug=new L(t.debug??!1);let o=e.readAndStripAidParam(),l=!1;w(r)?(o?(K(o,s),this.anonymousId=o):this.anonymousId=D(s),l=this.startSession()):this.anonymousId=k(g)??v(),this.queue=new Pe(se,i,{baseUrl:t.baseUrl,flushIntervalMs:t.flushInterval,flushSize:t.flushSize,onFlush:(a,h)=>this.debug.logFlush(a,h),onError:t.onError,staleFilter:a=>Ne(a.eventTimestamp),storagePrefix:"__imtbl_web_"}),this.consent=Le(this.queue,se,i,this.anonymousId,n,r,t.onError,t.baseUrl),this.attribution=Me(),this.isTrackingDisabled()||(this.queue.start(),l&&this.trackSessionStart());}static init(t){if(!t.publishableKey?.trim())throw new Error(`${b} publishableKey is required`);return e.liveInstances>0&&console.warn(`${b} Multiple SDK instances detected. Ensure previous instances are shut down to avoid duplicate events.`),e.liveInstances+=1,new e(t)}getAnonymousId(){return this.anonymousId}isTrackingDisabled(){return !w(this.consent.level)}effectiveUserId(){return x(this.consent.level)?this.userId:void 0}startSession(){let t=O(this.cookieDomain);return this.sessionId=t.sessionId,this.sessionStartTime=Date.now(),t.isNew}baseMessage(){return {messageId:v(),eventTimestamp:q(),anonymousId:this.anonymousId,surface:"web",context:Te(Fe,je),...this.testMode&&{test:!0}}}enqueue(t,s){this.queue.enqueue(s),this.debug.logEvent(t,s);}trackSessionStart(){this.sessionId&&this.enqueue("track(session_start)",{...this.baseMessage(),type:"track",eventName:B,properties:{session_id:this.sessionId,...this.attribution}});}trackSessionEnd(){this.sessionId&&this.enqueue("track(session_end)",{...this.baseMessage(),type:"track",eventName:G,properties:{session_id:this.sessionId,...this.sessionStartTime&&{duration:Math.round((Date.now()-this.sessionStartTime)/1e3)}}});}page(t){if(this.isTrackingDisabled())return;O(this.cookieDomain);let s={session_id:this.sessionId,...t};this.isFirstPage&&(Object.assign(s,this.attribution),this.isFirstPage=!1),this.enqueue("page",{...this.baseMessage(),type:"page",properties:s,userId:this.effectiveUserId()});}track(t,...s){if(this.isTrackingDisabled())return;O(this.cookieDomain);let[i]=s,r={session_id:this.sessionId,...os.has(t)?Ue():{},...i};this.enqueue("track",{...this.baseMessage(),type:"track",eventName:$(t),properties:r,userId:this.effectiveUserId()});}identify(t,s,i){if(!x(this.consent.level)){this.debug.logWarning("identify() requires full consent \u2014 call ignored.");return}O(this.cookieDomain);let r=$(t);this.userId=r,this.enqueue("identify",{...this.baseMessage(),type:"identify",userId:r,identityType:s,traits:i});}alias(t,s){if(!x(this.consent.level)){this.debug.logWarning("alias() requires full consent \u2014 call ignored.");return}if(!Oe(t.id,t.identityType,s.id,s.identityType)){this.debug.logWarning("alias() from and to are identical \u2014 call ignored.");return}O(this.cookieDomain),this.enqueue("alias",{...this.baseMessage(),type:"alias",fromId:$(t.id),fromType:t.identityType,toId:$(s.id),toType:s.identityType});}setConsent(t){let s=this.consent.level;if(t===s)return;this.debug.logConsent(s,t);let i=!w(s)&&w(t);if(i&&(this.anonymousId=D(this.cookieDomain)),w(t)||this.queue.stop(),this.consent.setLevel(t),w(t)?x(s)&&!x(t)&&(this.userId=void 0):(P(g,this.cookieDomain),P(y,this.cookieDomain)),i){this.isFirstPage=!0;let r=this.startSession();this.queue.start(),r&&this.trackSessionStart();}}reset(){this.userId=void 0,this.queue.clear(),P(g,this.cookieDomain),P(y,this.cookieDomain),this.isTrackingDisabled()?(this.anonymousId=v(),this.sessionId=void 0,this.sessionStartTime=void 0):(this.anonymousId=D(this.cookieDomain),this.startSession()&&this.trackSessionStart()),this.isFirstPage=!0;}async flush(){await this.queue.flush();}shutdown(){this.destroyed||(this.destroyed=!0,this.isTrackingDisabled()||this.trackSessionEnd(),this.queue.destroy(),e.liveInstances=Math.max(0,e.liveInstances-1));}};var as={SIGN_UP:"sign_up",SIGN_IN:"sign_in",WISHLIST_ADD:"wishlist_add",WISHLIST_REMOVE:"wishlist_remove",PURCHASE:"purchase",GAME_LAUNCH:"game_launch",PROGRESSION:"progression",RESOURCE:"resource",EMAIL_ACQUIRED:"email_acquired",GAME_PAGE_VIEWED:"game_page_viewed",LINK_CLICKED:"link_clicked",BUTTON_CLICKED:"button_clicked"};/*! Bundled license information:
|
|
3
|
+
var Ke=Object.create;var ue=Object.defineProperty;var Ve=Object.getOwnPropertyDescriptor;var He=Object.getOwnPropertyNames;var ze=Object.getPrototypeOf,We=Object.prototype.hasOwnProperty;var Je=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Ye=(e,t,s,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of He(t))!We.call(e,r)&&r!==s&&ue(e,r,{get:()=>t[r],enumerable:!(i=Ve(t,r))||i.enumerable});return e};var Xe=(e,t,s)=>(s=e!=null?Ke(ze(e)):{},Ye(ue(s,"default",{value:e,enumerable:!0}),e));var ye=Je(P=>{Object.defineProperty(P,"__esModule",{value:!0});P.clearGlobalNamespace=P.getGlobalisedValue=void 0;var et="globalise__singleton__",tt={},fe=()=>typeof window<"u"?window:typeof globalThis<"u"?globalThis:tt,st=(e,t)=>{if(typeof e!="string")throw "Invalid namespace key";if(typeof t!="string")throw "Invalid item key"},me=e=>`${et}${e}`,ge=e=>{let t=fe(),s=me(e);return t[s]||(t[s]={}),t[s]},it=(e,t)=>ge(e)[t]||void 0,rt=(e,t,s)=>{let i=ge(e);i[t]=s;},nt=(e,t,s)=>{st(e,t);let i=it(e,t);return i!==void 0?i:(rt(e,t,s),s)};P.getGlobalisedValue=nt;var ot=e=>{let t=fe(),s=me(e);t[s]!==void 0&&delete t[s];};P.clearGlobalNamespace=ot;});var j="https://api.immutable.com",ce="/v1/audience/messages",de="/v1/audience/tracking-consent",g="imtbl_anon_id",y="_imtbl_sid",B="session_start",G="session_end",p=()=>typeof window<"u"&&typeof document<"u",v=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.trunc(Math.random()*16);return (e==="x"?t:t%4+8).toString(16)}),q=()=>new Date().toISOString();function k(e){if(!p())return;let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):void 0}function A(e,t,s,i){if(!p())return;let r=window.location.protocol==="https:"?"; Secure":"",n=i?`; domain=${i}`:"";document.cookie=`${e}=${encodeURIComponent(t)}; path=/; max-age=${s}; SameSite=Lax${n}${r}`;}function T(e,t){A(e,"",0,t);}function O(e){let t=k(g);if(t)return t;let s=v();return A(g,s,63072e3,e),s}function K(e,t){A(g,e,63072e3,t);}var V=class{constructor(t=0,s=0,i=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=t,this.resetTtl=i,this.size=0,this.ttl=s;}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(t){if(this.has(t)){let s=this.items[t];delete this.items[t],this.size--,s.prev!==null&&(s.prev.next=s.next),s.next!==null&&(s.next.prev=s.prev),this.first===s&&(this.first=s.next),this.last===s&&(this.last=s.prev);}return this}entries(t=this.keys()){return t.map(s=>[s,this.get(s)])}evict(t=!1){if(t||this.size>0){let s=this.first;delete this.items[s.key],--this.size===0?(this.first=null,this.last=null):(this.first=s.next,this.first.prev=null);}return this}expiresAt(t){let s;return this.has(t)&&(s=this.items[t].expiry),s}get(t){let s;if(this.has(t)){let i=this.items[t];this.ttl>0&&i.expiry<=Date.now()?this.delete(t):(s=i.value,this.set(t,s,!0));}return s}has(t){return t in this.items}keys(){let t=[],s=this.first;for(;s!==null;)t.push(s.key),s=s.next;return t}set(t,s,i=!1,r=this.resetTtl){let n;if(i||this.has(t)){if(n=this.items[t],n.value=s,i===!1&&r&&(n.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.last!==n){let l=this.last,o=n.next,a=n.prev;this.first===n&&(this.first=n.next),n.next=null,n.prev=this.last,l.next=n,a!==null&&(a.next=o),o!==null&&(o.prev=a);}}else this.max>0&&this.size===this.max&&this.evict(!0),n=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:s},++this.size===1?this.first=n:this.last.next=n;return this.last=n,this}values(t=this.keys()){return t.map(s=>this.get(s))}};function he(e=1e3,t=0,s=!1){if(isNaN(e)||e<0)throw new TypeError("Invalid max value");if(isNaN(t)||t<0)throw new TypeError("Invalid ttl value");if(typeof s!="boolean")throw new TypeError("Invalid resetTtl value");return new V(e,t,s)}var Qe={max:1e3},pe=(e,t={})=>{let{cache:s,cacheKeyResolver:i=H,onHit:r,lruOptions:n={}}=t,l={...Qe,...n},o=s||he(l.max,l.ttl);function a(...u){let m=i(...u),d=o.get(m);if(o.has(m))return r&&r(m,d,o),d;let f=e.apply(this,u);return o.set(m,f),f}return a._cache=o,a},H=(...e)=>e.length===0?"no-args":e.map(t=>t===void 0?"undefined":t===null?"null":Array.isArray(t)?`[${H(...t)}]`:typeof t=="object"?`{${H(...Ze(t))}}`:JSON.stringify(t)).join(","),Ze=e=>Object.entries(e).sort((t,s)=>t[0]<s[0]?-1:1);var Q=Xe(ye()),at=Object.defineProperty,lt=(e,t)=>{for(var s in t)at(e,s,{get:t[s],enumerable:!0});},ut={};lt(ut,{deleteItem:()=>pt,getItem:()=>W,setItem:()=>M});var R=()=>typeof window>"u",we=()=>!R(),ct="__IMX-",Z=()=>we()&&window.localStorage,dt=e=>{if(e!==null)try{return JSON.parse(e)}catch{return e}},ht=e=>typeof e=="string"?e:JSON.stringify(e),ee=e=>`${ct}${e}`;function W(e){if(Z())return dt(window.localStorage.getItem(ee(e)))}var M=(e,t)=>Z()?(window.localStorage.setItem(ee(e),ht(t)),!0):!1,pt=e=>Z()?(window.localStorage.removeItem(ee(e)),!0):!1,J=0,ft=e=>{let t=parseInt(e,10)*1e3,s=new Date(t),i=new Date;return J=s.getTime()-i.getTime(),J},mt=()=>{let e=new Date().getTime()+J;return new Date(e).toISOString()},gt=(e=>(e.RUNTIME_ID="rid",e.PASSPORT_CLIENT_ID="passportClientId",e.ENVIRONMENT="env",e.PUBLISHABLE_API_KEY="pak",e.IDENTITY="uid",e.DOMAIN="domain",e.SDK_VERSION="sdkVersion",e))(gt||{}),yt="https://api.immutable.com",vt=e=>{if(typeof Buffer<"u")return Buffer.from(e,"utf-8").toString("base64");if(typeof btoa=="function")return btoa(unescape(encodeURIComponent(e)));throw new Error("Base64 encoding not supported in this environment")};async function be(e,t){let s=JSON.stringify(t),i={payload:vt(s)},r=await fetch(`${yt}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!r.ok){let n=await r.text().catch(()=>"");throw new Error(`Request failed (${r.status}): ${n||r.statusText}`)}return r.json()}var I,E,wt=()=>{I=W("metrics-events")||[],E=W("metrics-runtime")||{};};wt();var S=(e,t)=>{E={...E,[e]:t},M("metrics-runtime",E);},Y=e=>{if(E[e]!==void 0)return E[e]},bt=()=>E,It=()=>I,Et=e=>{I.push(e),M("metrics-events",I);},St=e=>{I=I.slice(e),M("metrics-events",I);},Ie=e=>{let t=[];return Object.entries(e).forEach(([s,i])=>{(typeof s=="string"||typeof i=="string"||typeof i=="number"||typeof i=="boolean")&&t.push([s,i.toString()]);}),t},z="2.20.1",_t=()=>R()?"":window.location.ancestorOrigins&&window.location.ancestorOrigins.length>0?new URL(window.location.ancestorOrigins[0]).hostname:document.referrer?new URL(window.document.referrer).hostname:"",xt=()=>{if(R())return "";let e;try{window.self!==window.top&&(e=_t());}catch{}return e||(e=window.location.hostname),e},kt=()=>{if(S("sdkVersion",z),R())return {browser:"nodejs",sdkVersion:z};let e=xt();return e&&S("domain",e),{sdkVersion:z,browser:window.navigator.userAgent,domain:e,tz:Intl.DateTimeFormat().resolvedOptions().timeZone,screen:`${window.screen.width}x${window.screen.height}`}},X=!1,At=()=>X,Tt=async()=>{X=!0;try{let e=Ie(kt()),t=Y("rid"),s=Y("uid"),i=await be("/v1/sdk/initialise",{version:1,data:{runtimeDetails:e,runtimeId:t,uId:s}}),{runtimeId:r,sTime:n}=i;S("rid",r),ft(n);}catch{X=!1;}};function h(e,t){return (...s)=>{try{let i=e(...s);return i instanceof Promise?i.catch(()=>t):i}catch{return t}}}function Pt(){return we()||typeof process>"u"?!1:process.env.JEST_WORKER_ID!==void 0}var Nt=h(Pt,!1),Ee="imtbl__metrics",Dt=5e3,Ot=1e3,C=(e,t)=>(0, Q.getGlobalisedValue)(Ee,e,t),Ct=(e,t)=>{let s=pe(t,{lruOptions:{ttl:Dt,max:Ot}});return (0, Q.getGlobalisedValue)(Ee,e,s)},$t=5e3,Rt=(e,t,s)=>{let i={event:`${e}.${t}`,time:mt(),...s&&{properties:Ie(s)}};Et(i);},_=h(Ct("track",Rt)),Mt=async()=>{if(At()===!1){await Tt();return}let e=It();if(e.length===0)return;let t=e.length,s=bt();await be("/v1/sdk/metrics",{version:1,data:{events:e,details:s}})instanceof Error||St(t);},Lt=h(Mt),Se=async()=>{await Lt(),setTimeout(Se,$t);},ve=!1,Ut=()=>{ve||(ve=!0,Se());};Nt()||h(C("startFlushing",Ut))();var Vt=(e,t,s,i)=>{let{message:r}=s,n=s.stack||"",{cause:l}=s;l instanceof Error&&(n=`${n}
|
|
4
|
+
Cause: ${l.message}
|
|
5
|
+
${l.stack}`),_(e,`trackError_${t}`,{...i||{},errorMessage:r,errorStack:n,isTrackError:!0});},_e=h(Vt),Wt=e=>{S("env",e);};h(C("setEnvironment",Wt));var Jt=e=>{S("passportClientId",e);};h(C("setPassportClientId",Jt));var Yt=e=>{S("pak",e);};h(C("setPublishableApiKey",Yt));h(C("getDetail",Y));var Xt={Passport:"passport",Steam:"steam",Epic:"epic",Google:"google",Apple:"apple",Discord:"discord",Email:"email",Custom:"custom"},L=class extends Error{status;endpoint;body;constructor(e){super(`audience transport failed: ${e.status||"network error"} ${e.endpoint}`,e.cause!==void 0?{cause:e.cause}:void 0),this.name="TransportError",this.status=e.status,this.endpoint=e.endpoint,this.body=e.body;}},N=class extends Error{code;status;endpoint;responseBody;cause;constructor(e){super(e.message),this.name="AudienceError",this.code=e.code,this.status=e.status,this.endpoint=e.endpoint,this.responseBody=e.responseBody,this.cause=e.cause;}};function Ae(e,t,s){if(e.status===0)return new N({code:"NETWORK_ERROR",message:t==="flush"?`Network error sending ${s??0} messages`:"Network error syncing consent",status:0,endpoint:e.endpoint,cause:e.cause});if(e.status>=200&&e.status<300){let i=e.body,r=i?.rejected??0,n=i?.accepted??0;return new N({code:"VALIDATION_REJECTED",message:`Backend rejected ${r} of ${r+n} messages`,status:e.status,endpoint:e.endpoint,responseBody:e.body})}return e.status===429?new N({code:"RATE_LIMITED",message:t==="flush"?"Flush rate limited (429)":"Consent sync rate limited (429)",status:e.status,endpoint:e.endpoint,responseBody:e.body}):e.status>=400&&e.status<500?new N({code:t==="flush"?"VALIDATION_REJECTED":"CONSENT_SYNC_FAILED",message:t==="flush"?`Flush rejected with status ${e.status}`:`Consent sync failed with status ${e.status}`,status:e.status,endpoint:e.endpoint,responseBody:e.body}):new N({code:t==="flush"?"FLUSH_FAILED":"CONSENT_SYNC_FAILED",message:t==="flush"?`Flush failed with status ${e.status}`:`Consent sync failed with status ${e.status}`,status:e.status,endpoint:e.endpoint,responseBody:e.body,cause:e.cause})}function Te(e,t){if(e)try{e(t);}catch{}}var Qt=3e4;function Zt(e){let t=e.get?.("retry-after");if(!t)return null;let s=Number(t.trim());if(!Number.isNaN(s)&&s>=0)return Math.round(s*1e3);let i=new Date(t);if(!Number.isNaN(i.getTime())){let r=i.getTime()-Date.now();return r>0?r:null}return null}function te(){try{return p()?navigator.onLine:void 0}catch{return}}async function xe(e){let t=e.headers?.get?.("content-type")??"";try{return t.includes("application/json")?await e.json():await e.text()}catch{return}}var ie=async(e,t,s,i)=>{let r=new AbortController,n=setTimeout(()=>r.abort(),Qt),l=Date.now();try{let o=await fetch(e,{method:i?.method??"POST",headers:{"Content-Type":"application/json","x-immutable-publishable-key":t},body:JSON.stringify(s),keepalive:i?.keepalive,signal:r.signal});if(o.status===429){_("audience","transport_send_failed",{status:429,online:te(),timeToFailureMs:Date.now()-l});let u=Zt(o.headers);return {ok:!1,error:new L({status:429,endpoint:e}),...u!==null?{retryAfterMs:u}:{}}}if(!o.ok){let u=await xe(o);return _("audience","transport_send_failed",{status:o.status,online:te(),timeToFailureMs:Date.now()-l}),{ok:!1,error:new L({status:o.status,endpoint:e,body:u})}}let a=await xe(o);if(typeof a=="object"&&a!==null&&"rejected"in a){let u=a.rejected??0;if(u>0)return _("audience","transport_partial_rejected",{status:o.status,rejected:u}),{ok:!1,error:new L({status:o.status,endpoint:e,body:a})}}return {ok:!0}}catch(o){let a=new L({status:0,endpoint:e,cause:o});return _e("audience","transport_send",a,{errorName:o instanceof Error?o.name:void 0,online:te(),timeToFailureMs:Date.now()-l}),{ok:!1,error:a}}finally{clearTimeout(n);}},re="__imtbl_audience_";function ne(){try{return p()&&typeof localStorage<"u"}catch{return !1}}function es(e,t=re){if(ne())try{let s=localStorage.getItem(`${t}${e}`);return s?JSON.parse(s):void 0}catch{return}}function ts(e,t,s=re){if(ne())try{localStorage.setItem(`${s}${e}`,JSON.stringify(t));}catch{}}function ss(e,t=re){if(ne())try{localStorage.removeItem(`${t}${e}`);}catch{}}var se="queue",ke=100,Pe=class{constructor(e,t,s){this.send=e,this.publishableKey=t,this.endpointUrl=`${s?.baseUrl??j}${ce}`,this.flushIntervalMs=s?.flushIntervalMs??5e3,this.flushSize=s?.flushSize??20,this.onFlush=s?.onFlush,this.onError=s?.onError,this.storagePrefix=s?.storagePrefix;let i=es(se,this.storagePrefix)??[];this.messages=s?.staleFilter?i.filter(s.staleFilter):i;}messages;timer=null;flushing=!1;unloadBound=!1;visibilityHandler;pagehideHandler;onFlush;onError;storagePrefix;endpointUrl;flushIntervalMs;flushSize;consecutiveFailures=0;nextAttemptAt=0;start(){this.timer||(this.timer=setInterval(()=>this.flush(),this.flushIntervalMs),this.registerUnload());}stop(){this.timer&&(clearInterval(this.timer),this.timer=null),this.removeUnload();}destroy(){this.stop(),this.flushUnload();}enqueue(e){this.messages.push(e),this.persist(),this.messages.length>=this.flushSize&&this.flush();}async flush(){if(!(this.flushing||this.messages.length===0)&&!(Date.now()<this.nextAttemptAt)){this.flushing=!0;try{let e=this.messages.slice(0,ke),t={messages:e},s=await this.send(this.endpointUrl,this.publishableKey,t),i;!s.ok&&s.error&&(i=Ae(s.error,"flush",e.length));let r=i?.code==="VALIDATION_REJECTED";s.ok||r?(this.messages=this.messages.slice(e.length),this.persist(),this.resetBackoff()):i&&(s.retryAfterMs!==void 0?this.setBackoffUntil(Date.now()+s.retryAfterMs):this.recordFailure()),this.onFlush?.(s.ok,e.length),i&&Te(this.onError,i);}finally{this.flushing=!1;}}}flushUnload(){if(this.flushing||this.messages.length===0)return;let e=this.messages.slice(0,ke),t={messages:e};this.send(this.endpointUrl,this.publishableKey,t,{keepalive:!0}),this.messages=this.messages.slice(e.length),this.persist();}purge(e){this.messages=this.messages.filter(t=>!e(t)),this.persist();}transform(e){this.messages=this.messages.map(e),this.persist();}get length(){return this.messages.length}clear(){this.messages=[],ss(se,this.storagePrefix);}registerUnload(){!p()||this.unloadBound||(this.unloadBound=!0,this.pagehideHandler=()=>this.flushUnload(),this.visibilityHandler=()=>{document.visibilityState==="hidden"&&this.flushUnload();},document.addEventListener("visibilitychange",this.visibilityHandler),window.addEventListener("pagehide",this.pagehideHandler));}removeUnload(){this.unloadBound&&(this.visibilityHandler&&document.removeEventListener("visibilitychange",this.visibilityHandler),this.pagehideHandler&&window.removeEventListener("pagehide",this.pagehideHandler),this.unloadBound=!1);}backoffDelayMs(){switch(this.consecutiveFailures){case 0:return 0;case 1:return 5e3;case 2:return 1e4;case 3:return 2e4;case 4:return 4e4;default:return 6e4}}recordFailure(){let e=Date.now();e<this.nextAttemptAt||(this.consecutiveFailures++,this.nextAttemptAt=e+this.backoffDelayMs());}setBackoffUntil(e){this.consecutiveFailures++,this.nextAttemptAt=e;}resetBackoff(){this.consecutiveFailures=0,this.nextAttemptAt=0;}persist(){ts(se,this.messages,this.storagePrefix);}},is="2.20.1";function Ne(e="@imtbl/audience",t=is){let s={library:e,libraryVersion:t};return p()&&(s.userAgent=navigator.userAgent,s.locale=navigator.language,s.timezone=Intl.DateTimeFormat().resolvedOptions().timeZone,s.screen=`${window.screen.width}x${window.screen.height}`,s.pageUrl=window.location.href,s.pagePath=window.location.pathname,s.pageReferrer=document.referrer,s.pageTitle=document.title),s}function De(e){let t=new Date(e).getTime();if(Number.isNaN(t))return !1;let s=Date.now();return t<=s+864e5&&t>=s-2592e6}function Oe(e,t,s,i){return e!==s||t!==i}function $(e,t=256){return e.length>t?e.slice(0,t):e}function D(e){let t=k(y);if(t)return A(y,t,1800,e),{sessionId:t,isNew:!1};let s=v();return A(y,s,1800,e),{sessionId:s,isNew:!0}}var Ce=["utm_source","utm_medium","utm_campaign","utm_content","utm_term"],$e=["gclid","dclid","fbclid","ttclid","msclkid","li_fat_id"],Re="__imtbl_attribution";function rs(e){let t;try{t=new URL(e).searchParams;}catch{return {}}let s={};for(let r of [...Ce,...$e]){let n=t.get(r);n&&(s[r]=n);}let i=t.get("referral_code");return i&&(s.referral_code=i),s}function ns(){try{let e=sessionStorage.getItem(Re);return e?JSON.parse(e):null}catch{return null}}function os(e){try{sessionStorage.setItem(Re,JSON.stringify(e));}catch{}}function Me(){let e=typeof window<"u"&&window.location?rs(window.location.href):{},t=typeof document<"u"&&document.referrer||void 0,s=$e.some(r=>r in e),i=Ce.some(r=>r in e);return {...e,referrer:t,touchpoint_type:s||i?"click":void 0}}function Le(){let e=ns();if(e)return e;let t=typeof window<"u"&&window.location?window.location.href:void 0,s={...Me(),landing_page:t};return os(s),s}function Ue(){return Me()}function w(e){return e!=="none"}function x(e){return e==="full"}function Fe(e,t,s,i,r,n,l,o){let a=n??"none",u={none:0,anonymous:1,full:2};function m(d){let c=`${o??j}${de}`;t(c,s,{anonymousId:i,status:d,source:r},{method:"PUT",keepalive:!0}).then(f=>{!f.ok&&f.error&&Te(l,Ae(f.error,"consent"));});}return {get level(){return a},setLevel(d){d!==a&&(u[d]<u[a]&&(d==="none"?e.purge(()=>!0):d==="anonymous"&&(e.purge(c=>c.type==="identify"||c.type==="alias"),e.transform(c=>{if("userId"in c){let{userId:f,...F}=c;return F}return c}))),a=d,m(d));}}}var je="@imtbl/audience",Be="2.20.1",b="[audience]",Ge="WebSDK";var U=class{enabled;constructor(t=!1){this.enabled=t;}logEvent(t,s){this.enabled&&console.log(`${b} ${t}`,s);}logFlush(t,s){this.enabled&&console.log(`${b} flush ${t?"ok":"failed"} (${s} messages)`);}logConsent(t,s){this.enabled&&console.log(`${b} consent ${t} \u2192 ${s}`);}logWarning(t){this.enabled&&console.warn(`${b} ${t}`);}};var as=new Set(["sign_up","link_clicked"]),oe=class e{static liveInstances=0;queue;consent;attribution;debug;cookieDomain;testMode;anonymousId;sessionId;sessionStartTime;userId;isFirstPage=!0;destroyed=!1;static UUID_RE=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;static readAndStripAidParam(){if(!p())return null;let t=new URLSearchParams(window.location.search),s=t.get("imtbl_aid");if(s!==null){t.delete("imtbl_aid");let i=t.toString(),r=`${window.location.pathname}${i?`?${i}`:""}${window.location.hash}`;window.history.replaceState(window.history.state,"",r);}return s&&e.UUID_RE.test(s)?s:null}constructor(t){let{cookieDomain:s,publishableKey:i}=t,r=t.consent??"none",n=Ge;this.cookieDomain=s,this.testMode=t.testMode??!1,this.debug=new U(t.debug??!1);let l=e.readAndStripAidParam(),o=!1;w(r)?(l?(K(l,s),this.anonymousId=l):this.anonymousId=O(s),o=this.startSession()):this.anonymousId=k(g)??v(),this.queue=new Pe(ie,i,{baseUrl:t.baseUrl,flushIntervalMs:t.flushInterval,flushSize:t.flushSize,onFlush:(a,u)=>this.debug.logFlush(a,u),onError:t.onError,staleFilter:a=>De(a.eventTimestamp),storagePrefix:"__imtbl_web_"}),this.consent=Fe(this.queue,ie,i,this.anonymousId,n,r,t.onError,t.baseUrl),this.attribution=Le(),this.isTrackingDisabled()||(this.queue.start(),o&&this.trackSessionStart());}static init(t){if(!t.publishableKey?.trim())throw new Error(`${b} publishableKey is required`);return e.liveInstances>0&&console.warn(`${b} Multiple SDK instances detected. Ensure previous instances are shut down to avoid duplicate events.`),e.liveInstances+=1,new e(t)}getAnonymousId(){return this.anonymousId}isTrackingDisabled(){return !w(this.consent.level)}effectiveUserId(){return x(this.consent.level)?this.userId:void 0}startSession(){let t=D(this.cookieDomain);return this.sessionId=t.sessionId,this.sessionStartTime=Date.now(),t.isNew}baseMessage(){return {messageId:v(),eventTimestamp:q(),anonymousId:this.anonymousId,surface:"web",context:Ne(je,Be),...this.testMode&&{test:!0}}}enqueue(t,s){this.queue.enqueue(s),this.debug.logEvent(t,s);}trackSessionStart(){this.sessionId&&this.enqueue("track(session_start)",{...this.baseMessage(),type:"track",eventName:B,properties:{session_id:this.sessionId,...this.attribution}});}trackSessionEnd(){this.sessionId&&this.enqueue("track(session_end)",{...this.baseMessage(),type:"track",eventName:G,properties:{session_id:this.sessionId,...this.sessionStartTime&&{duration:Math.round((Date.now()-this.sessionStartTime)/1e3)}}});}page(t){if(this.isTrackingDisabled())return;D(this.cookieDomain);let s={session_id:this.sessionId,...t};this.isFirstPage&&(Object.assign(s,this.attribution),this.isFirstPage=!1),this.enqueue("page",{...this.baseMessage(),type:"page",properties:s,userId:this.effectiveUserId()});}track(t,...s){if(this.isTrackingDisabled())return;D(this.cookieDomain);let[i]=s,r={session_id:this.sessionId,...as.has(t)?Ue():{},...i};this.enqueue("track",{...this.baseMessage(),type:"track",eventName:$(t),properties:r,userId:this.effectiveUserId()});}identify(t,s,i){if(!x(this.consent.level)){this.debug.logWarning("identify() requires full consent \u2014 call ignored.");return}D(this.cookieDomain);let r=$(t);this.userId=r,this.enqueue("identify",{...this.baseMessage(),type:"identify",userId:r,identityType:s,traits:i});}alias(t,s){if(!x(this.consent.level)){this.debug.logWarning("alias() requires full consent \u2014 call ignored.");return}if(!Oe(t.id,t.identityType,s.id,s.identityType)){this.debug.logWarning("alias() from and to are identical \u2014 call ignored.");return}D(this.cookieDomain),this.enqueue("alias",{...this.baseMessage(),type:"alias",fromId:$(t.id),fromType:t.identityType,toId:$(s.id),toType:s.identityType});}setConsent(t){let s=this.consent.level;if(t===s)return;this.debug.logConsent(s,t);let i=!w(s)&&w(t);if(i&&(this.anonymousId=O(this.cookieDomain)),w(t)||this.queue.stop(),this.consent.setLevel(t),w(t)?x(s)&&!x(t)&&(this.userId=void 0):(T(g,this.cookieDomain),T(y,this.cookieDomain)),i){this.isFirstPage=!0;let r=this.startSession();this.queue.start(),r&&this.trackSessionStart();}}reset(){this.userId=void 0,this.queue.clear(),T(g,this.cookieDomain),T(y,this.cookieDomain),this.isTrackingDisabled()?(this.anonymousId=v(),this.sessionId=void 0,this.sessionStartTime=void 0):(this.anonymousId=O(this.cookieDomain),this.startSession()&&this.trackSessionStart()),this.isFirstPage=!0;}async flush(){await this.queue.flush();}shutdown(){this.destroyed||(this.destroyed=!0,this.isTrackingDisabled()||this.trackSessionEnd(),this.queue.destroy(),e.liveInstances=Math.max(0,e.liveInstances-1));}};var ls={SIGN_UP:"sign_up",SIGN_IN:"sign_in",WISHLIST_ADD:"wishlist_add",WISHLIST_REMOVE:"wishlist_remove",PURCHASE:"purchase",GAME_LAUNCH:"game_launch",PROGRESSION:"progression",RESOURCE:"resource",EMAIL_ACQUIRED:"email_acquired",GAME_PAGE_VIEWED:"game_page_viewed",LINK_CLICKED:"link_clicked",BUTTON_CLICKED:"button_clicked"};/*! Bundled license information:
|
|
6
6
|
|
|
7
7
|
tiny-lru/dist/tiny-lru.js:
|
|
8
8
|
(**
|
|
@@ -14,9 +14,9 @@ tiny-lru/dist/tiny-lru.js:
|
|
|
14
14
|
*)
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
exports.Audience =
|
|
17
|
+
exports.Audience = oe;
|
|
18
18
|
exports.AudienceError = N;
|
|
19
|
-
exports.AudienceEvents =
|
|
20
|
-
exports.IdentityType =
|
|
19
|
+
exports.AudienceEvents = ls;
|
|
20
|
+
exports.IdentityType = Xt;
|
|
21
21
|
exports.canIdentify = x;
|
|
22
22
|
exports.canTrack = w;
|
package/dist/node/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
2
|
-
Cause: ${
|
|
3
|
-
${o.stack}`),_(e,`trackError_${t}`,{...i||{},errorMessage:r,errorStack:n,isTrackError:!0});},Se=d(Kt),zt=e=>{S("env",e);};d(C("setEnvironment",zt));var Wt=e=>{S("passportClientId",e);};d(C("setPassportClientId",Wt));var Jt=e=>{S("pak",e);};d(C("setPublishableApiKey",Jt));d(C("getDetail",Y));var Yt={Passport:"passport",Steam:"steam",Epic:"epic",Google:"google",Apple:"apple",Discord:"discord",Email:"email",Custom:"custom"},U=class extends Error{status;endpoint;body;constructor(e){super(`audience transport failed: ${e.status||"network error"} ${e.endpoint}`,e.cause!==void 0?{cause:e.cause}:void 0),this.name="TransportError",this.status=e.status,this.endpoint=e.endpoint,this.body=e.body;}},N=class extends Error{code;status;endpoint;responseBody;cause;constructor(e){super(e.message),this.name="AudienceError",this.code=e.code,this.status=e.status,this.endpoint=e.endpoint,this.responseBody=e.responseBody,this.cause=e.cause;}};function ke(e,t,s){if(e.status===0)return new N({code:"NETWORK_ERROR",message:t==="flush"?`Network error sending ${s??0} messages`:"Network error syncing consent",status:0,endpoint:e.endpoint,cause:e.cause});if(e.status>=200&&e.status<300){let i=e.body,r=i?.rejected??0,n=i?.accepted??0;return new N({code:"VALIDATION_REJECTED",message:`Backend rejected ${r} of ${r+n} messages`,status:e.status,endpoint:e.endpoint,responseBody:e.body})}return e.status===429?new N({code:"RATE_LIMITED",message:t==="flush"?"Flush rate limited (429)":"Consent sync rate limited (429)",status:e.status,endpoint:e.endpoint,responseBody:e.body}):e.status>=400&&e.status<500?new N({code:t==="flush"?"VALIDATION_REJECTED":"CONSENT_SYNC_FAILED",message:t==="flush"?`Flush rejected with status ${e.status}`:`Consent sync failed with status ${e.status}`,status:e.status,endpoint:e.endpoint,responseBody:e.body}):new N({code:t==="flush"?"FLUSH_FAILED":"CONSENT_SYNC_FAILED",message:t==="flush"?`Flush failed with status ${e.status}`:`Consent sync failed with status ${e.status}`,status:e.status,endpoint:e.endpoint,responseBody:e.body,cause:e.cause})}function Ae(e,t){if(e)try{e(t);}catch{}}var Xt=3e4;function Qt(e){let t=e.get?.("retry-after");if(!t)return null;let s=Number(t.trim());if(!Number.isNaN(s)&&s>=0)return Math.round(s*1e3);let i=new Date(t);if(!Number.isNaN(i.getTime())){let r=i.getTime()-Date.now();return r>0?r:null}return null}async function _e(e){let t=e.headers?.get?.("content-type")??"";try{return t.includes("application/json")?await e.json():await e.text()}catch{return}}var se=async(e,t,s,i)=>{let r=new AbortController,n=setTimeout(()=>r.abort(),Xt);try{let o=await fetch(e,{method:i?.method??"POST",headers:{"Content-Type":"application/json","x-immutable-publishable-key":t},body:JSON.stringify(s),keepalive:i?.keepalive,signal:r.signal});if(o.status===429){_("audience","transport_send_failed",{status:429});let a=Qt(o.headers);return {ok:!1,error:new U({status:429,endpoint:e}),...a!==null?{retryAfterMs:a}:{}}}if(!o.ok){let a=await _e(o);return _("audience","transport_send_failed",{status:o.status}),{ok:!1,error:new U({status:o.status,endpoint:e,body:a})}}let l=await _e(o);if(typeof l=="object"&&l!==null&&"rejected"in l){let a=l.rejected??0;if(a>0)return _("audience","transport_partial_rejected",{status:o.status,rejected:a}),{ok:!1,error:new U({status:o.status,endpoint:e,body:l})}}return {ok:!0}}catch(o){let l=new U({status:0,endpoint:e,cause:o});return Se("audience","transport_send",l),{ok:!1,error:l}}finally{clearTimeout(n);}},ie="__imtbl_audience_";function re(){try{return f()&&typeof localStorage<"u"}catch{return !1}}function Zt(e,t=ie){if(re())try{let s=localStorage.getItem(`${t}${e}`);return s?JSON.parse(s):void 0}catch{return}}function es(e,t,s=ie){if(re())try{localStorage.setItem(`${s}${e}`,JSON.stringify(t));}catch{}}function ts(e,t=ie){if(re())try{localStorage.removeItem(`${t}${e}`);}catch{}}var te="queue",xe=100,Pe=class{constructor(e,t,s){this.send=e,this.publishableKey=t,this.endpointUrl=`${s?.baseUrl??j}${ue}`,this.flushIntervalMs=s?.flushIntervalMs??5e3,this.flushSize=s?.flushSize??20,this.onFlush=s?.onFlush,this.onError=s?.onError,this.storagePrefix=s?.storagePrefix;let i=Zt(te,this.storagePrefix)??[];this.messages=s?.staleFilter?i.filter(s.staleFilter):i;}messages;timer=null;flushing=!1;unloadBound=!1;visibilityHandler;pagehideHandler;onFlush;onError;storagePrefix;endpointUrl;flushIntervalMs;flushSize;consecutiveFailures=0;nextAttemptAt=0;start(){this.timer||(this.timer=setInterval(()=>this.flush(),this.flushIntervalMs),this.registerUnload());}stop(){this.timer&&(clearInterval(this.timer),this.timer=null),this.removeUnload();}destroy(){this.stop(),this.flushUnload();}enqueue(e){this.messages.push(e),this.persist(),this.messages.length>=this.flushSize&&this.flush();}async flush(){if(!(this.flushing||this.messages.length===0)&&!(Date.now()<this.nextAttemptAt)){this.flushing=!0;try{let e=this.messages.slice(0,xe),t={messages:e},s=await this.send(this.endpointUrl,this.publishableKey,t),i;!s.ok&&s.error&&(i=ke(s.error,"flush",e.length));let r=i?.code==="VALIDATION_REJECTED";s.ok||r?(this.messages=this.messages.slice(e.length),this.persist(),this.resetBackoff()):i&&(s.retryAfterMs!==void 0?this.setBackoffUntil(Date.now()+s.retryAfterMs):this.recordFailure()),this.onFlush?.(s.ok,e.length),i&&Ae(this.onError,i);}finally{this.flushing=!1;}}}flushUnload(){if(this.flushing||this.messages.length===0)return;let e=this.messages.slice(0,xe),t={messages:e};this.send(this.endpointUrl,this.publishableKey,t,{keepalive:!0}),this.messages=this.messages.slice(e.length),this.persist();}purge(e){this.messages=this.messages.filter(t=>!e(t)),this.persist();}transform(e){this.messages=this.messages.map(e),this.persist();}get length(){return this.messages.length}clear(){this.messages=[],ts(te,this.storagePrefix);}registerUnload(){!f()||this.unloadBound||(this.unloadBound=!0,this.pagehideHandler=()=>this.flushUnload(),this.visibilityHandler=()=>{document.visibilityState==="hidden"&&this.flushUnload();},document.addEventListener("visibilitychange",this.visibilityHandler),window.addEventListener("pagehide",this.pagehideHandler));}removeUnload(){this.unloadBound&&(this.visibilityHandler&&document.removeEventListener("visibilitychange",this.visibilityHandler),this.pagehideHandler&&window.removeEventListener("pagehide",this.pagehideHandler),this.unloadBound=!1);}backoffDelayMs(){switch(this.consecutiveFailures){case 0:return 0;case 1:return 5e3;case 2:return 1e4;case 3:return 2e4;case 4:return 4e4;default:return 6e4}}recordFailure(){let e=Date.now();e<this.nextAttemptAt||(this.consecutiveFailures++,this.nextAttemptAt=e+this.backoffDelayMs());}setBackoffUntil(e){this.consecutiveFailures++,this.nextAttemptAt=e;}resetBackoff(){this.consecutiveFailures=0,this.nextAttemptAt=0;}persist(){es(te,this.messages,this.storagePrefix);}},ss="2.20.1-alpha.2";function Te(e="@imtbl/audience",t=ss){let s={library:e,libraryVersion:t};return f()&&(s.userAgent=navigator.userAgent,s.locale=navigator.language,s.timezone=Intl.DateTimeFormat().resolvedOptions().timeZone,s.screen=`${window.screen.width}x${window.screen.height}`,s.pageUrl=window.location.href,s.pagePath=window.location.pathname,s.pageReferrer=document.referrer,s.pageTitle=document.title),s}function Ne(e){let t=new Date(e).getTime();if(Number.isNaN(t))return !1;let s=Date.now();return t<=s+864e5&&t>=s-2592e6}function Oe(e,t,s,i){return e!==s||t!==i}function $(e,t=256){return e.length>t?e.slice(0,t):e}function O(e){let t=k(y);if(t)return A(y,t,1800,e),{sessionId:t,isNew:!1};let s=v();return A(y,s,1800,e),{sessionId:s,isNew:!0}}var De=["utm_source","utm_medium","utm_campaign","utm_content","utm_term"],Ce=["gclid","dclid","fbclid","ttclid","msclkid","li_fat_id"],$e="__imtbl_attribution";function is(e){let t;try{t=new URL(e).searchParams;}catch{return {}}let s={};for(let r of [...De,...Ce]){let n=t.get(r);n&&(s[r]=n);}let i=t.get("referral_code");return i&&(s.referral_code=i),s}function rs(){try{let e=sessionStorage.getItem($e);return e?JSON.parse(e):null}catch{return null}}function ns(e){try{sessionStorage.setItem($e,JSON.stringify(e));}catch{}}function Re(){let e=typeof window<"u"&&window.location?is(window.location.href):{},t=typeof document<"u"&&document.referrer||void 0,s=Ce.some(r=>r in e),i=De.some(r=>r in e);return {...e,referrer:t,touchpoint_type:s||i?"click":void 0}}function Me(){let e=rs();if(e)return e;let t=typeof window<"u"&&window.location?window.location.href:void 0,s={...Re(),landing_page:t};return ns(s),s}function Ue(){return Re()}function w(e){return e!=="none"}function x(e){return e==="full"}function Le(e,t,s,i,r,n,o,l){let a=n??"none",h={none:0,anonymous:1,full:2};function m(c){let u=`${l??j}${ce}`;t(u,s,{anonymousId:i,status:c,source:r},{method:"PUT",keepalive:!0}).then(p=>{!p.ok&&p.error&&Ae(o,ke(p.error,"consent"));});}return {get level(){return a},setLevel(c){c!==a&&(h[c]<h[a]&&(c==="none"?e.purge(()=>!0):c==="anonymous"&&(e.purge(u=>u.type==="identify"||u.type==="alias"),e.transform(u=>{if("userId"in u){let{userId:p,...F}=u;return F}return u}))),a=c,m(c));}}}var Fe="@imtbl/audience",je="2.20.1-alpha.2",b="[audience]",Be="WebSDK";var L=class{enabled;constructor(t=!1){this.enabled=t;}logEvent(t,s){this.enabled&&console.log(`${b} ${t}`,s);}logFlush(t,s){this.enabled&&console.log(`${b} flush ${t?"ok":"failed"} (${s} messages)`);}logConsent(t,s){this.enabled&&console.log(`${b} consent ${t} \u2192 ${s}`);}logWarning(t){this.enabled&&console.warn(`${b} ${t}`);}};var os=new Set(["sign_up","link_clicked"]),ne=class e{static liveInstances=0;queue;consent;attribution;debug;cookieDomain;testMode;anonymousId;sessionId;sessionStartTime;userId;isFirstPage=!0;destroyed=!1;static UUID_RE=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;static readAndStripAidParam(){if(!f())return null;let t=new URLSearchParams(window.location.search),s=t.get("imtbl_aid");if(s!==null){t.delete("imtbl_aid");let i=t.toString(),r=`${window.location.pathname}${i?`?${i}`:""}${window.location.hash}`;window.history.replaceState(window.history.state,"",r);}return s&&e.UUID_RE.test(s)?s:null}constructor(t){let{cookieDomain:s,publishableKey:i}=t,r=t.consent??"none",n=Be;this.cookieDomain=s,this.testMode=t.testMode??!1,this.debug=new L(t.debug??!1);let o=e.readAndStripAidParam(),l=!1;w(r)?(o?(K(o,s),this.anonymousId=o):this.anonymousId=D(s),l=this.startSession()):this.anonymousId=k(g)??v(),this.queue=new Pe(se,i,{baseUrl:t.baseUrl,flushIntervalMs:t.flushInterval,flushSize:t.flushSize,onFlush:(a,h)=>this.debug.logFlush(a,h),onError:t.onError,staleFilter:a=>Ne(a.eventTimestamp),storagePrefix:"__imtbl_web_"}),this.consent=Le(this.queue,se,i,this.anonymousId,n,r,t.onError,t.baseUrl),this.attribution=Me(),this.isTrackingDisabled()||(this.queue.start(),l&&this.trackSessionStart());}static init(t){if(!t.publishableKey?.trim())throw new Error(`${b} publishableKey is required`);return e.liveInstances>0&&console.warn(`${b} Multiple SDK instances detected. Ensure previous instances are shut down to avoid duplicate events.`),e.liveInstances+=1,new e(t)}getAnonymousId(){return this.anonymousId}isTrackingDisabled(){return !w(this.consent.level)}effectiveUserId(){return x(this.consent.level)?this.userId:void 0}startSession(){let t=O(this.cookieDomain);return this.sessionId=t.sessionId,this.sessionStartTime=Date.now(),t.isNew}baseMessage(){return {messageId:v(),eventTimestamp:q(),anonymousId:this.anonymousId,surface:"web",context:Te(Fe,je),...this.testMode&&{test:!0}}}enqueue(t,s){this.queue.enqueue(s),this.debug.logEvent(t,s);}trackSessionStart(){this.sessionId&&this.enqueue("track(session_start)",{...this.baseMessage(),type:"track",eventName:B,properties:{session_id:this.sessionId,...this.attribution}});}trackSessionEnd(){this.sessionId&&this.enqueue("track(session_end)",{...this.baseMessage(),type:"track",eventName:G,properties:{session_id:this.sessionId,...this.sessionStartTime&&{duration:Math.round((Date.now()-this.sessionStartTime)/1e3)}}});}page(t){if(this.isTrackingDisabled())return;O(this.cookieDomain);let s={session_id:this.sessionId,...t};this.isFirstPage&&(Object.assign(s,this.attribution),this.isFirstPage=!1),this.enqueue("page",{...this.baseMessage(),type:"page",properties:s,userId:this.effectiveUserId()});}track(t,...s){if(this.isTrackingDisabled())return;O(this.cookieDomain);let[i]=s,r={session_id:this.sessionId,...os.has(t)?Ue():{},...i};this.enqueue("track",{...this.baseMessage(),type:"track",eventName:$(t),properties:r,userId:this.effectiveUserId()});}identify(t,s,i){if(!x(this.consent.level)){this.debug.logWarning("identify() requires full consent \u2014 call ignored.");return}O(this.cookieDomain);let r=$(t);this.userId=r,this.enqueue("identify",{...this.baseMessage(),type:"identify",userId:r,identityType:s,traits:i});}alias(t,s){if(!x(this.consent.level)){this.debug.logWarning("alias() requires full consent \u2014 call ignored.");return}if(!Oe(t.id,t.identityType,s.id,s.identityType)){this.debug.logWarning("alias() from and to are identical \u2014 call ignored.");return}O(this.cookieDomain),this.enqueue("alias",{...this.baseMessage(),type:"alias",fromId:$(t.id),fromType:t.identityType,toId:$(s.id),toType:s.identityType});}setConsent(t){let s=this.consent.level;if(t===s)return;this.debug.logConsent(s,t);let i=!w(s)&&w(t);if(i&&(this.anonymousId=D(this.cookieDomain)),w(t)||this.queue.stop(),this.consent.setLevel(t),w(t)?x(s)&&!x(t)&&(this.userId=void 0):(P(g,this.cookieDomain),P(y,this.cookieDomain)),i){this.isFirstPage=!0;let r=this.startSession();this.queue.start(),r&&this.trackSessionStart();}}reset(){this.userId=void 0,this.queue.clear(),P(g,this.cookieDomain),P(y,this.cookieDomain),this.isTrackingDisabled()?(this.anonymousId=v(),this.sessionId=void 0,this.sessionStartTime=void 0):(this.anonymousId=D(this.cookieDomain),this.startSession()&&this.trackSessionStart()),this.isFirstPage=!0;}async flush(){await this.queue.flush();}shutdown(){this.destroyed||(this.destroyed=!0,this.isTrackingDisabled()||this.trackSessionEnd(),this.queue.destroy(),e.liveInstances=Math.max(0,e.liveInstances-1));}};var as={SIGN_UP:"sign_up",SIGN_IN:"sign_in",WISHLIST_ADD:"wishlist_add",WISHLIST_REMOVE:"wishlist_remove",PURCHASE:"purchase",GAME_LAUNCH:"game_launch",PROGRESSION:"progression",RESOURCE:"resource",EMAIL_ACQUIRED:"email_acquired",GAME_PAGE_VIEWED:"game_page_viewed",LINK_CLICKED:"link_clicked",BUTTON_CLICKED:"button_clicked"};/*! Bundled license information:
|
|
1
|
+
var Ke=Object.create;var ue=Object.defineProperty;var Ve=Object.getOwnPropertyDescriptor;var He=Object.getOwnPropertyNames;var ze=Object.getPrototypeOf,We=Object.prototype.hasOwnProperty;var Je=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Ye=(e,t,s,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of He(t))!We.call(e,r)&&r!==s&&ue(e,r,{get:()=>t[r],enumerable:!(i=Ve(t,r))||i.enumerable});return e};var Xe=(e,t,s)=>(s=e!=null?Ke(ze(e)):{},Ye(ue(s,"default",{value:e,enumerable:!0}),e));var ye=Je(P=>{Object.defineProperty(P,"__esModule",{value:!0});P.clearGlobalNamespace=P.getGlobalisedValue=void 0;var et="globalise__singleton__",tt={},fe=()=>typeof window<"u"?window:typeof globalThis<"u"?globalThis:tt,st=(e,t)=>{if(typeof e!="string")throw "Invalid namespace key";if(typeof t!="string")throw "Invalid item key"},me=e=>`${et}${e}`,ge=e=>{let t=fe(),s=me(e);return t[s]||(t[s]={}),t[s]},it=(e,t)=>ge(e)[t]||void 0,rt=(e,t,s)=>{let i=ge(e);i[t]=s;},nt=(e,t,s)=>{st(e,t);let i=it(e,t);return i!==void 0?i:(rt(e,t,s),s)};P.getGlobalisedValue=nt;var ot=e=>{let t=fe(),s=me(e);t[s]!==void 0&&delete t[s];};P.clearGlobalNamespace=ot;});var j="https://api.immutable.com",ce="/v1/audience/messages",de="/v1/audience/tracking-consent",g="imtbl_anon_id",y="_imtbl_sid",B="session_start",G="session_end",p=()=>typeof window<"u"&&typeof document<"u",v=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.trunc(Math.random()*16);return (e==="x"?t:t%4+8).toString(16)}),q=()=>new Date().toISOString();function k(e){if(!p())return;let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):void 0}function A(e,t,s,i){if(!p())return;let r=window.location.protocol==="https:"?"; Secure":"",n=i?`; domain=${i}`:"";document.cookie=`${e}=${encodeURIComponent(t)}; path=/; max-age=${s}; SameSite=Lax${n}${r}`;}function T(e,t){A(e,"",0,t);}function O(e){let t=k(g);if(t)return t;let s=v();return A(g,s,63072e3,e),s}function K(e,t){A(g,e,63072e3,t);}var V=class{constructor(t=0,s=0,i=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=t,this.resetTtl=i,this.size=0,this.ttl=s;}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(t){if(this.has(t)){let s=this.items[t];delete this.items[t],this.size--,s.prev!==null&&(s.prev.next=s.next),s.next!==null&&(s.next.prev=s.prev),this.first===s&&(this.first=s.next),this.last===s&&(this.last=s.prev);}return this}entries(t=this.keys()){return t.map(s=>[s,this.get(s)])}evict(t=!1){if(t||this.size>0){let s=this.first;delete this.items[s.key],--this.size===0?(this.first=null,this.last=null):(this.first=s.next,this.first.prev=null);}return this}expiresAt(t){let s;return this.has(t)&&(s=this.items[t].expiry),s}get(t){let s;if(this.has(t)){let i=this.items[t];this.ttl>0&&i.expiry<=Date.now()?this.delete(t):(s=i.value,this.set(t,s,!0));}return s}has(t){return t in this.items}keys(){let t=[],s=this.first;for(;s!==null;)t.push(s.key),s=s.next;return t}set(t,s,i=!1,r=this.resetTtl){let n;if(i||this.has(t)){if(n=this.items[t],n.value=s,i===!1&&r&&(n.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.last!==n){let l=this.last,o=n.next,a=n.prev;this.first===n&&(this.first=n.next),n.next=null,n.prev=this.last,l.next=n,a!==null&&(a.next=o),o!==null&&(o.prev=a);}}else this.max>0&&this.size===this.max&&this.evict(!0),n=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:s},++this.size===1?this.first=n:this.last.next=n;return this.last=n,this}values(t=this.keys()){return t.map(s=>this.get(s))}};function he(e=1e3,t=0,s=!1){if(isNaN(e)||e<0)throw new TypeError("Invalid max value");if(isNaN(t)||t<0)throw new TypeError("Invalid ttl value");if(typeof s!="boolean")throw new TypeError("Invalid resetTtl value");return new V(e,t,s)}var Qe={max:1e3},pe=(e,t={})=>{let{cache:s,cacheKeyResolver:i=H,onHit:r,lruOptions:n={}}=t,l={...Qe,...n},o=s||he(l.max,l.ttl);function a(...u){let m=i(...u),d=o.get(m);if(o.has(m))return r&&r(m,d,o),d;let f=e.apply(this,u);return o.set(m,f),f}return a._cache=o,a},H=(...e)=>e.length===0?"no-args":e.map(t=>t===void 0?"undefined":t===null?"null":Array.isArray(t)?`[${H(...t)}]`:typeof t=="object"?`{${H(...Ze(t))}}`:JSON.stringify(t)).join(","),Ze=e=>Object.entries(e).sort((t,s)=>t[0]<s[0]?-1:1);var Q=Xe(ye()),at=Object.defineProperty,lt=(e,t)=>{for(var s in t)at(e,s,{get:t[s],enumerable:!0});},ut={};lt(ut,{deleteItem:()=>pt,getItem:()=>W,setItem:()=>M});var R=()=>typeof window>"u",we=()=>!R(),ct="__IMX-",Z=()=>we()&&window.localStorage,dt=e=>{if(e!==null)try{return JSON.parse(e)}catch{return e}},ht=e=>typeof e=="string"?e:JSON.stringify(e),ee=e=>`${ct}${e}`;function W(e){if(Z())return dt(window.localStorage.getItem(ee(e)))}var M=(e,t)=>Z()?(window.localStorage.setItem(ee(e),ht(t)),!0):!1,pt=e=>Z()?(window.localStorage.removeItem(ee(e)),!0):!1,J=0,ft=e=>{let t=parseInt(e,10)*1e3,s=new Date(t),i=new Date;return J=s.getTime()-i.getTime(),J},mt=()=>{let e=new Date().getTime()+J;return new Date(e).toISOString()},gt=(e=>(e.RUNTIME_ID="rid",e.PASSPORT_CLIENT_ID="passportClientId",e.ENVIRONMENT="env",e.PUBLISHABLE_API_KEY="pak",e.IDENTITY="uid",e.DOMAIN="domain",e.SDK_VERSION="sdkVersion",e))(gt||{}),yt="https://api.immutable.com",vt=e=>{if(typeof Buffer<"u")return Buffer.from(e,"utf-8").toString("base64");if(typeof btoa=="function")return btoa(unescape(encodeURIComponent(e)));throw new Error("Base64 encoding not supported in this environment")};async function be(e,t){let s=JSON.stringify(t),i={payload:vt(s)},r=await fetch(`${yt}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!r.ok){let n=await r.text().catch(()=>"");throw new Error(`Request failed (${r.status}): ${n||r.statusText}`)}return r.json()}var I,E,wt=()=>{I=W("metrics-events")||[],E=W("metrics-runtime")||{};};wt();var S=(e,t)=>{E={...E,[e]:t},M("metrics-runtime",E);},Y=e=>{if(E[e]!==void 0)return E[e]},bt=()=>E,It=()=>I,Et=e=>{I.push(e),M("metrics-events",I);},St=e=>{I=I.slice(e),M("metrics-events",I);},Ie=e=>{let t=[];return Object.entries(e).forEach(([s,i])=>{(typeof s=="string"||typeof i=="string"||typeof i=="number"||typeof i=="boolean")&&t.push([s,i.toString()]);}),t},z="2.20.1",_t=()=>R()?"":window.location.ancestorOrigins&&window.location.ancestorOrigins.length>0?new URL(window.location.ancestorOrigins[0]).hostname:document.referrer?new URL(window.document.referrer).hostname:"",xt=()=>{if(R())return "";let e;try{window.self!==window.top&&(e=_t());}catch{}return e||(e=window.location.hostname),e},kt=()=>{if(S("sdkVersion",z),R())return {browser:"nodejs",sdkVersion:z};let e=xt();return e&&S("domain",e),{sdkVersion:z,browser:window.navigator.userAgent,domain:e,tz:Intl.DateTimeFormat().resolvedOptions().timeZone,screen:`${window.screen.width}x${window.screen.height}`}},X=!1,At=()=>X,Tt=async()=>{X=!0;try{let e=Ie(kt()),t=Y("rid"),s=Y("uid"),i=await be("/v1/sdk/initialise",{version:1,data:{runtimeDetails:e,runtimeId:t,uId:s}}),{runtimeId:r,sTime:n}=i;S("rid",r),ft(n);}catch{X=!1;}};function h(e,t){return (...s)=>{try{let i=e(...s);return i instanceof Promise?i.catch(()=>t):i}catch{return t}}}function Pt(){return we()||typeof process>"u"?!1:process.env.JEST_WORKER_ID!==void 0}var Nt=h(Pt,!1),Ee="imtbl__metrics",Dt=5e3,Ot=1e3,C=(e,t)=>(0, Q.getGlobalisedValue)(Ee,e,t),Ct=(e,t)=>{let s=pe(t,{lruOptions:{ttl:Dt,max:Ot}});return (0, Q.getGlobalisedValue)(Ee,e,s)},$t=5e3,Rt=(e,t,s)=>{let i={event:`${e}.${t}`,time:mt(),...s&&{properties:Ie(s)}};Et(i);},_=h(Ct("track",Rt)),Mt=async()=>{if(At()===!1){await Tt();return}let e=It();if(e.length===0)return;let t=e.length,s=bt();await be("/v1/sdk/metrics",{version:1,data:{events:e,details:s}})instanceof Error||St(t);},Lt=h(Mt),Se=async()=>{await Lt(),setTimeout(Se,$t);},ve=!1,Ut=()=>{ve||(ve=!0,Se());};Nt()||h(C("startFlushing",Ut))();var Vt=(e,t,s,i)=>{let{message:r}=s,n=s.stack||"",{cause:l}=s;l instanceof Error&&(n=`${n}
|
|
2
|
+
Cause: ${l.message}
|
|
3
|
+
${l.stack}`),_(e,`trackError_${t}`,{...i||{},errorMessage:r,errorStack:n,isTrackError:!0});},_e=h(Vt),Wt=e=>{S("env",e);};h(C("setEnvironment",Wt));var Jt=e=>{S("passportClientId",e);};h(C("setPassportClientId",Jt));var Yt=e=>{S("pak",e);};h(C("setPublishableApiKey",Yt));h(C("getDetail",Y));var Xt={Passport:"passport",Steam:"steam",Epic:"epic",Google:"google",Apple:"apple",Discord:"discord",Email:"email",Custom:"custom"},L=class extends Error{status;endpoint;body;constructor(e){super(`audience transport failed: ${e.status||"network error"} ${e.endpoint}`,e.cause!==void 0?{cause:e.cause}:void 0),this.name="TransportError",this.status=e.status,this.endpoint=e.endpoint,this.body=e.body;}},N=class extends Error{code;status;endpoint;responseBody;cause;constructor(e){super(e.message),this.name="AudienceError",this.code=e.code,this.status=e.status,this.endpoint=e.endpoint,this.responseBody=e.responseBody,this.cause=e.cause;}};function Ae(e,t,s){if(e.status===0)return new N({code:"NETWORK_ERROR",message:t==="flush"?`Network error sending ${s??0} messages`:"Network error syncing consent",status:0,endpoint:e.endpoint,cause:e.cause});if(e.status>=200&&e.status<300){let i=e.body,r=i?.rejected??0,n=i?.accepted??0;return new N({code:"VALIDATION_REJECTED",message:`Backend rejected ${r} of ${r+n} messages`,status:e.status,endpoint:e.endpoint,responseBody:e.body})}return e.status===429?new N({code:"RATE_LIMITED",message:t==="flush"?"Flush rate limited (429)":"Consent sync rate limited (429)",status:e.status,endpoint:e.endpoint,responseBody:e.body}):e.status>=400&&e.status<500?new N({code:t==="flush"?"VALIDATION_REJECTED":"CONSENT_SYNC_FAILED",message:t==="flush"?`Flush rejected with status ${e.status}`:`Consent sync failed with status ${e.status}`,status:e.status,endpoint:e.endpoint,responseBody:e.body}):new N({code:t==="flush"?"FLUSH_FAILED":"CONSENT_SYNC_FAILED",message:t==="flush"?`Flush failed with status ${e.status}`:`Consent sync failed with status ${e.status}`,status:e.status,endpoint:e.endpoint,responseBody:e.body,cause:e.cause})}function Te(e,t){if(e)try{e(t);}catch{}}var Qt=3e4;function Zt(e){let t=e.get?.("retry-after");if(!t)return null;let s=Number(t.trim());if(!Number.isNaN(s)&&s>=0)return Math.round(s*1e3);let i=new Date(t);if(!Number.isNaN(i.getTime())){let r=i.getTime()-Date.now();return r>0?r:null}return null}function te(){try{return p()?navigator.onLine:void 0}catch{return}}async function xe(e){let t=e.headers?.get?.("content-type")??"";try{return t.includes("application/json")?await e.json():await e.text()}catch{return}}var ie=async(e,t,s,i)=>{let r=new AbortController,n=setTimeout(()=>r.abort(),Qt),l=Date.now();try{let o=await fetch(e,{method:i?.method??"POST",headers:{"Content-Type":"application/json","x-immutable-publishable-key":t},body:JSON.stringify(s),keepalive:i?.keepalive,signal:r.signal});if(o.status===429){_("audience","transport_send_failed",{status:429,online:te(),timeToFailureMs:Date.now()-l});let u=Zt(o.headers);return {ok:!1,error:new L({status:429,endpoint:e}),...u!==null?{retryAfterMs:u}:{}}}if(!o.ok){let u=await xe(o);return _("audience","transport_send_failed",{status:o.status,online:te(),timeToFailureMs:Date.now()-l}),{ok:!1,error:new L({status:o.status,endpoint:e,body:u})}}let a=await xe(o);if(typeof a=="object"&&a!==null&&"rejected"in a){let u=a.rejected??0;if(u>0)return _("audience","transport_partial_rejected",{status:o.status,rejected:u}),{ok:!1,error:new L({status:o.status,endpoint:e,body:a})}}return {ok:!0}}catch(o){let a=new L({status:0,endpoint:e,cause:o});return _e("audience","transport_send",a,{errorName:o instanceof Error?o.name:void 0,online:te(),timeToFailureMs:Date.now()-l}),{ok:!1,error:a}}finally{clearTimeout(n);}},re="__imtbl_audience_";function ne(){try{return p()&&typeof localStorage<"u"}catch{return !1}}function es(e,t=re){if(ne())try{let s=localStorage.getItem(`${t}${e}`);return s?JSON.parse(s):void 0}catch{return}}function ts(e,t,s=re){if(ne())try{localStorage.setItem(`${s}${e}`,JSON.stringify(t));}catch{}}function ss(e,t=re){if(ne())try{localStorage.removeItem(`${t}${e}`);}catch{}}var se="queue",ke=100,Pe=class{constructor(e,t,s){this.send=e,this.publishableKey=t,this.endpointUrl=`${s?.baseUrl??j}${ce}`,this.flushIntervalMs=s?.flushIntervalMs??5e3,this.flushSize=s?.flushSize??20,this.onFlush=s?.onFlush,this.onError=s?.onError,this.storagePrefix=s?.storagePrefix;let i=es(se,this.storagePrefix)??[];this.messages=s?.staleFilter?i.filter(s.staleFilter):i;}messages;timer=null;flushing=!1;unloadBound=!1;visibilityHandler;pagehideHandler;onFlush;onError;storagePrefix;endpointUrl;flushIntervalMs;flushSize;consecutiveFailures=0;nextAttemptAt=0;start(){this.timer||(this.timer=setInterval(()=>this.flush(),this.flushIntervalMs),this.registerUnload());}stop(){this.timer&&(clearInterval(this.timer),this.timer=null),this.removeUnload();}destroy(){this.stop(),this.flushUnload();}enqueue(e){this.messages.push(e),this.persist(),this.messages.length>=this.flushSize&&this.flush();}async flush(){if(!(this.flushing||this.messages.length===0)&&!(Date.now()<this.nextAttemptAt)){this.flushing=!0;try{let e=this.messages.slice(0,ke),t={messages:e},s=await this.send(this.endpointUrl,this.publishableKey,t),i;!s.ok&&s.error&&(i=Ae(s.error,"flush",e.length));let r=i?.code==="VALIDATION_REJECTED";s.ok||r?(this.messages=this.messages.slice(e.length),this.persist(),this.resetBackoff()):i&&(s.retryAfterMs!==void 0?this.setBackoffUntil(Date.now()+s.retryAfterMs):this.recordFailure()),this.onFlush?.(s.ok,e.length),i&&Te(this.onError,i);}finally{this.flushing=!1;}}}flushUnload(){if(this.flushing||this.messages.length===0)return;let e=this.messages.slice(0,ke),t={messages:e};this.send(this.endpointUrl,this.publishableKey,t,{keepalive:!0}),this.messages=this.messages.slice(e.length),this.persist();}purge(e){this.messages=this.messages.filter(t=>!e(t)),this.persist();}transform(e){this.messages=this.messages.map(e),this.persist();}get length(){return this.messages.length}clear(){this.messages=[],ss(se,this.storagePrefix);}registerUnload(){!p()||this.unloadBound||(this.unloadBound=!0,this.pagehideHandler=()=>this.flushUnload(),this.visibilityHandler=()=>{document.visibilityState==="hidden"&&this.flushUnload();},document.addEventListener("visibilitychange",this.visibilityHandler),window.addEventListener("pagehide",this.pagehideHandler));}removeUnload(){this.unloadBound&&(this.visibilityHandler&&document.removeEventListener("visibilitychange",this.visibilityHandler),this.pagehideHandler&&window.removeEventListener("pagehide",this.pagehideHandler),this.unloadBound=!1);}backoffDelayMs(){switch(this.consecutiveFailures){case 0:return 0;case 1:return 5e3;case 2:return 1e4;case 3:return 2e4;case 4:return 4e4;default:return 6e4}}recordFailure(){let e=Date.now();e<this.nextAttemptAt||(this.consecutiveFailures++,this.nextAttemptAt=e+this.backoffDelayMs());}setBackoffUntil(e){this.consecutiveFailures++,this.nextAttemptAt=e;}resetBackoff(){this.consecutiveFailures=0,this.nextAttemptAt=0;}persist(){ts(se,this.messages,this.storagePrefix);}},is="2.20.1";function Ne(e="@imtbl/audience",t=is){let s={library:e,libraryVersion:t};return p()&&(s.userAgent=navigator.userAgent,s.locale=navigator.language,s.timezone=Intl.DateTimeFormat().resolvedOptions().timeZone,s.screen=`${window.screen.width}x${window.screen.height}`,s.pageUrl=window.location.href,s.pagePath=window.location.pathname,s.pageReferrer=document.referrer,s.pageTitle=document.title),s}function De(e){let t=new Date(e).getTime();if(Number.isNaN(t))return !1;let s=Date.now();return t<=s+864e5&&t>=s-2592e6}function Oe(e,t,s,i){return e!==s||t!==i}function $(e,t=256){return e.length>t?e.slice(0,t):e}function D(e){let t=k(y);if(t)return A(y,t,1800,e),{sessionId:t,isNew:!1};let s=v();return A(y,s,1800,e),{sessionId:s,isNew:!0}}var Ce=["utm_source","utm_medium","utm_campaign","utm_content","utm_term"],$e=["gclid","dclid","fbclid","ttclid","msclkid","li_fat_id"],Re="__imtbl_attribution";function rs(e){let t;try{t=new URL(e).searchParams;}catch{return {}}let s={};for(let r of [...Ce,...$e]){let n=t.get(r);n&&(s[r]=n);}let i=t.get("referral_code");return i&&(s.referral_code=i),s}function ns(){try{let e=sessionStorage.getItem(Re);return e?JSON.parse(e):null}catch{return null}}function os(e){try{sessionStorage.setItem(Re,JSON.stringify(e));}catch{}}function Me(){let e=typeof window<"u"&&window.location?rs(window.location.href):{},t=typeof document<"u"&&document.referrer||void 0,s=$e.some(r=>r in e),i=Ce.some(r=>r in e);return {...e,referrer:t,touchpoint_type:s||i?"click":void 0}}function Le(){let e=ns();if(e)return e;let t=typeof window<"u"&&window.location?window.location.href:void 0,s={...Me(),landing_page:t};return os(s),s}function Ue(){return Me()}function w(e){return e!=="none"}function x(e){return e==="full"}function Fe(e,t,s,i,r,n,l,o){let a=n??"none",u={none:0,anonymous:1,full:2};function m(d){let c=`${o??j}${de}`;t(c,s,{anonymousId:i,status:d,source:r},{method:"PUT",keepalive:!0}).then(f=>{!f.ok&&f.error&&Te(l,Ae(f.error,"consent"));});}return {get level(){return a},setLevel(d){d!==a&&(u[d]<u[a]&&(d==="none"?e.purge(()=>!0):d==="anonymous"&&(e.purge(c=>c.type==="identify"||c.type==="alias"),e.transform(c=>{if("userId"in c){let{userId:f,...F}=c;return F}return c}))),a=d,m(d));}}}var je="@imtbl/audience",Be="2.20.1",b="[audience]",Ge="WebSDK";var U=class{enabled;constructor(t=!1){this.enabled=t;}logEvent(t,s){this.enabled&&console.log(`${b} ${t}`,s);}logFlush(t,s){this.enabled&&console.log(`${b} flush ${t?"ok":"failed"} (${s} messages)`);}logConsent(t,s){this.enabled&&console.log(`${b} consent ${t} \u2192 ${s}`);}logWarning(t){this.enabled&&console.warn(`${b} ${t}`);}};var as=new Set(["sign_up","link_clicked"]),oe=class e{static liveInstances=0;queue;consent;attribution;debug;cookieDomain;testMode;anonymousId;sessionId;sessionStartTime;userId;isFirstPage=!0;destroyed=!1;static UUID_RE=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;static readAndStripAidParam(){if(!p())return null;let t=new URLSearchParams(window.location.search),s=t.get("imtbl_aid");if(s!==null){t.delete("imtbl_aid");let i=t.toString(),r=`${window.location.pathname}${i?`?${i}`:""}${window.location.hash}`;window.history.replaceState(window.history.state,"",r);}return s&&e.UUID_RE.test(s)?s:null}constructor(t){let{cookieDomain:s,publishableKey:i}=t,r=t.consent??"none",n=Ge;this.cookieDomain=s,this.testMode=t.testMode??!1,this.debug=new U(t.debug??!1);let l=e.readAndStripAidParam(),o=!1;w(r)?(l?(K(l,s),this.anonymousId=l):this.anonymousId=O(s),o=this.startSession()):this.anonymousId=k(g)??v(),this.queue=new Pe(ie,i,{baseUrl:t.baseUrl,flushIntervalMs:t.flushInterval,flushSize:t.flushSize,onFlush:(a,u)=>this.debug.logFlush(a,u),onError:t.onError,staleFilter:a=>De(a.eventTimestamp),storagePrefix:"__imtbl_web_"}),this.consent=Fe(this.queue,ie,i,this.anonymousId,n,r,t.onError,t.baseUrl),this.attribution=Le(),this.isTrackingDisabled()||(this.queue.start(),o&&this.trackSessionStart());}static init(t){if(!t.publishableKey?.trim())throw new Error(`${b} publishableKey is required`);return e.liveInstances>0&&console.warn(`${b} Multiple SDK instances detected. Ensure previous instances are shut down to avoid duplicate events.`),e.liveInstances+=1,new e(t)}getAnonymousId(){return this.anonymousId}isTrackingDisabled(){return !w(this.consent.level)}effectiveUserId(){return x(this.consent.level)?this.userId:void 0}startSession(){let t=D(this.cookieDomain);return this.sessionId=t.sessionId,this.sessionStartTime=Date.now(),t.isNew}baseMessage(){return {messageId:v(),eventTimestamp:q(),anonymousId:this.anonymousId,surface:"web",context:Ne(je,Be),...this.testMode&&{test:!0}}}enqueue(t,s){this.queue.enqueue(s),this.debug.logEvent(t,s);}trackSessionStart(){this.sessionId&&this.enqueue("track(session_start)",{...this.baseMessage(),type:"track",eventName:B,properties:{session_id:this.sessionId,...this.attribution}});}trackSessionEnd(){this.sessionId&&this.enqueue("track(session_end)",{...this.baseMessage(),type:"track",eventName:G,properties:{session_id:this.sessionId,...this.sessionStartTime&&{duration:Math.round((Date.now()-this.sessionStartTime)/1e3)}}});}page(t){if(this.isTrackingDisabled())return;D(this.cookieDomain);let s={session_id:this.sessionId,...t};this.isFirstPage&&(Object.assign(s,this.attribution),this.isFirstPage=!1),this.enqueue("page",{...this.baseMessage(),type:"page",properties:s,userId:this.effectiveUserId()});}track(t,...s){if(this.isTrackingDisabled())return;D(this.cookieDomain);let[i]=s,r={session_id:this.sessionId,...as.has(t)?Ue():{},...i};this.enqueue("track",{...this.baseMessage(),type:"track",eventName:$(t),properties:r,userId:this.effectiveUserId()});}identify(t,s,i){if(!x(this.consent.level)){this.debug.logWarning("identify() requires full consent \u2014 call ignored.");return}D(this.cookieDomain);let r=$(t);this.userId=r,this.enqueue("identify",{...this.baseMessage(),type:"identify",userId:r,identityType:s,traits:i});}alias(t,s){if(!x(this.consent.level)){this.debug.logWarning("alias() requires full consent \u2014 call ignored.");return}if(!Oe(t.id,t.identityType,s.id,s.identityType)){this.debug.logWarning("alias() from and to are identical \u2014 call ignored.");return}D(this.cookieDomain),this.enqueue("alias",{...this.baseMessage(),type:"alias",fromId:$(t.id),fromType:t.identityType,toId:$(s.id),toType:s.identityType});}setConsent(t){let s=this.consent.level;if(t===s)return;this.debug.logConsent(s,t);let i=!w(s)&&w(t);if(i&&(this.anonymousId=O(this.cookieDomain)),w(t)||this.queue.stop(),this.consent.setLevel(t),w(t)?x(s)&&!x(t)&&(this.userId=void 0):(T(g,this.cookieDomain),T(y,this.cookieDomain)),i){this.isFirstPage=!0;let r=this.startSession();this.queue.start(),r&&this.trackSessionStart();}}reset(){this.userId=void 0,this.queue.clear(),T(g,this.cookieDomain),T(y,this.cookieDomain),this.isTrackingDisabled()?(this.anonymousId=v(),this.sessionId=void 0,this.sessionStartTime=void 0):(this.anonymousId=O(this.cookieDomain),this.startSession()&&this.trackSessionStart()),this.isFirstPage=!0;}async flush(){await this.queue.flush();}shutdown(){this.destroyed||(this.destroyed=!0,this.isTrackingDisabled()||this.trackSessionEnd(),this.queue.destroy(),e.liveInstances=Math.max(0,e.liveInstances-1));}};var ls={SIGN_UP:"sign_up",SIGN_IN:"sign_in",WISHLIST_ADD:"wishlist_add",WISHLIST_REMOVE:"wishlist_remove",PURCHASE:"purchase",GAME_LAUNCH:"game_launch",PROGRESSION:"progression",RESOURCE:"resource",EMAIL_ACQUIRED:"email_acquired",GAME_PAGE_VIEWED:"game_page_viewed",LINK_CLICKED:"link_clicked",BUTTON_CLICKED:"button_clicked"};/*! Bundled license information:
|
|
4
4
|
|
|
5
5
|
tiny-lru/dist/tiny-lru.js:
|
|
6
6
|
(**
|
|
@@ -12,4 +12,4 @@ tiny-lru/dist/tiny-lru.js:
|
|
|
12
12
|
*)
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
export {
|
|
15
|
+
export { oe as Audience, N as AudienceError, ls as AudienceEvents, Xt as IdentityType, x as canIdentify, w as canTrack };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imtbl/audience",
|
|
3
3
|
"description": "Immutable Audience — consent-aware event tracking and identity management",
|
|
4
|
-
"version": "2.20.1
|
|
4
|
+
"version": "2.20.1",
|
|
5
5
|
"author": "Immutable",
|
|
6
6
|
"bugs": "https://github.com/immutable/ts-immutable-sdk/issues",
|
|
7
7
|
"devDependencies": {
|