@frak-labs/components 1.5.0-beta.92148223 → 1.5.0-beta.94832d46

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/cdn/components.js CHANGED
@@ -1 +1 @@
1
- import(`https://cdn.jsdelivr.net/npm/@frak-labs/components@1.5.0-beta.92148223/cdn/loader.js`);
1
+ import(`https://cdn.jsdelivr.net/npm/@frak-labs/components@1.5.0-beta.94832d46/cdn/loader.js`);
package/cdn/loader.js CHANGED
@@ -118,23 +118,23 @@ var e=Object.defineProperty,t=(t,n)=>{let r=Object.setPrototypeOf({},null);for(v
118
118
  .sharedBaseCss_buttonReset__7cswil0:focus-visible {
119
119
  outline-color: currentColor;
120
120
  }
121
- `;function r(e,t){let n=document.getElementById(e);if(n){n.textContent!==t&&(n.textContent=t);return}let r=document.createElement(`style`);r.id=e,r.textContent=t,document.head.appendChild(r)}function i(e,t){let n=`frak-base-${e}`;if(document.getElementById(n)||!t)return;let r=document.createElement(`style`);r.id=n,r.textContent=t,document.head.appendChild(r)}function a(e,t,n){r(`frak-placement-${e}-${t}`,n)}const o={injectBase:i,injectPlacement:a};function s(e){document.readyState===`complete`||document.readyState===`interactive`?setTimeout(e,1):document.addEventListener(`DOMContentLoaded`,e)}const c=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,l=new TextEncoder;function u(e,t){if(!c.test(e))throw Error(`${t} must be a UUID string, got: ${e}`);return h(e.replace(/-/g,``))}function d(e,t,n){if(!Number.isInteger(n)||n<0)throw Error(`ts must be a non-negative integer: ${n}`);let r=BigInt(n);for(let n=7;n>=0;n--)e[t+n]=Number(r&255n),r>>=8n}function f(e){if(e.binding.length!==0&&e.binding.length!==32)throw Error(`binding must be empty or 32 bytes, got ${e.binding.length}`);let t=l.encode(e.op),n=new Uint8Array(t.length+32+32+8),r=0;return n.set(t,r),r+=t.length,n.set(u(e.merchantId,`merchantId`),r),r+=16,n.set(u(e.anonymousId,`anonymousId`),r),r+=16,n.set(e.binding,r),r+=32,d(n,r,e.ts),n}function p(e){if(e.length<16)throw Error(`deriveClientIdFromHash requires at least 16 bytes, got ${e.length}`);let t=e.slice(0,16);t[6]=t[6]&15|64,t[8]=t[8]&63|128;let n=m(t);return[n.slice(0,8),n.slice(8,12),n.slice(12,16),n.slice(16,20),n.slice(20,32)].join(`-`)}function m(e){return Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}function h(e){return Uint8Array.from(e.match(/../g)??[],e=>Number.parseInt(e,16))}function g(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function _(e){if(e.pk.length!==65)throw Error(`pk must be 65 bytes, got ${e.pk.length}`);if(e.sig.length!==64)throw Error(`sig must be 64 bytes, got ${e.sig.length}`);let t=/* @__PURE__ */ new Uint8Array(138);return t[0]=e.v,t.set(e.pk,1),d(t,66,e.ts),t.set(e.sig,74),g(t)}const v=e=>e/2**32|0,ee=e=>e>>>0;function y(e,t,n,r){let i=v(n),a=ee(n);e.setUint32(t,r?a:i,r),e.setUint32(t+4,r?i:a,r)}function b(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`&&`BYTES_PER_ELEMENT`in e&&e.BYTES_PER_ELEMENT===1}const x=e=>e?`"${e}" `:``;function S(e,t=``){if(typeof e!=`number`)throw TypeError(x(t)+`expected number, got `+typeof e);if(!Number.isSafeInteger(e)||e<0)throw RangeError(x(t)+`expected integer >= 0, got `+e);return e}function C(e,t,n=``){if(b(e)&&(t===void 0||e.length===t))return e;t!==void 0&&S(t,`length`);let r=b(e),i=t===void 0?``:` of length ${t}`,a=r?`length=${e.length}`:`type=${typeof e}`,o=x(n)+`expected Uint8Array`+i+`, got `+a;throw r?RangeError(o):TypeError(o)}function te(e){if(typeof e!=`function`||typeof e.create!=`function`)throw TypeError(`expected hash wrapped by utils.createHasher`);if(S(e.outputLen),S(e.blockLen),e.outputLen<1||e.blockLen<1)throw Error(`hash blockLen / outputLen must be >= 1`)}const ne=(e,t)=>{if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError((t===`object`?``:`"${t}" `)+`expected object, got type=`+typeof e)},w=(e,t)=>{ne(e,t);let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)throw TypeError(`"${t}" expected plain object`);if(Object.hasOwn(e,`__proto__`))throw TypeError(`"${t}.__proto__" is not allowed`)};function T(e,t=!0){if(e.destroyed)throw Error(`hash was destroyed`);if(t&&e.finished)throw Error(`digest() was already called`)}function E(e,t){C(e,void 0,`output`);let n=t.outputLen;if(!(e.length>=n))throw RangeError(`"output" expected length >= `+n)}function re(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function D(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function O(e,t){return e<<32-t|e>>>t}const k=typeof Uint8Array.from([]).toHex==`function`&&typeof Uint8Array.fromHex==`function`,ie=/* @__PURE__ */ Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function A(e){if(C(e),k)return e.toHex();let t=``;for(let n=0;n<e.length;n++)t+=ie[e[n]];return t}function ae(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function oe(e){if(typeof e!=`string`)throw TypeError(`hex string expected, got `+typeof e);if(k)try{return Uint8Array.fromHex(e)}catch(e){throw e instanceof SyntaxError?RangeError(e.message):e}let t=e.length,n=t/2;if(t%2)throw RangeError(`hex string expected, got unpadded hex of length `+t);let r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){let n=ae(e.charCodeAt(i)),a=ae(e.charCodeAt(i+1));if(n===void 0||a===void 0){let t=e[i]+e[i+1];throw RangeError(`hex string expected, got non-hex character "`+t+`" at index `+i)}r[t]=n*16+a}return r}function se(...e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];C(r),t+=r.length}let n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){let i=e[t];n.set(i,r),r+=i.length}return n}function ce(e,t,n=`opts`){return w(e,`defaults`),t!==void 0&&w(t,n),Object.assign(Object.create(null),e,t)}function le(e,t={}){if(typeof e!=`function`)throw TypeError(`"hashCons" expected function, got type=`+typeof e);t=ce({},t,`info`);let n=(t,n)=>e(n).update(t).digest(),r=e(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.canXOF=r.canXOF,n.create=t=>e(t),Object.assign(n,t),Object.freeze(n)}function ue(e=32){S(e,`bytesLength`);let t=typeof globalThis==`object`?globalThis.crypto:null;if(typeof t?.getRandomValues!=`function`)throw Error(`crypto.getRandomValues must be defined`);if(e>65536)throw RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}const de=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function fe(e,t,n){return e&t^~e&n}function pe(e,t,n){return e&t^e&n^t&n}var me=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,n,r){this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=D(this.buffer)}update(e){T(this),C(e);let{view:t,buffer:n,blockLen:r}=this,i=e.length,a=!1;for(let o=0;o<i;){let s=Math.min(r-this.pos,i-o);if(s===r){let t=D(e);for(;r<=i-o;o+=r)this.process(t,o);a=!0}else n.set(o===0&&s===i?e:e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===r&&(this.process(t,0),this.pos=0,a=!0)}return this.length+=e.length,a&&this.roundClean(),this}digestInto(e){T(this),E(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:r,isLE:i}=this,{pos:a}=this;t[a++]=128,t.fill(0,a),this.padOffset>r-a&&(this.process(n,0),t.fill(0)),y(n,r-8,this.length*8,i),this.process(n,0),this.roundClean();let o=e===t?n:D(e),s=this.outputLen,c=s/4,l=this.get();if(s%4||c>l.length)throw Error(`invalid outputLen`);for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneIntoMeta(e){let{buffer:t,length:n,finished:r,destroyed:i,pos:a}=this;return e.destroyed=i,e.finished=r,e.length=n,e.pos=a,a&&e.buffer.set(t),e}clone(){return this._cloneInto()}};const he=/* @__PURE__ */ Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ge=/* @__PURE__ */ Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),j=/* @__PURE__ */ new Uint32Array(64);var _e=class extends me{A=0;B=0;C=0;D=0;E=0;F=0;G=0;H=0;constructor(e,t){super(64,e,8,!1),this.A=t[0]|0,this.B=t[1]|0,this.C=t[2]|0,this.D=t[3]|0,this.E=t[4]|0,this.F=t[5]|0,this.G=t[6]|0,this.H=t[7]|0}get(){let{A:e,B:t,C:n,D:r,E:i,F:a,G:o,H:s}=this;return[e,t,n,r,i,a,o,s]}set(e,t,n,r,i,a,o,s){this.A=e|0,this.B=t|0,this.C=n|0,this.D=r|0,this.E=i|0,this.F=a|0,this.G=o|0,this.H=s|0}_cloneInto(e){return(e||=new this.constructor).set(...this.get()),this._cloneIntoMeta(e)}process(e,t){for(let n=0;n<16;n++,t+=4)j[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=j[e-15],n=j[e-2],r=O(t,7)^O(t,18)^t>>>3,i=O(n,17)^O(n,19)^n>>>10;j[e]=i+j[e-7]+r+j[e-16]|0}let{A:n,B:r,C:i,D:a,E:o,F:s,G:c,H:l}=this;for(let e=0;e<64;e++){let t=O(o,6)^O(o,11)^O(o,25),u=l+t+fe(o,s,c)+ge[e]+j[e]|0,d=(O(n,2)^O(n,13)^O(n,22))+pe(n,r,i)|0;l=c,c=s,s=o,o=a+u|0,a=i,i=r,r=n,n=u+d|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,s=s+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,a,o,s,c,l)}roundClean(){re(j)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),re(this.buffer)}},ve=class extends _e{constructor(){super(32,he)}};const ye=/* @__PURE__ */ le(()=>new ve,/* @__PURE__ */ de(1));
121
+ `;function r(e,t){let n=document.getElementById(e);if(n){n.textContent!==t&&(n.textContent=t);return}let r=document.createElement(`style`);r.id=e,r.textContent=t,document.head.appendChild(r)}function i(e,t){let n=`frak-base-${e}`;if(document.getElementById(n)||!t)return;let r=document.createElement(`style`);r.id=n,r.textContent=t,document.head.appendChild(r)}function a(e,t,n){r(`frak-placement-${e}-${t}`,n)}const o={injectBase:i,injectPlacement:a};function s(e){document.readyState===`complete`||document.readyState===`interactive`?setTimeout(e,1):document.addEventListener(`DOMContentLoaded`,e)}const c=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,l=new TextEncoder;function u(e,t){if(!c.test(e))throw Error(`${t} must be a UUID string, got: ${e}`);return h(e.replace(/-/g,``))}function d(e,t,n){if(!Number.isInteger(n)||n<0)throw Error(`ts must be a non-negative integer: ${n}`);let r=BigInt(n);for(let n=7;n>=0;n--)e[t+n]=Number(r&255n),r>>=8n}function f(e){if(e.binding.length!==0&&e.binding.length!==32)throw Error(`binding must be empty or 32 bytes, got ${e.binding.length}`);let t=l.encode(e.op),n=new Uint8Array(t.length+32+32+8),r=0;return n.set(t,r),r+=t.length,n.set(u(e.merchantId,`merchantId`),r),r+=16,n.set(u(e.anonymousId,`anonymousId`),r),r+=16,n.set(e.binding,r),r+=32,d(n,r,e.ts),n}function p(e){if(e.length<16)throw Error(`deriveClientIdFromHash requires at least 16 bytes, got ${e.length}`);let t=e.slice(0,16);t[6]=t[6]&15|64,t[8]=t[8]&63|128;let n=m(t);return[n.slice(0,8),n.slice(8,12),n.slice(12,16),n.slice(16,20),n.slice(20,32)].join(`-`)}function m(e){return Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}function h(e){return Uint8Array.from(e.match(/../g)??[],e=>Number.parseInt(e,16))}function g(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function _(e){if(e.pk.length!==65)throw Error(`pk must be 65 bytes, got ${e.pk.length}`);if(e.sig.length!==64)throw Error(`sig must be 64 bytes, got ${e.sig.length}`);let t=/* @__PURE__ */ new Uint8Array(138);return t[0]=e.v,t.set(e.pk,1),d(t,66,e.ts),t.set(e.sig,74),g(t)}const v=e=>e/2**32|0,y=e=>e>>>0;function b(e,t,n,r){let i=v(n),a=y(n);e.setUint32(t,r?a:i,r),e.setUint32(t+4,r?i:a,r)}function x(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`&&`BYTES_PER_ELEMENT`in e&&e.BYTES_PER_ELEMENT===1}const S=e=>e?`"${e}" `:``;function C(e,t=``){if(typeof e!=`number`)throw TypeError(S(t)+`expected number, got `+typeof e);if(!Number.isSafeInteger(e)||e<0)throw RangeError(S(t)+`expected integer >= 0, got `+e);return e}function w(e,t,n=``){if(x(e)&&(t===void 0||e.length===t))return e;t!==void 0&&C(t,`length`);let r=x(e),i=t===void 0?``:` of length ${t}`,a=r?`length=${e.length}`:`type=${typeof e}`,o=S(n)+`expected Uint8Array`+i+`, got `+a;throw r?RangeError(o):TypeError(o)}function ee(e){if(typeof e!=`function`||typeof e.create!=`function`)throw TypeError(`expected hash wrapped by utils.createHasher`);if(C(e.outputLen),C(e.blockLen),e.outputLen<1||e.blockLen<1)throw Error(`hash blockLen / outputLen must be >= 1`)}const te=(e,t)=>{if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError((t===`object`?``:`"${t}" `)+`expected object, got type=`+typeof e)},T=(e,t)=>{te(e,t);let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)throw TypeError(`"${t}" expected plain object`);if(Object.hasOwn(e,`__proto__`))throw TypeError(`"${t}.__proto__" is not allowed`)};function E(e,t=!0){if(e.destroyed)throw Error(`hash was destroyed`);if(t&&e.finished)throw Error(`digest() was already called`)}function D(e,t){w(e,void 0,`output`);let n=t.outputLen;if(!(e.length>=n))throw RangeError(`"output" expected length >= `+n)}function ne(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function O(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function k(e,t){return e<<32-t|e>>>t}const A=typeof Uint8Array.from([]).toHex==`function`&&typeof Uint8Array.fromHex==`function`,re=/* @__PURE__ */ Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function j(e){if(w(e),A)return e.toHex();let t=``;for(let n=0;n<e.length;n++)t+=re[e[n]];return t}function ie(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function ae(e){if(typeof e!=`string`)throw TypeError(`hex string expected, got `+typeof e);if(A)try{return Uint8Array.fromHex(e)}catch(e){throw e instanceof SyntaxError?RangeError(e.message):e}let t=e.length,n=t/2;if(t%2)throw RangeError(`hex string expected, got unpadded hex of length `+t);let r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){let n=ie(e.charCodeAt(i)),a=ie(e.charCodeAt(i+1));if(n===void 0||a===void 0){let t=e[i]+e[i+1];throw RangeError(`hex string expected, got non-hex character "`+t+`" at index `+i)}r[t]=n*16+a}return r}function oe(...e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];w(r),t+=r.length}let n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){let i=e[t];n.set(i,r),r+=i.length}return n}function se(e,t,n=`opts`){return T(e,`defaults`),t!==void 0&&T(t,n),Object.assign(Object.create(null),e,t)}function ce(e,t={}){if(typeof e!=`function`)throw TypeError(`"hashCons" expected function, got type=`+typeof e);t=se({},t,`info`);let n=(t,n)=>e(n).update(t).digest(),r=e(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.canXOF=r.canXOF,n.create=t=>e(t),Object.assign(n,t),Object.freeze(n)}function le(e=32){C(e,`bytesLength`);let t=typeof globalThis==`object`?globalThis.crypto:null;if(typeof t?.getRandomValues!=`function`)throw Error(`crypto.getRandomValues must be defined`);if(e>65536)throw RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}const ue=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function de(e,t,n){return e&t^~e&n}function fe(e,t,n){return e&t^e&n^t&n}var pe=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,n,r){this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=O(this.buffer)}update(e){E(this),w(e);let{view:t,buffer:n,blockLen:r}=this,i=e.length,a=!1;for(let o=0;o<i;){let s=Math.min(r-this.pos,i-o);if(s===r){let t=O(e);for(;r<=i-o;o+=r)this.process(t,o);a=!0}else n.set(o===0&&s===i?e:e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===r&&(this.process(t,0),this.pos=0,a=!0)}return this.length+=e.length,a&&this.roundClean(),this}digestInto(e){E(this),D(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:r,isLE:i}=this,{pos:a}=this;t[a++]=128,t.fill(0,a),this.padOffset>r-a&&(this.process(n,0),t.fill(0)),b(n,r-8,this.length*8,i),this.process(n,0),this.roundClean();let o=e===t?n:O(e),s=this.outputLen,c=s/4,l=this.get();if(s%4||c>l.length)throw Error(`invalid outputLen`);for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneIntoMeta(e){let{buffer:t,length:n,finished:r,destroyed:i,pos:a}=this;return e.destroyed=i,e.finished=r,e.length=n,e.pos=a,a&&e.buffer.set(t),e}clone(){return this._cloneInto()}};const me=/* @__PURE__ */ Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),he=/* @__PURE__ */ Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),M=/* @__PURE__ */ new Uint32Array(64);var ge=class extends pe{A=0;B=0;C=0;D=0;E=0;F=0;G=0;H=0;constructor(e,t){super(64,e,8,!1),this.A=t[0]|0,this.B=t[1]|0,this.C=t[2]|0,this.D=t[3]|0,this.E=t[4]|0,this.F=t[5]|0,this.G=t[6]|0,this.H=t[7]|0}get(){let{A:e,B:t,C:n,D:r,E:i,F:a,G:o,H:s}=this;return[e,t,n,r,i,a,o,s]}set(e,t,n,r,i,a,o,s){this.A=e|0,this.B=t|0,this.C=n|0,this.D=r|0,this.E=i|0,this.F=a|0,this.G=o|0,this.H=s|0}_cloneInto(e){return(e||=new this.constructor).set(...this.get()),this._cloneIntoMeta(e)}process(e,t){for(let n=0;n<16;n++,t+=4)M[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=M[e-15],n=M[e-2],r=k(t,7)^k(t,18)^t>>>3,i=k(n,17)^k(n,19)^n>>>10;M[e]=i+M[e-7]+r+M[e-16]|0}let{A:n,B:r,C:i,D:a,E:o,F:s,G:c,H:l}=this;for(let e=0;e<64;e++){let t=k(o,6)^k(o,11)^k(o,25),u=l+t+de(o,s,c)+he[e]+M[e]|0,d=(k(n,2)^k(n,13)^k(n,22))+fe(n,r,i)|0;l=c,c=s,s=o,o=a+u|0,a=i,i=r,r=n,n=u+d|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,s=s+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,a,o,s,c,l)}roundClean(){ne(M)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),ne(this.buffer)}},_e=class extends ge{constructor(){super(32,me)}};const ve=/* @__PURE__ */ ce(()=>new _e,/* @__PURE__ */ ue(1));
122
122
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
123
- function be(e,t,n=()=>{}){if(!Array.isArray(e))throw TypeError(`"${t}" expected array, got type=${typeof e}`);for(let r=0;r<e.length;r++)n(e[r],`${t}[${r}]`);return e}const M=(e,t,n)=>C(e,t,n),xe=S;function Se(e,t=``){if(typeof e!=`string`){let n=t&&`"${t}" `;throw TypeError(n+`expected string, got type=`+typeof e)}return e}function Ce(e,t=`object`){if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError(t===`object`?`expected valid options object`:`"${t}" expected object, got type=${typeof e}`);return e}function we(e,t){if(typeof e!=`function`)throw TypeError(`"${t}" is invalid: expected function, got ${typeof e}`);return e}const Te=A,N=(...e)=>se(...e),Ee=e=>oe(e),De=b,Oe=e=>ue(e),ke=/* @__PURE__ */ BigInt(0),Ae=/* @__PURE__ */ BigInt(1),je=e=>e?`"${e}" `:``;function P(e,t=``){if(typeof e!=`boolean`)throw TypeError(je(t)+`expected boolean, got type=`+typeof e);return e}function Me(e){if(typeof e==`bigint`){if(!F(e))throw RangeError(`positive bigint expected, got `+e)}else xe(e);return e}function Ne(e,t=``){if(typeof e!=`number`){let n=t&&`"${t}" `;throw TypeError(n+`expected number, got type=`+typeof e)}if(!Number.isSafeInteger(e)){let n=t&&`"${t}" `;throw RangeError(n+`expected safe integer, got `+e)}}function Pe(e){let t=Me(e).toString(16);return t.length&1?`0`+t:t}function Fe(e){if(typeof e!=`string`)throw TypeError(`hex string expected, got `+typeof e);return e===``?ke:BigInt(`0x`+e)}function Ie(e){return Fe(A(e))}function Le(e){return Fe(A(Be(C(e)).reverse()))}function Re(e,t){if(S(t),t===0)throw Error(`zero output length is invalid`);e=Me(e);let n=t*2,r=e.toString(16);if(r.length>n)throw RangeError(`number is too large`);return oe(r.padStart(n,`0`))}function ze(e,t){return Re(e,t).reverse()}function Be(e){return Uint8Array.from(M(e))}function F(e){return typeof e==`bigint`&&ke<=e}function Ve(e,t,n){return F(e)&&F(t)&&F(n)&&t<=e&&e<n}function He(e,t,n,r){if(!Ve(t,n,r))throw RangeError(`expected valid `+e+`: `+n+` <= n < `+r+`, got `+t)}function Ue(e){if(e<ke)throw Error(`expected non-negative bigint, got `+e);return e===ke?0:e.toString(2).length}const We=e=>(Ne(e,`n`),(Ae<<BigInt(e))-Ae);function Ge(e,t,n){if(S(e,`hashLen`),S(t,`qByteLen`),typeof n!=`function`)throw TypeError(`hmacFn must be a function`);let r=e=>new Uint8Array(e),i=Uint8Array.of(),a=Uint8Array.of(0),o=Uint8Array.of(1),s=r(e),c=r(e),l=0,u=()=>{s.fill(1),c.fill(0),l=0},d=(...e)=>n(c,N(s,...e)),f=(e=i)=>{c=d(a,e),s=d(),e.length!==0&&(c=d(o,e),s=d())},p=()=>{if(l++>=1e3)throw Error(`drbg: tried max amount of iterations`);let e=0,n=[];for(;e<t;){s=d();let t=s.slice();n.push(t),e+=s.length}return N(...n)};return(e,t)=>{u(),f(e);let n;for(;(n=t(p()))===void 0;)f();return u(),n}}function I(e,t={},n={},r=`object`){Ce(e,r),Ce(t,`fields`),Ce(n,`optFields`);function i(t,n,i){let a=r===`object`?`param "${String(t)}"`:`"${r}.${String(t)}"`,o=e[t];if(!Object.hasOwn(e,t)&&(i?o!==void 0:n!==`function`))throw TypeError(`${a} is invalid: expected own property`);if(i&&o===void 0)return;let s=typeof o;if(s!==n||o===null)throw TypeError(`${a} is invalid: expected ${n}, got ${s}`)}let a=(e,t)=>Object.entries(e).forEach(([e,n])=>i(e,n,t));a(t,!1),a(n,!0)}
123
+ function ye(e,t,n=()=>{}){if(!Array.isArray(e))throw TypeError(`"${t}" expected array, got type=${typeof e}`);for(let r=0;r<e.length;r++)n(e[r],`${t}[${r}]`);return e}const N=(e,t,n)=>w(e,t,n),be=C;function xe(e,t=``){if(typeof e!=`string`){let n=t&&`"${t}" `;throw TypeError(n+`expected string, got type=`+typeof e)}return e}function Se(e,t=`object`){if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError(t===`object`?`expected valid options object`:`"${t}" expected object, got type=${typeof e}`);return e}function Ce(e,t){if(typeof e!=`function`)throw TypeError(`"${t}" is invalid: expected function, got ${typeof e}`);return e}const we=j,P=(...e)=>oe(...e),Te=e=>ae(e),Ee=x,De=e=>le(e),Oe=/* @__PURE__ */ BigInt(0),ke=/* @__PURE__ */ BigInt(1),Ae=e=>e?`"${e}" `:``;function F(e,t=``){if(typeof e!=`boolean`)throw TypeError(Ae(t)+`expected boolean, got type=`+typeof e);return e}function je(e){if(typeof e==`bigint`){if(!I(e))throw RangeError(`positive bigint expected, got `+e)}else be(e);return e}function Me(e,t=``){if(typeof e!=`number`){let n=t&&`"${t}" `;throw TypeError(n+`expected number, got type=`+typeof e)}if(!Number.isSafeInteger(e)){let n=t&&`"${t}" `;throw RangeError(n+`expected safe integer, got `+e)}}function Ne(e){let t=je(e).toString(16);return t.length&1?`0`+t:t}function Pe(e){if(typeof e!=`string`)throw TypeError(`hex string expected, got `+typeof e);return e===``?Oe:BigInt(`0x`+e)}function Fe(e){return Pe(j(e))}function Ie(e){return Pe(j(ze(w(e)).reverse()))}function Le(e,t){if(C(t),t===0)throw Error(`zero output length is invalid`);e=je(e);let n=t*2,r=e.toString(16);if(r.length>n)throw RangeError(`number is too large`);return ae(r.padStart(n,`0`))}function Re(e,t){return Le(e,t).reverse()}function ze(e){return Uint8Array.from(N(e))}function I(e){return typeof e==`bigint`&&Oe<=e}function Be(e,t,n){return I(e)&&I(t)&&I(n)&&t<=e&&e<n}function Ve(e,t,n,r){if(!Be(t,n,r))throw RangeError(`expected valid `+e+`: `+n+` <= n < `+r+`, got `+t)}function He(e){if(e<Oe)throw Error(`expected non-negative bigint, got `+e);return e===Oe?0:e.toString(2).length}const Ue=e=>(Me(e,`n`),(ke<<BigInt(e))-ke);function We(e,t,n){if(C(e,`hashLen`),C(t,`qByteLen`),typeof n!=`function`)throw TypeError(`hmacFn must be a function`);let r=e=>new Uint8Array(e),i=Uint8Array.of(),a=Uint8Array.of(0),o=Uint8Array.of(1),s=r(e),c=r(e),l=0,u=()=>{s.fill(1),c.fill(0),l=0},d=(...e)=>n(c,P(s,...e)),f=(e=i)=>{c=d(a,e),s=d(),e.length!==0&&(c=d(o,e),s=d())},p=()=>{if(l++>=1e3)throw Error(`drbg: tried max amount of iterations`);let e=0,n=[];for(;e<t;){s=d();let t=s.slice();n.push(t),e+=s.length}return P(...n)};return(e,t)=>{u(),f(e);let n;for(;(n=t(p()))===void 0;)f();return u(),n}}function L(e,t={},n={},r=`object`){Se(e,r),Se(t,`fields`),Se(n,`optFields`);function i(t,n,i){let a=r===`object`?`param "${String(t)}"`:`"${r}.${String(t)}"`,o=e[t];if(!Object.hasOwn(e,t)&&(i?o!==void 0:n!==`function`))throw TypeError(`${a} is invalid: expected own property`);if(i&&o===void 0)return;let s=typeof o;if(s!==n||o===null)throw TypeError(`${a} is invalid: expected ${n}, got ${s}`)}let a=(e,t)=>Object.entries(e).forEach(([e,n])=>i(e,n,t));a(t,!1),a(n,!0)}
124
124
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
125
- const L=/* @__PURE__ */ BigInt(0),R=/* @__PURE__ */ BigInt(1),z=/* @__PURE__ */ BigInt(2),Ke=/* @__PURE__ */ BigInt(3),qe=/* @__PURE__ */ BigInt(4),Je=/* @__PURE__ */ BigInt(5),Ye=/* @__PURE__ */ BigInt(7),Xe=/* @__PURE__ */ BigInt(8),Ze=/* @__PURE__ */ BigInt(9),Qe=/* @__PURE__ */ BigInt(15),$e=/* @__PURE__ */ BigInt(16),et=/* @__PURE__ */ BigInt(`0x10000000000000000`);function B(e,t){if(t<=L)throw Error(`mod: expected positive modulus, got `+t);let n=e%t;return n>=L?n:t+n}function tt(e,t,n){if(n<=R)throw Error(`pow: expected modulus > 1, got `+n);if(typeof t!=`bigint`)throw TypeError(`invalid exponent: expected bigint, got `+typeof t);if(t<L)throw Error(`invalid exponent, negatives unsupported`);if(t===L)return R;if(t===R)return e;let r=e%n;if(r<L&&(r+=n),t<et){let e=R;for(;t>L;)t&R&&(e=e*r%n),r=r*r%n,t>>=R;return e}let i=[];for(;t>L;)i.push(Number(t&Qe)),t>>=qe;let a=Array(16);a[0]=R,a[1]=r;for(let e=2;e<16;e++)a[e]=a[e-1]*r%n;let o=a[i[i.length-1]];for(let e=i.length-2;e>=0;e--){o=o*o%n,o=o*o%n,o=o*o%n,o=o*o%n;let t=i[e];t!==0&&(o=o*a[t]%n)}return o}function nt(e,t){if(e===L)throw Error(`invert: expected non-zero number`);if(t<=R)throw Error(`invert: expected modulus > 1, got `+t);let n=B(e,t),r=t,i=L,a=R;for(;n!==L;){let e=r/n,t=r-n*e,o=i-a*e;r=n,n=t,i=a,a=o}if(r!==R)throw Error(`invert: does not exist`);return B(i,t)}function rt(e,t){if(t<=R)throw Error(`invertCt: expected prime modulus > 1, got `+t);let n=B(e,t);if(n===L)throw Error(`invertCt: expected non-zero number`);let r=tt(n,t-z,t);if(B(n*r,t)!==R)throw Error(`invertCt: does not exist`);return r}function it(e,t,n){let r=e;if(!r.eql(r.sqr(t),n))throw Error(`Cannot find square root`)}function at(e,t){if((e&R)===L)throw Error(t+`: expected odd modulus, got `+e)}function ot(e,t){let n=e,r=(n.ORDER+R)/qe,i=n.pow(t,r);return it(n,i,t),i}function st(e,t){let n=e,r=(n.ORDER-Je)/Xe,i=n.mul(t,z),a=n.pow(i,r),o=n.mul(t,a),s=n.mul(n.mul(o,z),a),c=n.mul(o,n.sub(s,n.ONE));return it(n,c,t),c}function ct(e){let t=vt(e),n=lt(e),r=n(t,t.neg(t.ONE)),i=n(t,r),a=n(t,t.neg(r)),o=(e+Ye)/$e;return((e,t)=>{let n=e,s=n.pow(t,o),c=n.mul(s,r),l=n.mul(s,i),u=n.mul(s,a),d=n.eql(n.sqr(c),t),f=n.eql(n.sqr(l),t);s=n.cmov(s,c,d),c=n.cmov(u,l,f);let p=n.eql(n.sqr(c),t),m=n.cmov(s,c,p);return it(n,m,t),m})}function lt(e){if(e<Ke)throw Error(`sqrt is not defined for small field`);at(e,`tonelliShanks`);let t=e-R,n=0;for(;t%z===L;)t/=z,n++;let r=z,i=vt(e);for(;mt(i,r)===1;)if(r++>1e3)throw Error(`Cannot find square root: probably non-prime P`);if(n===1)return ot;let a=i.pow(r,t),o=(t+R)/z;return function(e,r){let i=e;if(i.is0(r))return r;if(mt(i,r)!==1)throw Error(`Cannot find square root`);let s=n,c=i.mul(i.ONE,a),l=i.pow(r,t),u=i.pow(r,o);for(;!i.eql(l,i.ONE);){if(i.is0(l))throw Error(`Cannot find square root: probably non-prime P`);let e=1,t=i.sqr(l);for(;!i.eql(t,i.ONE);)if(e++,t=i.sqr(t),e===s)throw Error(`Cannot find square root`);let n=R<<BigInt(s-e-1),r=i.pow(c,n);s=e,c=i.sqr(r),l=i.mul(l,c),u=i.mul(u,r)}return u}}function ut(e){return at(e,`Fp.sqrt`),e%qe===Ke?ot:e%Xe===Je?st:e%$e===Ze?ct(e):lt(e)}const dt=[`create`,`isValid`,`is0`,`neg`,`inv`,`sqrt`,`sqr`,`eql`,`add`,`sub`,`mul`,`pow`,`div`,`addN`,`subN`,`mulN`,`sqrN`];function ft(e){if(Ce(e,`field`),typeof e.ORDER!=`bigint`)throw TypeError(`param "ORDER" is invalid: expected bigint, got `+typeof e.ORDER);Ne(e.BYTES,`BYTES`),Ne(e.BITS,`BITS`);for(let t of dt)we(e[t],`field.`+t);if(e.BYTES<1||e.BITS<1)throw Error(`invalid field: expected BYTES/BITS > 0`);if(e.ORDER<=R)throw Error(`invalid field: expected ORDER > 1, got `+e.ORDER);return e}function pt(e,t,n=!1){ft(e),be(t,`nums`),P(n,`passZero`);let r=e,i=Array(t.length).fill(n?r.ZERO:void 0),a=t.reduce((e,t,n)=>r.is0(t)?e:(i[n]=e,r.mul(e,t)),r.ONE),o=r.inv(a);return t.reduceRight((e,t,n)=>r.is0(t)?e:(i[n]=r.mul(e,i[n]),r.mul(e,t)),o),i}function mt(e,t){ft(e);let n=e;at(n.ORDER,`FpLegendre`);let r=(n.ORDER-R)/z,i=n.pow(t,r),a=n.eql(i,n.ONE),o=n.eql(i,n.ZERO),s=n.eql(i,n.neg(n.ONE));if(!a&&!o&&!s)throw Error(`invalid Legendre symbol result`);return a?1:o?0:-1}function ht(e,t){if(t!==void 0&&xe(t),e<=L)throw Error(`invalid n length: expected positive n, got `+e);if(t!==void 0&&t<1)throw Error(`invalid n length: expected positive bit length, got `+t);let n=Ue(e);if(t!==void 0&&t<n)throw Error(`invalid n length: expected nBitLength (${t}) >= bitLen(n) (${n})`);let r=t===void 0?n:t;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}const gt=/* @__PURE__ */ new WeakMap;var _t=class{ORDER;BITS;BYTES;isLE;ZERO=L;ONE=R;_lengths;_mod;constructor(e,t={}){if(e<=R)throw Error(`invalid field: expected ORDER > 1, got `+e);let n;this.isLE=!1,typeof t==`object`&&t&&(typeof t.BITS==`number`&&(n=t.BITS),typeof t.sqrt==`function`&&Object.defineProperty(this,"sqrt",{value:t.sqrt,enumerable:!0}),typeof t.isLE==`boolean`&&(this.isLE=t.isLE),t.allowedLengths&&(this._lengths=Object.freeze(t.allowedLengths.slice())),typeof t.modFromBytes==`boolean`&&(this._mod=t.modFromBytes));let{nBitLength:r,nByteLength:i}=ht(e,n);if(i>2048)throw Error(`invalid field: expected ORDER of <= 2048 bytes`);this.ORDER=e,this.BITS=r,this.BYTES=i,Object.freeze(this)}create(e){return B(e,this.ORDER)}isValid(e){if(typeof e!=`bigint`)throw TypeError(`invalid field element: expected bigint, got `+typeof e);return L<=e&&e<this.ORDER}is0(e){return e===L}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&R)===R}neg(e){return B(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return B(e*e,this.ORDER)}add(e,t){return B(e+t,this.ORDER)}sub(e,t){return B(e-t,this.ORDER)}mul(e,t){return B(e*t,this.ORDER)}pow(e,t){return tt(e,t,this.ORDER)}div(e,t){return B(e*nt(t,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,t){return e+t}subN(e,t){return e-t}mulN(e,t){return e*t}inv(e){return nt(e,this.ORDER)}sqrt(e){let t=gt.get(this);return t||gt.set(this,t=ut(this.ORDER)),t(this,e)}toBytes(e){return this.isLE?ze(e,this.BYTES):Re(e,this.BYTES)}fromBytes(e,t=!1){M(e);let{_lengths:n,BYTES:r,isLE:i,ORDER:a,_mod:o}=this;if(n){if(e.length<1||!n.includes(e.length)||e.length>r)throw Error(`Field.fromBytes: expected `+n+` bytes, got `+e.length);let t=new Uint8Array(r);t.set(e,i?0:t.length-e.length),e=t}if(e.length!==r)throw Error(`Field.fromBytes: expected `+r+` bytes, got `+e.length);let s=i?Le(e):Ie(e);if(o&&(s=B(s,a)),!t&&!this.isValid(s))throw Error(`invalid field element: outside of range 0..ORDER`);return s}invertBatch(e){return pt(this,e,!0)}cmov(e,t,n){return P(n,`condition`),n?t:e}};function vt(e,t={}){return Object.freeze(_t.prototype),new _t(e,t)}function yt(e){if(typeof e!=`bigint`)throw Error(`field order must be bigint`);if(e<=R)throw Error(`field order must be greater than 1`);let t=Ue(e-R);return Math.ceil(t/8)}function bt(e){let t=yt(e);return t+Math.ceil(t/2)}function xt(e,t,n=!1){M(e);let r=e.length,i=yt(t),a=Math.max(bt(t),16);if(r<a||r>1024)throw Error(`expected `+a+`-1024 bytes of input, got `+r);let o=B(n?Le(e):Ie(e),t-R)+R;return n?ze(o,i):Re(o,i)}
125
+ const R=/* @__PURE__ */ BigInt(0),z=/* @__PURE__ */ BigInt(1),B=/* @__PURE__ */ BigInt(2),Ge=/* @__PURE__ */ BigInt(3),Ke=/* @__PURE__ */ BigInt(4),qe=/* @__PURE__ */ BigInt(5),Je=/* @__PURE__ */ BigInt(7),Ye=/* @__PURE__ */ BigInt(8),Xe=/* @__PURE__ */ BigInt(9),Ze=/* @__PURE__ */ BigInt(15),Qe=/* @__PURE__ */ BigInt(16),$e=/* @__PURE__ */ BigInt(`0x10000000000000000`);function V(e,t){if(t<=R)throw Error(`mod: expected positive modulus, got `+t);let n=e%t;return n>=R?n:t+n}function et(e,t,n){if(n<=z)throw Error(`pow: expected modulus > 1, got `+n);if(typeof t!=`bigint`)throw TypeError(`invalid exponent: expected bigint, got `+typeof t);if(t<R)throw Error(`invalid exponent, negatives unsupported`);if(t===R)return z;if(t===z)return e;let r=e%n;if(r<R&&(r+=n),t<$e){let e=z;for(;t>R;)t&z&&(e=e*r%n),r=r*r%n,t>>=z;return e}let i=[];for(;t>R;)i.push(Number(t&Ze)),t>>=Ke;let a=Array(16);a[0]=z,a[1]=r;for(let e=2;e<16;e++)a[e]=a[e-1]*r%n;let o=a[i[i.length-1]];for(let e=i.length-2;e>=0;e--){o=o*o%n,o=o*o%n,o=o*o%n,o=o*o%n;let t=i[e];t!==0&&(o=o*a[t]%n)}return o}function tt(e,t){if(e===R)throw Error(`invert: expected non-zero number`);if(t<=z)throw Error(`invert: expected modulus > 1, got `+t);let n=V(e,t),r=t,i=R,a=z;for(;n!==R;){let e=r/n,t=r-n*e,o=i-a*e;r=n,n=t,i=a,a=o}if(r!==z)throw Error(`invert: does not exist`);return V(i,t)}function nt(e,t){if(t<=z)throw Error(`invertCt: expected prime modulus > 1, got `+t);let n=V(e,t);if(n===R)throw Error(`invertCt: expected non-zero number`);let r=et(n,t-B,t);if(V(n*r,t)!==z)throw Error(`invertCt: does not exist`);return r}function rt(e,t,n){let r=e;if(!r.eql(r.sqr(t),n))throw Error(`Cannot find square root`)}function it(e,t){if((e&z)===R)throw Error(t+`: expected odd modulus, got `+e)}function at(e,t){let n=e,r=(n.ORDER+z)/Ke,i=n.pow(t,r);return rt(n,i,t),i}function ot(e,t){let n=e,r=(n.ORDER-qe)/Ye,i=n.mul(t,B),a=n.pow(i,r),o=n.mul(t,a),s=n.mul(n.mul(o,B),a),c=n.mul(o,n.sub(s,n.ONE));return rt(n,c,t),c}function st(e){let t=_t(e),n=ct(e),r=n(t,t.neg(t.ONE)),i=n(t,r),a=n(t,t.neg(r)),o=(e+Je)/Qe;return((e,t)=>{let n=e,s=n.pow(t,o),c=n.mul(s,r),l=n.mul(s,i),u=n.mul(s,a),d=n.eql(n.sqr(c),t),f=n.eql(n.sqr(l),t);s=n.cmov(s,c,d),c=n.cmov(u,l,f);let p=n.eql(n.sqr(c),t),m=n.cmov(s,c,p);return rt(n,m,t),m})}function ct(e){if(e<Ge)throw Error(`sqrt is not defined for small field`);it(e,`tonelliShanks`);let t=e-z,n=0;for(;t%B===R;)t/=B,n++;let r=B,i=_t(e);for(;pt(i,r)===1;)if(r++>1e3)throw Error(`Cannot find square root: probably non-prime P`);if(n===1)return at;let a=i.pow(r,t),o=(t+z)/B;return function(e,r){let i=e;if(i.is0(r))return r;if(pt(i,r)!==1)throw Error(`Cannot find square root`);let s=n,c=i.mul(i.ONE,a),l=i.pow(r,t),u=i.pow(r,o);for(;!i.eql(l,i.ONE);){if(i.is0(l))throw Error(`Cannot find square root: probably non-prime P`);let e=1,t=i.sqr(l);for(;!i.eql(t,i.ONE);)if(e++,t=i.sqr(t),e===s)throw Error(`Cannot find square root`);let n=z<<BigInt(s-e-1),r=i.pow(c,n);s=e,c=i.sqr(r),l=i.mul(l,c),u=i.mul(u,r)}return u}}function lt(e){return it(e,`Fp.sqrt`),e%Ke===Ge?at:e%Ye===qe?ot:e%Qe===Xe?st(e):ct(e)}const ut=[`create`,`isValid`,`is0`,`neg`,`inv`,`sqrt`,`sqr`,`eql`,`add`,`sub`,`mul`,`pow`,`div`,`addN`,`subN`,`mulN`,`sqrN`];function dt(e){if(Se(e,`field`),typeof e.ORDER!=`bigint`)throw TypeError(`param "ORDER" is invalid: expected bigint, got `+typeof e.ORDER);Me(e.BYTES,`BYTES`),Me(e.BITS,`BITS`);for(let t of ut)Ce(e[t],`field.`+t);if(e.BYTES<1||e.BITS<1)throw Error(`invalid field: expected BYTES/BITS > 0`);if(e.ORDER<=z)throw Error(`invalid field: expected ORDER > 1, got `+e.ORDER);return e}function ft(e,t,n=!1){dt(e),ye(t,`nums`),F(n,`passZero`);let r=e,i=Array(t.length).fill(n?r.ZERO:void 0),a=t.reduce((e,t,n)=>r.is0(t)?e:(i[n]=e,r.mul(e,t)),r.ONE),o=r.inv(a);return t.reduceRight((e,t,n)=>r.is0(t)?e:(i[n]=r.mul(e,i[n]),r.mul(e,t)),o),i}function pt(e,t){dt(e);let n=e;it(n.ORDER,`FpLegendre`);let r=(n.ORDER-z)/B,i=n.pow(t,r),a=n.eql(i,n.ONE),o=n.eql(i,n.ZERO),s=n.eql(i,n.neg(n.ONE));if(!a&&!o&&!s)throw Error(`invalid Legendre symbol result`);return a?1:o?0:-1}function mt(e,t){if(t!==void 0&&be(t),e<=R)throw Error(`invalid n length: expected positive n, got `+e);if(t!==void 0&&t<1)throw Error(`invalid n length: expected positive bit length, got `+t);let n=He(e);if(t!==void 0&&t<n)throw Error(`invalid n length: expected nBitLength (${t}) >= bitLen(n) (${n})`);let r=t===void 0?n:t;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}const ht=/* @__PURE__ */ new WeakMap;var gt=class{ORDER;BITS;BYTES;isLE;ZERO=R;ONE=z;_lengths;_mod;constructor(e,t={}){if(e<=z)throw Error(`invalid field: expected ORDER > 1, got `+e);let n;this.isLE=!1,typeof t==`object`&&t&&(typeof t.BITS==`number`&&(n=t.BITS),typeof t.sqrt==`function`&&Object.defineProperty(this,"sqrt",{value:t.sqrt,enumerable:!0}),typeof t.isLE==`boolean`&&(this.isLE=t.isLE),t.allowedLengths&&(this._lengths=Object.freeze(t.allowedLengths.slice())),typeof t.modFromBytes==`boolean`&&(this._mod=t.modFromBytes));let{nBitLength:r,nByteLength:i}=mt(e,n);if(i>2048)throw Error(`invalid field: expected ORDER of <= 2048 bytes`);this.ORDER=e,this.BITS=r,this.BYTES=i,Object.freeze(this)}create(e){return V(e,this.ORDER)}isValid(e){if(typeof e!=`bigint`)throw TypeError(`invalid field element: expected bigint, got `+typeof e);return R<=e&&e<this.ORDER}is0(e){return e===R}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&z)===z}neg(e){return V(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return V(e*e,this.ORDER)}add(e,t){return V(e+t,this.ORDER)}sub(e,t){return V(e-t,this.ORDER)}mul(e,t){return V(e*t,this.ORDER)}pow(e,t){return et(e,t,this.ORDER)}div(e,t){return V(e*tt(t,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,t){return e+t}subN(e,t){return e-t}mulN(e,t){return e*t}inv(e){return tt(e,this.ORDER)}sqrt(e){let t=ht.get(this);return t||ht.set(this,t=lt(this.ORDER)),t(this,e)}toBytes(e){return this.isLE?Re(e,this.BYTES):Le(e,this.BYTES)}fromBytes(e,t=!1){N(e);let{_lengths:n,BYTES:r,isLE:i,ORDER:a,_mod:o}=this;if(n){if(e.length<1||!n.includes(e.length)||e.length>r)throw Error(`Field.fromBytes: expected `+n+` bytes, got `+e.length);let t=new Uint8Array(r);t.set(e,i?0:t.length-e.length),e=t}if(e.length!==r)throw Error(`Field.fromBytes: expected `+r+` bytes, got `+e.length);let s=i?Ie(e):Fe(e);if(o&&(s=V(s,a)),!t&&!this.isValid(s))throw Error(`invalid field element: outside of range 0..ORDER`);return s}invertBatch(e){return ft(this,e,!0)}cmov(e,t,n){return F(n,`condition`),n?t:e}};function _t(e,t={}){return Object.freeze(gt.prototype),new gt(e,t)}function vt(e){if(typeof e!=`bigint`)throw Error(`field order must be bigint`);if(e<=z)throw Error(`field order must be greater than 1`);let t=He(e-z);return Math.ceil(t/8)}function yt(e){let t=vt(e);return t+Math.ceil(t/2)}function bt(e,t,n=!1){N(e);let r=e.length,i=vt(t),a=Math.max(yt(t),16);if(r<a||r>1024)throw Error(`expected `+a+`-1024 bytes of input, got `+r);let o=V(n?Ie(e):Fe(e),t-z)+z;return n?Re(o,i):Le(o,i)}
126
126
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
127
- const St=/* @__PURE__ */ BigInt(0),Ct=/* @__PURE__ */ BigInt(1),wt=/* @__PURE__ */ BigInt(4),Tt=2**31;function Et(e){let t=e;if(typeof t!=`function`)throw TypeError(`"Point" expected constructor, got type=`+typeof e);we(t.fromAffine,`Point.fromAffine`),we(t.fromBytes,`Point.fromBytes`),we(t.fromHex,`Point.fromHex`),Ce(t.BASE,`Point.BASE`),Ce(t.ZERO,`Point.ZERO`),ft(t.Fp),ft(t.Fn)}function Dt(e,t){Et(e),jt(t,e);let n=pt(e.Fp,t.map(e=>e.Z));return t.map((t,r)=>e.fromAffine(t.toAffine(n[r])))}function Ot(e,t,n=1){if(!Number.isSafeInteger(e)||e<n||e>t)throw Error(`invalid window size, expected [`+n+`..`+t+`], got W=`+e)}function kt(e,t){let n=e*(4*t+128);if(n>Tt)throw Error(`invalid window size: table would need ~`+Math.ceil(n/2**20)+` MiB, max `+Tt/2**20+` MiB`)}function At(e,t){if(e!==void 0){we(e,`randomBytes`);try{let n=e(t);if(!De(n)||n.length!==t)return}catch{return}return e}}function jt(e,t){be(e,`points`),e.forEach((e,n)=>{if(!(e instanceof t))throw Error(`invalid point at index `+n)})}function Mt(e,t,n){if(!Array.isArray(e))throw Error(`array of scalars expected`);e.forEach((e,r)=>{if(!(n===void 0?t.isValid(e):F(e)&&e<n))throw Error(`invalid scalar at index `+r)})}const Nt=/* @__PURE__ */ new WeakMap;function Pt(e){return Nt.get(e)||1}function Ft(e,t){let n=e.double(),r=[e];for(let e=1;e<t;e++)r.push(r[e-1].add(n));return r}function It(e,t){let n=2**t,r=n/2,i=BigInt(n-1),a=[];for(;e>St;){let t=0;e&Ct&&(t=Number(e&i),t>=r&&(t-=n),e-=BigInt(t)),a.push(t),e>>=Ct}return a}function Lt(e,t,n){let r=2**t,i=r/2,a=BigInt(r-1),o=BigInt(t),s=[];for(let t=0;t<n;t++){let t=Number(e&a);e>>=o,t>i&&(t-=r,e+=Ct),s.push(t)}if(e!==St)throw Error(`invalid wnaf`);return s}function Rt(e,t,n){let r=0;for(let e of n)r=Math.max(r,e.length);let i=e;for(let e=r-1;e>=0;e--){e!==r-1&&(i=i.double());for(let r=0;r<n.length;r++){let a=n[r][e];if(a){let e=t[r][Math.abs(a)-1>>1];i=i.add(a<0?e.negate():e)}}}return i}var zt=class{Point;BASE;ZERO;randomBytes;wnafPrecomputes=/* @__PURE__ */ new WeakMap;baseCanBeBlinded;bits;constructor(e,t){Et(e),this.randomBytes=At(t,16),this.Point=e,this.BASE=e.BASE,this.ZERO=e.ZERO,this.bits=e.Fn.BITS}buildWnafTable(e,t,n){let r=Math.ceil(n/t)+1,i=2**(t-1),a=[],o=e;for(let e=0;e<r;e++){let e=o;for(let t=0;t<i;t++)a.push(e),e=e.add(o);o=a[a.length-1].double()}return{W:t,bits:n,windows:r,comp:a}}wnafCachedCT(e,t){let{W:n,windows:r,comp:i}=e,a=2**(n-1),o=Lt(t,n,r),s=this.ZERO,c=this.BASE;for(let e=0;e<r;e++){let t=o[e],n=e*a,r=Math.abs(t)-1,l=i[n];for(let e=1;e<a;e++)l=e===r?i[n+e]:l;let u=l.negate();t===0?c=c.add(i[n]):s=s.add(t<0?u:l)}return{p:s,f:c}}getWnafPrecomputes(e,t,n,r){let i=this.wnafPrecomputes.get(t),a=i?.find(t=>t.W===e&&t.bits===n);return a||(a=this.buildWnafTable(t,e,n),typeof r==`function`&&(a={...a,comp:r(a.comp)}),i||(i=[],this.wnafPrecomputes.set(t,i)),i.push(a)),a}assertPoint(e){if(!(e instanceof this.Point))throw TypeError(`"point" expected Point instance, got type=`+typeof e)}validateMulInput(e,t){if(this.assertPoint(e),!Ve(t,Ct,this.Point.Fn.ORDER))throw Error(`invalid scalar`)}runCT(e,t,n,r){let i=Pt(e);return i===1?this.fixedWindowCT(e,t,n):this.wnafCachedCT(this.getWnafPrecomputes(i,e,n,r),t)}mulCT(e,t,n){return this.validateMulInput(e,t),this.runCT(e,t,this.bits,n)}mulCTBlinded(e,t,n){if(this.validateMulInput(e,t),this.randomBytes===void 0)throw Error(`randomBytes is required for scalar blinding`);let r=this.Point.Fn.BITS+128,i=this.randomBytes(16);if(!De(i)||i.length!==16)throw Error(`randomBytes returned invalid byte array`);i[0]=i[0]&63|128;let a=t+Ie(i)*this.Point.Fn.ORDER;return this.runCT(e,a,r,n)}fixedWindowCT(e,t,n){let r=We(5),i=Array(32);i[0]=this.ZERO;for(let t=1;t<32;t++)i[t]=i[t-1].add(e);let a=Math.ceil(n/5),o=this.ZERO;for(let e=a-1;e>=0;e--){if(e!==a-1)for(let e=0;e<5;e++)o=o.double();let n=Number(t>>BigInt(e*5)&r),s=i[0];for(let e=1;e<32;e++)s=e===n?i[e]:s;o=o.add(s)}return{p:o,f:o}}shouldBlind(e,t){return this.randomBytes===void 0?!1:t===Ct||e===this.BASE&&(this.baseCanBeBlinded===void 0&&(this.baseCanBeBlinded=this.mulUnsafe(this.BASE,this.Point.Fn.ORDER).is0()),this.baseCanBeBlinded)}mulSecret(e,t,n,r){return this.shouldBlind(e,n)?this.mulCTBlinded(e,t,r):this.mulCT(e,t,r)}mulUnsafe(e,t,n){if(this.assertPoint(e),!F(t))throw Error(`invalid scalar`);let r=Pt(e);if(r===1||t>=this.Point.Fn.ORDER)return Bt(this.Point,[e],[t],!0);let i=this.getWnafPrecomputes(r,e,this.bits,n);return this.wnafCachedCT(i,t).p}setWindowSize(e,t){this.assertPoint(e),Ot(t,this.bits),kt((Math.ceil((this.bits+128)/t)+1)*2**(t-1),this.Point.Fp.BYTES),Nt.set(e,t),this.wnafPrecomputes.delete(e)}hasWindowSize(e){return Pt(e)!==1}};function Bt(e,t,n,r=!1){if(Et(e),jt(t,e),P(r,`allowOversized`),Mt(n,e.Fn,r?e.Fn.ORDER**wt:void 0),t.length!==n.length)throw Error(`arrays of points and scalars must have equal length`);let i=t.map(e=>Ft(e,4)),a=n.map(e=>It(e,4));return Rt(e.ZERO,i,a)}function Vt(e,t,n){if(t){if(t.ORDER!==e)throw Error(`Field.ORDER must match order: Fp == p, Fn == n`);return ft(t),t}return vt(e,{isLE:n})}function Ht(e,t,n={},r){if(e!==`weierstrass`&&e!==`edwards`)throw Error(`expected curve type "weierstrass" or "edwards"`);if(r===void 0&&(r=e===`edwards`),!t||typeof t!=`object`)throw Error(`expected valid ${e} CURVE object`);I(n);for(let e of[`p`,`n`,`h`]){let n=t[e];if(!(F(n)&&n!==St))throw Error(`CURVE.${e} must be positive bigint`)}let i=Vt(t.p,n.Fp,r),a=Vt(t.n,n.Fn,r),o=[`Gx`,`Gy`,`a`,e===`weierstrass`?`b`:`d`];for(let e of o)if(!i.isValid(t[e]))throw Error(`CURVE.${e} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:i,Fn:a}}function Ut(e,t){return function(n){let r=e(n);return{secretKey:r,publicKey:t(r)}}}var Wt=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,t){if(te(e),C(t,void 0,`key`),this.iHash=e.create(),typeof this.iHash.update!=`function`)throw Error(`expected Hash instance`);this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,r=new Uint8Array(n);r.set(t.length>n?e.create().update(t).digest():t);for(let e=0;e<r.length;e++)r[e]^=54;this.iHash.update(r),this.oHash=e.create();for(let e=0;e<r.length;e++)r[e]^=106;this.oHash.update(r),re(r)}update(e){return T(this),this.iHash.update(e),this}digestInto(e){T(this),E(e,this),this.finished=!0;let t=e.subarray(0,this.outputLen);this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:n,finished:r,destroyed:i,blockLen:a,outputLen:o,canXOF:s}=this;return e=e,e.finished=r,e.destroyed=i,e.blockLen=a,e.outputLen=o,e.canXOF=s,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const Gt=/* @__PURE__ */ (()=>{let e=((e,t,n)=>new Wt(e,t).update(n).digest());return e.create=(e,t)=>new Wt(e,t),e})(),Kt=/* @__PURE__ */ BigInt(0),V={Err:class extends Error{constructor(e=``){
127
+ const xt=/* @__PURE__ */ BigInt(0),St=/* @__PURE__ */ BigInt(1),Ct=/* @__PURE__ */ BigInt(4),wt=2**31;function Tt(e){let t=e;if(typeof t!=`function`)throw TypeError(`"Point" expected constructor, got type=`+typeof e);Ce(t.fromAffine,`Point.fromAffine`),Ce(t.fromBytes,`Point.fromBytes`),Ce(t.fromHex,`Point.fromHex`),Se(t.BASE,`Point.BASE`),Se(t.ZERO,`Point.ZERO`),dt(t.Fp),dt(t.Fn)}function Et(e,t){Tt(e),At(t,e);let n=ft(e.Fp,t.map(e=>e.Z));return t.map((t,r)=>e.fromAffine(t.toAffine(n[r])))}function Dt(e,t,n=1){if(!Number.isSafeInteger(e)||e<n||e>t)throw Error(`invalid window size, expected [`+n+`..`+t+`], got W=`+e)}function Ot(e,t){let n=e*(4*t+128);if(n>wt)throw Error(`invalid window size: table would need ~`+Math.ceil(n/2**20)+` MiB, max `+wt/2**20+` MiB`)}function kt(e,t){if(e!==void 0){Ce(e,`randomBytes`);try{let n=e(t);if(!Ee(n)||n.length!==t)return}catch{return}return e}}function At(e,t){ye(e,`points`),e.forEach((e,n)=>{if(!(e instanceof t))throw Error(`invalid point at index `+n)})}function jt(e,t,n){if(!Array.isArray(e))throw Error(`array of scalars expected`);e.forEach((e,r)=>{if(!(n===void 0?t.isValid(e):I(e)&&e<n))throw Error(`invalid scalar at index `+r)})}const Mt=/* @__PURE__ */ new WeakMap;function Nt(e){return Mt.get(e)||1}function Pt(e,t){let n=e.double(),r=[e];for(let e=1;e<t;e++)r.push(r[e-1].add(n));return r}function Ft(e,t){let n=2**t,r=n/2,i=BigInt(n-1),a=[];for(;e>xt;){let t=0;e&St&&(t=Number(e&i),t>=r&&(t-=n),e-=BigInt(t)),a.push(t),e>>=St}return a}function It(e,t,n){let r=2**t,i=r/2,a=BigInt(r-1),o=BigInt(t),s=[];for(let t=0;t<n;t++){let t=Number(e&a);e>>=o,t>i&&(t-=r,e+=St),s.push(t)}if(e!==xt)throw Error(`invalid wnaf`);return s}function Lt(e,t,n){let r=0;for(let e of n)r=Math.max(r,e.length);let i=e;for(let e=r-1;e>=0;e--){e!==r-1&&(i=i.double());for(let r=0;r<n.length;r++){let a=n[r][e];if(a){let e=t[r][Math.abs(a)-1>>1];i=i.add(a<0?e.negate():e)}}}return i}var Rt=class{Point;BASE;ZERO;randomBytes;wnafPrecomputes=/* @__PURE__ */ new WeakMap;baseCanBeBlinded;bits;constructor(e,t){Tt(e),this.randomBytes=kt(t,16),this.Point=e,this.BASE=e.BASE,this.ZERO=e.ZERO,this.bits=e.Fn.BITS}buildWnafTable(e,t,n){let r=Math.ceil(n/t)+1,i=2**(t-1),a=[],o=e;for(let e=0;e<r;e++){let e=o;for(let t=0;t<i;t++)a.push(e),e=e.add(o);o=a[a.length-1].double()}return{W:t,bits:n,windows:r,comp:a}}wnafCachedCT(e,t){let{W:n,windows:r,comp:i}=e,a=2**(n-1),o=It(t,n,r),s=this.ZERO,c=this.BASE;for(let e=0;e<r;e++){let t=o[e],n=e*a,r=Math.abs(t)-1,l=i[n];for(let e=1;e<a;e++)l=e===r?i[n+e]:l;let u=l.negate();t===0?c=c.add(i[n]):s=s.add(t<0?u:l)}return{p:s,f:c}}getWnafPrecomputes(e,t,n,r){let i=this.wnafPrecomputes.get(t),a=i?.find(t=>t.W===e&&t.bits===n);return a||(a=this.buildWnafTable(t,e,n),typeof r==`function`&&(a={...a,comp:r(a.comp)}),i||(i=[],this.wnafPrecomputes.set(t,i)),i.push(a)),a}assertPoint(e){if(!(e instanceof this.Point))throw TypeError(`"point" expected Point instance, got type=`+typeof e)}validateMulInput(e,t){if(this.assertPoint(e),!Be(t,St,this.Point.Fn.ORDER))throw Error(`invalid scalar`)}runCT(e,t,n,r){let i=Nt(e);return i===1?this.fixedWindowCT(e,t,n):this.wnafCachedCT(this.getWnafPrecomputes(i,e,n,r),t)}mulCT(e,t,n){return this.validateMulInput(e,t),this.runCT(e,t,this.bits,n)}mulCTBlinded(e,t,n){if(this.validateMulInput(e,t),this.randomBytes===void 0)throw Error(`randomBytes is required for scalar blinding`);let r=this.Point.Fn.BITS+128,i=this.randomBytes(16);if(!Ee(i)||i.length!==16)throw Error(`randomBytes returned invalid byte array`);i[0]=i[0]&63|128;let a=t+Fe(i)*this.Point.Fn.ORDER;return this.runCT(e,a,r,n)}fixedWindowCT(e,t,n){let r=Ue(5),i=Array(32);i[0]=this.ZERO;for(let t=1;t<32;t++)i[t]=i[t-1].add(e);let a=Math.ceil(n/5),o=this.ZERO;for(let e=a-1;e>=0;e--){if(e!==a-1)for(let e=0;e<5;e++)o=o.double();let n=Number(t>>BigInt(e*5)&r),s=i[0];for(let e=1;e<32;e++)s=e===n?i[e]:s;o=o.add(s)}return{p:o,f:o}}shouldBlind(e,t){return this.randomBytes===void 0?!1:t===St||e===this.BASE&&(this.baseCanBeBlinded===void 0&&(this.baseCanBeBlinded=this.mulUnsafe(this.BASE,this.Point.Fn.ORDER).is0()),this.baseCanBeBlinded)}mulSecret(e,t,n,r){return this.shouldBlind(e,n)?this.mulCTBlinded(e,t,r):this.mulCT(e,t,r)}mulUnsafe(e,t,n){if(this.assertPoint(e),!I(t))throw Error(`invalid scalar`);let r=Nt(e);if(r===1||t>=this.Point.Fn.ORDER)return zt(this.Point,[e],[t],!0);let i=this.getWnafPrecomputes(r,e,this.bits,n);return this.wnafCachedCT(i,t).p}setWindowSize(e,t){this.assertPoint(e),Dt(t,this.bits),Ot((Math.ceil((this.bits+128)/t)+1)*2**(t-1),this.Point.Fp.BYTES),Mt.set(e,t),this.wnafPrecomputes.delete(e)}hasWindowSize(e){return Nt(e)!==1}};function zt(e,t,n,r=!1){if(Tt(e),At(t,e),F(r,`allowOversized`),jt(n,e.Fn,r?e.Fn.ORDER**Ct:void 0),t.length!==n.length)throw Error(`arrays of points and scalars must have equal length`);let i=t.map(e=>Pt(e,4)),a=n.map(e=>Ft(e,4));return Lt(e.ZERO,i,a)}function Bt(e,t,n){if(t){if(t.ORDER!==e)throw Error(`Field.ORDER must match order: Fp == p, Fn == n`);return dt(t),t}return _t(e,{isLE:n})}function Vt(e,t,n={},r){if(e!==`weierstrass`&&e!==`edwards`)throw Error(`expected curve type "weierstrass" or "edwards"`);if(r===void 0&&(r=e===`edwards`),!t||typeof t!=`object`)throw Error(`expected valid ${e} CURVE object`);L(n);for(let e of[`p`,`n`,`h`]){let n=t[e];if(!(I(n)&&n!==xt))throw Error(`CURVE.${e} must be positive bigint`)}let i=Bt(t.p,n.Fp,r),a=Bt(t.n,n.Fn,r),o=[`Gx`,`Gy`,`a`,e===`weierstrass`?`b`:`d`];for(let e of o)if(!i.isValid(t[e]))throw Error(`CURVE.${e} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:i,Fn:a}}function Ht(e,t){return function(n){let r=e(n);return{secretKey:r,publicKey:t(r)}}}var Ut=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,t){if(ee(e),w(t,void 0,`key`),this.iHash=e.create(),typeof this.iHash.update!=`function`)throw Error(`expected Hash instance`);this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,r=new Uint8Array(n);r.set(t.length>n?e.create().update(t).digest():t);for(let e=0;e<r.length;e++)r[e]^=54;this.iHash.update(r),this.oHash=e.create();for(let e=0;e<r.length;e++)r[e]^=106;this.oHash.update(r),ne(r)}update(e){return E(this),this.iHash.update(e),this}digestInto(e){E(this),D(e,this),this.finished=!0;let t=e.subarray(0,this.outputLen);this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:n,finished:r,destroyed:i,blockLen:a,outputLen:o,canXOF:s}=this;return e=e,e.finished=r,e.destroyed=i,e.blockLen=a,e.outputLen=o,e.canXOF=s,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const Wt=/* @__PURE__ */ (()=>{let e=((e,t,n)=>new Ut(e,t).update(n).digest());return e.create=(e,t)=>new Ut(e,t),e})(),Gt=/* @__PURE__ */ BigInt(0),H={Err:class extends Error{constructor(e=``){
128
128
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
129
- super(e)}},_tlv:{encode:(e,t)=>{let{Err:n}=V;if(Ne(e,`tag`),e<0||e>255)throw new n(`tlv.encode: wrong tag`);if(Se(t,`data`),t.length&1)throw new n(`tlv.encode: unpadded data`);let r=t.length/2,i=Pe(r);if(i.length/2&128)throw new n(`tlv.encode: long form length too big`);let a=r>127?Pe(i.length/2|128):``;return Pe(e)+a+i+t},decode(e,t){let{Err:n}=V;t=M(t,void 0,`DER data`);let r=0;if(e<0||e>255)throw new n(`tlv.decode: wrong tag`);if(t.length<2||t[r++]!==e)throw new n(`tlv.decode: wrong tlv`);let i=t[r++],a=!!(i&128),o=0;if(!a)o=i;else{let e=i&127;if(!e)throw new n(`tlv.decode(long): indefinite length not supported`);if(e>4)throw new n(`tlv.decode(long): byte length is too big`);let a=t.subarray(r,r+e);if(a.length!==e)throw new n(`tlv.decode: length bytes not complete`);if(a[0]===0)throw new n(`tlv.decode(long): zero leftmost byte`);for(let e of a)o=o<<8|e;if(r+=e,o<128)throw new n(`tlv.decode(long): not minimal encoding`)}let s=t.subarray(r,r+o);if(s.length!==o)throw new n(`tlv.decode: wrong value length`);return{v:s,l:t.subarray(r+o)}}},_int:{encode(e){let{Err:t}=V;if(Me(e),e<Kt)throw new t(`integer: negative integers are not allowed`);let n=Pe(e);if(Number.parseInt(n[0],16)&8&&(n=`00`+n),n.length&1)throw new t(`unexpected DER parsing assertion: unpadded hex`);return n},decode(e){let{Err:t}=V;if(e.length<1)throw new t(`invalid signature integer: empty`);if(e[0]&128)throw new t(`invalid signature integer: negative`);if(e.length>1&&e[0]===0&&!(e[1]&128))throw new t(`invalid signature integer: unnecessary leading zero`);return Ie(e)}},toSig(e,t){let{Err:n,_int:r,_tlv:i}=V;if(t!==void 0&&(Ne(t,`maxScalarBytes`),t<1))throw new n(`invalid signature: maxScalarBytes must be positive`);let a=M(e,void 0,`signature`),{v:o,l:s}=i.decode(48,a);if(s.length)throw new n(`invalid signature: left bytes after parsing`);let{v:c,l}=i.decode(2,o),{v:u,l:d}=i.decode(2,l);if(d.length)throw new n(`invalid signature: left bytes after parsing`);if(t!==void 0&&(c.length>t||u.length>t))throw new n(`invalid signature: integer too large`);return{r:r.decode(c),s:r.decode(u)}},hexFromSig(e){let{_tlv:t,_int:n}=V;I(e,{r:`bigint`,s:`bigint`},{},`sig`);let r=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,r)}},qt=(Object.freeze(V._tlv),Object.freeze(V._int),Object.freeze(V)),Jt=(e,t)=>(e+(e>=0?t:-t)/Qt)/t
129
+ super(e)}},_tlv:{encode:(e,t)=>{let{Err:n}=H;if(Me(e,`tag`),e<0||e>255)throw new n(`tlv.encode: wrong tag`);if(xe(t,`data`),t.length&1)throw new n(`tlv.encode: unpadded data`);let r=t.length/2,i=Ne(r);if(i.length/2&128)throw new n(`tlv.encode: long form length too big`);let a=r>127?Ne(i.length/2|128):``;return Ne(e)+a+i+t},decode(e,t){let{Err:n}=H;t=N(t,void 0,`DER data`);let r=0;if(e<0||e>255)throw new n(`tlv.decode: wrong tag`);if(t.length<2||t[r++]!==e)throw new n(`tlv.decode: wrong tlv`);let i=t[r++],a=!!(i&128),o=0;if(!a)o=i;else{let e=i&127;if(!e)throw new n(`tlv.decode(long): indefinite length not supported`);if(e>4)throw new n(`tlv.decode(long): byte length is too big`);let a=t.subarray(r,r+e);if(a.length!==e)throw new n(`tlv.decode: length bytes not complete`);if(a[0]===0)throw new n(`tlv.decode(long): zero leftmost byte`);for(let e of a)o=o<<8|e;if(r+=e,o<128)throw new n(`tlv.decode(long): not minimal encoding`)}let s=t.subarray(r,r+o);if(s.length!==o)throw new n(`tlv.decode: wrong value length`);return{v:s,l:t.subarray(r+o)}}},_int:{encode(e){let{Err:t}=H;if(je(e),e<Gt)throw new t(`integer: negative integers are not allowed`);let n=Ne(e);if(Number.parseInt(n[0],16)&8&&(n=`00`+n),n.length&1)throw new t(`unexpected DER parsing assertion: unpadded hex`);return n},decode(e){let{Err:t}=H;if(e.length<1)throw new t(`invalid signature integer: empty`);if(e[0]&128)throw new t(`invalid signature integer: negative`);if(e.length>1&&e[0]===0&&!(e[1]&128))throw new t(`invalid signature integer: unnecessary leading zero`);return Fe(e)}},toSig(e,t){let{Err:n,_int:r,_tlv:i}=H;if(t!==void 0&&(Me(t,`maxScalarBytes`),t<1))throw new n(`invalid signature: maxScalarBytes must be positive`);let a=N(e,void 0,`signature`),{v:o,l:s}=i.decode(48,a);if(s.length)throw new n(`invalid signature: left bytes after parsing`);let{v:c,l}=i.decode(2,o),{v:u,l:d}=i.decode(2,l);if(d.length)throw new n(`invalid signature: left bytes after parsing`);if(t!==void 0&&(c.length>t||u.length>t))throw new n(`invalid signature: integer too large`);return{r:r.decode(c),s:r.decode(u)}},hexFromSig(e){let{_tlv:t,_int:n}=H;L(e,{r:`bigint`,s:`bigint`},{},`sig`);let r=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,r)}},Kt=(Object.freeze(H._tlv),Object.freeze(H._int),Object.freeze(H)),qt=(e,t)=>(e+(e>=0?t:-t)/Zt)/t
130
130
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
131
- ;function Yt(e,t,n){He(`scalar`,e,H,n);let[[r,i],[a,o]]=t,s=Jt(o*e,n),c=Jt(-i*e,n),l=e-s*r-c*a,u=-s*i-c*o,d=l<H,f=u<H;d&&(l=-l),f&&(u=-u);let p=We(Math.ceil(Ue(n)/2))+U;if(l<H||l>=p||u<H||u>=p)throw Error(`splitScalar (endomorphism): failed for k`);return{k1neg:d,k1:l,k2neg:f,k2:u}}function Xt(e){if(![`compact`,`recovered`,`der`].includes(e))throw Error(`Signature format must be "compact", "recovered", or "der"`);return e}function Zt(e,t){I(e);let n={};for(let r of Object.keys(t))n[r]=e[r]===void 0?t[r]:e[r];return P(n.lowS,`lowS`),P(n.prehash,`prehash`),n.format!==void 0&&Xt(n.format),n}const H=/* @__PURE__ */ BigInt(0),U=/* @__PURE__ */ BigInt(1),Qt=/* @__PURE__ */ BigInt(2),$t=/* @__PURE__ */ BigInt(3),en=/* @__PURE__ */ BigInt(4);function tn(e,t={}){let n=Ht(`weierstrass`,e,t),r=n.Fp,i=n.Fn,a=n.CURVE,{h:o,n:s}=a;I(t,{},{allowInfinityPoint:`boolean`,clearCofactor:`function`,isTorsionFree:`function`,fromBytes:`function`,toBytes:`function`,endo:`object`,randomBytes:`function`});let{endo:c,allowInfinityPoint:l,clearCofactor:u,isTorsionFree:d,fromBytes:f,toBytes:p}=t,m=t.randomBytes===void 0?Oe:t.randomBytes;if(c&&(!r.is0(a.a)||typeof c.beta!=`bigint`||!Array.isArray(c.basises)))throw Error(`invalid endo: expected "beta": bigint and "basises": array`);let h=c?{beta:c.beta,basises:c.basises.map(e=>[...e])}:void 0,g=rn(r,i);function _(){if(!r.isOdd)throw Error(`compression is not supported: Field does not have .isOdd()`)}function v(e,t,n){if(t.is0()){if(!l)throw Error(`bad point: ZERO`);return Uint8Array.of(0)}let{x:i,y:a}=t.toAffine(),o=r.toBytes(i);if(P(n,`isCompressed`),n){_();let e=!r.isOdd(a);return N(nn(e),o)}return N(Uint8Array.of(4),o,r.toBytes(a))}function ee(e){M(e,void 0,`Point`);let{publicKey:t,publicKeyUncompressed:n}=g,i=e.length,a=e[0],o=e.subarray(1);if(l&&i===1&&a===0)return{x:r.ZERO,y:r.ZERO};if(i===t&&(a===2||a===3)){let e=r.fromBytes(o);if(!r.isValid(e))throw Error(`bad point: is not on curve, wrong x`);let t=C(e),n;try{n=r.sqrt(t)}catch(e){let t=e instanceof Error?`: `+e.message:``;throw Error(`bad point: is not on curve, sqrt error`+t)}_();let i=r.isOdd(n);return(a&1)==1!==i&&(n=r.neg(n)),{x:e,y:n}}if(i===n&&a===4){let e=r.BYTES,t=r.fromBytes(o.subarray(0,e)),n=r.fromBytes(o.subarray(e,e*2));if(!te(t,n))throw Error(`bad point: is not on curve`);return{x:t,y:n}}throw Error(`bad point: got length ${i}, expected compressed=${t} or uncompressed=${n}`)}let y=p===void 0?v:p,b=f===void 0?ee:f,x=r.mul(a.b,$t),S=r.is0(a.a)?e=>r.ZERO:e=>r.mul(a.a,e);function C(e){let t=r.sqr(e),n=r.mul(t,e);return r.add(r.add(n,r.mul(e,a.a)),a.b)}function te(e,t){let n=r.sqr(t),i=C(e);return r.eql(n,i)}if(!te(a.Gx,a.Gy))throw Error(`bad curve params: generator point`);let ne=r.mul(r.pow(a.a,$t),en),w=r.mul(r.sqr(a.b),BigInt(27));if(r.is0(r.add(ne,w)))throw Error(`bad curve params: a or b`);function T(e,t,n=!1){if(!r.isValid(t)||n&&r.is0(t))throw Error(`bad point coordinate ${e}`);return typeof t==`object`&&t?r.create(t):t}function E(e){if(!(e instanceof k))throw Error(`Weierstrass Point expected`)}function re(e){if(!h||!h.basises)throw Error(`no endo`);return Yt(e,h.basises,i.ORDER)}function D(e,t,n,a){if(!i.isValid(a))throw RangeError(`invalid scalar: out of range`);if(h){let{k1neg:i,k1:o,k2neg:s,k2:c}=re(a),l=new k(r.mul(n.X,h.beta),n.Y,n.Z);e.push(i?n.negate():n,s?l.negate():l),t.push(o,c)}else e.push(n),t.push(a)}let O=/* @__PURE__ */ new WeakSet;class k{static BASE=new k(a.Gx,a.Gy,r.ONE);static ZERO=new k(r.ZERO,r.ONE,r.ZERO);static Fp=r;static Fn=i;X;Y;Z;constructor(e,t,n){this.X=T(`x`,e),this.Y=T(`y`,t,!0),this.Z=T(`z`,n),Object.freeze(this)}static CURVE(){return a}static fromAffine(e){let{x:t,y:n}=e||{};if(!e||!r.isValid(t)||!r.isValid(n))throw Error(`invalid affine point`);if(e instanceof k)throw Error(`projective point not allowed`);return r.is0(t)&&r.is0(n)?k.ZERO:new k(t,n,r.ONE)}static fromBytes(e){let t=k.fromAffine(b(M(e,void 0,`point`)));return t.assertValidity(),t}static fromHex(e){return k.fromBytes(Ee(e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=6,t=!0){return A.setWindowSize(this,e),t||this.multiply($t),this}assertValidity(){let e=this;if(e.is0()){if(l&&r.is0(e.X)&&r.eql(e.Y,r.ONE)&&r.is0(e.Z))return;throw Error(`bad point: ZERO`)}if(O.has(e))return;let{x:t,y:n}=e.toAffine();if(!r.isValid(t)||!r.isValid(n))throw Error(`bad point: x or y not field elements`);if(!te(t,n))throw Error(`bad point: equation left != right`);if(!e.isTorsionFree())throw Error(`bad point: not in prime-order subgroup`);O.add(e)}hasEvenY(){let{y:e}=this.toAffine();if(!r.isOdd)throw Error(`Field doesn't support isOdd`);return!r.isOdd(e)}equals(e){E(e);let{X:t,Y:n,Z:i}=this,{X:a,Y:o,Z:s}=e,c=r.eql(r.mul(t,s),r.mul(a,i)),l=r.eql(r.mul(n,s),r.mul(o,i));return c&&l}negate(){return new k(this.X,r.neg(this.Y),this.Z)}double(){let{X:e,Y:t,Z:n}=this,i=r.ZERO,a=r.ZERO,o=r.ZERO,s=r.mul(e,e),c=r.mul(t,t),l=r.mul(n,n),u=r.mul(e,t);return u=r.add(u,u),o=r.mul(e,n),o=r.add(o,o),i=S(o),a=r.mul(x,l),a=r.add(i,a),i=r.sub(c,a),a=r.add(c,a),a=r.mul(i,a),i=r.mul(u,i),o=r.mul(x,o),l=S(l),u=r.sub(s,l),u=S(u),u=r.add(u,o),o=r.add(s,s),s=r.add(o,s),s=r.add(s,l),s=r.mul(s,u),a=r.add(a,s),l=r.mul(t,n),l=r.add(l,l),s=r.mul(l,u),i=r.sub(i,s),o=r.mul(l,c),o=r.add(o,o),o=r.add(o,o),new k(i,a,o)}add(e){E(e);let{X:t,Y:n,Z:i}=this,{X:a,Y:o,Z:s}=e,c=r.ZERO,l=r.ZERO,u=r.ZERO,d=r.mul(t,a),f=r.mul(n,o),p=r.mul(i,s),m=r.add(t,n),h=r.add(a,o);m=r.mul(m,h),h=r.add(d,f),m=r.sub(m,h),h=r.add(t,i);let g=r.add(a,s);return h=r.mul(h,g),g=r.add(d,p),h=r.sub(h,g),g=r.add(n,i),c=r.add(o,s),g=r.mul(g,c),c=r.add(f,p),g=r.sub(g,c),u=S(h),c=r.mul(x,p),u=r.add(c,u),c=r.sub(f,u),u=r.add(f,u),l=r.mul(c,u),f=r.add(d,d),f=r.add(f,d),p=S(p),h=r.mul(x,h),f=r.add(f,p),p=r.sub(d,p),p=S(p),h=r.add(h,p),d=r.mul(f,h),l=r.add(l,d),d=r.mul(g,h),c=r.mul(m,c),c=r.sub(c,d),d=r.mul(m,f),u=r.mul(g,u),u=r.add(u,d),new k(c,l,u)}subtract(e){return E(e),this.add(e.negate())}is0(){return this.equals(k.ZERO)}multiply(e){if(!i.isValidNot0(e))throw RangeError(`invalid scalar: out of range`);let{p:t,f:n}=A.mulSecret(this,e,o,ie);return ie([t,n])[0]}multiplyUnsafe(e){let t=this,n=e;if(!i.isValid(n))throw RangeError(`invalid scalar: out of range`);if(n===H||t.is0())return k.ZERO;if(n===U)return t;if(A.hasWindowSize(this))return A.mulUnsafe(t,n,ie);let r=[],a=[];return D(r,a,t,n),Bt(k,r,a)}mulAddUnsafe(e,t,n){E(t);let r=[],i=[];return D(r,i,this,e),D(r,i,t,n),Bt(k,r,i)}toAffine(e){let t=this,n=e;if(n!=null&&!r.isValid(n))throw RangeError(`"invertedZ" expected valid field element`);let{X:i,Y:a,Z:o}=t;if(r.eql(o,r.ONE))return{x:i,y:a};let s=t.is0();n??=s?r.ONE:r.inv(o);let c=r.mul(i,n),l=r.mul(a,n),u=r.mul(o,n);if(s)return{x:r.ZERO,y:r.ZERO};if(!r.eql(u,r.ONE))throw Error(`invZ was invalid`);return{x:c,y:l}}isTorsionFree(){return o===U?!0:d?d(k,this):A.mulUnsafe(this,s).is0()}clearCofactor(){return o===U?this:u?u(k,this):this.multiplyUnsafe(o)}isSmallOrder(){return o===U?this.is0():this.clearCofactor().is0()}toBytes(e=!0){return P(e,`isCompressed`),this.assertValidity(),y(k,this,e)}toHex(e=!0){return Te(this.toBytes(e))}toString(){return`<Point ${this.is0()?`ZERO`:this.toHex()}>`}}let ie=e=>Dt(k,e),A=new zt(k,m);return A.bits>=6&&k.BASE.precompute(6),Object.freeze(k.prototype),Object.freeze(k),k}function nn(e){return Uint8Array.of(e?2:3)}function rn(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function an(e,t={}){Et(e);let{Fn:n}=e,r=t.randomBytes===void 0?Oe:t.randomBytes,i=Object.assign(rn(e.Fp,n),{seed:Math.max(bt(n.ORDER),16)});function a(e){try{let t=n.fromBytes(e);return n.isValidNot0(t)}catch{return!1}}function o(t,n){let{publicKey:r,publicKeyUncompressed:a}=i;try{let i=t.length;return n===!0&&i!==r||n===!1&&i!==a?!1:!e.fromBytes(t).is0()}catch{return!1}}function s(e){return e=e===void 0?r(i.seed):e,xt(M(e,i.seed,`seed`),n.ORDER)}function c(t,r=!0){return e.BASE.multiply(n.fromBytes(t)).toBytes(r)}function l(e){let{secretKey:t,publicKey:r,publicKeyUncompressed:a}=i,o=n._lengths;if(!De(e))return;let s=M(e,void 0,`key`).length,c=s===r||s===a,l=s===t||!!o?.includes(s);if(!(c&&l))return c}function u(t,r,i=!0){if(l(t)===!0)throw Error(`first arg must be private key`);if(l(r)===!1)throw Error(`second arg must be public key`);let a=n.fromBytes(t),o=e.fromBytes(r);if(o.is0())throw Error(`invalid public key: point at infinity`);return o.multiply(a).toBytes(i)}let d={isValidSecretKey:a,isValidPublicKey:o,randomSecretKey:s},f=Ut(s,c);return Object.freeze(d),Object.freeze(i),Object.freeze({getPublicKey:c,getSharedSecret:u,keygen:f,Point:e,utils:d,lengths:i})}function on(e,t,n={}){Et(e);let r=t;te(r),I(n,{},{hmac:`function`,lowS:`boolean`,randomBytes:`function`,bits2int:`function`,bits2int_modN:`function`});let i=Object.assign({},n),a=i.randomBytes===void 0?Oe:i.randomBytes,o=i.hmac===void 0?(e,t)=>Gt(r,e,t):i.hmac,{Fp:s,Fn:c}=e,{ORDER:l,BITS:u}=c,d=bt(l),f=At(a,d),{keygen:p,getPublicKey:m,getSharedSecret:h,utils:g,lengths:_}=an(e,i),v={prehash:!0,lowS:typeof i.lowS!=`boolean`||i.lowS,format:`compact`,extraEntropy:!1},ee=l*Qt+U<s.ORDER;function y(e){return e>l>>U}function b(e,t){if(!c.isValidNot0(t))throw Error(`invalid signature ${e}: out of range 1..Point.Fn.ORDER`);return t}function x(){if(!s.isOdd)throw Error(`Field doesn't support isOdd`)}function S(e,t,n){return x(),(e===n?0:2)|Number(s.isOdd(t))}function C(){if(ee)throw Error(`"recovered" sig type is not supported for cofactor >2 curves`)}function ne(e,t){Xt(t);let n=_.signature,r=t===`compact`?n:t===`recovered`?n+1:void 0;return M(e,r)}class w{r;s;recovery;constructor(e,t,n){if(this.r=b(`r`,e),this.s=b(`s`,t),n!=null){if(C(),![0,1,2,3].includes(n))throw Error(`invalid recovery id`);this.recovery=n}Object.freeze(this)}static fromBytes(e,t=v.format){ne(e,t);let n;if(t===`der`){if(e.length>2*c.BYTES+16)throw new qt.Err(`invalid signature: DER signature too long`);let{r:t,s:n}=qt.toSig(M(e),c.BYTES+1);return new w(t,n)}t===`recovered`&&(n=e[0],t=`compact`,e=e.subarray(1));let r=_.signature/2,i=e.subarray(0,r),a=e.subarray(r,r*2);return new w(c.fromBytes(i),c.fromBytes(a),n)}static fromHex(e,t){return this.fromBytes(Ee(e),t)}assertRecovery(){let{recovery:e}=this;if(e==null)throw Error(`invalid recovery id: must be present`);return e}addRecoveryBit(e){return new w(this.r,this.s,e)}recoverPublicKey(t){let{r:n,s:r}=this,i=this.assertRecovery(),a=i===2||i===3?n+l:n;if(!s.isValid(a))throw Error(`invalid recovery id: sig.r+curve.n != R.x`);let o=s.toBytes(a),u=e.fromBytes(N(nn(!(i&1)),o)),d=c.inv(a),f=E(M(t,void 0,`msgHash`)),p=c.create(-f*d),m=c.create(r*d),h=e.BASE.mulAddUnsafe(p,u,m);if(h.is0())throw Error(`invalid recovery: point at infinify`);return h.assertValidity(),h}hasHighS(){return y(this.s)}toBytes(e=v.format){if(Xt(e),e===`der`)return Ee(qt.hexFromSig(this));let{r:t,s:n}=this,r=c.toBytes(t),i=c.toBytes(n);return e===`recovered`?(C(),N(Uint8Array.of(this.assertRecovery()),r,i)):N(r,i)}toHex(e){return Te(this.toBytes(e))}}Object.freeze(w.prototype),Object.freeze(w);let T=i.bits2int===void 0?function(e){if(e.length>8192)throw Error(`input is too large`);let t=Ie(e),n=e.length*8-u;return n>0?t>>BigInt(n):t}:i.bits2int,E=i.bits2int_modN===void 0?function(e){return c.create(T(e))}:i.bits2int_modN,re=We(u);function D(e){return He(`num < 2^`+u,e,H,re),c.toBytes(e)}function O(e,t){return M(e,void 0,`message`),t?M(r(e),void 0,`prehashed message`):e}function k(t,n,r){let{lowS:i,prehash:o,extraEntropy:s}=Zt(r,v);t=O(t,o);let u=E(t),p=c.fromBytes(n);if(!c.isValidNot0(p))throw Error(`invalid private key`);let m=[D(p),D(u)];if(s!=null&&s!==!1){let e=s===!0?a(_.secretKey):s;m.push(M(e,void 0,`extraEntropy`))}let h=N(...m),g=u;function b(t){let n=T(t);if(!c.isValidNot0(n))return;let r=e.BASE.multiply(n).toAffine(),a=c.create(r.x);if(a===H)return;let o;if(f!==void 0){let e=Ie(xt(f(d),l)),t=c.inv(c.mul(e,n)),r=c.mul(e,g),i=c.mul(e,p);o=c.create(t*c.create(r+i*a))}else{let e=rt(n,l);o=c.create(e*c.create(g+a*p))}if(o===H)return;let s=S(r.x,r.y,a),u=o;return i&&y(o)&&(u=c.neg(o),s^=1),new w(a,u,ee?void 0:s)}return{seed:h,k2sig:b}}function ie(e,t,n={}){let{seed:i,k2sig:a}=k(e,t,n);return Ge(r.outputLen,c.BYTES,o)(i,a).toBytes(n.format)}function A(t,n,r,i={}){let{lowS:a,prehash:o,format:s}=Zt(i,v);if(r=M(r,void 0,`publicKey`),n=O(n,o),!De(t)){let e=t instanceof w?`, use sig.toBytes()`:``;throw Error(`verify expects Uint8Array signature`+e)}ne(t,s);try{let i=w.fromBytes(t,s),o=e.fromBytes(r);if(o.is0()||a&&i.hasHighS())return!1;let{r:l,s:u}=i,d=E(n),f=c.inv(u),p=c.create(d*f),m=c.create(l*f),h=e.BASE.mulAddUnsafe(p,o,m);if(h.is0())return!1;let g=h.toAffine();return!(c.create(g.x)!==l||s===`recovered`&&i.recovery!==S(g.x,g.y,l))}catch{return!1}}function ae(e,t,n={}){let{prehash:r}=Zt(n,v);return t=O(t,r),w.fromBytes(e,`recovered`).recoverPublicKey(t).toBytes()}return Object.freeze({keygen:p,getPublicKey:m,getSharedSecret:h,utils:g,lengths:_,Point:e,sign:ie,verify:A,recoverPublicKey:ae,Signature:w,hash:r})}
131
+ ;function Jt(e,t,n){Ve(`scalar`,e,U,n);let[[r,i],[a,o]]=t,s=qt(o*e,n),c=qt(-i*e,n),l=e-s*r-c*a,u=-s*i-c*o,d=l<U,f=u<U;d&&(l=-l),f&&(u=-u);let p=Ue(Math.ceil(He(n)/2))+W;if(l<U||l>=p||u<U||u>=p)throw Error(`splitScalar (endomorphism): failed for k`);return{k1neg:d,k1:l,k2neg:f,k2:u}}function Yt(e){if(![`compact`,`recovered`,`der`].includes(e))throw Error(`Signature format must be "compact", "recovered", or "der"`);return e}function Xt(e,t){L(e);let n={};for(let r of Object.keys(t))n[r]=e[r]===void 0?t[r]:e[r];return F(n.lowS,`lowS`),F(n.prehash,`prehash`),n.format!==void 0&&Yt(n.format),n}const U=/* @__PURE__ */ BigInt(0),W=/* @__PURE__ */ BigInt(1),Zt=/* @__PURE__ */ BigInt(2),Qt=/* @__PURE__ */ BigInt(3),$t=/* @__PURE__ */ BigInt(4);function en(e,t={}){let n=Vt(`weierstrass`,e,t),r=n.Fp,i=n.Fn,a=n.CURVE,{h:o,n:s}=a;L(t,{},{allowInfinityPoint:`boolean`,clearCofactor:`function`,isTorsionFree:`function`,fromBytes:`function`,toBytes:`function`,endo:`object`,randomBytes:`function`});let{endo:c,allowInfinityPoint:l,clearCofactor:u,isTorsionFree:d,fromBytes:f,toBytes:p}=t,m=t.randomBytes===void 0?De:t.randomBytes;if(c&&(!r.is0(a.a)||typeof c.beta!=`bigint`||!Array.isArray(c.basises)))throw Error(`invalid endo: expected "beta": bigint and "basises": array`);let h=c?{beta:c.beta,basises:c.basises.map(e=>[...e])}:void 0,g=nn(r,i);function _(){if(!r.isOdd)throw Error(`compression is not supported: Field does not have .isOdd()`)}function v(e,t,n){if(t.is0()){if(!l)throw Error(`bad point: ZERO`);return Uint8Array.of(0)}let{x:i,y:a}=t.toAffine(),o=r.toBytes(i);if(F(n,`isCompressed`),n){_();let e=!r.isOdd(a);return P(tn(e),o)}return P(Uint8Array.of(4),o,r.toBytes(a))}function y(e){N(e,void 0,`Point`);let{publicKey:t,publicKeyUncompressed:n}=g,i=e.length,a=e[0],o=e.subarray(1);if(l&&i===1&&a===0)return{x:r.ZERO,y:r.ZERO};if(i===t&&(a===2||a===3)){let e=r.fromBytes(o);if(!r.isValid(e))throw Error(`bad point: is not on curve, wrong x`);let t=w(e),n;try{n=r.sqrt(t)}catch(e){let t=e instanceof Error?`: `+e.message:``;throw Error(`bad point: is not on curve, sqrt error`+t)}_();let i=r.isOdd(n);return(a&1)==1!==i&&(n=r.neg(n)),{x:e,y:n}}if(i===n&&a===4){let e=r.BYTES,t=r.fromBytes(o.subarray(0,e)),n=r.fromBytes(o.subarray(e,e*2));if(!ee(t,n))throw Error(`bad point: is not on curve`);return{x:t,y:n}}throw Error(`bad point: got length ${i}, expected compressed=${t} or uncompressed=${n}`)}let b=p===void 0?v:p,x=f===void 0?y:f,S=r.mul(a.b,Qt),C=r.is0(a.a)?e=>r.ZERO:e=>r.mul(a.a,e);function w(e){let t=r.sqr(e),n=r.mul(t,e);return r.add(r.add(n,r.mul(e,a.a)),a.b)}function ee(e,t){let n=r.sqr(t),i=w(e);return r.eql(n,i)}if(!ee(a.Gx,a.Gy))throw Error(`bad curve params: generator point`);let te=r.mul(r.pow(a.a,Qt),$t),T=r.mul(r.sqr(a.b),BigInt(27));if(r.is0(r.add(te,T)))throw Error(`bad curve params: a or b`);function E(e,t,n=!1){if(!r.isValid(t)||n&&r.is0(t))throw Error(`bad point coordinate ${e}`);return typeof t==`object`&&t?r.create(t):t}function D(e){if(!(e instanceof A))throw Error(`Weierstrass Point expected`)}function ne(e){if(!h||!h.basises)throw Error(`no endo`);return Jt(e,h.basises,i.ORDER)}function O(e,t,n,a){if(!i.isValid(a))throw RangeError(`invalid scalar: out of range`);if(h){let{k1neg:i,k1:o,k2neg:s,k2:c}=ne(a),l=new A(r.mul(n.X,h.beta),n.Y,n.Z);e.push(i?n.negate():n,s?l.negate():l),t.push(o,c)}else e.push(n),t.push(a)}let k=/* @__PURE__ */ new WeakSet;class A{static BASE=new A(a.Gx,a.Gy,r.ONE);static ZERO=new A(r.ZERO,r.ONE,r.ZERO);static Fp=r;static Fn=i;X;Y;Z;constructor(e,t,n){this.X=E(`x`,e),this.Y=E(`y`,t,!0),this.Z=E(`z`,n),Object.freeze(this)}static CURVE(){return a}static fromAffine(e){let{x:t,y:n}=e||{};if(!e||!r.isValid(t)||!r.isValid(n))throw Error(`invalid affine point`);if(e instanceof A)throw Error(`projective point not allowed`);return r.is0(t)&&r.is0(n)?A.ZERO:new A(t,n,r.ONE)}static fromBytes(e){let t=A.fromAffine(x(N(e,void 0,`point`)));return t.assertValidity(),t}static fromHex(e){return A.fromBytes(Te(e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=6,t=!0){return j.setWindowSize(this,e),t||this.multiply(Qt),this}assertValidity(){let e=this;if(e.is0()){if(l&&r.is0(e.X)&&r.eql(e.Y,r.ONE)&&r.is0(e.Z))return;throw Error(`bad point: ZERO`)}if(k.has(e))return;let{x:t,y:n}=e.toAffine();if(!r.isValid(t)||!r.isValid(n))throw Error(`bad point: x or y not field elements`);if(!ee(t,n))throw Error(`bad point: equation left != right`);if(!e.isTorsionFree())throw Error(`bad point: not in prime-order subgroup`);k.add(e)}hasEvenY(){let{y:e}=this.toAffine();if(!r.isOdd)throw Error(`Field doesn't support isOdd`);return!r.isOdd(e)}equals(e){D(e);let{X:t,Y:n,Z:i}=this,{X:a,Y:o,Z:s}=e,c=r.eql(r.mul(t,s),r.mul(a,i)),l=r.eql(r.mul(n,s),r.mul(o,i));return c&&l}negate(){return new A(this.X,r.neg(this.Y),this.Z)}double(){let{X:e,Y:t,Z:n}=this,i=r.ZERO,a=r.ZERO,o=r.ZERO,s=r.mul(e,e),c=r.mul(t,t),l=r.mul(n,n),u=r.mul(e,t);return u=r.add(u,u),o=r.mul(e,n),o=r.add(o,o),i=C(o),a=r.mul(S,l),a=r.add(i,a),i=r.sub(c,a),a=r.add(c,a),a=r.mul(i,a),i=r.mul(u,i),o=r.mul(S,o),l=C(l),u=r.sub(s,l),u=C(u),u=r.add(u,o),o=r.add(s,s),s=r.add(o,s),s=r.add(s,l),s=r.mul(s,u),a=r.add(a,s),l=r.mul(t,n),l=r.add(l,l),s=r.mul(l,u),i=r.sub(i,s),o=r.mul(l,c),o=r.add(o,o),o=r.add(o,o),new A(i,a,o)}add(e){D(e);let{X:t,Y:n,Z:i}=this,{X:a,Y:o,Z:s}=e,c=r.ZERO,l=r.ZERO,u=r.ZERO,d=r.mul(t,a),f=r.mul(n,o),p=r.mul(i,s),m=r.add(t,n),h=r.add(a,o);m=r.mul(m,h),h=r.add(d,f),m=r.sub(m,h),h=r.add(t,i);let g=r.add(a,s);return h=r.mul(h,g),g=r.add(d,p),h=r.sub(h,g),g=r.add(n,i),c=r.add(o,s),g=r.mul(g,c),c=r.add(f,p),g=r.sub(g,c),u=C(h),c=r.mul(S,p),u=r.add(c,u),c=r.sub(f,u),u=r.add(f,u),l=r.mul(c,u),f=r.add(d,d),f=r.add(f,d),p=C(p),h=r.mul(S,h),f=r.add(f,p),p=r.sub(d,p),p=C(p),h=r.add(h,p),d=r.mul(f,h),l=r.add(l,d),d=r.mul(g,h),c=r.mul(m,c),c=r.sub(c,d),d=r.mul(m,f),u=r.mul(g,u),u=r.add(u,d),new A(c,l,u)}subtract(e){return D(e),this.add(e.negate())}is0(){return this.equals(A.ZERO)}multiply(e){if(!i.isValidNot0(e))throw RangeError(`invalid scalar: out of range`);let{p:t,f:n}=j.mulSecret(this,e,o,re);return re([t,n])[0]}multiplyUnsafe(e){let t=this,n=e;if(!i.isValid(n))throw RangeError(`invalid scalar: out of range`);if(n===U||t.is0())return A.ZERO;if(n===W)return t;if(j.hasWindowSize(this))return j.mulUnsafe(t,n,re);let r=[],a=[];return O(r,a,t,n),zt(A,r,a)}mulAddUnsafe(e,t,n){D(t);let r=[],i=[];return O(r,i,this,e),O(r,i,t,n),zt(A,r,i)}toAffine(e){let t=this,n=e;if(n!=null&&!r.isValid(n))throw RangeError(`"invertedZ" expected valid field element`);let{X:i,Y:a,Z:o}=t;if(r.eql(o,r.ONE))return{x:i,y:a};let s=t.is0();n??=s?r.ONE:r.inv(o);let c=r.mul(i,n),l=r.mul(a,n),u=r.mul(o,n);if(s)return{x:r.ZERO,y:r.ZERO};if(!r.eql(u,r.ONE))throw Error(`invZ was invalid`);return{x:c,y:l}}isTorsionFree(){return o===W?!0:d?d(A,this):j.mulUnsafe(this,s).is0()}clearCofactor(){return o===W?this:u?u(A,this):this.multiplyUnsafe(o)}isSmallOrder(){return o===W?this.is0():this.clearCofactor().is0()}toBytes(e=!0){return F(e,`isCompressed`),this.assertValidity(),b(A,this,e)}toHex(e=!0){return we(this.toBytes(e))}toString(){return`<Point ${this.is0()?`ZERO`:this.toHex()}>`}}let re=e=>Et(A,e),j=new Rt(A,m);return j.bits>=6&&A.BASE.precompute(6),Object.freeze(A.prototype),Object.freeze(A),A}function tn(e){return Uint8Array.of(e?2:3)}function nn(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function rn(e,t={}){Tt(e);let{Fn:n}=e,r=t.randomBytes===void 0?De:t.randomBytes,i=Object.assign(nn(e.Fp,n),{seed:Math.max(yt(n.ORDER),16)});function a(e){try{let t=n.fromBytes(e);return n.isValidNot0(t)}catch{return!1}}function o(t,n){let{publicKey:r,publicKeyUncompressed:a}=i;try{let i=t.length;return n===!0&&i!==r||n===!1&&i!==a?!1:!e.fromBytes(t).is0()}catch{return!1}}function s(e){return e=e===void 0?r(i.seed):e,bt(N(e,i.seed,`seed`),n.ORDER)}function c(t,r=!0){return e.BASE.multiply(n.fromBytes(t)).toBytes(r)}function l(e){let{secretKey:t,publicKey:r,publicKeyUncompressed:a}=i,o=n._lengths;if(!Ee(e))return;let s=N(e,void 0,`key`).length,c=s===r||s===a,l=s===t||!!o?.includes(s);if(!(c&&l))return c}function u(t,r,i=!0){if(l(t)===!0)throw Error(`first arg must be private key`);if(l(r)===!1)throw Error(`second arg must be public key`);let a=n.fromBytes(t),o=e.fromBytes(r);if(o.is0())throw Error(`invalid public key: point at infinity`);return o.multiply(a).toBytes(i)}let d={isValidSecretKey:a,isValidPublicKey:o,randomSecretKey:s},f=Ht(s,c);return Object.freeze(d),Object.freeze(i),Object.freeze({getPublicKey:c,getSharedSecret:u,keygen:f,Point:e,utils:d,lengths:i})}function an(e,t,n={}){Tt(e);let r=t;ee(r),L(n,{},{hmac:`function`,lowS:`boolean`,randomBytes:`function`,bits2int:`function`,bits2int_modN:`function`});let i=Object.assign({},n),a=i.randomBytes===void 0?De:i.randomBytes,o=i.hmac===void 0?(e,t)=>Wt(r,e,t):i.hmac,{Fp:s,Fn:c}=e,{ORDER:l,BITS:u}=c,d=yt(l),f=kt(a,d),{keygen:p,getPublicKey:m,getSharedSecret:h,utils:g,lengths:_}=rn(e,i),v={prehash:!0,lowS:typeof i.lowS!=`boolean`||i.lowS,format:`compact`,extraEntropy:!1},y=l*Zt+W<s.ORDER;function b(e){return e>l>>W}function x(e,t){if(!c.isValidNot0(t))throw Error(`invalid signature ${e}: out of range 1..Point.Fn.ORDER`);return t}function S(){if(!s.isOdd)throw Error(`Field doesn't support isOdd`)}function C(e,t,n){return S(),(e===n?0:2)|Number(s.isOdd(t))}function w(){if(y)throw Error(`"recovered" sig type is not supported for cofactor >2 curves`)}function te(e,t){Yt(t);let n=_.signature,r=t===`compact`?n:t===`recovered`?n+1:void 0;return N(e,r)}class T{r;s;recovery;constructor(e,t,n){if(this.r=x(`r`,e),this.s=x(`s`,t),n!=null){if(w(),![0,1,2,3].includes(n))throw Error(`invalid recovery id`);this.recovery=n}Object.freeze(this)}static fromBytes(e,t=v.format){te(e,t);let n;if(t===`der`){if(e.length>2*c.BYTES+16)throw new Kt.Err(`invalid signature: DER signature too long`);let{r:t,s:n}=Kt.toSig(N(e),c.BYTES+1);return new T(t,n)}t===`recovered`&&(n=e[0],t=`compact`,e=e.subarray(1));let r=_.signature/2,i=e.subarray(0,r),a=e.subarray(r,r*2);return new T(c.fromBytes(i),c.fromBytes(a),n)}static fromHex(e,t){return this.fromBytes(Te(e),t)}assertRecovery(){let{recovery:e}=this;if(e==null)throw Error(`invalid recovery id: must be present`);return e}addRecoveryBit(e){return new T(this.r,this.s,e)}recoverPublicKey(t){let{r:n,s:r}=this,i=this.assertRecovery(),a=i===2||i===3?n+l:n;if(!s.isValid(a))throw Error(`invalid recovery id: sig.r+curve.n != R.x`);let o=s.toBytes(a),u=e.fromBytes(P(tn(!(i&1)),o)),d=c.inv(a),f=D(N(t,void 0,`msgHash`)),p=c.create(-f*d),m=c.create(r*d),h=e.BASE.mulAddUnsafe(p,u,m);if(h.is0())throw Error(`invalid recovery: point at infinify`);return h.assertValidity(),h}hasHighS(){return b(this.s)}toBytes(e=v.format){if(Yt(e),e===`der`)return Te(Kt.hexFromSig(this));let{r:t,s:n}=this,r=c.toBytes(t),i=c.toBytes(n);return e===`recovered`?(w(),P(Uint8Array.of(this.assertRecovery()),r,i)):P(r,i)}toHex(e){return we(this.toBytes(e))}}Object.freeze(T.prototype),Object.freeze(T);let E=i.bits2int===void 0?function(e){if(e.length>8192)throw Error(`input is too large`);let t=Fe(e),n=e.length*8-u;return n>0?t>>BigInt(n):t}:i.bits2int,D=i.bits2int_modN===void 0?function(e){return c.create(E(e))}:i.bits2int_modN,ne=Ue(u);function O(e){return Ve(`num < 2^`+u,e,U,ne),c.toBytes(e)}function k(e,t){return N(e,void 0,`message`),t?N(r(e),void 0,`prehashed message`):e}function A(t,n,r){let{lowS:i,prehash:o,extraEntropy:s}=Xt(r,v);t=k(t,o);let u=D(t),p=c.fromBytes(n);if(!c.isValidNot0(p))throw Error(`invalid private key`);let m=[O(p),O(u)];if(s!=null&&s!==!1){let e=s===!0?a(_.secretKey):s;m.push(N(e,void 0,`extraEntropy`))}let h=P(...m),g=u;function x(t){let n=E(t);if(!c.isValidNot0(n))return;let r=e.BASE.multiply(n).toAffine(),a=c.create(r.x);if(a===U)return;let o;if(f!==void 0){let e=Fe(bt(f(d),l)),t=c.inv(c.mul(e,n)),r=c.mul(e,g),i=c.mul(e,p);o=c.create(t*c.create(r+i*a))}else{let e=nt(n,l);o=c.create(e*c.create(g+a*p))}if(o===U)return;let s=C(r.x,r.y,a),u=o;return i&&b(o)&&(u=c.neg(o),s^=1),new T(a,u,y?void 0:s)}return{seed:h,k2sig:x}}function re(e,t,n={}){let{seed:i,k2sig:a}=A(e,t,n);return We(r.outputLen,c.BYTES,o)(i,a).toBytes(n.format)}function j(t,n,r,i={}){let{lowS:a,prehash:o,format:s}=Xt(i,v);if(r=N(r,void 0,`publicKey`),n=k(n,o),!Ee(t)){let e=t instanceof T?`, use sig.toBytes()`:``;throw Error(`verify expects Uint8Array signature`+e)}te(t,s);try{let i=T.fromBytes(t,s),o=e.fromBytes(r);if(o.is0()||a&&i.hasHighS())return!1;let{r:l,s:u}=i,d=D(n),f=c.inv(u),p=c.create(d*f),m=c.create(l*f),h=e.BASE.mulAddUnsafe(p,o,m);if(h.is0())return!1;let g=h.toAffine();return!(c.create(g.x)!==l||s===`recovered`&&i.recovery!==C(g.x,g.y,l))}catch{return!1}}function ie(e,t,n={}){let{prehash:r}=Xt(n,v);return t=k(t,r),T.fromBytes(e,`recovered`).recoverPublicKey(t).toBytes()}return Object.freeze({keygen:p,getPublicKey:m,getSharedSecret:h,utils:g,lengths:_,Point:e,sign:re,verify:j,recoverPublicKey:ie,Signature:T,hash:r})}
132
132
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
133
- const W=/* @__PURE__ */ on(/* @__PURE__ */ tn({p:BigInt(`0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff`),n:BigInt(`0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551`),h:BigInt(1),a:BigInt(`0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc`),b:BigInt(`0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b`),Gx:BigInt(`0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296`),Gy:BigInt(`0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5`)}),ye),sn=`pkcs8`,cn=sn,ln=`spki`
133
+ const G=/* @__PURE__ */ an(/* @__PURE__ */ en({p:BigInt(`0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff`),n:BigInt(`0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551`),h:BigInt(1),a:BigInt(`0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc`),b:BigInt(`0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b`),Gx:BigInt(`0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296`),Gy:BigInt(`0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5`)}),ve),on=`pkcs8`,sn=on,cn=`spki`
134
134
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
135
- ;function G(){let e=globalThis?.crypto?.subtle;if(typeof e==`object`&&e)return e;throw Error(`crypto.subtle must be defined`)}function un(e,t){return async function(n){let r=await e();return{secretKey:r,publicKey:await t(r)}}}function dn(e){let t=e.match(/[0-9a-f]{2}/gi);if(!t||t.length*2!==e.length)throw Error(`invalid hex`);return Uint8Array.from(t,e=>Number.parseInt(e,16))}function fn(e){let t={...e};for(let[e,n]of Object.entries(t))Array.isArray(n)&&(t[e]=n.slice());return t}function pn(e,t){if(t.type!==e)throw Error(`invalid key type, expected ${e}`)}function mn(e,t,n,r){let i=t?[`deriveBits`]:[`sign`],a=t?[]:[`verify`],o=(e,t)=>t===`jwk`?e:new Uint8Array(e),s={async import(t,n){let r=await G().importKey(n,t,e,!0,a);return pn(`public`,r),r},async export(e,t){pn(`public`,e);let n=await G().exportKey(t,e);return o(n,t)},async convert(e,t,n){return s.export(await s.import(e,t),n)}},c={async import(a,o){let s=G(),c;if(o===`raw`){let t=M(a,n,`secretKey`),o=dn(r),l=new Uint8Array(o.length+t.length);l.set(o,0),l.set(t,o.length),c=await s.importKey(sn,l,e,!0,i)}else t&&o===`jwk`&&(a={...a,key_ops:i}),c=await s.importKey(o,a,e,!0,i);return pn(`private`,c),c},async export(e,t){let r=G();if(pn(`private`,e),t===`raw`){let t=(await r.exportKey(`jwk`,e)).d.replace(/-/g,`+`).replace(/_/g,`/`),i=t.length%4?`=`.repeat(4-t.length%4):``,a=atob(t+i),o=Uint8Array.from(a,e=>e.charCodeAt(0)),s=new Uint8Array(n);return s.set(o,n-o.length),s}let i=await r.exportKey(t,e);return o(i,t)},async convert(e,t,n){return c.export(await c.import(e,t),n)}};async function l(e,t={}){I(t,{},{formatSec:`string`,formatPub:`string`},`opts`);let n=t.formatSec??cn,r=t.formatPub??ln,i=n===`jwk`?{...e}:await c.convert(e,n,`jwk`);return delete i.d,i.key_ops=a,r===`jwk`?i:s.convert(i,`jwk`,r)}async function u(t=cn){let n=await G().generateKey(e,!0,i);return c.export(n.privateKey,t)}let d;return{pub:s,priv:c,async isSupported(){if(d!==void 0)return d;try{let n=G(),r=await n.generateKey(e,!0,i);return await c.export(r.privateKey,`jwk`),t&&await n.deriveBits({name:typeof e==`string`?e:e.name,public:r.publicKey},r.privateKey,8),d=!0}catch{return d=!1}},getPublicKey:l,keygen:un(u,l),utils:Object.freeze({randomSecretKey:u,convertPublicKey:s.convert,convertSecretKey:c.convert})}}function hn(e,t){return{async sign(n,r,i={}){I(i,{},{formatSec:`string`,formatPub:`string`},`opts`);let a=Be(M(n,void 0,`message`)),o=await e.priv.import(r,i.formatSec??cn),s=await G().sign(t,o,a);return new Uint8Array(s)},async verify(n,r,i,a={}){I(a,{},{formatSec:`string`,formatPub:`string`},`opts`);let o=Be(M(n,void 0,`signature`)),s=Be(M(r,void 0,`message`)),c=await e.pub.import(i,a.formatPub??ln);return await G().verify(t,c,o,s)}}}function gn(e,t,n){return{async getSharedSecret(r,i,a={}){I(a,{},{formatSec:`string`,formatPub:`string`},`opts`);let o=a.formatSec===void 0?cn:a.formatSec,s=a.formatPub===void 0?ln:a.formatPub,c=De(i)?Be(M(i,void 0,`publicKey`)):fn(i),l=await e.priv.import(r,o),u=await e.pub.import(c,s),d=await G().deriveBits({name:typeof t==`string`?t:t.name,public:u},l,8*n);return new Uint8Array(d)}}}function _n(e,t,n,r){let i={name:`ECDH`,namedCurve:e},a=mn({name:`ECDSA`,namedCurve:e},!1,n,r),o=mn(i,!0,n,r);return Object.freeze({name:e,isSupported:a.isSupported,getPublicKey:a.getPublicKey,keygen:un(a.utils.randomSecretKey,a.getPublicKey),...hn(a,{name:`ECDSA`,hash:{name:t}}),...gn(o,i,n),utils:Object.freeze({...a.utils,async convertSecretKey(e,t,n){let r=t===`jwk`?e:void 0;return Array.isArray(r?.key_ops)&&r.key_ops.length===1&&r.key_ops[0]===`deriveBits`?o.utils.convertSecretKey(e,t,n):a.utils.convertSecretKey(e,t,n)}})})}const vn=/* @__PURE__ */ _n(`P-256`,`SHA-256`,32,`3041020100301306072a8648ce3d020106082a8648ce3d030107042730250201010420`),yn={parseError:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internalError:-32603,serverError:-32e3,clientNotConnected:-32001,configError:-32002,corruptedResponse:-32003,clientAborted:-32004,walletNotConnected:-32005,serverErrorForInteractionDelegation:-32006,userRejected:-32007};var bn=class extends Error{code;data;constructor(e,t,n){super(t),this.code=e,this.data=n}toJSON(){return{code:this.code,message:this.message,data:this.data}}},xn=class{_promise;_resolve;_reject;constructor(){this._promise=new Promise((e,t)=>{this._resolve=e,this._reject=t})}get promise(){return this._promise}resolve=e=>{this._resolve?.(e)};reject=e=>{this._reject?.(e)}};function Sn(e){return new bn(e.code,e.message,e.data)}function Cn(e){let{emittingTransport:t,listeningTransport:n,targetOrigin:r,middleware:i=[],lifecycleHandlers:a}=e,o=/* @__PURE__ */ new Map;function s(e){return typeof e!=`object`||!e?!1:`clientLifecycle`in e||`iframeLifecycle`in e}function c(e){return typeof e!=`object`||!e?!1:`id`in e&&`topic`in e&&`data`in e}async function l(e){try{`clientLifecycle`in e&&a?.clientLifecycle?await a.clientLifecycle(e,{origin:r,source:null}):`iframeLifecycle`in e&&a?.iframeLifecycle&&await a.iframeLifecycle(e,{origin:r,source:null})}catch(e){console.error(`[RPC Client] Lifecycle handler error:`,e)}}async function u(e){let t={origin:r,source:null};for(let n of i)n.onRequest&&await n.onRequest(e,t);return e}async function d(e,t){let n={origin:r,source:null},a=t;for(let t of i)t.onResponse&&(a=await t.onResponse(e,a,n));return a}async function f(e){try{if(new URL(e.origin).origin.toLowerCase()!==new URL(r).origin.toLowerCase())return}catch(e){console.error(`[RPC Client] Invalid origin`,e);return}if(s(e.data)){await l(e.data);return}if(!c(e.data))return;let t;try{let n=e.data.data,r=n instanceof Uint8Array||ArrayBuffer.isView(n)?{result:n}:n;t=await d(e.data,r)}catch(e){console.error(`[RPC Client] Middleware error on response:`,e),t={error:{code:yn.internalError,message:e instanceof Error?e.message:`Response middleware failed`}}}let n=o.get(e.data.id);n&&n(t)}async function p(e){let n=await u(e);t.postMessage(n,r)}function m(e){t.postMessage(e,r)}function h(){return`${Date.now()}-${Math.random().toString(36).substring(2,9)}`}n.addEventListener(`message`,f);function g(e){let t=h(),n=new xn;return o.set(t,e=>{e.error?n.reject(Sn(e.error)):n.resolve(e.result),o.delete(t)}),p({id:t,topic:e.method,data:{method:e.method,params:e.params}}).catch(e=>{o.delete(t),n.reject(e)}),n.promise}function _(e,t,n){let r=h(),i=!1;return o.set(r,e=>{e.error?(console.error(`[RPC Client] Listener error:`,e.error),o.delete(r),n?.(Sn(e.error))):t(e.result)}),p({id:r,topic:e.method,data:{method:e.method,params:e.params}}).catch(e=>{console.error(`[RPC Client] Failed to send listener request:`,e),o.delete(r),i||n?.(e)}),()=>{i=!0,o.delete(r)}}function v(){n.removeEventListener(`message`,f),o.clear()}return{request:g,listen:_,sendLifecycle:m,cleanup:v}}function wn(e){return new TextEncoder().encode(JSON.stringify(e))}function Tn(e){try{return JSON.parse(new TextDecoder().decode(e))}catch{return null}}const En=`__frakEnv`,Dn={prod:{wallet:`https://wallet.frak.id`,backend:`https://backend.frak.id`},dev:{wallet:`https://wallet-dev.frak.id`,backend:`https://backend.gcp-dev.frak.id`}};function On(){return typeof window<`u`}let kn=Dn.prod;function An(e){return e.replace(/\/+$/,``)}function jn(e){return typeof e==`string`?Object.hasOwn(Dn,e)?Dn[e]:(console.error(`[Frak SDK] Unknown env "${e}", falling back to production. Expected "prod", "dev", or { wallet, backend }.`),Dn.prod):!e?.wallet||!e?.backend?(console.error("[Frak SDK] env must state both `wallet` and `backend` origins, falling back to production. Received:",e),Dn.prod):{wallet:An(e.wallet),backend:An(e.backend)}}function Mn(e){if(!e)return Nn();let t=jn(e),n=On()?window[En]:void 0;return n&&(n.wallet!==t.wallet||n.backend!==t.backend)&&console.warn(`[Frak SDK] env changed after being published; the last value wins for every SDK call on this page.`,{previous:n,next:t}),kn=t,On()&&(window[En]=t),t}function Nn(){return On()?window[En]??kn:kn}function Pn(){return Nn().wallet}function K(){return Nn().backend}var Fn=class extends Map{maxSize;constructor(e){super(),this.maxSize=e}get(e){let t=super.get(e);return super.has(e)&&(super.delete(e),super.set(e,t)),t}set(e,t){if(super.has(e)&&super.delete(e),super.set(e,t),this.maxSize&&this.size>this.maxSize){let e=super.keys().next().value;e!==void 0&&super.delete(e)}return this}};let In;function Ln(){return In||={promiseCache:new Fn(1024),responseCache:new Fn(1024),failureCache:new Fn(1024)},In}async function Rn(e,{cacheKey:t,cacheTime:n=3e4}){let{promiseCache:r,responseCache:i,failureCache:a}=Ln();if(n>0){let e=i.get(t);if(e&&Date.now()-e.created<n)return e.data}let o=a.get(t);if(o&&Date.now()-o<1e3)throw Error(`Cache: ${t} recently failed, backing off`);let s=r.get(t);s||(s=e(),r.set(t,s));try{let e=await s;return i.set(t,{data:e,created:Date.now()}),a.delete(t),e}catch(e){throw a.set(t,Date.now()),e}finally{r.delete(t)}}function zn(){In&&(In.promiseCache.clear(),In.responseCache.clear(),In.failureCache.clear())}const Bn=`__frakSdkConfig`,Vn=`frak-config-cache`,Hn=`frak-merchant-id`,Un={key:Vn},q=typeof window<`u`;function Wn(){return{isResolved:!1,merchantId:``}}let Gn=null;function Kn(){if(!q)return null;try{let e=localStorage.getItem(Un.key);if(!e)return null;let t=JSON.parse(e);return t.config?.isResolved?(Gn=t,t):null}catch{return null}}function qn(){return(Gn??Kn())?.config}function Jn(){let e=Gn??Kn();return e?Date.now()-e.timestamp<3e4:!1}function Yn(e){if(q&&e.isResolved)try{let t={config:e,timestamp:Date.now()};localStorage.setItem(Un.key,JSON.stringify(t)),Gn=t}catch{}}function Xn(){if(q){Gn=null;try{localStorage.removeItem(Un.key)}catch{}}}function Zn(){q&&(window[Bn]||(window[Bn]=qn()??Wn()))}function Qn(){return q?(Zn(),window[Bn]??Wn()):Wn()}function $n(e){q&&window.dispatchEvent(new CustomEvent(`frak:config`,{detail:e}))}function er(e){return e??(q?window.location.hostname:``)}async function tr(e,t){try{let n=K(),r=t?`&lang=${encodeURIComponent(t)}`:``,i=await fetch(`${n}/user/merchant/resolve?domain=${encodeURIComponent(e)}${r}`);if(!i.ok){console.warn(`[Frak SDK] Merchant lookup failed for domain ${e}: ${i.status}`);return}let a=await i.json();if(q)try{sessionStorage.setItem(Hn,a.merchantId)}catch{}return a}catch(e){console.warn(`[Frak SDK] Failed to fetch merchant config:`,e);return}}const J={getConfig:Qn,get isResolved(){return Qn().isResolved},get isCacheFresh(){return Jn()},setCacheScope(e,t){let n=`${Vn}:${e}:${t??``}`;n!==Un.key&&(Un.key=n,Gn=null)},setConfig(e){if(q&&(window[Bn]=e),Yn(e),$n(e),q&&e.merchantId)try{sessionStorage.setItem(Hn,e.merchantId)}catch{}},reset(){let e=qn()??Wn();q&&(window[Bn]=e),$n(e)},clearCache(){if(Xn(),zn(),q)try{sessionStorage.removeItem(Hn)}catch{}},resolve(e,t){let n=er(e);return n?Rn(async()=>{let e=await tr(n,t);if(!e)throw Error(`Config resolution returned empty`);return e},{cacheKey:`sdkConfig:${n}:${t??``}`,cacheTime:1/0}).catch(()=>void 0):Promise.resolve(void 0)},getMerchantId(){let e=Qn();if(e.isResolved&&e.merchantId)return e.merchantId;if(q)try{return sessionStorage.getItem(Hn)??void 0}catch{}},async resolveMerchantId(e){return J.getMerchantId()||(await J.resolve(e))?.merchantId}};function nr(){if(typeof navigator<`u`)return navigator.locks}async function rr(e,t,n={}){let r=nr();if(!r)return t();if(n.ifAvailable){let n=!1;try{return await r.request(e,{ifAvailable:!0},async e=>{if(e)return n=!0,t()})}catch(e){if(n)throw e;return t()}}let i=new AbortController,a=setTimeout(()=>i.abort(),5e3),o=!1;try{return await r.request(e,{signal:i.signal},()=>(o=!0,t()))}catch(e){if(o)throw e;return t()}finally{clearTimeout(a)}}async function ir(e){return p(ye(e))}const ar=`frak-client-id`,or=`frak-client-key`,sr=`frak-client-id-legacy`,cr=/* @__PURE__ */ h(`308187020100301306072a8648ce3d020106082a8648ce3d030107046d306b0201010420`),lr=/* @__PURE__ */ h(`a144034200`),ur={formatSec:`pkcs8`,formatPub:`raw`};function dr(e,t){let n=new Uint8Array(cr.length+32+lr.length+65),r=0;for(let i of[cr,e,lr,t])n.set(i,r),r+=i.length;return n}const fr=/* @__PURE__ */ (/* @__PURE__ */ new Uint8Array(32)).fill(1),pr=/* @__PURE__ */ new Uint8Array(32);let mr=null;async function hr(){try{if(!await vn.isSupported())return W;let e=dr(fr,W.getPublicKey(fr,!1));return await vn.sign(pr,e,ur),vn}catch{return W}}function gr(){return mr??=hr(),mr}function _r(e,t,n,r){if(e===vn){let e=dr(n,r);return vn.sign(t,e,ur)}return Promise.resolve(W.sign(t,n,{prehash:!0}))}const vr=()=>typeof window<`u`&&!!window.localStorage;let yr=null;function br(e){let t=m(e);if(yr?.keyHex===t)return yr.publicKey;let n=W.getPublicKey(e,!1);return yr={keyHex:t,publicKey:n},n}function xr(){if(vr())return localStorage.getItem(sr)??void 0}function Sr(){vr()&&localStorage.removeItem(sr)}function Cr(){let e=localStorage.getItem(or);if(!e)return null;if(!/^[0-9a-f]{64}$/i.test(e))throw Error(`[Frak SDK] Corrupt client key`);return h(e)}function wr(e){try{for(let[t,n]of e)localStorage.setItem(t,n)}catch{}}async function Tr(){if(!vr())throw Error(`[Frak SDK] No window/localStorage available to derive a client id`);if(typeof crypto>`u`||!crypto.getRandomValues)throw Error(`[Frak SDK] crypto.getRandomValues unavailable, cannot derive a client id`);return rr(`frak-identity-key`,Er)}async function Er(){let e=localStorage.getItem(ar),t,n,r;try{t=Cr(),n=t??W.utils.randomSecretKey(),r=await ir(br(n))}catch(e){throw localStorage.removeItem(or),yr=null,e}if(t){e!==r&&wr([[ar,r]]);let t=xr();return{clientId:r,...t&&{pendingLegacyId:t}}}return wr([...e?[[sr,e]]:[],[or,m(n)],[ar,r]]),{clientId:r,...e&&{pendingLegacyId:e}}}async function Y(e){if(!vr())return null;try{let t=Cr();if(!t)return null;let n=e.ts??Math.floor(Date.now()/1e3),r=f({op:e.op,merchantId:e.merchantId,anonymousId:e.anonymousId,binding:e.binding??/* @__PURE__ */ new Uint8Array,ts:n}),i=br(t),a=await gr(),o;try{o=await _r(a,r,t,i)}catch(e){if(a===W)throw e;mr=Promise.resolve(W),o=await _r(W,r,t,i)}return _({v:1,pk:i,ts:n,sig:o})}catch{return null}}function Dr(){return{"x-frak-sdk-version":`1.6.0-beta.92148223`}}const Or=/* @__PURE__ */ new Set([`PROOF_REQUIRED`,`PROOF_OR_TOKEN_REQUIRED`,`MISSING_ANONYMOUS_ID`]);async function kr(e){if(e.status>=500||e.status===403)return!0;try{let t=await e.clone().json();return typeof t.code==`string`&&Or.has(t.code)}catch{return!1}}async function Ar({legacyId:e,derivedId:t}){typeof window<`u`&&(!e||e===t?Sr():await rr(`frak-legacy-merge`,async()=>{xr()===e&&await jr({legacyId:e,derivedId:t})},{ifAvailable:!0}))}async function jr({legacyId:e,derivedId:t}){try{let n=await J.resolveMerchantId();if(!n)return;let r=await Y({op:`frak-merge-v1`,merchantId:n,anonymousId:t});if(!r)return;let i=K(),a=await fetch(`${i}/user/identity/merge/initiate`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,...Dr()},body:JSON.stringify({sourceAnonymousId:t,merchantId:n,proof:r})});if(!a.ok){await kr(a)||Sr();return}let{mergeToken:o}=await a.json();if(!o)return;let s=await fetch(`${i}/user/identity/merge/execute`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,...Dr()},body:JSON.stringify({mergeToken:o,targetAnonymousId:e,merchantId:n})});if(s.ok){Sr();return}await kr(s)||Sr()}catch{}}let Mr=null,Nr=null;async function Pr(){return Mr||Nr||(Nr=Tr().then(({clientId:e,pendingLegacyId:t})=>(Mr=e,t&&Ar({legacyId:t,derivedId:e}),e)),Nr)}function Fr(){if(Mr)return Mr;Pr().catch(()=>{})}async function X(){return Mr||Pr()}function Ir(e){return btoa(Array.from(e,e=>String.fromCharCode(e)).join(``)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function Lr(e){let t=e.length%4;return Uint8Array.from(atob(e.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(e.length+(t===0?0:4-t),`=`)),e=>e.charCodeAt(0))}function Rr(e){return Ir(wn(e))}function zr(e,t,n,r,i,a,o){let s=Rr(Br({redirectUrl:t.redirectUrl,directExit:t.directExit,lang:t.lang,merchantId:n,metadata:{name:r,css:a,logoUrl:t.metadata?.logoUrl,homepageLink:t.metadata?.homepageLink},clientId:i,proof:o})),c=new URL(e);return c.pathname=`/sso`,c.searchParams.set(`p`,s),c.toString()}function Br(e){return{r:e.redirectUrl,cId:e.clientId,d:e.directExit,l:e.lang,m:e.merchantId,md:{n:e.metadata?.name,css:e.metadata?.css,l:e.metadata?.logoUrl,h:e.metadata?.homepageLink},pf:e.proof}}function Vr(e){return{...e,directExit:e.directExit??!e.redirectUrl}}async function Hr(e,t){let{metadata:n,customizations:r}=e.config,i=Fr()??await X().catch(()=>void 0),a=await J.resolveMerchantId()??``,o=i&&a?await Y({op:`frak-sso-v1`,merchantId:a,anonymousId:i}):null;return{ssoUrl:zr(Pn(),Vr(t),a,n.name,i,r?.css,o??void 0)}}const Ur=`menubar=no,status=no,scrollbars=no,fullscreen=no,width=500, height=800`,Wr=`frak-sso`;async function Gr(e,t){let{metadata:n,customizations:r}=e.config;if(`ssoUrl`in t)return Kr(t.ssoUrl),await e.request({method:`frak_openSso`,params:[{},n.name,r?.css]})??{};let i=Vr(t);return i.openInSameWindow??!!i.redirectUrl?await e.request({method:`frak_openSso`,params:[i,n.name,r?.css]}):(Kr(i.ssoPopupUrl??(await Hr(e,i)).ssoUrl),await e.request({method:`frak_openSso`,params:[i,n.name,r?.css]})??{})}function Kr(e){let t=window.open(e,Wr,Ur);if(!t)throw Error(`Popup was blocked. Please allow popups for this site.`);t.focus()}function Z(e,t,n){if(e)try{e.openPanel?.track(t,n)}catch(e){console.debug(`[Frak] Failed to track event:`,t,e)}}function qr(e,t){let n=e.get(t);if(n!==null)return n;let r=t.toLowerCase();for(let[t,n]of e)if(t.toLowerCase()===r)return n;return null}function Q(e,t){let n=t.toLowerCase(),r=[...e.keys()].filter(e=>e.toLowerCase()===n);for(let t of r)e.delete(t)}const Jr=/^0x[a-fA-F0-9]{40}$/;function Yr(e){return typeof e==`string`&&Jr.test(e)}function Xr(e,t){return e.toLowerCase()===t.toLowerCase()}function Zr(e){let t=/* @__PURE__ */ new Uint8Array(20);for(let n=0;n<20;n++){let r=Number.parseInt(e.substring(2+n*2,4+n*2),16);if(Number.isNaN(r))throw Error(`Invalid address: ${e}`);t[n]=r}return t}const Qr=/*#__PURE__*/ Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function $r(e){let t=`0x`;for(let n=0;n<20;n++)t+=Qr[e[n]];return t}function ei(e){return`r`in e&&!(`v`in e)}function ti(e){return`v`in e&&e.v===2}const ni=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function ri(e){return typeof e==`string`&&ni.test(e)}function ii(e){let t=e.replace(/-/g,``),n=/* @__PURE__ */ new Uint8Array(16);for(let e=0;e<16;e++)n[e]=Number.parseInt(t.substring(e*2,e*2+2),16);return n}function ai(e){let t=``;for(let n=0;n<16;n++)t+=e[n].toString(16).padStart(2,`0`);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20,32)}`}function oi(e){if(!ri(e.m)||!Number.isInteger(e.t)||e.t<0||e.t>4294967295)return null;let t=typeof e.c==`string`&&e.c.length>0,n=typeof e.w==`string`&&Yr(e.w);if(!t&&!n||t&&!ri(e.c))return null;let r=new Uint8Array(21+(t?16:0)+(n?20:0)),i=new DataView(r.buffer,r.byteOffset,r.byteLength),a=0;return r[a++]=2|(t?16:0)|(n?32:0),r.set(ii(e.m),a),a+=16,i.setUint32(a,e.t,!1),a+=4,t&&(r.set(ii(e.c),a),a+=16),n&&(r.set(Zr(e.w),a),a+=20),r}function si(e){if(e.length<21)return null;let t=e[0];if((t&15)!=2||t&192)return null;let n=!!(t&16),r=!!(t&32);if(!n&&!r)return null;let i=21+(n?16:0)+(r?20:0);if(e.length!==i)return null;let a=1,o=ai(e.subarray(a,a+16));a+=16;let s=new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(a,!1);a+=4;let c={v:2,m:o,t:s};if(n&&(c.c=ai(e.subarray(a,a+16)),a+=16),r){let t=$r(e.subarray(a,a+20));if(!Yr(t))return null;c.w=t,a+=20}return c}const ci=`fCtx`;function li(e){try{return new URL(e)}catch{return null}}function ui(e){return e.protocol===`http:`||e.protocol===`https:`}function di(e){if(e)try{if(ti(e)){let t=oi(e);return t?Ir(t):void 0}return Ir(Zr(e.r))}catch(t){console.error(`Error compressing Frak context`,{e:t,context:e})}}function fi(e){if(e&&e.length!==0)try{let t=Lr(e);if(t.length!==20)return si(t)||void 0;let n=$r(t);if(Yr(n))return{r:n}}catch(t){console.error(`Error decompressing Frak context`,{e:t,context:e})}}function pi({url:e}){if(!e)return null;let t=li(e);if(!t)return null;let n=qr(t.searchParams,ci);return n?fi(n):null}function mi(e){return{utm_source:e.utmSource??`frak`,utm_medium:e.utmMedium??void 0,utm_campaign:e.utmCampaign??void 0,utm_content:e.utmContent,utm_term:e.utmTerm,via:e.via??void 0,ref:e.ref??void 0}}function hi(e,t){let n=mi(t??{});for(let[t,r]of Object.entries(n))r!==void 0&&r!==``&&(e.searchParams.has(t)||e.searchParams.set(t,r))}function gi({url:e,context:t,attribution:n}){let r=e?li(e):null;return!r||!ui(r)?null:_i(r,t,n)}function _i(e,t,n){let r=di(t);return r?(Q(e.searchParams,ci),e.searchParams.set(ci,r),hi(e,n),e.toString()):null}function vi(e){let t=li(e);return t?(Q(t.searchParams,ci),t.toString()):e}function yi({url:e,context:t}){if(typeof window>`u`||!window.location?.href){console.error(`No window found, can't update context`);return}let n=e??window.location.href,r;if(t!==null){let e=li(n);r=e?_i(e,t):null}else r=vi(n);r&&window.history.replaceState(null,``,r.toString())}const bi={compress:di,decompress:fi,parse:pi,update:gi,remove:vi,replaceUrl:yi},xi={eur:`fr-FR`,usd:`en-US`,gbp:`en-GB`};function Si(e){return e&&e in xi?e:`eur`}function Ci(e){return e?xi[e]??xi.eur:xi.eur}function wi(e){return e.replaceAll(` `,`\xA0`)}function Ti(e,t){let n=Ci(t),r=Si(t);return wi(e.toLocaleString(n,{style:`currency`,currency:r,minimumFractionDigits:0,maximumFractionDigits:2}))}function Ei(e){return e.formatToParts(1.1).find(e=>e.type===`decimal`)?.value??`.`}function Di(e,t){let n=Ci(t),r=Si(t),i=new Intl.NumberFormat(n,{style:`currency`,currency:r,minimumFractionDigits:0,maximumFractionDigits:2}),a=i.formatToParts(e),o=``,s=``,c=``,l=`suffix`,u=!1;for(let e of a)switch(e.type){case`integer`:case`group`:o+=wi(e.value),u=!0;break;case`decimal`:case`fraction`:s+=e.value;break;case`currency`:c=e.value,l=u?`suffix`:`prefix`}return{integer:o,decimals:s||`${Ei(i)}00`,unit:c,unitPosition:l}}function Oi(e){return{integer:String(e),unit:`%`,unitPosition:`suffix`}}function ki(e){return e?`${e}Amount`:`eurAmount`}var Ai=class{constructor(e){this.baseUrl=e.baseUrl,this.headers={"Content-Type":`application/json`,...e.defaultHeaders},this.maxRetries=e.maxRetries??3,this.initialRetryDelay=e.initialRetryDelay??500}async resolveHeaders(){let e={};for(let[t,n]of Object.entries(this.headers)){let r=await n;r!==null&&(e[t]=r)}return e}addHeader(e,t){this.headers[e]=t}async post(e,t,n,r){try{let r=await fetch(e,{method:`POST`,headers:await this.resolveHeaders(),body:t?JSON.stringify(t??{}):void 0,keepalive:!0,...n});if(r.status===401)return null;if(r.status!==200&&r.status!==202)throw Error(`HTTP error! status: ${r.status}`);let i=await r.text();return i?JSON.parse(i):null}catch(i){if(r<this.maxRetries){let i=this.initialRetryDelay*2**r;return await new Promise(e=>setTimeout(e,i)),this.post(e,t,n,r+1)}return console.error(`Max retries reached:`,i),null}}async fetch(e,t,n={}){let r=`${this.baseUrl}${e}`;return this.post(r,t,n,0)}},ji=class{constructor(e){this.groups=[],this.queue=[],this.options=e;let t={"openpanel-client-id":e.clientId};e.clientSecret&&(t[`openpanel-client-secret`]=e.clientSecret),t[`openpanel-sdk-name`]=e.sdk||`node`,t[`openpanel-sdk-version`]=e.sdkVersion||`1.3.2`,this.api=new Ai({baseUrl:e.apiUrl||`https://api.openpanel.dev`,defaultHeaders:t})}init(){}ready(){this.options.disabled=!1,this.options.waitForProfile=!1,this.flush()}shouldQueue(e){return!!(this.options.disabled||this.options.waitForProfile&&!this.profileId||e.type===`replay`&&!this.sessionId)}addQueue(e){e.type===`track`&&(e.payload.properties={...e.payload.properties??{},__timestamp:(/* @__PURE__ */ new Date()).toISOString()}),this.queue.push(e)}async send(e){if(this.options.filter&&!this.options.filter(e))return Promise.resolve();if(this.shouldQueue(e))return this.addQueue(e),Promise.resolve();let t=await this.api.fetch(`/track`,e,{keepalive:e.type!==`replay`});this.deviceId=t?.deviceId;let n=!!this.sessionId;return this.sessionId=t?.sessionId,!n&&this.sessionId&&this.flush(),t}setGlobalProperties(e){this.global={...this.global,...e}}track(e,t){this.log(`track event`,e,t);let{groups:n,profileId:r,...i}=t??{},a=[.../* @__PURE__ */ new Set([...this.groups,...n??[]])];return this.send({type:`track`,payload:{name:e,profileId:r??this.profileId,groups:a.length>0?a:void 0,properties:{...this.global??{},...i}}})}identify(e){if(this.log(`identify user`,e),e.profileId&&(this.profileId=e.profileId,this.flush()),e.profileId&&Object.keys(e).length>1)return this.send({type:`identify`,payload:{...e,properties:{...this.global,...e.properties}}})}upsertGroup(e){return this.log(`upsert group`,e),this.send({type:`group`,payload:e})}setGroup(e){return this.log(`set group`,e),this.groups.includes(e)||(this.groups=[...this.groups,e]),this.send({type:`assign_group`,payload:{groupIds:[e],profileId:this.profileId}})}setGroups(e){return this.log(`set groups`,e),this.groups=[.../* @__PURE__ */ new Set([...this.groups,...e])],this.send({type:`assign_group`,payload:{groupIds:e,profileId:this.profileId}})}alias(e){}increment(e){return this.send({type:`increment`,payload:e})}decrement(e){return this.send({type:`decrement`,payload:e})}revenue(e,t){let n=t?.deviceId;return delete t?.deviceId,this.track(`revenue`,{...t??{},...n?{__deviceId:n}:{},__revenue:e})}getDeviceId(){return this.deviceId??``}getSessionId(){return this.sessionId??``}fetchDeviceId(){return Promise.resolve(this.deviceId??``)}clear(){this.profileId=void 0,this.groups=[],this.deviceId=void 0,this.sessionId=void 0}buildFlushPayload(e){if(e.type===`replay`)return e.payload;if(e.type===`track`){let t=`groups`in e.payload?e.payload.groups??[]:[],n=[.../* @__PURE__ */ new Set([...this.groups,...t])];return{...e.payload,profileId:e.payload.profileId??this.profileId,groups:n.length>0?n:void 0}}return e.type===`identify`||e.type===`increment`||e.type===`decrement`||e.type===`assign_group`?{...e.payload,profileId:e.payload.profileId??this.profileId}:e.payload}flush(){let e=[];for(let t of this.queue){if(this.shouldQueue(t)){e.push(t);continue}let n=this.buildFlushPayload(t);this.send({...t,payload:n})}this.queue=e}log(...e){this.options.debug&&console.log(`[OpenPanel.dev]`,...e)}},Mi=typeof document<`u`?document.currentScript:null;function Ni(e){return e.replace(/([-_][a-z])/gi,e=>e.toUpperCase().replace(`-`,``).replace(`_`,``))}var Pi=class extends ji{constructor(e){if(super({sdk:`web`,sdkVersion:`1.4.2`,...e}),this.options=e,this.lastPath=``,this.pendingRevenues=[],!this.isServer()){try{let e=sessionStorage.getItem(`openpanel-pending-revenues`);if(e){let t=JSON.parse(e);Array.isArray(t)&&(this.pendingRevenues=t)}}catch{this.pendingRevenues=[]}if(this.setGlobalProperties({__referrer:document.referrer}),this.options.trackScreenViews&&(this.trackScreenViews(),setTimeout(()=>this.screenView(),0)),this.options.trackOutgoingLinks&&this.trackOutgoingLinks(),this.options.trackAttributes&&this.trackAttributes(),this.options.sessionReplay?.enabled){let e=this.options.sessionReplay.sampleRate??1;Math.random()<e&&this.loadReplayModule().then(e=>{e&&e.startReplayRecorder(this.options.sessionReplay,e=>{this.send({type:`replay`,payload:{...e,sessionId:this.sessionId}})})})}}}async loadReplayModule(){try{if(typeof __OPENPANEL_REPLAY_URL__<`u`){let e=Mi,t=this.options.sessionReplay?.scriptUrl||e?.src?.replace(`.js`,`-replay.js`)||`https://openpanel.dev/op1-replay.js`;return window.__openpanel_replay?window.__openpanel_replay:new Promise(e=>{let n=document.createElement(`script`);n.src=t,n.onload=()=>{e(window.__openpanel_replay??null)},n.onerror=()=>{console.warn(`[OpenPanel] Failed to load replay script from`,t),e(null)},document.head.appendChild(n)})}return await import(`./replay-V6FXES7X.CgBxdfNp.js`)}catch(e){return console.warn(`[OpenPanel] Failed to load replay module`,e),null}}debounce(e,t){clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(e,t)}isServer(){return typeof document>`u`}trackOutgoingLinks(){this.isServer()||document.addEventListener(`click`,e=>{let t=e.target,n=t.closest(`a`);if(n&&t){let e=n.getAttribute(`href`);if(e?.startsWith(`http`))try{let r=new URL(e),i=window.location.hostname;r.hostname!==i&&this.track(`link_out`,{href:e,text:n.innerText||n.getAttribute(`title`)||t.getAttribute(`alt`)||t.getAttribute(`title`)})}catch{}}})}trackScreenViews(){if(this.isServer())return;let e=history.pushState;history.pushState=function(...t){let n=e.apply(this,t);return window.dispatchEvent(new Event(`pushstate`)),window.dispatchEvent(new Event(`locationchange`)),n};let t=history.replaceState;history.replaceState=function(...e){let n=t.apply(this,e);return window.dispatchEvent(new Event(`replacestate`)),window.dispatchEvent(new Event(`locationchange`)),n},window.addEventListener(`popstate`,()=>{window.dispatchEvent(new Event(`locationchange`))});let n=()=>this.debounce(()=>this.screenView(),50);this.options.trackHashChanges?window.addEventListener(`hashchange`,n):window.addEventListener(`locationchange`,n)}trackAttributes(){this.isServer()||document.addEventListener(`click`,e=>{let t=e.target,n=t.closest(`button`),r=t.closest(`a`),i=n?.getAttribute(`data-track`)?n:r?.getAttribute(`data-track`)?r:null;if(i){let e={};for(let t of i.attributes)t.name.startsWith(`data-`)&&t.name!==`data-track`&&(e[Ni(t.name.replace(/^data-/,``))]=t.value);let t=i.getAttribute(`data-track`);t&&this.track(t,e)}})}track(e,t){return super.track(e,{...t,__path:this.currentPath()})}currentPath(){return this.lastPath?this.lastPath:this.isServer()?``:window.location.href}screenView(e,t){if(this.isServer())return;let n,r;typeof e==`string`?(n=e,r=t):(n=window.location.href,r=e),this.lastPath!==n&&(this.lastPath=n,super.track(`screen_view`,{...r??{},__path:n,__title:document.title}))}async flushRevenue(){let e=this.pendingRevenues.map(e=>super.revenue(e.amount,e.properties));await Promise.all(e),this.clearRevenue()}clearRevenue(){if(this.pendingRevenues=[],!this.isServer())try{sessionStorage.removeItem(`openpanel-pending-revenues`)}catch{}}pendingRevenue(e,t){if(this.pendingRevenues.push({amount:e,properties:t}),!this.isServer())try{sessionStorage.setItem(`openpanel-pending-revenues`,JSON.stringify(this.pendingRevenues))}catch{}}};function Fi(e){let t=e?.split(`-`)[0]?.toLowerCase();return t===`en`||t===`fr`?t:void 0}function Ii(){return(typeof document<`u`?Fi(document.documentElement.lang):void 0)||(typeof navigator<`u`?Fi(navigator.language):void 0)}function Li(e){let t=e.metadata.lang??Ii(),n=e.domain??(typeof window<`u`?window.location.hostname:``);return J.setCacheScope(n,t),J.reset(),t}const Ri=`nexus-wallet-backup`,zi=`frakwallet://`,Bi=/* @__PURE__ */ new WeakMap,Vi=/* @__PURE__ */ new WeakMap;function Hi(e,t){let n=new URL(t).origin,r={createdAt:Date.now(),listenerSeen:!1};Bi.set(e,r),e.addEventListener(`load`,()=>{r.loadedAt??=Date.now()},{once:!0});let i=t=>{if(t.origin!==n||t.source!==e.contentWindow)return;r.listenerSeen=!0;let i=t.data;if(typeof i==`object`&&i){if(i.iframeLifecycle===`boot-error`){let e=i.data?.message;typeof e==`string`&&(r.bootError=e.slice(0,200))}else i.iframeLifecycle===`connected`&&Ui(e)}};window.addEventListener(`message`,i),Vi.set(e,()=>window.removeEventListener(`message`,i))}function Ui(e){Vi.get(e)?.(),Vi.delete(e)}function Wi(e){return Bi.get(e)}const Gi=3e4;function Ki({track:e,isConnected:t,iframe:n,startedAt:r}){let i=!1,a=!1,o=document.visibilityState===`hidden`,s=()=>{document.visibilityState===`hidden`&&(o=!0)};document.addEventListener(`visibilitychange`,s);let c=()=>{clearTimeout(l),document.removeEventListener(`visibilitychange`,s)},l=setTimeout(()=>{a||(i=!0,c(),e(`sdk_iframe_handshake_failed`,{reason:`timeout`,...qi(n,o)}),Ui(n))},Gi);t.then(()=>{a||(a=!0,c(),e(`sdk_iframe_connected`,{handshake_duration_ms:Date.now()-r,...i&&{after_timeout:!0}}))}).catch(()=>{a||i||(a=!0,c(),e(`sdk_iframe_handshake_failed`,{reason:`unknown`}))})}function qi(e,t){let n=Wi(e);return{visibility_state:document.visibilityState,was_hidden:t,online:navigator.onLine,...n&&{listener_seen:n.listenerSeen,...n.bootError&&{listener_error:n.bootError},...n.loadedAt!==void 0&&{iframe_load_ms:n.loadedAt-n.createdAt}}}}function Ji(e,t){if(typeof window>`u`)return;let n=new URL(window.location.href),r=n.searchParams.get(`sso`);r&&(t.then(()=>{e.sendLifecycle({clientLifecycle:`sso-redirect-complete`,data:{compressed:r}})}).catch(e=>{console.error(`[SSO URL Listener] Failed to forward SSO data:`,e)}),n.searchParams.delete(`sso`),window.history.replaceState({},``,n.toString()))}function Yi(){let e=navigator.userAgent;return/Android/i.test(e)&&/Chrome\/\d+/i.test(e)}const Xi=/* @__PURE__ */ zi.replace(`://`,``);function Zi(e){return`intent://${e.slice(13)}#Intent;scheme=${Xi};end`}function Qi(e,t){let n=t?.timeout??2500,r=!1,i=()=>{document.hidden&&(r=!0)};document.addEventListener(`visibilitychange`,i);let a=Yi()&&$i(e)?Zi(e):e;window.location.href=a,setTimeout(()=>{document.removeEventListener(`visibilitychange`,i),r||t?.onFallback?.()},n)}function $i(e){return e.startsWith(zi)}function ea(){if(typeof navigator>`u`)return!1;let e=navigator.userAgent;return!!(/iPhone|iPad|iPod/i.test(e)||/Macintosh/i.test(e)&&navigator.maxTouchPoints>1)}const $=/* @__PURE__ */ ea();function ta(){return typeof navigator>`u`?!1:$?!0:/Android|webOS|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}function na(){if(typeof navigator>`u`)return!1;let e=navigator.userAgent.toLowerCase();return e.includes(`instagram`)||e.includes(`fban`)||e.includes(`fbav`)||e.includes(`facebook`)}const ra=/* @__PURE__ */ na();function ia(){return typeof navigator>`u`?!1:navigator.userAgent.toLowerCase().includes(`instagram`)}const aa=/* @__PURE__ */ ia();function oa(e){$&&aa&&/^https?:\/\//.test(e)?window.location.href=`instagram://extbrowser/?url=${encodeURIComponent(e)}`:$&&e.startsWith(`https://`)?window.location.href=`x-safari-https://${e.slice(8)}`:$&&e.startsWith(`http://`)?window.location.href=`x-safari-http://${e.slice(7)}`:window.location.href=`${K()}/common/social?u=${encodeURIComponent(e)}`}const sa={id:`frak-wallet`,name:`frak-wallet`,title:`Frak Wallet`,allow:`publickey-credentials-get *; clipboard-write; web-share *`,style:{width:`0`,height:`0`,border:`0`,position:`absolute`,zIndex:2000001,top:`-1000px`,left:`-1000px`,colorScheme:`auto`}};async function ca({config:e}){let t=document.querySelector(`#frak-wallet`);t&&t.remove();let n=document.createElement(`iframe`);n.id=sa.id,n.name=sa.name,n.allow=sa.allow,n.style.zIndex=sa.style.zIndex.toString(),ua({iframe:n,isVisible:!1});let r=Mn(e?.env).wallet,i=await Pr().catch(e=>{console.warn(`[Frak SDK] Unable to derive a client id`,e)});return ma(r),ma(K()),Hi(n,r),n.src=la({walletUrl:r,clientId:i,preload:e?.preload}),new Promise(e=>{n.addEventListener(`load`,()=>e(n)),document.body.appendChild(n)})}function la({walletUrl:e=Pn(),clientId:t,preload:n}){let r=t?`${e}/listener?clientId=${encodeURIComponent(t)}`:`${e}/listener`;return!n||n.length===0?r:`${r}#preload=${n.join(`,`)}`}function ua({iframe:e,isVisible:t}){t?(e.style.position=`fixed`,e.style.top=`0`,e.style.left=`0`,e.style.width=`100%`,e.style.height=`100%`,e.style.backgroundColor=`transparent`,e.style.border=`0`,e.style.margin=`0`,e.style.padding=`0`,e.style.pointerEvents=`auto`,da(e)):(fa(e),e.style.width=`0`,e.style.height=`0`,e.style.border=`0`,e.style.position=`fixed`,e.style.top=`-1000px`,e.style.left=`-1000px`)}function da(e){if(typeof e.showPopover==`function`&&!e.hasAttribute(`popover`))try{e.setAttribute(`popover`,`manual`),e.showPopover()}catch{e.removeAttribute(`popover`)}}function fa(e){if(typeof e.hidePopover==`function`){try{e.hidePopover()}catch{}e.removeAttribute(`popover`)}}function pa(e=`/listener`){if(!window.opener)return null;let t=t=>{try{return t.location.origin===window.location.origin&&t.location.pathname===e}catch{return!1}};if(t(window.opener))return window.opener;try{let e=window.opener.frames;for(let n=0;n<e.length;n++)if(t(e[n]))return e[n];return null}catch(t){return console.error(`[findIframeInOpener] Error finding iframe with pathname ${e}:`,t),null}}function ma(e){if(typeof document<`u`)try{let t=new URL(e).origin,n=`link[rel="preconnect"][data-frak-preconnect="${t}"]`;if(document.head.querySelector(n))return;let r=document.createElement(`link`);r.rel=`preconnect`,r.href=t,r.crossOrigin=``,r.dataset.frakPreconnect=t,document.head.appendChild(r)}catch{}}const ha=$&&ra;function ga(e){e?localStorage.setItem(Ri,e):localStorage.removeItem(Ri)}function _a(e,t){try{let n=new URL(e);if(!n.searchParams.has(`u`))return e;let r=ya(window.location.href,t);return n.searchParams.delete(`u`),n.searchParams.append(`u`,r),n.toString()}catch{return e}}function va(e){return e.includes(`/common/social`)}function ya(e,t){if(!t)return e;try{let n=new URL(e);return n.searchParams.set(`fmt`,t),n.toString()}catch{return`${e}${e.includes(`?`)?`&`:`?`}fmt=${encodeURIComponent(t)}`}}function ba(e,t,n,r,i){if(i){let e=_a(t,r);window.open(e,`_blank`)}else if($i(t)){let i=_a(t,r);Qi(i,{onFallback:()=>{e.contentWindow?.postMessage({clientLifecycle:`deep-link-failed`,data:{originalUrl:i}},n)}})}else if(ha&&va(t))oa(ya(window.location.href,r));else{let e=_a(t,r);window.location.href=e}}function xa({iframe:e,targetOrigin:t}){let n=new xn;return{handleEvent:r=>{if(!(`iframeLifecycle`in r))return;let{iframeLifecycle:i,data:a}=r;switch(i){case`connected`:n.resolve(!0);break;case`do-backup`:ga(a.backup);break;case`remove-backup`:localStorage.removeItem(Ri);break;case`show`:case`hide`:ua({iframe:e,isVisible:i===`show`});break;case`redirect`:ba(e,a.baseRedirectUrl,t,a.mergeToken,a.openInNewTab)}},isConnected:n.promise}}async function Sa({config:e,iframe:t}){let n=Mn(e.env).wallet,r=Li(e),i=J.isCacheFresh?void 0:J.resolve(e.domain,r),a=await X().catch(()=>void 0),o=xa({iframe:t,targetOrigin:n}),s=new xn,c=Date.now();if(!t.contentWindow)throw new bn(yn.configError,`The iframe does not have a content window`);let l=Promise.race([o.isConnected,new Promise(e=>setTimeout(()=>e(!1),Gi))]),u=Cn({emittingTransport:t.contentWindow,listeningTransport:window,targetOrigin:n,middleware:[{async onRequest(e,n){if(!t.isConnected)throw new bn(yn.clientNotConnected,`The Frak iframe was removed from the page`);if(!await Promise.race([o.isConnected,l]))throw new bn(yn.clientNotConnected,`The iframe provider isn't connected yet`);return await s.promise,n}}],lifecycleHandlers:{iframeLifecycle:(e,n)=>{t.isConnected?o.handleEvent(e):m({detachOnly:!0})}}}),d=Ca(u,l),f,p=!1,m=async e=>{p=!0,d(),f?.(),u.cleanup(),e?.detachOnly||(t.remove(),zn(),J.clearCache(),J.reset())},h,g;{h=new Pi({apiUrl:`https://op-api.gcp.frak.id`,clientId:`6eacc8d7-49ac-4936-95e9-81ef29449570`,trackScreenViews:!1,trackOutgoingLinks:!1,trackAttributes:!1,filter:({type:e,payload:t})=>(e!==`track`||!t?.properties||`sdk_version`in t.properties||(t.properties={...t.properties,sdk_version:`1.6.0-beta.92148223`,...a&&{user_anonymous_client_id:a,__deviceId:a}}),!0)}),h.setGlobalProperties({sdk_version:`1.6.0-beta.92148223`,...a&&{user_anonymous_client_id:a,__deviceId:a}}),h.init(),h.track(`sdk_initialized`,{sdk_version:`1.6.0-beta.92148223`});let e=h;g=(t,n)=>e.track(t,n),Ki({track:g,isConnected:o.isConnected,iframe:t,startedAt:c})}return{config:e,waitForConnection:l,waitForSetup:Oa({config:e,rpcClient:u,lifecycleManager:o,configPromise:i,contextSent:s,openPanel:h,track:g,clientId:a}).then(e=>{p?e():f=e}).catch(e=>{throw s.reject(e),e}),request:u.request,listenerRequest:u.listen,destroy:m,openPanel:h}}function Ca(e,t){let n,r=()=>e.sendLifecycle({clientLifecycle:`heartbeat`});async function i(){r(),n=setInterval(r,250),await t,a()}function a(){n&&clearInterval(n)}return i(),a}function wa(e){return e.hasRawSdkConfig?{name:e.name,logoUrl:e.logoUrl,homepageLink:e.homepageLink,lang:e.lang,currency:e.currency,hidden:e.hidden,css:e.css,translations:e.translations,placements:e.placements,attribution:e.attribution}:e.attribution?{attribution:e.attribution}:void 0}function Ta(e,t){if(!e)return;let n=e.global??{};e.setGlobalProperties({...n,merchant_id:t.merchantId,domain:t.domain??``})}async function Ea(e){let t=new TextEncoder().encode(e);if(typeof crypto<`u`&&crypto.subtle)try{let e=await crypto.subtle.digest(`SHA-256`,t);return new Uint8Array(e)}catch{}try{return ye(t)}catch{return}}async function Da({merchantId:e,anonymousId:t,pendingMergeToken:n}){let r=n?await Ea(n):void 0,[i,a,o]=await Promise.all([r?Y({op:`frak-merge-v1`,merchantId:e,anonymousId:t,binding:r}):Promise.resolve(null),Y({op:`frak-merge-v1`,merchantId:e,anonymousId:t}),Y({op:`frak-install-v1`,merchantId:e,anonymousId:t})]);if(i||a||o)return{anonymousId:t,proofs:{...i&&{merge:i},...a&&{mergeSource:a},...o&&{install:o}}}}async function Oa({config:e,rpcClient:t,lifecycleManager:n,configPromise:r,contextSent:i,openPanel:a,track:o,clientId:s}){await n.isConnected,Ji(t,n.isConnected);let c=new URL(window.location.href),l=c.searchParams.get(`fmt`)??void 0;l&&(c.searchParams.delete(`fmt`),window.history.replaceState({},``,c.toString()));let u=t=>{let n=t?.merchantId??e.metadata.merchantId??``,r=t?.domain??``,i=t?.allowedDomains??[],a=t?.sdkConfig,o=a?.attribution||e.attribution?{...e.attribution,...a?.attribution}:void 0;J.setConfig(a?{isResolved:!0,merchantId:n,domain:r,allowedDomains:i,hasRawSdkConfig:!0,name:a.name??e.metadata.name,logoUrl:a.logoUrl??e.metadata.logoUrl,homepageLink:a.homepageLink??e.metadata.homepageLink,lang:a.lang??e.metadata.lang,currency:a.currency??e.metadata.currency,hidden:a.hidden,css:a.css,translations:a.translations,placements:a.placements,components:a.components,attribution:o}:{isResolved:!0,merchantId:n,domain:r,allowedDomains:i,name:e.metadata.name,logoUrl:e.metadata.logoUrl,homepageLink:e.metadata.homepageLink,lang:e.metadata.lang,currency:e.metadata.currency,attribution:o})},d=!1,f=Promise.resolve(),p=e=>{let n=d?void 0:l;d=!0;let r=wa(e),i=s,o=window.location.href;return Ta(a,e),f=f.then(async()=>{t.sendLifecycle({clientLifecycle:`resolved-config`,data:{merchantId:e.merchantId,domain:e.domain??``,allowedDomains:e.allowedDomains??[],sourceUrl:o,...i&&{sdkAnonymousId:i},...n&&{pendingMergeToken:n},...r&&{sdkConfig:r},...i&&{sdkIdentity:await Da({merchantId:e.merchantId,anonymousId:i,pendingMergeToken:n})}}})}).catch(e=>{console.error(`Failed to send lifecycle config`,e)}),f};J.isResolved&&p(J.getConfig()).then(i.resolve),r&&(u(await r),p(J.getConfig()).then(i.resolve));async function m(){let n=e.customizations?.css;n&&t.sendLifecycle({clientLifecycle:`modal-css`,data:{cssLink:n}})}async function h(){let n=e.customizations?.i18n;n&&t.sendLifecycle({clientLifecycle:`modal-i18n`,data:{i18n:n}})}async function g(){if(typeof window>`u`)return;let e=null;try{e=window.localStorage.getItem(Ri)}catch{}e&&t.sendLifecycle({clientLifecycle:`restore-backup`,data:{backup:e}})}let _=[[`css`,m()],[`i18n`,h()],[`backup`,g()]],v=await Promise.allSettled(_.map(([,e])=>e)),ee=v.findIndex(e=>e.status===`rejected`),y=v[ee];if(y?.status===`rejected`){let{reason:e}=y,t=e instanceof Error;o?.(`sdk_iframe_handshake_failed`,{reason:`asset_push`,asset:_[ee][0],error_name:t?e.name:typeof e,error_message:(t?e.message:String(e)).slice(0,200)})}return ka(p)}function ka(e){if(typeof document>`u`)return()=>{};let t=0,n=n=>{if(document.visibilityState!==`visible`||!J.isResolved)return;let r=Date.now();n&&r-t<6e4||(t=r,e(J.getConfig()))},r=()=>n(!0),i=setInterval(()=>n(!1),3e5);return document.addEventListener(`visibilitychange`,r),()=>{clearInterval(i),document.removeEventListener(`visibilitychange`,r)}}function Aa(e){return Tn(Lr(e))}function ja(e){try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}}function Ma(e){if(!e)return null;if(Array.isArray(e))return e;if(typeof e!=`string`)return null;try{let t=JSON.parse(e);return Array.isArray(t)?t:null}catch{return null}}function Na(e){if(typeof e==`number`)return Number.isFinite(e)?e:void 0;if(typeof e==`string`&&e.trim()!==``){let t=Number.parseFloat(e);return Number.isFinite(t)?t:void 0}}function Pa(e){if(typeof e!=`string`)return;let t=e.trim();return t===``?void 0:t}function Fa(e){if(!e||typeof e!=`object`)return;let t=e,n={},r=Pa(t.productId);r!==void 0&&(n.productId=r);let i=Pa(t.sku);i!==void 0&&(n.sku=i);let a=Pa(t.name);a!==void 0&&(n.name=a);let o=Na(t.quantity);o!==void 0&&(n.quantity=o);let s=Na(t.unitPrice);s!==void 0&&(n.unitPrice=s);let c=Na(t.totalPrice);return c!==void 0&&(n.totalPrice=c),Object.keys(n).length>0?n:void 0}function Ia(e){let t=Ma(e);if(!t)return;let n=[];for(let e of t){let t=Fa(e);t&&n.push(t)}return n.length>0?n:void 0}function La(e){if(!e||typeof e!=`object`)return null;let t=e,n=typeof t.title==`string`?t.title.trim():``,r=Fa(e);if(n===``&&!r)return null;let i={...r};return n!==``&&(i.title=n),typeof t.imageUrl==`string`&&ja(t.imageUrl)&&(i.imageUrl=t.imageUrl),typeof t.link==`string`&&ja(t.link)&&(i.link=t.link),typeof t.utmContent==`string`&&t.utmContent!==``&&(i.utmContent=t.utmContent),i}function Ra(e){let t=Ma(e);if(!t)return;let n=[];for(let e of t){let t=La(e);t&&n.push(t)}return n.length>0?n:void 0}function za(e){if(!e)return;let t;try{t=Aa(e)}catch{return}if(t!==null)return Ra(t)}async function Ba({config:e}){let t=Va(e);Li(t);let n=await ca({config:t});if(!n){console.error(`Failed to create iframe`);return}let r=await Sa({config:t,iframe:n});if(!await r.waitForConnection)console.error(`Failed to connect to client`),await r.destroy({detachOnly:!0});else return await r.waitForSetup,r}function Va(e){let t=Si(e.metadata.currency);return{...e,metadata:{...e.metadata,currency:t}}}function Ha({perCall:e,defaults:t,productUtmContent:n}){if(e===null)return;let r=e!==void 0,i=t!==void 0&&Object.keys(t).length>0;if(!r&&!i&&(n===void 0||n===``))return;let a={...t,...e??{}},o=n||e?.utmContent;return o!==void 0&&o!==``?a.utmContent=o:delete a.utmContent,a}var Ua=/* @__PURE__ */ t({DEEP_LINK_SCHEME:()=>zi,FrakContextManager:()=>bi,areAddressesEqual:()=>Xr,base64urlDecode:()=>Lr,base64urlEncode:()=>Ir,baseIframeProps:()=>sa,buildListenerUrl:()=>la,clearAllCache:()=>zn,coerceProductCandidates:()=>Ma,compressJsonToB64:()=>Rr,createIFrameFrakClient:()=>Sa,decodeProductsParam:()=>za,decompressJsonFromB64:()=>Aa,deleteQueryParamCaseInsensitive:()=>Q,detectPageLanguage:()=>Ii,findIframeInOpener:()=>pa,formatAmount:()=>Ti,formatAmountParts:()=>Di,generateSsoUrl:()=>zr,getBackendUrl:()=>K,getClientId:()=>Fr,getClientIdAsync:()=>X,getCurrencyAmountKey:()=>ki,getEnvironment:()=>Nn,getQueryParamCaseInsensitive:()=>qr,getSupportedCurrency:()=>Si,isIOS:()=>$,isInAppBrowser:()=>ra,isInstagramBrowser:()=>aa,isMobile:()=>ta,mergeAttribution:()=>Ha,normalizeProductDetails:()=>Fa,normalizeSharingProduct:()=>La,redirectToExternalBrowser:()=>oa,sanitizeProductDetailsList:()=>Ia,sanitizeSharingProducts:()=>Ra,sdkConfigStore:()=>J,setEnvironment:()=>Mn,setupClient:()=>Ba,ssoPopupFeatures:()=>Ur,ssoPopupName:()=>Wr,trackEvent:()=>Z,triggerDeepLinkWithFallback:()=>Qi,withCache:()=>Rn});function Wa(){return window.FrakSetup?.config?.rewardReminder?.enabled!==!1&&J.getConfig().components?.rewardReminder?.enabled!==!1}const Ga=`frak:client`;function Ka(){let e=new CustomEvent(Ga);window.dispatchEvent(e)}function qa(e,t){window.FrakSetup?.client&&e===`add`?t():(e===`add`?window.addEventListener:window.removeEventListener)(Ga,t,!1)}function Ja(e){typeof window.requestIdleCallback==`function`?window.requestIdleCallback(e):setTimeout(e,1)}function Ya(){import(
135
+ ;function K(){let e=globalThis?.crypto?.subtle;if(typeof e==`object`&&e)return e;throw Error(`crypto.subtle must be defined`)}function ln(e,t){return async function(n){let r=await e();return{secretKey:r,publicKey:await t(r)}}}function un(e){let t=e.match(/[0-9a-f]{2}/gi);if(!t||t.length*2!==e.length)throw Error(`invalid hex`);return Uint8Array.from(t,e=>Number.parseInt(e,16))}function dn(e){let t={...e};for(let[e,n]of Object.entries(t))Array.isArray(n)&&(t[e]=n.slice());return t}function fn(e,t){if(t.type!==e)throw Error(`invalid key type, expected ${e}`)}function pn(e,t,n,r){let i=t?[`deriveBits`]:[`sign`],a=t?[]:[`verify`],o=(e,t)=>t===`jwk`?e:new Uint8Array(e),s={async import(t,n){let r=await K().importKey(n,t,e,!0,a);return fn(`public`,r),r},async export(e,t){fn(`public`,e);let n=await K().exportKey(t,e);return o(n,t)},async convert(e,t,n){return s.export(await s.import(e,t),n)}},c={async import(a,o){let s=K(),c;if(o===`raw`){let t=N(a,n,`secretKey`),o=un(r),l=new Uint8Array(o.length+t.length);l.set(o,0),l.set(t,o.length),c=await s.importKey(on,l,e,!0,i)}else t&&o===`jwk`&&(a={...a,key_ops:i}),c=await s.importKey(o,a,e,!0,i);return fn(`private`,c),c},async export(e,t){let r=K();if(fn(`private`,e),t===`raw`){let t=(await r.exportKey(`jwk`,e)).d.replace(/-/g,`+`).replace(/_/g,`/`),i=t.length%4?`=`.repeat(4-t.length%4):``,a=atob(t+i),o=Uint8Array.from(a,e=>e.charCodeAt(0)),s=new Uint8Array(n);return s.set(o,n-o.length),s}let i=await r.exportKey(t,e);return o(i,t)},async convert(e,t,n){return c.export(await c.import(e,t),n)}};async function l(e,t={}){L(t,{},{formatSec:`string`,formatPub:`string`},`opts`);let n=t.formatSec??sn,r=t.formatPub??cn,i=n===`jwk`?{...e}:await c.convert(e,n,`jwk`);return delete i.d,i.key_ops=a,r===`jwk`?i:s.convert(i,`jwk`,r)}async function u(t=sn){let n=await K().generateKey(e,!0,i);return c.export(n.privateKey,t)}let d;return{pub:s,priv:c,async isSupported(){if(d!==void 0)return d;try{let n=K(),r=await n.generateKey(e,!0,i);return await c.export(r.privateKey,`jwk`),t&&await n.deriveBits({name:typeof e==`string`?e:e.name,public:r.publicKey},r.privateKey,8),d=!0}catch{return d=!1}},getPublicKey:l,keygen:ln(u,l),utils:Object.freeze({randomSecretKey:u,convertPublicKey:s.convert,convertSecretKey:c.convert})}}function mn(e,t){return{async sign(n,r,i={}){L(i,{},{formatSec:`string`,formatPub:`string`},`opts`);let a=ze(N(n,void 0,`message`)),o=await e.priv.import(r,i.formatSec??sn),s=await K().sign(t,o,a);return new Uint8Array(s)},async verify(n,r,i,a={}){L(a,{},{formatSec:`string`,formatPub:`string`},`opts`);let o=ze(N(n,void 0,`signature`)),s=ze(N(r,void 0,`message`)),c=await e.pub.import(i,a.formatPub??cn);return await K().verify(t,c,o,s)}}}function hn(e,t,n){return{async getSharedSecret(r,i,a={}){L(a,{},{formatSec:`string`,formatPub:`string`},`opts`);let o=a.formatSec===void 0?sn:a.formatSec,s=a.formatPub===void 0?cn:a.formatPub,c=Ee(i)?ze(N(i,void 0,`publicKey`)):dn(i),l=await e.priv.import(r,o),u=await e.pub.import(c,s),d=await K().deriveBits({name:typeof t==`string`?t:t.name,public:u},l,8*n);return new Uint8Array(d)}}}function gn(e,t,n,r){let i={name:`ECDH`,namedCurve:e},a=pn({name:`ECDSA`,namedCurve:e},!1,n,r),o=pn(i,!0,n,r);return Object.freeze({name:e,isSupported:a.isSupported,getPublicKey:a.getPublicKey,keygen:ln(a.utils.randomSecretKey,a.getPublicKey),...mn(a,{name:`ECDSA`,hash:{name:t}}),...hn(o,i,n),utils:Object.freeze({...a.utils,async convertSecretKey(e,t,n){let r=t===`jwk`?e:void 0;return Array.isArray(r?.key_ops)&&r.key_ops.length===1&&r.key_ops[0]===`deriveBits`?o.utils.convertSecretKey(e,t,n):a.utils.convertSecretKey(e,t,n)}})})}const _n=/* @__PURE__ */ gn(`P-256`,`SHA-256`,32,`3041020100301306072a8648ce3d020106082a8648ce3d030107042730250201010420`),q={parseError:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internalError:-32603,serverError:-32e3,clientNotConnected:-32001,configError:-32002,corruptedResponse:-32003,clientAborted:-32004,walletNotConnected:-32005,serverErrorForInteractionDelegation:-32006,userRejected:-32007};var vn=class extends Error{code;data;constructor(e,t,n){super(t),this.code=e,this.data=n}toJSON(){return{code:this.code,message:this.message,data:this.data}}},yn=class{_promise;_resolve;_reject;constructor(){this._promise=new Promise((e,t)=>{this._resolve=e,this._reject=t})}get promise(){return this._promise}resolve=e=>{this._resolve?.(e)};reject=e=>{this._reject?.(e)}};function bn(e){return new vn(e.code,e.message,e.data)}function xn(e){let{emittingTransport:t,listeningTransport:n,targetOrigin:r,middleware:i=[],lifecycleHandlers:a}=e,o=/* @__PURE__ */ new Map,s=!1;function c(){if(s)throw new vn(q.clientNotConnected,`The RPC client was cleaned up`)}function l(e){return typeof e!=`object`||!e?!1:`clientLifecycle`in e||`iframeLifecycle`in e}function u(e){return typeof e!=`object`||!e?!1:`id`in e&&`topic`in e&&`data`in e}async function d(e){try{`clientLifecycle`in e&&a?.clientLifecycle?await a.clientLifecycle(e,{origin:r,source:null}):`iframeLifecycle`in e&&a?.iframeLifecycle&&await a.iframeLifecycle(e,{origin:r,source:null})}catch(e){console.error(`[RPC Client] Lifecycle handler error:`,e)}}async function f(e){let t={origin:r,source:null};for(let n of i)n.onRequest&&await n.onRequest(e,t);return e}async function p(e,t){let n={origin:r,source:null},a=t;for(let t of i)t.onResponse&&(a=await t.onResponse(e,a,n));return a}async function m(e){try{if(new URL(e.origin).origin.toLowerCase()!==new URL(r).origin.toLowerCase())return}catch(e){console.error(`[RPC Client] Invalid origin`,e);return}if(l(e.data)){await d(e.data);return}if(!u(e.data))return;let t;try{let n=e.data.data,r=n instanceof Uint8Array||ArrayBuffer.isView(n)?{result:n}:n;t=await p(e.data,r)}catch(e){console.error(`[RPC Client] Middleware error on response:`,e),t={error:{code:q.internalError,message:e instanceof Error?e.message:`Response middleware failed`}}}let n=o.get(e.data.id);n&&n(t)}async function h(e){c();let n=await f(e);c(),t.postMessage(n,r)}function g(e){t.postMessage(e,r)}function _(){return`${Date.now()}-${Math.random().toString(36).substring(2,9)}`}n.addEventListener(`message`,m);function v(e){let t=_(),n=new yn;return o.set(t,e=>{e.error?n.reject(bn(e.error)):n.resolve(e.result),o.delete(t)}),h({id:t,topic:e.method,data:{method:e.method,params:e.params}}).catch(e=>{o.delete(t),n.reject(e)}),n.promise}function y(e,t,n){let r=_(),i=!1;return o.set(r,e=>{if(e.error){if(console.error(`[RPC Client] Listener error:`,e.error),o.delete(r),i)return;i=!0,n?.(bn(e.error))}else t(e.result)}),h({id:r,topic:e.method,data:{method:e.method,params:e.params}}).catch(e=>{console.error(`[RPC Client] Failed to send listener request:`,e),o.delete(r),i||n?.(e)}),()=>{i=!0,o.delete(r)}}function b(){n.removeEventListener(`message`,m),s=!0;let e=[...o.values()];o.clear();for(let t of e)t({error:{code:q.clientNotConnected,message:`The RPC client was cleaned up`}})}return{request:v,listen:y,sendLifecycle:g,cleanup:b}}function Sn(e){return new TextEncoder().encode(JSON.stringify(e))}function Cn(e){try{return JSON.parse(new TextDecoder().decode(e))}catch{return null}}const wn=`__frakEnv`,Tn={prod:{wallet:`https://wallet.frak.id`,backend:`https://backend.frak.id`},dev:{wallet:`https://wallet-dev.frak.id`,backend:`https://backend.gcp-dev.frak.id`}};function En(){return typeof window<`u`}let Dn=Tn.prod;function On(e){return e.replace(/\/+$/,``)}function kn(e){return typeof e==`string`?Object.hasOwn(Tn,e)?Tn[e]:(console.error(`[Frak SDK] Unknown env "${e}", falling back to production. Expected "prod", "dev", or { wallet, backend }.`),Tn.prod):!e?.wallet||!e?.backend?(console.error("[Frak SDK] env must state both `wallet` and `backend` origins, falling back to production. Received:",e),Tn.prod):{wallet:On(e.wallet),backend:On(e.backend)}}function An(e){if(!e)return jn();let t=kn(e),n=En()?window[wn]:void 0;return n&&(n.wallet!==t.wallet||n.backend!==t.backend)&&console.warn(`[Frak SDK] env changed after being published; the last value wins for every SDK call on this page.`,{previous:n,next:t}),Dn=t,En()&&(window[wn]=t),t}function jn(){return En()?window[wn]??Dn:Dn}function Mn(){return jn().wallet}function J(){return jn().backend}var Nn=class extends Map{maxSize;constructor(e){super(),this.maxSize=e}get(e){let t=super.get(e);return super.has(e)&&(super.delete(e),super.set(e,t)),t}set(e,t){if(super.has(e)&&super.delete(e),super.set(e,t),this.maxSize&&this.size>this.maxSize){let e=super.keys().next().value;e!==void 0&&super.delete(e)}return this}};let Pn;function Fn(){return Pn||={promiseCache:new Nn(1024),responseCache:new Nn(1024),failureCache:new Nn(1024)},Pn}async function In(e,{cacheKey:t,cacheTime:n=3e4}){let{promiseCache:r,responseCache:i,failureCache:a}=Fn();if(n>0){let e=i.get(t);if(e&&Date.now()-e.created<n)return e.data}let o=a.get(t);if(o&&Date.now()-o<1e3)throw Error(`Cache: ${t} recently failed, backing off`);let s=r.get(t);s||(s=e(),r.set(t,s));try{let e=await s;return i.set(t,{data:e,created:Date.now()}),a.delete(t),e}catch(e){throw a.set(t,Date.now()),e}finally{r.delete(t)}}function Ln(){Pn&&(Pn.promiseCache.clear(),Pn.responseCache.clear(),Pn.failureCache.clear())}const Rn=`__frakSdkConfig`,zn=`frak-config-cache`,Bn=`frak-merchant-id`,Vn={key:zn},Y=typeof window<`u`;function Hn(){return{isResolved:!1,merchantId:``}}let Un=null;function Wn(){if(!Y)return null;try{let e=localStorage.getItem(Vn.key);if(!e)return null;let t=JSON.parse(e);return t.config?.isResolved?(Un=t,t):null}catch{return null}}function Gn(){return(Un??Wn())?.config}function Kn(){let e=Un??Wn();return e?Date.now()-e.timestamp<3e4:!1}function qn(e){if(Y&&e.isResolved)try{let t={config:e,timestamp:Date.now()};localStorage.setItem(Vn.key,JSON.stringify(t)),Un=t}catch{}}function Jn(){if(Y){Un=null;try{localStorage.removeItem(Vn.key)}catch{}}}function Yn(){Y&&(window[Rn]||(window[Rn]=Gn()??Hn()))}function Xn(){return Y?(Yn(),window[Rn]??Hn()):Hn()}function Zn(e){Y&&window.dispatchEvent(new CustomEvent(`frak:config`,{detail:e}))}function Qn(e){return e??(Y?window.location.hostname:``)}async function $n(e,t){try{let n=J(),r=t?`&lang=${encodeURIComponent(t)}`:``,i=await fetch(`${n}/user/merchant/resolve?domain=${encodeURIComponent(e)}${r}`);if(!i.ok){console.warn(`[Frak SDK] Merchant lookup failed for domain ${e}: ${i.status}`);return}let a=await i.json();if(Y)try{sessionStorage.setItem(Bn,a.merchantId)}catch{}return a}catch(e){console.warn(`[Frak SDK] Failed to fetch merchant config:`,e);return}}const X={getConfig:Xn,get isResolved(){return Xn().isResolved},get isCacheFresh(){return Kn()},setCacheScope(e,t){let n=`${zn}:${e}:${t??``}`;n!==Vn.key&&(Vn.key=n,Un=null)},setConfig(e){if(Y&&(window[Rn]=e),qn(e),Zn(e),Y&&e.merchantId)try{sessionStorage.setItem(Bn,e.merchantId)}catch{}},reset(){let e=Gn()??Hn();Y&&(window[Rn]=e),Zn(e)},clearCache(){if(Jn(),Ln(),Y)try{sessionStorage.removeItem(Bn)}catch{}},resolve(e,t){let n=Qn(e);return n?In(async()=>{let e=await $n(n,t);if(!e)throw Error(`Config resolution returned empty`);return e},{cacheKey:`sdkConfig:${n}:${t??``}`,cacheTime:1/0}).catch(()=>void 0):Promise.resolve(void 0)},getMerchantId(){let e=Xn();if(e.isResolved&&e.merchantId)return e.merchantId;if(Y)try{return sessionStorage.getItem(Bn)??void 0}catch{}},async resolveMerchantId(e){return X.getMerchantId()||(await X.resolve(e))?.merchantId}};function er(){if(typeof navigator<`u`)return navigator.locks}async function tr(e,t,n={}){let r=er();if(!r)return t();if(n.ifAvailable){let n=!1;try{return await r.request(e,{ifAvailable:!0},async e=>{if(e)return n=!0,t()})}catch(e){if(n)throw e;return t()}}let i=new AbortController,a=setTimeout(()=>i.abort(),5e3),o=!1;try{return await r.request(e,{signal:i.signal},()=>(o=!0,t()))}catch(e){if(o)throw e;return t()}finally{clearTimeout(a)}}async function nr(e){return p(ve(e))}const rr=`frak-client-id`,ir=`frak-client-key`,ar=`frak-client-id-legacy`,or=/* @__PURE__ */ h(`308187020100301306072a8648ce3d020106082a8648ce3d030107046d306b0201010420`),sr=/* @__PURE__ */ h(`a144034200`),cr={formatSec:`pkcs8`,formatPub:`raw`};function lr(e,t){let n=new Uint8Array(or.length+32+sr.length+65),r=0;for(let i of[or,e,sr,t])n.set(i,r),r+=i.length;return n}const ur=/* @__PURE__ */ (/* @__PURE__ */ new Uint8Array(32)).fill(1),dr=/* @__PURE__ */ new Uint8Array(32);let fr=null;async function pr(){try{if(!await _n.isSupported())return G;let e=lr(ur,G.getPublicKey(ur,!1));return await _n.sign(dr,e,cr),_n}catch{return G}}function mr(){return fr??=pr(),fr}function hr(e,t,n,r){if(e===_n){let e=lr(n,r);return _n.sign(t,e,cr)}return Promise.resolve(G.sign(t,n,{prehash:!0}))}const gr=()=>typeof window<`u`&&!!window.localStorage;let _r=null;function vr(e){let t=m(e);if(_r?.keyHex===t)return _r.publicKey;let n=G.getPublicKey(e,!1);return _r={keyHex:t,publicKey:n},n}function yr(){if(gr())return localStorage.getItem(ar)??void 0}function br(){gr()&&localStorage.removeItem(ar)}function xr(){let e=localStorage.getItem(ir);if(!e)return null;if(!/^[0-9a-f]{64}$/i.test(e))throw Error(`[Frak SDK] Corrupt client key`);return h(e)}function Sr(e){try{for(let[t,n]of e)localStorage.setItem(t,n)}catch{}}async function Cr(){if(!gr())throw Error(`[Frak SDK] No window/localStorage available to derive a client id`);if(typeof crypto>`u`||!crypto.getRandomValues)throw Error(`[Frak SDK] crypto.getRandomValues unavailable, cannot derive a client id`);return tr(`frak-identity-key`,wr)}async function wr(){let e=localStorage.getItem(rr),t,n,r;try{t=xr(),n=t??G.utils.randomSecretKey(),r=await nr(vr(n))}catch(e){throw localStorage.removeItem(ir),_r=null,e}if(t){e!==r&&Sr([[rr,r]]);let t=yr();return{clientId:r,...t&&{pendingLegacyId:t}}}return Sr([...e?[[ar,e]]:[],[ir,m(n)],[rr,r]]),{clientId:r,...e&&{pendingLegacyId:e}}}async function Z(e){if(!gr())return null;try{let t=xr();if(!t)return null;let n=e.ts??Math.floor(Date.now()/1e3),r=f({op:e.op,merchantId:e.merchantId,anonymousId:e.anonymousId,binding:e.binding??/* @__PURE__ */ new Uint8Array,ts:n}),i=vr(t),a=await mr(),o;try{o=await hr(a,r,t,i)}catch(e){if(a===G)throw e;fr=Promise.resolve(G),o=await hr(G,r,t,i)}return _({v:1,pk:i,ts:n,sig:o})}catch{return null}}function Tr(){return{"x-frak-sdk-version":`1.6.0-beta.94832d46`}}const Er=/* @__PURE__ */ new Set([`PROOF_REQUIRED`,`PROOF_OR_TOKEN_REQUIRED`,`MISSING_ANONYMOUS_ID`]);async function Dr(e){if(e.status>=500||e.status===403)return!0;try{let t=await e.clone().json();return typeof t.code==`string`&&Er.has(t.code)}catch{return!1}}async function Or({legacyId:e,derivedId:t}){typeof window<`u`&&(!e||e===t?br():await tr(`frak-legacy-merge`,async()=>{yr()===e&&await kr({legacyId:e,derivedId:t})},{ifAvailable:!0}))}async function kr({legacyId:e,derivedId:t}){try{let n=await X.resolveMerchantId();if(!n)return;let r=await Z({op:`frak-merge-v1`,merchantId:n,anonymousId:t});if(!r)return;let i=J(),a=await fetch(`${i}/user/identity/merge/initiate`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,...Tr()},body:JSON.stringify({sourceAnonymousId:t,merchantId:n,proof:r})});if(!a.ok){await Dr(a)||br();return}let{mergeToken:o}=await a.json();if(!o)return;let s=await fetch(`${i}/user/identity/merge/execute`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,...Tr()},body:JSON.stringify({mergeToken:o,targetAnonymousId:e,merchantId:n})});if(s.ok){br();return}await Dr(s)||br()}catch{}}let Ar=null,jr=null;async function Mr(){return Ar||jr||(jr=Cr().then(({clientId:e,pendingLegacyId:t})=>(Ar=e,t&&Or({legacyId:t,derivedId:e}),e)),jr)}function Nr(){if(Ar)return Ar;Mr().catch(()=>{})}async function Q(){return Ar||Mr()}function Pr(e){return btoa(Array.from(e,e=>String.fromCharCode(e)).join(``)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function Fr(e){let t=e.length%4;return Uint8Array.from(atob(e.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(e.length+(t===0?0:4-t),`=`)),e=>e.charCodeAt(0))}function Ir(e){return Pr(Sn(e))}function Lr(e,t,n,r,i,a,o){let s=Ir(Rr({redirectUrl:t.redirectUrl,directExit:t.directExit,lang:t.lang,merchantId:n,metadata:{name:r,css:a,logoUrl:t.metadata?.logoUrl,homepageLink:t.metadata?.homepageLink},clientId:i,proof:o})),c=new URL(e);return c.pathname=`/sso`,c.searchParams.set(`p`,s),c.toString()}function Rr(e){return{r:e.redirectUrl,cId:e.clientId,d:e.directExit,l:e.lang,m:e.merchantId,md:{n:e.metadata?.name,css:e.metadata?.css,l:e.metadata?.logoUrl,h:e.metadata?.homepageLink},pf:e.proof}}function zr(e){return{...e,directExit:e.directExit??!e.redirectUrl}}async function Br(e,t){let{metadata:n,customizations:r}=e.config,i=Nr()??await Q().catch(()=>void 0),a=await X.resolveMerchantId()??``,o=i&&a?await Z({op:`frak-sso-v1`,merchantId:a,anonymousId:i}):null;return{ssoUrl:Lr(Mn(),zr(t),a,n.name,i,r?.css,o??void 0)}}const Vr=`menubar=no,status=no,scrollbars=no,fullscreen=no,width=500, height=800`,Hr=`frak-sso`;async function Ur(e,t){let{metadata:n,customizations:r}=e.config;if(`ssoUrl`in t)return Wr(t.ssoUrl),await e.request({method:`frak_openSso`,params:[{},n.name,r?.css]})??{};let i=zr(t);return i.openInSameWindow??!!i.redirectUrl?await e.request({method:`frak_openSso`,params:[i,n.name,r?.css]}):(Wr(i.ssoPopupUrl??(await Br(e,i)).ssoUrl),await e.request({method:`frak_openSso`,params:[i,n.name,r?.css]})??{})}function Wr(e){let t=window.open(e,Hr,Vr);if(!t)throw Error(`Popup was blocked. Please allow popups for this site.`);t.focus()}function $(e,t,n){if(e)try{e.openPanel?.track(t,n)}catch(e){console.debug(`[Frak] Failed to track event:`,t,e)}}function Gr(e,t){let n=e.get(t);if(n!==null)return n;let r=t.toLowerCase();for(let[t,n]of e)if(t.toLowerCase()===r)return n;return null}function Kr(e,t){let n=t.toLowerCase(),r=[...e.keys()].filter(e=>e.toLowerCase()===n);for(let t of r)e.delete(t)}const qr=/^0x[a-fA-F0-9]{40}$/;function Jr(e){return typeof e==`string`&&qr.test(e)}function Yr(e,t){return e.toLowerCase()===t.toLowerCase()}function Xr(e){let t=/* @__PURE__ */ new Uint8Array(20);for(let n=0;n<20;n++){let r=Number.parseInt(e.substring(2+n*2,4+n*2),16);if(Number.isNaN(r))throw Error(`Invalid address: ${e}`);t[n]=r}return t}const Zr=/*#__PURE__*/ Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function Qr(e){let t=`0x`;for(let n=0;n<20;n++)t+=Zr[e[n]];return t}function $r(e){return`r`in e&&!(`v`in e)}function ei(e){return`v`in e&&e.v===2}const ti=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function ni(e){return typeof e==`string`&&ti.test(e)}function ri(e){let t=e.replace(/-/g,``),n=/* @__PURE__ */ new Uint8Array(16);for(let e=0;e<16;e++)n[e]=Number.parseInt(t.substring(e*2,e*2+2),16);return n}function ii(e){let t=``;for(let n=0;n<16;n++)t+=e[n].toString(16).padStart(2,`0`);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20,32)}`}function ai(e){if(!ni(e.m)||!Number.isInteger(e.t)||e.t<0||e.t>4294967295)return null;let t=typeof e.c==`string`&&e.c.length>0,n=typeof e.w==`string`&&Jr(e.w);if(!t&&!n||t&&!ni(e.c))return null;let r=new Uint8Array(21+(t?16:0)+(n?20:0)),i=new DataView(r.buffer,r.byteOffset,r.byteLength),a=0;return r[a++]=2|(t?16:0)|(n?32:0),r.set(ri(e.m),a),a+=16,i.setUint32(a,e.t,!1),a+=4,t&&(r.set(ri(e.c),a),a+=16),n&&(r.set(Xr(e.w),a),a+=20),r}function oi(e){if(e.length<21)return null;let t=e[0];if((t&15)!=2||t&192)return null;let n=!!(t&16),r=!!(t&32);if(!n&&!r)return null;let i=21+(n?16:0)+(r?20:0);if(e.length!==i)return null;let a=1,o=ii(e.subarray(a,a+16));a+=16;let s=new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(a,!1);a+=4;let c={v:2,m:o,t:s};if(n&&(c.c=ii(e.subarray(a,a+16)),a+=16),r){let t=Qr(e.subarray(a,a+20));if(!Jr(t))return null;c.w=t,a+=20}return c}const si=`fCtx`;function ci(e){try{return new URL(e)}catch{return null}}function li(e){return e.protocol===`http:`||e.protocol===`https:`}function ui(e){if(e)try{if(ei(e)){let t=ai(e);return t?Pr(t):void 0}return Pr(Xr(e.r))}catch(t){console.error(`Error compressing Frak context`,{e:t,context:e})}}function di(e){if(e&&e.length!==0)try{let t=Fr(e);if(t.length!==20)return oi(t)||void 0;let n=Qr(t);if(Jr(n))return{r:n}}catch(t){console.error(`Error decompressing Frak context`,{e:t,context:e})}}function fi({url:e}){if(!e)return null;let t=ci(e);if(!t)return null;let n=Gr(t.searchParams,si);return n?di(n):null}function pi(e){return{utm_source:e.utmSource??`frak`,utm_medium:e.utmMedium??void 0,utm_campaign:e.utmCampaign??void 0,utm_content:e.utmContent,utm_term:e.utmTerm,via:e.via??void 0,ref:e.ref??void 0}}function mi(e,t){let n=pi(t??{});for(let[t,r]of Object.entries(n))r!==void 0&&r!==``&&(e.searchParams.has(t)||e.searchParams.set(t,r))}function hi({url:e,context:t,attribution:n}){let r=e?ci(e):null;return!r||!li(r)?null:gi(r,t,n)}function gi(e,t,n){let r=ui(t);return r?(Kr(e.searchParams,si),e.searchParams.set(si,r),mi(e,n),e.toString()):null}function _i(e){let t=ci(e);return t?(Kr(t.searchParams,si),t.toString()):e}function vi({url:e,context:t}){if(typeof window>`u`||!window.location?.href){console.error(`No window found, can't update context`);return}let n=e??window.location.href,r;if(t!==null){let e=ci(n);r=e?gi(e,t):null}else r=_i(n);r&&window.history.replaceState(null,``,r.toString())}const yi={compress:ui,decompress:di,parse:fi,update:hi,remove:_i,replaceUrl:vi},bi={eur:`fr-FR`,usd:`en-US`,gbp:`en-GB`};function xi(e){return e&&e in bi?e:`eur`}function Si(e){return e?bi[e]??bi.eur:bi.eur}function Ci(e){return e.replaceAll(` `,`\xA0`)}function wi(e,t){let n=Si(t),r=xi(t);return Ci(e.toLocaleString(n,{style:`currency`,currency:r,minimumFractionDigits:0,maximumFractionDigits:2}))}function Ti(e){return e.formatToParts(1.1).find(e=>e.type===`decimal`)?.value??`.`}function Ei(e,t){let n=Si(t),r=xi(t),i=new Intl.NumberFormat(n,{style:`currency`,currency:r,minimumFractionDigits:0,maximumFractionDigits:2}),a=i.formatToParts(e),o=``,s=``,c=``,l=`suffix`,u=!1;for(let e of a)switch(e.type){case`integer`:case`group`:o+=Ci(e.value),u=!0;break;case`decimal`:case`fraction`:s+=e.value;break;case`currency`:c=e.value,l=u?`suffix`:`prefix`}return{integer:o,decimals:s||`${Ti(i)}00`,unit:c,unitPosition:l}}function Di(e){return{integer:String(e),unit:`%`,unitPosition:`suffix`}}function Oi(e){return e?`${e}Amount`:`eurAmount`}var ki=class{constructor(e){this.baseUrl=e.baseUrl,this.headers={"Content-Type":`application/json`,...e.defaultHeaders},this.maxRetries=e.maxRetries??3,this.initialRetryDelay=e.initialRetryDelay??500}async resolveHeaders(){let e={};for(let[t,n]of Object.entries(this.headers)){let r=await n;r!==null&&(e[t]=r)}return e}addHeader(e,t){this.headers[e]=t}async post(e,t,n,r){try{let r=await fetch(e,{method:`POST`,headers:await this.resolveHeaders(),body:t?JSON.stringify(t??{}):void 0,keepalive:!0,...n});if(r.status===401)return null;if(r.status!==200&&r.status!==202)throw Error(`HTTP error! status: ${r.status}`);let i=await r.text();return i?JSON.parse(i):null}catch(i){if(r<this.maxRetries){let i=this.initialRetryDelay*2**r;return await new Promise(e=>setTimeout(e,i)),this.post(e,t,n,r+1)}return console.error(`Max retries reached:`,i),null}}async fetch(e,t,n={}){let r=`${this.baseUrl}${e}`;return this.post(r,t,n,0)}},Ai=class{constructor(e){this.groups=[],this.queue=[],this.options=e;let t={"openpanel-client-id":e.clientId};e.clientSecret&&(t[`openpanel-client-secret`]=e.clientSecret),t[`openpanel-sdk-name`]=e.sdk||`node`,t[`openpanel-sdk-version`]=e.sdkVersion||`1.3.2`,this.api=new ki({baseUrl:e.apiUrl||`https://api.openpanel.dev`,defaultHeaders:t})}init(){}ready(){this.options.disabled=!1,this.options.waitForProfile=!1,this.flush()}shouldQueue(e){return!!(this.options.disabled||this.options.waitForProfile&&!this.profileId||e.type===`replay`&&!this.sessionId)}addQueue(e){e.type===`track`&&(e.payload.properties={...e.payload.properties??{},__timestamp:(/* @__PURE__ */ new Date()).toISOString()}),this.queue.push(e)}async send(e){if(this.options.filter&&!this.options.filter(e))return Promise.resolve();if(this.shouldQueue(e))return this.addQueue(e),Promise.resolve();let t=await this.api.fetch(`/track`,e,{keepalive:e.type!==`replay`});this.deviceId=t?.deviceId;let n=!!this.sessionId;return this.sessionId=t?.sessionId,!n&&this.sessionId&&this.flush(),t}setGlobalProperties(e){this.global={...this.global,...e}}track(e,t){this.log(`track event`,e,t);let{groups:n,profileId:r,...i}=t??{},a=[.../* @__PURE__ */ new Set([...this.groups,...n??[]])];return this.send({type:`track`,payload:{name:e,profileId:r??this.profileId,groups:a.length>0?a:void 0,properties:{...this.global??{},...i}}})}identify(e){if(this.log(`identify user`,e),e.profileId&&(this.profileId=e.profileId,this.flush()),e.profileId&&Object.keys(e).length>1)return this.send({type:`identify`,payload:{...e,properties:{...this.global,...e.properties}}})}upsertGroup(e){return this.log(`upsert group`,e),this.send({type:`group`,payload:e})}setGroup(e){return this.log(`set group`,e),this.groups.includes(e)||(this.groups=[...this.groups,e]),this.send({type:`assign_group`,payload:{groupIds:[e],profileId:this.profileId}})}setGroups(e){return this.log(`set groups`,e),this.groups=[.../* @__PURE__ */ new Set([...this.groups,...e])],this.send({type:`assign_group`,payload:{groupIds:e,profileId:this.profileId}})}alias(e){}increment(e){return this.send({type:`increment`,payload:e})}decrement(e){return this.send({type:`decrement`,payload:e})}revenue(e,t){let n=t?.deviceId;return delete t?.deviceId,this.track(`revenue`,{...t??{},...n?{__deviceId:n}:{},__revenue:e})}getDeviceId(){return this.deviceId??``}getSessionId(){return this.sessionId??``}fetchDeviceId(){return Promise.resolve(this.deviceId??``)}clear(){this.profileId=void 0,this.groups=[],this.deviceId=void 0,this.sessionId=void 0}buildFlushPayload(e){if(e.type===`replay`)return e.payload;if(e.type===`track`){let t=`groups`in e.payload?e.payload.groups??[]:[],n=[.../* @__PURE__ */ new Set([...this.groups,...t])];return{...e.payload,profileId:e.payload.profileId??this.profileId,groups:n.length>0?n:void 0}}return e.type===`identify`||e.type===`increment`||e.type===`decrement`||e.type===`assign_group`?{...e.payload,profileId:e.payload.profileId??this.profileId}:e.payload}flush(){let e=[];for(let t of this.queue){if(this.shouldQueue(t)){e.push(t);continue}let n=this.buildFlushPayload(t);this.send({...t,payload:n})}this.queue=e}log(...e){this.options.debug&&console.log(`[OpenPanel.dev]`,...e)}},ji=typeof document<`u`?document.currentScript:null;function Mi(e){return e.replace(/([-_][a-z])/gi,e=>e.toUpperCase().replace(`-`,``).replace(`_`,``))}var Ni=class extends Ai{constructor(e){if(super({sdk:`web`,sdkVersion:`1.4.2`,...e}),this.options=e,this.lastPath=``,this.pendingRevenues=[],!this.isServer()){try{let e=sessionStorage.getItem(`openpanel-pending-revenues`);if(e){let t=JSON.parse(e);Array.isArray(t)&&(this.pendingRevenues=t)}}catch{this.pendingRevenues=[]}if(this.setGlobalProperties({__referrer:document.referrer}),this.options.trackScreenViews&&(this.trackScreenViews(),setTimeout(()=>this.screenView(),0)),this.options.trackOutgoingLinks&&this.trackOutgoingLinks(),this.options.trackAttributes&&this.trackAttributes(),this.options.sessionReplay?.enabled){let e=this.options.sessionReplay.sampleRate??1;Math.random()<e&&this.loadReplayModule().then(e=>{e&&e.startReplayRecorder(this.options.sessionReplay,e=>{this.send({type:`replay`,payload:{...e,sessionId:this.sessionId}})})})}}}async loadReplayModule(){try{if(typeof __OPENPANEL_REPLAY_URL__<`u`){let e=ji,t=this.options.sessionReplay?.scriptUrl||e?.src?.replace(`.js`,`-replay.js`)||`https://openpanel.dev/op1-replay.js`;return window.__openpanel_replay?window.__openpanel_replay:new Promise(e=>{let n=document.createElement(`script`);n.src=t,n.onload=()=>{e(window.__openpanel_replay??null)},n.onerror=()=>{console.warn(`[OpenPanel] Failed to load replay script from`,t),e(null)},document.head.appendChild(n)})}return await import(`./replay-V6FXES7X.CgBxdfNp.js`)}catch(e){return console.warn(`[OpenPanel] Failed to load replay module`,e),null}}debounce(e,t){clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(e,t)}isServer(){return typeof document>`u`}trackOutgoingLinks(){this.isServer()||document.addEventListener(`click`,e=>{let t=e.target,n=t.closest(`a`);if(n&&t){let e=n.getAttribute(`href`);if(e?.startsWith(`http`))try{let r=new URL(e),i=window.location.hostname;r.hostname!==i&&this.track(`link_out`,{href:e,text:n.innerText||n.getAttribute(`title`)||t.getAttribute(`alt`)||t.getAttribute(`title`)})}catch{}}})}trackScreenViews(){if(this.isServer())return;let e=history.pushState;history.pushState=function(...t){let n=e.apply(this,t);return window.dispatchEvent(new Event(`pushstate`)),window.dispatchEvent(new Event(`locationchange`)),n};let t=history.replaceState;history.replaceState=function(...e){let n=t.apply(this,e);return window.dispatchEvent(new Event(`replacestate`)),window.dispatchEvent(new Event(`locationchange`)),n},window.addEventListener(`popstate`,()=>{window.dispatchEvent(new Event(`locationchange`))});let n=()=>this.debounce(()=>this.screenView(),50);this.options.trackHashChanges?window.addEventListener(`hashchange`,n):window.addEventListener(`locationchange`,n)}trackAttributes(){this.isServer()||document.addEventListener(`click`,e=>{let t=e.target,n=t.closest(`button`),r=t.closest(`a`),i=n?.getAttribute(`data-track`)?n:r?.getAttribute(`data-track`)?r:null;if(i){let e={};for(let t of i.attributes)t.name.startsWith(`data-`)&&t.name!==`data-track`&&(e[Mi(t.name.replace(/^data-/,``))]=t.value);let t=i.getAttribute(`data-track`);t&&this.track(t,e)}})}track(e,t){return super.track(e,{...t,__path:this.currentPath()})}currentPath(){return this.lastPath?this.lastPath:this.isServer()?``:window.location.href}screenView(e,t){if(this.isServer())return;let n,r;typeof e==`string`?(n=e,r=t):(n=window.location.href,r=e),this.lastPath!==n&&(this.lastPath=n,super.track(`screen_view`,{...r??{},__path:n,__title:document.title}))}async flushRevenue(){let e=this.pendingRevenues.map(e=>super.revenue(e.amount,e.properties));await Promise.all(e),this.clearRevenue()}clearRevenue(){if(this.pendingRevenues=[],!this.isServer())try{sessionStorage.removeItem(`openpanel-pending-revenues`)}catch{}}pendingRevenue(e,t){if(this.pendingRevenues.push({amount:e,properties:t}),!this.isServer())try{sessionStorage.setItem(`openpanel-pending-revenues`,JSON.stringify(this.pendingRevenues))}catch{}}};function Pi(e){let t=e?.split(`-`)[0]?.toLowerCase();return t===`en`||t===`fr`?t:void 0}function Fi(){return(typeof document<`u`?Pi(document.documentElement.lang):void 0)||(typeof navigator<`u`?Pi(navigator.language):void 0)}function Ii(e){let t=e.metadata.lang??Fi(),n=e.domain??(typeof window<`u`?window.location.hostname:``);return X.setCacheScope(n,t),X.reset(),t}const Li=`nexus-wallet-backup`,Ri=`frakwallet://`,zi=/* @__PURE__ */ new WeakMap,Bi=/* @__PURE__ */ new WeakMap;function Vi(e,t){let n=new URL(t).origin,r={createdAt:Date.now(),listenerSeen:!1};zi.set(e,r),e.addEventListener(`load`,()=>{r.loadedAt??=Date.now()},{once:!0});let i=t=>{if(t.origin!==n||t.source!==e.contentWindow)return;r.listenerSeen=!0;let i=t.data;if(typeof i==`object`&&i){if(i.iframeLifecycle===`boot-error`){let e=i.data?.message;typeof e==`string`&&(r.bootError=e.slice(0,200))}else i.iframeLifecycle===`connected`&&Hi(e)}};window.addEventListener(`message`,i),Bi.set(e,()=>window.removeEventListener(`message`,i))}function Hi(e){Bi.get(e)?.(),Bi.delete(e)}function Ui(e){return zi.get(e)}const Wi=3e4;function Gi({track:e,isConnected:t,iframe:n,startedAt:r}){let i=!1,a=!1,o=document.visibilityState===`hidden`,s=()=>{document.visibilityState===`hidden`&&(o=!0)};document.addEventListener(`visibilitychange`,s);let c=()=>{clearTimeout(l),document.removeEventListener(`visibilitychange`,s)},l=setTimeout(()=>{a||(i=!0,c(),e(`sdk_iframe_handshake_failed`,{reason:`timeout`,...Ki(n,o)}),Hi(n))},Wi);t.then(()=>{a||(a=!0,c(),e(`sdk_iframe_connected`,{handshake_duration_ms:Date.now()-r,...i&&{after_timeout:!0}}))}).catch(()=>{a||i||(a=!0,c(),e(`sdk_iframe_handshake_failed`,{reason:`unknown`}))})}function Ki(e,t){let n=Ui(e);return{visibility_state:document.visibilityState,was_hidden:t,online:navigator.onLine,...n&&{listener_seen:n.listenerSeen,...n.bootError&&{listener_error:n.bootError},...n.loadedAt!==void 0&&{iframe_load_ms:n.loadedAt-n.createdAt}}}}function qi(e,t){if(typeof window>`u`)return;let n=new URL(window.location.href),r=n.searchParams.get(`sso`);r&&(t.then(()=>{e.sendLifecycle({clientLifecycle:`sso-redirect-complete`,data:{compressed:r}})}).catch(e=>{console.error(`[SSO URL Listener] Failed to forward SSO data:`,e)}),n.searchParams.delete(`sso`),window.history.replaceState({},``,n.toString()))}function Ji(){let e=navigator.userAgent;return/Android/i.test(e)&&/Chrome\/\d+/i.test(e)}const Yi=/* @__PURE__ */ Ri.replace(`://`,``);function Xi(e){return`intent://${e.slice(13)}#Intent;scheme=${Yi};end`}function Zi(e,t){let n=t?.timeout??2500,r=!1,i=()=>{document.hidden&&(r=!0)};document.addEventListener(`visibilitychange`,i);let a=Ji()&&Qi(e)?Xi(e):e;window.location.href=a,setTimeout(()=>{document.removeEventListener(`visibilitychange`,i),r||t?.onFallback?.()},n)}function Qi(e){return e.startsWith(Ri)}function $i(){if(typeof navigator>`u`)return!1;let e=navigator.userAgent;return!!(/iPhone|iPad|iPod/i.test(e)||/Macintosh/i.test(e)&&navigator.maxTouchPoints>1)}const ea=/* @__PURE__ */ $i();function ta(){return typeof navigator>`u`?!1:ea?!0:/Android|webOS|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}function na(){if(typeof navigator>`u`)return!1;let e=navigator.userAgent.toLowerCase();return e.includes(`instagram`)||e.includes(`fban`)||e.includes(`fbav`)||e.includes(`facebook`)}const ra=/* @__PURE__ */ na();function ia(){return typeof navigator>`u`?!1:navigator.userAgent.toLowerCase().includes(`instagram`)}const aa=/* @__PURE__ */ ia();function oa(e){ea&&aa&&/^https?:\/\//.test(e)?window.location.href=`instagram://extbrowser/?url=${encodeURIComponent(e)}`:ea&&e.startsWith(`https://`)?window.location.href=`x-safari-https://${e.slice(8)}`:ea&&e.startsWith(`http://`)?window.location.href=`x-safari-http://${e.slice(7)}`:window.location.href=`${J()}/common/social?u=${encodeURIComponent(e)}`}const sa={id:`frak-wallet`,name:`frak-wallet`,title:`Frak Wallet`,allow:`publickey-credentials-get *; clipboard-write; web-share *`,style:{width:`0`,height:`0`,border:`0`,position:`absolute`,zIndex:2000001,top:`-1000px`,left:`-1000px`,colorScheme:`auto`}};async function ca({config:e}){let t=document.querySelector(`#frak-wallet`);t&&t.remove();let n=document.createElement(`iframe`);n.id=sa.id,n.name=sa.name,n.allow=sa.allow,n.style.zIndex=sa.style.zIndex.toString(),ua({iframe:n,isVisible:!1});let r=An(e?.env).wallet,i=await Mr().catch(e=>{console.warn(`[Frak SDK] Unable to derive a client id`,e)});return ma(r),ma(J()),Vi(n,r),n.src=la({walletUrl:r,clientId:i,preload:e?.preload}),new Promise(e=>{n.addEventListener(`load`,()=>e(n)),document.body.appendChild(n)})}function la({walletUrl:e=Mn(),clientId:t,preload:n}){let r=t?`${e}/listener?clientId=${encodeURIComponent(t)}`:`${e}/listener`;return!n||n.length===0?r:`${r}#preload=${n.join(`,`)}`}function ua({iframe:e,isVisible:t}){t?(e.style.position=`fixed`,e.style.top=`0`,e.style.left=`0`,e.style.width=`100%`,e.style.height=`100%`,e.style.backgroundColor=`transparent`,e.style.border=`0`,e.style.margin=`0`,e.style.padding=`0`,e.style.pointerEvents=`auto`,da(e)):(fa(e),e.style.width=`0`,e.style.height=`0`,e.style.border=`0`,e.style.position=`fixed`,e.style.top=`-1000px`,e.style.left=`-1000px`)}function da(e){if(typeof e.showPopover==`function`&&!e.hasAttribute(`popover`))try{e.setAttribute(`popover`,`manual`),e.showPopover()}catch{e.removeAttribute(`popover`)}}function fa(e){if(typeof e.hidePopover==`function`){try{e.hidePopover()}catch{}e.removeAttribute(`popover`)}}function pa(e=`/listener`){if(!window.opener)return null;let t=t=>{try{return t.location.origin===window.location.origin&&t.location.pathname===e}catch{return!1}};if(t(window.opener))return window.opener;try{let e=window.opener.frames;for(let n=0;n<e.length;n++)if(t(e[n]))return e[n];return null}catch(t){return console.error(`[findIframeInOpener] Error finding iframe with pathname ${e}:`,t),null}}function ma(e){if(typeof document<`u`)try{let t=new URL(e).origin,n=`link[rel="preconnect"][data-frak-preconnect="${t}"]`;if(document.head.querySelector(n))return;let r=document.createElement(`link`);r.rel=`preconnect`,r.href=t,r.crossOrigin=``,r.dataset.frakPreconnect=t,document.head.appendChild(r)}catch{}}const ha=ea&&ra;function ga(e){e?localStorage.setItem(Li,e):localStorage.removeItem(Li)}function _a(e,t){try{let n=new URL(e);if(!n.searchParams.has(`u`))return e;let r=ya(window.location.href,t);return n.searchParams.delete(`u`),n.searchParams.append(`u`,r),n.toString()}catch{return e}}function va(e){return e.includes(`/common/social`)}function ya(e,t){if(!t)return e;try{let n=new URL(e);return n.searchParams.set(`fmt`,t),n.toString()}catch{return`${e}${e.includes(`?`)?`&`:`?`}fmt=${encodeURIComponent(t)}`}}function ba(e,t,n,r,i){if(i){let e=_a(t,r);window.open(e,`_blank`)}else if(Qi(t)){let i=_a(t,r);Zi(i,{onFallback:()=>{e.contentWindow?.postMessage({clientLifecycle:`deep-link-failed`,data:{originalUrl:i}},n)}})}else if(ha&&va(t))oa(ya(window.location.href,r));else{let e=_a(t,r);window.location.href=e}}function xa({iframe:e,targetOrigin:t}){let n=new yn;return{handleEvent:r=>{if(!(`iframeLifecycle`in r))return;let{iframeLifecycle:i,data:a}=r;switch(i){case`connected`:n.resolve(!0);break;case`do-backup`:ga(a.backup);break;case`remove-backup`:localStorage.removeItem(Li);break;case`show`:case`hide`:ua({iframe:e,isVisible:i===`show`});break;case`redirect`:ba(e,a.baseRedirectUrl,t,a.mergeToken,a.openInNewTab)}},isConnected:n.promise}}async function Sa({config:e,iframe:t}){let n=An(e.env).wallet,r=Ii(e),i=X.isCacheFresh?void 0:X.resolve(e.domain,r),a=await Q().catch(()=>void 0),o=xa({iframe:t,targetOrigin:n}),s=new yn,c=Date.now();if(!t.contentWindow)throw new vn(q.configError,`The iframe does not have a content window`);let l=Promise.race([o.isConnected,new Promise(e=>setTimeout(()=>e(!1),Wi))]),u=xn({emittingTransport:t.contentWindow,listeningTransport:window,targetOrigin:n,middleware:[{async onRequest(e,n){if(!t.isConnected)throw new vn(q.clientNotConnected,`The Frak iframe was removed from the page`);if(!await Promise.race([o.isConnected,l]))throw new vn(q.clientNotConnected,`The iframe provider isn't connected yet`);return await s.promise,n}}],lifecycleHandlers:{iframeLifecycle:(e,n)=>{t.isConnected?o.handleEvent(e):m({detachOnly:!0})}}}),d=Ca(u,l),f,p=!1,m=async e=>{p=!0,d(),f?.(),u.cleanup(),e?.detachOnly||(t.remove(),Ln(),X.clearCache(),X.reset())},h,g;{h=new Ni({apiUrl:`https://op-api.gcp.frak.id`,clientId:`6eacc8d7-49ac-4936-95e9-81ef29449570`,trackScreenViews:!1,trackOutgoingLinks:!1,trackAttributes:!1,filter:({type:e,payload:t})=>(e!==`track`||!t?.properties||`sdk_version`in t.properties||(t.properties={...t.properties,sdk_version:`1.6.0-beta.94832d46`,...a&&{user_anonymous_client_id:a,__deviceId:a}}),!0)}),h.setGlobalProperties({sdk_version:`1.6.0-beta.94832d46`,...a&&{user_anonymous_client_id:a,__deviceId:a}}),h.init(),h.track(`sdk_initialized`,{sdk_version:`1.6.0-beta.94832d46`});let e=h;g=(t,n)=>e.track(t,n),Gi({track:g,isConnected:o.isConnected,iframe:t,startedAt:c})}return{config:e,waitForConnection:l,waitForSetup:Oa({config:e,rpcClient:u,lifecycleManager:o,configPromise:i,contextSent:s,openPanel:h,track:g,clientId:a}).then(e=>{p?e():f=e}).catch(e=>{throw s.reject(e),e}),request:u.request,listenerRequest:u.listen,destroy:m,openPanel:h}}function Ca(e,t){let n,r=()=>e.sendLifecycle({clientLifecycle:`heartbeat`});async function i(){r(),n=setInterval(r,250),await t,a()}function a(){n&&clearInterval(n)}return i(),a}function wa(e){return e.hasRawSdkConfig?{name:e.name,logoUrl:e.logoUrl,homepageLink:e.homepageLink,lang:e.lang,currency:e.currency,hidden:e.hidden,css:e.css,translations:e.translations,placements:e.placements,attribution:e.attribution}:e.attribution?{attribution:e.attribution}:void 0}function Ta(e,t){if(!e)return;let n=e.global??{};e.setGlobalProperties({...n,merchant_id:t.merchantId,domain:t.domain??``})}async function Ea(e){let t=new TextEncoder().encode(e);if(typeof crypto<`u`&&crypto.subtle)try{let e=await crypto.subtle.digest(`SHA-256`,t);return new Uint8Array(e)}catch{}try{return ve(t)}catch{return}}async function Da({merchantId:e,anonymousId:t,pendingMergeToken:n}){let r=n?await Ea(n):void 0,[i,a,o]=await Promise.all([r?Z({op:`frak-merge-v1`,merchantId:e,anonymousId:t,binding:r}):Promise.resolve(null),Z({op:`frak-merge-v1`,merchantId:e,anonymousId:t}),Z({op:`frak-install-v1`,merchantId:e,anonymousId:t})]);if(i||a||o)return{anonymousId:t,proofs:{...i&&{merge:i},...a&&{mergeSource:a},...o&&{install:o}}}}async function Oa({config:e,rpcClient:t,lifecycleManager:n,configPromise:r,contextSent:i,openPanel:a,track:o,clientId:s}){await n.isConnected,qi(t,n.isConnected);let c=new URL(window.location.href),l=c.searchParams.get(`fmt`)??void 0;l&&(c.searchParams.delete(`fmt`),window.history.replaceState({},``,c.toString()));let u=t=>{let n=t?.merchantId??e.metadata.merchantId??``,r=t?.domain??``,i=t?.allowedDomains??[],a=t?.sdkConfig,o=a?.attribution||e.attribution?{...e.attribution,...a?.attribution}:void 0;X.setConfig(a?{isResolved:!0,merchantId:n,domain:r,allowedDomains:i,hasRawSdkConfig:!0,name:a.name??e.metadata.name,logoUrl:a.logoUrl??e.metadata.logoUrl,homepageLink:a.homepageLink??e.metadata.homepageLink,lang:a.lang??e.metadata.lang,currency:a.currency??e.metadata.currency,hidden:a.hidden,css:a.css,translations:a.translations,placements:a.placements,components:a.components,attribution:o}:{isResolved:!0,merchantId:n,domain:r,allowedDomains:i,name:e.metadata.name,logoUrl:e.metadata.logoUrl,homepageLink:e.metadata.homepageLink,lang:e.metadata.lang,currency:e.metadata.currency,attribution:o})},d=!1,f=Promise.resolve(),p=e=>{let n=d?void 0:l;d=!0;let r=wa(e),i=s,o=window.location.href;return Ta(a,e),f=f.then(async()=>{t.sendLifecycle({clientLifecycle:`resolved-config`,data:{merchantId:e.merchantId,domain:e.domain??``,allowedDomains:e.allowedDomains??[],sourceUrl:o,...i&&{sdkAnonymousId:i},...n&&{pendingMergeToken:n},...r&&{sdkConfig:r},...i&&{sdkIdentity:await Da({merchantId:e.merchantId,anonymousId:i,pendingMergeToken:n})}}})}).catch(e=>{console.error(`Failed to send lifecycle config`,e)}),f};X.isResolved&&p(X.getConfig()).then(i.resolve),r&&(u(await r),p(X.getConfig()).then(i.resolve));async function m(){let n=e.customizations?.css;n&&t.sendLifecycle({clientLifecycle:`modal-css`,data:{cssLink:n}})}async function h(){let n=e.customizations?.i18n;n&&t.sendLifecycle({clientLifecycle:`modal-i18n`,data:{i18n:n}})}async function g(){if(typeof window>`u`)return;let e=null;try{e=window.localStorage.getItem(Li)}catch{}e&&t.sendLifecycle({clientLifecycle:`restore-backup`,data:{backup:e}})}let _=[[`css`,m()],[`i18n`,h()],[`backup`,g()]],v=await Promise.allSettled(_.map(([,e])=>e)),y=v.findIndex(e=>e.status===`rejected`),b=v[y];if(b?.status===`rejected`){let{reason:e}=b,t=e instanceof Error;o?.(`sdk_iframe_handshake_failed`,{reason:`asset_push`,asset:_[y][0],error_name:t?e.name:typeof e,error_message:(t?e.message:String(e)).slice(0,200)})}return ka(p)}function ka(e){if(typeof document>`u`)return()=>{};let t=0,n=n=>{if(document.visibilityState!==`visible`||!X.isResolved)return;let r=Date.now();n&&r-t<6e4||(t=r,e(X.getConfig()))},r=()=>n(!0),i=setInterval(()=>n(!1),3e5);return document.addEventListener(`visibilitychange`,r),()=>{clearInterval(i),document.removeEventListener(`visibilitychange`,r)}}function Aa(e){return Cn(Fr(e))}function ja(e){try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}}function Ma(e){if(!e)return null;if(Array.isArray(e))return e;if(typeof e!=`string`)return null;try{let t=JSON.parse(e);return Array.isArray(t)?t:null}catch{return null}}function Na(e){if(typeof e==`number`)return Number.isFinite(e)?e:void 0;if(typeof e==`string`&&e.trim()!==``){let t=Number.parseFloat(e);return Number.isFinite(t)?t:void 0}}function Pa(e){if(typeof e!=`string`)return;let t=e.trim();return t===``?void 0:t}function Fa(e){if(!e||typeof e!=`object`)return;let t=e,n={},r=Pa(t.productId);r!==void 0&&(n.productId=r);let i=Pa(t.sku);i!==void 0&&(n.sku=i);let a=Pa(t.name);a!==void 0&&(n.name=a);let o=Na(t.quantity);o!==void 0&&(n.quantity=o);let s=Na(t.unitPrice);s!==void 0&&(n.unitPrice=s);let c=Na(t.totalPrice);return c!==void 0&&(n.totalPrice=c),Object.keys(n).length>0?n:void 0}function Ia(e){let t=Ma(e);if(!t)return;let n=[];for(let e of t){let t=Fa(e);t&&n.push(t)}return n.length>0?n:void 0}function La(e){if(!e||typeof e!=`object`)return null;let t=e,n=typeof t.title==`string`?t.title.trim():``,r=Fa(e);if(n===``&&!r)return null;let i={...r};return n!==``&&(i.title=n),typeof t.imageUrl==`string`&&ja(t.imageUrl)&&(i.imageUrl=t.imageUrl),typeof t.link==`string`&&ja(t.link)&&(i.link=t.link),typeof t.utmContent==`string`&&t.utmContent!==``&&(i.utmContent=t.utmContent),i}function Ra(e){let t=Ma(e);if(!t)return;let n=[];for(let e of t){let t=La(e);t&&n.push(t)}return n.length>0?n:void 0}function za(e){if(!e)return;let t;try{t=Aa(e)}catch{return}if(t!==null)return Ra(t)}async function Ba({config:e}){let t=Va(e);Ii(t);let n=await ca({config:t});if(!n){console.error(`Failed to create iframe`);return}let r=await Sa({config:t,iframe:n});if(!await r.waitForConnection)console.error(`Failed to connect to client`),await r.destroy({detachOnly:!0});else return await r.waitForSetup,r}function Va(e){let t=xi(e.metadata.currency);return{...e,metadata:{...e.metadata,currency:t}}}function Ha({perCall:e,defaults:t,productUtmContent:n}){if(e===null)return;let r=e!==void 0,i=t!==void 0&&Object.keys(t).length>0;if(!r&&!i&&(n===void 0||n===``))return;let a={...t,...e??{}},o=n||e?.utmContent;return o!==void 0&&o!==``?a.utmContent=o:delete a.utmContent,a}var Ua=/* @__PURE__ */ t({DEEP_LINK_SCHEME:()=>Ri,FrakContextManager:()=>yi,areAddressesEqual:()=>Yr,base64urlDecode:()=>Fr,base64urlEncode:()=>Pr,baseIframeProps:()=>sa,buildListenerUrl:()=>la,clearAllCache:()=>Ln,coerceProductCandidates:()=>Ma,compressJsonToB64:()=>Ir,createIFrameFrakClient:()=>Sa,decodeProductsParam:()=>za,decompressJsonFromB64:()=>Aa,deleteQueryParamCaseInsensitive:()=>Kr,detectPageLanguage:()=>Fi,findIframeInOpener:()=>pa,formatAmount:()=>wi,formatAmountParts:()=>Ei,generateSsoUrl:()=>Lr,getBackendUrl:()=>J,getClientId:()=>Nr,getClientIdAsync:()=>Q,getCurrencyAmountKey:()=>Oi,getEnvironment:()=>jn,getQueryParamCaseInsensitive:()=>Gr,getSupportedCurrency:()=>xi,isIOS:()=>ea,isInAppBrowser:()=>ra,isInstagramBrowser:()=>aa,isMobile:()=>ta,mergeAttribution:()=>Ha,normalizeProductDetails:()=>Fa,normalizeSharingProduct:()=>La,redirectToExternalBrowser:()=>oa,sanitizeProductDetailsList:()=>Ia,sanitizeSharingProducts:()=>Ra,sdkConfigStore:()=>X,setEnvironment:()=>An,setupClient:()=>Ba,ssoPopupFeatures:()=>Vr,ssoPopupName:()=>Hr,trackEvent:()=>$,triggerDeepLinkWithFallback:()=>Zi,withCache:()=>In});function Wa(){return window.FrakSetup?.config?.rewardReminder?.enabled!==!1&&X.getConfig().components?.rewardReminder?.enabled!==!1}const Ga=`frak:client`;function Ka(){let e=new CustomEvent(Ga);window.dispatchEvent(e)}function qa(e,t){window.FrakSetup?.client&&e===`add`?t():(e===`add`?window.addEventListener:window.removeEventListener)(Ga,t,!1)}function Ja(e){typeof window.requestIdleCallback==`function`?window.requestIdleCallback(e):setTimeout(e,1)}function Ya(){import(
136
136
  /* webpackChunkName: "mount-reward-reminder" */
137
- `./mountRewardReminder.BlmSRJDe.js`).then(({mountRewardReminder:e})=>e()).catch(e=>console.error(e))}function Xa(){let e=!1,t=()=>{!e&&window.FrakSetup?.client&&J.isResolved&&!J.getConfig().hidden&&Wa()&&(e=!0,window.removeEventListener(`frak:config`,t),qa(`remove`,t),Ja(Ya))};return window.addEventListener(`frak:config`,t),qa(`add`,t),()=>{window.removeEventListener(`frak:config`,t),qa(`remove`,t)}}const Za=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Qa(e){if(Za.test(e))return g(u(e,`uuid`))}async function $a(e,{steps:t,metadata:n},r){return await e.request({method:`frak_displayModal`,params:r?[t,n,e.config.metadata,r]:[t,n,e.config.metadata]})}async function eo(e,t,n){return await e.request({method:`frak_displaySharingPage`,params:n?[t,e.config.metadata,n]:[t,e.config.metadata]})}async function to(e){if(typeof window>`u`)return;let t=await X().catch(()=>void 0);if(!t)return;let n=await J.resolveMerchantId();if(!n)return;let r=`frak-identity-ensured-${n}-${t}`;if(!window.sessionStorage.getItem(r))try{let i=K(),a=await Y({op:`frak-ensure-v1`,merchantId:n,anonymousId:t});(await fetch(`${i}/user/identity/ensure`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"x-wallet-sdk-auth":e,"x-frak-client-id":t,...Dr()},body:JSON.stringify({merchantId:n,...a&&{proof:a}})})).ok&&window.sessionStorage.setItem(r,`1`)}catch{}}async function no({merchantId:e,checkoutToken:t}={}){let n=e??await J.resolveMerchantId();if(!n)return;let r=Pn(),i=encodeURIComponent(Qa(n)??n),a=t?`&checkoutToken=${encodeURIComponent(t)}`:``,o=`${r}/i?m=${i}`,s=await X().catch(()=>void 0);if(!s)return`${o}${a}`;let c=await Y({op:`frak-install-v1`,merchantId:n,anonymousId:s});return c?`${o}${a}#p=${encodeURIComponent(c)}`:`${o}&a=${encodeURIComponent(Qa(s)??s)}${a}`}async function ro(e,t){return Rn(()=>e.request({method:`frak_getMerchantInformation`}),{cacheKey:`frak_getMerchantInformation`,cacheTime:t?.cacheTime})}async function io(e,t){return Rn(async()=>{let t=await X().catch(()=>void 0),n=await J.resolveMerchantId(),r=t&&n?await Y({op:`frak-merge-v1`,merchantId:n,anonymousId:t}):null;return e.request({method:`frak_getMergeToken`,params:r?[r]:void 0})},{cacheKey:`frak_getMergeToken`,cacheTime:t?.cacheTime})}function ao(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.linked==`boolean`&&(t.pending===null||typeof t.pending==`object`)&&(t.earned===null||typeof t.earned==`object`)}async function oo({merchantId:e}={}){if(typeof window>`u`)return null;let t=e??await J.resolveMerchantId();if(!t)return null;let n=await X().catch(()=>void 0);if(!n)return null;let r=await Y({op:`frak-rewards-v1`,merchantId:t,anonymousId:n});if(!r)return null;let i=new AbortController,a=setTimeout(()=>i.abort(),5e3);try{let e=new URL(`${K()}/user/merchant/rewards-summary`);e.searchParams.set(`merchantId`,t);let a=await fetch(e.toString(),{signal:i.signal,headers:{Accept:`application/json`,"x-frak-client-id":n,"x-frak-proof":r,...Dr()}});if(!a.ok)return null;let o=await a.json();return ao(o)?o:null}catch{return null}finally{clearTimeout(a)}}async function so(e,t){return Rn(()=>e.request({method:`frak_getUserReferralStatus`}),{cacheKey:`frak_getUserReferralStatus`,cacheTime:t?.cacheTime})}async function co(e,t){let{metadata:n,customizations:r}=e.config;return await e.request({method:`frak_prepareSso`,params:[t,n.name,r?.css]})}async function lo(e,t){try{let n=await X().catch(()=>void 0);await e.request({method:`frak_sendInteraction`,params:[t,{clientId:n}]})}catch{console.warn(`[Frak SDK] Failed to send interaction:`,t.type)}}function uo(e,t,n){return ti(t)?(Z(e,`user_referred_started`,{referrer_client_id:t.c,referrer_wallet:t.w,wallet_status:n?.key}),lo(e,{type:`arrival`,referrerClientId:t.c,referrerMerchantId:t.m,referrerWallet:t.w,referralTimestamp:t.t}),!0):ei(t)?(Z(e,`user_referred_started`,{referrer:t.r,wallet_status:n?.key}),lo(e,{type:`arrival`,referrerWallet:t.r}),!0):!1}function fo(e,t,n){return!t&&!n?null:{v:2,m:e,t:Math.floor(Date.now()/1e3),...t?{c:t}:{},...n?{w:n}:{}}}function po(e,t,n){return ti(e)?e.w&&n?.wallet?Xr(e.w,n.wallet):e.c?t===e.c:!1:ei(e)&&n?.wallet?Xr(e.r,n.wallet):!1}async function mo(e,{walletStatus:t,frakContext:n,options:r}){if(!n)return`no-referrer`;let i=await X().catch(()=>void 0);if(po(n,i,t))return`self-referral`;if(!uo(e,n,t))return`no-referrer`;let a=ti(n)?n.m:r?.merchantId,o=r?.alwaysAppendUrl&&a?fo(a,i,t?.wallet):null;return bi.replaceUrl({url:window.location.href,context:o}),Z(e,`user_referred_completed`,{status:`success`}),`success`}async function ho(e,{options:t}={}){let n=bi.parse({url:window.location.href}),r=await yo(e);try{return await mo(e,{walletStatus:r,frakContext:n,options:t})}catch(e){console.warn(`Error processing referral`,{error:e})}}const go=`frak:referral-success`;async function _o(e){try{await ho(e)===`success`&&window.dispatchEvent(new Event(`frak:referral-success`))}catch(e){console.warn(`[Frak] Referral setup failed`,e)}}async function vo(e){if(typeof window>`u`){console.warn(`[Frak] No window found, can't track purchase`);return}let t=window.sessionStorage.getItem(`frak-wallet-interaction-token`),n=await X().catch(()=>void 0);if(!t&&!n){console.warn(`[Frak] No identity found, skipping purchase check`);return}let r=e.merchantId??await J.resolveMerchantId();if(!r){console.warn(`[Frak] No merchant id found, skipping purchase check`);return}let i={Accept:`application/json`,"Content-Type":`application/json`};t&&(i[`x-wallet-sdk-auth`]=t),n&&(i[`x-frak-client-id`]=n);let a=K();await fetch(`${a}/user/track/purchase`,{method:`POST`,headers:i,body:JSON.stringify({customerId:e.customerId,orderId:e.orderId,token:e.token,merchantId:r})})}function yo(e,t){if(!t)return e.request({method:`frak_listenToWalletStatus`}).then(t=>(bo(e,t),t));let n=new xn,r=!1;return e.listenerRequest({method:`frak_listenToWalletStatus`},i=>{bo(e,i),t(i),r||=(n.resolve(i),!0)},e=>n.reject(e)),n.promise}function bo(e,t){typeof window<`u`&&(e.openPanel?.setGlobalProperties({wallet:t.wallet??null}),t.interactionToken?(window.sessionStorage.setItem(`frak-wallet-interaction-token`,t.interactionToken),to(t.interactionToken)):window.sessionStorage.removeItem(`frak-wallet-interaction-token`))}function xo(e,{metadata:t,login:n}){return So(e,{steps:{login:n??{}},metadata:t})}function So(e,t){function n(n){return So(e,{...t,steps:{...t.steps,sendTransaction:n}})}function r(n){return So(e,{...t,steps:{...t.steps,final:{...n,action:{key:`reward`}}}})}async function i(n,r){return n&&(t.metadata=n(t.metadata??{})),await $a(e,t,r)}return{params:t,sendTx:n,reward:r,display:i}}async function Co(e,{tx:t,metadata:n}){return(await $a(e,{metadata:n,steps:{login:{},sendTransaction:{tx:t}}})).sendTransaction}function wo(e=96){let t=Math.ceil(e/2),n=``;if(typeof crypto<`u`&&crypto.getRandomValues){let e=new Uint8Array(t);crypto.getRandomValues(e);for(let t=0;t<e.length;t++)n+=e[t].toString(16).padStart(2,`0`)}else for(let e=0;e<t;e++)n+=(Math.random()*256|0).toString(16).padStart(2,`0`);return n.substring(0,e)}async function To(e,{siwe:t,metadata:n}){let r=e.config?.domain??window.location.host,i=t?.statement??`I confirm that I want to use my Frak wallet on: ${e.config.metadata.name}`;return(await $a(e,{metadata:n,steps:{login:{},siweAuthenticate:{siwe:{...t,statement:i,nonce:t?.nonce??wo(),uri:t?.uri??`https://${r}`,version:t?.version??`1`,domain:r}}}})).siweAuthenticate}var Eo=/* @__PURE__ */ t({REFERRAL_SUCCESS_EVENT:()=>go,displayModal:()=>$a,displaySharingPage:()=>eo,ensureIdentity:()=>to,getInstallUrl:()=>no,getMerchantInformation:()=>ro,getMergeToken:()=>io,getRewardSummary:()=>oo,getUserReferralStatus:()=>so,modalBuilder:()=>xo,openSso:()=>Gr,prepareSso:()=>co,prepareSsoUrl:()=>Hr,processReferral:()=>mo,referralInteraction:()=>ho,sendInteraction:()=>lo,sendTransaction:()=>Co,setupReferral:()=>_o,siweAuthenticate:()=>To,trackPurchaseStatus:()=>vo,watchWalletStatus:()=>yo});async function Do(e,t,n,r){window.FrakSetup?.client?await eo(window.FrakSetup.client,{...r?.link&&{link:r.link},...r?.products?.length&&{products:r.products},...r?.checkoutToken&&{checkoutToken:r.checkoutToken},metadata:{entryPoint:e,...t&&{targetInteraction:t}}},n).catch(e=>console.error(`Frak sharing page failed`,e)):console.error(`Frak client not found`)}function Oo(){return typeof document>`u`||document.querySelector(`frak-button-share,frak-button-wallet,frak-open-in-app,frak-post-purchase,frak-banner`)===null?[]:[`sharing`]}function ko(){return window.FrakSetup.core={...Ua,...Eo},window.FrakSetup?.client?Promise.resolve():Rn(()=>Ao(),{cacheKey:`frak-sdk-init`,cacheTime:1/0}).catch(e=>{Z(window.FrakSetup?.client,`sdk_init_failed`,{reason:e instanceof Error?e.message:typeof e==`string`?e:`unknown`,config_missing:!window.FrakSetup?.config})})}async function Ao(){if(!window.FrakSetup?.config)throw Error(`[Frak SDK] Configuration not found. Please ensure window.FrakSetup.config is set.`);let e=await Ba({config:jo(window.FrakSetup.config)});if(!e)throw Error(`[Frak SDK] Failed to create client`);window.FrakSetup.client=e,Ka(),_o(e),Mo()}function jo(e){return e.preload===void 0?{...e,preload:Oo()}:e}function Mo(){let e=new URL(window.location.href);if(qr(e.searchParams,`frakAction`)?.toLowerCase()!==`share`)return;let t=qr(e.searchParams,`link`)??void 0,n=qr(e.searchParams,`placement`)??void 0,r=za(qr(e.searchParams,`products`));Q(e.searchParams,`frakAction`),Q(e.searchParams,`link`),Q(e.searchParams,`placement`),Q(e.searchParams,`products`),window.history.replaceState({},``,e.toString()),Z(window.FrakSetup?.client,`sharing_page_auto_opened`,{placement:n,has_link:!!t,has_products:!!r?.length}),Do(`auto_open`,void 0,n,{link:t,products:r})}o.injectBase(`shared`,n),o.injectBase(`fouce`,`frak-ambassador:not(:defined), frak-button-share:not(:defined), frak-button-wallet:not(:defined), frak-open-in-app:not(:defined), frak-post-purchase:not(:defined), frak-banner:not(:defined), frak-reward-reminder:not(:defined) { display: none !important; }`),s(ko),Xa();const No={ambassador:()=>import(
137
+ `./mountRewardReminder.BlmSRJDe.js`).then(({mountRewardReminder:e})=>e()).catch(e=>console.error(e))}function Xa(){let e=!1,t=()=>{!e&&window.FrakSetup?.client&&X.isResolved&&!X.getConfig().hidden&&Wa()&&(e=!0,window.removeEventListener(`frak:config`,t),qa(`remove`,t),Ja(Ya))};return window.addEventListener(`frak:config`,t),qa(`add`,t),()=>{window.removeEventListener(`frak:config`,t),qa(`remove`,t)}}const Za=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Qa(e){if(Za.test(e))return g(u(e,`uuid`))}async function $a(e,{steps:t,metadata:n},r){return await e.request({method:`frak_displayModal`,params:r?[t,n,e.config.metadata,r]:[t,n,e.config.metadata]})}async function eo(e,t,n){return await e.request({method:`frak_displaySharingPage`,params:n?[t,e.config.metadata,n]:[t,e.config.metadata]})}async function to(e){if(typeof window>`u`)return;let t=await Q().catch(()=>void 0);if(!t)return;let n=await X.resolveMerchantId();if(!n)return;let r=`frak-identity-ensured-${n}-${t}`;if(!window.sessionStorage.getItem(r))try{let i=J(),a=await Z({op:`frak-ensure-v1`,merchantId:n,anonymousId:t});(await fetch(`${i}/user/identity/ensure`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"x-wallet-sdk-auth":e,"x-frak-client-id":t,...Tr()},body:JSON.stringify({merchantId:n,...a&&{proof:a}})})).ok&&window.sessionStorage.setItem(r,`1`)}catch{}}async function no({merchantId:e,checkoutToken:t}={}){let n=e??await X.resolveMerchantId();if(!n)return;let r=Mn(),i=encodeURIComponent(Qa(n)??n),a=t?`&checkoutToken=${encodeURIComponent(t)}`:``,o=`${r}/i?m=${i}`,s=await Q().catch(()=>void 0);if(!s)return`${o}${a}`;let c=await Z({op:`frak-install-v1`,merchantId:n,anonymousId:s});return c?`${o}${a}#p=${encodeURIComponent(c)}`:`${o}&a=${encodeURIComponent(Qa(s)??s)}${a}`}async function ro(e,t){return In(()=>e.request({method:`frak_getMerchantInformation`}),{cacheKey:`frak_getMerchantInformation`,cacheTime:t?.cacheTime})}async function io(e,t){return In(async()=>{let t=await Q().catch(()=>void 0),n=await X.resolveMerchantId(),r=t&&n?await Z({op:`frak-merge-v1`,merchantId:n,anonymousId:t}):null;return e.request({method:`frak_getMergeToken`,params:r?[r]:void 0})},{cacheKey:`frak_getMergeToken`,cacheTime:t?.cacheTime})}function ao(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.linked==`boolean`&&(t.pending===null||typeof t.pending==`object`)&&(t.earned===null||typeof t.earned==`object`)}async function oo({merchantId:e}={}){if(typeof window>`u`)return null;let t=e??await X.resolveMerchantId();if(!t)return null;let n=await Q().catch(()=>void 0);if(!n)return null;let r=await Z({op:`frak-rewards-v1`,merchantId:t,anonymousId:n});if(!r)return null;let i=new AbortController,a=setTimeout(()=>i.abort(),5e3);try{let e=new URL(`${J()}/user/merchant/rewards-summary`);e.searchParams.set(`merchantId`,t);let a=await fetch(e.toString(),{signal:i.signal,headers:{Accept:`application/json`,"x-frak-client-id":n,"x-frak-proof":r,...Tr()}});if(!a.ok)return null;let o=await a.json();return ao(o)?o:null}catch{return null}finally{clearTimeout(a)}}async function so(e,t){return In(()=>e.request({method:`frak_getUserReferralStatus`}),{cacheKey:`frak_getUserReferralStatus`,cacheTime:t?.cacheTime})}async function co(e,t){let{metadata:n,customizations:r}=e.config;return await e.request({method:`frak_prepareSso`,params:[t,n.name,r?.css]})}async function lo(e,t){try{let n=await Q().catch(()=>void 0);await e.request({method:`frak_sendInteraction`,params:[t,{clientId:n}]})}catch{console.warn(`[Frak SDK] Failed to send interaction:`,t.type)}}function uo(e,t,n){return ei(t)?($(e,`user_referred_started`,{referrer_client_id:t.c,referrer_wallet:t.w,wallet_status:n?.key}),lo(e,{type:`arrival`,referrerClientId:t.c,referrerMerchantId:t.m,referrerWallet:t.w,referralTimestamp:t.t}),!0):$r(t)?($(e,`user_referred_started`,{referrer:t.r,wallet_status:n?.key}),lo(e,{type:`arrival`,referrerWallet:t.r}),!0):!1}function fo(e,t,n){return!t&&!n?null:{v:2,m:e,t:Math.floor(Date.now()/1e3),...t?{c:t}:{},...n?{w:n}:{}}}function po(e,t,n){return ei(e)?e.w&&n?.wallet?Yr(e.w,n.wallet):e.c?t===e.c:!1:$r(e)&&n?.wallet?Yr(e.r,n.wallet):!1}async function mo(e,{walletStatus:t,frakContext:n,options:r}){if(!n)return`no-referrer`;let i=await Q().catch(()=>void 0);if(po(n,i,t))return`self-referral`;if(!uo(e,n,t))return`no-referrer`;let a=ei(n)?n.m:r?.merchantId,o=r?.alwaysAppendUrl&&a?fo(a,i,t?.wallet):null;return yi.replaceUrl({url:window.location.href,context:o}),$(e,`user_referred_completed`,{status:`success`}),`success`}async function ho(e,{options:t}={}){let n=yi.parse({url:window.location.href}),r=await yo(e);try{return await mo(e,{walletStatus:r,frakContext:n,options:t})}catch(e){console.warn(`Error processing referral`,{error:e})}}const go=`frak:referral-success`;async function _o(e){try{await ho(e)===`success`&&window.dispatchEvent(new Event(`frak:referral-success`))}catch(e){console.warn(`[Frak] Referral setup failed`,e)}}async function vo(e){if(typeof window>`u`){console.warn(`[Frak] No window found, can't track purchase`);return}let t=window.sessionStorage.getItem(`frak-wallet-interaction-token`),n=await Q().catch(()=>void 0);if(!t&&!n){console.warn(`[Frak] No identity found, skipping purchase check`);return}let r=e.merchantId??await X.resolveMerchantId();if(!r){console.warn(`[Frak] No merchant id found, skipping purchase check`);return}let i={Accept:`application/json`,"Content-Type":`application/json`};t&&(i[`x-wallet-sdk-auth`]=t),n&&(i[`x-frak-client-id`]=n);let a=J();await fetch(`${a}/user/track/purchase`,{method:`POST`,headers:i,body:JSON.stringify({customerId:e.customerId,orderId:e.orderId,token:e.token,merchantId:r})})}function yo(e,t){if(!t)return e.request({method:`frak_listenToWalletStatus`}).then(t=>(bo(e,t),t));let n=new yn,r=!1;return e.listenerRequest({method:`frak_listenToWalletStatus`},i=>{bo(e,i),t(i),r||=(n.resolve(i),!0)},e=>n.reject(e)),n.promise}function bo(e,t){typeof window<`u`&&(e.openPanel?.setGlobalProperties({wallet:t.wallet??null}),t.interactionToken?(window.sessionStorage.setItem(`frak-wallet-interaction-token`,t.interactionToken),to(t.interactionToken)):window.sessionStorage.removeItem(`frak-wallet-interaction-token`))}function xo(e,{metadata:t,login:n}){return So(e,{steps:{login:n??{}},metadata:t})}function So(e,t){function n(n){return So(e,{...t,steps:{...t.steps,sendTransaction:n}})}function r(n){return So(e,{...t,steps:{...t.steps,final:{...n,action:{key:`reward`}}}})}async function i(n,r){return n&&(t.metadata=n(t.metadata??{})),await $a(e,t,r)}return{params:t,sendTx:n,reward:r,display:i}}async function Co(e,{tx:t,metadata:n}){return(await $a(e,{metadata:n,steps:{login:{},sendTransaction:{tx:t}}})).sendTransaction}function wo(e=96){let t=Math.ceil(e/2),n=``;if(typeof crypto<`u`&&crypto.getRandomValues){let e=new Uint8Array(t);crypto.getRandomValues(e);for(let t=0;t<e.length;t++)n+=e[t].toString(16).padStart(2,`0`)}else for(let e=0;e<t;e++)n+=(Math.random()*256|0).toString(16).padStart(2,`0`);return n.substring(0,e)}async function To(e,{siwe:t,metadata:n}){let r=e.config?.domain??window.location.host,i=t?.statement??`I confirm that I want to use my Frak wallet on: ${e.config.metadata.name}`;return(await $a(e,{metadata:n,steps:{login:{},siweAuthenticate:{siwe:{...t,statement:i,nonce:t?.nonce??wo(),uri:t?.uri??`https://${r}`,version:t?.version??`1`,domain:r}}}})).siweAuthenticate}var Eo=/* @__PURE__ */ t({REFERRAL_SUCCESS_EVENT:()=>go,displayModal:()=>$a,displaySharingPage:()=>eo,ensureIdentity:()=>to,getInstallUrl:()=>no,getMerchantInformation:()=>ro,getMergeToken:()=>io,getRewardSummary:()=>oo,getUserReferralStatus:()=>so,modalBuilder:()=>xo,openSso:()=>Ur,prepareSso:()=>co,prepareSsoUrl:()=>Br,processReferral:()=>mo,referralInteraction:()=>ho,sendInteraction:()=>lo,sendTransaction:()=>Co,setupReferral:()=>_o,siweAuthenticate:()=>To,trackPurchaseStatus:()=>vo,watchWalletStatus:()=>yo});async function Do(e,t,n,r){window.FrakSetup?.client?await eo(window.FrakSetup.client,{...r?.link&&{link:r.link},...r?.products?.length&&{products:r.products},...r?.checkoutToken&&{checkoutToken:r.checkoutToken},metadata:{entryPoint:e,...t&&{targetInteraction:t}}},n).catch(e=>console.error(`Frak sharing page failed`,e)):console.error(`Frak client not found`)}function Oo(){return typeof document>`u`||document.querySelector(`frak-button-share,frak-button-wallet,frak-open-in-app,frak-post-purchase,frak-banner`)===null?[]:[`sharing`]}function ko(){return window.FrakSetup.core={...Ua,...Eo},window.FrakSetup?.client?Promise.resolve():In(()=>Ao(),{cacheKey:`frak-sdk-init`,cacheTime:1/0}).catch(e=>{$(window.FrakSetup?.client,`sdk_init_failed`,{reason:e instanceof Error?e.message:typeof e==`string`?e:`unknown`,config_missing:!window.FrakSetup?.config})})}async function Ao(){if(!window.FrakSetup?.config)throw Error(`[Frak SDK] Configuration not found. Please ensure window.FrakSetup.config is set.`);let e=await Ba({config:jo(window.FrakSetup.config)});if(!e)throw Error(`[Frak SDK] Failed to create client`);window.FrakSetup.client=e,Ka(),_o(e),Mo()}function jo(e){return e.preload===void 0?{...e,preload:Oo()}:e}function Mo(){let e=new URL(window.location.href);if(Gr(e.searchParams,`frakAction`)?.toLowerCase()!==`share`)return;let t=Gr(e.searchParams,`link`)??void 0,n=Gr(e.searchParams,`placement`)??void 0,r=za(Gr(e.searchParams,`products`));Kr(e.searchParams,`frakAction`),Kr(e.searchParams,`link`),Kr(e.searchParams,`placement`),Kr(e.searchParams,`products`),window.history.replaceState({},``,e.toString()),$(window.FrakSetup?.client,`sharing_page_auto_opened`,{placement:n,has_link:!!t,has_products:!!r?.length}),Do(`auto_open`,void 0,n,{link:t,products:r})}o.injectBase(`shared`,n),o.injectBase(`fouce`,`frak-ambassador:not(:defined), frak-button-share:not(:defined), frak-button-wallet:not(:defined), frak-open-in-app:not(:defined), frak-post-purchase:not(:defined), frak-banner:not(:defined), frak-reward-reminder:not(:defined) { display: none !important; }`),s(ko),Xa();const No={ambassador:()=>import(
138
138
  /* webpackChunkName: "ambassador" */
139
139
  `./Ambassador.Cmb0kX5D.js`),"button-share":()=>import(
140
140
  /* webpackChunkName: "button-share" */
@@ -148,4 +148,4 @@ const W=/* @__PURE__ */ on(/* @__PURE__ */ tn({p:BigInt(`0xffffffff0000000100000
148
148
  /* webpackChunkName: "banner" */
149
149
  `./Banner.2WJ4pT6E.js`),"reward-reminder":()=>import(
150
150
  /* webpackChunkName: "reward-reminder" */
151
- `./RewardReminder.C6o8lgak.js`)},Po=new MutationObserver(e=>{for(let{addedNodes:t}of e)for(let e of Array.from(t))e.nodeType===Node.ELEMENT_NODE&&Fo(e)});async function Fo(e){let t=e instanceof Element?e.tagName.toLowerCase():``,n=t?.startsWith(`frak-`),r=Array.from(e.querySelectorAll(`:not(:defined)`)).map(e=>e.tagName.toLowerCase()).filter(e=>e.startsWith(`frak-`));n&&!customElements.get(t)&&r.push(t);let i=[...new Set(r)];await Promise.allSettled(i.map(e=>Io(e)))}async function Io(e){if(customElements.get(e))return Promise.resolve();let t=e.replace(/^frak-/i,``);if(!(t in No))console.error(`Component ${e} is not supported.`);else try{await No[t]()}catch(e){console.error(e)}}Fo(document.body),Po.observe(document.documentElement,{subtree:!0,childList:!0});export{yn as A,Di as C,J as D,Z as E,s as M,o as N,Fr as O,n as P,Ti as S,Si as T,ta as _,so as a,Ia as b,oo as c,Wa as d,Ra as f,Qi as g,$ as h,vo as i,bn as j,Nn as k,io as l,ra as m,Do as n,no as o,oa as p,go as r,ro as s,ko as t,qa as u,Ii as v,Oi as w,ki as x,zi as y};
151
+ `./RewardReminder.C6o8lgak.js`)},Po=new MutationObserver(e=>{for(let{addedNodes:t}of e)for(let e of Array.from(t))e.nodeType===Node.ELEMENT_NODE&&Fo(e)});async function Fo(e){let t=e instanceof Element?e.tagName.toLowerCase():``,n=t?.startsWith(`frak-`),r=Array.from(e.querySelectorAll(`:not(:defined)`)).map(e=>e.tagName.toLowerCase()).filter(e=>e.startsWith(`frak-`));n&&!customElements.get(t)&&r.push(t);let i=[...new Set(r)];await Promise.allSettled(i.map(e=>Io(e)))}async function Io(e){if(customElements.get(e))return Promise.resolve();let t=e.replace(/^frak-/i,``);if(!(t in No))console.error(`Component ${e} is not supported.`);else try{await No[t]()}catch(e){console.error(e)}}Fo(document.body),Po.observe(document.documentElement,{subtree:!0,childList:!0});export{q as A,Ei as C,X as D,$ as E,s as M,o as N,Nr as O,n as P,wi as S,xi as T,ta as _,so as a,Ia as b,oo as c,Wa as d,Ra as f,Zi as g,ea as h,vo as i,vn as j,jn as k,io as l,ra as m,Do as n,no as o,oa as p,go as r,ro as s,ko as t,qa as u,Fi as v,Di as w,Oi as x,Ri as y};
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "url": "https://twitter.com/QNivelais"
12
12
  }
13
13
  ],
14
- "version": "1.5.0-beta.92148223",
14
+ "version": "1.5.0-beta.94832d46",
15
15
  "description": "Frak web components (share button, banner, post-purchase, ambassador page) for any merchant page; load the shim from https://sdk.frak.id/components.js.",
16
16
  "repository": {
17
17
  "url": "https://github.com/frak-id/wallet",
@@ -114,8 +114,8 @@
114
114
  "try:merchant": "bun scripts/tryOnMerchant.ts"
115
115
  },
116
116
  "dependencies": {
117
- "@frak-labs/core-sdk": "1.6.0-beta.92148223",
118
- "@frak-labs/frame-connector": "1.5.2-beta.92148223",
117
+ "@frak-labs/core-sdk": "1.6.0-beta.94832d46",
118
+ "@frak-labs/frame-connector": "1.5.2-beta.94832d46",
119
119
  "preact": "^10.29.8",
120
120
  "preact-custom-element": "^4.6.0",
121
121
  "qr": "^0.7.0"