@frak-labs/components 1.4.0 → 1.5.0-beta.671227ad

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.
Files changed (48) hide show
  1. package/cdn/Ambassador.Cmb0kX5D.js +519 -0
  2. package/cdn/Banner.2WJ4pT6E.js +227 -0
  3. package/cdn/{ButtonShare.C7A2tEvB.js → ButtonShare.DSGvJfJ-.js} +1 -1
  4. package/cdn/{ButtonWallet.Cg2OK1di.js → ButtonWallet.DHpHCl4c.js} +2 -2
  5. package/cdn/GiftIcon.DYg5xgHg.js +1 -0
  6. package/cdn/InstallQr.CHImaq56.js +1 -0
  7. package/cdn/{OpenInAppButton.Djz_cb9Y.js → OpenInAppButton.CxBzRNKw.js} +1 -1
  8. package/cdn/PostPurchase.C75q-9BM.js +124 -0
  9. package/cdn/RewardReminder.C6o8lgak.js +369 -0
  10. package/cdn/components.js +1 -1
  11. package/cdn/format.D2Ai5cCn.js +1 -0
  12. package/cdn/{GiftIcon.CW1SwrXH.js → icons.CdzHzZIJ.js} +1 -1
  13. package/cdn/jsxRuntime.module.7FJBZ9bf.js +58 -0
  14. package/cdn/loader.js +21 -16
  15. package/cdn/mountRewardReminder.BlmSRJDe.js +1 -0
  16. package/cdn/previewSummary.DxyobqED.js +1 -0
  17. package/cdn/replay-V6FXES7X.CgBxdfNp.js +1 -0
  18. package/cdn/rewardSummaryStore.DyjI-vPH.js +1 -0
  19. package/cdn/{rewards.t-rH9M3s.js → rewards.CeNLrK54.js} +1 -1
  20. package/cdn/useGlobalComponents.CNnOzerU.js +1 -0
  21. package/cdn/{useLightDomStyles.B72V1WPK.js → useLightDomStyles.557xWurb.js} +1 -1
  22. package/cdn/usePlacement.DYgmdkfr.js +1 -0
  23. package/cdn/{useReward.D2kXQbtD.js → useReward.BzUL3ijd.js} +1 -1
  24. package/dist/GiftIcon-Csu31jtf.js +62 -0
  25. package/dist/InstallQr-kpb44cfg.js +84 -0
  26. package/dist/ambassador.d.ts +16 -1
  27. package/dist/ambassador.js +534 -178
  28. package/dist/banner.d.ts +20 -6
  29. package/dist/banner.js +235 -13
  30. package/dist/format-zGdbUoX_.js +283 -0
  31. package/dist/i18n/defaults.d.ts +72 -0
  32. package/dist/i18n/defaults.js +108 -6
  33. package/dist/{GiftIcon-B9k_syq6.js → icons-iN3qH_Bv.js} +1 -61
  34. package/dist/postPurchase.d.ts +6 -1
  35. package/dist/postPurchase.js +187 -33
  36. package/dist/previewSummary-CMc6q8vI.js +37 -0
  37. package/dist/rewardReminder.d.ts +50 -0
  38. package/dist/rewardReminder.js +809 -0
  39. package/dist/sharedBaseCss.css-48sBApvf.js +3 -0
  40. package/package.json +18 -12
  41. package/cdn/Ambassador.BDu4aVZ9.js +0 -392
  42. package/cdn/Banner.BqfCxKs3.js +0 -208
  43. package/cdn/PostPurchase.DIZneqoT.js +0 -102
  44. package/cdn/jsxRuntime.module.DWH-kRVd.js +0 -58
  45. package/cdn/replay-V6FXES7X.efKsNT6s.js +0 -1
  46. package/cdn/useGlobalComponents.DVgSWfOp.js +0 -1
  47. package/cdn/usePlacement.DEOEf5_6.js +0 -1
  48. package/dist/sharedBaseCss.css-nYy9vlzH.js +0 -3
package/cdn/loader.js CHANGED
@@ -1,8 +1,9 @@
1
- var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};const n=`.reset_base__1831jhd0 {
1
+ var e=Object.defineProperty,t=(t,n)=>{let r=Object.setPrototypeOf({},null);for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n&1||e(r,Symbol.toStringTag,{value:`Module`}),n&2?r:Object.preventExtensions(r)};const n=`.reset_base__1831jhd0 {
2
2
  box-sizing: border-box;
3
3
  font-size: 100%;
4
4
  font: inherit;
5
5
  vertical-align: baseline;
6
+ overflow-wrap: break-word;
6
7
  -webkit-tap-highlight-color: transparent;
7
8
  border: 0;
8
9
  margin: 0;
@@ -85,7 +86,7 @@ var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],en
85
86
  --surface-success__pbq4ako: #f3fcf7;
86
87
  --surface-warning__pbq4akp: #fef9f2;
87
88
  --border-subtle__pbq4akq: #f5f5f5;
88
- --border-focus__pbq4akr: #a3a3a3;
89
+ --border-focus__pbq4akr: #737373;
89
90
  --border-error__pbq4aks: #e31c31;
90
91
  --border-success__pbq4akt: #09be67;
91
92
  --border-warning__pbq4aku: #ec7e00;
@@ -117,30 +118,34 @@ var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],en
117
118
  .sharedBaseCss_buttonReset__7cswil0:focus-visible {
118
119
  outline-color: currentColor;
119
120
  }
