@imtbl/audience 2.15.1-alpha.4 → 2.15.1-alpha.5
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 +2 -2
- package/dist/node/index.cjs +2 -2
- package/dist/node/index.js +2 -2
- package/package.json +1 -1
package/dist/browser/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var gn=Object.create;var lt=Object.defineProperty;var yn=Object.getOwnPropertyDescriptor;var mn=Object.getOwnPropertyNames;var wn=Object.getPrototypeOf,vn=Object.prototype.hasOwnProperty;var ft=(r,i)=>()=>(r&&(i=r(r=0)),i);var bn=(r,i)=>()=>(i||r((i={exports:{}}).exports,i),i.exports);var In=(r,i,o,f)=>{if(i&&typeof i=="object"||typeof i=="function")for(let c of mn(i))!vn.call(r,c)&&c!==o&<(r,c,{get:()=>i[c],enumerable:!(f=yn(i,c))||f.enumerable});return r};var En=(r,i,o)=>(o=r!=null?gn(wn(r)):{},In(lt(o,"default",{value:r,enumerable:!0}),r));var B=ft(()=>{});var T=ft(()=>{});var yt=bn(ie=>{T();B();Object.defineProperty(ie,"__esModule",{value:!0});ie.clearGlobalNamespace=ie.getGlobalisedValue=void 0;var An="globalise__singleton__",xn={},pt=()=>typeof window<"u"?window:typeof globalThis<"u"?globalThis:xn,Bn=(r,i)=>{if(typeof r!="string")throw "Invalid namespace key";if(typeof i!="string")throw "Invalid item key"},dt=r=>`${An}${r}`,gt=r=>{let i=pt(),o=dt(r);return i[o]||(i[o]={}),i[o]},Tn=(r,i)=>gt(r)[i]||void 0,Un=(r,i,o)=>{let f=gt(r);f[i]=o;},kn=(r,i,o)=>{Bn(r,i);let f=Tn(r,i);return f!==void 0?f:(Un(r,i,o),o)};ie.getGlobalisedValue=kn;var On=r=>{let i=pt(),o=dt(r);i[o]!==void 0&&delete i[o];};ie.clearGlobalNamespace=On;});T();B();T();B();T();B();T();B();T();B();T();B();var Ue=class{constructor(i=0,o=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=o;}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(i){if(this.has(i)){let o=this.items[i];delete this.items[i],this.size--,o.prev!==null&&(o.prev.next=o.next),o.next!==null&&(o.next.prev=o.prev),this.first===o&&(this.first=o.next),this.last===o&&(this.last=o.prev);}return this}entries(i=this.keys()){return i.map(o=>[o,this.get(o)])}evict(i=!1){if(i||this.size>0){let o=this.first;delete this.items[o.key],--this.size===0?(this.first=null,this.last=null):(this.first=o.next,this.first.prev=null);}return this}expiresAt(i){let o;return this.has(i)&&(o=this.items[i].expiry),o}get(i){let o;if(this.has(i)){let f=this.items[i];this.ttl>0&&f.expiry<=Date.now()?this.delete(i):(o=f.value,this.set(i,o,!0));}return o}has(i){return i in this.items}keys(){let i=[],o=this.first;for(;o!==null;)i.push(o.key),o=o.next;return i}set(i,o,f=!1,c=this.resetTtl){let p;if(f||this.has(i)){if(p=this.items[i],p.value=o,f===!1&&c&&(p.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.last!==p){let a=this.last,y=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=y),y!==null&&(y.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:o},++this.size===1?this.first=p:this.last.next=p;return this.last=p,this}values(i=this.keys()){return i.map(o=>this.get(o))}};function ht(r=1e3,i=0,o=!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 o!="boolean")throw new TypeError("Invalid resetTtl value");return new Ue(r,i,o)}var Sn={max:1e3},ct=(r,i={})=>{let{cache:o,cacheKeyResolver:f=ke,onHit:c,lruOptions:p={}}=i,a={...Sn,...p},y=o||ht(a.max,a.ttl);function m(...x){let v=f(...x),w=y.get(v);if(y.has(v))return c&&c(v,w,y),w;let d=r.apply(this,x);return y.set(v,d),d}return m._cache=y,m},ke=(...r)=>r.length===0?"no-args":r.map(i=>i===void 0?"undefined":i===null?"null":Array.isArray(i)?`[${ke(...i)}]`:typeof i=="object"?`{${ke(..._n(i))}}`:JSON.stringify(i)).join(","),_n=r=>Object.entries(r).sort((i,o)=>i[0]<o[0]?-1:1);var Fe=En(yt()),Pn=Object.defineProperty,Rn=(r,i)=>{for(var o in i)Pn(r,o,{get:i[o],enumerable:!0});};function je(r){throw new Error("Node.js process "+r+" is not supported by JSPM core outside of Node.js")}var q=[],se=!1,J,ve=-1;function Nn(){!se||!J||(se=!1,J.length?q=J.concat(q):ve=-1,q.length&&Et());}function Et(){if(!se){var r=setTimeout(Nn,0);se=!0;for(var i=q.length;i;){for(J=q,q=[];++ve<i;)J&&J[ve].run();ve=-1,i=q.length;}J=null,se=!1,clearTimeout(r);}}function Ln(r){var i=new Array(arguments.length-1);if(arguments.length>1)for(var o=1;o<arguments.length;o++)i[o-1]=arguments[o];q.push(new St(r,i)),q.length===1&&!se&&setTimeout(Et,0);}function St(r,i){this.fun=r,this.array=i;}St.prototype.run=function(){this.fun.apply(null,this.array);};var Cn="browser",$n="x64",Mn="browser",Dn={PATH:"/usr/bin",LANG:navigator.language+".UTF-8",PWD:"/",HOME:"/home",TMP:"/tmp"},Fn=["/usr/bin/node"],jn=[],Gn="v16.8.0",qn={},Vn=function(r,i){console.warn((i?i+": ":"")+r);},Kn=function(r){je("binding");},zn=function(r){return 0},Wn=function(){return "/"},Hn=function(r){},Yn={name:"node",sourceUrl:"",headersUrl:"",libUrl:""};function N(){}var Jn=N,Xn=[];function Qn(r){je("_linkedBinding");}var Zn={},er=!1,tr={};function nr(r){je("dlopen");}function rr(){return []}function ir(){return []}var sr=N,or=N,Ge=function(){return {}},ar=Ge,ur=Ge,lr=N,fr=N,hr=N,cr={};function pr(r,i){if(!r)throw new Error(i||"assertion error")}var dr={inspector:!1,debug:!1,uv:!1,ipv6:!1,tls_alpn:!1,tls_sni:!1,tls_ocsp:!1,tls:!1,cached_builtins:!0},gr=N,yr=N;function mr(){return !1}var wr=N,vr=N,br=N,Ir=N,Er=N,Sr=void 0,_r=void 0,Ar=void 0,xr=N,Br=2,Tr=1,Ur="/bin/usr/node",kr=9229,Or="node",Pr=[],Rr=N,K={now:typeof performance<"u"?performance.now.bind(performance):void 0,timing:typeof performance<"u"?performance.timing:void 0};K.now===void 0&&(Oe=Date.now(),K.timing&&K.timing.navigationStart&&(Oe=K.timing.navigationStart),K.now=()=>Date.now()-Oe);var Oe;function Nr(){return K.now()/1e3}var Re=1e9;function Ne(r){var i=Math.floor((Date.now()-K.now())*.001),o=K.now()*.001,f=Math.floor(o)+i,c=Math.floor(o%1*1e9);return r&&(f=f-r[0],c=c-r[1],c<0&&(f--,c+=Re)),[f,c]}Ne.bigint=function(r){var i=Ne(r);return typeof BigInt>"u"?i[0]*Re+i[1]:BigInt(i[0]*Re)+BigInt(i[1])};var Lr=10,Cr={},$r=0;function z(){return Le}var Mr=z,Dr=z,Fr=z,jr=z,Gr=z,qr=N,Vr=z,Kr=z;function zr(r){return []}var Le={version:Gn,versions:qn,arch:$n,platform:Mn,release:Yn,_rawDebug:Jn,moduleLoadList:Xn,binding:Kn,_linkedBinding:Qn,_events:Cr,_eventsCount:$r,_maxListeners:Lr,on:z,addListener:Mr,once:Dr,off:Fr,removeListener:jr,removeAllListeners:Gr,emit:qr,prependListener:Vr,prependOnceListener:Kr,listeners:zr,domain:Zn,_exiting:er,config:tr,dlopen:nr,uptime:Nr,_getActiveRequests:rr,_getActiveHandles:ir,reallyExit:sr,_kill:or,cpuUsage:Ge,resourceUsage:ar,memoryUsage:ur,kill:lr,exit:fr,openStdin:hr,allowedNodeEnvironmentFlags:cr,assert:pr,features:dr,_fatalExceptions:gr,setUncaughtExceptionCaptureCallback:yr,hasUncaughtExceptionCaptureCallback:mr,emitWarning:Vn,nextTick:Ln,_tickCallback:wr,_debugProcess:vr,_debugEnd:br,_startProfilerIdleNotifier:Ir,_stopProfilerIdleNotifier:Er,stdout:Sr,stdin:Ar,stderr:_r,abort:xr,umask:zn,chdir:Hn,cwd:Wn,env:Dn,title:Cn,argv:Fn,execArgv:jn,pid:Br,ppid:Tr,execPath:Ur,debugPort:kr,hrtime:Ne,argv0:Or,_preload_modules:Pr,setSourceMapsEnabled:Rr},ce={},mt=!1;function Wr(){if(mt)return ce;mt=!0,ce.byteLength=y,ce.toByteArray=x,ce.fromByteArray=b;for(var r=[],i=[],o=typeof Uint8Array<"u"?Uint8Array:Array,f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=0,p=f.length;c<p;++c)r[c]=f[c],i[f.charCodeAt(c)]=c;i[45]=62,i[95]=63;function a(d){var g=d.length;if(g%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var I=d.indexOf("=");I===-1&&(I=g);var A=I===g?0:4-I%4;return [I,A]}function y(d){var g=a(d),I=g[0],A=g[1];return (I+A)*3/4-A}function m(d,g,I){return (g+I)*3/4-I}function x(d){var g,I=a(d),A=I[0],R=I[1],U=new o(m(d,A,R)),C=0,M=R>0?A-4:A,L;for(L=0;L<M;L+=4)g=i[d.charCodeAt(L)]<<18|i[d.charCodeAt(L+1)]<<12|i[d.charCodeAt(L+2)]<<6|i[d.charCodeAt(L+3)],U[C++]=g>>16&255,U[C++]=g>>8&255,U[C++]=g&255;return R===2&&(g=i[d.charCodeAt(L)]<<2|i[d.charCodeAt(L+1)]>>4,U[C++]=g&255),R===1&&(g=i[d.charCodeAt(L)]<<10|i[d.charCodeAt(L+1)]<<4|i[d.charCodeAt(L+2)]>>2,U[C++]=g>>8&255,U[C++]=g&255),U}function v(d){return r[d>>18&63]+r[d>>12&63]+r[d>>6&63]+r[d&63]}function w(d,g,I){for(var A,R=[],U=g;U<I;U+=3)A=(d[U]<<16&16711680)+(d[U+1]<<8&65280)+(d[U+2]&255),R.push(v(A));return R.join("")}function b(d){for(var g,I=d.length,A=I%3,R=[],U=16383,C=0,M=I-A;C<M;C+=U)R.push(w(d,C,C+U>M?M:C+U));return A===1?(g=d[I-1],R.push(r[g>>2]+r[g<<4&63]+"==")):A===2&&(g=(d[I-2]<<8)+d[I-1],R.push(r[g>>10]+r[g>>4&63]+r[g<<2&63]+"=")),R.join("")}return ce}var we={},wt=!1;function Hr(){return wt?we:(wt=!0,we.read=function(r,i,o,f,c){var p,a,y=c*8-f-1,m=(1<<y)-1,x=m>>1,v=-7,w=o?c-1:0,b=o?-1:1,d=r[i+w];for(w+=b,p=d&(1<<-v)-1,d>>=-v,v+=y;v>0;p=p*256+r[i+w],w+=b,v-=8);for(a=p&(1<<-v)-1,p>>=-v,v+=f;v>0;a=a*256+r[i+w],w+=b,v-=8);if(p===0)p=1-x;else {if(p===m)return a?NaN:(d?-1:1)*(1/0);a=a+Math.pow(2,f),p=p-x;}return (d?-1:1)*a*Math.pow(2,p-f)},we.write=function(r,i,o,f,c,p){var a,y,m,x=p*8-c-1,v=(1<<x)-1,w=v>>1,b=c===23?Math.pow(2,-24)-Math.pow(2,-77):0,d=f?0:p-1,g=f?1:-1,I=i<0||i===0&&1/i<0?1:0;for(i=Math.abs(i),isNaN(i)||i===1/0?(y=isNaN(i)?1:0,a=v):(a=Math.floor(Math.log(i)/Math.LN2),i*(m=Math.pow(2,-a))<1&&(a--,m*=2),a+w>=1?i+=b/m:i+=b*Math.pow(2,1-w),i*m>=2&&(a++,m/=2),a+w>=v?(y=0,a=v):a+w>=1?(y=(i*m-1)*Math.pow(2,c),a=a+w):(y=i*Math.pow(2,w-1)*Math.pow(2,c),a=0));c>=8;r[o+d]=y&255,d+=g,y/=256,c-=8);for(a=a<<c|y,x+=c;x>0;r[o+d]=a&255,d+=g,a/=256,x-=8);r[o+d-g]|=I*128;},we)}var Y={},vt=!1;function Yr(){if(vt)return Y;vt=!0;let r=Wr(),i=Hr(),o=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;Y.Buffer=a,Y.SlowBuffer=R,Y.INSPECT_MAX_BYTES=50;let f=2147483647;Y.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{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 v(e)}return y(e,t,n)}a.poolSize=8192;function y(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(F(e,ArrayBuffer)||e&&F(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(F(e,SharedArrayBuffer)||e&&F(e.buffer,SharedArrayBuffer)))return g(e,t,n);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let s=e.valueOf&&e.valueOf();if(s!=null&&s!==e)return a.from(s,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 y(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 x(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 x(e,t,n)};function v(e){return m(e),p(e<0?0:A(e)|0)}a.allocUnsafe=function(e){return v(e)},a.allocUnsafeSlow=function(e){return v(e)};function w(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!a.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let n=U(e,t)|0,s=p(n),u=s.write(e,t);return u!==n&&(s=s.slice(0,u)),s}function b(e){let t=e.length<0?0:A(e.length)|0,n=p(t);for(let s=0;s<t;s+=1)n[s]=e[s]&255;return n}function d(e){if(F(e,Uint8Array)){let t=new Uint8Array(e);return g(t.buffer,t.byteOffset,t.byteLength)}return b(e)}function g(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 s;return t===void 0&&n===void 0?s=new Uint8Array(e):n===void 0?s=new Uint8Array(e,t):s=new Uint8Array(e,t,n),Object.setPrototypeOf(s,a.prototype),s}function I(e){if(a.isBuffer(e)){let t=A(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"||Te(e.length)?p(0):b(e);if(e.type==="Buffer"&&Array.isArray(e.data))return b(e.data)}function A(e){if(e>=f)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+f.toString(16)+" bytes");return e|0}function R(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,s=t.length;for(let u=0,l=Math.min(n,s);u<l;++u)if(e[u]!==t[u]){n=e[u],s=t[u];break}return n<s?-1:s<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 s=a.allocUnsafe(t),u=0;for(n=0;n<e.length;++n){let l=e[n];if(F(l,Uint8Array))u+l.length>s.length?(a.isBuffer(l)||(l=a.from(l)),l.copy(s,u)):Uint8Array.prototype.set.call(s,l,u);else if(a.isBuffer(l))l.copy(s,u);else throw new TypeError('"list" argument must be an Array of Buffers');u+=l.length;}return s};function U(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,s=arguments.length>2&&arguments[2]===!0;if(!s&&n===0)return 0;let u=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return Be(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return n*2;case"hex":return n>>>1;case"base64":return ut(e).length;default:if(u)return s?-1:Be(e).length;t=(""+t).toLowerCase(),u=!0;}}a.byteLength=U;function C(e,t,n){let s=!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 on(this,t,n);case"utf8":case"utf-8":return Ze(this,t,n);case"ascii":return rn(this,t,n);case"latin1":case"binary":return sn(this,t,n);case"base64":return tn(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return an(this,t,n);default:if(s)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),s=!0;}}a.prototype._isBuffer=!0;function M(e,t,n){let s=e[t];e[t]=e[n],e[n]=s;}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?Ze(this,0,e):C.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=Y.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"},o&&(a.prototype[o]=a.prototype.inspect),a.prototype.compare=function(e,t,n,s,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),s===void 0&&(s=0),u===void 0&&(u=this.length),t<0||n>e.length||s<0||u>this.length)throw new RangeError("out of range index");if(s>=u&&t>=n)return 0;if(s>=u)return -1;if(t>=n)return 1;if(t>>>=0,n>>>=0,s>>>=0,u>>>=0,this===e)return 0;let l=u-s,h=n-t,S=Math.min(l,h),P=this.slice(s,u),_=e.slice(t,n);for(let E=0;E<S;++E)if(P[E]!==_[E]){l=P[E],h=_[E];break}return l<h?-1:h<l?1:0};function L(e,t,n,s,u){if(e.length===0)return -1;if(typeof n=="string"?(s=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,Te(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,s)),a.isBuffer(t))return t.length===0?-1:Qe(e,t,n,s,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):Qe(e,[t],n,s,u);throw new TypeError("val must be string, number or Buffer")}function Qe(e,t,n,s,u){let l=1,h=e.length,S=t.length;if(s!==void 0&&(s=String(s).toLowerCase(),s==="ucs2"||s==="ucs-2"||s==="utf16le"||s==="utf-16le")){if(e.length<2||t.length<2)return -1;l=2,h/=2,S/=2,n/=2;}function P(E,k){return l===1?E[k]:E.readUInt16BE(k*l)}let _;if(u){let E=-1;for(_=n;_<h;_++)if(P(e,_)===P(t,E===-1?0:_-E)){if(E===-1&&(E=_),_-E+1===S)return E*l}else E!==-1&&(_-=_-E),E=-1;}else for(n+S>h&&(n=h-S),_=n;_>=0;_--){let E=!0;for(let k=0;k<S;k++)if(P(e,_+k)!==P(t,k)){E=!1;break}if(E)return _}return -1}a.prototype.includes=function(e,t,n){return this.indexOf(e,t,n)!==-1},a.prototype.indexOf=function(e,t,n){return L(this,e,t,n,!0)},a.prototype.lastIndexOf=function(e,t,n){return L(this,e,t,n,!1)};function Jt(e,t,n,s){n=Number(n)||0;let u=e.length-n;s?(s=Number(s),s>u&&(s=u)):s=u;let l=t.length;s>l/2&&(s=l/2);let h;for(h=0;h<s;++h){let S=parseInt(t.substr(h*2,2),16);if(Te(S))return h;e[n+h]=S;}return h}function Xt(e,t,n,s){return me(Be(t,e.length-n),e,n,s)}function Qt(e,t,n,s){return me(hn(t),e,n,s)}function Zt(e,t,n,s){return me(ut(t),e,n,s)}function en(e,t,n,s){return me(cn(t,e.length-n),e,n,s)}a.prototype.write=function(e,t,n,s){if(t===void 0)s="utf8",n=this.length,t=0;else if(n===void 0&&typeof t=="string")s=t,n=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(n)?(n=n>>>0,s===void 0&&(s="utf8")):(s=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");s||(s="utf8");let l=!1;for(;;)switch(s){case"hex":return Jt(this,e,t,n);case"utf8":case"utf-8":return Xt(this,e,t,n);case"ascii":case"latin1":case"binary":return Qt(this,e,t,n);case"base64":return Zt(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return en(this,e,t,n);default:if(l)throw new TypeError("Unknown encoding: "+s);s=(""+s).toLowerCase(),l=!0;}},a.prototype.toJSON=function(){return {type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function tn(e,t,n){return t===0&&n===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,n))}function Ze(e,t,n){n=Math.min(e.length,n);let s=[],u=t;for(;u<n;){let l=e[u],h=null,S=l>239?4:l>223?3:l>191?2:1;if(u+S<=n){let P,_,E,k;switch(S){case 1:l<128&&(h=l);break;case 2:P=e[u+1],(P&192)===128&&(k=(l&31)<<6|P&63,k>127&&(h=k));break;case 3:P=e[u+1],_=e[u+2],(P&192)===128&&(_&192)===128&&(k=(l&15)<<12|(P&63)<<6|_&63,k>2047&&(k<55296||k>57343)&&(h=k));break;case 4:P=e[u+1],_=e[u+2],E=e[u+3],(P&192)===128&&(_&192)===128&&(E&192)===128&&(k=(l&15)<<18|(P&63)<<12|(_&63)<<6|E&63,k>65535&&k<1114112&&(h=k));}}h===null?(h=65533,S=1):h>65535&&(h-=65536,s.push(h>>>10&1023|55296),h=56320|h&1023),s.push(h),u+=S;}return nn(s)}let et=4096;function nn(e){let t=e.length;if(t<=et)return String.fromCharCode.apply(String,e);let n="",s=0;for(;s<t;)n+=String.fromCharCode.apply(String,e.slice(s,s+=et));return n}function rn(e,t,n){let s="";n=Math.min(e.length,n);for(let u=t;u<n;++u)s+=String.fromCharCode(e[u]&127);return s}function sn(e,t,n){let s="";n=Math.min(e.length,n);for(let u=t;u<n;++u)s+=String.fromCharCode(e[u]);return s}function on(e,t,n){let s=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>s)&&(n=s);let u="";for(let l=t;l<n;++l)u+=pn[e[l]];return u}function an(e,t,n){let s=e.slice(t,n),u="";for(let l=0;l<s.length-1;l+=2)u+=String.fromCharCode(s[l]+s[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 s=this.subarray(e,t);return Object.setPrototypeOf(s,a.prototype),s};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 s=this[e],u=1,l=0;for(;++l<t&&(u*=256);)s+=this[e+l]*u;return s},a.prototype.readUintBE=a.prototype.readUIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||O(e,t,this.length);let s=this[e+--t],u=1;for(;t>0&&(u*=256);)s+=this[e+--t]*u;return s},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=V(function(e){e=e>>>0,re(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&he(e,this.length-8);let s=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(s)+(BigInt(u)<<BigInt(32))}),a.prototype.readBigUInt64BE=V(function(e){e=e>>>0,re(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&he(e,this.length-8);let s=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(s)<<BigInt(32))+BigInt(u)}),a.prototype.readIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||O(e,t,this.length);let s=this[e],u=1,l=0;for(;++l<t&&(u*=256);)s+=this[e+l]*u;return u*=128,s>=u&&(s-=Math.pow(2,8*t)),s},a.prototype.readIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||O(e,t,this.length);let s=t,u=1,l=this[e+--s];for(;s>0&&(u*=256);)l+=this[e+--s]*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=V(function(e){e=e>>>0,re(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&he(e,this.length-8);let s=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return (BigInt(s)<<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,re(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&he(e,this.length-8);let s=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return (BigInt(s)<<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 $(e,t,n,s,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+s>e.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(e,t,n,s){if(e=+e,t=t>>>0,n=n>>>0,!s){let h=Math.pow(2,8*n)-1;$(this,e,t,n,h,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,s){if(e=+e,t=t>>>0,n=n>>>0,!s){let h=Math.pow(2,8*n)-1;$(this,e,t,n,h,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||$(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||$(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||$(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||$(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||$(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 tt(e,t,n,s,u){at(t,s,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 h=Number(t>>BigInt(32)&BigInt(4294967295));return e[n++]=h,h=h>>8,e[n++]=h,h=h>>8,e[n++]=h,h=h>>8,e[n++]=h,n}function nt(e,t,n,s,u){at(t,s,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 h=Number(t>>BigInt(32)&BigInt(4294967295));return e[n+3]=h,h=h>>8,e[n+2]=h,h=h>>8,e[n+1]=h,h=h>>8,e[n]=h,n+8}a.prototype.writeBigUInt64LE=V(function(e,t=0){return tt(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=V(function(e,t=0){return nt(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(e,t,n,s){if(e=+e,t=t>>>0,!s){let S=Math.pow(2,8*n-1);$(this,e,t,n,S-1,-S);}let u=0,l=1,h=0;for(this[t]=e&255;++u<n&&(l*=256);)e<0&&h===0&&this[t+u-1]!==0&&(h=1),this[t+u]=(e/l>>0)-h&255;return t+n},a.prototype.writeIntBE=function(e,t,n,s){if(e=+e,t=t>>>0,!s){let S=Math.pow(2,8*n-1);$(this,e,t,n,S-1,-S);}let u=n-1,l=1,h=0;for(this[t+u]=e&255;--u>=0&&(l*=256);)e<0&&h===0&&this[t+u+1]!==0&&(h=1),this[t+u]=(e/l>>0)-h&255;return t+n},a.prototype.writeInt8=function(e,t,n){return e=+e,t=t>>>0,n||$(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||$(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||$(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||$(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||$(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 tt(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=V(function(e,t=0){return nt(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function rt(e,t,n,s,u,l){if(n+s>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function it(e,t,n,s,u){return t=+t,n=n>>>0,u||rt(e,t,n,4),i.write(e,t,n,s,23,4),n+4}a.prototype.writeFloatLE=function(e,t,n){return it(this,e,t,!0,n)},a.prototype.writeFloatBE=function(e,t,n){return it(this,e,t,!1,n)};function st(e,t,n,s,u){return t=+t,n=n>>>0,u||rt(e,t,n,8),i.write(e,t,n,s,52,8),n+8}a.prototype.writeDoubleLE=function(e,t,n){return st(this,e,t,!0,n)},a.prototype.writeDoubleBE=function(e,t,n){return st(this,e,t,!1,n)},a.prototype.copy=function(e,t,n,s){if(!a.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!s&&s!==0&&(s=this.length),t>=e.length&&(t=e.length),t||(t=0),s>0&&s<n&&(s=n),s===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(s<0)throw new RangeError("sourceEnd out of bounds");s>this.length&&(s=this.length),e.length-t<s-n&&(s=e.length-t+n);let u=s-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,n,s):Uint8Array.prototype.set.call(e,this.subarray(n,s),t),u},a.prototype.fill=function(e,t,n,s){if(typeof e=="string"){if(typeof t=="string"?(s=t,t=0,n=this.length):typeof n=="string"&&(s=n,n=this.length),s!==void 0&&typeof s!="string")throw new TypeError("encoding must be a string");if(typeof s=="string"&&!a.isEncoding(s))throw new TypeError("Unknown encoding: "+s);if(e.length===1){let l=e.charCodeAt(0);(s==="utf8"&&l<128||s==="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,s),h=l.length;if(h===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(u=0;u<n-t;++u)this[u+t]=l[u%h];}return this};let ne={};function xe(e,t,n){ne[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(s){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:s,writable:!0});}toString(){return `${this.name} [${e}]: ${this.message}`}};}xe("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),xe("ERR_INVALID_ARG_TYPE",function(e,t){return `The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError),xe("ERR_OUT_OF_RANGE",function(e,t,n){let s=`The value of "${e}" is out of range.`,u=n;return Number.isInteger(n)&&Math.abs(n)>2**32?u=ot(String(n)):typeof n=="bigint"&&(u=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(u=ot(u)),u+="n"),s+=` It must be ${t}. Received ${u}`,s},RangeError);function ot(e){let t="",n=e.length,s=e[0]==="-"?1:0;for(;n>=s+4;n-=3)t=`_${e.slice(n-3,n)}${t}`;return `${e.slice(0,n)}${t}`}function un(e,t,n){re(t,"offset"),(e[t]===void 0||e[t+n]===void 0)&&he(t,e.length-(n+1));}function at(e,t,n,s,u,l){if(e>n||e<t){let h=typeof t=="bigint"?"n":"",S;throw t===0||t===BigInt(0)?S=`>= 0${h} and < 2${h} ** ${(l+1)*8}${h}`:S=`>= -(2${h} ** ${(l+1)*8-1}${h}) and < 2 ** ${(l+1)*8-1}${h}`,new ne.ERR_OUT_OF_RANGE("value",S,e)}un(s,u,l);}function re(e,t){if(typeof e!="number")throw new ne.ERR_INVALID_ARG_TYPE(t,"number",e)}function he(e,t,n){throw Math.floor(e)!==e?(re(e,n),new ne.ERR_OUT_OF_RANGE("offset","an integer",e)):t<0?new ne.ERR_BUFFER_OUT_OF_BOUNDS:new ne.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${t}`,e)}let ln=/[^+/0-9A-Za-z-_]/g;function fn(e){if(e=e.split("=")[0],e=e.trim().replace(ln,""),e.length<2)return "";for(;e.length%4!==0;)e=e+"=";return e}function Be(e,t){t=t||1/0;let n,s=e.length,u=null,l=[];for(let h=0;h<s;++h){if(n=e.charCodeAt(h),n>55295&&n<57344){if(!u){if(n>56319){(t-=3)>-1&&l.push(239,191,189);continue}else if(h+1===s){(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 hn(e){let t=[];for(let n=0;n<e.length;++n)t.push(e.charCodeAt(n)&255);return t}function cn(e,t){let n,s,u,l=[];for(let h=0;h<e.length&&!((t-=2)<0);++h)n=e.charCodeAt(h),s=n>>8,u=n%256,l.push(u),l.push(s);return l}function ut(e){return r.toByteArray(fn(e))}function me(e,t,n,s){let u;for(u=0;u<s&&!(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 Te(e){return e!==e}let pn=function(){let e="0123456789abcdef",t=new Array(256);for(let n=0;n<16;++n){let s=n*16;for(let u=0;u<16;++u)t[s+u]=e[n]+e[u];}return t}();function V(e){return typeof BigInt>"u"?dn:e}function dn(){throw new Error("BigInt not supported")}return Y}var ee=Yr();ee.Buffer;ee.SlowBuffer;ee.INSPECT_MAX_BYTES;ee.kMaxLength;var bt=ee.Buffer;ee.INSPECT_MAX_BYTES;ee.kMaxLength;var Jr={};Rn(Jr,{deleteItem:()=>ei,getItem:()=>Ce,setItem:()=>Ie});var be=()=>typeof window>"u",_t=()=>!be(),Xr="__IMX-",qe=()=>_t()&&window.localStorage,Qr=r=>{if(r!==null)try{return JSON.parse(r)}catch{return r}},Zr=r=>typeof r=="string"?r:JSON.stringify(r),Ve=r=>`${Xr}${r}`;function Ce(r){if(qe())return Qr(window.localStorage.getItem(Ve(r)))}var Ie=(r,i)=>qe()?(window.localStorage.setItem(Ve(r),Zr(i)),!0):!1,ei=r=>qe()?(window.localStorage.removeItem(Ve(r)),!0):!1,$e=0,ti=r=>{let i=parseInt(r,10)*1e3,o=new Date(i),f=new Date;return $e=o.getTime()-f.getTime(),$e},ni=()=>{let r=new Date().getTime()+$e;return new Date(r).toISOString()},ri=(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))(ri||{}),ii="https://api.immutable.com",si=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 At(r,i){let o=JSON.stringify(i),f={payload:si(o)},c=await fetch(`${ii}${r}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)});if(!c.ok){let p=await c.text().catch(()=>"");throw new Error(`Request failed (${c.status}): ${p||c.statusText}`)}return c.json()}var X,Q,oi=()=>{X=Ce("metrics-events")||[],Q=Ce("metrics-runtime")||{};};oi();var Z=(r,i)=>{Q={...Q,[r]:i},Ie("metrics-runtime",Q);},Me=r=>{if(Q[r]!==void 0)return Q[r]},ai=()=>Q,ui=()=>X,li=r=>{X.push(r),Ie("metrics-events",X);},fi=r=>{X=X.slice(r),Ie("metrics-events",X);},xt=r=>{let i=[];return Object.entries(r).forEach(([o,f])=>{(typeof o=="string"||typeof f=="string"||typeof f=="number"||typeof f=="boolean")&&i.push([o,f.toString()]);}),i},Pe="2.15.1-alpha.4",hi=()=>be()?"":window.location.ancestorOrigins&&window.location.ancestorOrigins.length>0?new URL(window.location.ancestorOrigins[0]).hostname:document.referrer?new URL(window.document.referrer).hostname:"",ci=()=>{if(be())return "";let r;try{window.self!==window.top&&(r=hi());}catch{}return r||(r=window.location.hostname),r},pi=()=>{if(Z("sdkVersion",Pe),be())return {browser:"nodejs",sdkVersion:Pe};let r=ci();return r&&Z("domain",r),{sdkVersion:Pe,browser:window.navigator.userAgent,domain:r,tz:Intl.DateTimeFormat().resolvedOptions().timeZone,screen:`${window.screen.width}x${window.screen.height}`}},De=!1,di=()=>De,gi=async()=>{De=!0;try{let r=xt(pi()),i=Me("rid"),o=Me("uid"),f=await At("/v1/sdk/initialise",{version:1,data:{runtimeDetails:r,runtimeId:i,uId:o}}),{runtimeId:c,sTime:p}=f;Z("rid",c),ti(p);}catch{De=!1;}};function D(r,i){return (...o)=>{try{let f=r(...o);return f instanceof Promise?f.catch(()=>i):f}catch{return i}}}function yi(){return _t()||typeof Le>"u"?!1:Le.env.JEST_WORKER_ID!==void 0}var mi=D(yi,!1),Bt="imtbl__metrics",wi=5e3,vi=1e3,pe=(r,i)=>(0, Fe.getGlobalisedValue)(Bt,r,i),bi=(r,i)=>{let o=ct(i,{lruOptions:{ttl:wi,max:vi}});return (0, Fe.getGlobalisedValue)(Bt,r,o)},Ii=5e3,Ei=(r,i,o)=>{let f={event:`${r}.${i}`,time:ni(),...o&&{properties:xt(o)}};li(f);},oe=D(bi("track",Ei)),Si=async()=>{if(di()===!1){await gi();return}let r=ui();if(r.length===0)return;let i=r.length,o=ai();await At("/v1/sdk/metrics",{version:1,data:{events:r,details:o}})instanceof Error||fi(i);},_i=D(Si),Tt=async()=>{await _i(),setTimeout(Tt,Ii);},It=!1,Ai=()=>{It||(It=!0,Tt());};mi()||D(pe("startFlushing",Ai))();var Pi=(r,i,o,f)=>{let{message:c}=o,p=o.stack||"",{cause:a}=o;a instanceof Error&&(p=`${p}
|
|
1
|
+
var gn=Object.create;var lt=Object.defineProperty;var yn=Object.getOwnPropertyDescriptor;var mn=Object.getOwnPropertyNames;var wn=Object.getPrototypeOf,vn=Object.prototype.hasOwnProperty;var ft=(r,i)=>()=>(r&&(i=r(r=0)),i);var bn=(r,i)=>()=>(i||r((i={exports:{}}).exports,i),i.exports);var In=(r,i,o,f)=>{if(i&&typeof i=="object"||typeof i=="function")for(let c of mn(i))!vn.call(r,c)&&c!==o&<(r,c,{get:()=>i[c],enumerable:!(f=yn(i,c))||f.enumerable});return r};var En=(r,i,o)=>(o=r!=null?gn(wn(r)):{},In(lt(o,"default",{value:r,enumerable:!0}),r));var B=ft(()=>{});var T=ft(()=>{});var yt=bn(ie=>{T();B();Object.defineProperty(ie,"__esModule",{value:!0});ie.clearGlobalNamespace=ie.getGlobalisedValue=void 0;var An="globalise__singleton__",xn={},pt=()=>typeof window<"u"?window:typeof globalThis<"u"?globalThis:xn,Bn=(r,i)=>{if(typeof r!="string")throw "Invalid namespace key";if(typeof i!="string")throw "Invalid item key"},dt=r=>`${An}${r}`,gt=r=>{let i=pt(),o=dt(r);return i[o]||(i[o]={}),i[o]},Tn=(r,i)=>gt(r)[i]||void 0,Un=(r,i,o)=>{let f=gt(r);f[i]=o;},kn=(r,i,o)=>{Bn(r,i);let f=Tn(r,i);return f!==void 0?f:(Un(r,i,o),o)};ie.getGlobalisedValue=kn;var On=r=>{let i=pt(),o=dt(r);i[o]!==void 0&&delete i[o];};ie.clearGlobalNamespace=On;});T();B();T();B();T();B();T();B();T();B();T();B();var Ue=class{constructor(i=0,o=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=o;}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(i){if(this.has(i)){let o=this.items[i];delete this.items[i],this.size--,o.prev!==null&&(o.prev.next=o.next),o.next!==null&&(o.next.prev=o.prev),this.first===o&&(this.first=o.next),this.last===o&&(this.last=o.prev);}return this}entries(i=this.keys()){return i.map(o=>[o,this.get(o)])}evict(i=!1){if(i||this.size>0){let o=this.first;delete this.items[o.key],--this.size===0?(this.first=null,this.last=null):(this.first=o.next,this.first.prev=null);}return this}expiresAt(i){let o;return this.has(i)&&(o=this.items[i].expiry),o}get(i){let o;if(this.has(i)){let f=this.items[i];this.ttl>0&&f.expiry<=Date.now()?this.delete(i):(o=f.value,this.set(i,o,!0));}return o}has(i){return i in this.items}keys(){let i=[],o=this.first;for(;o!==null;)i.push(o.key),o=o.next;return i}set(i,o,f=!1,c=this.resetTtl){let p;if(f||this.has(i)){if(p=this.items[i],p.value=o,f===!1&&c&&(p.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.last!==p){let a=this.last,y=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=y),y!==null&&(y.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:o},++this.size===1?this.first=p:this.last.next=p;return this.last=p,this}values(i=this.keys()){return i.map(o=>this.get(o))}};function ht(r=1e3,i=0,o=!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 o!="boolean")throw new TypeError("Invalid resetTtl value");return new Ue(r,i,o)}var Sn={max:1e3},ct=(r,i={})=>{let{cache:o,cacheKeyResolver:f=ke,onHit:c,lruOptions:p={}}=i,a={...Sn,...p},y=o||ht(a.max,a.ttl);function m(...x){let v=f(...x),w=y.get(v);if(y.has(v))return c&&c(v,w,y),w;let d=r.apply(this,x);return y.set(v,d),d}return m._cache=y,m},ke=(...r)=>r.length===0?"no-args":r.map(i=>i===void 0?"undefined":i===null?"null":Array.isArray(i)?`[${ke(...i)}]`:typeof i=="object"?`{${ke(..._n(i))}}`:JSON.stringify(i)).join(","),_n=r=>Object.entries(r).sort((i,o)=>i[0]<o[0]?-1:1);var Fe=En(yt()),Pn=Object.defineProperty,Rn=(r,i)=>{for(var o in i)Pn(r,o,{get:i[o],enumerable:!0});};function je(r){throw new Error("Node.js process "+r+" is not supported by JSPM core outside of Node.js")}var q=[],se=!1,J,ve=-1;function Nn(){!se||!J||(se=!1,J.length?q=J.concat(q):ve=-1,q.length&&Et());}function Et(){if(!se){var r=setTimeout(Nn,0);se=!0;for(var i=q.length;i;){for(J=q,q=[];++ve<i;)J&&J[ve].run();ve=-1,i=q.length;}J=null,se=!1,clearTimeout(r);}}function Ln(r){var i=new Array(arguments.length-1);if(arguments.length>1)for(var o=1;o<arguments.length;o++)i[o-1]=arguments[o];q.push(new St(r,i)),q.length===1&&!se&&setTimeout(Et,0);}function St(r,i){this.fun=r,this.array=i;}St.prototype.run=function(){this.fun.apply(null,this.array);};var Cn="browser",$n="x64",Mn="browser",Dn={PATH:"/usr/bin",LANG:navigator.language+".UTF-8",PWD:"/",HOME:"/home",TMP:"/tmp"},Fn=["/usr/bin/node"],jn=[],Gn="v16.8.0",qn={},Vn=function(r,i){console.warn((i?i+": ":"")+r);},Kn=function(r){je("binding");},zn=function(r){return 0},Wn=function(){return "/"},Hn=function(r){},Yn={name:"node",sourceUrl:"",headersUrl:"",libUrl:""};function N(){}var Jn=N,Xn=[];function Qn(r){je("_linkedBinding");}var Zn={},er=!1,tr={};function nr(r){je("dlopen");}function rr(){return []}function ir(){return []}var sr=N,or=N,Ge=function(){return {}},ar=Ge,ur=Ge,lr=N,fr=N,hr=N,cr={};function pr(r,i){if(!r)throw new Error(i||"assertion error")}var dr={inspector:!1,debug:!1,uv:!1,ipv6:!1,tls_alpn:!1,tls_sni:!1,tls_ocsp:!1,tls:!1,cached_builtins:!0},gr=N,yr=N;function mr(){return !1}var wr=N,vr=N,br=N,Ir=N,Er=N,Sr=void 0,_r=void 0,Ar=void 0,xr=N,Br=2,Tr=1,Ur="/bin/usr/node",kr=9229,Or="node",Pr=[],Rr=N,K={now:typeof performance<"u"?performance.now.bind(performance):void 0,timing:typeof performance<"u"?performance.timing:void 0};K.now===void 0&&(Oe=Date.now(),K.timing&&K.timing.navigationStart&&(Oe=K.timing.navigationStart),K.now=()=>Date.now()-Oe);var Oe;function Nr(){return K.now()/1e3}var Re=1e9;function Ne(r){var i=Math.floor((Date.now()-K.now())*.001),o=K.now()*.001,f=Math.floor(o)+i,c=Math.floor(o%1*1e9);return r&&(f=f-r[0],c=c-r[1],c<0&&(f--,c+=Re)),[f,c]}Ne.bigint=function(r){var i=Ne(r);return typeof BigInt>"u"?i[0]*Re+i[1]:BigInt(i[0]*Re)+BigInt(i[1])};var Lr=10,Cr={},$r=0;function z(){return Le}var Mr=z,Dr=z,Fr=z,jr=z,Gr=z,qr=N,Vr=z,Kr=z;function zr(r){return []}var Le={version:Gn,versions:qn,arch:$n,platform:Mn,release:Yn,_rawDebug:Jn,moduleLoadList:Xn,binding:Kn,_linkedBinding:Qn,_events:Cr,_eventsCount:$r,_maxListeners:Lr,on:z,addListener:Mr,once:Dr,off:Fr,removeListener:jr,removeAllListeners:Gr,emit:qr,prependListener:Vr,prependOnceListener:Kr,listeners:zr,domain:Zn,_exiting:er,config:tr,dlopen:nr,uptime:Nr,_getActiveRequests:rr,_getActiveHandles:ir,reallyExit:sr,_kill:or,cpuUsage:Ge,resourceUsage:ar,memoryUsage:ur,kill:lr,exit:fr,openStdin:hr,allowedNodeEnvironmentFlags:cr,assert:pr,features:dr,_fatalExceptions:gr,setUncaughtExceptionCaptureCallback:yr,hasUncaughtExceptionCaptureCallback:mr,emitWarning:Vn,nextTick:Ln,_tickCallback:wr,_debugProcess:vr,_debugEnd:br,_startProfilerIdleNotifier:Ir,_stopProfilerIdleNotifier:Er,stdout:Sr,stdin:Ar,stderr:_r,abort:xr,umask:zn,chdir:Hn,cwd:Wn,env:Dn,title:Cn,argv:Fn,execArgv:jn,pid:Br,ppid:Tr,execPath:Ur,debugPort:kr,hrtime:Ne,argv0:Or,_preload_modules:Pr,setSourceMapsEnabled:Rr},ce={},mt=!1;function Wr(){if(mt)return ce;mt=!0,ce.byteLength=y,ce.toByteArray=x,ce.fromByteArray=b;for(var r=[],i=[],o=typeof Uint8Array<"u"?Uint8Array:Array,f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=0,p=f.length;c<p;++c)r[c]=f[c],i[f.charCodeAt(c)]=c;i[45]=62,i[95]=63;function a(d){var g=d.length;if(g%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var I=d.indexOf("=");I===-1&&(I=g);var A=I===g?0:4-I%4;return [I,A]}function y(d){var g=a(d),I=g[0],A=g[1];return (I+A)*3/4-A}function m(d,g,I){return (g+I)*3/4-I}function x(d){var g,I=a(d),A=I[0],R=I[1],U=new o(m(d,A,R)),C=0,M=R>0?A-4:A,L;for(L=0;L<M;L+=4)g=i[d.charCodeAt(L)]<<18|i[d.charCodeAt(L+1)]<<12|i[d.charCodeAt(L+2)]<<6|i[d.charCodeAt(L+3)],U[C++]=g>>16&255,U[C++]=g>>8&255,U[C++]=g&255;return R===2&&(g=i[d.charCodeAt(L)]<<2|i[d.charCodeAt(L+1)]>>4,U[C++]=g&255),R===1&&(g=i[d.charCodeAt(L)]<<10|i[d.charCodeAt(L+1)]<<4|i[d.charCodeAt(L+2)]>>2,U[C++]=g>>8&255,U[C++]=g&255),U}function v(d){return r[d>>18&63]+r[d>>12&63]+r[d>>6&63]+r[d&63]}function w(d,g,I){for(var A,R=[],U=g;U<I;U+=3)A=(d[U]<<16&16711680)+(d[U+1]<<8&65280)+(d[U+2]&255),R.push(v(A));return R.join("")}function b(d){for(var g,I=d.length,A=I%3,R=[],U=16383,C=0,M=I-A;C<M;C+=U)R.push(w(d,C,C+U>M?M:C+U));return A===1?(g=d[I-1],R.push(r[g>>2]+r[g<<4&63]+"==")):A===2&&(g=(d[I-2]<<8)+d[I-1],R.push(r[g>>10]+r[g>>4&63]+r[g<<2&63]+"=")),R.join("")}return ce}var we={},wt=!1;function Hr(){return wt?we:(wt=!0,we.read=function(r,i,o,f,c){var p,a,y=c*8-f-1,m=(1<<y)-1,x=m>>1,v=-7,w=o?c-1:0,b=o?-1:1,d=r[i+w];for(w+=b,p=d&(1<<-v)-1,d>>=-v,v+=y;v>0;p=p*256+r[i+w],w+=b,v-=8);for(a=p&(1<<-v)-1,p>>=-v,v+=f;v>0;a=a*256+r[i+w],w+=b,v-=8);if(p===0)p=1-x;else {if(p===m)return a?NaN:(d?-1:1)*(1/0);a=a+Math.pow(2,f),p=p-x;}return (d?-1:1)*a*Math.pow(2,p-f)},we.write=function(r,i,o,f,c,p){var a,y,m,x=p*8-c-1,v=(1<<x)-1,w=v>>1,b=c===23?Math.pow(2,-24)-Math.pow(2,-77):0,d=f?0:p-1,g=f?1:-1,I=i<0||i===0&&1/i<0?1:0;for(i=Math.abs(i),isNaN(i)||i===1/0?(y=isNaN(i)?1:0,a=v):(a=Math.floor(Math.log(i)/Math.LN2),i*(m=Math.pow(2,-a))<1&&(a--,m*=2),a+w>=1?i+=b/m:i+=b*Math.pow(2,1-w),i*m>=2&&(a++,m/=2),a+w>=v?(y=0,a=v):a+w>=1?(y=(i*m-1)*Math.pow(2,c),a=a+w):(y=i*Math.pow(2,w-1)*Math.pow(2,c),a=0));c>=8;r[o+d]=y&255,d+=g,y/=256,c-=8);for(a=a<<c|y,x+=c;x>0;r[o+d]=a&255,d+=g,a/=256,x-=8);r[o+d-g]|=I*128;},we)}var Y={},vt=!1;function Yr(){if(vt)return Y;vt=!0;let r=Wr(),i=Hr(),o=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;Y.Buffer=a,Y.SlowBuffer=R,Y.INSPECT_MAX_BYTES=50;let f=2147483647;Y.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{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 v(e)}return y(e,t,n)}a.poolSize=8192;function y(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(F(e,ArrayBuffer)||e&&F(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(F(e,SharedArrayBuffer)||e&&F(e.buffer,SharedArrayBuffer)))return g(e,t,n);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let s=e.valueOf&&e.valueOf();if(s!=null&&s!==e)return a.from(s,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 y(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 x(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 x(e,t,n)};function v(e){return m(e),p(e<0?0:A(e)|0)}a.allocUnsafe=function(e){return v(e)},a.allocUnsafeSlow=function(e){return v(e)};function w(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!a.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let n=U(e,t)|0,s=p(n),u=s.write(e,t);return u!==n&&(s=s.slice(0,u)),s}function b(e){let t=e.length<0?0:A(e.length)|0,n=p(t);for(let s=0;s<t;s+=1)n[s]=e[s]&255;return n}function d(e){if(F(e,Uint8Array)){let t=new Uint8Array(e);return g(t.buffer,t.byteOffset,t.byteLength)}return b(e)}function g(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 s;return t===void 0&&n===void 0?s=new Uint8Array(e):n===void 0?s=new Uint8Array(e,t):s=new Uint8Array(e,t,n),Object.setPrototypeOf(s,a.prototype),s}function I(e){if(a.isBuffer(e)){let t=A(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"||Te(e.length)?p(0):b(e);if(e.type==="Buffer"&&Array.isArray(e.data))return b(e.data)}function A(e){if(e>=f)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+f.toString(16)+" bytes");return e|0}function R(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,s=t.length;for(let u=0,l=Math.min(n,s);u<l;++u)if(e[u]!==t[u]){n=e[u],s=t[u];break}return n<s?-1:s<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 s=a.allocUnsafe(t),u=0;for(n=0;n<e.length;++n){let l=e[n];if(F(l,Uint8Array))u+l.length>s.length?(a.isBuffer(l)||(l=a.from(l)),l.copy(s,u)):Uint8Array.prototype.set.call(s,l,u);else if(a.isBuffer(l))l.copy(s,u);else throw new TypeError('"list" argument must be an Array of Buffers');u+=l.length;}return s};function U(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,s=arguments.length>2&&arguments[2]===!0;if(!s&&n===0)return 0;let u=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return Be(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return n*2;case"hex":return n>>>1;case"base64":return ut(e).length;default:if(u)return s?-1:Be(e).length;t=(""+t).toLowerCase(),u=!0;}}a.byteLength=U;function C(e,t,n){let s=!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 on(this,t,n);case"utf8":case"utf-8":return Ze(this,t,n);case"ascii":return rn(this,t,n);case"latin1":case"binary":return sn(this,t,n);case"base64":return tn(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return an(this,t,n);default:if(s)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),s=!0;}}a.prototype._isBuffer=!0;function M(e,t,n){let s=e[t];e[t]=e[n],e[n]=s;}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?Ze(this,0,e):C.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=Y.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"},o&&(a.prototype[o]=a.prototype.inspect),a.prototype.compare=function(e,t,n,s,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),s===void 0&&(s=0),u===void 0&&(u=this.length),t<0||n>e.length||s<0||u>this.length)throw new RangeError("out of range index");if(s>=u&&t>=n)return 0;if(s>=u)return -1;if(t>=n)return 1;if(t>>>=0,n>>>=0,s>>>=0,u>>>=0,this===e)return 0;let l=u-s,h=n-t,S=Math.min(l,h),P=this.slice(s,u),_=e.slice(t,n);for(let E=0;E<S;++E)if(P[E]!==_[E]){l=P[E],h=_[E];break}return l<h?-1:h<l?1:0};function L(e,t,n,s,u){if(e.length===0)return -1;if(typeof n=="string"?(s=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,Te(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,s)),a.isBuffer(t))return t.length===0?-1:Qe(e,t,n,s,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):Qe(e,[t],n,s,u);throw new TypeError("val must be string, number or Buffer")}function Qe(e,t,n,s,u){let l=1,h=e.length,S=t.length;if(s!==void 0&&(s=String(s).toLowerCase(),s==="ucs2"||s==="ucs-2"||s==="utf16le"||s==="utf-16le")){if(e.length<2||t.length<2)return -1;l=2,h/=2,S/=2,n/=2;}function P(E,k){return l===1?E[k]:E.readUInt16BE(k*l)}let _;if(u){let E=-1;for(_=n;_<h;_++)if(P(e,_)===P(t,E===-1?0:_-E)){if(E===-1&&(E=_),_-E+1===S)return E*l}else E!==-1&&(_-=_-E),E=-1;}else for(n+S>h&&(n=h-S),_=n;_>=0;_--){let E=!0;for(let k=0;k<S;k++)if(P(e,_+k)!==P(t,k)){E=!1;break}if(E)return _}return -1}a.prototype.includes=function(e,t,n){return this.indexOf(e,t,n)!==-1},a.prototype.indexOf=function(e,t,n){return L(this,e,t,n,!0)},a.prototype.lastIndexOf=function(e,t,n){return L(this,e,t,n,!1)};function Jt(e,t,n,s){n=Number(n)||0;let u=e.length-n;s?(s=Number(s),s>u&&(s=u)):s=u;let l=t.length;s>l/2&&(s=l/2);let h;for(h=0;h<s;++h){let S=parseInt(t.substr(h*2,2),16);if(Te(S))return h;e[n+h]=S;}return h}function Xt(e,t,n,s){return me(Be(t,e.length-n),e,n,s)}function Qt(e,t,n,s){return me(hn(t),e,n,s)}function Zt(e,t,n,s){return me(ut(t),e,n,s)}function en(e,t,n,s){return me(cn(t,e.length-n),e,n,s)}a.prototype.write=function(e,t,n,s){if(t===void 0)s="utf8",n=this.length,t=0;else if(n===void 0&&typeof t=="string")s=t,n=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(n)?(n=n>>>0,s===void 0&&(s="utf8")):(s=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");s||(s="utf8");let l=!1;for(;;)switch(s){case"hex":return Jt(this,e,t,n);case"utf8":case"utf-8":return Xt(this,e,t,n);case"ascii":case"latin1":case"binary":return Qt(this,e,t,n);case"base64":return Zt(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return en(this,e,t,n);default:if(l)throw new TypeError("Unknown encoding: "+s);s=(""+s).toLowerCase(),l=!0;}},a.prototype.toJSON=function(){return {type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function tn(e,t,n){return t===0&&n===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,n))}function Ze(e,t,n){n=Math.min(e.length,n);let s=[],u=t;for(;u<n;){let l=e[u],h=null,S=l>239?4:l>223?3:l>191?2:1;if(u+S<=n){let P,_,E,k;switch(S){case 1:l<128&&(h=l);break;case 2:P=e[u+1],(P&192)===128&&(k=(l&31)<<6|P&63,k>127&&(h=k));break;case 3:P=e[u+1],_=e[u+2],(P&192)===128&&(_&192)===128&&(k=(l&15)<<12|(P&63)<<6|_&63,k>2047&&(k<55296||k>57343)&&(h=k));break;case 4:P=e[u+1],_=e[u+2],E=e[u+3],(P&192)===128&&(_&192)===128&&(E&192)===128&&(k=(l&15)<<18|(P&63)<<12|(_&63)<<6|E&63,k>65535&&k<1114112&&(h=k));}}h===null?(h=65533,S=1):h>65535&&(h-=65536,s.push(h>>>10&1023|55296),h=56320|h&1023),s.push(h),u+=S;}return nn(s)}let et=4096;function nn(e){let t=e.length;if(t<=et)return String.fromCharCode.apply(String,e);let n="",s=0;for(;s<t;)n+=String.fromCharCode.apply(String,e.slice(s,s+=et));return n}function rn(e,t,n){let s="";n=Math.min(e.length,n);for(let u=t;u<n;++u)s+=String.fromCharCode(e[u]&127);return s}function sn(e,t,n){let s="";n=Math.min(e.length,n);for(let u=t;u<n;++u)s+=String.fromCharCode(e[u]);return s}function on(e,t,n){let s=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>s)&&(n=s);let u="";for(let l=t;l<n;++l)u+=pn[e[l]];return u}function an(e,t,n){let s=e.slice(t,n),u="";for(let l=0;l<s.length-1;l+=2)u+=String.fromCharCode(s[l]+s[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 s=this.subarray(e,t);return Object.setPrototypeOf(s,a.prototype),s};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 s=this[e],u=1,l=0;for(;++l<t&&(u*=256);)s+=this[e+l]*u;return s},a.prototype.readUintBE=a.prototype.readUIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||O(e,t,this.length);let s=this[e+--t],u=1;for(;t>0&&(u*=256);)s+=this[e+--t]*u;return s},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=V(function(e){e=e>>>0,re(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&he(e,this.length-8);let s=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(s)+(BigInt(u)<<BigInt(32))}),a.prototype.readBigUInt64BE=V(function(e){e=e>>>0,re(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&he(e,this.length-8);let s=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(s)<<BigInt(32))+BigInt(u)}),a.prototype.readIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||O(e,t,this.length);let s=this[e],u=1,l=0;for(;++l<t&&(u*=256);)s+=this[e+l]*u;return u*=128,s>=u&&(s-=Math.pow(2,8*t)),s},a.prototype.readIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||O(e,t,this.length);let s=t,u=1,l=this[e+--s];for(;s>0&&(u*=256);)l+=this[e+--s]*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=V(function(e){e=e>>>0,re(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&he(e,this.length-8);let s=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return (BigInt(s)<<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,re(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&he(e,this.length-8);let s=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return (BigInt(s)<<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 $(e,t,n,s,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+s>e.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(e,t,n,s){if(e=+e,t=t>>>0,n=n>>>0,!s){let h=Math.pow(2,8*n)-1;$(this,e,t,n,h,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,s){if(e=+e,t=t>>>0,n=n>>>0,!s){let h=Math.pow(2,8*n)-1;$(this,e,t,n,h,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||$(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||$(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||$(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||$(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||$(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 tt(e,t,n,s,u){at(t,s,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 h=Number(t>>BigInt(32)&BigInt(4294967295));return e[n++]=h,h=h>>8,e[n++]=h,h=h>>8,e[n++]=h,h=h>>8,e[n++]=h,n}function nt(e,t,n,s,u){at(t,s,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 h=Number(t>>BigInt(32)&BigInt(4294967295));return e[n+3]=h,h=h>>8,e[n+2]=h,h=h>>8,e[n+1]=h,h=h>>8,e[n]=h,n+8}a.prototype.writeBigUInt64LE=V(function(e,t=0){return tt(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=V(function(e,t=0){return nt(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(e,t,n,s){if(e=+e,t=t>>>0,!s){let S=Math.pow(2,8*n-1);$(this,e,t,n,S-1,-S);}let u=0,l=1,h=0;for(this[t]=e&255;++u<n&&(l*=256);)e<0&&h===0&&this[t+u-1]!==0&&(h=1),this[t+u]=(e/l>>0)-h&255;return t+n},a.prototype.writeIntBE=function(e,t,n,s){if(e=+e,t=t>>>0,!s){let S=Math.pow(2,8*n-1);$(this,e,t,n,S-1,-S);}let u=n-1,l=1,h=0;for(this[t+u]=e&255;--u>=0&&(l*=256);)e<0&&h===0&&this[t+u+1]!==0&&(h=1),this[t+u]=(e/l>>0)-h&255;return t+n},a.prototype.writeInt8=function(e,t,n){return e=+e,t=t>>>0,n||$(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||$(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||$(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||$(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||$(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 tt(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=V(function(e,t=0){return nt(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function rt(e,t,n,s,u,l){if(n+s>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function it(e,t,n,s,u){return t=+t,n=n>>>0,u||rt(e,t,n,4),i.write(e,t,n,s,23,4),n+4}a.prototype.writeFloatLE=function(e,t,n){return it(this,e,t,!0,n)},a.prototype.writeFloatBE=function(e,t,n){return it(this,e,t,!1,n)};function st(e,t,n,s,u){return t=+t,n=n>>>0,u||rt(e,t,n,8),i.write(e,t,n,s,52,8),n+8}a.prototype.writeDoubleLE=function(e,t,n){return st(this,e,t,!0,n)},a.prototype.writeDoubleBE=function(e,t,n){return st(this,e,t,!1,n)},a.prototype.copy=function(e,t,n,s){if(!a.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!s&&s!==0&&(s=this.length),t>=e.length&&(t=e.length),t||(t=0),s>0&&s<n&&(s=n),s===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(s<0)throw new RangeError("sourceEnd out of bounds");s>this.length&&(s=this.length),e.length-t<s-n&&(s=e.length-t+n);let u=s-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,n,s):Uint8Array.prototype.set.call(e,this.subarray(n,s),t),u},a.prototype.fill=function(e,t,n,s){if(typeof e=="string"){if(typeof t=="string"?(s=t,t=0,n=this.length):typeof n=="string"&&(s=n,n=this.length),s!==void 0&&typeof s!="string")throw new TypeError("encoding must be a string");if(typeof s=="string"&&!a.isEncoding(s))throw new TypeError("Unknown encoding: "+s);if(e.length===1){let l=e.charCodeAt(0);(s==="utf8"&&l<128||s==="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,s),h=l.length;if(h===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(u=0;u<n-t;++u)this[u+t]=l[u%h];}return this};let ne={};function xe(e,t,n){ne[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(s){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:s,writable:!0});}toString(){return `${this.name} [${e}]: ${this.message}`}};}xe("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),xe("ERR_INVALID_ARG_TYPE",function(e,t){return `The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError),xe("ERR_OUT_OF_RANGE",function(e,t,n){let s=`The value of "${e}" is out of range.`,u=n;return Number.isInteger(n)&&Math.abs(n)>2**32?u=ot(String(n)):typeof n=="bigint"&&(u=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(u=ot(u)),u+="n"),s+=` It must be ${t}. Received ${u}`,s},RangeError);function ot(e){let t="",n=e.length,s=e[0]==="-"?1:0;for(;n>=s+4;n-=3)t=`_${e.slice(n-3,n)}${t}`;return `${e.slice(0,n)}${t}`}function un(e,t,n){re(t,"offset"),(e[t]===void 0||e[t+n]===void 0)&&he(t,e.length-(n+1));}function at(e,t,n,s,u,l){if(e>n||e<t){let h=typeof t=="bigint"?"n":"",S;throw t===0||t===BigInt(0)?S=`>= 0${h} and < 2${h} ** ${(l+1)*8}${h}`:S=`>= -(2${h} ** ${(l+1)*8-1}${h}) and < 2 ** ${(l+1)*8-1}${h}`,new ne.ERR_OUT_OF_RANGE("value",S,e)}un(s,u,l);}function re(e,t){if(typeof e!="number")throw new ne.ERR_INVALID_ARG_TYPE(t,"number",e)}function he(e,t,n){throw Math.floor(e)!==e?(re(e,n),new ne.ERR_OUT_OF_RANGE("offset","an integer",e)):t<0?new ne.ERR_BUFFER_OUT_OF_BOUNDS:new ne.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${t}`,e)}let ln=/[^+/0-9A-Za-z-_]/g;function fn(e){if(e=e.split("=")[0],e=e.trim().replace(ln,""),e.length<2)return "";for(;e.length%4!==0;)e=e+"=";return e}function Be(e,t){t=t||1/0;let n,s=e.length,u=null,l=[];for(let h=0;h<s;++h){if(n=e.charCodeAt(h),n>55295&&n<57344){if(!u){if(n>56319){(t-=3)>-1&&l.push(239,191,189);continue}else if(h+1===s){(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 hn(e){let t=[];for(let n=0;n<e.length;++n)t.push(e.charCodeAt(n)&255);return t}function cn(e,t){let n,s,u,l=[];for(let h=0;h<e.length&&!((t-=2)<0);++h)n=e.charCodeAt(h),s=n>>8,u=n%256,l.push(u),l.push(s);return l}function ut(e){return r.toByteArray(fn(e))}function me(e,t,n,s){let u;for(u=0;u<s&&!(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 Te(e){return e!==e}let pn=function(){let e="0123456789abcdef",t=new Array(256);for(let n=0;n<16;++n){let s=n*16;for(let u=0;u<16;++u)t[s+u]=e[n]+e[u];}return t}();function V(e){return typeof BigInt>"u"?dn:e}function dn(){throw new Error("BigInt not supported")}return Y}var ee=Yr();ee.Buffer;ee.SlowBuffer;ee.INSPECT_MAX_BYTES;ee.kMaxLength;var bt=ee.Buffer;ee.INSPECT_MAX_BYTES;ee.kMaxLength;var Jr={};Rn(Jr,{deleteItem:()=>ei,getItem:()=>Ce,setItem:()=>Ie});var be=()=>typeof window>"u",_t=()=>!be(),Xr="__IMX-",qe=()=>_t()&&window.localStorage,Qr=r=>{if(r!==null)try{return JSON.parse(r)}catch{return r}},Zr=r=>typeof r=="string"?r:JSON.stringify(r),Ve=r=>`${Xr}${r}`;function Ce(r){if(qe())return Qr(window.localStorage.getItem(Ve(r)))}var Ie=(r,i)=>qe()?(window.localStorage.setItem(Ve(r),Zr(i)),!0):!1,ei=r=>qe()?(window.localStorage.removeItem(Ve(r)),!0):!1,$e=0,ti=r=>{let i=parseInt(r,10)*1e3,o=new Date(i),f=new Date;return $e=o.getTime()-f.getTime(),$e},ni=()=>{let r=new Date().getTime()+$e;return new Date(r).toISOString()},ri=(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))(ri||{}),ii="https://api.immutable.com",si=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 At(r,i){let o=JSON.stringify(i),f={payload:si(o)},c=await fetch(`${ii}${r}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)});if(!c.ok){let p=await c.text().catch(()=>"");throw new Error(`Request failed (${c.status}): ${p||c.statusText}`)}return c.json()}var X,Q,oi=()=>{X=Ce("metrics-events")||[],Q=Ce("metrics-runtime")||{};};oi();var Z=(r,i)=>{Q={...Q,[r]:i},Ie("metrics-runtime",Q);},Me=r=>{if(Q[r]!==void 0)return Q[r]},ai=()=>Q,ui=()=>X,li=r=>{X.push(r),Ie("metrics-events",X);},fi=r=>{X=X.slice(r),Ie("metrics-events",X);},xt=r=>{let i=[];return Object.entries(r).forEach(([o,f])=>{(typeof o=="string"||typeof f=="string"||typeof f=="number"||typeof f=="boolean")&&i.push([o,f.toString()]);}),i},Pe="2.15.1-alpha.5",hi=()=>be()?"":window.location.ancestorOrigins&&window.location.ancestorOrigins.length>0?new URL(window.location.ancestorOrigins[0]).hostname:document.referrer?new URL(window.document.referrer).hostname:"",ci=()=>{if(be())return "";let r;try{window.self!==window.top&&(r=hi());}catch{}return r||(r=window.location.hostname),r},pi=()=>{if(Z("sdkVersion",Pe),be())return {browser:"nodejs",sdkVersion:Pe};let r=ci();return r&&Z("domain",r),{sdkVersion:Pe,browser:window.navigator.userAgent,domain:r,tz:Intl.DateTimeFormat().resolvedOptions().timeZone,screen:`${window.screen.width}x${window.screen.height}`}},De=!1,di=()=>De,gi=async()=>{De=!0;try{let r=xt(pi()),i=Me("rid"),o=Me("uid"),f=await At("/v1/sdk/initialise",{version:1,data:{runtimeDetails:r,runtimeId:i,uId:o}}),{runtimeId:c,sTime:p}=f;Z("rid",c),ti(p);}catch{De=!1;}};function D(r,i){return (...o)=>{try{let f=r(...o);return f instanceof Promise?f.catch(()=>i):f}catch{return i}}}function yi(){return _t()||typeof Le>"u"?!1:Le.env.JEST_WORKER_ID!==void 0}var mi=D(yi,!1),Bt="imtbl__metrics",wi=5e3,vi=1e3,pe=(r,i)=>(0, Fe.getGlobalisedValue)(Bt,r,i),bi=(r,i)=>{let o=ct(i,{lruOptions:{ttl:wi,max:vi}});return (0, Fe.getGlobalisedValue)(Bt,r,o)},Ii=5e3,Ei=(r,i,o)=>{let f={event:`${r}.${i}`,time:ni(),...o&&{properties:xt(o)}};li(f);},oe=D(bi("track",Ei)),Si=async()=>{if(di()===!1){await gi();return}let r=ui();if(r.length===0)return;let i=r.length,o=ai();await At("/v1/sdk/metrics",{version:1,data:{events:r,details:o}})instanceof Error||fi(i);},_i=D(Si),Tt=async()=>{await _i(),setTimeout(Tt,Ii);},It=!1,Ai=()=>{It||(It=!0,Tt());};mi()||D(pe("startFlushing",Ai))();var Pi=(r,i,o,f)=>{let{message:c}=o,p=o.stack||"",{cause:a}=o;a instanceof Error&&(p=`${p}
|
|
2
2
|
Cause: ${a.message}
|
|
3
|
-
${a.stack}`),oe(r,`trackError_${i}`,{...f||{},errorMessage:c,errorStack:p,isTrackError:!0});},Ut=D(Pi),Li=r=>{Z("env",r);};D(pe("setEnvironment",Li));var Ci=r=>{Z("passportClientId",r);};D(pe("setPassportClientId",Ci));var $i=r=>{Z("pak",r);};D(pe("setPublishableApiKey",$i));D(pe("getDetail",Me));var Mi={Passport:"passport",Steam:"steam",Epic:"epic",Google:"google",Apple:"apple",Discord:"discord",Email:"email",Custom:"custom"},Di="pk_imapik-test-",Fi="/v1/audience/messages",ji="/v1/audience/tracking-consent",ue="imtbl_anon_id",ae="_imtbl_sid",Pt="session_start",Rt="session_end",Nt=r=>r.startsWith(Di)?"https://api.sandbox.immutable.com":"https://api.immutable.com",de=()=>typeof window<"u"&&typeof document<"u",le=()=>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)}),Lt=()=>new Date().toISOString();function Se(r){if(!de())return;let i=document.cookie.match(new RegExp(`(?:^|; )${r}=([^;]*)`));return i?decodeURIComponent(i[1]):void 0}function Ee(r,i,o,f){if(!de())return;let c=window.location.protocol==="https:"?"; Secure":"",p=f?`; domain=${f}`:"";document.cookie=`${r}=${encodeURIComponent(i)}; path=/; max-age=${o}; SameSite=Lax${p}${c}`;}function ge(r,i){Ee(r,"",0,i);}function _e(r){let i=Se(ue);if(i)return i;let o=le();return Ee(ue,o,63072e3,r),o}var Ke=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;}},ze=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 Ct(r,i,o){if(r.status===0)return new ze({code:"NETWORK_ERROR",message:i==="flush"?`Network error sending ${o??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,c=f?.rejected??0,p=f?.accepted??0;return new ze({code:"VALIDATION_REJECTED",message:`Backend rejected ${c} of ${c+p} messages`,status:r.status,endpoint:r.endpoint,responseBody:r.body})}return new ze({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 $t(r,i){if(r)try{r(i);}catch{}}async function kt(r){let i=r.headers?.get?.("content-type")??"";try{return i.includes("application/json")?await r.json():await r.text()}catch{return}}var He=async(r,i,o,f)=>{try{let c=await fetch(r,{method:f?.method??"POST",headers:{"Content-Type":"application/json","x-immutable-publishable-key":i},body:JSON.stringify(o),keepalive:f?.keepalive});if(!c.ok){let a=await kt(c);return oe("audience","transport_send_failed",{status:c.status}),{ok:!1,error:new Ke({status:c.status,endpoint:r,body:a})}}let p=await kt(c);if(typeof p=="object"&&p!==null&&"rejected"in p){let a=p.rejected??0;if(a>0)return oe("audience","transport_partial_rejected",{status:c.status,rejected:a}),{ok:!1,error:new Ke({status:c.status,endpoint:r,body:p})}}return {ok:!0}}catch(c){let p=new Ke({status:0,endpoint:r,cause:c});return Ut("audience","transport_send",p),{ok:!1,error:p}}},Ye="__imtbl_audience_";function Je(){try{return de()&&typeof localStorage<"u"}catch{return !1}}function Gi(r,i=Ye){if(Je())try{let o=localStorage.getItem(`${i}${r}`);return o?JSON.parse(o):void 0}catch{return}}function qi(r,i,o=Ye){if(Je())try{localStorage.setItem(`${o}${r}`,JSON.stringify(i));}catch{}}function Vi(r,i=Ye){if(Je())try{localStorage.removeItem(`${i}${r}`);}catch{}}var We="queue",Ot=100,Mt=class{constructor(r,i,o){this.send=r,this.publishableKey=i,this.endpointUrl=`${o?.baseUrl??Nt(i)}${Fi}`,this.flushIntervalMs=o?.flushIntervalMs??5e3,this.flushSize=o?.flushSize??20,this.onFlush=o?.onFlush,this.onError=o?.onError,this.storagePrefix=o?.storagePrefix;let f=Gi(We,this.storagePrefix)??[];this.messages=o?.staleFilter?f.filter(o.staleFilter):f;}messages;timer=null;flushing=!1;unloadBound=!1;visibilityHandler;pagehideHandler;onFlush;onError;storagePrefix;endpointUrl;flushIntervalMs;flushSize;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)){this.flushing=!0;try{let r=this.messages.slice(0,Ot),i={messages:r},o=await this.send(this.endpointUrl,this.publishableKey,i),f;!o.ok&&o.error&&(f=Ct(o.error,"flush",r.length));let c=f?.code==="VALIDATION_REJECTED";(o.ok||c)&&(this.messages=this.messages.slice(r.length),this.persist()),this.onFlush?.(o.ok,r.length),f&&$t(this.onError,f);}finally{this.flushing=!1;}}}flushUnload(){if(this.flushing||this.messages.length===0)return;let r=this.messages.slice(0,Ot),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=[],Vi(We,this.storagePrefix);}registerUnload(){!de()||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);}persist(){qi(We,this.messages,this.storagePrefix);}},Ki="2.15.1-alpha.4";function Dt(r="@imtbl/audience",i=Ki){let o={library:r,libraryVersion:i};return de()&&(o.userAgent=navigator.userAgent,o.locale=navigator.language,o.timezone=Intl.DateTimeFormat().resolvedOptions().timeZone,o.screen=`${window.screen.width}x${window.screen.height}`,o.pageUrl=window.location.href,o.pagePath=window.location.pathname,o.pageReferrer=document.referrer,o.pageTitle=document.title),o}function Ft(r){let i=new Date(r).getTime();if(Number.isNaN(i))return !1;let o=Date.now();return i<=o+864e5&&i>=o-2592e6}function jt(r,i,o,f){return r!==o||i!==f}function ye(r,i=256){return r.length>i?r.slice(0,i):r}function fe(r){let i=Se(ae);if(i)return Ee(ae,i,1800,r),{sessionId:i,isNew:!1};let o=le();return Ee(ae,o,1800,r),{sessionId:o,isNew:!0}}var Gt=["utm_source","utm_medium","utm_campaign","utm_content","utm_term"],qt=["gclid","dclid","fbclid","ttclid","msclkid","li_fat_id"],Vt="__imtbl_attribution";function zi(r){let i;try{i=new URL(r).searchParams;}catch{return {}}let o={};for(let c of [...Gt,...qt]){let p=i.get(c);p&&(o[c]=p);}let f=i.get("referral_code");return f&&(o.referral_code=f),o}function Wi(){try{let r=sessionStorage.getItem(Vt);return r?JSON.parse(r):null}catch{return null}}function Hi(r){try{sessionStorage.setItem(Vt,JSON.stringify(r));}catch{}}function Kt(){let r=Wi();if(r)return r;let i=typeof window<"u"&&window.location?zi(window.location.href):{},o=typeof document<"u"&&document.referrer||void 0,f=typeof window<"u"&&window.location?window.location.href:void 0,c=qt.some(y=>y in i),p=Gt.some(y=>y in i),a={...i,referrer:o,landing_page:f,touchpoint_type:c||p?"click":void 0};return Hi(a),a}function W(r){return r!=="none"}function te(r){return r==="full"}function zt(r,i,o,f,c,p,a,y){let m=p??"none",x={none:0,anonymous:1,full:2};function v(w){let b=`${y??Nt(o)}${ji}`;i(b,o,{anonymousId:f,status:w,source:c},{method:"PUT",keepalive:!0}).then(d=>{!d.ok&&d.error&&$t(a,Ct(d.error,"consent"));});}return {get level(){return m},setLevel(w){w!==m&&(x[w]<x[m]&&(w==="none"?r.purge(()=>!0):w==="anonymous"&&(r.purge(b=>b.type==="identify"||b.type==="alias"),r.transform(b=>{if("userId"in b){let{userId:d,...g}=b;return g}return b}))),m=w,v(w));}}}T();B();T();B();var Wt="@imtbl/audience",Ht="2.15.1-alpha.4",H="[audience]",Yt="WebSDK";var Ae=class{enabled;constructor(i=!1){this.enabled=i;}logEvent(i,o){this.enabled&&console.log(`${H} ${i}`,o);}logFlush(i,o){this.enabled&&console.log(`${H} flush ${i?"ok":"failed"} (${o} messages)`);}logConsent(i,o){this.enabled&&console.log(`${H} consent ${i} \u2192 ${o}`);}logWarning(i){this.enabled&&console.warn(`${H} ${i}`);}};var Xe=class r{static liveInstances=0;queue;consent;attribution;debug;cookieDomain;anonymousId;sessionId;sessionStartTime;userId;isFirstPage=!0;destroyed=!1;constructor(i){let{cookieDomain:o,publishableKey:f}=i,c=i.consent??"none",p=Yt;this.cookieDomain=o,this.debug=new Ae(i.debug??!1);let a=!1;W(c)?(this.anonymousId=_e(o),a=this.startSession()):this.anonymousId=Se(ue)??le(),this.queue=new Mt(He,f,{baseUrl:i.baseUrl,flushIntervalMs:i.flushInterval,flushSize:i.flushSize,onFlush:(y,m)=>this.debug.logFlush(y,m),staleFilter:y=>Ft(y.eventTimestamp),storagePrefix:"__imtbl_web_"}),this.consent=zt(this.queue,He,f,this.anonymousId,p,c,void 0,i.baseUrl),this.attribution=Kt(),this.isTrackingDisabled()||(this.queue.start(),a&&this.trackSessionStart());}static init(i){if(!i.publishableKey?.trim())throw new Error(`${H} publishableKey is required`);return r.liveInstances>0&&console.warn(`${H} Multiple SDK instances detected. Ensure previous instances are shut down to avoid duplicate events.`),r.liveInstances+=1,new r(i)}isTrackingDisabled(){return !W(this.consent.level)}effectiveUserId(){return te(this.consent.level)?this.userId:void 0}startSession(){let i=fe(this.cookieDomain);return this.sessionId=i.sessionId,this.sessionStartTime=Date.now(),i.isNew}baseMessage(){return {messageId:le(),eventTimestamp:Lt(),anonymousId:this.anonymousId,surface:"web",context:Dt(Wt,Ht)}}enqueue(i,o){this.queue.enqueue(o),this.debug.logEvent(i,o);}trackSessionStart(){this.sessionId&&this.enqueue("track(session_start)",{...this.baseMessage(),type:"track",eventName:Pt,properties:{sessionId:this.sessionId,...this.attribution}});}trackSessionEnd(){this.sessionId&&this.enqueue("track(session_end)",{...this.baseMessage(),type:"track",eventName:Rt,properties:{sessionId:this.sessionId,...this.sessionStartTime&&{duration:Math.round((Date.now()-this.sessionStartTime)/1e3)}}});}page(i){if(this.isTrackingDisabled())return;fe(this.cookieDomain);let o={...i};this.isFirstPage&&(Object.assign(o,this.attribution),this.isFirstPage=!1),this.enqueue("page",{...this.baseMessage(),type:"page",properties:Object.keys(o).length>0?o:void 0,userId:this.effectiveUserId()});}track(i,...o){if(this.isTrackingDisabled())return;fe(this.cookieDomain);let[f]=o;this.enqueue("track",{...this.baseMessage(),type:"track",eventName:ye(i),properties:f,userId:this.effectiveUserId()});}identify(i,o,f){if(!te(this.consent.level)){this.debug.logWarning("identify() requires full consent \u2014 call ignored.");return}if(fe(this.cookieDomain),i!==null&&typeof i=="object"&&!Array.isArray(i)){this.enqueue("identify",{...this.baseMessage(),type:"identify",traits:i});return}if(typeof i!="string")return;let c=ye(i);this.userId=c,this.enqueue("identify",{...this.baseMessage(),type:"identify",userId:c,identityType:o,traits:f});}alias(i,o){if(!te(this.consent.level)){this.debug.logWarning("alias() requires full consent \u2014 call ignored.");return}if(!jt(i.id,i.identityType,o.id,o.identityType)){this.debug.logWarning("alias() from and to are identical \u2014 call ignored.");return}fe(this.cookieDomain),this.enqueue("alias",{...this.baseMessage(),type:"alias",fromId:ye(i.id),fromType:i.identityType,toId:ye(o.id),toType:o.identityType});}setConsent(i){let o=this.consent.level;if(i===o)return;this.debug.logConsent(o,i);let f=!W(o)&&W(i);if(f&&(this.anonymousId=_e(this.cookieDomain)),W(i)||this.queue.stop(),this.consent.setLevel(i),W(i)?te(o)&&!te(i)&&(this.userId=void 0):(ge(ue,this.cookieDomain),ge(ae,this.cookieDomain)),f){this.isFirstPage=!0;let c=this.startSession();this.queue.start(),c&&this.trackSessionStart();}}reset(){this.userId=void 0,this.queue.clear(),ge(ue,this.cookieDomain),ge(ae,this.cookieDomain),this.isTrackingDisabled()?(this.anonymousId=le(),this.sessionId=void 0,this.sessionStartTime=void 0):(this.anonymousId=_e(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));}};T();B();var Yi={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"};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
3
|
+
${a.stack}`),oe(r,`trackError_${i}`,{...f||{},errorMessage:c,errorStack:p,isTrackError:!0});},Ut=D(Pi),Li=r=>{Z("env",r);};D(pe("setEnvironment",Li));var Ci=r=>{Z("passportClientId",r);};D(pe("setPassportClientId",Ci));var $i=r=>{Z("pak",r);};D(pe("setPublishableApiKey",$i));D(pe("getDetail",Me));var Mi={Passport:"passport",Steam:"steam",Epic:"epic",Google:"google",Apple:"apple",Discord:"discord",Email:"email",Custom:"custom"},Di="pk_imapik-test-",Fi="/v1/audience/messages",ji="/v1/audience/tracking-consent",ue="imtbl_anon_id",ae="_imtbl_sid",Pt="session_start",Rt="session_end",Nt=r=>r.startsWith(Di)?"https://api.sandbox.immutable.com":"https://api.immutable.com",de=()=>typeof window<"u"&&typeof document<"u",le=()=>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)}),Lt=()=>new Date().toISOString();function Se(r){if(!de())return;let i=document.cookie.match(new RegExp(`(?:^|; )${r}=([^;]*)`));return i?decodeURIComponent(i[1]):void 0}function Ee(r,i,o,f){if(!de())return;let c=window.location.protocol==="https:"?"; Secure":"",p=f?`; domain=${f}`:"";document.cookie=`${r}=${encodeURIComponent(i)}; path=/; max-age=${o}; SameSite=Lax${p}${c}`;}function ge(r,i){Ee(r,"",0,i);}function _e(r){let i=Se(ue);if(i)return i;let o=le();return Ee(ue,o,63072e3,r),o}var Ke=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;}},ze=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 Ct(r,i,o){if(r.status===0)return new ze({code:"NETWORK_ERROR",message:i==="flush"?`Network error sending ${o??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,c=f?.rejected??0,p=f?.accepted??0;return new ze({code:"VALIDATION_REJECTED",message:`Backend rejected ${c} of ${c+p} messages`,status:r.status,endpoint:r.endpoint,responseBody:r.body})}return new ze({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 $t(r,i){if(r)try{r(i);}catch{}}async function kt(r){let i=r.headers?.get?.("content-type")??"";try{return i.includes("application/json")?await r.json():await r.text()}catch{return}}var He=async(r,i,o,f)=>{try{let c=await fetch(r,{method:f?.method??"POST",headers:{"Content-Type":"application/json","x-immutable-publishable-key":i},body:JSON.stringify(o),keepalive:f?.keepalive});if(!c.ok){let a=await kt(c);return oe("audience","transport_send_failed",{status:c.status}),{ok:!1,error:new Ke({status:c.status,endpoint:r,body:a})}}let p=await kt(c);if(typeof p=="object"&&p!==null&&"rejected"in p){let a=p.rejected??0;if(a>0)return oe("audience","transport_partial_rejected",{status:c.status,rejected:a}),{ok:!1,error:new Ke({status:c.status,endpoint:r,body:p})}}return {ok:!0}}catch(c){let p=new Ke({status:0,endpoint:r,cause:c});return Ut("audience","transport_send",p),{ok:!1,error:p}}},Ye="__imtbl_audience_";function Je(){try{return de()&&typeof localStorage<"u"}catch{return !1}}function Gi(r,i=Ye){if(Je())try{let o=localStorage.getItem(`${i}${r}`);return o?JSON.parse(o):void 0}catch{return}}function qi(r,i,o=Ye){if(Je())try{localStorage.setItem(`${o}${r}`,JSON.stringify(i));}catch{}}function Vi(r,i=Ye){if(Je())try{localStorage.removeItem(`${i}${r}`);}catch{}}var We="queue",Ot=100,Mt=class{constructor(r,i,o){this.send=r,this.publishableKey=i,this.endpointUrl=`${o?.baseUrl??Nt(i)}${Fi}`,this.flushIntervalMs=o?.flushIntervalMs??5e3,this.flushSize=o?.flushSize??20,this.onFlush=o?.onFlush,this.onError=o?.onError,this.storagePrefix=o?.storagePrefix;let f=Gi(We,this.storagePrefix)??[];this.messages=o?.staleFilter?f.filter(o.staleFilter):f;}messages;timer=null;flushing=!1;unloadBound=!1;visibilityHandler;pagehideHandler;onFlush;onError;storagePrefix;endpointUrl;flushIntervalMs;flushSize;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)){this.flushing=!0;try{let r=this.messages.slice(0,Ot),i={messages:r},o=await this.send(this.endpointUrl,this.publishableKey,i),f;!o.ok&&o.error&&(f=Ct(o.error,"flush",r.length));let c=f?.code==="VALIDATION_REJECTED";(o.ok||c)&&(this.messages=this.messages.slice(r.length),this.persist()),this.onFlush?.(o.ok,r.length),f&&$t(this.onError,f);}finally{this.flushing=!1;}}}flushUnload(){if(this.flushing||this.messages.length===0)return;let r=this.messages.slice(0,Ot),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=[],Vi(We,this.storagePrefix);}registerUnload(){!de()||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);}persist(){qi(We,this.messages,this.storagePrefix);}},Ki="2.15.1-alpha.5";function Dt(r="@imtbl/audience",i=Ki){let o={library:r,libraryVersion:i};return de()&&(o.userAgent=navigator.userAgent,o.locale=navigator.language,o.timezone=Intl.DateTimeFormat().resolvedOptions().timeZone,o.screen=`${window.screen.width}x${window.screen.height}`,o.pageUrl=window.location.href,o.pagePath=window.location.pathname,o.pageReferrer=document.referrer,o.pageTitle=document.title),o}function Ft(r){let i=new Date(r).getTime();if(Number.isNaN(i))return !1;let o=Date.now();return i<=o+864e5&&i>=o-2592e6}function jt(r,i,o,f){return r!==o||i!==f}function ye(r,i=256){return r.length>i?r.slice(0,i):r}function fe(r){let i=Se(ae);if(i)return Ee(ae,i,1800,r),{sessionId:i,isNew:!1};let o=le();return Ee(ae,o,1800,r),{sessionId:o,isNew:!0}}var Gt=["utm_source","utm_medium","utm_campaign","utm_content","utm_term"],qt=["gclid","dclid","fbclid","ttclid","msclkid","li_fat_id"],Vt="__imtbl_attribution";function zi(r){let i;try{i=new URL(r).searchParams;}catch{return {}}let o={};for(let c of [...Gt,...qt]){let p=i.get(c);p&&(o[c]=p);}let f=i.get("referral_code");return f&&(o.referral_code=f),o}function Wi(){try{let r=sessionStorage.getItem(Vt);return r?JSON.parse(r):null}catch{return null}}function Hi(r){try{sessionStorage.setItem(Vt,JSON.stringify(r));}catch{}}function Kt(){let r=Wi();if(r)return r;let i=typeof window<"u"&&window.location?zi(window.location.href):{},o=typeof document<"u"&&document.referrer||void 0,f=typeof window<"u"&&window.location?window.location.href:void 0,c=qt.some(y=>y in i),p=Gt.some(y=>y in i),a={...i,referrer:o,landing_page:f,touchpoint_type:c||p?"click":void 0};return Hi(a),a}function W(r){return r!=="none"}function te(r){return r==="full"}function zt(r,i,o,f,c,p,a,y){let m=p??"none",x={none:0,anonymous:1,full:2};function v(w){let b=`${y??Nt(o)}${ji}`;i(b,o,{anonymousId:f,status:w,source:c},{method:"PUT",keepalive:!0}).then(d=>{!d.ok&&d.error&&$t(a,Ct(d.error,"consent"));});}return {get level(){return m},setLevel(w){w!==m&&(x[w]<x[m]&&(w==="none"?r.purge(()=>!0):w==="anonymous"&&(r.purge(b=>b.type==="identify"||b.type==="alias"),r.transform(b=>{if("userId"in b){let{userId:d,...g}=b;return g}return b}))),m=w,v(w));}}}T();B();T();B();var Wt="@imtbl/audience",Ht="2.15.1-alpha.5",H="[audience]",Yt="WebSDK";var Ae=class{enabled;constructor(i=!1){this.enabled=i;}logEvent(i,o){this.enabled&&console.log(`${H} ${i}`,o);}logFlush(i,o){this.enabled&&console.log(`${H} flush ${i?"ok":"failed"} (${o} messages)`);}logConsent(i,o){this.enabled&&console.log(`${H} consent ${i} \u2192 ${o}`);}logWarning(i){this.enabled&&console.warn(`${H} ${i}`);}};var Xe=class r{static liveInstances=0;queue;consent;attribution;debug;cookieDomain;anonymousId;sessionId;sessionStartTime;userId;isFirstPage=!0;destroyed=!1;constructor(i){let{cookieDomain:o,publishableKey:f}=i,c=i.consent??"none",p=Yt;this.cookieDomain=o,this.debug=new Ae(i.debug??!1);let a=!1;W(c)?(this.anonymousId=_e(o),a=this.startSession()):this.anonymousId=Se(ue)??le(),this.queue=new Mt(He,f,{baseUrl:i.baseUrl,flushIntervalMs:i.flushInterval,flushSize:i.flushSize,onFlush:(y,m)=>this.debug.logFlush(y,m),staleFilter:y=>Ft(y.eventTimestamp),storagePrefix:"__imtbl_web_"}),this.consent=zt(this.queue,He,f,this.anonymousId,p,c,void 0,i.baseUrl),this.attribution=Kt(),this.isTrackingDisabled()||(this.queue.start(),a&&this.trackSessionStart());}static init(i){if(!i.publishableKey?.trim())throw new Error(`${H} publishableKey is required`);return r.liveInstances>0&&console.warn(`${H} Multiple SDK instances detected. Ensure previous instances are shut down to avoid duplicate events.`),r.liveInstances+=1,new r(i)}isTrackingDisabled(){return !W(this.consent.level)}effectiveUserId(){return te(this.consent.level)?this.userId:void 0}startSession(){let i=fe(this.cookieDomain);return this.sessionId=i.sessionId,this.sessionStartTime=Date.now(),i.isNew}baseMessage(){return {messageId:le(),eventTimestamp:Lt(),anonymousId:this.anonymousId,surface:"web",context:Dt(Wt,Ht)}}enqueue(i,o){this.queue.enqueue(o),this.debug.logEvent(i,o);}trackSessionStart(){this.sessionId&&this.enqueue("track(session_start)",{...this.baseMessage(),type:"track",eventName:Pt,properties:{sessionId:this.sessionId,...this.attribution}});}trackSessionEnd(){this.sessionId&&this.enqueue("track(session_end)",{...this.baseMessage(),type:"track",eventName:Rt,properties:{sessionId:this.sessionId,...this.sessionStartTime&&{duration:Math.round((Date.now()-this.sessionStartTime)/1e3)}}});}page(i){if(this.isTrackingDisabled())return;fe(this.cookieDomain);let o={...i};this.isFirstPage&&(Object.assign(o,this.attribution),this.isFirstPage=!1),this.enqueue("page",{...this.baseMessage(),type:"page",properties:Object.keys(o).length>0?o:void 0,userId:this.effectiveUserId()});}track(i,...o){if(this.isTrackingDisabled())return;fe(this.cookieDomain);let[f]=o;this.enqueue("track",{...this.baseMessage(),type:"track",eventName:ye(i),properties:f,userId:this.effectiveUserId()});}identify(i,o,f){if(!te(this.consent.level)){this.debug.logWarning("identify() requires full consent \u2014 call ignored.");return}if(fe(this.cookieDomain),i!==null&&typeof i=="object"&&!Array.isArray(i)){this.enqueue("identify",{...this.baseMessage(),type:"identify",traits:i});return}if(typeof i!="string")return;let c=ye(i);this.userId=c,this.enqueue("identify",{...this.baseMessage(),type:"identify",userId:c,identityType:o,traits:f});}alias(i,o){if(!te(this.consent.level)){this.debug.logWarning("alias() requires full consent \u2014 call ignored.");return}if(!jt(i.id,i.identityType,o.id,o.identityType)){this.debug.logWarning("alias() from and to are identical \u2014 call ignored.");return}fe(this.cookieDomain),this.enqueue("alias",{...this.baseMessage(),type:"alias",fromId:ye(i.id),fromType:i.identityType,toId:ye(o.id),toType:o.identityType});}setConsent(i){let o=this.consent.level;if(i===o)return;this.debug.logConsent(o,i);let f=!W(o)&&W(i);if(f&&(this.anonymousId=_e(this.cookieDomain)),W(i)||this.queue.stop(),this.consent.setLevel(i),W(i)?te(o)&&!te(i)&&(this.userId=void 0):(ge(ue,this.cookieDomain),ge(ae,this.cookieDomain)),f){this.isFirstPage=!0;let c=this.startSession();this.queue.start(),c&&this.trackSessionStart();}}reset(){this.userId=void 0,this.queue.clear(),ge(ue,this.cookieDomain),ge(ae,this.cookieDomain),this.isTrackingDisabled()?(this.anonymousId=le(),this.sessionId=void 0,this.sessionStartTime=void 0):(this.anonymousId=_e(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));}};T();B();var Yi={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"};/*! 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:
|
package/dist/node/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var Me=Object.create;var ie=Object.defineProperty;var Fe=Object.getOwnPropertyDescriptor;var je=Object.getOwnPropertyNames;var qe=Object.getPrototypeOf,Ge=Object.prototype.hasOwnProperty;var Ke=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Ve=(e,t,s,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of je(t))!Ge.call(e,r)&&r!==s&&ie(e,r,{get:()=>t[r],enumerable:!(i=Fe(t,r))||i.enumerable});return e};var Be=(e,t,s)=>(s=e!=null?Me(qe(e)):{},Ve(ie(s,"default",{value:e,enumerable:!0}),e));var ue=Ke(b=>{Object.defineProperty(b,"__esModule",{value:!0});b.clearGlobalNamespace=b.getGlobalisedValue=void 0;var We="globalise__singleton__",Je={},oe=()=>typeof window<"u"?window:typeof globalThis<"u"?globalThis:Je,Ye=(e,t)=>{if(typeof e!="string")throw "Invalid namespace key";if(typeof t!="string")throw "Invalid item key"},ae=e=>`${We}${e}`,le=e=>{let t=oe(),s=ae(e);return t[s]||(t[s]={}),t[s]},Xe=(e,t)=>le(e)[t]||void 0,Qe=(e,t,s)=>{let i=le(e);i[t]=s;},Ze=(e,t,s)=>{Ye(e,t);let i=Xe(e,t);return i!==void 0?i:(Qe(e,t,s),s)};b.getGlobalisedValue=Ze;var et=e=>{let t=oe(),s=ae(e);t[s]!==void 0&&delete t[s];};b.clearGlobalNamespace=et;});var M=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 o=this.last,a=n.next,l=n.prev;this.first===n&&(this.first=n.next),n.next=null,n.prev=this.last,o.next=n,l!==null&&(l.next=a),a!==null&&(a.prev=l);}}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 re(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 M(e,t,s)}var ze={max:1e3},ne=(e,t={})=>{let{cache:s,cacheKeyResolver:i=F,onHit:r,lruOptions:n={}}=t,o={...ze,...n},a=s||re(o.max,o.ttl);function l(...h){let f=i(...h),c=a.get(f);if(a.has(f))return r&&r(f,c,a),c;let p=e.apply(this,h);return a.set(f,p),p}return l._cache=a,l},F=(...e)=>e.length===0?"no-args":e.map(t=>t===void 0?"undefined":t===null?"null":Array.isArray(t)?`[${F(...t)}]`:typeof t=="object"?`{${F(...He(t))}}`:JSON.stringify(t)).join(","),He=e=>Object.entries(e).sort((t,s)=>t[0]<s[0]?-1:1);var B=Be(ue()),tt=Object.defineProperty,st=(e,t)=>{for(var s in t)tt(e,s,{get:t[s],enumerable:!0});},it={};st(it,{deleteItem:()=>at,getItem:()=>q,setItem:()=>C});var O=()=>typeof window>"u",de=()=>!O(),rt="__IMX-",z=()=>de()&&window.localStorage,nt=e=>{if(e!==null)try{return JSON.parse(e)}catch{return e}},ot=e=>typeof e=="string"?e:JSON.stringify(e),H=e=>`${rt}${e}`;function q(e){if(z())return nt(window.localStorage.getItem(H(e)))}var C=(e,t)=>z()?(window.localStorage.setItem(H(e),ot(t)),!0):!1,at=e=>z()?(window.localStorage.removeItem(H(e)),!0):!1,G=0,lt=e=>{let t=parseInt(e,10)*1e3,s=new Date(t),i=new Date;return G=s.getTime()-i.getTime(),G},ut=()=>{let e=new Date().getTime()+G;return new Date(e).toISOString()},ct=(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))(ct||{}),dt="https://api.immutable.com",ht=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 he(e,t){let s=JSON.stringify(t),i={payload:ht(s)},r=await fetch(`${dt}${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 y,v,pt=()=>{y=q("metrics-events")||[],v=q("metrics-runtime")||{};};pt();var w=(e,t)=>{v={...v,[e]:t},C("metrics-runtime",v);},K=e=>{if(v[e]!==void 0)return v[e]},ft=()=>v,mt=()=>y,gt=e=>{y.push(e),C("metrics-events",y);},yt=e=>{y=y.slice(e),C("metrics-events",y);},pe=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},j="2.15.1-alpha.
|
|
3
|
+
var Me=Object.create;var ie=Object.defineProperty;var Fe=Object.getOwnPropertyDescriptor;var je=Object.getOwnPropertyNames;var qe=Object.getPrototypeOf,Ge=Object.prototype.hasOwnProperty;var Ke=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Ve=(e,t,s,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of je(t))!Ge.call(e,r)&&r!==s&&ie(e,r,{get:()=>t[r],enumerable:!(i=Fe(t,r))||i.enumerable});return e};var Be=(e,t,s)=>(s=e!=null?Me(qe(e)):{},Ve(ie(s,"default",{value:e,enumerable:!0}),e));var ue=Ke(b=>{Object.defineProperty(b,"__esModule",{value:!0});b.clearGlobalNamespace=b.getGlobalisedValue=void 0;var We="globalise__singleton__",Je={},oe=()=>typeof window<"u"?window:typeof globalThis<"u"?globalThis:Je,Ye=(e,t)=>{if(typeof e!="string")throw "Invalid namespace key";if(typeof t!="string")throw "Invalid item key"},ae=e=>`${We}${e}`,le=e=>{let t=oe(),s=ae(e);return t[s]||(t[s]={}),t[s]},Xe=(e,t)=>le(e)[t]||void 0,Qe=(e,t,s)=>{let i=le(e);i[t]=s;},Ze=(e,t,s)=>{Ye(e,t);let i=Xe(e,t);return i!==void 0?i:(Qe(e,t,s),s)};b.getGlobalisedValue=Ze;var et=e=>{let t=oe(),s=ae(e);t[s]!==void 0&&delete t[s];};b.clearGlobalNamespace=et;});var M=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 o=this.last,a=n.next,l=n.prev;this.first===n&&(this.first=n.next),n.next=null,n.prev=this.last,o.next=n,l!==null&&(l.next=a),a!==null&&(a.prev=l);}}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 re(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 M(e,t,s)}var ze={max:1e3},ne=(e,t={})=>{let{cache:s,cacheKeyResolver:i=F,onHit:r,lruOptions:n={}}=t,o={...ze,...n},a=s||re(o.max,o.ttl);function l(...h){let f=i(...h),c=a.get(f);if(a.has(f))return r&&r(f,c,a),c;let p=e.apply(this,h);return a.set(f,p),p}return l._cache=a,l},F=(...e)=>e.length===0?"no-args":e.map(t=>t===void 0?"undefined":t===null?"null":Array.isArray(t)?`[${F(...t)}]`:typeof t=="object"?`{${F(...He(t))}}`:JSON.stringify(t)).join(","),He=e=>Object.entries(e).sort((t,s)=>t[0]<s[0]?-1:1);var B=Be(ue()),tt=Object.defineProperty,st=(e,t)=>{for(var s in t)tt(e,s,{get:t[s],enumerable:!0});},it={};st(it,{deleteItem:()=>at,getItem:()=>q,setItem:()=>C});var O=()=>typeof window>"u",de=()=>!O(),rt="__IMX-",z=()=>de()&&window.localStorage,nt=e=>{if(e!==null)try{return JSON.parse(e)}catch{return e}},ot=e=>typeof e=="string"?e:JSON.stringify(e),H=e=>`${rt}${e}`;function q(e){if(z())return nt(window.localStorage.getItem(H(e)))}var C=(e,t)=>z()?(window.localStorage.setItem(H(e),ot(t)),!0):!1,at=e=>z()?(window.localStorage.removeItem(H(e)),!0):!1,G=0,lt=e=>{let t=parseInt(e,10)*1e3,s=new Date(t),i=new Date;return G=s.getTime()-i.getTime(),G},ut=()=>{let e=new Date().getTime()+G;return new Date(e).toISOString()},ct=(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))(ct||{}),dt="https://api.immutable.com",ht=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 he(e,t){let s=JSON.stringify(t),i={payload:ht(s)},r=await fetch(`${dt}${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 y,v,pt=()=>{y=q("metrics-events")||[],v=q("metrics-runtime")||{};};pt();var w=(e,t)=>{v={...v,[e]:t},C("metrics-runtime",v);},K=e=>{if(v[e]!==void 0)return v[e]},ft=()=>v,mt=()=>y,gt=e=>{y.push(e),C("metrics-events",y);},yt=e=>{y=y.slice(e),C("metrics-events",y);},pe=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},j="2.15.1-alpha.5",vt=()=>O()?"":window.location.ancestorOrigins&&window.location.ancestorOrigins.length>0?new URL(window.location.ancestorOrigins[0]).hostname:document.referrer?new URL(window.document.referrer).hostname:"",wt=()=>{if(O())return "";let e;try{window.self!==window.top&&(e=vt());}catch{}return e||(e=window.location.hostname),e},It=()=>{if(w("sdkVersion",j),O())return {browser:"nodejs",sdkVersion:j};let e=wt();return e&&w("domain",e),{sdkVersion:j,browser:window.navigator.userAgent,domain:e,tz:Intl.DateTimeFormat().resolvedOptions().timeZone,screen:`${window.screen.width}x${window.screen.height}`}},V=!1,bt=()=>V,St=async()=>{V=!0;try{let e=pe(It()),t=K("rid"),s=K("uid"),i=await he("/v1/sdk/initialise",{version:1,data:{runtimeDetails:e,runtimeId:t,uId:s}}),{runtimeId:r,sTime:n}=i;w("rid",r),lt(n);}catch{V=!1;}};function d(e,t){return (...s)=>{try{let i=e(...s);return i instanceof Promise?i.catch(()=>t):i}catch{return t}}}function Et(){return de()||typeof process>"u"?!1:process.env.JEST_WORKER_ID!==void 0}var xt=d(Et,!1),fe="imtbl__metrics",_t=5e3,kt=1e3,P=(e,t)=>(0, B.getGlobalisedValue)(fe,e,t),Pt=(e,t)=>{let s=ne(t,{lruOptions:{ttl:_t,max:kt}});return (0, B.getGlobalisedValue)(fe,e,s)},Tt=5e3,Nt=(e,t,s)=>{let i={event:`${e}.${t}`,time:ut(),...s&&{properties:pe(s)}};gt(i);},S=d(Pt("track",Nt)),At=async()=>{if(bt()===!1){await St();return}let e=mt();if(e.length===0)return;let t=e.length,s=ft();await he("/v1/sdk/metrics",{version:1,data:{events:e,details:s}})instanceof Error||yt(t);},Ot=d(At),me=async()=>{await Ot(),setTimeout(me,Tt);},ce=!1,Ct=()=>{ce||(ce=!0,me());};xt()||d(P("startFlushing",Ct))();var Ft=(e,t,s,i)=>{let{message:r}=s,n=s.stack||"",{cause:o}=s;o instanceof Error&&(n=`${n}
|
|
4
4
|
Cause: ${o.message}
|
|
5
|
-
${o.stack}`),S(e,`trackError_${t}`,{...i||{},errorMessage:r,errorStack:n,isTrackError:!0});},ge=d(Ft),Gt=e=>{w("env",e);};d(P("setEnvironment",Gt));var Kt=e=>{w("passportClientId",e);};d(P("setPassportClientId",Kt));var Vt=e=>{w("pak",e);};d(P("setPublishableApiKey",Vt));d(P("getDetail",K));var Bt={Passport:"passport",Steam:"steam",Epic:"epic",Google:"google",Apple:"apple",Discord:"discord",Email:"email",Custom:"custom"},zt="pk_imapik-test-",Ht="/v1/audience/messages",Wt="/v1/audience/tracking-consent",x="imtbl_anon_id",E="_imtbl_sid",we="session_start",Ie="session_end",be=e=>e.startsWith(zt)?"https://api.sandbox.immutable.com":"https://api.immutable.com",T=()=>typeof window<"u"&&typeof document<"u",_=()=>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)}),Se=()=>new Date().toISOString();function $(e){if(!T())return;let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):void 0}function D(e,t,s,i){if(!T())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 N(e,t){D(e,"",0,t);}function R(e){let t=$(x);if(t)return t;let s=_();return D(x,s,63072e3,e),s}var W=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;}},J=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 Ee(e,t,s){if(e.status===0)return new J({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 J({code:"VALIDATION_REJECTED",message:`Backend rejected ${r} of ${r+n} messages`,status:e.status,endpoint:e.endpoint,responseBody:e.body})}return new J({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 xe(e,t){if(e)try{e(t);}catch{}}async function ye(e){let t=e.headers?.get?.("content-type")??"";try{return t.includes("application/json")?await e.json():await e.text()}catch{return}}var X=async(e,t,s,i)=>{try{let r=await fetch(e,{method:i?.method??"POST",headers:{"Content-Type":"application/json","x-immutable-publishable-key":t},body:JSON.stringify(s),keepalive:i?.keepalive});if(!r.ok){let o=await ye(r);return S("audience","transport_send_failed",{status:r.status}),{ok:!1,error:new W({status:r.status,endpoint:e,body:o})}}let n=await ye(r);if(typeof n=="object"&&n!==null&&"rejected"in n){let o=n.rejected??0;if(o>0)return S("audience","transport_partial_rejected",{status:r.status,rejected:o}),{ok:!1,error:new W({status:r.status,endpoint:e,body:n})}}return {ok:!0}}catch(r){let n=new W({status:0,endpoint:e,cause:r});return ge("audience","transport_send",n),{ok:!1,error:n}}},Q="__imtbl_audience_";function Z(){try{return T()&&typeof localStorage<"u"}catch{return !1}}function Jt(e,t=Q){if(Z())try{let s=localStorage.getItem(`${t}${e}`);return s?JSON.parse(s):void 0}catch{return}}function Yt(e,t,s=Q){if(Z())try{localStorage.setItem(`${s}${e}`,JSON.stringify(t));}catch{}}function Xt(e,t=Q){if(Z())try{localStorage.removeItem(`${t}${e}`);}catch{}}var Y="queue",ve=100,_e=class{constructor(e,t,s){this.send=e,this.publishableKey=t,this.endpointUrl=`${s?.baseUrl??be(t)}${Ht}`,this.flushIntervalMs=s?.flushIntervalMs??5e3,this.flushSize=s?.flushSize??20,this.onFlush=s?.onFlush,this.onError=s?.onError,this.storagePrefix=s?.storagePrefix;let i=Jt(Y,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;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)){this.flushing=!0;try{let e=this.messages.slice(0,ve),t={messages:e},s=await this.send(this.endpointUrl,this.publishableKey,t),i;!s.ok&&s.error&&(i=Ee(s.error,"flush",e.length));let r=i?.code==="VALIDATION_REJECTED";(s.ok||r)&&(this.messages=this.messages.slice(e.length),this.persist()),this.onFlush?.(s.ok,e.length),i&&xe(this.onError,i);}finally{this.flushing=!1;}}}flushUnload(){if(this.flushing||this.messages.length===0)return;let e=this.messages.slice(0,ve),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=[],Xt(Y,this.storagePrefix);}registerUnload(){!T()||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);}persist(){Yt(Y,this.messages,this.storagePrefix);}},Qt="2.15.1-alpha.4";function ke(e="@imtbl/audience",t=Qt){let s={library:e,libraryVersion:t};return T()&&(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 Pe(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 Te(e,t,s,i){return e!==s||t!==i}function A(e,t=256){return e.length>t?e.slice(0,t):e}function k(e){let t=$(E);if(t)return D(E,t,1800,e),{sessionId:t,isNew:!1};let s=_();return D(E,s,1800,e),{sessionId:s,isNew:!0}}var Ne=["utm_source","utm_medium","utm_campaign","utm_content","utm_term"],Ae=["gclid","dclid","fbclid","ttclid","msclkid","li_fat_id"],Oe="__imtbl_attribution";function Zt(e){let t;try{t=new URL(e).searchParams;}catch{return {}}let s={};for(let r of [...Ne,...Ae]){let n=t.get(r);n&&(s[r]=n);}let i=t.get("referral_code");return i&&(s.referral_code=i),s}function es(){try{let e=sessionStorage.getItem(Oe);return e?JSON.parse(e):null}catch{return null}}function ts(e){try{sessionStorage.setItem(Oe,JSON.stringify(e));}catch{}}function Ce(){let e=es();if(e)return e;let t=typeof window<"u"&&window.location?Zt(window.location.href):{},s=typeof document<"u"&&document.referrer||void 0,i=typeof window<"u"&&window.location?window.location.href:void 0,r=Ae.some(a=>a in t),n=Ne.some(a=>a in t),o={...t,referrer:s,landing_page:i,touchpoint_type:r||n?"click":void 0};return ts(o),o}function m(e){return e!=="none"}function I(e){return e==="full"}function De(e,t,s,i,r,n,o,a){let l=n??"none",h={none:0,anonymous:1,full:2};function f(c){let u=`${a??be(s)}${Wt}`;t(u,s,{anonymousId:i,status:c,source:r},{method:"PUT",keepalive:!0}).then(p=>{!p.ok&&p.error&&xe(o,Ee(p.error,"consent"));});}return {get level(){return l},setLevel(c){c!==l&&(h[c]<h[l]&&(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,...U}=u;return U}return u}))),l=c,f(c));}}}var $e="@imtbl/audience",Re="2.15.1-alpha.4",g="[audience]",Le="WebSDK";var L=class{enabled;constructor(t=!1){this.enabled=t;}logEvent(t,s){this.enabled&&console.log(`${g} ${t}`,s);}logFlush(t,s){this.enabled&&console.log(`${g} flush ${t?"ok":"failed"} (${s} messages)`);}logConsent(t,s){this.enabled&&console.log(`${g} consent ${t} \u2192 ${s}`);}logWarning(t){this.enabled&&console.warn(`${g} ${t}`);}};var ee=class e{static liveInstances=0;queue;consent;attribution;debug;cookieDomain;anonymousId;sessionId;sessionStartTime;userId;isFirstPage=!0;destroyed=!1;constructor(t){let{cookieDomain:s,publishableKey:i}=t,r=t.consent??"none",n=Le;this.cookieDomain=s,this.debug=new L(t.debug??!1);let o=!1;m(r)?(this.anonymousId=R(s),o=this.startSession()):this.anonymousId=$(x)??_(),this.queue=new _e(X,i,{baseUrl:t.baseUrl,flushIntervalMs:t.flushInterval,flushSize:t.flushSize,onFlush:(a,l)=>this.debug.logFlush(a,l),staleFilter:a=>Pe(a.eventTimestamp),storagePrefix:"__imtbl_web_"}),this.consent=De(this.queue,X,i,this.anonymousId,n,r,void 0,t.baseUrl),this.attribution=Ce(),this.isTrackingDisabled()||(this.queue.start(),o&&this.trackSessionStart());}static init(t){if(!t.publishableKey?.trim())throw new Error(`${g} publishableKey is required`);return e.liveInstances>0&&console.warn(`${g} Multiple SDK instances detected. Ensure previous instances are shut down to avoid duplicate events.`),e.liveInstances+=1,new e(t)}isTrackingDisabled(){return !m(this.consent.level)}effectiveUserId(){return I(this.consent.level)?this.userId:void 0}startSession(){let t=k(this.cookieDomain);return this.sessionId=t.sessionId,this.sessionStartTime=Date.now(),t.isNew}baseMessage(){return {messageId:_(),eventTimestamp:Se(),anonymousId:this.anonymousId,surface:"web",context:ke($e,Re)}}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:we,properties:{sessionId:this.sessionId,...this.attribution}});}trackSessionEnd(){this.sessionId&&this.enqueue("track(session_end)",{...this.baseMessage(),type:"track",eventName:Ie,properties:{sessionId:this.sessionId,...this.sessionStartTime&&{duration:Math.round((Date.now()-this.sessionStartTime)/1e3)}}});}page(t){if(this.isTrackingDisabled())return;k(this.cookieDomain);let s={...t};this.isFirstPage&&(Object.assign(s,this.attribution),this.isFirstPage=!1),this.enqueue("page",{...this.baseMessage(),type:"page",properties:Object.keys(s).length>0?s:void 0,userId:this.effectiveUserId()});}track(t,...s){if(this.isTrackingDisabled())return;k(this.cookieDomain);let[i]=s;this.enqueue("track",{...this.baseMessage(),type:"track",eventName:A(t),properties:i,userId:this.effectiveUserId()});}identify(t,s,i){if(!I(this.consent.level)){this.debug.logWarning("identify() requires full consent \u2014 call ignored.");return}if(k(this.cookieDomain),t!==null&&typeof t=="object"&&!Array.isArray(t)){this.enqueue("identify",{...this.baseMessage(),type:"identify",traits:t});return}if(typeof t!="string")return;let r=A(t);this.userId=r,this.enqueue("identify",{...this.baseMessage(),type:"identify",userId:r,identityType:s,traits:i});}alias(t,s){if(!I(this.consent.level)){this.debug.logWarning("alias() requires full consent \u2014 call ignored.");return}if(!Te(t.id,t.identityType,s.id,s.identityType)){this.debug.logWarning("alias() from and to are identical \u2014 call ignored.");return}k(this.cookieDomain),this.enqueue("alias",{...this.baseMessage(),type:"alias",fromId:A(t.id),fromType:t.identityType,toId:A(s.id),toType:s.identityType});}setConsent(t){let s=this.consent.level;if(t===s)return;this.debug.logConsent(s,t);let i=!m(s)&&m(t);if(i&&(this.anonymousId=R(this.cookieDomain)),m(t)||this.queue.stop(),this.consent.setLevel(t),m(t)?I(s)&&!I(t)&&(this.userId=void 0):(N(x,this.cookieDomain),N(E,this.cookieDomain)),i){this.isFirstPage=!0;let r=this.startSession();this.queue.start(),r&&this.trackSessionStart();}}reset(){this.userId=void 0,this.queue.clear(),N(x,this.cookieDomain),N(E,this.cookieDomain),this.isTrackingDisabled()?(this.anonymousId=_(),this.sessionId=void 0,this.sessionStartTime=void 0):(this.anonymousId=R(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 ss={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"};/*! Bundled license information:
|
|
5
|
+
${o.stack}`),S(e,`trackError_${t}`,{...i||{},errorMessage:r,errorStack:n,isTrackError:!0});},ge=d(Ft),Gt=e=>{w("env",e);};d(P("setEnvironment",Gt));var Kt=e=>{w("passportClientId",e);};d(P("setPassportClientId",Kt));var Vt=e=>{w("pak",e);};d(P("setPublishableApiKey",Vt));d(P("getDetail",K));var Bt={Passport:"passport",Steam:"steam",Epic:"epic",Google:"google",Apple:"apple",Discord:"discord",Email:"email",Custom:"custom"},zt="pk_imapik-test-",Ht="/v1/audience/messages",Wt="/v1/audience/tracking-consent",x="imtbl_anon_id",E="_imtbl_sid",we="session_start",Ie="session_end",be=e=>e.startsWith(zt)?"https://api.sandbox.immutable.com":"https://api.immutable.com",T=()=>typeof window<"u"&&typeof document<"u",_=()=>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)}),Se=()=>new Date().toISOString();function $(e){if(!T())return;let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):void 0}function D(e,t,s,i){if(!T())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 N(e,t){D(e,"",0,t);}function R(e){let t=$(x);if(t)return t;let s=_();return D(x,s,63072e3,e),s}var W=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;}},J=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 Ee(e,t,s){if(e.status===0)return new J({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 J({code:"VALIDATION_REJECTED",message:`Backend rejected ${r} of ${r+n} messages`,status:e.status,endpoint:e.endpoint,responseBody:e.body})}return new J({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 xe(e,t){if(e)try{e(t);}catch{}}async function ye(e){let t=e.headers?.get?.("content-type")??"";try{return t.includes("application/json")?await e.json():await e.text()}catch{return}}var X=async(e,t,s,i)=>{try{let r=await fetch(e,{method:i?.method??"POST",headers:{"Content-Type":"application/json","x-immutable-publishable-key":t},body:JSON.stringify(s),keepalive:i?.keepalive});if(!r.ok){let o=await ye(r);return S("audience","transport_send_failed",{status:r.status}),{ok:!1,error:new W({status:r.status,endpoint:e,body:o})}}let n=await ye(r);if(typeof n=="object"&&n!==null&&"rejected"in n){let o=n.rejected??0;if(o>0)return S("audience","transport_partial_rejected",{status:r.status,rejected:o}),{ok:!1,error:new W({status:r.status,endpoint:e,body:n})}}return {ok:!0}}catch(r){let n=new W({status:0,endpoint:e,cause:r});return ge("audience","transport_send",n),{ok:!1,error:n}}},Q="__imtbl_audience_";function Z(){try{return T()&&typeof localStorage<"u"}catch{return !1}}function Jt(e,t=Q){if(Z())try{let s=localStorage.getItem(`${t}${e}`);return s?JSON.parse(s):void 0}catch{return}}function Yt(e,t,s=Q){if(Z())try{localStorage.setItem(`${s}${e}`,JSON.stringify(t));}catch{}}function Xt(e,t=Q){if(Z())try{localStorage.removeItem(`${t}${e}`);}catch{}}var Y="queue",ve=100,_e=class{constructor(e,t,s){this.send=e,this.publishableKey=t,this.endpointUrl=`${s?.baseUrl??be(t)}${Ht}`,this.flushIntervalMs=s?.flushIntervalMs??5e3,this.flushSize=s?.flushSize??20,this.onFlush=s?.onFlush,this.onError=s?.onError,this.storagePrefix=s?.storagePrefix;let i=Jt(Y,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;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)){this.flushing=!0;try{let e=this.messages.slice(0,ve),t={messages:e},s=await this.send(this.endpointUrl,this.publishableKey,t),i;!s.ok&&s.error&&(i=Ee(s.error,"flush",e.length));let r=i?.code==="VALIDATION_REJECTED";(s.ok||r)&&(this.messages=this.messages.slice(e.length),this.persist()),this.onFlush?.(s.ok,e.length),i&&xe(this.onError,i);}finally{this.flushing=!1;}}}flushUnload(){if(this.flushing||this.messages.length===0)return;let e=this.messages.slice(0,ve),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=[],Xt(Y,this.storagePrefix);}registerUnload(){!T()||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);}persist(){Yt(Y,this.messages,this.storagePrefix);}},Qt="2.15.1-alpha.5";function ke(e="@imtbl/audience",t=Qt){let s={library:e,libraryVersion:t};return T()&&(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 Pe(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 Te(e,t,s,i){return e!==s||t!==i}function A(e,t=256){return e.length>t?e.slice(0,t):e}function k(e){let t=$(E);if(t)return D(E,t,1800,e),{sessionId:t,isNew:!1};let s=_();return D(E,s,1800,e),{sessionId:s,isNew:!0}}var Ne=["utm_source","utm_medium","utm_campaign","utm_content","utm_term"],Ae=["gclid","dclid","fbclid","ttclid","msclkid","li_fat_id"],Oe="__imtbl_attribution";function Zt(e){let t;try{t=new URL(e).searchParams;}catch{return {}}let s={};for(let r of [...Ne,...Ae]){let n=t.get(r);n&&(s[r]=n);}let i=t.get("referral_code");return i&&(s.referral_code=i),s}function es(){try{let e=sessionStorage.getItem(Oe);return e?JSON.parse(e):null}catch{return null}}function ts(e){try{sessionStorage.setItem(Oe,JSON.stringify(e));}catch{}}function Ce(){let e=es();if(e)return e;let t=typeof window<"u"&&window.location?Zt(window.location.href):{},s=typeof document<"u"&&document.referrer||void 0,i=typeof window<"u"&&window.location?window.location.href:void 0,r=Ae.some(a=>a in t),n=Ne.some(a=>a in t),o={...t,referrer:s,landing_page:i,touchpoint_type:r||n?"click":void 0};return ts(o),o}function m(e){return e!=="none"}function I(e){return e==="full"}function De(e,t,s,i,r,n,o,a){let l=n??"none",h={none:0,anonymous:1,full:2};function f(c){let u=`${a??be(s)}${Wt}`;t(u,s,{anonymousId:i,status:c,source:r},{method:"PUT",keepalive:!0}).then(p=>{!p.ok&&p.error&&xe(o,Ee(p.error,"consent"));});}return {get level(){return l},setLevel(c){c!==l&&(h[c]<h[l]&&(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,...U}=u;return U}return u}))),l=c,f(c));}}}var $e="@imtbl/audience",Re="2.15.1-alpha.5",g="[audience]",Le="WebSDK";var L=class{enabled;constructor(t=!1){this.enabled=t;}logEvent(t,s){this.enabled&&console.log(`${g} ${t}`,s);}logFlush(t,s){this.enabled&&console.log(`${g} flush ${t?"ok":"failed"} (${s} messages)`);}logConsent(t,s){this.enabled&&console.log(`${g} consent ${t} \u2192 ${s}`);}logWarning(t){this.enabled&&console.warn(`${g} ${t}`);}};var ee=class e{static liveInstances=0;queue;consent;attribution;debug;cookieDomain;anonymousId;sessionId;sessionStartTime;userId;isFirstPage=!0;destroyed=!1;constructor(t){let{cookieDomain:s,publishableKey:i}=t,r=t.consent??"none",n=Le;this.cookieDomain=s,this.debug=new L(t.debug??!1);let o=!1;m(r)?(this.anonymousId=R(s),o=this.startSession()):this.anonymousId=$(x)??_(),this.queue=new _e(X,i,{baseUrl:t.baseUrl,flushIntervalMs:t.flushInterval,flushSize:t.flushSize,onFlush:(a,l)=>this.debug.logFlush(a,l),staleFilter:a=>Pe(a.eventTimestamp),storagePrefix:"__imtbl_web_"}),this.consent=De(this.queue,X,i,this.anonymousId,n,r,void 0,t.baseUrl),this.attribution=Ce(),this.isTrackingDisabled()||(this.queue.start(),o&&this.trackSessionStart());}static init(t){if(!t.publishableKey?.trim())throw new Error(`${g} publishableKey is required`);return e.liveInstances>0&&console.warn(`${g} Multiple SDK instances detected. Ensure previous instances are shut down to avoid duplicate events.`),e.liveInstances+=1,new e(t)}isTrackingDisabled(){return !m(this.consent.level)}effectiveUserId(){return I(this.consent.level)?this.userId:void 0}startSession(){let t=k(this.cookieDomain);return this.sessionId=t.sessionId,this.sessionStartTime=Date.now(),t.isNew}baseMessage(){return {messageId:_(),eventTimestamp:Se(),anonymousId:this.anonymousId,surface:"web",context:ke($e,Re)}}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:we,properties:{sessionId:this.sessionId,...this.attribution}});}trackSessionEnd(){this.sessionId&&this.enqueue("track(session_end)",{...this.baseMessage(),type:"track",eventName:Ie,properties:{sessionId:this.sessionId,...this.sessionStartTime&&{duration:Math.round((Date.now()-this.sessionStartTime)/1e3)}}});}page(t){if(this.isTrackingDisabled())return;k(this.cookieDomain);let s={...t};this.isFirstPage&&(Object.assign(s,this.attribution),this.isFirstPage=!1),this.enqueue("page",{...this.baseMessage(),type:"page",properties:Object.keys(s).length>0?s:void 0,userId:this.effectiveUserId()});}track(t,...s){if(this.isTrackingDisabled())return;k(this.cookieDomain);let[i]=s;this.enqueue("track",{...this.baseMessage(),type:"track",eventName:A(t),properties:i,userId:this.effectiveUserId()});}identify(t,s,i){if(!I(this.consent.level)){this.debug.logWarning("identify() requires full consent \u2014 call ignored.");return}if(k(this.cookieDomain),t!==null&&typeof t=="object"&&!Array.isArray(t)){this.enqueue("identify",{...this.baseMessage(),type:"identify",traits:t});return}if(typeof t!="string")return;let r=A(t);this.userId=r,this.enqueue("identify",{...this.baseMessage(),type:"identify",userId:r,identityType:s,traits:i});}alias(t,s){if(!I(this.consent.level)){this.debug.logWarning("alias() requires full consent \u2014 call ignored.");return}if(!Te(t.id,t.identityType,s.id,s.identityType)){this.debug.logWarning("alias() from and to are identical \u2014 call ignored.");return}k(this.cookieDomain),this.enqueue("alias",{...this.baseMessage(),type:"alias",fromId:A(t.id),fromType:t.identityType,toId:A(s.id),toType:s.identityType});}setConsent(t){let s=this.consent.level;if(t===s)return;this.debug.logConsent(s,t);let i=!m(s)&&m(t);if(i&&(this.anonymousId=R(this.cookieDomain)),m(t)||this.queue.stop(),this.consent.setLevel(t),m(t)?I(s)&&!I(t)&&(this.userId=void 0):(N(x,this.cookieDomain),N(E,this.cookieDomain)),i){this.isFirstPage=!0;let r=this.startSession();this.queue.start(),r&&this.trackSessionStart();}}reset(){this.userId=void 0,this.queue.clear(),N(x,this.cookieDomain),N(E,this.cookieDomain),this.isTrackingDisabled()?(this.anonymousId=_(),this.sessionId=void 0,this.sessionStartTime=void 0):(this.anonymousId=R(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 ss={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"};/*! Bundled license information:
|
|
6
6
|
|
|
7
7
|
tiny-lru/dist/tiny-lru.js:
|
|
8
8
|
(**
|
package/dist/node/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var Me=Object.create;var ie=Object.defineProperty;var Fe=Object.getOwnPropertyDescriptor;var je=Object.getOwnPropertyNames;var qe=Object.getPrototypeOf,Ge=Object.prototype.hasOwnProperty;var Ke=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Ve=(e,t,s,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of je(t))!Ge.call(e,r)&&r!==s&&ie(e,r,{get:()=>t[r],enumerable:!(i=Fe(t,r))||i.enumerable});return e};var Be=(e,t,s)=>(s=e!=null?Me(qe(e)):{},Ve(ie(s,"default",{value:e,enumerable:!0}),e));var ue=Ke(b=>{Object.defineProperty(b,"__esModule",{value:!0});b.clearGlobalNamespace=b.getGlobalisedValue=void 0;var We="globalise__singleton__",Je={},oe=()=>typeof window<"u"?window:typeof globalThis<"u"?globalThis:Je,Ye=(e,t)=>{if(typeof e!="string")throw "Invalid namespace key";if(typeof t!="string")throw "Invalid item key"},ae=e=>`${We}${e}`,le=e=>{let t=oe(),s=ae(e);return t[s]||(t[s]={}),t[s]},Xe=(e,t)=>le(e)[t]||void 0,Qe=(e,t,s)=>{let i=le(e);i[t]=s;},Ze=(e,t,s)=>{Ye(e,t);let i=Xe(e,t);return i!==void 0?i:(Qe(e,t,s),s)};b.getGlobalisedValue=Ze;var et=e=>{let t=oe(),s=ae(e);t[s]!==void 0&&delete t[s];};b.clearGlobalNamespace=et;});var M=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 o=this.last,a=n.next,l=n.prev;this.first===n&&(this.first=n.next),n.next=null,n.prev=this.last,o.next=n,l!==null&&(l.next=a),a!==null&&(a.prev=l);}}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 re(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 M(e,t,s)}var ze={max:1e3},ne=(e,t={})=>{let{cache:s,cacheKeyResolver:i=F,onHit:r,lruOptions:n={}}=t,o={...ze,...n},a=s||re(o.max,o.ttl);function l(...h){let f=i(...h),c=a.get(f);if(a.has(f))return r&&r(f,c,a),c;let p=e.apply(this,h);return a.set(f,p),p}return l._cache=a,l},F=(...e)=>e.length===0?"no-args":e.map(t=>t===void 0?"undefined":t===null?"null":Array.isArray(t)?`[${F(...t)}]`:typeof t=="object"?`{${F(...He(t))}}`:JSON.stringify(t)).join(","),He=e=>Object.entries(e).sort((t,s)=>t[0]<s[0]?-1:1);var B=Be(ue()),tt=Object.defineProperty,st=(e,t)=>{for(var s in t)tt(e,s,{get:t[s],enumerable:!0});},it={};st(it,{deleteItem:()=>at,getItem:()=>q,setItem:()=>C});var O=()=>typeof window>"u",de=()=>!O(),rt="__IMX-",z=()=>de()&&window.localStorage,nt=e=>{if(e!==null)try{return JSON.parse(e)}catch{return e}},ot=e=>typeof e=="string"?e:JSON.stringify(e),H=e=>`${rt}${e}`;function q(e){if(z())return nt(window.localStorage.getItem(H(e)))}var C=(e,t)=>z()?(window.localStorage.setItem(H(e),ot(t)),!0):!1,at=e=>z()?(window.localStorage.removeItem(H(e)),!0):!1,G=0,lt=e=>{let t=parseInt(e,10)*1e3,s=new Date(t),i=new Date;return G=s.getTime()-i.getTime(),G},ut=()=>{let e=new Date().getTime()+G;return new Date(e).toISOString()},ct=(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))(ct||{}),dt="https://api.immutable.com",ht=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 he(e,t){let s=JSON.stringify(t),i={payload:ht(s)},r=await fetch(`${dt}${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 y,v,pt=()=>{y=q("metrics-events")||[],v=q("metrics-runtime")||{};};pt();var w=(e,t)=>{v={...v,[e]:t},C("metrics-runtime",v);},K=e=>{if(v[e]!==void 0)return v[e]},ft=()=>v,mt=()=>y,gt=e=>{y.push(e),C("metrics-events",y);},yt=e=>{y=y.slice(e),C("metrics-events",y);},pe=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},j="2.15.1-alpha.
|
|
1
|
+
var Me=Object.create;var ie=Object.defineProperty;var Fe=Object.getOwnPropertyDescriptor;var je=Object.getOwnPropertyNames;var qe=Object.getPrototypeOf,Ge=Object.prototype.hasOwnProperty;var Ke=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Ve=(e,t,s,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of je(t))!Ge.call(e,r)&&r!==s&&ie(e,r,{get:()=>t[r],enumerable:!(i=Fe(t,r))||i.enumerable});return e};var Be=(e,t,s)=>(s=e!=null?Me(qe(e)):{},Ve(ie(s,"default",{value:e,enumerable:!0}),e));var ue=Ke(b=>{Object.defineProperty(b,"__esModule",{value:!0});b.clearGlobalNamespace=b.getGlobalisedValue=void 0;var We="globalise__singleton__",Je={},oe=()=>typeof window<"u"?window:typeof globalThis<"u"?globalThis:Je,Ye=(e,t)=>{if(typeof e!="string")throw "Invalid namespace key";if(typeof t!="string")throw "Invalid item key"},ae=e=>`${We}${e}`,le=e=>{let t=oe(),s=ae(e);return t[s]||(t[s]={}),t[s]},Xe=(e,t)=>le(e)[t]||void 0,Qe=(e,t,s)=>{let i=le(e);i[t]=s;},Ze=(e,t,s)=>{Ye(e,t);let i=Xe(e,t);return i!==void 0?i:(Qe(e,t,s),s)};b.getGlobalisedValue=Ze;var et=e=>{let t=oe(),s=ae(e);t[s]!==void 0&&delete t[s];};b.clearGlobalNamespace=et;});var M=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 o=this.last,a=n.next,l=n.prev;this.first===n&&(this.first=n.next),n.next=null,n.prev=this.last,o.next=n,l!==null&&(l.next=a),a!==null&&(a.prev=l);}}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 re(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 M(e,t,s)}var ze={max:1e3},ne=(e,t={})=>{let{cache:s,cacheKeyResolver:i=F,onHit:r,lruOptions:n={}}=t,o={...ze,...n},a=s||re(o.max,o.ttl);function l(...h){let f=i(...h),c=a.get(f);if(a.has(f))return r&&r(f,c,a),c;let p=e.apply(this,h);return a.set(f,p),p}return l._cache=a,l},F=(...e)=>e.length===0?"no-args":e.map(t=>t===void 0?"undefined":t===null?"null":Array.isArray(t)?`[${F(...t)}]`:typeof t=="object"?`{${F(...He(t))}}`:JSON.stringify(t)).join(","),He=e=>Object.entries(e).sort((t,s)=>t[0]<s[0]?-1:1);var B=Be(ue()),tt=Object.defineProperty,st=(e,t)=>{for(var s in t)tt(e,s,{get:t[s],enumerable:!0});},it={};st(it,{deleteItem:()=>at,getItem:()=>q,setItem:()=>C});var O=()=>typeof window>"u",de=()=>!O(),rt="__IMX-",z=()=>de()&&window.localStorage,nt=e=>{if(e!==null)try{return JSON.parse(e)}catch{return e}},ot=e=>typeof e=="string"?e:JSON.stringify(e),H=e=>`${rt}${e}`;function q(e){if(z())return nt(window.localStorage.getItem(H(e)))}var C=(e,t)=>z()?(window.localStorage.setItem(H(e),ot(t)),!0):!1,at=e=>z()?(window.localStorage.removeItem(H(e)),!0):!1,G=0,lt=e=>{let t=parseInt(e,10)*1e3,s=new Date(t),i=new Date;return G=s.getTime()-i.getTime(),G},ut=()=>{let e=new Date().getTime()+G;return new Date(e).toISOString()},ct=(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))(ct||{}),dt="https://api.immutable.com",ht=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 he(e,t){let s=JSON.stringify(t),i={payload:ht(s)},r=await fetch(`${dt}${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 y,v,pt=()=>{y=q("metrics-events")||[],v=q("metrics-runtime")||{};};pt();var w=(e,t)=>{v={...v,[e]:t},C("metrics-runtime",v);},K=e=>{if(v[e]!==void 0)return v[e]},ft=()=>v,mt=()=>y,gt=e=>{y.push(e),C("metrics-events",y);},yt=e=>{y=y.slice(e),C("metrics-events",y);},pe=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},j="2.15.1-alpha.5",vt=()=>O()?"":window.location.ancestorOrigins&&window.location.ancestorOrigins.length>0?new URL(window.location.ancestorOrigins[0]).hostname:document.referrer?new URL(window.document.referrer).hostname:"",wt=()=>{if(O())return "";let e;try{window.self!==window.top&&(e=vt());}catch{}return e||(e=window.location.hostname),e},It=()=>{if(w("sdkVersion",j),O())return {browser:"nodejs",sdkVersion:j};let e=wt();return e&&w("domain",e),{sdkVersion:j,browser:window.navigator.userAgent,domain:e,tz:Intl.DateTimeFormat().resolvedOptions().timeZone,screen:`${window.screen.width}x${window.screen.height}`}},V=!1,bt=()=>V,St=async()=>{V=!0;try{let e=pe(It()),t=K("rid"),s=K("uid"),i=await he("/v1/sdk/initialise",{version:1,data:{runtimeDetails:e,runtimeId:t,uId:s}}),{runtimeId:r,sTime:n}=i;w("rid",r),lt(n);}catch{V=!1;}};function d(e,t){return (...s)=>{try{let i=e(...s);return i instanceof Promise?i.catch(()=>t):i}catch{return t}}}function Et(){return de()||typeof process>"u"?!1:process.env.JEST_WORKER_ID!==void 0}var xt=d(Et,!1),fe="imtbl__metrics",_t=5e3,kt=1e3,P=(e,t)=>(0, B.getGlobalisedValue)(fe,e,t),Pt=(e,t)=>{let s=ne(t,{lruOptions:{ttl:_t,max:kt}});return (0, B.getGlobalisedValue)(fe,e,s)},Tt=5e3,Nt=(e,t,s)=>{let i={event:`${e}.${t}`,time:ut(),...s&&{properties:pe(s)}};gt(i);},S=d(Pt("track",Nt)),At=async()=>{if(bt()===!1){await St();return}let e=mt();if(e.length===0)return;let t=e.length,s=ft();await he("/v1/sdk/metrics",{version:1,data:{events:e,details:s}})instanceof Error||yt(t);},Ot=d(At),me=async()=>{await Ot(),setTimeout(me,Tt);},ce=!1,Ct=()=>{ce||(ce=!0,me());};xt()||d(P("startFlushing",Ct))();var Ft=(e,t,s,i)=>{let{message:r}=s,n=s.stack||"",{cause:o}=s;o instanceof Error&&(n=`${n}
|
|
2
2
|
Cause: ${o.message}
|
|
3
|
-
${o.stack}`),S(e,`trackError_${t}`,{...i||{},errorMessage:r,errorStack:n,isTrackError:!0});},ge=d(Ft),Gt=e=>{w("env",e);};d(P("setEnvironment",Gt));var Kt=e=>{w("passportClientId",e);};d(P("setPassportClientId",Kt));var Vt=e=>{w("pak",e);};d(P("setPublishableApiKey",Vt));d(P("getDetail",K));var Bt={Passport:"passport",Steam:"steam",Epic:"epic",Google:"google",Apple:"apple",Discord:"discord",Email:"email",Custom:"custom"},zt="pk_imapik-test-",Ht="/v1/audience/messages",Wt="/v1/audience/tracking-consent",x="imtbl_anon_id",E="_imtbl_sid",we="session_start",Ie="session_end",be=e=>e.startsWith(zt)?"https://api.sandbox.immutable.com":"https://api.immutable.com",T=()=>typeof window<"u"&&typeof document<"u",_=()=>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)}),Se=()=>new Date().toISOString();function $(e){if(!T())return;let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):void 0}function D(e,t,s,i){if(!T())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 N(e,t){D(e,"",0,t);}function R(e){let t=$(x);if(t)return t;let s=_();return D(x,s,63072e3,e),s}var W=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;}},J=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 Ee(e,t,s){if(e.status===0)return new J({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 J({code:"VALIDATION_REJECTED",message:`Backend rejected ${r} of ${r+n} messages`,status:e.status,endpoint:e.endpoint,responseBody:e.body})}return new J({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 xe(e,t){if(e)try{e(t);}catch{}}async function ye(e){let t=e.headers?.get?.("content-type")??"";try{return t.includes("application/json")?await e.json():await e.text()}catch{return}}var X=async(e,t,s,i)=>{try{let r=await fetch(e,{method:i?.method??"POST",headers:{"Content-Type":"application/json","x-immutable-publishable-key":t},body:JSON.stringify(s),keepalive:i?.keepalive});if(!r.ok){let o=await ye(r);return S("audience","transport_send_failed",{status:r.status}),{ok:!1,error:new W({status:r.status,endpoint:e,body:o})}}let n=await ye(r);if(typeof n=="object"&&n!==null&&"rejected"in n){let o=n.rejected??0;if(o>0)return S("audience","transport_partial_rejected",{status:r.status,rejected:o}),{ok:!1,error:new W({status:r.status,endpoint:e,body:n})}}return {ok:!0}}catch(r){let n=new W({status:0,endpoint:e,cause:r});return ge("audience","transport_send",n),{ok:!1,error:n}}},Q="__imtbl_audience_";function Z(){try{return T()&&typeof localStorage<"u"}catch{return !1}}function Jt(e,t=Q){if(Z())try{let s=localStorage.getItem(`${t}${e}`);return s?JSON.parse(s):void 0}catch{return}}function Yt(e,t,s=Q){if(Z())try{localStorage.setItem(`${s}${e}`,JSON.stringify(t));}catch{}}function Xt(e,t=Q){if(Z())try{localStorage.removeItem(`${t}${e}`);}catch{}}var Y="queue",ve=100,_e=class{constructor(e,t,s){this.send=e,this.publishableKey=t,this.endpointUrl=`${s?.baseUrl??be(t)}${Ht}`,this.flushIntervalMs=s?.flushIntervalMs??5e3,this.flushSize=s?.flushSize??20,this.onFlush=s?.onFlush,this.onError=s?.onError,this.storagePrefix=s?.storagePrefix;let i=Jt(Y,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;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)){this.flushing=!0;try{let e=this.messages.slice(0,ve),t={messages:e},s=await this.send(this.endpointUrl,this.publishableKey,t),i;!s.ok&&s.error&&(i=Ee(s.error,"flush",e.length));let r=i?.code==="VALIDATION_REJECTED";(s.ok||r)&&(this.messages=this.messages.slice(e.length),this.persist()),this.onFlush?.(s.ok,e.length),i&&xe(this.onError,i);}finally{this.flushing=!1;}}}flushUnload(){if(this.flushing||this.messages.length===0)return;let e=this.messages.slice(0,ve),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=[],Xt(Y,this.storagePrefix);}registerUnload(){!T()||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);}persist(){Yt(Y,this.messages,this.storagePrefix);}},Qt="2.15.1-alpha.4";function ke(e="@imtbl/audience",t=Qt){let s={library:e,libraryVersion:t};return T()&&(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 Pe(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 Te(e,t,s,i){return e!==s||t!==i}function A(e,t=256){return e.length>t?e.slice(0,t):e}function k(e){let t=$(E);if(t)return D(E,t,1800,e),{sessionId:t,isNew:!1};let s=_();return D(E,s,1800,e),{sessionId:s,isNew:!0}}var Ne=["utm_source","utm_medium","utm_campaign","utm_content","utm_term"],Ae=["gclid","dclid","fbclid","ttclid","msclkid","li_fat_id"],Oe="__imtbl_attribution";function Zt(e){let t;try{t=new URL(e).searchParams;}catch{return {}}let s={};for(let r of [...Ne,...Ae]){let n=t.get(r);n&&(s[r]=n);}let i=t.get("referral_code");return i&&(s.referral_code=i),s}function es(){try{let e=sessionStorage.getItem(Oe);return e?JSON.parse(e):null}catch{return null}}function ts(e){try{sessionStorage.setItem(Oe,JSON.stringify(e));}catch{}}function Ce(){let e=es();if(e)return e;let t=typeof window<"u"&&window.location?Zt(window.location.href):{},s=typeof document<"u"&&document.referrer||void 0,i=typeof window<"u"&&window.location?window.location.href:void 0,r=Ae.some(a=>a in t),n=Ne.some(a=>a in t),o={...t,referrer:s,landing_page:i,touchpoint_type:r||n?"click":void 0};return ts(o),o}function m(e){return e!=="none"}function I(e){return e==="full"}function De(e,t,s,i,r,n,o,a){let l=n??"none",h={none:0,anonymous:1,full:2};function f(c){let u=`${a??be(s)}${Wt}`;t(u,s,{anonymousId:i,status:c,source:r},{method:"PUT",keepalive:!0}).then(p=>{!p.ok&&p.error&&xe(o,Ee(p.error,"consent"));});}return {get level(){return l},setLevel(c){c!==l&&(h[c]<h[l]&&(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,...U}=u;return U}return u}))),l=c,f(c));}}}var $e="@imtbl/audience",Re="2.15.1-alpha.4",g="[audience]",Le="WebSDK";var L=class{enabled;constructor(t=!1){this.enabled=t;}logEvent(t,s){this.enabled&&console.log(`${g} ${t}`,s);}logFlush(t,s){this.enabled&&console.log(`${g} flush ${t?"ok":"failed"} (${s} messages)`);}logConsent(t,s){this.enabled&&console.log(`${g} consent ${t} \u2192 ${s}`);}logWarning(t){this.enabled&&console.warn(`${g} ${t}`);}};var ee=class e{static liveInstances=0;queue;consent;attribution;debug;cookieDomain;anonymousId;sessionId;sessionStartTime;userId;isFirstPage=!0;destroyed=!1;constructor(t){let{cookieDomain:s,publishableKey:i}=t,r=t.consent??"none",n=Le;this.cookieDomain=s,this.debug=new L(t.debug??!1);let o=!1;m(r)?(this.anonymousId=R(s),o=this.startSession()):this.anonymousId=$(x)??_(),this.queue=new _e(X,i,{baseUrl:t.baseUrl,flushIntervalMs:t.flushInterval,flushSize:t.flushSize,onFlush:(a,l)=>this.debug.logFlush(a,l),staleFilter:a=>Pe(a.eventTimestamp),storagePrefix:"__imtbl_web_"}),this.consent=De(this.queue,X,i,this.anonymousId,n,r,void 0,t.baseUrl),this.attribution=Ce(),this.isTrackingDisabled()||(this.queue.start(),o&&this.trackSessionStart());}static init(t){if(!t.publishableKey?.trim())throw new Error(`${g} publishableKey is required`);return e.liveInstances>0&&console.warn(`${g} Multiple SDK instances detected. Ensure previous instances are shut down to avoid duplicate events.`),e.liveInstances+=1,new e(t)}isTrackingDisabled(){return !m(this.consent.level)}effectiveUserId(){return I(this.consent.level)?this.userId:void 0}startSession(){let t=k(this.cookieDomain);return this.sessionId=t.sessionId,this.sessionStartTime=Date.now(),t.isNew}baseMessage(){return {messageId:_(),eventTimestamp:Se(),anonymousId:this.anonymousId,surface:"web",context:ke($e,Re)}}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:we,properties:{sessionId:this.sessionId,...this.attribution}});}trackSessionEnd(){this.sessionId&&this.enqueue("track(session_end)",{...this.baseMessage(),type:"track",eventName:Ie,properties:{sessionId:this.sessionId,...this.sessionStartTime&&{duration:Math.round((Date.now()-this.sessionStartTime)/1e3)}}});}page(t){if(this.isTrackingDisabled())return;k(this.cookieDomain);let s={...t};this.isFirstPage&&(Object.assign(s,this.attribution),this.isFirstPage=!1),this.enqueue("page",{...this.baseMessage(),type:"page",properties:Object.keys(s).length>0?s:void 0,userId:this.effectiveUserId()});}track(t,...s){if(this.isTrackingDisabled())return;k(this.cookieDomain);let[i]=s;this.enqueue("track",{...this.baseMessage(),type:"track",eventName:A(t),properties:i,userId:this.effectiveUserId()});}identify(t,s,i){if(!I(this.consent.level)){this.debug.logWarning("identify() requires full consent \u2014 call ignored.");return}if(k(this.cookieDomain),t!==null&&typeof t=="object"&&!Array.isArray(t)){this.enqueue("identify",{...this.baseMessage(),type:"identify",traits:t});return}if(typeof t!="string")return;let r=A(t);this.userId=r,this.enqueue("identify",{...this.baseMessage(),type:"identify",userId:r,identityType:s,traits:i});}alias(t,s){if(!I(this.consent.level)){this.debug.logWarning("alias() requires full consent \u2014 call ignored.");return}if(!Te(t.id,t.identityType,s.id,s.identityType)){this.debug.logWarning("alias() from and to are identical \u2014 call ignored.");return}k(this.cookieDomain),this.enqueue("alias",{...this.baseMessage(),type:"alias",fromId:A(t.id),fromType:t.identityType,toId:A(s.id),toType:s.identityType});}setConsent(t){let s=this.consent.level;if(t===s)return;this.debug.logConsent(s,t);let i=!m(s)&&m(t);if(i&&(this.anonymousId=R(this.cookieDomain)),m(t)||this.queue.stop(),this.consent.setLevel(t),m(t)?I(s)&&!I(t)&&(this.userId=void 0):(N(x,this.cookieDomain),N(E,this.cookieDomain)),i){this.isFirstPage=!0;let r=this.startSession();this.queue.start(),r&&this.trackSessionStart();}}reset(){this.userId=void 0,this.queue.clear(),N(x,this.cookieDomain),N(E,this.cookieDomain),this.isTrackingDisabled()?(this.anonymousId=_(),this.sessionId=void 0,this.sessionStartTime=void 0):(this.anonymousId=R(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 ss={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"};/*! Bundled license information:
|
|
3
|
+
${o.stack}`),S(e,`trackError_${t}`,{...i||{},errorMessage:r,errorStack:n,isTrackError:!0});},ge=d(Ft),Gt=e=>{w("env",e);};d(P("setEnvironment",Gt));var Kt=e=>{w("passportClientId",e);};d(P("setPassportClientId",Kt));var Vt=e=>{w("pak",e);};d(P("setPublishableApiKey",Vt));d(P("getDetail",K));var Bt={Passport:"passport",Steam:"steam",Epic:"epic",Google:"google",Apple:"apple",Discord:"discord",Email:"email",Custom:"custom"},zt="pk_imapik-test-",Ht="/v1/audience/messages",Wt="/v1/audience/tracking-consent",x="imtbl_anon_id",E="_imtbl_sid",we="session_start",Ie="session_end",be=e=>e.startsWith(zt)?"https://api.sandbox.immutable.com":"https://api.immutable.com",T=()=>typeof window<"u"&&typeof document<"u",_=()=>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)}),Se=()=>new Date().toISOString();function $(e){if(!T())return;let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):void 0}function D(e,t,s,i){if(!T())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 N(e,t){D(e,"",0,t);}function R(e){let t=$(x);if(t)return t;let s=_();return D(x,s,63072e3,e),s}var W=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;}},J=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 Ee(e,t,s){if(e.status===0)return new J({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 J({code:"VALIDATION_REJECTED",message:`Backend rejected ${r} of ${r+n} messages`,status:e.status,endpoint:e.endpoint,responseBody:e.body})}return new J({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 xe(e,t){if(e)try{e(t);}catch{}}async function ye(e){let t=e.headers?.get?.("content-type")??"";try{return t.includes("application/json")?await e.json():await e.text()}catch{return}}var X=async(e,t,s,i)=>{try{let r=await fetch(e,{method:i?.method??"POST",headers:{"Content-Type":"application/json","x-immutable-publishable-key":t},body:JSON.stringify(s),keepalive:i?.keepalive});if(!r.ok){let o=await ye(r);return S("audience","transport_send_failed",{status:r.status}),{ok:!1,error:new W({status:r.status,endpoint:e,body:o})}}let n=await ye(r);if(typeof n=="object"&&n!==null&&"rejected"in n){let o=n.rejected??0;if(o>0)return S("audience","transport_partial_rejected",{status:r.status,rejected:o}),{ok:!1,error:new W({status:r.status,endpoint:e,body:n})}}return {ok:!0}}catch(r){let n=new W({status:0,endpoint:e,cause:r});return ge("audience","transport_send",n),{ok:!1,error:n}}},Q="__imtbl_audience_";function Z(){try{return T()&&typeof localStorage<"u"}catch{return !1}}function Jt(e,t=Q){if(Z())try{let s=localStorage.getItem(`${t}${e}`);return s?JSON.parse(s):void 0}catch{return}}function Yt(e,t,s=Q){if(Z())try{localStorage.setItem(`${s}${e}`,JSON.stringify(t));}catch{}}function Xt(e,t=Q){if(Z())try{localStorage.removeItem(`${t}${e}`);}catch{}}var Y="queue",ve=100,_e=class{constructor(e,t,s){this.send=e,this.publishableKey=t,this.endpointUrl=`${s?.baseUrl??be(t)}${Ht}`,this.flushIntervalMs=s?.flushIntervalMs??5e3,this.flushSize=s?.flushSize??20,this.onFlush=s?.onFlush,this.onError=s?.onError,this.storagePrefix=s?.storagePrefix;let i=Jt(Y,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;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)){this.flushing=!0;try{let e=this.messages.slice(0,ve),t={messages:e},s=await this.send(this.endpointUrl,this.publishableKey,t),i;!s.ok&&s.error&&(i=Ee(s.error,"flush",e.length));let r=i?.code==="VALIDATION_REJECTED";(s.ok||r)&&(this.messages=this.messages.slice(e.length),this.persist()),this.onFlush?.(s.ok,e.length),i&&xe(this.onError,i);}finally{this.flushing=!1;}}}flushUnload(){if(this.flushing||this.messages.length===0)return;let e=this.messages.slice(0,ve),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=[],Xt(Y,this.storagePrefix);}registerUnload(){!T()||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);}persist(){Yt(Y,this.messages,this.storagePrefix);}},Qt="2.15.1-alpha.5";function ke(e="@imtbl/audience",t=Qt){let s={library:e,libraryVersion:t};return T()&&(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 Pe(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 Te(e,t,s,i){return e!==s||t!==i}function A(e,t=256){return e.length>t?e.slice(0,t):e}function k(e){let t=$(E);if(t)return D(E,t,1800,e),{sessionId:t,isNew:!1};let s=_();return D(E,s,1800,e),{sessionId:s,isNew:!0}}var Ne=["utm_source","utm_medium","utm_campaign","utm_content","utm_term"],Ae=["gclid","dclid","fbclid","ttclid","msclkid","li_fat_id"],Oe="__imtbl_attribution";function Zt(e){let t;try{t=new URL(e).searchParams;}catch{return {}}let s={};for(let r of [...Ne,...Ae]){let n=t.get(r);n&&(s[r]=n);}let i=t.get("referral_code");return i&&(s.referral_code=i),s}function es(){try{let e=sessionStorage.getItem(Oe);return e?JSON.parse(e):null}catch{return null}}function ts(e){try{sessionStorage.setItem(Oe,JSON.stringify(e));}catch{}}function Ce(){let e=es();if(e)return e;let t=typeof window<"u"&&window.location?Zt(window.location.href):{},s=typeof document<"u"&&document.referrer||void 0,i=typeof window<"u"&&window.location?window.location.href:void 0,r=Ae.some(a=>a in t),n=Ne.some(a=>a in t),o={...t,referrer:s,landing_page:i,touchpoint_type:r||n?"click":void 0};return ts(o),o}function m(e){return e!=="none"}function I(e){return e==="full"}function De(e,t,s,i,r,n,o,a){let l=n??"none",h={none:0,anonymous:1,full:2};function f(c){let u=`${a??be(s)}${Wt}`;t(u,s,{anonymousId:i,status:c,source:r},{method:"PUT",keepalive:!0}).then(p=>{!p.ok&&p.error&&xe(o,Ee(p.error,"consent"));});}return {get level(){return l},setLevel(c){c!==l&&(h[c]<h[l]&&(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,...U}=u;return U}return u}))),l=c,f(c));}}}var $e="@imtbl/audience",Re="2.15.1-alpha.5",g="[audience]",Le="WebSDK";var L=class{enabled;constructor(t=!1){this.enabled=t;}logEvent(t,s){this.enabled&&console.log(`${g} ${t}`,s);}logFlush(t,s){this.enabled&&console.log(`${g} flush ${t?"ok":"failed"} (${s} messages)`);}logConsent(t,s){this.enabled&&console.log(`${g} consent ${t} \u2192 ${s}`);}logWarning(t){this.enabled&&console.warn(`${g} ${t}`);}};var ee=class e{static liveInstances=0;queue;consent;attribution;debug;cookieDomain;anonymousId;sessionId;sessionStartTime;userId;isFirstPage=!0;destroyed=!1;constructor(t){let{cookieDomain:s,publishableKey:i}=t,r=t.consent??"none",n=Le;this.cookieDomain=s,this.debug=new L(t.debug??!1);let o=!1;m(r)?(this.anonymousId=R(s),o=this.startSession()):this.anonymousId=$(x)??_(),this.queue=new _e(X,i,{baseUrl:t.baseUrl,flushIntervalMs:t.flushInterval,flushSize:t.flushSize,onFlush:(a,l)=>this.debug.logFlush(a,l),staleFilter:a=>Pe(a.eventTimestamp),storagePrefix:"__imtbl_web_"}),this.consent=De(this.queue,X,i,this.anonymousId,n,r,void 0,t.baseUrl),this.attribution=Ce(),this.isTrackingDisabled()||(this.queue.start(),o&&this.trackSessionStart());}static init(t){if(!t.publishableKey?.trim())throw new Error(`${g} publishableKey is required`);return e.liveInstances>0&&console.warn(`${g} Multiple SDK instances detected. Ensure previous instances are shut down to avoid duplicate events.`),e.liveInstances+=1,new e(t)}isTrackingDisabled(){return !m(this.consent.level)}effectiveUserId(){return I(this.consent.level)?this.userId:void 0}startSession(){let t=k(this.cookieDomain);return this.sessionId=t.sessionId,this.sessionStartTime=Date.now(),t.isNew}baseMessage(){return {messageId:_(),eventTimestamp:Se(),anonymousId:this.anonymousId,surface:"web",context:ke($e,Re)}}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:we,properties:{sessionId:this.sessionId,...this.attribution}});}trackSessionEnd(){this.sessionId&&this.enqueue("track(session_end)",{...this.baseMessage(),type:"track",eventName:Ie,properties:{sessionId:this.sessionId,...this.sessionStartTime&&{duration:Math.round((Date.now()-this.sessionStartTime)/1e3)}}});}page(t){if(this.isTrackingDisabled())return;k(this.cookieDomain);let s={...t};this.isFirstPage&&(Object.assign(s,this.attribution),this.isFirstPage=!1),this.enqueue("page",{...this.baseMessage(),type:"page",properties:Object.keys(s).length>0?s:void 0,userId:this.effectiveUserId()});}track(t,...s){if(this.isTrackingDisabled())return;k(this.cookieDomain);let[i]=s;this.enqueue("track",{...this.baseMessage(),type:"track",eventName:A(t),properties:i,userId:this.effectiveUserId()});}identify(t,s,i){if(!I(this.consent.level)){this.debug.logWarning("identify() requires full consent \u2014 call ignored.");return}if(k(this.cookieDomain),t!==null&&typeof t=="object"&&!Array.isArray(t)){this.enqueue("identify",{...this.baseMessage(),type:"identify",traits:t});return}if(typeof t!="string")return;let r=A(t);this.userId=r,this.enqueue("identify",{...this.baseMessage(),type:"identify",userId:r,identityType:s,traits:i});}alias(t,s){if(!I(this.consent.level)){this.debug.logWarning("alias() requires full consent \u2014 call ignored.");return}if(!Te(t.id,t.identityType,s.id,s.identityType)){this.debug.logWarning("alias() from and to are identical \u2014 call ignored.");return}k(this.cookieDomain),this.enqueue("alias",{...this.baseMessage(),type:"alias",fromId:A(t.id),fromType:t.identityType,toId:A(s.id),toType:s.identityType});}setConsent(t){let s=this.consent.level;if(t===s)return;this.debug.logConsent(s,t);let i=!m(s)&&m(t);if(i&&(this.anonymousId=R(this.cookieDomain)),m(t)||this.queue.stop(),this.consent.setLevel(t),m(t)?I(s)&&!I(t)&&(this.userId=void 0):(N(x,this.cookieDomain),N(E,this.cookieDomain)),i){this.isFirstPage=!0;let r=this.startSession();this.queue.start(),r&&this.trackSessionStart();}}reset(){this.userId=void 0,this.queue.clear(),N(x,this.cookieDomain),N(E,this.cookieDomain),this.isTrackingDisabled()?(this.anonymousId=_(),this.sessionId=void 0,this.sessionStartTime=void 0):(this.anonymousId=R(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 ss={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"};/*! Bundled license information:
|
|
4
4
|
|
|
5
5
|
tiny-lru/dist/tiny-lru.js:
|
|
6
6
|
(**
|
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.15.1-alpha.
|
|
4
|
+
"version": "2.15.1-alpha.5",
|
|
5
5
|
"author": "Immutable",
|
|
6
6
|
"bugs": "https://github.com/immutable/ts-immutable-sdk/issues",
|
|
7
7
|
"devDependencies": {
|