120
- `;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 ee(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 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)),ee(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,ee=e=>e>>>0;function te(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 y(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`&&`BYTES_PER_ELEMENT`in e&&e.BYTES_PER_ELEMENT===1}const b=e=>e?`"${e}" `:``;function x(e,t=``){if(typeof e!=`number`)throw TypeError(b(t)+`expected number, got `+typeof e);if(!Number.isSafeInteger(e)||e<0)throw RangeError(b(t)+`expected integer >= 0, got `+e);return e}function S(e,t,n=``){if(y(e)&&(t===void 0||e.length===t))return e;t!==void 0&&x(t,`length`);let r=y(e),i=t===void 0?``:` of length ${t}`,a=r?`length=${e.length}`:`type=${typeof e}`,o=b(n)+`expected Uint8Array`+i+`, got `+a;throw r?RangeError(o):TypeError(o)}function ne(e){if(typeof e!=`function`||typeof e.create!=`function`)throw TypeError(`expected hash wrapped by utils.createHasher`);if(x(e.outputLen),x(e.blockLen),e.outputLen<1||e.blockLen<1)throw Error(`hash blockLen / outputLen must be >= 1`)}const re=(e,t)=>{if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError((t===`object`?``:`"${t}" `)+`expected object, got type=`+typeof e)},C=(e,t)=>{re(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 w(e,t=!0){if(e.destroyed)throw Error(`hash was destroyed`);if(t&&e.finished)throw Error(`digest() was already called`)}function T(e,t){S(e,void 0,`output`);let n=t.outputLen;if(!(e.length>=n))throw RangeError(`"output" expected length >= `+n)}function ie(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function E(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function D(e,t){return e<<32-t|e>>>t}const O=typeof Uint8Array.from([]).toHex==`function`&&typeof Uint8Array.fromHex==`function`,ae=/* @__PURE__ */ Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function k(e){if(S(e),O)return e.toHex();let t=``;for(let n=0;n<e.length;n++)t+=ae[e[n]];return t}function oe(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function se(e){if(typeof e!=`string`)throw TypeError(`hex string expected, got `+typeof e);if(O)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=oe(e.charCodeAt(i)),a=oe(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 ce(...e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];S(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 le(e,t,n=`opts`){return C(e,`defaults`),t!==void 0&&C(t,n),Object.assign(Object.create(null),e,t)}function ue(e,t={}){if(typeof e!=`function`)throw TypeError(`"hashCons" expected function, got type=`+typeof e);t=le({},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 de(e=32){x(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 fe=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function pe(e,t,n){return e&t^~e&n}function me(e,t,n){return e&t^e&n^t&n}var he=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=E(this.buffer)}update(e){w(this),S(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=E(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){w(this),T(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)),te(n,r-8,this.length*8,i),this.process(n,0),this.roundClean();let o=e===t?n:E(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 ge=/* @__PURE__ */ Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),_e=/* @__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]),A=/* @__PURE__ */ new Uint32Array(64);var ve=class extends he{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)A[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=A[e-15],n=A[e-2],r=D(t,7)^D(t,18)^t>>>3,i=D(n,17)^D(n,19)^n>>>10;A[e]=i+A[e-7]+r+A[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=D(o,6)^D(o,11)^D(o,25),u=l+t+pe(o,s,c)+_e[e]+A[e]|0,d=(D(n,2)^D(n,13)^D(n,22))+me(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(){ie(A)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),ie(this.buffer)}},ye=class extends ve{constructor(){super(32,ge)}};const be=/* @__PURE__ */ ue(()=>new ye,/* @__PURE__ */ fe(1));
121
122
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
122
- 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 N(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=A,P=(...e)=>se(...e),Te=e=>oe(e),Ee=b,De=e=>ue(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 xe(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(A(e))}function Ie(e){return Pe(A(ze(C(e)).reverse()))}function Le(e,t){if(S(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 oe(r.padStart(n,`0`))}function Re(e,t){return Le(e,t).reverse()}function ze(e){return Uint8Array.from(M(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(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,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`){N(e,r),N(t,`fields`),N(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 xe(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 j=(e,t,n)=>S(e,t,n),Se=x;function Ce(e,t=``){if(typeof e!=`string`){let n=t&&`"${t}" `;throw TypeError(n+`expected string, got type=`+typeof e)}return e}function we(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 Te(e,t){if(typeof e!=`function`)throw TypeError(`"${t}" is invalid: expected function, got ${typeof e}`);return e}const Ee=k,M=(...e)=>ce(...e),De=e=>se(e),Oe=y,ke=e=>de(e),Ae=/* @__PURE__ */ BigInt(0),je=/* @__PURE__ */ BigInt(1),Me=e=>e?`"${e}" `:``;function N(e,t=``){if(typeof e!=`boolean`)throw TypeError(Me(t)+`expected boolean, got type=`+typeof e);return e}function Ne(e){if(typeof e==`bigint`){if(!P(e))throw RangeError(`positive bigint expected, got `+e)}else Se(e);return e}function Pe(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 Fe(e){let t=Ne(e).toString(16);return t.length&1?`0`+t:t}function Ie(e){if(typeof e!=`string`)throw TypeError(`hex string expected, got `+typeof e);return e===``?Ae:BigInt(`0x`+e)}function Le(e){return Ie(k(e))}function Re(e){return Ie(k(Ve(S(e)).reverse()))}function ze(e,t){if(x(t),t===0)throw Error(`zero output length is invalid`);e=Ne(e);let n=t*2,r=e.toString(16);if(r.length>n)throw RangeError(`number is too large`);return se(r.padStart(n,`0`))}function Be(e,t){return ze(e,t).reverse()}function Ve(e){return Uint8Array.from(j(e))}function P(e){return typeof e==`bigint`&&Ae<=e}function He(e,t,n){return P(e)&&P(t)&&P(n)&&t<=e&&e<n}function Ue(e,t,n,r){if(!He(t,n,r))throw RangeError(`expected valid `+e+`: `+n+` <= n < `+r+`, got `+t)}function We(e){if(e<Ae)throw Error(`expected non-negative bigint, got `+e);return e===Ae?0:e.toString(2).length}const Ge=e=>(Pe(e,`n`),(je<<BigInt(e))-je);function Ke(e,t,n){if(x(e,`hashLen`),x(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,M(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 M(...n)};return(e,t)=>{u(),f(e);let n;for(;(n=t(p()))===void 0;)f();return u(),n}}function F(e,t={},n={},r=`object`){we(e,r),we(t,`fields`),we(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
124
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
124
- 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(N(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),be(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&&xe(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){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?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){M(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)}
125
+ const I=/* @__PURE__ */ BigInt(0),L=/* @__PURE__ */ BigInt(1),R=/* @__PURE__ */ BigInt(2),qe=/* @__PURE__ */ BigInt(3),Je=/* @__PURE__ */ BigInt(4),Ye=/* @__PURE__ */ BigInt(5),Xe=/* @__PURE__ */ BigInt(7),Ze=/* @__PURE__ */ BigInt(8),Qe=/* @__PURE__ */ BigInt(9),$e=/* @__PURE__ */ BigInt(15),et=/* @__PURE__ */ BigInt(16),tt=/* @__PURE__ */ BigInt(`0x10000000000000000`);function z(e,t){if(t<=I)throw Error(`mod: expected positive modulus, got `+t);let n=e%t;return n>=I?n:t+n}function nt(e,t,n){if(n<=L)throw Error(`pow: expected modulus > 1, got `+n);if(typeof t!=`bigint`)throw TypeError(`invalid exponent: expected bigint, got `+typeof t);if(t<I)throw Error(`invalid exponent, negatives unsupported`);if(t===I)return L;if(t===L)return e;let r=e%n;if(r<I&&(r+=n),t<tt){let e=L;for(;t>I;)t&L&&(e=e*r%n),r=r*r%n,t>>=L;return e}let i=[];for(;t>I;)i.push(Number(t&$e)),t>>=Je;let a=Array(16);a[0]=L,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 rt(e,t){if(e===I)throw Error(`invert: expected non-zero number`);if(t<=L)throw Error(`invert: expected modulus > 1, got `+t);let n=z(e,t),r=t,i=I,a=L;for(;n!==I;){let e=r/n,t=r-n*e,o=i-a*e;r=n,n=t,i=a,a=o}if(r!==L)throw Error(`invert: does not exist`);return z(i,t)}function it(e,t){if(t<=L)throw Error(`invertCt: expected prime modulus > 1, got `+t);let n=z(e,t);if(n===I)throw Error(`invertCt: expected non-zero number`);let r=nt(n,t-R,t);if(z(n*r,t)!==L)throw Error(`invertCt: does not exist`);return r}function at(e,t,n){let r=e;if(!r.eql(r.sqr(t),n))throw Error(`Cannot find square root`)}function ot(e,t){if((e&L)===I)throw Error(t+`: expected odd modulus, got `+e)}function st(e,t){let n=e,r=(n.ORDER+L)/Je,i=n.pow(t,r);return at(n,i,t),i}function ct(e,t){let n=e,r=(n.ORDER-Ye)/Ze,i=n.mul(t,R),a=n.pow(i,r),o=n.mul(t,a),s=n.mul(n.mul(o,R),a),c=n.mul(o,n.sub(s,n.ONE));return at(n,c,t),c}function lt(e){let t=yt(e),n=ut(e),r=n(t,t.neg(t.ONE)),i=n(t,r),a=n(t,t.neg(r)),o=(e+Xe)/et;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 at(n,m,t),m})}function ut(e){if(e<qe)throw Error(`sqrt is not defined for small field`);ot(e,`tonelliShanks`);let t=e-L,n=0;for(;t%R===I;)t/=R,n++;let r=R,i=yt(e);for(;ht(i,r)===1;)if(r++>1e3)throw Error(`Cannot find square root: probably non-prime P`);if(n===1)return st;let a=i.pow(r,t),o=(t+L)/R;return function(e,r){let i=e;if(i.is0(r))return r;if(ht(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=L<<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 dt(e){return ot(e,`Fp.sqrt`),e%Je===qe?st:e%Ze===Ye?ct:e%et===Qe?lt(e):ut(e)}const ft=[`create`,`isValid`,`is0`,`neg`,`inv`,`sqrt`,`sqr`,`eql`,`add`,`sub`,`mul`,`pow`,`div`,`addN`,`subN`,`mulN`,`sqrN`];function pt(e){if(we(e,`field`),typeof e.ORDER!=`bigint`)throw TypeError(`param "ORDER" is invalid: expected bigint, got `+typeof e.ORDER);Pe(e.BYTES,`BYTES`),Pe(e.BITS,`BITS`);for(let t of ft)Te(e[t],`field.`+t);if(e.BYTES<1||e.BITS<1)throw Error(`invalid field: expected BYTES/BITS > 0`);if(e.ORDER<=L)throw Error(`invalid field: expected ORDER > 1, got `+e.ORDER);return e}function mt(e,t,n=!1){pt(e),xe(t,`nums`),N(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 ht(e,t){pt(e);let n=e;ot(n.ORDER,`FpLegendre`);let r=(n.ORDER-L)/R,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 gt(e,t){if(t!==void 0&&Se(t),e<=I)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=We(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 _t=/* @__PURE__ */ new WeakMap;var vt=class{ORDER;BITS;BYTES;isLE;ZERO=I;ONE=L;_lengths;_mod;constructor(e,t={}){if(e<=L)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}=gt(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 z(e,this.ORDER)}isValid(e){if(typeof e!=`bigint`)throw TypeError(`invalid field element: expected bigint, got `+typeof e);return I<=e&&e<this.ORDER}is0(e){return e===I}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&L)===L}neg(e){return z(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return z(e*e,this.ORDER)}add(e,t){return z(e+t,this.ORDER)}sub(e,t){return z(e-t,this.ORDER)}mul(e,t){return z(e*t,this.ORDER)}pow(e,t){return nt(e,t,this.ORDER)}div(e,t){return z(e*rt(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 rt(e,this.ORDER)}sqrt(e){let t=_t.get(this);return t||_t.set(this,t=dt(this.ORDER)),t(this,e)}toBytes(e){return this.isLE?Be(e,this.BYTES):ze(e,this.BYTES)}fromBytes(e,t=!1){j(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?Re(e):Le(e);if(o&&(s=z(s,a)),!t&&!this.isValid(s))throw Error(`invalid field element: outside of range 0..ORDER`);return s}invertBatch(e){return mt(this,e,!0)}cmov(e,t,n){return N(n,`condition`),n?t:e}};function yt(e,t={}){return Object.freeze(vt.prototype),new vt(e,t)}function bt(e){if(typeof e!=`bigint`)throw Error(`field order must be bigint`);if(e<=L)throw Error(`field order must be greater than 1`);let t=We(e-L);return Math.ceil(t/8)}function xt(e){let t=bt(e);return t+Math.ceil(t/2)}function St(e,t,n=!1){j(e);let r=e.length,i=bt(t),a=Math.max(xt(t),16);if(r<a||r>1024)throw Error(`expected `+a+`-1024 bytes of input, got `+r);let o=z(n?Re(e):Le(e),t-L)+L;return n?Be(o,i):ze(o,i)}
125
126
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
126
- 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`),N(t.BASE,`Point.BASE`),N(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){be(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(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 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=``){
127
+ const Ct=/* @__PURE__ */ BigInt(0),wt=/* @__PURE__ */ BigInt(1),Tt=/* @__PURE__ */ BigInt(4),Et=2**31;function Dt(e){let t=e;if(typeof t!=`function`)throw TypeError(`"Point" expected constructor, got type=`+typeof e);Te(t.fromAffine,`Point.fromAffine`),Te(t.fromBytes,`Point.fromBytes`),Te(t.fromHex,`Point.fromHex`),we(t.BASE,`Point.BASE`),we(t.ZERO,`Point.ZERO`),pt(t.Fp),pt(t.Fn)}function Ot(e,t){Dt(e),Mt(t,e);let n=mt(e.Fp,t.map(e=>e.Z));return t.map((t,r)=>e.fromAffine(t.toAffine(n[r])))}function kt(e,t,n=1){if(!Number.isSafeInteger(e)||e<n||e>t)throw Error(`invalid window size, expected [`+n+`..`+t+`], got W=`+e)}function At(e,t){let n=e*(4*t+128);if(n>Et)throw Error(`invalid window size: table would need ~`+Math.ceil(n/2**20)+` MiB, max `+Et/2**20+` MiB`)}function jt(e,t){if(e!==void 0){Te(e,`randomBytes`);try{let n=e(t);if(!Oe(n)||n.length!==t)return}catch{return}return e}}function Mt(e,t){xe(e,`points`),e.forEach((e,n)=>{if(!(e instanceof t))throw Error(`invalid point at index `+n)})}function Nt(e,t,n){if(!Array.isArray(e))throw Error(`array of scalars expected`);e.forEach((e,r)=>{if(!(n===void 0?t.isValid(e):P(e)&&e<n))throw Error(`invalid scalar at index `+r)})}const Pt=/* @__PURE__ */ new WeakMap;function Ft(e){return Pt.get(e)||1}function It(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 Lt(e,t){let n=2**t,r=n/2,i=BigInt(n-1),a=[];for(;e>Ct;){let t=0;e&wt&&(t=Number(e&i),t>=r&&(t-=n),e-=BigInt(t)),a.push(t),e>>=wt}return a}function Rt(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+=wt),s.push(t)}if(e!==Ct)throw Error(`invalid wnaf`);return s}function zt(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 Bt=class{Point;BASE;ZERO;randomBytes;wnafPrecomputes=/* @__PURE__ */ new WeakMap;baseCanBeBlinded;bits;constructor(e,t){Dt(e),this.randomBytes=jt(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=Rt(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),!He(t,wt,this.Point.Fn.ORDER))throw Error(`invalid scalar`)}runCT(e,t,n,r){let i=Ft(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(!Oe(i)||i.length!==16)throw Error(`randomBytes returned invalid byte array`);i[0]=i[0]&63|128;let a=t+Le(i)*this.Point.Fn.ORDER;return this.runCT(e,a,r,n)}fixedWindowCT(e,t,n){let r=Ge(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===wt||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),!P(t))throw Error(`invalid scalar`);let r=Ft(e);if(r===1||t>=this.Point.Fn.ORDER)return Vt(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),kt(t,this.bits),At((Math.ceil((this.bits+128)/t)+1)*2**(t-1),this.Point.Fp.BYTES),Pt.set(e,t),this.wnafPrecomputes.delete(e)}hasWindowSize(e){return Ft(e)!==1}};function Vt(e,t,n,r=!1){if(Dt(e),Mt(t,e),N(r,`allowOversized`),Nt(n,e.Fn,r?e.Fn.ORDER**Tt:void 0),t.length!==n.length)throw Error(`arrays of points and scalars must have equal length`);let i=t.map(e=>It(e,4)),a=n.map(e=>Lt(e,4));return zt(e.ZERO,i,a)}function Ht(e,t,n){if(t){if(t.ORDER!==e)throw Error(`Field.ORDER must match order: Fp == p, Fn == n`);return pt(t),t}return yt(e,{isLE:n})}function Ut(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`);F(n);for(let e of[`p`,`n`,`h`]){let n=t[e];if(!(P(n)&&n!==Ct))throw Error(`CURVE.${e} must be positive bigint`)}let i=Ht(t.p,n.Fp,r),a=Ht(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 Wt(e,t){return function(n){let r=e(n);return{secretKey:r,publicKey:t(r)}}}var Gt=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,t){if(ne(e),S(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),ie(r)}update(e){return w(this),this.iHash.update(e),this}digestInto(e){w(this),T(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 Kt=/* @__PURE__ */ (()=>{let e=((e,t,n)=>new Gt(e,t).update(n).digest());return e.create=(e,t)=>new Gt(e,t),e})(),qt=/* @__PURE__ */ BigInt(0),B={Err:class extends Error{constructor(e=``){
127
128
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
128
- 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(Se(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=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}=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=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}=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
129
+ super(e)}},_tlv:{encode:(e,t)=>{let{Err:n}=B;if(Pe(e,`tag`),e<0||e>255)throw new n(`tlv.encode: wrong tag`);if(Ce(t,`data`),t.length&1)throw new n(`tlv.encode: unpadded data`);let r=t.length/2,i=Fe(r);if(i.length/2&128)throw new n(`tlv.encode: long form length too big`);let a=r>127?Fe(i.length/2|128):``;return Fe(e)+a+i+t},decode(e,t){let{Err:n}=B;t=j(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}=B;if(Ne(e),e<qt)throw new t(`integer: negative integers are not allowed`);let n=Fe(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}=B;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 Le(e)}},toSig(e,t){let{Err:n,_int:r,_tlv:i}=B;if(t!==void 0&&(Pe(t,`maxScalarBytes`),t<1))throw new n(`invalid signature: maxScalarBytes must be positive`);let a=j(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}=B;F(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)}},Jt=(Object.freeze(B._tlv),Object.freeze(B._int),Object.freeze(B)),Yt=(e,t)=>(e+(e>=0?t:-t)/$t)/t
129
130
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
130
- ;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){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 ee=p===void 0?v:p,b=f===void 0?y:f,x=r.mul(a.b,Qt),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,Qt),$t),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 Jt(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(Te(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(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(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===U||t.is0())return k.ZERO;if(n===W)return t;if(A.hasWindowSize(this))return A.mulUnsafe(t,n,ie);let r=[],a=[];return D(r,a,t,n),zt(k,r,a)}mulAddUnsafe(e,t,n){E(t);let r=[],i=[];return D(r,i,this,e),D(r,i,t,n),zt(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===W?!0:d?d(k,this):A.mulUnsafe(this,s).is0()}clearCofactor(){return o===W?this:u?u(k,this):this.multiplyUnsafe(o)}isSmallOrder(){return o===W?this.is0():this.clearCofactor().is0()}toBytes(e=!0){return F(e,`isCompressed`),this.assertValidity(),ee(k,this,e)}toHex(e=!0){return we(this.toBytes(e))}toString(){return`<Point ${this.is0()?`ZERO`:this.toHex()}>`}}let ie=e=>Et(k,e),A=new Rt(k,m);return A.bits>=6&&k.BASE.precompute(6),Object.freeze(k.prototype),Object.freeze(k),k}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(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(!Ee(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=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;te(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 ee(e){return e>l>>W}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(y)throw Error(`"recovered" sig type is not supported for cofactor >2 curves`)}function ne(e,t){Yt(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 Kt.Err(`invalid signature: DER signature too long`);let{r:t,s:n}=Kt.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(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 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(P(tn(!(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 ee(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`?(C(),P(Uint8Array.of(this.assertRecovery()),r,i)):P(r,i)}toHex(e){return we(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=Fe(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=Ue(u);function D(e){return Ve(`num < 2^`+u,e,U,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}=Xt(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=P(...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===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=S(r.x,r.y,a),u=o;return i&&ee(o)&&(u=c.neg(o),s^=1),new w(a,u,y?void 0:s)}return{seed:h,k2sig:b}}function ie(e,t,n={}){let{seed:i,k2sig:a}=k(e,t,n);return We(r.outputLen,c.BYTES,o)(i,a).toBytes(n.format)}function A(t,n,r,i={}){let{lowS:a,prehash:o,format:s}=Xt(i,v);if(r=M(r,void 0,`publicKey`),n=O(n,o),!Ee(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}=Xt(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 Xt(e,t,n){Ue(`scalar`,e,V,n);let[[r,i],[a,o]]=t,s=Yt(o*e,n),c=Yt(-i*e,n),l=e-s*r-c*a,u=-s*i-c*o,d=l<V,f=u<V;d&&(l=-l),f&&(u=-u);let p=Ge(Math.ceil(We(n)/2))+H;if(l<V||l>=p||u<V||u>=p)throw Error(`splitScalar (endomorphism): failed for k`);return{k1neg:d,k1:l,k2neg:f,k2:u}}function Zt(e){if(![`compact`,`recovered`,`der`].includes(e))throw Error(`Signature format must be "compact", "recovered", or "der"`);return e}function Qt(e,t){F(e);let n={};for(let r of Object.keys(t))n[r]=e[r]===void 0?t[r]:e[r];return N(n.lowS,`lowS`),N(n.prehash,`prehash`),n.format!==void 0&&Zt(n.format),n}const V=/* @__PURE__ */ BigInt(0),H=/* @__PURE__ */ BigInt(1),$t=/* @__PURE__ */ BigInt(2),en=/* @__PURE__ */ BigInt(3),tn=/* @__PURE__ */ BigInt(4);function nn(e,t={}){let n=Ut(`weierstrass`,e,t),r=n.Fp,i=n.Fn,a=n.CURVE,{h:o,n:s}=a;F(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?ke: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=an(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(N(n,`isCompressed`),n){_();let e=!r.isOdd(a);return M(rn(e),o)}return M(Uint8Array.of(4),o,r.toBytes(a))}function ee(e){j(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=S(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(!ne(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 te=p===void 0?v:p,y=f===void 0?ee:f,b=r.mul(a.b,en),x=r.is0(a.a)?e=>r.ZERO:e=>r.mul(a.a,e);function S(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 ne(e,t){let n=r.sqr(t),i=S(e);return r.eql(n,i)}if(!ne(a.Gx,a.Gy))throw Error(`bad curve params: generator point`);let re=r.mul(r.pow(a.a,en),tn),C=r.mul(r.sqr(a.b),BigInt(27));if(r.is0(r.add(re,C)))throw Error(`bad curve params: a or b`);function w(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 T(e){if(!(e instanceof O))throw Error(`Weierstrass Point expected`)}function ie(e){if(!h||!h.basises)throw Error(`no endo`);return Xt(e,h.basises,i.ORDER)}function E(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}=ie(a),l=new O(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 D=/* @__PURE__ */ new WeakSet;class O{static BASE=new O(a.Gx,a.Gy,r.ONE);static ZERO=new O(r.ZERO,r.ONE,r.ZERO);static Fp=r;static Fn=i;X;Y;Z;constructor(e,t,n){this.X=w(`x`,e),this.Y=w(`y`,t,!0),this.Z=w(`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 O)throw Error(`projective point not allowed`);return r.is0(t)&&r.is0(n)?O.ZERO:new O(t,n,r.ONE)}static fromBytes(e){let t=O.fromAffine(y(j(e,void 0,`point`)));return t.assertValidity(),t}static fromHex(e){return O.fromBytes(De(e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=6,t=!0){return k.setWindowSize(this,e),t||this.multiply(en),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(D.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(!ne(t,n))throw Error(`bad point: equation left != right`);if(!e.isTorsionFree())throw Error(`bad point: not in prime-order subgroup`);D.add(e)}hasEvenY(){let{y:e}=this.toAffine();if(!r.isOdd)throw Error(`Field doesn't support isOdd`);return!r.isOdd(e)}equals(e){T(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 O(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=x(o),a=r.mul(b,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(b,o),l=x(l),u=r.sub(s,l),u=x(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 O(i,a,o)}add(e){T(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=x(h),c=r.mul(b,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=x(p),h=r.mul(b,h),f=r.add(f,p),p=r.sub(d,p),p=x(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 O(c,l,u)}subtract(e){return T(e),this.add(e.negate())}is0(){return this.equals(O.ZERO)}multiply(e){if(!i.isValidNot0(e))throw RangeError(`invalid scalar: out of range`);let{p:t,f:n}=k.mulSecret(this,e,o,ae);return ae([t,n])[0]}multiplyUnsafe(e){let t=this,n=e;if(!i.isValid(n))throw RangeError(`invalid scalar: out of range`);if(n===V||t.is0())return O.ZERO;if(n===H)return t;if(k.hasWindowSize(this))return k.mulUnsafe(t,n,ae);let r=[],a=[];return E(r,a,t,n),Vt(O,r,a)}mulAddUnsafe(e,t,n){T(t);let r=[],i=[];return E(r,i,this,e),E(r,i,t,n),Vt(O,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===H?!0:d?d(O,this):k.mulUnsafe(this,s).is0()}clearCofactor(){return o===H?this:u?u(O,this):this.multiplyUnsafe(o)}isSmallOrder(){return o===H?this.is0():this.clearCofactor().is0()}toBytes(e=!0){return N(e,`isCompressed`),this.assertValidity(),te(O,this,e)}toHex(e=!0){return Ee(this.toBytes(e))}toString(){return`<Point ${this.is0()?`ZERO`:this.toHex()}>`}}let ae=e=>Ot(O,e),k=new Bt(O,m);return k.bits>=6&&O.BASE.precompute(6),Object.freeze(O.prototype),Object.freeze(O),O}function rn(e){return Uint8Array.of(e?2:3)}function an(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function on(e,t={}){Dt(e);let{Fn:n}=e,r=t.randomBytes===void 0?ke:t.randomBytes,i=Object.assign(an(e.Fp,n),{seed:Math.max(xt(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,St(j(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(!Oe(e))return;let s=j(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=Wt(s,c);return Object.freeze(d),Object.freeze(i),Object.freeze({getPublicKey:c,getSharedSecret:u,keygen:f,Point:e,utils:d,lengths:i})}function sn(e,t,n={}){Dt(e);let r=t;ne(r),F(n,{},{hmac:`function`,lowS:`boolean`,randomBytes:`function`,bits2int:`function`,bits2int_modN:`function`});let i=Object.assign({},n),a=i.randomBytes===void 0?ke:i.randomBytes,o=i.hmac===void 0?(e,t)=>Kt(r,e,t):i.hmac,{Fp:s,Fn:c}=e,{ORDER:l,BITS:u}=c,d=xt(l),f=jt(a,d),{keygen:p,getPublicKey:m,getSharedSecret:h,utils:g,lengths:_}=on(e,i),v={prehash:!0,lowS:typeof i.lowS!=`boolean`||i.lowS,format:`compact`,extraEntropy:!1},ee=l*$t+H<s.ORDER;function te(e){return e>l>>H}function y(e,t){if(!c.isValidNot0(t))throw Error(`invalid signature ${e}: out of range 1..Point.Fn.ORDER`);return t}function b(){if(!s.isOdd)throw Error(`Field doesn't support isOdd`)}function x(e,t,n){return b(),(e===n?0:2)|Number(s.isOdd(t))}function S(){if(ee)throw Error(`"recovered" sig type is not supported for cofactor >2 curves`)}function re(e,t){Zt(t);let n=_.signature,r=t===`compact`?n:t===`recovered`?n+1:void 0;return j(e,r)}class C{r;s;recovery;constructor(e,t,n){if(this.r=y(`r`,e),this.s=y(`s`,t),n!=null){if(S(),![0,1,2,3].includes(n))throw Error(`invalid recovery id`);this.recovery=n}Object.freeze(this)}static fromBytes(e,t=v.format){re(e,t);let n;if(t===`der`){if(e.length>2*c.BYTES+16)throw new Jt.Err(`invalid signature: DER signature too long`);let{r:t,s:n}=Jt.toSig(j(e),c.BYTES+1);return new C(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 C(c.fromBytes(i),c.fromBytes(a),n)}static fromHex(e,t){return this.fromBytes(De(e),t)}assertRecovery(){let{recovery:e}=this;if(e==null)throw Error(`invalid recovery id: must be present`);return e}addRecoveryBit(e){return new C(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(M(rn(!(i&1)),o)),d=c.inv(a),f=T(j(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 te(this.s)}toBytes(e=v.format){if(Zt(e),e===`der`)return De(Jt.hexFromSig(this));let{r:t,s:n}=this,r=c.toBytes(t),i=c.toBytes(n);return e===`recovered`?(S(),M(Uint8Array.of(this.assertRecovery()),r,i)):M(r,i)}toHex(e){return Ee(this.toBytes(e))}}Object.freeze(C.prototype),Object.freeze(C);let w=i.bits2int===void 0?function(e){if(e.length>8192)throw Error(`input is too large`);let t=Le(e),n=e.length*8-u;return n>0?t>>BigInt(n):t}:i.bits2int,T=i.bits2int_modN===void 0?function(e){return c.create(w(e))}:i.bits2int_modN,ie=Ge(u);function E(e){return Ue(`num < 2^`+u,e,V,ie),c.toBytes(e)}function D(e,t){return j(e,void 0,`message`),t?j(r(e),void 0,`prehashed message`):e}function O(t,n,r){let{lowS:i,prehash:o,extraEntropy:s}=Qt(r,v);t=D(t,o);let u=T(t),p=c.fromBytes(n);if(!c.isValidNot0(p))throw Error(`invalid private key`);let m=[E(p),E(u)];if(s!=null&&s!==!1){let e=s===!0?a(_.secretKey):s;m.push(j(e,void 0,`extraEntropy`))}let h=M(...m),g=u;function y(t){let n=w(t);if(!c.isValidNot0(n))return;let r=e.BASE.multiply(n).toAffine(),a=c.create(r.x);if(a===V)return;let o;if(f!==void 0){let e=Le(St(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=it(n,l);o=c.create(e*c.create(g+a*p))}if(o===V)return;let s=x(r.x,r.y,a),u=o;return i&&te(o)&&(u=c.neg(o),s^=1),new C(a,u,ee?void 0:s)}return{seed:h,k2sig:y}}function ae(e,t,n={}){let{seed:i,k2sig:a}=O(e,t,n);return Ke(r.outputLen,c.BYTES,o)(i,a).toBytes(n.format)}function k(t,n,r,i={}){let{lowS:a,prehash:o,format:s}=Qt(i,v);if(r=j(r,void 0,`publicKey`),n=D(n,o),!Oe(t)){let e=t instanceof C?`, use sig.toBytes()`:``;throw Error(`verify expects Uint8Array signature`+e)}re(t,s);try{let i=C.fromBytes(t,s),o=e.fromBytes(r);if(o.is0()||a&&i.hasHighS())return!1;let{r:l,s:u}=i,d=T(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!==x(g.x,g.y,l))}catch{return!1}}function oe(e,t,n={}){let{prehash:r}=Qt(n,v);return t=D(t,r),C.fromBytes(e,`recovered`).recoverPublicKey(t).toBytes()}return Object.freeze({keygen:p,getPublicKey:m,getSharedSecret:h,utils:g,lengths:_,Point:e,sign:ae,verify:k,recoverPublicKey:oe,Signature:C,hash:r})}
131
132
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
132
- 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`)}),ye),on=`pkcs8`,sn=on,cn=`spki`
133
+ const U=/* @__PURE__ */ sn(/* @__PURE__ */ nn({p:BigInt(`0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff`),n:BigInt(`0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551`),h:BigInt(1),a:BigInt(`0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc`),b:BigInt(`0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b`),Gx:BigInt(`0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296`),Gy:BigInt(`0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5`)}),be),cn=`pkcs8`,ln=cn,un=`spki`
133
134
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
134
- ;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=M(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(M(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(M(n,void 0,`signature`)),s=ze(M(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(M(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`),vn={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 yn=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}}},bn=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 xn(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{}}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{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{return}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 bn;return o.set(t,e=>{e.error?n.reject(new yn(e.error.code,e.error.message,e.error.data)):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){let n=h();return o.set(n,e=>{e.error?o.delete(n):t(e.result)}),p({id:n,topic:e.method,data:{method:e.method,params:e.params}}).catch(e=>{o.delete(n)}),()=>{o.delete(n)}}function v(){n.removeEventListener(`message`,f),o.clear()}return{request:g,listen:_,sendLifecycle:m,cleanup:v}}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]:Tn.prod:!e?.wallet||!e?.backend?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)),Dn=t,En()&&(window[wn]=t),t}function jn(){return En()?window[wn]??Dn:Dn}function Mn(){return jn().wallet}function q(){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},J=typeof window<`u`;function Hn(){return{isResolved:!1,merchantId:``}}let Un=null;function Wn(){if(!J)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(J&&e.isResolved)try{let t={config:e,timestamp:Date.now()};localStorage.setItem(Vn.key,JSON.stringify(t)),Un=t}catch{}}function Jn(){if(J){Un=null;try{localStorage.removeItem(Vn.key)}catch{}}}function Yn(){J&&(window[Rn]||(window[Rn]=Gn()??Hn()))}function Xn(){return J?(Yn(),window[Rn]??Hn()):Hn()}function Zn(e){J&&window.dispatchEvent(new CustomEvent(`frak:config`,{detail:e}))}function Qn(e){return e??(J?window.location.hostname:``)}async function $n(e,t){try{let n=q(),r=t?`&lang=${encodeURIComponent(t)}`:``,i=await fetch(`${n}/user/merchant/resolve?domain=${encodeURIComponent(e)}${r}`);if(!i.ok)return;let a=await i.json();if(J)try{sessionStorage.setItem(Bn,a.merchantId)}catch{}return a}catch{return}}const Y={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(J&&(window[Rn]=e),qn(e),Zn(e),J&&e.merchantId)try{sessionStorage.setItem(Bn,e.merchantId)}catch{}},reset(){let e=Gn()??Hn();J&&(window[Rn]=e),Zn(e)},clearCache(){if(Jn(),Ln(),J)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(J)try{return sessionStorage.getItem(Bn)??void 0}catch{}},async resolveMerchantId(e){return Y.getMerchantId()||(await Y.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(ye(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 X(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.5.5`}}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 Y.resolveMerchantId();if(!n)return;let r=await X({op:`frak-merge-v1`,merchantId:n,anonymousId:t});if(!r)return;let i=q(),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 Z(){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 Z().catch(()=>void 0),a=await Y.resolveMerchantId()??``,o=i&&a?await X({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 Q(e,t,n){if(e)try{e.openPanel?.track(t,n)}catch{}}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 $(e,t){let n=t.toLowerCase(),r=[...e.keys()].filter(e=>e.toLowerCase()===n);for(let t of r)e.delete(t)}const Kr=/^0x[a-fA-F0-9]{40}$/;function qr(e){return typeof e==`string`&&Kr.test(e)}function Jr(e,t){return e.toLowerCase()===t.toLowerCase()}function Yr(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 Xr=/*#__PURE__*/ Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function Zr(e){let t=`0x`;for(let n=0;n<20;n++)t+=Xr[e[n]];return t}function Qr(e){return`r`in e&&!(`v`in e)}function $r(e){return`v`in e&&e.v===2}const ei=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function ti(e){return typeof e==`string`&&ei.test(e)}function ni(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 ri(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 ii(e){if(!ti(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`&&qr(e.w);if(!t&&!n||t&&!ti(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(ni(e.m),a),a+=16,i.setUint32(a,e.t,!1),a+=4,t&&(r.set(ni(e.c),a),a+=16),n&&(r.set(Yr(e.w),a),a+=20),r}function ai(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=ri(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=ri(e.subarray(a,a+16)),a+=16),r){let t=Zr(e.subarray(a,a+20));if(!qr(t))return null;c.w=t,a+=20}return c}const oi=`fCtx`;function si(e){try{return new URL(e)}catch{return null}}function ci(e){return e.protocol===`http:`||e.protocol===`https:`}function li(e){if(e)try{if($r(e)){let t=ii(e);return t?Pr(t):void 0}return Pr(Yr(e.r))}catch{}}function ui(e){if(e&&e.length!==0)try{let t=Fr(e);if(t.length!==20)return ai(t)||void 0;let n=Zr(t);if(qr(n))return{r:n}}catch{}}function di({url:e}){if(!e)return null;let t=si(e);if(!t)return null;let n=Gr(t.searchParams,oi);return n?ui(n):null}function fi(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 pi(e,t){let n=fi(t??{});for(let[t,r]of Object.entries(n))r!==void 0&&r!==``&&(e.searchParams.has(t)||e.searchParams.set(t,r))}function mi({url:e,context:t,attribution:n}){let r=e?si(e):null;return!r||!ci(r)?null:hi(r,t,n)}function hi(e,t,n){let r=li(t);return r?($(e.searchParams,oi),e.searchParams.set(oi,r),pi(e,n),e.toString()):null}function gi(e){let t=si(e);return t?($(t.searchParams,oi),t.toString()):e}function _i({url:e,context:t}){if(typeof window>`u`||!window.location?.href)return;let n=e??window.location.href,r;if(t!==null){let e=si(n);r=e?hi(e,t):null}else r=gi(n);r&&window.history.replaceState(null,``,r.toString())}const vi={compress:li,decompress:ui,parse:di,update:mi,remove:gi,replaceUrl:_i},yi={eur:`fr-FR`,usd:`en-US`,gbp:`en-GB`};function bi(e){return e&&e in yi?e:`eur`}function xi(e){return e?yi[e]??yi.eur:yi.eur}function Si(e){return e.replaceAll(` `,`\xA0`)}function Ci(e,t){let n=xi(t),r=bi(t);return Si(e.toLocaleString(n,{style:`currency`,currency:r,minimumFractionDigits:0,maximumFractionDigits:2}))}function wi(e){return e.formatToParts(1.1).find(e=>e.type===`decimal`)?.value??`.`}function Ti(e,t){let n=xi(t),r=bi(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+=Si(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||`${wi(i)}00`,unit:c,unitPosition:l}}function Ei(e){return{integer:String(e),unit:`%`,unitPosition:`suffix`}}function Di(e){return e?`${e}Amount`:`eurAmount`}var Oi=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{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 null}}async fetch(e,t,n={}){let r=`${this.baseUrl}${e}`;return this.post(r,t,n,0)}},ki=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 Oi({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}},Ai=typeof document<`u`?document.currentScript:null;function ji(e){return e.replace(/([-_][a-z])/gi,e=>e.toUpperCase().replace(`-`,``).replace(`_`,``))}var Mi=class extends ki{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=Ai,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=()=>{e(null)},document.head.appendChild(n)})}return await import(`./replay-V6FXES7X.efKsNT6s.js`)}catch{return 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[ji(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 Ni(e){let t=e?.split(`-`)[0]?.toLowerCase();return t===`en`||t===`fr`?t:void 0}function Pi(){return(typeof document<`u`?Ni(document.documentElement.lang):void 0)||(typeof navigator<`u`?Ni(navigator.language):void 0)}function Fi(e){let t=e.metadata.lang??Pi(),n=e.domain??(typeof window<`u`?window.location.hostname:``);return Y.setCacheScope(n,t),Y.reset(),t}const Ii=`nexus-wallet-backup`,Li=`frakwallet://`,Ri=/* @__PURE__ */ new WeakMap,zi=/* @__PURE__ */ new WeakMap;function Bi(e,t){let n=new URL(t).origin,r={createdAt:Date.now(),listenerSeen:!1};Ri.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`&&Vi(e)}};window.addEventListener(`message`,i),zi.set(e,()=>window.removeEventListener(`message`,i))}function Vi(e){zi.get(e)?.(),zi.delete(e)}function Hi(e){return Ri.get(e)}const Ui=3e4;function Wi({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`,...Gi(n,o)}),Vi(n))},Ui);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 Gi(e,t){let n=Hi(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 Ki(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=>{}),n.searchParams.delete(`sso`),window.history.replaceState({},``,n.toString()))}function qi(){let e=navigator.userAgent;return/Android/i.test(e)&&/Chrome\/\d+/i.test(e)}const Ji=/* @__PURE__ */ Li.replace(`://`,``);function Yi(e){return`intent://${e.slice(13)}#Intent;scheme=${Ji};end`}function Xi(e,t){let n=t?.timeout??2500,r=!1,i=()=>{document.hidden&&(r=!0)};document.addEventListener(`visibilitychange`,i);let a=qi()&&Zi(e)?Yi(e):e;window.location.href=a,setTimeout(()=>{document.removeEventListener(`visibilitychange`,i),r||t?.onFallback?.()},n)}function Zi(e){return e.startsWith(Li)}function Qi(){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 $i=/* @__PURE__ */ Qi();function ea(){return typeof navigator>`u`?!1:$i?!0:/Android|webOS|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}function ta(){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 na=/* @__PURE__ */ ta();function ra(){return typeof navigator>`u`?!1:navigator.userAgent.toLowerCase().includes(`instagram`)}const ia=/* @__PURE__ */ ra();function aa(e){$i&&ia&&/^https?:\/\//.test(e)?window.location.href=`instagram://extbrowser/?url=${encodeURIComponent(e)}`:$i&&e.startsWith(`https://`)?window.location.href=`x-safari-https://${e.slice(8)}`:$i&&e.startsWith(`http://`)?window.location.href=`x-safari-http://${e.slice(7)}`:window.location.href=`${q()}/common/social?u=${encodeURIComponent(e)}`}const oa={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 sa({config:e}){let t=document.querySelector(`#frak-wallet`);t&&t.remove();let n=document.createElement(`iframe`);n.id=oa.id,n.name=oa.name,n.allow=oa.allow,n.style.zIndex=oa.style.zIndex.toString(),la({iframe:n,isVisible:!1});let r=An(e?.env).wallet,i=await Mr().catch(e=>{});return pa(r),pa(q()),Bi(n,r),n.src=ca({walletUrl:r,clientId:i,preload:e?.preload}),new Promise(e=>{n.addEventListener(`load`,()=>e(n)),document.body.appendChild(n)})}function ca({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 la({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`,ua(e)):(da(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 ua(e){if(typeof e.showPopover==`function`&&!e.hasAttribute(`popover`))try{e.setAttribute(`popover`,`manual`),e.showPopover()}catch{e.removeAttribute(`popover`)}}function da(e){if(typeof e.hidePopover==`function`){try{e.hidePopover()}catch{}e.removeAttribute(`popover`)}}function fa(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{return null}}function pa(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 ma=$i&&na;function ha(e){e?localStorage.setItem(Ii,e):localStorage.removeItem(Ii)}function ga(e,t){try{let n=new URL(e);if(!n.searchParams.has(`u`))return e;let r=va(window.location.href,t);return n.searchParams.delete(`u`),n.searchParams.append(`u`,r),n.toString()}catch{return e}}function _a(e){return e.includes(`/common/social`)}function va(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 ya(e,t,n,r,i){if(i){let e=ga(t,r);window.open(e,`_blank`)}else if(Zi(t)){let i=ga(t,r);Xi(i,{onFallback:()=>{e.contentWindow?.postMessage({clientLifecycle:`deep-link-failed`,data:{originalUrl:i}},n)}})}else if(ma&&_a(t))aa(va(window.location.href,r));else{let e=ga(t,r);window.location.href=e}}function ba({iframe:e,targetOrigin:t}){let n=new bn;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`:ha(a.backup);break;case`remove-backup`:localStorage.removeItem(Ii);break;case`show`:case`hide`:la({iframe:e,isVisible:i===`show`});break;case`redirect`:ya(e,a.baseRedirectUrl,t,a.mergeToken,a.openInNewTab)}},isConnected:n.promise}}async function xa({config:e,iframe:t}){let n=An(e.env).wallet,r=Fi(e),i=Y.isCacheFresh?void 0:Y.resolve(e.domain,r),a=await Z().catch(()=>void 0),o=ba({iframe:t,targetOrigin:n}),s=new bn,c=Date.now();if(!t.contentWindow)throw new yn(vn.configError,`The iframe does not have a content window`);let l=xn({emittingTransport:t.contentWindow,listeningTransport:window,targetOrigin:n,middleware:[{async onRequest(e,t){if(!await o.isConnected)throw new yn(vn.clientNotConnected,`The iframe provider isn't connected yet`);return await s.promise,t}}],lifecycleHandlers:{iframeLifecycle:(e,t)=>{o.handleEvent(e)}}}),u=Sa(l,o),d,f=!1,p=async()=>{f=!0,u(),d?.(),l.cleanup(),t.remove(),Ln(),Y.clearCache(),Y.reset()},m,h;{m=new Mi({apiUrl:`https://op-api.gcp.frak.id`,clientId:`f305d11d-b93b-487c-80d4-92deb7903e98`,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.5.5`,...a&&{user_anonymous_client_id:a,__deviceId:a}}),!0)}),m.setGlobalProperties({sdk_version:`1.5.5`,...a&&{user_anonymous_client_id:a,__deviceId:a}}),m.init(),m.track(`sdk_initialized`,{sdk_version:`1.5.5`});let e=m;h=(t,n)=>e.track(t,n),Wi({track:h,isConnected:o.isConnected,iframe:t,startedAt:c})}let g=Da({config:e,rpcClient:l,lifecycleManager:o,configPromise:i,contextSent:s,openPanel:m,track:h,clientId:a}).then(e=>{f?e():d=e}).catch(e=>{throw s.reject(e),e});return{config:e,waitForConnection:o.isConnected,waitForSetup:g,request:l.request,listenerRequest:l.listen,destroy:p,openPanel:m}}function Sa(e,t){let n,r,i=()=>e.sendLifecycle({clientLifecycle:`heartbeat`});async function a(){i(),n=setInterval(i,250),r=setTimeout(o,Ui),await t.isConnected,o()}function o(){n&&clearInterval(n),r&&clearTimeout(r)}return a(),o}function Ca(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 wa(e,t){if(!e)return;let n=e.global??{};e.setGlobalProperties({...n,merchant_id:t.merchantId,domain:t.domain??``})}async function Ta(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 Ea({merchantId:e,anonymousId:t,pendingMergeToken:n}){let r=n?await Ta(n):void 0,[i,a,o]=await Promise.all([r?X({op:`frak-merge-v1`,merchantId:e,anonymousId:t,binding:r}):Promise.resolve(null),X({op:`frak-merge-v1`,merchantId:e,anonymousId:t}),X({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 Da({config:e,rpcClient:t,lifecycleManager:n,configPromise:r,contextSent:i,openPanel:a,track:o,clientId:s}){await n.isConnected,Ki(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;Y.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=Ca(e),i=s,o=window.location.href;return wa(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 Ea({merchantId:e.merchantId,anonymousId:i,pendingMergeToken:n})}}})}).catch(e=>{}),f};Y.isResolved&&p(Y.getConfig()).then(i.resolve),r&&(u(await r),p(Y.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(Ii)}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`),ee=v[y];if(ee?.status===`rejected`){let{reason:e}=ee,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 Oa(p)}function Oa(e){if(typeof document>`u`)return()=>{};let t=0,n=n=>{if(document.visibilityState!==`visible`||!Y.isResolved)return;let r=Date.now();n&&r-t<6e4||(t=r,e(Y.getConfig()))},r=()=>n(!0),i=setInterval(()=>n(!1),3e5);return document.addEventListener(`visibilitychange`,r),()=>{clearInterval(i),document.removeEventListener(`visibilitychange`,r)}}function ka(e){return Cn(Fr(e))}function Aa(e){try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}}function ja(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 Ma(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 Na(e){if(typeof e!=`string`)return;let t=e.trim();return t===``?void 0:t}function Pa(e){if(!e||typeof e!=`object`)return;let t=e,n={},r=Na(t.productId);r!==void 0&&(n.productId=r);let i=Na(t.sku);i!==void 0&&(n.sku=i);let a=Na(t.name);a!==void 0&&(n.name=a);let o=Ma(t.quantity);o!==void 0&&(n.quantity=o);let s=Ma(t.unitPrice);s!==void 0&&(n.unitPrice=s);let c=Ma(t.totalPrice);return c!==void 0&&(n.totalPrice=c),Object.keys(n).length>0?n:void 0}function Fa(e){let t=ja(e);if(!t)return;let n=[];for(let e of t){let t=Pa(e);t&&n.push(t)}return n.length>0?n:void 0}function Ia(e){if(!e||typeof e!=`object`)return null;let t=e,n=typeof t.title==`string`?t.title.trim():``,r=Pa(e);if(n===``&&!r)return null;let i={...r};return n!==``&&(i.title=n),typeof t.imageUrl==`string`&&Aa(t.imageUrl)&&(i.imageUrl=t.imageUrl),typeof t.link==`string`&&Aa(t.link)&&(i.link=t.link),typeof t.utmContent==`string`&&t.utmContent!==``&&(i.utmContent=t.utmContent),i}function La(e){let t=ja(e);if(!t)return;let n=[];for(let e of t){let t=Ia(e);t&&n.push(t)}return n.length>0?n:void 0}function Ra(e){if(!e)return;let t;try{t=ka(e)}catch{return}if(t!==null)return La(t)}async function za({config:e}){let t=Ba(e);Fi(t);let n=await sa({config:t});if(!n)return;let r=await xa({config:t,iframe:n});if(await r.waitForSetup,await r.waitForConnection)return r}function Ba(e){let t=bi(e.metadata.currency);return{...e,metadata:{...e.metadata,currency:t}}}function Va({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 Ha=/* @__PURE__ */ t({DEEP_LINK_SCHEME:()=>Li,FrakContextManager:()=>vi,areAddressesEqual:()=>Jr,base64urlDecode:()=>Fr,base64urlEncode:()=>Pr,baseIframeProps:()=>oa,buildListenerUrl:()=>ca,clearAllCache:()=>Ln,coerceProductCandidates:()=>ja,compressJsonToB64:()=>Ir,createIFrameFrakClient:()=>xa,decodeProductsParam:()=>Ra,decompressJsonFromB64:()=>ka,deleteQueryParamCaseInsensitive:()=>$,detectPageLanguage:()=>Pi,findIframeInOpener:()=>fa,formatAmount:()=>Ci,formatAmountParts:()=>Ti,generateSsoUrl:()=>Lr,getBackendUrl:()=>q,getClientId:()=>Nr,getClientIdAsync:()=>Z,getCurrencyAmountKey:()=>Di,getEnvironment:()=>jn,getQueryParamCaseInsensitive:()=>Gr,getSupportedCurrency:()=>bi,isIOS:()=>$i,isInAppBrowser:()=>na,isInstagramBrowser:()=>ia,isMobile:()=>ea,mergeAttribution:()=>Va,normalizeProductDetails:()=>Pa,normalizeSharingProduct:()=>Ia,redirectToExternalBrowser:()=>aa,sanitizeProductDetailsList:()=>Fa,sanitizeSharingProducts:()=>La,sdkConfigStore:()=>Y,setEnvironment:()=>An,setupClient:()=>za,ssoPopupFeatures:()=>Vr,ssoPopupName:()=>Hr,trackEvent:()=>Q,triggerDeepLinkWithFallback:()=>Xi,withCache:()=>In});const Ua=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Wa(e){if(Ua.test(e))return g(u(e,`uuid`))}async function Ga(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 Ka(e,t,n){return await e.request({method:`frak_displaySharingPage`,params:n?[t,e.config.metadata,n]:[t,e.config.metadata]})}async function qa(e){if(typeof window>`u`)return;let t=await Z().catch(()=>void 0);if(!t)return;let n=await Y.resolveMerchantId();if(!n)return;let r=`frak-identity-ensured-${n}-${t}`;if(!window.sessionStorage.getItem(r))try{let i=q(),a=await X({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 Ja({merchantId:e,checkoutToken:t}={}){let n=e??await Y.resolveMerchantId();if(!n)return;let r=Mn(),i=encodeURIComponent(Wa(n)??n),a=t?`&checkoutToken=${encodeURIComponent(t)}`:``,o=`${r}/i?m=${i}`,s=await Z().catch(()=>void 0);if(!s)return`${o}${a}`;let c=await X({op:`frak-install-v1`,merchantId:n,anonymousId:s});return c?`${o}${a}#p=${encodeURIComponent(c)}`:`${o}&a=${encodeURIComponent(Wa(s)??s)}${a}`}async function Ya(e,t){return In(()=>e.request({method:`frak_getMerchantInformation`}),{cacheKey:`frak_getMerchantInformation`,cacheTime:t?.cacheTime})}async function Xa(e,t){return In(async()=>{let t=await Z().catch(()=>void 0),n=await Y.resolveMerchantId(),r=t&&n?await X({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})}async function Za(e,t){return In(()=>e.request({method:`frak_getUserReferralStatus`}),{cacheKey:`frak_getUserReferralStatus`,cacheTime:t?.cacheTime})}async function Qa(e,t){let{metadata:n,customizations:r}=e.config;return await e.request({method:`frak_prepareSso`,params:[t,n.name,r?.css]})}async function $a(e,t){try{let n=await Z().catch(()=>void 0);await e.request({method:`frak_sendInteraction`,params:[t,{clientId:n}]})}catch{}}function eo(e,t,n){return $r(t)?(Q(e,`user_referred_started`,{referrer_client_id:t.c,referrer_wallet:t.w,wallet_status:n?.key}),$a(e,{type:`arrival`,referrerClientId:t.c,referrerMerchantId:t.m,referrerWallet:t.w,referralTimestamp:t.t}),!0):Qr(t)?(Q(e,`user_referred_started`,{referrer:t.r,wallet_status:n?.key}),$a(e,{type:`arrival`,referrerWallet:t.r}),!0):!1}function to(e,t,n){return!t&&!n?null:{v:2,m:e,t:Math.floor(Date.now()/1e3),...t?{c:t}:{},...n?{w:n}:{}}}function no(e,t,n){return $r(e)?e.w&&n?.wallet?Jr(e.w,n.wallet):e.c?t===e.c:!1:Qr(e)&&n?.wallet?Jr(e.r,n.wallet):!1}async function ro(e,{walletStatus:t,frakContext:n,options:r}){if(!n)return`no-referrer`;let i=await Z().catch(()=>void 0);if(no(n,i,t))return`self-referral`;if(!eo(e,n,t))return`no-referrer`;let a=$r(n)?n.m:r?.merchantId,o=r?.alwaysAppendUrl&&a?to(a,i,t?.wallet):null;return vi.replaceUrl({url:window.location.href,context:o}),Q(e,`user_referred_completed`,{status:`success`}),`success`}async function io(e,{options:t}={}){let n=vi.parse({url:window.location.href}),r=await co(e);try{return await ro(e,{walletStatus:r,frakContext:n,options:t})}catch{}}const ao=`frak:referral-success`;async function oo(e){try{await io(e)===`success`&&window.dispatchEvent(new Event(`frak:referral-success`))}catch{}}async function so(e){if(typeof window>`u`)return;let t=window.sessionStorage.getItem(`frak-wallet-interaction-token`),n=await Z().catch(()=>void 0);if(!t&&!n)return;let r=e.merchantId??await Y.resolveMerchantId();if(!r)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=q();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 co(e,t){if(!t)return e.request({method:`frak_listenToWalletStatus`}).then(t=>(lo(e,t),t));let n=new bn,r=!1;return e.listenerRequest({method:`frak_listenToWalletStatus`},i=>{lo(e,i),t(i),r||=(n.resolve(i),!0)}),n.promise}function lo(e,t){typeof window<`u`&&(e.openPanel?.setGlobalProperties({wallet:t.wallet??null}),t.interactionToken?(window.sessionStorage.setItem(`frak-wallet-interaction-token`,t.interactionToken),qa(t.interactionToken)):window.sessionStorage.removeItem(`frak-wallet-interaction-token`))}function uo(e,{metadata:t,login:n}){return fo(e,{steps:{login:n??{}},metadata:t})}function fo(e,t){function n(n){return fo(e,{...t,steps:{...t.steps,sendTransaction:n}})}function r(n){return fo(e,{...t,steps:{...t.steps,final:{...n,action:{key:`reward`}}}})}async function i(n,r){return n&&(t.metadata=n(t.metadata??{})),await Ga(e,t,r)}return{params:t,sendTx:n,reward:r,display:i}}async function po(e,{tx:t,metadata:n}){return(await Ga(e,{metadata:n,steps:{login:{},sendTransaction:{tx:t}}})).sendTransaction}function mo(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 ho(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 Ga(e,{metadata:n,steps:{login:{},siweAuthenticate:{siwe:{...t,statement:i,nonce:t?.nonce??mo(),uri:t?.uri??`https://${r}`,version:t?.version??`1`,domain:r}}}})).siweAuthenticate}var go=/* @__PURE__ */ t({REFERRAL_SUCCESS_EVENT:()=>ao,displayModal:()=>Ga,displaySharingPage:()=>Ka,ensureIdentity:()=>qa,getInstallUrl:()=>Ja,getMerchantInformation:()=>Ya,getMergeToken:()=>Xa,getUserReferralStatus:()=>Za,modalBuilder:()=>uo,openSso:()=>Ur,prepareSso:()=>Qa,prepareSsoUrl:()=>Br,processReferral:()=>ro,referralInteraction:()=>io,sendInteraction:()=>$a,sendTransaction:()=>po,setupReferral:()=>oo,siweAuthenticate:()=>ho,trackPurchaseStatus:()=>so,watchWalletStatus:()=>co});async function _o(e,t,n,r){window.FrakSetup?.client&&await Ka(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=>void 0)}function vo(){return typeof document>`u`||document.querySelector(`frak-button-share,frak-button-wallet,frak-open-in-app,frak-post-purchase,frak-banner`)===null?[]:[`sharing`]}const yo=`frak:client`;function bo(){let e=new CustomEvent(yo);window.dispatchEvent(e)}function xo(e,t){window.FrakSetup?.client&&e===`add`?t():(e===`add`?window.addEventListener:window.removeEventListener)(yo,t,!1)}function So(){return window.FrakSetup.core={...Ha,...go},window.FrakSetup?.client?Promise.resolve():In(()=>Co(),{cacheKey:`frak-sdk-init`,cacheTime:1/0}).catch(e=>{Q(window.FrakSetup?.client,`sdk_init_failed`,{reason:e instanceof Error?e.message:typeof e==`string`?e:`unknown`,config_missing:!window.FrakSetup?.config})})}async function Co(){if(!window.FrakSetup?.config)throw Error(`[Frak SDK] Configuration not found. Please ensure window.FrakSetup.config is set.`);let e=await za({config:wo(window.FrakSetup.config)});if(!e)throw Error(`[Frak SDK] Failed to create client`);window.FrakSetup.client=e,bo(),oo(e),To()}function wo(e){return e.preload===void 0?{...e,preload:vo()}:e}function To(){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=Ra(Gr(e.searchParams,`products`));$(e.searchParams,`frakAction`),$(e.searchParams,`link`),$(e.searchParams,`placement`),$(e.searchParams,`products`),window.history.replaceState({},``,e.toString()),Q(window.FrakSetup?.client,`sharing_page_auto_opened`,{placement:n,has_link:!!t,has_products:!!r?.length}),_o(`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) { display: none !important; }`),s(So);const Eo={ambassador:()=>import(
135
+ ;function W(){let e=globalThis?.crypto?.subtle;if(typeof e==`object`&&e)return e;throw Error(`crypto.subtle must be defined`)}function dn(e,t){return async function(n){let r=await e();return{secretKey:r,publicKey:await t(r)}}}function fn(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 pn(e){let t={...e};for(let[e,n]of Object.entries(t))Array.isArray(n)&&(t[e]=n.slice());return t}function mn(e,t){if(t.type!==e)throw Error(`invalid key type, expected ${e}`)}function hn(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 W().importKey(n,t,e,!0,a);return mn(`public`,r),r},async export(e,t){mn(`public`,e);let n=await W().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=W(),c;if(o===`raw`){let t=j(a,n,`secretKey`),o=fn(r),l=new Uint8Array(o.length+t.length);l.set(o,0),l.set(t,o.length),c=await s.importKey(cn,l,e,!0,i)}else t&&o===`jwk`&&(a={...a,key_ops:i}),c=await s.importKey(o,a,e,!0,i);return mn(`private`,c),c},async export(e,t){let r=W();if(mn(`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={}){F(t,{},{formatSec:`string`,formatPub:`string`},`opts`);let n=t.formatSec??ln,r=t.formatPub??un,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=ln){let n=await W().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=W(),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:dn(u,l),utils:Object.freeze({randomSecretKey:u,convertPublicKey:s.convert,convertSecretKey:c.convert})}}function gn(e,t){return{async sign(n,r,i={}){F(i,{},{formatSec:`string`,formatPub:`string`},`opts`);let a=Ve(j(n,void 0,`message`)),o=await e.priv.import(r,i.formatSec??ln),s=await W().sign(t,o,a);return new Uint8Array(s)},async verify(n,r,i,a={}){F(a,{},{formatSec:`string`,formatPub:`string`},`opts`);let o=Ve(j(n,void 0,`signature`)),s=Ve(j(r,void 0,`message`)),c=await e.pub.import(i,a.formatPub??un);return await W().verify(t,c,o,s)}}}function _n(e,t,n){return{async getSharedSecret(r,i,a={}){F(a,{},{formatSec:`string`,formatPub:`string`},`opts`);let o=a.formatSec===void 0?ln:a.formatSec,s=a.formatPub===void 0?un:a.formatPub,c=Oe(i)?Ve(j(i,void 0,`publicKey`)):pn(i),l=await e.priv.import(r,o),u=await e.pub.import(c,s),d=await W().deriveBits({name:typeof t==`string`?t:t.name,public:u},l,8*n);return new Uint8Array(d)}}}function vn(e,t,n,r){let i={name:`ECDH`,namedCurve:e},a=hn({name:`ECDSA`,namedCurve:e},!1,n,r),o=hn(i,!0,n,r);return Object.freeze({name:e,isSupported:a.isSupported,getPublicKey:a.getPublicKey,keygen:dn(a.utils.randomSecretKey,a.getPublicKey),...gn(a,{name:`ECDSA`,hash:{name:t}}),..._n(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 yn=/* @__PURE__ */ vn(`P-256`,`SHA-256`,32,`3041020100301306072a8648ce3d020106082a8648ce3d030107042730250201010420`),bn={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 xn=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}}},Sn=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 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);return}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 Sn;return o.set(t,e=>{e.error?n.reject(new xn(e.error.code,e.error.message,e.error.data)):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){let n=h();return o.set(n,e=>{e.error?(console.error(`[RPC Client] Listener error:`,e.error),o.delete(n)):t(e.result)}),p({id:n,topic:e.method,data:{method:e.method,params:e.params}}).catch(e=>{console.error(`[RPC Client] Failed to send listener request:`,e),o.delete(n)}),()=>{o.delete(n)}}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 G(){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},K=typeof window<`u`;function Wn(){return{isResolved:!1,merchantId:``}}let q=null;function Gn(){if(!K)return null;try{let e=localStorage.getItem(Un.key);if(!e)return null;let t=JSON.parse(e);return t.config?.isResolved?(q=t,t):null}catch{return null}}function Kn(){return(q??Gn())?.config}function qn(){let e=q??Gn();return e?Date.now()-e.timestamp<3e4:!1}function Jn(e){if(K&&e.isResolved)try{let t={config:e,timestamp:Date.now()};localStorage.setItem(Un.key,JSON.stringify(t)),q=t}catch{}}function Yn(){if(K){q=null;try{localStorage.removeItem(Un.key)}catch{}}}function Xn(){K&&(window[Bn]||(window[Bn]=Kn()??Wn()))}function Zn(){return K?(Xn(),window[Bn]??Wn()):Wn()}function Qn(e){K&&window.dispatchEvent(new CustomEvent(`frak:config`,{detail:e}))}function $n(e){return e??(K?window.location.hostname:``)}async function er(e,t){try{let n=G(),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(K)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:Zn,get isResolved(){return Zn().isResolved},get isCacheFresh(){return qn()},setCacheScope(e,t){let n=`${Vn}:${e}:${t??``}`;n!==Un.key&&(Un.key=n,q=null)},setConfig(e){if(K&&(window[Bn]=e),Jn(e),Qn(e),K&&e.merchantId)try{sessionStorage.setItem(Hn,e.merchantId)}catch{}},reset(){let e=Kn()??Wn();K&&(window[Bn]=e),Qn(e)},clearCache(){if(Yn(),zn(),K)try{sessionStorage.removeItem(Hn)}catch{}},resolve(e,t){let n=$n(e);return n?Rn(async()=>{let e=await er(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=Zn();if(e.isResolved&&e.merchantId)return e.merchantId;if(K)try{return sessionStorage.getItem(Hn)??void 0}catch{}},async resolveMerchantId(e){return J.getMerchantId()||(await J.resolve(e))?.merchantId}};function tr(){if(typeof navigator<`u`)return navigator.locks}async function nr(e,t,n={}){let r=tr();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 rr(e){return p(be(e))}const ir=`frak-client-id`,ar=`frak-client-key`,or=`frak-client-id-legacy`,sr=/* @__PURE__ */ h(`308187020100301306072a8648ce3d020106082a8648ce3d030107046d306b0201010420`),cr=/* @__PURE__ */ h(`a144034200`),lr={formatSec:`pkcs8`,formatPub:`raw`};function ur(e,t){let n=new Uint8Array(sr.length+32+cr.length+65),r=0;for(let i of[sr,e,cr,t])n.set(i,r),r+=i.length;return n}const dr=/* @__PURE__ */ (/* @__PURE__ */ new Uint8Array(32)).fill(1),fr=/* @__PURE__ */ new Uint8Array(32);let pr=null;async function mr(){try{if(!await yn.isSupported())return U;let e=ur(dr,U.getPublicKey(dr,!1));return await yn.sign(fr,e,lr),yn}catch{return U}}function hr(){return pr??=mr(),pr}function gr(e,t,n,r){if(e===yn){let e=ur(n,r);return yn.sign(t,e,lr)}return Promise.resolve(U.sign(t,n,{prehash:!0}))}const _r=()=>typeof window<`u`&&!!window.localStorage;let vr=null;function yr(e){let t=m(e);if(vr?.keyHex===t)return vr.publicKey;let n=U.getPublicKey(e,!1);return vr={keyHex:t,publicKey:n},n}function br(){if(_r())return localStorage.getItem(or)??void 0}function xr(){_r()&&localStorage.removeItem(or)}function Sr(){let e=localStorage.getItem(ar);if(!e)return null;if(!/^[0-9a-f]{64}$/i.test(e))throw Error(`[Frak SDK] Corrupt client key`);return h(e)}function Cr(e){try{for(let[t,n]of e)localStorage.setItem(t,n)}catch{}}async function wr(){if(!_r())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 nr(`frak-identity-key`,Tr)}async function Tr(){let e=localStorage.getItem(ir),t,n,r;try{t=Sr(),n=t??U.utils.randomSecretKey(),r=await rr(yr(n))}catch(e){throw localStorage.removeItem(ar),vr=null,e}if(t){e!==r&&Cr([[ir,r]]);let t=br();return{clientId:r,...t&&{pendingLegacyId:t}}}return Cr([...e?[[or,e]]:[],[ar,m(n)],[ir,r]]),{clientId:r,...e&&{pendingLegacyId:e}}}async function Y(e){if(!_r())return null;try{let t=Sr();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=yr(t),a=await hr(),o;try{o=await gr(a,r,t,i)}catch(e){if(a===U)throw e;pr=Promise.resolve(U),o=await gr(U,r,t,i)}return _({v:1,pk:i,ts:n,sig:o})}catch{return null}}function Er(){return{"x-frak-sdk-version":`1.6.0-beta.671227ad`}}const Dr=/* @__PURE__ */ new Set([`PROOF_REQUIRED`,`PROOF_OR_TOKEN_REQUIRED`,`MISSING_ANONYMOUS_ID`]);async function Or(e){if(e.status>=500||e.status===403)return!0;try{let t=await e.clone().json();return typeof t.code==`string`&&Dr.has(t.code)}catch{return!1}}async function kr({legacyId:e,derivedId:t}){typeof window<`u`&&(!e||e===t?xr():await nr(`frak-legacy-merge`,async()=>{br()===e&&await Ar({legacyId:e,derivedId:t})},{ifAvailable:!0}))}async function Ar({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=G(),a=await fetch(`${i}/user/identity/merge/initiate`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,...Er()},body:JSON.stringify({sourceAnonymousId:t,merchantId:n,proof:r})});if(!a.ok){await Or(a)||xr();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`,...Er()},body:JSON.stringify({mergeToken:o,targetAnonymousId:e,merchantId:n})});if(s.ok){xr();return}await Or(s)||xr()}catch{}}let jr=null,Mr=null;async function Nr(){return jr||Mr||(Mr=wr().then(({clientId:e,pendingLegacyId:t})=>(jr=e,t&&kr({legacyId:t,derivedId:e}),e)),Mr)}function Pr(){if(jr)return jr;Nr().catch(()=>{})}async function X(){return jr||Nr()}function Fr(e){return btoa(Array.from(e,e=>String.fromCharCode(e)).join(``)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function Ir(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 Lr(e){return Fr(wn(e))}function Rr(e,t,n,r,i,a,o){let s=Lr(zr({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 zr(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 Br(e){return{...e,directExit:e.directExit??!e.redirectUrl}}async function Vr(e,t){let{metadata:n,customizations:r}=e.config,i=Pr()??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:Rr(Pn(),Br(t),a,n.name,i,r?.css,o??void 0)}}const Hr=`menubar=no,status=no,scrollbars=no,fullscreen=no,width=500, height=800`,Ur=`frak-sso`;async function Wr(e,t){let{metadata:n,customizations:r}=e.config;if(`ssoUrl`in t)return Gr(t.ssoUrl),await e.request({method:`frak_openSso`,params:[{},n.name,r?.css]})??{};let i=Br(t);return i.openInSameWindow??!!i.redirectUrl?await e.request({method:`frak_openSso`,params:[i,n.name,r?.css]}):(Gr(i.ssoPopupUrl??(await Vr(e,i)).ssoUrl),await e.request({method:`frak_openSso`,params:[i,n.name,r?.css]})??{})}function Gr(e){let t=window.open(e,Ur,Hr);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 Kr(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 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?Fr(t):void 0}return Fr(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=Ir(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=Kr(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?(Q(e.searchParams,si),e.searchParams.set(si,r),mi(e,n),e.toString()):null}function _i(e){let t=ci(e);return t?(Q(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 J.setCacheScope(n,t),J.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 $=/* @__PURE__ */ $i();function ea(){return typeof navigator>`u`?!1:$?!0:/Android|webOS|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}function ta(){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 na=/* @__PURE__ */ ta();function ra(){return typeof navigator>`u`?!1:navigator.userAgent.toLowerCase().includes(`instagram`)}const ia=/* @__PURE__ */ ra();function aa(e){$&&ia&&/^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=`${G()}/common/social?u=${encodeURIComponent(e)}`}const oa={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 sa({config:e}){let t=document.querySelector(`#frak-wallet`);t&&t.remove();let n=document.createElement(`iframe`);n.id=oa.id,n.name=oa.name,n.allow=oa.allow,n.style.zIndex=oa.style.zIndex.toString(),la({iframe:n,isVisible:!1});let r=Mn(e?.env).wallet,i=await Nr().catch(e=>{console.warn(`[Frak SDK] Unable to derive a client id`,e)});return pa(r),pa(G()),Vi(n,r),n.src=ca({walletUrl:r,clientId:i,preload:e?.preload}),new Promise(e=>{n.addEventListener(`load`,()=>e(n)),document.body.appendChild(n)})}function ca({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 la({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`,ua(e)):(da(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 ua(e){if(typeof e.showPopover==`function`&&!e.hasAttribute(`popover`))try{e.setAttribute(`popover`,`manual`),e.showPopover()}catch{e.removeAttribute(`popover`)}}function da(e){if(typeof e.hidePopover==`function`){try{e.hidePopover()}catch{}e.removeAttribute(`popover`)}}function fa(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 pa(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 ma=$&&na;function ha(e){e?localStorage.setItem(Li,e):localStorage.removeItem(Li)}function ga(e,t){try{let n=new URL(e);if(!n.searchParams.has(`u`))return e;let r=va(window.location.href,t);return n.searchParams.delete(`u`),n.searchParams.append(`u`,r),n.toString()}catch{return e}}function _a(e){return e.includes(`/common/social`)}function va(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 ya(e,t,n,r,i){if(i){let e=ga(t,r);window.open(e,`_blank`)}else if(Qi(t)){let i=ga(t,r);Zi(i,{onFallback:()=>{e.contentWindow?.postMessage({clientLifecycle:`deep-link-failed`,data:{originalUrl:i}},n)}})}else if(ma&&_a(t))aa(va(window.location.href,r));else{let e=ga(t,r);window.location.href=e}}function ba({iframe:e,targetOrigin:t}){let n=new Sn;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`:ha(a.backup);break;case`remove-backup`:localStorage.removeItem(Li);break;case`show`:case`hide`:la({iframe:e,isVisible:i===`show`});break;case`redirect`:ya(e,a.baseRedirectUrl,t,a.mergeToken,a.openInNewTab)}},isConnected:n.promise}}async function xa({config:e,iframe:t}){let n=Mn(e.env).wallet,r=Ii(e),i=J.isCacheFresh?void 0:J.resolve(e.domain,r),a=await X().catch(()=>void 0),o=ba({iframe:t,targetOrigin:n}),s=new Sn,c=Date.now();if(!t.contentWindow)throw new xn(bn.configError,`The iframe does not have a content window`);let l=Cn({emittingTransport:t.contentWindow,listeningTransport:window,targetOrigin:n,middleware:[{async onRequest(e,t){if(!await o.isConnected)throw new xn(bn.clientNotConnected,`The iframe provider isn't connected yet`);return await s.promise,t}}],lifecycleHandlers:{iframeLifecycle:(e,n)=>{t.isConnected?o.handleEvent(e):p({detachOnly:!0})}}}),u=Sa(l,o),d,f=!1,p=async e=>{f=!0,u(),d?.(),l.cleanup(),e?.detachOnly||(t.remove(),zn(),J.clearCache(),J.reset())},m,h;{m=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.671227ad`,...a&&{user_anonymous_client_id:a,__deviceId:a}}),!0)}),m.setGlobalProperties({sdk_version:`1.6.0-beta.671227ad`,...a&&{user_anonymous_client_id:a,__deviceId:a}}),m.init(),m.track(`sdk_initialized`,{sdk_version:`1.6.0-beta.671227ad`});let e=m;h=(t,n)=>e.track(t,n),Gi({track:h,isConnected:o.isConnected,iframe:t,startedAt:c})}let g=Da({config:e,rpcClient:l,lifecycleManager:o,configPromise:i,contextSent:s,openPanel:m,track:h,clientId:a}).then(e=>{f?e():d=e}).catch(e=>{throw s.reject(e),e});return{config:e,waitForConnection:o.isConnected,waitForSetup:g,request:l.request,listenerRequest:l.listen,destroy:p,openPanel:m}}function Sa(e,t){let n,r,i=()=>e.sendLifecycle({clientLifecycle:`heartbeat`});async function a(){i(),n=setInterval(i,250),r=setTimeout(o,Wi),await t.isConnected,o()}function o(){n&&clearInterval(n),r&&clearTimeout(r)}return a(),o}function Ca(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 wa(e,t){if(!e)return;let n=e.global??{};e.setGlobalProperties({...n,merchant_id:t.merchantId,domain:t.domain??``})}async function Ta(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 be(t)}catch{return}}async function Ea({merchantId:e,anonymousId:t,pendingMergeToken:n}){let r=n?await Ta(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 Da({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;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=Ca(e),i=s,o=window.location.href;return wa(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 Ea({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(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)),ee=v.findIndex(e=>e.status===`rejected`),te=v[ee];if(te?.status===`rejected`){let{reason:e}=te,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 Oa(p)}function Oa(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 ka(e){return Tn(Ir(e))}function Aa(e){try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}}function ja(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 Ma(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 Na(e){if(typeof e!=`string`)return;let t=e.trim();return t===``?void 0:t}function Pa(e){if(!e||typeof e!=`object`)return;let t=e,n={},r=Na(t.productId);r!==void 0&&(n.productId=r);let i=Na(t.sku);i!==void 0&&(n.sku=i);let a=Na(t.name);a!==void 0&&(n.name=a);let o=Ma(t.quantity);o!==void 0&&(n.quantity=o);let s=Ma(t.unitPrice);s!==void 0&&(n.unitPrice=s);let c=Ma(t.totalPrice);return c!==void 0&&(n.totalPrice=c),Object.keys(n).length>0?n:void 0}function Fa(e){let t=ja(e);if(!t)return;let n=[];for(let e of t){let t=Pa(e);t&&n.push(t)}return n.length>0?n:void 0}function Ia(e){if(!e||typeof e!=`object`)return null;let t=e,n=typeof t.title==`string`?t.title.trim():``,r=Pa(e);if(n===``&&!r)return null;let i={...r};return n!==``&&(i.title=n),typeof t.imageUrl==`string`&&Aa(t.imageUrl)&&(i.imageUrl=t.imageUrl),typeof t.link==`string`&&Aa(t.link)&&(i.link=t.link),typeof t.utmContent==`string`&&t.utmContent!==``&&(i.utmContent=t.utmContent),i}function La(e){let t=ja(e);if(!t)return;let n=[];for(let e of t){let t=Ia(e);t&&n.push(t)}return n.length>0?n:void 0}function Ra(e){if(!e)return;let t;try{t=ka(e)}catch{return}if(t!==null)return La(t)}async function za({config:e}){let t=Ba(e);Ii(t);let n=await sa({config:t});if(!n){console.error(`Failed to create iframe`);return}let r=await xa({config:t,iframe:n});if(await r.waitForSetup,!await r.waitForConnection)console.error(`Failed to connect to client`);else return r}function Ba(e){let t=xi(e.metadata.currency);return{...e,metadata:{...e.metadata,currency:t}}}function Va({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 Ha=/* @__PURE__ */ t({DEEP_LINK_SCHEME:()=>Ri,FrakContextManager:()=>yi,areAddressesEqual:()=>Yr,base64urlDecode:()=>Ir,base64urlEncode:()=>Fr,baseIframeProps:()=>oa,buildListenerUrl:()=>ca,clearAllCache:()=>zn,coerceProductCandidates:()=>ja,compressJsonToB64:()=>Lr,createIFrameFrakClient:()=>xa,decodeProductsParam:()=>Ra,decompressJsonFromB64:()=>ka,deleteQueryParamCaseInsensitive:()=>Q,detectPageLanguage:()=>Fi,findIframeInOpener:()=>fa,formatAmount:()=>wi,formatAmountParts:()=>Ei,generateSsoUrl:()=>Rr,getBackendUrl:()=>G,getClientId:()=>Pr,getClientIdAsync:()=>X,getCurrencyAmountKey:()=>Oi,getEnvironment:()=>Nn,getQueryParamCaseInsensitive:()=>Kr,getSupportedCurrency:()=>xi,isIOS:()=>$,isInAppBrowser:()=>na,isInstagramBrowser:()=>ia,isMobile:()=>ea,mergeAttribution:()=>Va,normalizeProductDetails:()=>Pa,normalizeSharingProduct:()=>Ia,redirectToExternalBrowser:()=>aa,sanitizeProductDetailsList:()=>Fa,sanitizeSharingProducts:()=>La,sdkConfigStore:()=>J,setEnvironment:()=>Mn,setupClient:()=>za,ssoPopupFeatures:()=>Hr,ssoPopupName:()=>Ur,trackEvent:()=>Z,triggerDeepLinkWithFallback:()=>Zi,withCache:()=>Rn});function Ua(){return window.FrakSetup?.config?.rewardReminder?.enabled!==!1&&J.getConfig().components?.rewardReminder?.enabled!==!1}const Wa=`frak:client`;function Ga(){let e=new CustomEvent(Wa);window.dispatchEvent(e)}function Ka(e,t){window.FrakSetup?.client&&e===`add`?t():(e===`add`?window.addEventListener:window.removeEventListener)(Wa,t,!1)}function qa(e){typeof window.requestIdleCallback==`function`?window.requestIdleCallback(e):setTimeout(e,1)}function Ja(){import(
136
+ /* webpackChunkName: "mount-reward-reminder" */
137
+ `./mountRewardReminder.BlmSRJDe.js`).then(({mountRewardReminder:e})=>e()).catch(e=>console.error(e))}function Ya(){let e=!1,t=()=>{!e&&window.FrakSetup?.client&&J.isResolved&&!J.getConfig().hidden&&Ua()&&(e=!0,window.removeEventListener(`frak:config`,t),Ka(`remove`,t),qa(Ja))};return window.addEventListener(`frak:config`,t),Ka(`add`,t),()=>{window.removeEventListener(`frak:config`,t),Ka(`remove`,t)}}const Xa=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Za(e){if(Xa.test(e))return g(u(e,`uuid`))}async function Qa(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 $a(e,t,n){return await e.request({method:`frak_displaySharingPage`,params:n?[t,e.config.metadata,n]:[t,e.config.metadata]})}async function eo(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=G(),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,...Er()},body:JSON.stringify({merchantId:n,...a&&{proof:a}})})).ok&&window.sessionStorage.setItem(r,`1`)}catch{}}async function to({merchantId:e,checkoutToken:t}={}){let n=e??await J.resolveMerchantId();if(!n)return;let r=Pn(),i=encodeURIComponent(Za(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(Za(s)??s)}${a}`}async function no(e,t){return Rn(()=>e.request({method:`frak_getMerchantInformation`}),{cacheKey:`frak_getMerchantInformation`,cacheTime:t?.cacheTime})}async function ro(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 io(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 ao({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(`${G()}/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,...Er()}});if(!a.ok)return null;let o=await a.json();return io(o)?o:null}catch{return null}finally{clearTimeout(a)}}async function oo(e,t){return Rn(()=>e.request({method:`frak_getUserReferralStatus`}),{cacheKey:`frak_getUserReferralStatus`,cacheTime:t?.cacheTime})}async function so(e,t){let{metadata:n,customizations:r}=e.config;return await e.request({method:`frak_prepareSso`,params:[t,n.name,r?.css]})}async function co(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 lo(e,t,n){return ei(t)?(Z(e,`user_referred_started`,{referrer_client_id:t.c,referrer_wallet:t.w,wallet_status:n?.key}),co(e,{type:`arrival`,referrerClientId:t.c,referrerMerchantId:t.m,referrerWallet:t.w,referralTimestamp:t.t}),!0):$r(t)?(Z(e,`user_referred_started`,{referrer:t.r,wallet_status:n?.key}),co(e,{type:`arrival`,referrerWallet:t.r}),!0):!1}function uo(e,t,n){return!t&&!n?null:{v:2,m:e,t:Math.floor(Date.now()/1e3),...t?{c:t}:{},...n?{w:n}:{}}}function fo(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 po(e,{walletStatus:t,frakContext:n,options:r}){if(!n)return`no-referrer`;let i=await X().catch(()=>void 0);if(fo(n,i,t))return`self-referral`;if(!lo(e,n,t))return`no-referrer`;let a=ei(n)?n.m:r?.merchantId,o=r?.alwaysAppendUrl&&a?uo(a,i,t?.wallet):null;return yi.replaceUrl({url:window.location.href,context:o}),Z(e,`user_referred_completed`,{status:`success`}),`success`}async function mo(e,{options:t}={}){let n=yi.parse({url:window.location.href}),r=await vo(e);try{return await po(e,{walletStatus:r,frakContext:n,options:t})}catch(e){console.warn(`Error processing referral`,{error:e})}}const ho=`frak:referral-success`;async function go(e){try{await mo(e)===`success`&&window.dispatchEvent(new Event(`frak:referral-success`))}catch(e){console.warn(`[Frak] Referral setup failed`,e)}}async function _o(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=G();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 vo(e,t){if(!t)return e.request({method:`frak_listenToWalletStatus`}).then(t=>(yo(e,t),t));let n=new Sn,r=!1;return e.listenerRequest({method:`frak_listenToWalletStatus`},i=>{yo(e,i),t(i),r||=(n.resolve(i),!0)}),n.promise}function yo(e,t){typeof window<`u`&&(e.openPanel?.setGlobalProperties({wallet:t.wallet??null}),t.interactionToken?(window.sessionStorage.setItem(`frak-wallet-interaction-token`,t.interactionToken),eo(t.interactionToken)):window.sessionStorage.removeItem(`frak-wallet-interaction-token`))}function bo(e,{metadata:t,login:n}){return xo(e,{steps:{login:n??{}},metadata:t})}function xo(e,t){function n(n){return xo(e,{...t,steps:{...t.steps,sendTransaction:n}})}function r(n){return xo(e,{...t,steps:{...t.steps,final:{...n,action:{key:`reward`}}}})}async function i(n,r){return n&&(t.metadata=n(t.metadata??{})),await Qa(e,t,r)}return{params:t,sendTx:n,reward:r,display:i}}async function So(e,{tx:t,metadata:n}){return(await Qa(e,{metadata:n,steps:{login:{},sendTransaction:{tx:t}}})).sendTransaction}function Co(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 wo(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 Qa(e,{metadata:n,steps:{login:{},siweAuthenticate:{siwe:{...t,statement:i,nonce:t?.nonce??Co(),uri:t?.uri??`https://${r}`,version:t?.version??`1`,domain:r}}}})).siweAuthenticate}var To=/* @__PURE__ */ t({REFERRAL_SUCCESS_EVENT:()=>ho,displayModal:()=>Qa,displaySharingPage:()=>$a,ensureIdentity:()=>eo,getInstallUrl:()=>to,getMerchantInformation:()=>no,getMergeToken:()=>ro,getRewardSummary:()=>ao,getUserReferralStatus:()=>oo,modalBuilder:()=>bo,openSso:()=>Wr,prepareSso:()=>so,prepareSsoUrl:()=>Vr,processReferral:()=>po,referralInteraction:()=>mo,sendInteraction:()=>co,sendTransaction:()=>So,setupReferral:()=>go,siweAuthenticate:()=>wo,trackPurchaseStatus:()=>_o,watchWalletStatus:()=>vo});async function Eo(e,t,n,r){window.FrakSetup?.client?await $a(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 Do(){return typeof document>`u`||document.querySelector(`frak-button-share,frak-button-wallet,frak-open-in-app,frak-post-purchase,frak-banner`)===null?[]:[`sharing`]}function Oo(){return window.FrakSetup.core={...Ha,...To},window.FrakSetup?.client?Promise.resolve():Rn(()=>ko(),{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 ko(){if(!window.FrakSetup?.config)throw Error(`[Frak SDK] Configuration not found. Please ensure window.FrakSetup.config is set.`);let e=await za({config:Ao(window.FrakSetup.config)});if(!e)throw Error(`[Frak SDK] Failed to create client`);window.FrakSetup.client=e,Ga(),go(e),jo()}function Ao(e){return e.preload===void 0?{...e,preload:Do()}:e}function jo(){let e=new URL(window.location.href);if(Kr(e.searchParams,`frakAction`)?.toLowerCase()!==`share`)return;let t=Kr(e.searchParams,`link`)??void 0,n=Kr(e.searchParams,`placement`)??void 0,r=Ra(Kr(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}),Eo(`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(Oo),Ya();const Mo={ambassador:()=>import(
135
138
  /* webpackChunkName: "ambassador" */
136
- `./Ambassador.BDu4aVZ9.js`),"button-share":()=>import(
139
+ `./Ambassador.Cmb0kX5D.js`),"button-share":()=>import(
137
140
  /* webpackChunkName: "button-share" */
138
- `./ButtonShare.C7A2tEvB.js`),"button-wallet":()=>import(
141
+ `./ButtonShare.DSGvJfJ-.js`),"button-wallet":()=>import(
139
142
  /* webpackChunkName: "button-wallet" */
140
- `./ButtonWallet.Cg2OK1di.js`),"open-in-app":()=>import(
143
+ `./ButtonWallet.DHpHCl4c.js`),"open-in-app":()=>import(
141
144
  /* webpackChunkName: "open-in-app" */
142
- `./OpenInAppButton.Djz_cb9Y.js`),"post-purchase":()=>import(
145
+ `./OpenInAppButton.CxBzRNKw.js`),"post-purchase":()=>import(
143
146
  /* webpackChunkName: "post-purchase" */
144
- `./PostPurchase.DIZneqoT.js`),banner:()=>import(
147
+ `./PostPurchase.C75q-9BM.js`),banner:()=>import(
145
148
  /* webpackChunkName: "banner" */
146
- `./Banner.BqfCxKs3.js`)},Do=new MutationObserver(e=>{for(let{addedNodes:t}of e)for(let e of Array.from(t))e.nodeType===Node.ELEMENT_NODE&&Oo(e)});async function Oo(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=>ko(e)))}async function ko(e){if(customElements.get(e))return Promise.resolve();let t=e.replace(/^frak-/i,``);if(t in Eo)try{await Eo[t]()}catch{}}Oo(document.body),Do.observe(document.documentElement,{subtree:!0,childList:!0});export{Q as C,s as D,yn as E,o as O,bi as S,vn as T,Fa as _,ao as a,Ti as b,Ya as c,aa as d,na as f,Li as g,Pi as h,so as i,n as k,Xa as l,ea as m,xo as n,Ja as o,Xi as p,_o as r,Za as s,So as t,La as u,Di as v,Y as w,Ei as x,Ci as y};
149
+ `./Banner.2WJ4pT6E.js`),"reward-reminder":()=>import(
150
+ /* webpackChunkName: "reward-reminder" */
151
+ `./RewardReminder.C6o8lgak.js`)},No=new MutationObserver(e=>{for(let{addedNodes:t}of e)for(let e of Array.from(t))e.nodeType===Node.ELEMENT_NODE&&Po(e)});async function Po(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=>Fo(e)))}async function Fo(e){if(customElements.get(e))return Promise.resolve();let t=e.replace(/^frak-/i,``);if(!(t in Mo))console.error(`Component ${e} is not supported.`);else try{await Mo[t]()}catch(e){console.error(e)}}Po(document.body),No.observe(document.documentElement,{subtree:!0,childList:!0});export{bn as A,Ei as C,J as D,Z as E,s as M,o as N,Pr as O,n as P,wi as S,xi as T,ea as _,oo as a,Fa as b,ao as c,Ua as d,La as f,Zi as g,$ as h,_o as i,xn as j,Nn as k,ro as l,na as m,Eo as n,to as o,aa as p,ho as r,no as s,Oo as t,Ka as u,Fi as v,Di as w,Oi as x,Ri as y};
@@ -0,0 +1 @@
1
+ import{n as e,r as t,s as n}from"./rewardSummaryStore.DyjI-vPH.js";const r=`frak-reward-reminder`;async function i(){if(document.querySelector(r)||n())return;let i=await t();e(i)&&!document.querySelector(r)&&document.body.append(document.createElement(r))}export{i as mountRewardReminder};
@@ -0,0 +1 @@
1
+ import{n as e}from"./jsxRuntime.module.7FJBZ9bf.js";import{t}from"./format.D2Ai5cCn.js";function n(n,r){let i=e[r].rewardReminder;return n<=0?i.countdownToday:n===1?i.countdownOneDay:t(i.countdownDays,{days:n})}function r(e=Date.now()){return{total:{eurAmount:12.5,usdAmount:13.5,gbpAmount:10.5},cashback:{eurAmount:10,usdAmount:10.8,gbpAmount:8.4},fromFriends:{eurAmount:2.5,usdAmount:2.7,gbpAmount:2.1},count:2,lockedCount:0,nextUnlockAt:null,expiresAt:new Date(e+10368e5).toISOString()}}export{n,r as t};
@@ -0,0 +1 @@
1
+ function e(){return()=>{}}var t=null;function n(n,r){if(typeof document>`u`||typeof window>`u`)return;t&&t();let i=n.maxEventsPerChunk??200,a=n.flushIntervalMs??1e4,o=n.maxPayloadBytes??1048576,s=[],c=0,l=null;function u(e){if(s.length===0)return;let t=JSON.stringify(s);if(new TextEncoder().encode(t).length>o){if(s.length>1){let t=Math.floor(s.length/2),n=s.slice(0,t),r=s.slice(t),i=e&&n.some(e=>e.type===2);s=n,u(i),s=r,u(!1);return}s=[];return}let n=s[0].timestamp,i=s[s.length-1].timestamp;try{r({chunk_index:c,events_count:s.length,is_full_snapshot:e,started_at:new Date(n).toISOString(),ended_at:new Date(i).toISOString(),payload:t}),c+=1,s=[]}catch(e){throw console.error(`[ReplayRecorder] sendChunk failed`,e),e}}function d(e){let t=e||s.some(e=>e.type===2);s.length>=i?u(t):e&&s.length>0&&u(!0)}let f=n.maskAllText!==!1,p=n.unmaskTextSelector,m=e({emit(e,t){s.push(e),d(!!t)},checkoutEveryNms:a,maskAllInputs:n.maskAllInputs??!0,maskTextSelector:f?`*`:`[data-openpanel-replay-mask]`,maskTextFn:f&&p?(e,t)=>t?.closest(p)?e:e.replace(/\S/g,`*`):void 0,blockSelector:n.blockSelector??`[data-openpanel-replay-block]`,blockClass:n.blockClass,ignoreSelector:n.ignoreSelector});l=setInterval(()=>{s.length>0&&u(s.some(e=>e.type===2))},a);function h(){document.visibilityState===`hidden`&&s.length>0&&u(s.some(e=>e.type===2))}function g(){s.length>0&&u(s.some(e=>e.type===2))}document.addEventListener(`visibilitychange`,h),window.addEventListener(`pagehide`,g),t=()=>{s.length>0&&u(s.some(e=>e.type===2)),l&&=(clearInterval(l),null),document.removeEventListener(`visibilitychange`,h),window.removeEventListener(`pagehide`,g),m?.(),t=null}}function r(){t&&t()}export{n as startReplayRecorder,r as stopReplayRecorder};
@@ -0,0 +1 @@
1
+ import{D as e,O as t,c as n,r}from"./loader.js";const i=`frak:reward-reminder-dismissed`;function a(){return`frak-reward-reminder-dismissed-${e.getConfig().merchantId??`unknown`}`}function o(){try{return window.sessionStorage.getItem(a())===`1`}catch{return!1}}function s(){try{window.sessionStorage.setItem(a(),`1`)}catch{}window.dispatchEvent(new CustomEvent(i))}function c(e){return window.addEventListener(i,e),()=>window.removeEventListener(i,e)}const l=`frak-reward-summary-`;let u={status:`idle`,summary:null},d=null,f=0,p=!1,m=!1,h=!1;const g=/* @__PURE__ */ new Set;function _(e){u=e;for(let e of g)e()}function v(e){let n=t();return n?`${l}${e}-${n}`:void 0}function y(e){return e.pending?window.sessionStorage:window.localStorage}function b(e){let t=v(e);if(!t)return null;for(let[e,n]of[[window.sessionStorage,6e5],[window.localStorage,36e5]])try{let r=e.getItem(t);if(!r)continue;let i=JSON.parse(r);if(Date.now()-i.at<n)return i.summary;e.removeItem(t)}catch{}return null}function x(e,t){let n=v(e);if(n)try{let e={at:Date.now(),summary:t};y(t).setItem(n,JSON.stringify(e))}catch{}}function S(){for(let e of[window.sessionStorage,window.localStorage])try{let t=[];for(let n=0;n<e.length;n++){let r=e.key(n);r?.startsWith(l)&&t.push(r)}for(let n of t)e.removeItem(n)}catch{}}function C(){p||typeof window>`u`||(p=!0,window.addEventListener(r,O))}function w(){h&&document.visibilityState!==`hidden`&&(h=!1,O())}function T(e){e.persisted&&w()}function E(){h=!0,m||typeof window>`u`||(m=!0,document.addEventListener(`visibilitychange`,w),window.addEventListener(`pageshow`,T))}function D(){if(C(),u.status===`ready`)return Promise.resolve(u.summary);if(d)return d;let t=f;return _({status:`loading`,summary:u.summary}),d=(async()=>{let r=await e.resolveMerchantId(),i=r?b(r):null,a=i??(r?await n({merchantId:r}):null);return t===f&&(a&&r&&!i&&x(r,a),_({status:`ready`,summary:a})),a})().catch(()=>(t===f&&_({status:`ready`,summary:null}),null)).finally(()=>{t===f&&(d=null)}),d}function O(){f+=1,d=null,S(),_({status:`idle`,summary:u.summary})}function k(){return u}function A(e){return g.add(e),()=>g.delete(e)}function j(e){return e!==null&&Date.parse(e)<=Date.now()}function M(e){return!!e&&!e.linked&&!!e.pending&&e.pending.count>0&&!j(e.pending.expiresAt)}export{A as a,c,E as i,M as n,s as o,D as r,o as s,k as t};